@gamelearn/arcade-components 3.18.3 → 3.18.4
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(l,e,n=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,a=e.onDragEnd||e.onDragMove;t&&!a&&(console.warn(DRAGGABLE_WARNING),dragWarningShowed=!0)}for(var o in n)if(!propsToSkip[o]){var d=o.slice(0,2)==="on",f=n[o]!==e[o];if(d&&f){var h=o.substr(2).toLowerCase();h.substr(0,7)==="content"&&(h="content"+h.substr(7,1).toUpperCase()+h.substr(8)),l.off(h,n[o])}var u=!e.hasOwnProperty(o);u&&l.setAttr(o,void 0)}var p=e._useStrictMode,x={},R=!1;const S={};for(var o in e)if(!propsToSkip[o]){var d=o.slice(0,2)==="on",E=n[o]!==e[o];if(d&&E){var h=o.substr(2).toLowerCase();h.substr(0,7)==="content"&&(h="content"+h.substr(7,1).toUpperCase()+h.substr(8)),e[o]&&(S[h]=e[o])}!d&&(e[o]!==n[o]||p&&e[o]!==l.getAttr(o))&&(R=!0,x[o]=e[o])}R&&(l.setAttrs(x),updatePicture(l));for(var h in S)l.on(h+EVENTS_NAMESPACE,S[h])}function updatePicture(l){if(!Global.Konva.autoDrawEnabled){var e=l.getLayer()||l.getStage();e&&e.batchDraw()}}var schedulerExports=requireScheduler();const NO_CONTEXT={},UPDATE_SIGNAL={};Konva.Node.prototype._applyProps=applyNodeProps;function appendInitialChild(l,e){if(typeof e=="string"){console.error(`Do not use plain text as child of Konva.Node. You are using text: ${e}`);return}l.add(e),updatePicture(l)}function createInstance(l,e,n){let t=Konva[l];t||(console.error(`Konva has no node with the type ${l}. Group will be used instead. If you use minimal version of react-konva, just import required nodes into Konva: "import "konva/lib/shapes/${l}" 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 a={},o={};for(var d in e){var f=d.slice(0,2)==="on";f?o[d]=e[d]:a[d]=e[d]}const h=new t(a);return applyNodeProps(h,o),h}function createTextInstance(l,e,n){console.error(`Text components are not supported for now in ReactKonva. Your text is: "${l}"`)}function finalizeInitialChildren(l,e,n){return!1}function getPublicInstance(l){return l}function prepareForCommit(){return null}function preparePortalMount(){return null}function prepareUpdate(l,e,n,t){return UPDATE_SIGNAL}function resetAfterCommit(){}function resetTextContent(l){}function shouldDeprioritizeSubtree(l,e){return!1}function getRootHostContext(){return NO_CONTEXT}function getChildHostContext(){return NO_CONTEXT}const scheduleTimeout=setTimeout,cancelTimeout=clearTimeout,noTimeout=-1;function shouldSetTextContent(l,e){return!1}const isPrimaryRenderer=!1,warnsIfNotActing=!0,supportsMutation=!0;function appendChild(l,e){e.parent===l?e.moveToTop():l.add(e),updatePicture(l)}function appendChildToContainer(l,e){e.parent===l?e.moveToTop():l.add(e),updatePicture(l)}function insertBefore(l,e,n){e._remove(),l.add(e),e.setZIndex(n.getZIndex()),updatePicture(l)}function insertInContainerBefore(l,e,n){insertBefore(l,e,n)}function removeChild(l,e){e.destroy(),e.off(EVENTS_NAMESPACE),updatePicture(l)}function removeChildFromContainer(l,e){e.destroy(),e.off(EVENTS_NAMESPACE),updatePicture(l)}function commitTextUpdate(l,e,n){console.error(`Text components are not yet supported in ReactKonva. You text is: "${n}"`)}function commitMount(l,e,n){}function commitUpdate(l,e,n,t,a){applyNodeProps(l,a,t)}function hideInstance(l){l.hide(),updatePicture(l)}function hideTextInstance(l){}function unhideInstance(l,e){(e.visible==null||e.visible)&&l.show()}function unhideTextInstance(l,e){}function clearContainer(l){}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=(l,e,n)=>e in l?__defProp(l,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):l[e]=n,__spreadValues=(l,e)=>{for(var n in e||(e={}))__hasOwnProp.call(e,n)&&__defNormalProp(l,n,e[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(e))__propIsEnum.call(e,n)&&__defNormalProp(l,n,e[n]);return l},__spreadProps=(l,e)=>__defProps(l,__getOwnPropDescs(e));function traverseFiber(l,e,n){if(!l)return;if(n(l)===!0)return l;let t=e?l.return:l.child;for(;t;){const a=traverseFiber(t,e,n);if(a)return a;t=e?null:t.sibling}}function wrapContext(l){try{return Object.defineProperties(l,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return l}}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 l=React__namespace.useContext(FiberContext);if(l===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,l,l==null?void 0:l.alternate]){if(!t)continue;const a=traverseFiber(t,!1,o=>{let d=o.memoizedState;for(;d;){if(d.memoizedState===e)return!0;d=d.next}});if(a)return a}},[l,e])}function useContextMap(){var l,e;const n=useFiber(),[t]=React__namespace.useState(()=>new Map);t.clear();let a=n;for(;a;){const o=(l=a.type)==null?void 0:l._context;o&&o!==FiberContext&&!t.has(o)&&t.set(o,(e=ReactCurrentDispatcher==null?void 0:ReactCurrentDispatcher.current)==null?void 0:e.readContext(wrapContext(o))),a=a.return}return t}function useContextBridge(){const l=useContextMap();return React__namespace.useMemo(()=>Array.from(l.keys()).reduce((e,n)=>t=>React__namespace.createElement(e,null,React__namespace.createElement(n.Provider,__spreadProps(__spreadValues({},t),{value:l.get(n)}))),e=>React__namespace.createElement(FiberProvider,__spreadValues({},e))),[l])}function usePrevious(l){const e=React$2.useRef({});return React$2.useLayoutEffect(()=>{e.current=l}),React$2.useLayoutEffect(()=>()=>{e.current={}},[]),e.current}const StageWrap=l=>{const e=React$2.useRef(),n=React$2.useRef(),t=React$2.useRef(),a=usePrevious(l),o=useContextBridge(),d=f=>{const{forwardedRef:h}=l;h&&(typeof h=="function"?h(f):h.current=f)};return React$2.useLayoutEffect(()=>(n.current=new Konva.Stage({width:l.width,height:l.height,container:e.current}),d(n.current),t.current=KonvaRenderer.createContainer(n.current,constantsExports.LegacyRoot,!1,null),KonvaRenderer.updateContainer(React$2.createElement(o,{},l.children),t.current),()=>{Konva.isBrowser&&(d(null),KonvaRenderer.updateContainer(null,t.current,null),n.current.destroy())}),[]),React$2.useLayoutEffect(()=>{d(n.current),applyNodeProps(n.current,l,a),KonvaRenderer.updateContainer(React$2.createElement(o,{},l.children),t.current,null)}),React$2.createElement("div",{ref:e,id:l.id,accessKey:l.accessKey,className:l.className,role:l.role,style:l.style,tabIndex:l.tabIndex,title:l.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((l,e)=>React$2.createElement(FiberProvider,{},React$2.createElement(StageWrap,{...l,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(l,e){i.usingClientEntryPoint=!0;try{return m.createRoot(l,e)}finally{i.usingClientEntryPoint=!1}},client.hydrateRoot=function(l,e,n){i.usingClientEntryPoint=!0;try{return m.hydrateRoot(l,e,n)}finally{i.usingClientEntryPoint=!1}}}var __rest=function(l,e){var n={};for(var t in l)Object.prototype.hasOwnProperty.call(l,t)&&e.indexOf(t)<0&&(n[t]=l[t]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,t=Object.getOwnPropertySymbols(l);a<t.length;a++)e.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(l,t[a])&&(n[t[a]]=l[t[a]]);return n};const needForceStyle=l=>{const e=window.getComputedStyle(l).position;return!(e==="absolute"||e==="relative")};function useEvent(l=()=>{}){const e=React$2.useRef(l);return e.current=l,React$2.useCallback((...n)=>e.current.apply(null,n),[])}const Html=({children:l,groupProps:e,divProps:n,transform:t,transformFunc:a})=>{const o=React$2.useRef(null);React$2.useRef();const[d]=React$2.useState(()=>document.createElement("div")),f=React$2.useMemo(()=>client.createRoot(d),[d]),h=t??!0,u=useEvent(()=>{if(h&&o.current){let E=o.current.getAbsoluteTransform().decompose();a&&(E=a(E)),d.style.position="absolute",d.style.zIndex="10",d.style.top="0px",d.style.left="0px",d.style.transform=`translate(${E.x}px, ${E.y}px) rotate(${E.rotation}deg) scaleX(${E.scaleX}) scaleY(${E.scaleY})`,d.style.transformOrigin="top left"}else d.style.position="",d.style.zIndex="",d.style.top="",d.style.left="",d.style.transform="",d.style.transformOrigin="";const p=n||{},{style:x}=p,R=__rest(p,["style"]);Object.assign(d.style,x),Object.assign(d,R)});return React$2.useLayoutEffect(()=>{var p;const x=o.current;if(!x)return;const R=(p=x.getStage())===null||p===void 0?void 0:p.container();if(R)return R.appendChild(d),h&&needForceStyle(R)&&(R.style.position="relative"),x.on("absoluteTransformChange",u),u(),()=>{var S;x.off("absoluteTransformChange",u),(S=d.parentNode)===null||S===void 0||S.removeChild(d)}},[h]),React$2.useLayoutEffect(()=>{u()},[n,a]),React$2.useLayoutEffect(()=>{f.render(l)}),React$2.useLayoutEffect(()=>()=>{setTimeout(()=>{f.unmount()})},[]),React$2.createElement(Group,Object.assign({ref:o},e))};function Area({area:l,finished:e,isClicked:n,isBad:t,hasHighlights:a,completed:o,onClick:d,onClickOutside:f}){const h=React$2.useRef(),[u,p]=React$2.useState(),x=t?"rgba(255, 99, 77, 0.32)":"rgba(75, 215, 169, 0.32)",R=t?"#ff634d":"#4bd7a9",S=DeviceDetection(),E=()=>{var _,w,C;a&&!o&&!n&&((_=h.current)==null||_.setAttr("fill","rgba(130, 134, 142, 0.4)"),(w=h.current)==null||w.setAttr("stroke","rgba(255, 255, 255, 0.3)"),(C=h.current)==null||C.to({duration:.25,opacity:1}))},g=()=>{var _;a&&!o&&!n&&((_=h.current)==null||_.to({duration:.25,opacity:0}))};React$2.useEffect(()=>{var _,w,C;o&&!e&&(t?(C=h.current)==null||C.to({duration:.25,opacity:0}):((_=h.current)==null||_.to({duration:.25,opacity:1}),(w=h.current)==null||w.globalCompositeOperation("destination-out")))},[o,e,t]);const v=()=>{var _,w;o||(t?f(l):d(l),(_=h.current)==null||_.setAttr("fill",x),(w=h.current)==null||w.setAttr("stroke",R))},T=l.scaleX?l.scaleX:1,b=l.scaleY?l.scaleY:1;return React$2.useLayoutEffect(()=>{const _=h.current.getStage();_.on("stage-loaded",()=>{const w=h.current.getClientRect({relativeTo:h.current.getParent()});p({x:w.x+w.width/2,y:w.y+w.height/2}),_.batchDraw()})},[l]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[u?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...u},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:l.id})}):null,jsxRuntimeExports.jsx(Line,{name:l.id,ref:h,onFocus:()=>E(),onMouseOver:()=>E(),onMouseLeave:g,onClick:()=>v(),onTap:()=>v(),x:l.x,y:l.y,scale:{x:T,y:b},skew:{x:l.skewX,y:l.skewY},rotation:l.rotation,points:l.points,shape:"poly",fill:e?"":x,stroke:e||n?R:"",strokeWidth:S?10:4,opacity:e||n?1:0,closed:!0})]})}Area.defaultProps={finished:!1,isBad:!1,isClicked:!1,hasHighlights:!1,completed:!1,onClick:()=>{},onClickOutside:()=>{}};const useWindowSize=()=>{const[l,e]=React$2.useState([0,0]);return React$2.useLayoutEffect(()=>{function n(){e([window.innerWidth,window.innerHeight])}return window.addEventListener("resize",n),n(),()=>window.removeEventListener("resize",n)},[]),l};function KonvaMapper({areas:l,badAreas:e,imageUrl:n,completed:t,onClick:a,onClickOutside:o,hasHighlights:d,clickedZones:f}){const h=React$2.useRef(),u=React$2.useRef(),p=React$2.useRef(),x=React$2.useRef(),R=React$2.useRef(),S=React$2.useRef(),E=React$2.useRef(),[g,v]=React$2.useState(new window.Image),[T,b]=useWindowSize(),_=e.find(P=>P.id==="AllArea")||!1,w=e.filter(P=>P.id!=="AllArea");React$2.useEffect(()=>{E.current&&u.current&&t&&(E.current.to({duration:.25,opacity:.5}),u.current.setAttr("visible",!0))},[t]);const C=P=>{_&&!P.target.attrs.shape&&o(_)};return React$2.useEffect(()=>{g.src=n,g.addEventListener("load",()=>{if(h.current){const P={x:T/2,y:b/2,width:g.width,height:g.height,offsetX:g.width/2,offsetY:g.height/2,scale:{x:Math.min(T/g.width,b/g.height),y:Math.min(T/g.width,b/g.height)}};x.current&&x.current.setAttrs(P),R.current&&R.current.setAttrs(P),u.current&&u.current.setAttrs(P),p.current&&p.current.setAttrs(P),S.current&&S.current.setAttrs(P),h.current.batchDraw(),v(g),h.current.fire("stage-loaded")}})},[g,b,n,T]),jsxRuntimeExports.jsxs(Stage,{ref:h,width:T,height:b,onClick:C,onTouchEnd:C,children:[jsxRuntimeExports.jsx(Layer,{children:jsxRuntimeExports.jsx(Image$2,{ref:S,image:g})}),jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Rect,{ref:E,width:T,height:b,fill:"black",opacity:0}),jsxRuntimeExports.jsx(Group,{ref:R,children:w.map((P,D)=>jsxRuntimeExports.jsx(Area,{hasHighlights:d,completed:t,onClick:a,onClickOutside:o,area:P,isBad:!0},P.name+"_"+D))}),jsxRuntimeExports.jsx(Group,{ref:x,children:l.map((P,D)=>jsxRuntimeExports.jsx(Area,{hasHighlights:d,completed:t,onClick:a,onClickOutside:o,area:P,isClicked:f.some(N=>N.index===P.index)},P.name+"_"+D))}),jsxRuntimeExports.jsx(Group,{ref:p,visible:!1,children:w.map((P,D)=>jsxRuntimeExports.jsx(Area,{hasHighlights:d,completed:t,onClick:a,onClickOutside:o,area:P,isBad:!0,finished:!0},P.name+"_"+D))}),jsxRuntimeExports.jsx(Group,{ref:u,visible:!1,children:l.map((P,D)=>jsxRuntimeExports.jsx(Area,{hasHighlights:d,completed:t,onClick:a,onClickOutside:o,area:P,finished:!0},P.name+"_"+D))})]})]})}KonvaMapper.defaultProps={hasHighlights:!1,onClick:()=>{},completed:!1,onClickOutside:()=>{}};function TimerDialog({retry:l,translate:e,onInit:n}){return jsxRuntimeExports.jsx("div",{className:"timer-dialog",children:jsxRuntimeExports.jsxs("div",{className:"timer-dialog__container",children:[jsxRuntimeExports.jsx("div",{className:"timer-dialog__title",children:e("storylines.misc.ready")}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:n,children:jsxRuntimeExports.jsx("span",{children:e(l?"storylines.misc.start":"storylines.misc.retry")})})]})})}function CountDown({time:l}){const e=Math.floor(l/60),n=l%60;return jsxRuntimeExports.jsx("div",{className:`count-down count-down--in-puzzle-frame ${l<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{children:[e<10?`0${e}`:e," : ",n<10?`0${Math.floor(n)}`:Math.floor(n)]})})}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(l){var Xe,Ye;const{soundActions:e,emitEvent:n,handleClick:t,disableExit:a,setResolveAction:o,info:d,image:f,areas:h,badAreas:u,hasClickOrder:p,timer:x,hasClickOnce:R,hasHighlights:S,hasImageReview:E,defaultCompleted:g,className:v,emitFinish:T,emitResolve:b,translateFromParent:_,specificFeedbacks:w,slideNumber:C,emitResetPuzzle:P,firstTryForFrame:D,puzzlesAutoCompleted:N,emitOpenPopupCounterInfo:k,pause:F,keyboardControl:M}=l,[U,$]=React$2.useState([]),[B,J]=React$2.useState(!1),[re,ae]=React$2.useState(!1),[Q,K]=React$2.useState({show:!1,success:!1,text:"",rewards:[]}),ne=React$2.useRef(!1),[ue,fe]=React$2.useState(!0),[te,H]=React$2.useState(!1),W=React$2.useRef(null),V=React$2.useRef(null),z=React$2.useRef(null),q=React$2.useRef(null),ee=React$2.useRef(null),le=React$2.useRef(null),ce=React$2.useRef(null),he=React$2.useRef(null),ve=React$2.useRef(null),[be,Re]=React$2.useState(x),Le=Pe=>_?_(Pe):n({type:"translate",payload:Pe}),[Oe]=e,{solution:Ke}=d,St=f.img.url||defaultImg,it=h.map((Pe,Ae)=>({index:Ae,shape:"poly",...Pe})),gt=u.map((Pe,Ae)=>({index:Ae,shape:"poly",...Pe})),Ge=React$2.useCallback(()=>{if(!ue){const Pe=setInterval(()=>{Re(Ae=>Ae>1?Ae-1:0)},1e3);ve.current=Pe}},[ue]),Me=React$2.useCallback((Pe,Ae)=>{T?T(Pe,Ae):n({type:"addPoints",payload:Pe})},[n,T]);React$2.useEffect(()=>{B&&a(!0)},[B,a]),React$2.useEffect(()=>{J(g)},[g]);const De=React$2.useCallback(()=>{clearInterval(z.current)},[]),Ve=React$2.useCallback(()=>{clearInterval(ve.current)},[]),ct=React$2.useCallback(Pe=>{ee.current=Date.now(),q.current?(ce.current=q.current-ee.current,De()):(ce.current=ee.current-(ee.current-Pe*1e3),De())},[De]),dt=React$2.useCallback(()=>{K(()=>{var Pe,Ae;return{show:!0,success:!1,text:(Pe=d==null?void 0:d.timerFeedback)!=null&&Pe.desc?d.timerFeedback.desc:"",rewards:(Ae=d==null?void 0:d.timerFeedback)==null?void 0:Ae.rewards}}),H(!0),Ve(),De()},[Ve,De,(Xe=d.timerFeedback)==null?void 0:Xe.desc,(Ye=d.timerFeedback)==null?void 0:Ye.rewards]),rt=React$2.useCallback(()=>{clearInterval(z.current),z.current=setInterval(()=>{V.current=Date.now(),V.current>q.current&&dt()},250)},[dt]);React$2.useEffect(()=>{var Pe;if((h.length===U.length||R&&U.length>0)&&!B){J(!0);const Ae=U[U.length-1],_e=w==null?void 0:w.correctFeedbacks.find(Ie=>Ie.id===Ae.id);(!((Pe=w==null?void 0:w.correctFeedbacks)!=null&&Pe.length)||w!=null&&w.correctFeedbacks.some(Ie=>!Ie.desc)||R)&&(K(Ie=>({...Ie,show:!0,success:!0,text:_e?_e.desc:d.solution.right.desc,rewards:_e?_e.rewards:d.solution.right.rewards})),x&&(Ve(),ct()))}},[U,h.length,w,R,B,d.solution.right,ct,x,Ve]),React$2.useEffect(()=>{o(Pe=>{x&&(Ve(),fe(!1),Q.show?K(Ae=>({...Ae,show:!1,success:!1,text:"",rewards:[]})):De()),J(!0),ae(!0),setTimeout(()=>{b?b(Pe):Pe()},4e3)})},[o,b,Oe,x,Q.show,De,Ve]),React$2.useEffect(()=>{re&&a(!0)},[re,a]);const xt=(Pe,Ae=!1)=>{var _e,Ie;if(!B){const{rewards:tt,desc:Gt}=Ke.wrong;let Dt=Gt,ke=tt;const mt=(_e=w==null?void 0:w.wrongFeedbacks)==null?void 0:_e.find(Pt=>Pt.id===Pe.id);mt&&(Dt=mt.desc,ke=mt.rewards),p&&($([]),Ae&&(Ie=d==null?void 0:d.orderFeedback)!=null&&Ie.desc&&(Dt=d.orderFeedback.desc,ke=d.orderFeedback.rewards)),x&&(Ve(),ct()),K(Pt=>({...Pt,show:!0,success:!1,text:Dt,rewards:ke})),Oe("fail")}},Et=React$2.useCallback(()=>{le.current=Date.now();const Pe=le.current+ce.current;V.current=null,q.current=Pe,(x||te)&&(Q.success?h.length===U.length||R&&U.length>0?Ve():(Re(ce.current*.001),Ge(),rt()):($([]),fe(!0),P())),Me(Q.rewards,Q.success),Oe("click-ui"),K(Ae=>({...Ae,show:!1,success:!1,text:"",rewards:[]}))},[x,te,Me,Q.rewards,Q.success,Oe,h.length,U.length,R,P,Ve,Ge,rt]),Qe=Pe=>{var Ae,_e;if(!U.some(Ie=>Ie.index===Pe.index)&&!Q.show&&!B){Oe("click-ui");let Ie=Ke.right.desc,{rewards:tt}=Ke.right;const Gt=[...U,Pe];if(p&&Pe.index===U.length||!p){if(x&&ct(be),t(),(Ae=w==null?void 0:w.correctFeedbacks)!=null&&Ae.length){const Dt=(_e=w.correctFeedbacks)==null?void 0:_e.find(ke=>ke.id===Pe.id);Dt&&(Ie=Dt.desc,tt=Dt.rewards),!Ie&&h.length>Gt.length&&!R?Me(tt,!0):Ie&&!R&&(K(ke=>({...ke,show:!0,success:!0,text:Ie,rewards:tt})),x&&Ve())}$(Gt)}else xt(Pe,!0)}},Be=React$2.useCallback(()=>{Ve(),Re(x),Ge(),!ne.current&&D&&k(),fe(!1),W.current=Date.now(),q.current=W.current+x*1e3,rt()},[Ve,x,Ge,D,rt,k]);return React$2.useEffect(()=>{x&&C>0&&!he.current&&(D&&Object.keys(N).length&&N[C-1]?(fe(!0),he.current=!0):fe(!1))},[g,D,N,C,x]),React$2.useEffect(()=>{x&&be===0&&dt()},[be,dt,x]),React$2.useEffect(()=>{x&&(F?(Ve(),ct()):Ge())},[Ve,rt,F,ct,Ge,x]),jsxRuntimeExports.jsxs("div",{className:v,children:[Q.show?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:Oe,text:Q.text,success:Q.success,translate:Le,hasTimeout:!Q.text,delay:x?1e3:2e3,functionOnClose:Et,timeExpired:te,keyboardControl:M}):null,jsxRuntimeExports.jsx(KonvaMapper,{completed:B,imageUrl:St,areas:R&&U.length?[U[0]]:it,badAreas:gt,clickedZones:U,onClick:Qe,onClickOutside:xt,hasHighlights:S,emitEvent:n}),E?jsxRuntimeExports.jsx(ImageReview,{}):null,x&&ue?jsxRuntimeExports.jsx(TimerDialog,{retry:D||N[C-1],translate:Le,onInit:Be}):null,x?jsxRuntimeExports.jsx(CountDown,{time:be}):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(l){const e=(n,t)=>{t?(l.emitEvent({type:"addPoints",complex:!0,finish:!0,payload:n}),l.emitEvent({type:"passPuzzle"})):(l.emitEvent({type:"addPoints",payload:n,finish:!1}),l.emitEvent({type:"failPuzzle"}))};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...l,emitFinish:e,name:"image-click-puzzle"})}const GREEN="#44d7ab",ORANGE="#FFB34B",RED="#FF634D",getDistance=(l,e)=>Math.max(Math.abs(l[0]-e[0]),Math.abs(l[1]-e[1])),generatePasswordPositions=(l,e,n,t)=>{const a=[],o=l;for(const d of e.toLowerCase()){const f=Math.floor(Math.random()*n),h=Math.floor(Math.random()*t);o[f][h].value=d,a.push({char:d,position:[f,h]})}return[o,a]},paintedGridPassword=(l,e,n,t)=>{const a=l;for(let o=0;o<e;o+=1)for(let d=0;d<n;d+=1)switch(t.reduce((h,u)=>{const p=[o,d],x=getDistance(u.position,p);return x<h?x:h},9999)){case 0:a[o][d].hiddenColor=GREEN;break;case 1:a[o][d].hiddenColor=ORANGE;break;case 2:a[o][d].hiddenColor=RED;break}return a},resetColors=(l,e,n)=>{const t=n;for(let a=0;a<l;a+=1)for(let o=0;o<e;o+=1)t[a][o].color="",t[a][o].hiddenColor=RED;return t},repaintGridPassword=(l,e,n,t)=>{const a=resetColors(n,t,l),[o,d]=generatePasswordPositions(a,e,n,t);return paintedGridPassword(o,n,t,d)},prepareAcceptedChars=(l,e)=>e.split("").filter(n=>!l.includes(n)).join(""),generateBasicGrid=(l,e,n)=>{const t=[];for(let a=0;a<l;a+=1){const o=[];for(let d=0;d<e;d+=1){const f={color:"",hiddenColor:RED,value:n[Math.floor(Math.random()*n.length)]};o.push(f)}t.push(o)}return t},makeSomeNoise=({numberOfColumns:l,numberOfRows:e,password:n})=>{const t=LangIsRtl()?"٠١٢٣٤٥٦٧٨٩شزذيثبلاهتنمورخحضقسفعدصطغظ":"0123456789abcdefghijklmnopqrstuvwxyz",a=prepareAcceptedChars(n,t),o=generateBasicGrid(e,l,a),[d,f]=generatePasswordPositions(o,n,e,l);return paintedGridPassword(d,e,l,f)};function DrawItem({item:l,rowIndex:e,columnIndex:n,setCursorPosition:t,cursorPosition:a}){const o=Math.abs(e-a[0])<3&&Math.abs(n-a[1])<3;return jsxRuntimeExports.jsx("span",{className:"puzzle--cracker__item",style:{backgroundColor:`${o?l.hiddenColor:l.color}`,flexGrow:1,textAlign:"center"},onMouseOver:()=>{t([e,n])},onFocus:()=>{t([e,n])},children:l.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:l,rowIndex:e,setCursorPosition:n,cursorPosition:t}){return l.length?jsxRuntimeExports.jsx("div",{className:"puzzle--cracker",children:l.map((a,o)=>jsxRuntimeExports.jsx(DrawItem,{item:a,rowIndex:e,columnIndex:o,setCursorPosition:n,cursorPosition:t},o))}):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:l,cursorPosition:e,setCursorPosition:n}){return jsxRuntimeExports.jsx("div",{className:"puzzle--cracker__canvas",children:l.map((t,a)=>jsxRuntimeExports.jsx(DrawRow,{row:t,rowIndex:a,cursorPosition:e,setCursorPosition:n},a))})}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:l,soundActions:e,info:n,velocity:t,password:a,disableExit:o,difficulty:d,setResolveAction:f}){const[h]=e,u=fe=>l({type:"translate",payload:fe}),p=React$2.useRef(),x=React$2.useRef(),{solution:R}=n,[S,E]=React$2.useState(a.toLowerCase()),[g,v]=React$2.useState(),[T,b]=React$2.useState(Array(a.toLowerCase().length).fill("")),[_,w]=React$2.useState(!1),[C,P]=React$2.useState([0,0]),D=u("puzzle.cracker.crackedPassword"),N=n.solution.right.desc&&n.solution.right.desc!==""?n.solution.right.desc:"",k=u("puzzle.cracker.congratulations"),[F,M]=React$2.useState([[]]),{visibleRows:U,visibleColumns:$}=DIFFICULTY_MAP[d];let B=U==="auto"?Math.ceil(window.innerHeight*.025):U;B=B>=20?B:20,React$2.useEffect(()=>{_&&o(!0)},[_,o]),React$2.useEffect(()=>{f(fe=>{h("score"),w(!0),setTimeout(()=>{l({type:"hidePuzzleButtons",payload:!1}),fe()},0)})},[f,h]);const J=()=>{h("click-ui");const{rewards:fe}=R.right;l({type:"addPoints",complex:!0,finish:!0,payload:fe}),l({type:"passPuzzle"})},re=()=>a.toLowerCase().split("").map((te,H)=>({char:te,index:H,used:!1})),ae=fe=>fe.filter(te=>te.used===!1).map(te=>te.char).join(""),Q=fe=>{if(fe[0].length>0&&!_){const te=[...fe];return te.push(te.shift()),te}return fe};let K=0;const ne=fe=>{if(x.current!==void 0){const te=fe-x.current;K+=te,K>1e3/VELOCITY_MAP[t]&&(M(Q),K=0)}x.current=fe,p.current=requestAnimationFrame(ne)};React$2.useEffect(()=>{E(a.toLowerCase());const fe=makeSomeNoise({numberOfColumns:$,numberOfRows:B,password:a.toLowerCase()});return M(fe),v(re()),p.current=requestAnimationFrame(ne),()=>cancelAnimationFrame(p.current)},[]);const ue=()=>{if(F.length<=1)return;const[fe,te]=C,H=F[fe][te];if(H.hiddenColor===GREEN){const W=g.filter(V=>V.char===H.value.toLowerCase()&&V.used===!1)[0];if(W){const{index:V}=W;h("score");const z=g;z[V].used=!0,v(z);const q=[...T];q[V]=H.value;const ee=ae(z);E(ee);const le=repaintGridPassword(F,ee,B,$);M(le),b(q)}}S<=0&&(h("score"),w(!0))};return React$2.useEffect(()=>{_||ue()},[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((fe,te)=>jsxRuntimeExports.jsx("span",{className:"puzzle--pieces__item",children:fe&&jsxRuntimeExports.jsx("span",{className:"character success-transition-animation","data-testid":`solution${te}`,children:fe})},`${fe+te}`))})]}),jsxRuntimeExports.jsx(DrawGrid,{grid:_?[[]]:F,cursorPosition:C,setCursorPosition:P}),_&&D&&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:[`${D} ${a.toLowerCase()}`," "]}),jsxRuntimeExports.jsxs("span",{children:[k," "]}),N!==""&&jsxRuntimeExports.jsx("span",{children:N})]}),jsxRuntimeExports.jsx("div",{className:"position--absolute bottom center",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary gat--btn__cracker",onClick:J,children:u("screens.continue")})})]})]})}CrackerPuzzleComponent.defaultProps={velocity:"slow",difficulty:"easy",context:{},info:{}};const ARABIC=/[\u0600-\u06FF]/,restrictCharacters=(l,e)=>{let n=!1;return e==="or"&&(n=l===""||l===" "||l===","||l==="."||l==="/"),e==="and"&&(n=l&&l!==" "&&l!==","&&l!=="."&&l!==""&&l!=="/"),n},sortChar=(l,e)=>l.char>e.char?1:l.char<e.char?-1:0,analyzeChars=l=>{const e={anyArabic:!1,anyNumber:!1,anyWestern:!1};for(let n=0;n<l.length;n+=1){const t=l[n].charCodeAt(0);t>=65&&t<=90?e.anyWestern=!0:t>=48&&t<=57?e.anyNumber=!0:ARABIC.test(l[n])&&(e.anyArabic=!0)}return e},makeChar=l=>{const e="شزذيثبلاهتنمورخحضثقسفعدصطغظ",n="ABCDEFGHIJKLMNOPQRSTUVWXYZ",t="0123456789";let a="";return l.anyWestern&&(a+=n),l.anyNumber&&(a+=t),l.anyArabic&&(a+=e),a.charAt(Math.floor(Math.random()*a.length))},MAX_POOL_LETTERS=26,MAX_EXTRA_LETTERS=8,AnswerPanel=({answer:l,flickerPosition:e,show:n=!1,showCorrectSolution:t})=>{const a=[];let o=0;return l.forEach(d=>{a[o]||(a[o]=[]),a[o]=[...a[o],d],d.char===" "&&(o+=1),t||(d.positionInitial=d.index)}),a.map((d,f)=>jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__word","data-testid":`result-${f}`,children:n?d.map((h,u)=>jsxRuntimeExports.jsx("span",{className:"puzzle--hanged__letter active",children:h},`${h+u}`)):d.filter(({char:h})=>h!==" ").map(({char:h,fixed:u},p)=>jsxRuntimeExports.jsx("span",{className:`puzzle--hanged__letter ${u?"":"active"} ${d[p].positionInitial===e?"fakeFocus":""}`,children:h},`${h+p}`))},`${d+f}`))},defaultImage="https://min.gamelearn.io/css-resources/gamelearn/resources/partenon.jpg";function HangedPuzzleComponent({soundActions:l,emitEvent:e,disableExit:n,question:t,image:a,info:o,answer:d,hintUsed:f,setResolveAction:h,setHintAction:u,keyboardControl:p}){var le;const[x]=l,R=((le=a.img)==null?void 0:le.url)||defaultImage,[S,E]=React$2.useState(0),[g,v]=React$2.useState(!1),[T,b]=React$2.useState([]),[_,w]=React$2.useState(!1),[C,P]=React$2.useState([]),[D,N]=React$2.useState(""),[k,F]=React$2.useState(!1),[M,U]=React$2.useState([]),[$,B]=React$2.useState(!1),J=d.toUpperCase().split(""),re=J.filter(ce=>restrictCharacters(ce,"and")),ae=ce=>e({type:"translate",payload:ce}),Q=React$2.useCallback(()=>{const ce=re.map(be=>({char:be}));let he=[];const ve=analyzeChars(re);for(;he.length<MAX_EXTRA_LETTERS;){const be=makeChar(ve);he=[...he,{char:be}]}return[...ce,...he]},[re]),K=d.toUpperCase().split("").map((ce,he)=>restrictCharacters(ce,"or")?{index:he,letter:ce,char:ce,fixed:!0}:{index:he,letter:ce,char:""}),ne=React$2.useCallback(()=>{let ce=Q();for(;ce.length>MAX_POOL_LETTERS;){const he=Math.trunc(Math.random()*(ce.length-1))+1,ve=ce[he],be=K.find((Re,Le)=>ve.char===Re.letter&&!K[Le].fixed);be&&(ce.splice(he,1),K[be.index]={...be,char:be.letter,fixed:!0})}f&&(ce=[],K.forEach(({letter:he})=>{he!==" "&&ce.push({char:he})})),P(K),b(ce)},[K,f,Q]),ue=(ce,he)=>T.map((be,Re)=>Re===he?{...be,deleted:!0}:{...be}),fe=(ce,he,ve)=>{const be=he.map((Le,Oe)=>ve.find(St=>St.poolIndex===Oe)?{char:Le.char}:Le);b(be),P(ce);const Re=ce.find(Le=>Le.char==="");E(Re.index)},te=(ce,he)=>{x("click-ui");let ve=!1;const be=C.map(Oe=>!Oe.char&&!ve?(ve=!0,{...Oe,char:ce,poolIndex:he}):Oe),Re=ue(ce,he),Le=be.filter(Oe=>Oe.char).length;b(Re),P(be),H(),Le===C.length&&q(be,Re)},H=()=>{var ce;if(g){const he=C.find(ve=>ve.index!==S&&ve.letter!==" "&&ve.char===""&&ve.poolIndex===!1);he&&E(he.index)}else{const he=C.find(ve=>ve.char==="");E(he.index+1),((ce=C[he.index+1])==null?void 0:ce.letter)===" "&&E(he.index+2)}},W=()=>{x("click-ui");const ce=C.map((he,ve)=>C[C.length-1-ve]).find(he=>he.char&&!he.fixed);if(ce){const he=C.map(Re=>Re.index===ce.index?{...ce,char:""}:Re);let ve=!1;const be=T.map((Re,Le)=>Le===ce.poolIndex&&(Re.deleted||!ve)?(ve=!0,{char:Re.char}):Re);b(be),P(he),E(ce.index)}},V=()=>{n(!0),N("");const ce=[...M,...o.solution.right.rewards];x("score"),e({type:"hidePuzzleButtons",payload:!1}),e({type:"addPoints",complex:!0,finish:!0,payload:ce}),e({type:"passPuzzle"})},z=()=>{x("fail"),e({type:"hidePuzzleButtons",payload:!1}),U([...M,...o.solution.wrong.rewards]),N(""),F(!1),e({type:"failPuzzle"}),v(!0)},q=(ce,he)=>{let ve=[];F(!0);const be=ce.map((Le,Oe)=>J[Oe]===Le.char?{...Le,fixed:!0}:(ve=[...ve,Le],{...Le,poolIndex:!1,char:""})),Re=be.filter(Le=>Le.fixed).length;e({type:"hidePuzzleButtons",payload:!0}),Re===J.length?(N("success"),o.solution.right.desc===""&&setTimeout(()=>{V()},2e3)):(N("failed"),fe(be,he,ve),o.solution.wrong.desc===""&&setTimeout(()=>{z()},2e3))},ee=()=>{if(D==="success")V();else{z();const ce=C.find(he=>he.char==="");E(ce.index)}};return React$2.useEffect(()=>{_||(w(!0),ne()),h(ce=>{B(!0),setTimeout(()=>{e({type:"hidePuzzleButtons",payload:!1}),ce()},2e3)}),u(ce=>{const he=[];K.forEach(({letter:ve})=>{ve!==" "&&he.push({char:ve})}),b(he),ce()})},[ne,_,d,h,e,M,o.resolve.rewards,K,u]),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged",style:{backgroundImage:`url("${R}")`},children:[D?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:x,text:o.solution[D==="success"?"right":"wrong"].desc,success:D==="success",translate:ae,functionOnClose:ee,keyboardControl:p}):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 ${D}`,"data-testid":`${D}`,children:$?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:$,answer:d.split(""),show:!0})}):jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:$,flickerPosition:S,answer:C})}),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__keyboard",children:[T.sort((ce,he)=>sortChar(ce,he)).map((ce,he)=>jsxRuntimeExports.jsx("button",{"data-testid":`key-${ce.char}`,type:"button",onClick:()=>{!ce.deleted&&!D&&!k&&(te(ce.char,he),x("click-ui"))},className:`puzzle--hanged__keyboard--item ${ce.deleted||k?"disabled":""}`,children:ce.char},`${ce+he}`)),jsxRuntimeExports.jsx("button",{onClick:k?null:()=>W(),type:"button",disabled:k?"disabled":null,"aria-label":ae("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:l,description:e,nodeId:n,setInfo:t,emitEvent:a,disableExit:o,setResolveAction:d,soundActions:f,setSelected:h,selected:u,pause:p,loadPuzzleStatus:x,index:R,setIndex:S,slidesCompleted:E,setSlidesCompleted:g,keyboardControl:v,totalCorrects:T}){const b=React$2.useRef([]),_=React$2.useRef(0),w=React$2.useRef(0),C=`chained-image-click-puzzle_${R}_${n}`,[P]=f,D=Q=>{b.current=[...b.current,...Q]},N=React$2.useCallback(Q=>{P("score"),a({type:"hidePuzzleButtons",payload:!1}),a({type:"addPoints",complex:!0,finish:!0,payload:[...b.current,...Q]}),a({type:"passPuzzle"})},[P,a]),[k,F]=React$2.useState(!1),M=l[R],{info:U,specificFeedbacks:$}=M;U.description=e,React$2.useEffect(()=>{_.current=0,w.current=0,F(!1)},[R]);const B=React$2.useCallback((Q,K=!1)=>{var ue;let ne={...E};if(K){if((ue=$==null?void 0:$.correctFeedbacks)!=null&&ue.length&&!M.hasClickOnce){const fe=$.correctFeedbacks.length;k&&fe?(_.current>0?h(u+(fe-_.current)):h(u+fe),_.current=fe):_.current+=1}else{let fe=u;w.current&&(fe-=w.current),_.current=M.areas.length,h(fe+_.current)}_.current===M.areas.length&&(R+1>=l.length?N(Q):S(R+1),ne={...ne,[R]:!0},g(ne)),D(Q)}else a({type:"addPoints",payload:Q,finish:!1}),a({type:"failPuzzle"}),M.hasClickOrder&&(h(u-_.current),_.current===0&&Object.entries(E).length===0?h(0):_.current=0),Object.entries(E).length===0&&M.hasClickOrder&&!u&&h(0)},[E,$,M.hasClickOnce,M.areas.length,M.hasClickOrder,k,h,u,R,l.length,g,N,S,a]),J=()=>{for(let Q=0;Q<b.current.length;Q=Q+1)if(b.current[Q].points>0)return!0;return!1},re=()=>{F(!0),R>=l.length-1&&h(T),P("score"),R+1>=l.length&&J()?(U.resolve.rewards.forEach(Q=>{b.current.forEach(K=>{K.id===Q.id&&(Q.points=Q.points+K.points)})}),a({type:"puzzleAction",action:"resolve",payload:{element:C,rewards:U.resolve.rewards,finish:!0}})):a({type:"puzzleAction",action:"resolve",payload:{element:C,rewards:U.resolve.rewards,finish:R+1>=l.length}})};React$2.useEffect(()=>{t({...U,hintId:C})},[U,C,t]),React$2.useEffect(()=>{x&&R!==l.length-1&&B([],!0)},[R,l.length,x,B]);const ae=()=>{const Q=M.hasClickOnce?M.areas.length:1;w.current+=Q,h(u+Q)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...M,puzzle:{name:C,component:"chained-image-click-puzzle"},specificFeedbacks:$,emitFinish:B,emitError:D,emitResolve:re,isLast:R+1===l.length,defaultCompleted:E[R]||!!x,hideContinue:R+1!==l.length,handleClick:ae,emitEvent:a,disableExit:o,soundActions:f,setResolveAction:d,pause:p,keyboardControl:v},R)}function ChainedImageClickPuzzleComponent(l){const{setInfo:e,emitEvent:n,nodeId:t,list:a,description:o,soundActions:d,showFrames:f,disableExit:h,setResolveAction:u,pause:p,keyboardControl:x}=l,[R,S]=React$2.useState(0),[E,g]=React$2.useState(0),[v,T]=React$2.useState({}),b=`chained-image-click-puzzle_${E}_${t}`,_=React$2.useMemo(()=>n({type:"loadObjectStatus",payload:b}),[n,b]),w=a.reduce((P,D)=>P+D.areas.length,0),C={list:a,description:o,nodeId:t,disableExit:h,setResolveAction:u,emitEvent:n,soundActions:d,setInfo:e,setSelected:S,selected:R,index:E,setIndex:g,slidesCompleted:v,setSlidesCompleted:T,loadPuzzleStatus:_,pause:p,keyboardControl:x,totalCorrects:w};return jsxRuntimeExports.jsxs("div",{className:"puzzle--image__click",children:[f?jsxRuntimeExports.jsxs("div",{className:"puzzle-image__info",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[R," / ",w]})]}):null,jsxRuntimeExports.jsx(CurrentImageClickPuzzle,{...C})]})}function CurrentFramePuzzle({list:l,index:e,puzzlesCompiledRef:n,framesCompleted:t,handleFinish:a,accRewards:o,setRewards:d,setIndex:f,setFramesCompleted:h,loadPuzzleStatus:u,soundActions:p,setResolveAction:x,disableExit:R,description:S,translateFromParent:E,setInfo:g,emitEvent:v,nodeId:T,setSelected:b,selected:_,emitResetPuzzle:w,firstTryForFrame:C,setPuzzlesAutoCompleted:P,puzzlesAutoCompleted:D,emitOpenPopupCounterInfo:N,resetValues:k,setResetValues:F,pause:M,keyboardControl:U,totalCorrects:$}){var q;const[B]=p,[J,re]=React$2.useState(!1),ae=l[e],{info:Q,specificFeedbacks:K}=ae;Q.description=S;const ne=React$2.useRef(0),ue=React$2.useRef(0),fe=`frame-image-click-puzzle_${e}_${T}`;React$2.useEffect(()=>{n.current+=1},[n]),React$2.useEffect(()=>{g({...Q,hintId:fe})},[g,Q,fe]),React$2.useEffect(()=>{k&&(ue.current=0,ne.current=0,b(0),F(!1))},[k,F,b]),React$2.useEffect(()=>{ue.current=0,ne.current=0,re(!1)},[e]);const te=React$2.useCallback((ee,le=!1)=>{var he;let ce={...t};if(le){if((he=K==null?void 0:K.correctFeedbacks)!=null&&he.length&&!ae.hasClickOnce){const ve=K.correctFeedbacks.length;J&&ve?(ue.current>0?b(_+(ve-ue.current)):b(_+ve),ue.current=ve):ue.current+=1}else{let ve=_;ne.current&&(ve-=ne.current),ue.current=ae.areas.length,D[0]&&Object.entries(t).length===0?b(ue.current):b(ve+ue.current)}ue.current===ae.areas.length&&(e+1>=l.length&&a(ee),ce={...ce,[e]:!0},h(ce),f(e+1>l.length-1?0:e+1)),d(ee)}else v({type:"addPoints",payload:ee,finish:!1}),v({type:"failPuzzle"}),ae.hasClickOrder&&(b(_-ue.current),ue.current=0)},[t,(q=K==null?void 0:K.correctFeedbacks)==null?void 0:q.length,ae.hasClickOnce,ae.areas.length,ae.hasClickOrder,d,J,b,_,D,e,l.length,h,f,a,v]),H=React$2.useCallback(()=>{for(let ee=0;ee<o.current.length;ee=ee+1)if(o.current[ee].points>0)return!0;return!1},[o]),W=React$2.useCallback(()=>{re(!0),e>=l.length-1&&b($),B("score"),v({type:"hidePuzzleButtons",payload:!1}),P(ee=>({...ee,[e]:!0})),e+1>=l.length&&H()?(Q.resolve.rewards.forEach(ee=>{o.current.forEach(le=>{le.id===ee.id&&(ee.points=ee.points+le.points)})}),v({type:"puzzleAction",action:"resolve",payload:{element:fe,rewards:Q.resolve.rewards,finish:!0}})):v({type:"puzzleAction",action:"resolve",payload:{element:fe,rewards:Q.resolve.rewards,finish:e+1>=l.length}})},[e,l.length,B,v,P,H,b,$,Q.resolve.rewards,fe,o]),V=React$2.useCallback(()=>{h({}),ue.current=0,ne.current=0,w()},[w,h]);React$2.useEffect(()=>{u&&e!==l.length-1&&te([],!0)},[t,e,l.length,u,te]);const z=()=>{const ee=ae.hasClickOnce?ae.areas.length:1;ne.current+=ee,b(_+ee)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...ae,className:"puzzle-frame__canvas",puzzle:{name:"",component:"frame-click-puzzle"},specificFeedbacks:K,emitFinish:te,emitResolve:W,hideContinue:!0,disableInfo:n.current>1,defaultCompleted:t[e]||!!u,soundActions:p,setResolveAction:x,disableExit:R,translateFromParent:E,emitEvent:v,slideNumber:e,handleClick:z,emitResetPuzzle:V,firstTryForFrame:C,puzzlesAutoCompleted:D,emitOpenPopupCounterInfo:N,pause:M,keyboardControl:U},e)}function Tooltip({emitEvent:l}){const e=n=>l({type:"translate",payload:n});return jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle-frame__info--tooltip",children:e("puzzles.counterTooltip")})}function Counter({current:l,total:e,tooltip:n,emitEvent:t}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[n?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:[l," / ",e]})]})]})}function FrameImageClickComponent({emitEvent:l,nodeId:e,list:n,description:t,showFrames:a,soundActions:o,disableExit:d,setResolveAction:f,setInfo:h,pause:u,keyboardControl:p}){const[x,R]=React$2.useState({}),S=React$2.useRef([]),[E,g]=React$2.useState(0),[v,T]=React$2.useState({}),[b,_]=React$2.useState(0),w=React$2.useRef(0),[C,P]=React$2.useState(!0),[D,N]=React$2.useState(!0),[k,F]=React$2.useState(!1),M=n.reduce((ue,fe)=>ue+fe.areas.length,0),U=ue=>{S.current=[...S.current,...ue]},$=`frame-image-click-puzzle_${E}_${e}`,B=React$2.useMemo(()=>l({type:"loadObjectStatus",payload:$}),[l,$]),J=React$2.useCallback(ue=>{l({type:"addPoints",complex:!0,finish:!0,payload:[...S.current,...ue]}),l({type:"passPuzzle"})},[l]),re=React$2.useCallback(()=>{N(!1),S.current=[],_(0),g(0),T({}),P(!0),F(!0)},[]),ae=ue=>l({type:"translate",payload:ue}),Q=()=>{P(!0)},ne={firstTryForFrame:D,list:n,description:t,index:E,puzzlesCompiledRef:w,framesCompleted:v,handleFinish:J,setRewards:U,accRewards:S,setSelected:_,selected:b,setIndex:g,setFramesCompleted:T,loadPuzzleStatus:B,soundActions:o,setResolveAction:f,disableExit:d,translateFromParent:ae,setInfo:h,emitEvent:l,nodeId:e,emitResetPuzzle:re,resetValues:k,setResetValues:F,setPuzzlesAutoCompleted:R,puzzlesAutoCompleted:x,emitOpenPopupCounterInfo:()=>{E===0&&P(!1)},pause:u,keyboardControl:p,totalCorrects:M};return jsxRuntimeExports.jsxs("div",{className:"puzzle-frame",children:[jsxRuntimeExports.jsx(CurrentFramePuzzle,{...ne}),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",{"data-testid":"puzzle-frame-progress",style:{width:`${b/M*100}%`},className:"puzzle-frame__progress--handle"})})}),a?jsxRuntimeExports.jsx("button",{"data-testid":"puzzle-frame-counter-button",disabled:C,"aria-hidden":C,type:"button",className:"puzzle-frame__info",onClick:Q,children:jsxRuntimeExports.jsx(Counter,{current:b,total:M,tooltip:!C,emitEvent:l})}):null]})]})}FrameImageClickComponent.defaultProps={description:"",context:{},nodeId:0,showFrames:!1};function EditButton({action:l,className:e}){return jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,"aria-label":`${l} edit button`,onKeyUp:()=>{},className:`puzzle--webBuilder__edit ${e}`,onClick:l,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:l,usingTemplate:e,openPopup:n,onSave:t,header:a,translate:o}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[l?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:[a.logo?jsxRuntimeExports.jsx("img",{src:path+a.logo,alt:"",title:""}):jsxRuntimeExports.jsxs("span",{children:[jsxRuntimeExports.jsx("b",{children:o("webbuilder.bank.header.title")}),jsxRuntimeExports.jsx("b",{children:o("webbuilder.bank.header.logo")})]}),jsxRuntimeExports.jsx(EditButton,{action:()=>n("PopupImageComponent",{text:"Documents",images:imagesOptions,onSave:d=>t({logo:d})})})]}),jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsxs("ul",{className:"bank--navigation",children:[jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:o("webbuilder.bank.header.account")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:o("webbuilder.bank.header.invest")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:o("webbuilder.bank.header.loans")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:o("webbuilder.bank.header.mortgage")})]}),l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>n("PopupColorComponent",{colors:colorOptions,onSave:d=>t({color:d})})})]})]})}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:l,usingTemplate:e,header:n,translate:t}){const a=l?e.header.userImage:n.userImage,o=l?e.header.username:n.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+a})`}}),jsxRuntimeExports.jsx("span",{className:"facebook--header__user--text",children:t(o||"webbuilder.facebook.header.userName")})]})]})}FacebookHeader.defaultProps={showingReference:!1,usingTemplate:{},header:{}};function WebBuilderHeader(l){const{isFacebook:e,header:n,showingReference:t,usingTemplate:a}=l,o=t?a.header.color:n.color;return jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__header ${e?"":"bank"}`,style:e?{}:{backgroundColor:`${o}`},children:jsxRuntimeExports.jsx("div",{className:`${e?"facebook":"bank"}--header`,children:e?jsxRuntimeExports.jsx(FacebookHeader,{...l}):jsxRuntimeExports.jsx(BankHeader,{...l})})})}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:l,usingTemplate:e,header:n,onSave:t,translate:a,openPopup:o}){const d=l?e.header.userImage:n.userImage,f=l?e.header.username:n.username,h=l?e.header.bgImage:n.bgImage;return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__front",style:{backgroundImage:`url(${path+h})`},children:[jsxRuntimeExports.jsxs("div",{className:"facebook--user",children:[jsxRuntimeExports.jsx("span",{className:"facebook--user__circle",style:{backgroundImage:`url(${path+d})`},children:l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{o("PopupImageComponent",{images:imagesOptions,onSave:u=>t({userImage:u})})}})}),jsxRuntimeExports.jsx("span",{className:"facebook--user__text",children:a(f||"webbuilder.facebook.header.userName")}),l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{o("PopupTextComponent",{options:userOptions,onSave:u=>t({username:u})})}})]}),l?null:jsxRuntimeExports.jsx(EditButton,{className:"position--absolute right top",action:()=>{o("PopupImageComponent",{images:imagesOptions,onSave:u=>t({bgImage:u})})}})]})}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:l,usingTemplate:e,body:n,onSave:t,openPopup:a,translate:o}){const d=l?e.body.work:n.work,f=l?e.body.studies:n.studies,h=l?e.body.home:n.home,u=l?e.body.mail:n.mail;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("ul",{className:"facebook--sidebar",dir:"auto",children:[jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${d||l?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-work"}),jsxRuntimeExports.jsx("span",{className:"text",children:o(d||"webbuilder.facebook.body.work")})]}),l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupTextComponent",{options:workOptions,onSave:p=>t({work:p})})}})]}),jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${f||l?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-education"}),jsxRuntimeExports.jsx("span",{className:"text",children:o(f||"webbuilder.facebook.body.studies")})]}),l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupTextComponent",{options:studiesOptions,onSave:p=>t({studies:p})})}})]}),jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${h||l?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-home"}),jsxRuntimeExports.jsx("span",{className:"text",children:o(h||"webbuilder.facebook.body.home")})]}),l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupTextComponent",{options:homeOptions,onSave:p=>t({home:p})})}})]})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--board",children:[jsxRuntimeExports.jsx("div",{className:"facebook--mail__label",children:"E-mail"}),jsxRuntimeExports.jsxs("div",{className:`facebook--mail__box ${u||l?"active":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-mail"}),jsxRuntimeExports.jsx("span",{className:"text",children:o(u||"webbuilder.facebook.body.email")})]}),l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupTextComponent",{options:mailOptions,onSave:p=>t({mail:p})})}})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs",children:[jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-edit"}),o("webbuilder.facebook.body.editPost")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-photo"}),o("webbuilder.facebook.body.editPhoto")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-video"}),o("webbuilder.facebook.body.liveVideo")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-events"}),o("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:o("webbuilder.facebook.body.think")})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--chips",children:[jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:o("webbuilder.facebook.body.photo")}),jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:o("webbuilder.facebook.body.label")}),jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:o("webbuilder.facebook.body.feeling")})]})]})]})]})}FacebookBody.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},body:{}};function BankBody({showingReference:l,usingTemplate:e,body:n,onSave:t,openPopup:a,translate:o}){const d=l?e.body.bgImage:n.bgImage,f=l?e.body.btnColor:n.btnColor,h=o(l?e.body.bankTitle:"webbuilder.bank.body.image.title"),u=o(l?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+d})`},children:jsxRuntimeExports.jsxs("div",{className:"bank--image__text",children:[jsxRuntimeExports.jsx("span",{className:"title",children:n.bankTitle&&!l?o(n.bankTitle):h}),jsxRuntimeExports.jsx("span",{children:n.bankDesc&&!l?o(n.bankDesc):u}),l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupTextComponent",{options:titleOptions,onSave:p=>t({bankTitle:p.title,bankDesc:p.desc})})}}),l?null:jsxRuntimeExports.jsx(EditButton,{className:"position--absolute top right",action:()=>{a("PopupImageComponent",{images:imagesOptions,onSave:p=>t({bgImage:p})})}})]})}),jsxRuntimeExports.jsx("div",{dir:"auto",className:"bank--sidebar",children:jsxRuntimeExports.jsxs("div",{className:"bank--form",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__title",children:o("webbuilder.bank.body.password.title")}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:o("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:o("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:o("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:`${f}`},children:o("webbuilder.save")}),l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupColorComponent",{colors:colorOptions2,onSave:p=>t({btnColor:p})})}})]})]})})]})}function WebBuilderBody(l){const{isFacebook:e}=l;return jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__body ${e?"":"bank"}`,children:e?jsxRuntimeExports.jsx(FacebookBody,{...l}):jsxRuntimeExports.jsx(BankBody,{...l})})}WebBuilderBody.defaultProps={isFacebook:!1};WebBuilderBody.propTypes={isFacebook:PropTypes.bool};function CurrentButton({translate:l,backActive:e,action:n}){return jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__topbar--buttons",children:jsxRuntimeExports.jsx("button",{type:"button",className:"puzzle--webBuilder__topbar--buttons__item",onClick:n,children:l(`webbuilder.${e?"return":"showReference"}`)})})}function WebBuilderTopBar({backActive:l,displayButton:e,clickAction:n,translate:t}){return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__topbar",children:[e?jsxRuntimeExports.jsx(CurrentButton,{backActive:l,action:n,translate:t}):null,jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__title",children:"web builder 3.0"})]})}function FeedbackResult({onNext:l,success:e,showButton:n,translate:t}){const a=t(e?"webbuilder.feedback.successTitle":"webbuilder.feedback.failTitle"),o=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:a}),jsxRuntimeExports.jsx("div",{className:"description",children:o})]}),n?jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__secondary ${e?"green":"red"}`,onClick:l,style:{marginRight:"64px"},children:t("webbuilder.continue")}):null]})}FeedbackResult.defaultProps={onNext:()=>{},success:!1,showButton:!0};function PublishButton({onPublish:l,translate:e}){return jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,onKeyUp:()=>{},"aria-label":"publish",className:"position--absolute bottom center",onClick:l,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:l,onSave:e,closingAction:n,translate:t,soundActions:a}){const[o]=a,[d,f]=React$2.useState(),h=d===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:l.map(u=>jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__color--select ${d===u?"selected":""}`,style:{borderColor:`${u}`},onClick:()=>f(u),children:jsxRuntimeExports.jsx("span",{style:{backgroundColor:`${u}`}})},u+Date.now()))})]})})}),jsxRuntimeExports.jsxs("div",{className:"popup--buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:n,children:jsxRuntimeExports.jsx("span",{children:t("webbuilder.cancel")})}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${h?"disabled":""}`,onClick:h?null:()=>{o("click-ui"),e(d)},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:l,onSave:e,closingAction:n,translate:t,soundActions:a}){const[o]=a,[d,f]=React$2.useState(),h=!d;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:n,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:l.map(u=>jsxRuntimeExports.jsxs("li",{className:"folder-item-file",children:[jsxRuntimeExports.jsx("div",{className:"folder-item-file__imagewrap",onClick:()=>f(u),onKeyUp:()=>{},role:"button",tabIndex:0,children:jsxRuntimeExports.jsx("img",{alt:u.src,src:path+u.src})}),jsxRuntimeExports.jsx("div",{className:"folder-item-file__title",title:u.src,children:u.src})]},u.src+Date.now()))})}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:n,children:t("webbuilder.cancel")}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${h?"disabled":""}`,onClick:h?null:()=>{o("click-ui"),e(d.src)},children:t("webbuilder.open")})]})]})]})})}PopupImageComponent.defaultProps={closingAction:()=>{},onSave:()=>{},images:[]};function Selected({item:l,translate:e}){return l instanceof Object?e(l.title.toString()):jsxRuntimeExports.jsx("span",{children:e(l||"webbuilder.textSelect.title")})}function PopupTextComponent({closingAction:l,onSave:e,options:n,translate:t,soundActions:a}){const[o]=a,[d,f]=React$2.useState(""),h=d==="",[u,p]=React$2.useState(!1),x=u?"puzzle--webBuilder__select--item open":"puzzle--webBuilder__select--item",R=()=>{p(!u)};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:x,onClick:()=>R(),role:"presentation",children:[jsxRuntimeExports.jsx(Selected,{item:d,translate:t}),jsxRuntimeExports.jsx("span",{className:"icon-down-arrow"}),jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__dropdown",children:n.map(S=>S instanceof Object?jsxRuntimeExports.jsxs("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{f(S)},children:[jsxRuntimeExports.jsx("span",{children:t(S.title)}),jsxRuntimeExports.jsx("span",{className:"subtitle",children:t(S.desc)})]},S.title):jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{f(S)},children:t(S)},S))})]})]})})}),jsxRuntimeExports.jsxs("div",{className:"popup--buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:l,children:t("webbuilder.cancel")}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${h?"disabled":""}`,disabled:h,onClick:()=>{o("click-ui"),e(d)},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:l,close:e,translate:n,soundActions:t,...a}){const o=POPUPS[l];return o?jsxRuntimeExports.jsx(o,{type:l,...a.props,closingAction:e,translate:n,soundActions:t}):null}function DisplayingFeedback({feed:l,resolved:e,translate:n,onNext:t}){return l==="success"?jsxRuntimeExports.jsx(FeedbackResult,{success:!0,showButton:!e,onNext:t,translate:n}):l==="failed"?jsxRuntimeExports.jsx(FeedbackResult,{onNext:t,translate:n}):null}function WebBuilderPuzzleComponent({type:l,info:e,emitEvent:n,setResolveAction:t,soundActions:a,disableExit:o,keyboardControl:d}){const[f,h]=React$2.useState(!1),[u,p]=React$2.useState(!1),[x,R]=React$2.useState(!1),[S,E]=React$2.useState(!1),[g,v]=React$2.useState(!1),[T,b]=React$2.useState(null),_=l==="facebook",w=_?FacebookTemplate:BankTemplate,[C,P]=React$2.useState({type:"",props:{}}),[D,N]=React$2.useState(defaultHeader),[k,F]=React$2.useState(defaultBody),[M]=a,U=H=>n({type:"translate",payload:H}),$=()=>{P({type:"",props:{}})},B=(H,W={})=>{P({type:H,props:W})},J=()=>{if(e.solution){const{rewards:H}=e.solution.right,{rewards:W}=e.solution.wrong;M(x?"fail":"score"),n({type:"addPoints",complex:!0,finish:!0,payload:x?W:H}),n({type:"passPuzzle"})}},re=d({disabled:T!=="success",forward:J,escape:J});React$2.useEffect(()=>re(),[re]);const ae=(H,W)=>{const V=Object.keys(H),z={existing:0,equal:0};return V.forEach(q=>{W[q]!==null&&W[q]!==""&&(z.existing+=1),H[q]===W[q]&&(z.equal+=1)}),z},Q=(H,W)=>{const V=Object.keys(w.header).length,z=Object.keys(w.body).length,q=ae(w.header,H),ee=ae(w.body,W),le=ee.existing+q.existing===V+z,ce=ee.equal+q.equal===V+z;return{exist:le,equal:ce}},K=()=>{M("click-ui");const{exist:H,equal:W}=Q(D,k);n({type:"hidePuzzleButtons",payload:!0}),H&&!W?(g&&v(!1),b("failed"),R(!0),n({type:"failPuzzle"})):H&&W&&(g&&(o(!1),v(!1)),E(!0),b("success"))},ne=H=>{if(Object.keys(H).length>0){const W={...D,...H};N(W),$();const{exist:V}=Q(W,k);v(!!V)}},ue=H=>{if(Object.keys(H).length>0){const W={...k,...H};F(W),$();const{exist:V}=Q(D,W);v(!!V)}};React$2.useEffect(()=>{t(H=>{p(!0),b("success"),h(!1),setTimeout(()=>{b(""),H()},4e3)}),o(!0)},[t,o,e.resolve.rewards,n]);const fe={showingReference:f||u,isFacebook:_,openPopup:B,usingTemplate:w,translate:U},te=()=>{T==="failed"?(b(null),n({type:"hidePuzzleButtons",payload:!1})):T==="success"&&J()};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(PopupComponent,{type:C.type,...C,close:$,soundActions:a,translate:U}),jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder",children:[jsxRuntimeExports.jsx(WebBuilderTopBar,{backActive:f,displayButton:!u&&!S,translate:U,clickAction:()=>{M("click-ui"),h(!f)}}),jsxRuntimeExports.jsx(WebBuilderHeader,{...fe,header:D,onSave:ne}),_?jsxRuntimeExports.jsx(WebBuilderFront,{...fe,header:D,onSave:ne}):null,jsxRuntimeExports.jsx(WebBuilderBody,{...fe,body:k,onSave:ue})]}),!g&&!f?jsxRuntimeExports.jsx(DisplayingFeedback,{feed:T,onNext:te,resolved:u,translate:U}):null,g&&!f?jsxRuntimeExports.jsx(PublishButton,{onPublish:K,translate:U}):null]})}function CardImage({img:l}){const n=(l||{}).url;return jsxRuntimeExports.jsx("img",{src:n,alt:""})}function CardText({text:l,hasImage:e}){return l?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:l||"_"})})}):null}function CardNumber({order:l}){return l?jsxRuntimeExports.jsx("div",{className:"card-selector-item__order",children:jsxRuntimeExports.jsx("div",{children:l})}):null}function CardSuccess({order:l}){return jsxRuntimeExports.jsxs("div",{className:"card-selector-item__feedback card-selector-item__feedback--success ",children:[jsxRuntimeExports.jsx(CardNumber,{order:l}),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:l,correct:e,order:n,wrongOrder:t,isEmpty:a}){return!a&&l&&e&&!t?jsxRuntimeExports.jsx(CardSuccess,{order:n}):!a&&l?jsxRuntimeExports.jsx(CardFail,{}):null}function Card({card:l,handleClick:e,flipped:n,cardIndex:t,wrongOrder:a}){const o=()=>!(l.img||l.text),d=()=>!!(n&&!l.correct||!n);return jsxRuntimeExports.jsxs("button",{"data-testid":`card-${t}`,type:"button",order:l.order,onClick:()=>{!o()&&d()&&e(t)},className:`unset-button card-selector-item ${o()?"card-selector-item--empty":""}`,"aria-label":l.text?l.text:null,children:[jsxRuntimeExports.jsx(CardImage,{img:l.img}),jsxRuntimeExports.jsx(CardText,{text:l.text,hasImage:!!l.img}),jsxRuntimeExports.jsx(CardContainer,{isEmpty:o(),flipped:n,wrongOrder:a,order:l.order,correct:l.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:l,currentOrder:e,setCurrentOrder:n,handleError:t,feedbackIsShown:a,resolvePuzzle:o,soundActions:d,onFinish:f,handleSuccess:h,resolveWithAnyCard:u}){const[p,x]=React$2.useState(Array(l.length).fill(!1)),[R,S]=React$2.useState(Array(l.length).fill(!1)),[E,g]=React$2.useState(0),[v,T]=React$2.useState(!1),[b]=d,_=l.filter(M=>M.correct===!0).length,w=l.filter(M=>M.order).length>0,C=React$2.useCallback(()=>{x(Array(l.length).fill(!1)),S(Array(l.length).fill(!1)),g(0),n(1)},[l.length,n]),P=()=>{setTimeout(()=>{C()},1e3)};function D(M,U=M){const $=Array.from(p);$[M]=U,x($)}const N=React$2.useCallback(()=>{const M=[];l.forEach((U,$)=>{U.correct===!0&&M.push($)}),x(M)},[l]);React$2.useEffect(()=>{o&&N()},[N,o]),React$2.useEffect(()=>{(u&&E||E===_&&_>0)&&(f(),T(!0),g(0))},[E,f,_,u]);const k=M=>{D(M),h(l[M].id||null),g(E+1)},F=M=>{var U,$;if(!v&&!a)if(b("click-ui"),l[M].correct&&!w)k(M);else if(w){if(l[M].order===e)n(e+1),k(M);else if(D(M),l[M].order!==e){const B=Array.from(R);B[M]=M,S(B),t(((U=l[M])==null?void 0:U.id)||null,l[M].correct),P()}}else t((($=l[M])==null?void 0:$.id)||null),D(M),setTimeout(()=>{D(M,!1)},1e3)};return jsxRuntimeExports.jsx("div",{className:`cards-selector__content cards-selector__content-${l.length}`,children:l&&l.map((M,U)=>jsxRuntimeExports.jsx(Card,{setCurrentOrder:n,card:M,handleClick:()=>F(U),flipped:p.includes(U),wrongOrder:R.includes(U),cardIndex:U},`cardPuzzle ${l.indexOf(M)}`))})}Board.defaultProps={setCurrentOrder:()=>{},handleError:()=>{},onFinish:()=>{},handleSuccess:()=>{},documentsDict:{},cards:[],currentOrder:1,resolvePuzzle:!1,feedbackIsShown:!1,resolveWithAnyCard:!1};function CardsSelectorPuzzleComponent({emitEvent:l,info:e,cards:n,resolveWithAnyCard:t,specificFeedbacks:a,disableExit:o,setResolveAction:d,soundActions:f,backgroundImage:h,nodeId:u,keyboardControl:p,hideBackgroundImageTheme:x=!1}){var te,H;const[R,S]=React$2.useState(!1),[E,g]=React$2.useState(1),[v,T]=React$2.useState(!1),[b,_]=React$2.useState(!1),[w,C]=React$2.useState(!1),[P,D]=React$2.useState([]),[N,k]=React$2.useState(!1),[F,M]=React$2.useState(""),[U]=f,$=W=>l({type:"translate",payload:W}),B=`cards-selector-puzzle_${u}`,J=React$2.useCallback(W=>{T(!1),C(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"addPoints",complex:!0,finish:!0,payload:W}),l({type:"passPuzzle"})},[l]),re=React$2.useCallback(()=>{var q,ee;l({type:"hidePuzzleButtons",payload:!0}),T(!0);const{rewards:W}=((q=e==null?void 0:e.solution)==null?void 0:q.right)||{},V=((ee=a==null?void 0:a.correctFeedbacks)==null?void 0:ee.map(le=>le.rewards).flat())||[],z=[...P,...W,...V];U("score"),J(z)},[P,J,l,(te=e==null?void 0:e.solution)==null?void 0:te.right,U,a==null?void 0:a.correctFeedbacks]),ae=()=>{S(!0),e.solution.right.desc&&!(a!=null&&a.specificCorrectFeedbacks)&&M(e.solution.right.desc),C(!0)},Q=()=>{v||R?re():(T(!1),o(!1),C(!1),l({type:"hidePuzzleButtons",payload:!1})),M("")},K=W=>{if(_(!0),a!=null&&a.specificCorrectFeedbacks){const V=a.correctFeedbacks.find(z=>z.id===W);V!=null&&V.desc&&(M(V.desc),C(!0))}U("score"),l({type:"hidePuzzleButtons",payload:!0})},ne=(W,V=!1)=>{var z,q;if(_(!1),V)M((z=e.orderFeedback)==null?void 0:z.desc),C(!0),D([...P,...((q=e.orderFeedback)==null?void 0:q.rewards)||[]]);else if(a!=null&&a.specificWrongFeedbacks){const ee=a.wrongFeedbacks.find(le=>le.id===W);ee!=null&&ee.desc?(M(ee.desc),C(!0)):(C(!0),setTimeout(()=>{Q(),l({type:"hidePuzzleButtons",payload:!1})},2e3)),D([...P,...(ee==null?void 0:ee.rewards)||[]])}else e.solution.wrong.desc?(M(e.solution.wrong.desc),C(!0)):(C(!0),setTimeout(()=>{Q(),l({type:"hidePuzzleButtons",payload:!1})},3e3));o(!0),!(a!=null&&a.specificWrongFeedbacks)&&!V&&D([...P,...e.solution.wrong.rewards]),U("fail"),l({type:"hidePuzzleButtons",payload:!0}),l({type:"failPuzzle"})};React$2.useEffect(()=>{R&&o(!0)},[o,R]),React$2.useEffect(()=>{d(()=>{var V;l({type:"hidePuzzleButtons",payload:!0}),k(!0);const W=[...P,...((V=e==null?void 0:e.resolve)==null?void 0:V.rewards)||{}];setTimeout(()=>{T(!1),C(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:B,rewards:W,finish:!0}})},2e3)})},[d,o,P,(H=e==null?void 0:e.resolve)==null?void 0:H.rewards,l,B]);const ue=React$2.useMemo(()=>{let W="";return W="cards-selector",h!=null&&h.url&&(W+=" cards-selector--with-custom-bg"),x&&(W+=" disable-background-image"),W},[h==null?void 0:h.url,x]),fe={backgroundImage:h!=null&&h.url?`url('${h.url}')`:""};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:ue,style:fe,children:jsxRuntimeExports.jsx(Board,{setCurrentOrder:g,currentOrder:E,cards:n,onFinish:ae,resolveWithAnyCard:t,handleError:ne,feedbackIsShown:w,resolvePuzzle:N,soundActions:f,handleSuccess:K})}),w&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:v||b,text:F,hasTimeout:!F,translate:$,functionOnClose:Q,keyboardControl:p})]})}CardsSelectorPuzzleComponent.defaultProps={cards:[],info:{},resolveWithAnyCard:!1,backgroundImage:{url:""}};function Fakecursor(){return jsxRuntimeExports.jsx("span",{className:"fakecursor",children:"|"})}function FixedComponent({delay:l,index:e,length:n,textToPrint:t,setDoneTyping:a,nextParagraphType:o,isWriting:d}){const[f,h]=React$2.useState(!0),[u,p]=React$2.useState(""),[x,R]=React$2.useState(!1);React$2.useEffect(()=>{R(e===n-1)},[e,n]);const S=T=>{if(!T||!T.length)return"";const b=T.replace(/<script.*?>.*?<\/script>/gim,""),_=document.createElement("DIV");return _.innerHTML=b,_.textContent||_.innerText||""};React$2.useEffect(()=>{const T=()=>{const _=t.trim().split(" ");return b(_,_.length-1).join(" ")},b=(_,w)=>{if(w<0)return[""];const C=[..._];if(S(_[w]).length!==0){const P=_[w];return C[w]=`<span class="lastWord" >${P}</span>`,C}return b(_,w-1)};o==="election"?p(T()):setTimeout(()=>{p(t)},200)},[o,t]);const E=()=>{a(!0),h(!1)},g=t.split("<p>");g.shift();const v=g.length>1;return f&&t!==""&&u!==""?jsxRuntimeExports.jsx("span",{className:`writer-inline ${v?"multiple":""} ${x?"Typist":""}`,"data-testid":`result-${e}`,children:jsxRuntimeExports.jsx(Typist,{startDelay:300,avgTypingDelay:l,stdTypingDelay:10,onCharacterTyped:d,onTypingDone:E,cursor:{hideWhenDone:!0,hideWhenDoneDelay:200},blink:!0,children:HTMLReactParser$1(t)})}):jsxRuntimeExports.jsxs("span",{className:`writer-inline ${v?"multiple":""} ${x?"Typist":""}`,"data-testid":`result-${e}`,children:[HTMLReactParser$1(u),o==="election"&&x&&jsxRuntimeExports.jsx(Fakecursor,{})]})}FixedComponent.defaultProps={delay:0,textToPrint:"",setDoneTyping:()=>{},nextParagraphType:"",isWriting:()=>{}};function SingleElection({option:l,decisionInspected:e,setCurrentDecisionSelected:n,index:t,setCurrentDecisionInspected:a,soundActions:o}){const[d]=o,f=R=>R.previewText!==""?HTMLReactParser$1(R.previewText):HTMLReactParser$1(R.fullText),h=R=>R.previewText!==""?e===t?"icon-eye inspected":"icon-eye":"",u=()=>{d("click-ui"),n(t)},p=R=>{R.keyCode===13&&x(R)},x=R=>{R.preventDefault(),R.stopPropagation(),e===t?(R.target.style.background="",a("")):a(t)};return jsxRuntimeExports.jsxs("div",{className:"single-election",children:[jsxRuntimeExports.jsxs("button",{className:"single-election__cta",type:"button",onClick:()=>u(),children:[jsxRuntimeExports.jsx("div",{className:"single-election__btn",children:jsxRuntimeExports.jsx("span",{children:f(l)})}),jsxRuntimeExports.jsx("div",{onClick:x,onKeyDown:p,className:h(l),"aria-label":"Inspect",role:"button",tabIndex:0})]}),e===t&&jsxRuntimeExports.jsx("div",{className:"single-election__complete",children:jsxRuntimeExports.jsx("div",{children:HTMLReactParser$1(l.fullText)})})]})}SingleElection.defaultProps={setCurrentDecisionSelected:()=>{},setCurrentDecisionInspected:()=>{},option:{},index:0};function SingleElectionRender({decisionInspected:l,opt:e,index:n,setCurrentDecisionSelected:t,setCurrentDecisionInspected:a,soundActions:o}){return e&&e.fullText&&e.fullText!==""?jsxRuntimeExports.jsx(SingleElection,{decisionInspected:l,setCurrentDecisionSelected:t,setCurrentDecisionInspected:a,option:e,soundActions:o,index:n}):null}function ElectionComponent({textWithOpts:l,setCurrentDecisionSelected:e,printed:n,soundActions:t}){const[a,o]=React$2.useState("");return React$2.useEffect(()=>{n()},[n]),jsxRuntimeExports.jsx("div",{className:`elections-box pos${a+1}-${l.filter(d=>!!d.fullText).length}`,children:l&&l.map((d,f)=>jsxRuntimeExports.jsx(SingleElectionRender,{opt:d,soundActions:t,index:f,setCurrentDecisionSelected:e,setCurrentDecisionInspected:o,decisionInspected:a},f))})}ElectionComponent.defaultProps={textWithOpts:[],setCurrentDecisionSelected:()=>{},printed:()=>{}};function FeedbackElement({decision:l}){const{title:e,body:n}=l.feedback;return jsxRuntimeExports.jsx("div",{children:n!==""&&jsxRuntimeExports.jsxs("div",{className:"writer-feedback-decision-item",children:[e&&jsxRuntimeExports.jsxs("div",{dir:"auto",className:"writer-feedback-decision-item__title",children:[e," "]}),n&&jsxRuntimeExports.jsxs("div",{dir:"auto",className:"writer-feedback-decision-item__message",children:[l.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:n})]})]})})}FeedbackElement.defaultProps={decision:{}};function FeedbackComponent({emitEvent:l,closingAction:e,feedbackIsDone:n,decisionsList:t,texts:a,retryAction:o,retry:d,skip:f,checkCorrect:h,rewardsStack:u,setFailed:p,soundActions:x}){const[R]=x,S=g=>l({type:"translate",payload:g}),E=()=>{R("click-ui"),e(),p(),n()};return jsxRuntimeExports.jsxs("div",{className:`writer-feedback ${u.length?"":"start"}`,children:[jsxRuntimeExports.jsx("div",{className:"writer-feedback__title",children:S("puzzles.feedback")}),jsxRuntimeExports.jsx("div",{className:"writer-feedback__decisions",children:t.map(g=>a[g.currenTextParagraph].electionTexts[g.index].feedback.body?jsxRuntimeExports.jsx(FeedbackElement,{decision:a[g.currenTextParagraph].electionTexts[g.index]},g.index):null)}),jsxRuntimeExports.jsxs("div",{className:"writer-feedback__btns",children:[f&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary writer-feedback__btn-mobile",onClick:()=>{E()},children:S("puzzles.skip")}),d&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>{h()?E():(R("click-ui"),o())},children:S(h()?"puzzles.continue":"puzzles.retry")}),!d&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>E(),children:S("puzzles.continue")})]})]})}FeedbackComponent.defaultProps={emitEvent:()=>{},closingAction:()=>{},feedbackIsDone:()=>{},decisionsList:[],texts:[],retryAction:()=>{},retry:!1,skip:!1,checkCorrect:()=>{},nodeId:"0"};function FinishedTextComponent({textToPrint:l,correct:e}){const n=l.split("<p>");n.shift();const t=n.length>1;return jsxRuntimeExports.jsx("span",{className:`writer-inline ${t?"multiple":""} ${e}`,children:HTMLReactParser$1(l)})}FinishedTextComponent.defaultProps={correct:"",textToPrint:""};function WriterPuzzleComponent({emitEvent:l,styles:e,nodeId:n,retry:t,skip:a,type:o,info:d,setResolveAction:f,documentTitle:h,documentTitle_labelId:u,texts:p,soundActions:x,backgroundImage:R,hideBackgroundImageTheme:S=!1}){const E=rt=>l({type:"translate",payload:rt}),g=React$2.useRef(),[v,T]=React$2.useState(!1),[b,_]=React$2.useState(!1),[w,C]=React$2.useState(0),[P,D]=React$2.useState({[`text_${w}`]:{...p[w],id:`text_${w}`,correct:""}}),[N,k]=React$2.useState(!1),[F,M]=React$2.useState([]),[U,$]=React$2.useState(!1),[B,J]=React$2.useState(!1),[re,ae]=React$2.useState(!1),[Q,K]=React$2.useState(!0),[ne,ue]=React$2.useState([]),[fe,te]=React$2.useState(!0),[H]=x,W=React$2.useRef({}),V=rt=>{let xt;return rt.electionTexts.forEach((Et,Qe)=>{Et.correct&&(xt=Qe)}),xt},z=React$2.useCallback(rt=>F.filter(Et=>Et.currenTextParagraph===rt)[0].fullText_labelId,[F]),q=React$2.useCallback(()=>p.map((rt,xt)=>{if(rt.type==="fixed")return rt.fullText_labelId??rt.fullText;if(rt.type==="election"){const Et=V(rt);return Et>=0?rt.electionTexts[Et].fullText_labelId:z(xt)}return""}),[z,p]),ee=12,le=()=>{if(F){const rt=F.length;let xt=0;for(let Et=0;Et<rt;Et+=1)F[Et].isCorrect==="none"&&(xt+=1);return xt===rt}return!0},ce=React$2.useCallback(()=>{if(F){const rt=F.length;let xt=0;for(let Et=0;Et<rt;Et+=1)F[Et].isCorrect==="green"&&(xt+=1);return xt===rt}return!0},[F]),he=()=>!!(F&&F.length),ve=()=>F.find(rt=>{const{feedback:xt}=p[rt.currenTextParagraph].electionTexts[rt.index];return xt.body!==""}),be=React$2.useCallback(()=>{const rt=q();l({type:"finishMedia",payload:{name:u,text:rt,documentType:o,type:"text"}})},[q,u,l,o]),Re=React$2.useCallback(rt=>{const xt=ce();H(b?"fail":xt?"score":"fail"),l({type:"addPoints",complex:!0,finish:!0,payload:rt||ne,onFinish:o!=="view"?be:null}),l({type:"passPuzzle"})},[ce,l,b,be,H,ne,o]);React$2.useEffect(()=>{v&&te(!1),f(()=>{Re(d.resolve.rewards)})},[l,Re,v,be,d.resolve.rewards,f,o]);const Le=()=>{T(!1),C(0),M([]),ue([]),_(!1),ae(!1),k(!1),J(!1),$(!1),D({text_0:{...p[0],id:"text_0",correct:""}}),K(!0),l({type:"addPoints",complex:!0,finish:!1,payload:ne}),l({type:"failPuzzle"})},Oe=()=>{he()?le()&&($(!0),Re()):($(!0),ae(!0),Re()),U?(K(!1),re&&!B?J(!0):(B||!re&&!B)&&(!re&&!B&&t?ce()?Re():Le():Re())):($(!0),ve()&&ae(!0))},Ke=()=>{const rt=p[w].electionTexts.filter(Et=>Et.correct).length,xt=p[w].electionTexts;return rt===0||rt===xt},St=rt=>{const xt=p[w].electionTexts[rt],Et=xt.feedback.rewards;Et&&Et[0]&&Et[0].points&&(W.current[`t${w}_e${rt}`]||(xt.correct&&(W.current[`t${w}_e${rt}`]=!0),ue([...ne,...Et])));const Qe=()=>Ke()?"none":xt.correct?"green":"red",Be={currenTextParagraph:w,fullText:xt.fullText,index:rt,isCorrect:Qe()};D({...P,[`text_${w}`]:{type:"fixed",fullText:xt.fullText,correct:Be.isCorrect}}),M([...F,Be])},it=()=>{g.current.scrollTop=g.current.scrollHeight+100},gt=()=>{if(g.current.querySelector(".wrapfixed").offsetHeight>g.current.offsetHeight){const rt=g.current.querySelector(".wrapfixed").offsetHeight;g.current.scrollTo({top:rt,behavior:"smooth"})}},Ge=(rt,xt,Et)=>{const Qe=rt.fullText,Be=p[Et+1]?p[Et+1].type:"",Xe=P[`text_${Et+1}`]&&P[`text_${Et+1}`].type?P[`text_${Et+1}`].type:Be;return jsxRuntimeExports.jsx(FixedComponent,{length:xt,doneTyping:N,index:Et,delay:ee,setDoneTyping:k,nextParagraphType:Xe,isWriting:gt,textToPrint:Qe},Et.toString())},Me=(rt,xt)=>{const Et=rt.fullText;return jsxRuntimeExports.jsx(FinishedTextComponent,{textToPrint:Et,correct:rt.correct},xt)},De=rt=>jsxRuntimeExports.jsx(ElectionComponent,{soundActions:x,textWithOpts:rt.electionTexts,setCurrentDecisionSelected:St,printed:it,disableExit:fe},rt.electionTexts),Ve=(rt,xt,Et)=>rt.type==="fixed"?Ge(rt,xt,Et):De(rt);React$2.useEffect(()=>{N===!0&&(()=>{p[w+1]?(D({...P,[`text_${w+1}`]:{...p[w+1],id:`text_${w+1}`,correct:""}}),C(w+1),k(!1)):T(!0)})()},[N,w,P,p]);const ct=React$2.useMemo(()=>{let rt=`writer-puzzle writer-puzzle--${e}`;return S&&(rt+=" disable-background-image"),rt},[S,e]),dt={backgroundImage:R!=null&&R.url?`url('${R.url}')`:""};return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:ct,style:dt,children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__overlay",children:[B&&jsxRuntimeExports.jsx(FeedbackComponent,{emitEvent:l,texts:p,setFailed:()=>_(!0),decisionsList:F,closingAction:Oe,retry:t,skip:a,checkCorrect:ce,retryAction:Le,rewardsStack:ne,nodeId:n,soundActions:x}),!B&&jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__container",children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"writer-puzzle__title",children:h!==""&&h}),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:g,children:[jsxRuntimeExports.jsx("div",{className:"wrapfixed",children:Q&&!U&&Object.values(P).map((rt,xt)=>Ve(rt,Object.values(P).length-1,xt))}),U&&Object.values(P).map((rt,xt)=>Me(rt,xt))]})}),v&&jsxRuntimeExports.jsx("div",{className:"writer-puzzle__footer",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:Oe,children:E("screens.continue")})})]})]})})})}WriterPuzzleComponent.defaultProps={emitEvent:()=>{},info:{},styles:"",nodeId:"0",retry:!1,skip:!1,type:"",documentTitle:"",texts:[]};function Image$1({document:l,name:e,isWallpaper:n}){const t=(l==null?void 0:l.url)||null;return jsxRuntimeExports.jsx("div",{className:`puzzle--terminal__image ${n?"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:l,solution:e,showContinue:n,info:t,resolvePuzzle:a,backFile:o,translate:d,soundActions:f,keyboardControl:h}){var b;const{fileId:u}=l,p=((b=l.document)==null?void 0:b.url)||"",[x]=f,R={image:{component:Image$1,props:{...l,url:p,soundActions:f}},video:{component:VideoVisor,props:{...l,url:p,endVideo:a,soundActions:f,translate:d}},embedded_video:{component:VideoVisor,props:{...l,url:p,soundActions:f}},pdf:{component:PdfVisor,props:{...l,url:p,translate:d,soundActions:f,emitNumberOfPages:()=>{},endPdf:()=>{},keyboardControl:h}},application:{component:PdfVisor,props:{...l,url:p,translate:d,soundActions:f,emitNumberOfPages:()=>{},keyboardControl:h,endPdf:()=>{}}}};if(!R[l.type])return null;const S=R[l.type].component,E=R[l.type].props,v=l.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:x,shortText:!0,success:u===T,text:u===T?t.solution.right.desc:t.solution.wrong.desc,functionOnClose:u===T?a:o,additionalStyle:ICONS$1[l.type],secondText:v,translate:d,puzzleHeaderClass:"puzzle--terminal__visor--message",keyboardControl:h}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__visor--body",children:jsxRuntimeExports.jsx(S,{...E})}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__button",children:u===T&&n?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary green",type:"button",onClick:a,children:d("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:l,selectItem:e}){const n=l.name;return jsxRuntimeExports.jsx("li",{className:"puzzle--terminal__folder__list--item",children:jsxRuntimeExports.jsxs("button",{type:"button",title:n,className:`unset-button puzzle--terminal__item id-${l.id}`,onClick:()=>l.fixed?null:e(l),children:[jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__icon ${ICONS[l.type]}`}),jsxRuntimeExports.jsx("span",{children:n})]})})}function FilesGroup({initFile:l,backFile:e,file:n,closeFolder:t,selectItem:a}){return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:n.id==="init"?jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:n.children.map((o,d)=>jsxRuntimeExports.jsx(Item,{selectItem:a,item:o},`${`${d}${o.id}`}`))}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:l.children.map((o,d)=>jsxRuntimeExports.jsx(Item,{selectItem:a,item:o},`${d+o.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[n.type]}`}),jsxRuntimeExports.jsx("span",{className:"text",children:n.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:n.children.map((o,d)=>jsxRuntimeExports.jsx(Item,{selectItem:a,item:o},`${d+o.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:l,items:e,backgroundImage:n,solution:t,info:a,disableExit:o,soundActions:d,setResolveAction:f,nodeId:h,keyboardControl:u}){const[p,x]=React$2.useState({}),[R]=React$2.useState(!1),[S,E]=React$2.useState([]),g=React$2.useRef([]),[v]=d,T=k=>l({type:"translate",payload:k}),b=`terminal-puzzle_${h}`,_=React$2.useMemo(()=>({name:"init",children:[...FIXED_ITEMS,...e],id:"init"}),[e]),w=React$2.useCallback(k=>{v("click-ui"),x(k),E([...S,k]),k.type!=="folder"&&(l({type:"hidePuzzleButtons",payload:!0}),o(!0))},[S,o,l,v]);React$2.useEffect(()=>{x(_),E([_])},[_]),React$2.useEffect(()=>{f(()=>{g.current=[...g.current,...a.resolve.rewards];const k=g.current.map(F=>{var re;const{name:M,points:U,type:$,id:B}=F,J={name:M,points:U,type:$,id:B};return(re=F==null?void 0:F.document)!=null&&re.resourceId&&(J.id=F.document.resourceId),J});l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:b,rewards:k,finish:!0}})})},[f,a.resolve.rewards,l,b]);const C=()=>{g.current=[...g.current,...a.solution.wrong.rewards];const k=S.length-1,F=S.filter((M,U)=>k>U);x(S[k-1]),E(F),o(!1),l({type:"hidePuzzleButtons",payload:!1})},P=()=>{v("click-ui");const k=S[0];x(k),E([k])},D=()=>{g.current=[...g.current,...a.solution.right.rewards];const k=g.current.map(F=>{var re;const{name:M,points:U,type:$,id:B}=F,J={name:M,points:U,type:$,id:B};return(re=F==null?void 0:F.document)!=null&&re.resourceId&&(J.id=F.document.resourceId),J});l({type:"hidePuzzleButtons",payload:!1}),v("score"),l({type:"addPoints",complex:!0,finish:!0,payload:k}),l({type:"passPuzzle"})},N=(n==null?void 0:n.url)||DEFAULT_IMG;return jsxRuntimeExports.jsx("div",{className:"puzzle--terminal",children:p.children?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Image$1,{isWallpaper:!0,document:{url:N}}),jsxRuntimeExports.jsx(FilesGroup,{backFile:C,initFile:_,selectItem:w,breadcrumb:S,closeFolder:P,file:p,translate:T})]}):jsxRuntimeExports.jsx(Visor,{soundActions:d,backFile:C,resolvePuzzle:D,info:a,showContinue:!R,solution:t,file:p,translate:T,keyboardControl:u})})}function DragItemPuzzleComponent({area:l,image:e,resolveObject:n,info:t,hasHighlights:a,consume:o,disableExit:d,emitEvent:f,soundActions:h,keyboardControl:u}){const{solution:p}=t,x=React$2.useRef(),R=React$2.useRef(),S=React$2.useRef(),E=React$2.useRef(),g=React$2.useRef({}),[v,T]=React$2.useState(""),[b,_]=React$2.useState(!1),[w,C]=React$2.useState(),[P]=React$2.useState(new window.Image),D=React$2.useRef([]),[N]=h,k=fe=>f({type:"translate",payload:fe});React$2.useEffect(()=>{d(v!=="")},[v,d]);const F=(fe,te)=>(fe.x+fe.width>te.x&&fe.x+fe.width<=te.x+te.width||te.x+te.width>fe.x&&te.x+te.width<=fe.x+fe.width)&&(fe.y+fe.height>te.y&&fe.y+fe.height<=te.y+te.height||te.y+te.height>fe.y&&te.y+te.height<=fe.y+fe.height),M=()=>{x&&a&&(x.current.to({duration:.25,opacity:.75}),R.current.to({duration:.25,opacity:.4}))},U=()=>{x&&a&&(x.current.to({duration:.25,opacity:0}),R.current.to({duration:.25,opacity:0}))},$=React$2.useCallback(fe=>{let te=!1;if(fe){const H=S.current;H.setPointersPositions(fe);const W=H.getPointerPosition(),V=x.current.getClientRect({relativeTo:H});te=F({...W,width:1,height:1},V)}return te},[]),B=React$2.useCallback(fe=>fe&&n.uid===JSON.parse(fe).uid,[n.uid]),J=React$2.useCallback(()=>{T(""),f({type:"hidePuzzleButtons",payload:!1}),f({type:"addPoints",complex:!0,finish:!0,payload:D.current}),f({type:"passPuzzle"}),o&&f({type:"consumeItem",payload:{uid:n.uid,targetId:n.uid,name:n.name}}),f({type:"closeUI",ui:"inventory"})},[o,f,n.name,n.uid]),re=React$2.useCallback(()=>{T("success"),f({type:"hidePuzzleButtons",payload:!0}),D.current=[...D.current,...p.right.rewards],setTimeout(()=>{J()},2e3)},[f,J,p.right.rewards]),ae=React$2.useCallback(()=>{f({type:"openUI",ui:"inventory",onFinish:()=>{}}),T(""),f({type:"hidePuzzleButtons",payload:!1}),f({type:"failPuzzle"}),D.current=[...D.current,...p.wrong.rewards]},[f,p.wrong.rewards]),Q=React$2.useCallback(fe=>{const te=fe.dataTransfer.getData("item");S.current.setPointersPositions(fe);const H=$(fe);f({type:"hidePuzzleButtons",payload:!0}),H&&B(te)?(T("success"),f({type:"closeUI",ui:"inventory"}),t.solution.right.desc===""&&re()):(f({type:"closeUI",ui:"inventory"}),T("failed"),t.solution.wrong.desc===""&&setTimeout(()=>{ae()},2e3))},[$,B,f,re,ae,t.solution.right.desc,t.solution.wrong.desc]),K=()=>{v==="success"?re():ae()};React$2.useEffect(()=>{const fe=e.img.url||"";P.src=fe,P.onload=()=>{E.current&&(g.current={x:E.current.clientWidth/2,y:E.current.clientHeight/2,width:P.width,height:P.height,offsetX:P.width/2,offsetY:P.height/2,scale:{x:Math.min(E.current.clientWidth/P.width,E.current.clientHeight/P.height),y:Math.min(E.current.clientWidth/P.width,E.current.clientHeight/P.height)}},_(!0))}},[P,e.img.url]);const ne=fe=>{fe!==null&&(x.current=fe)},ue=fe=>{if(fe!==null&&(R.current=fe,x.current)){const{x:te,y:H,width:W,height:V}=x.current.getClientRect();fe.setAttr("x",te),fe.setAttr("y",H),fe.setAttr("height",V),fe.setAttr("width",W)}};return React$2.useLayoutEffect(()=>{if(x.current&&b){const fe=x.current.getClientRect({relativeTo:x.current.getParent()});C({x:fe.x+fe.width/2,y:fe.y+fe.height/2})}},[b]),jsxRuntimeExports.jsxs("div",{className:"puzzle--drag__mask100",onDrop:Q,onDragOver:fe=>{fe.preventDefault()},children:[jsxRuntimeExports.jsx("div",{className:"puzzle--drag__mask",children:jsxRuntimeExports.jsx("div",{ref:E,"data-testid":"mask_canvas",className:"puzzle--drag__mask--canvas",children:b?jsxRuntimeExports.jsx(Stage,{ref:S,width:E.current.clientWidth,height:E.current.clientHeight,children:jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Image$2,{image:P,...g.current}),jsxRuntimeExports.jsxs(Group,{...g.current,children:[w?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...w},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:"object-area-projection"})}):null,jsxRuntimeExports.jsx(Line,{onMouseEnter:M,onMouseLeave:U,ref:ne,...l,shape:"poly",fill:"#262a31d9",stroke:"white",strokeWidth:1,opacity:0,dash:[3,2],closed:!0,draggable:!1})]}),jsxRuntimeExports.jsx(Text,{onMouseEnter:M,onMouseLeave:U,ref:ue,text:k("puzzle.drag.dropzone"),fontSize:12,align:"center",verticalAlign:"middle",fill:"#ffffff",opacity:0})]})}):null})}),v!==""?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:t.solution[v==="success"?"right":"wrong"].desc,success:v==="success",translate:k,playSound:N,functionOnClose:K,keyboardControl:u}):null]})}const LABELS_INDEX$1=["A","B","C","D","E","F","G","H","I","J"];function Questions({disabled:l,answered:e,question:n,updateForm:t,result:a,correctQuestions:o,translate:d}){const[f,h]=React$2.useState(!1),u=n.answers.filter(v=>v.text),p=v=>{let T=!1;return a[n.id].find(b=>b.id===v)&&(T=!0),T},x=v=>{let T="";return f?(e&&p(v.id)&&(T="selected"),l&&p(v.id)&&o.includes(v.id)&&(T="success"),l&&p(v.id)&&!o.includes(v.id)&&(T="failed")):(e&&v.id===a[n.id][0].id&&(T="selected"),l&&v.id===a[n.id][0].id&&(T=a[n.id][0].isCorrect?"success":"failed")),T},R=v=>{const T=x(v);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":""},S=v=>l&&v.feedback&&(f&&p(v.id)||v.id===a[n.id][0].id),E=(v,T)=>T===0?"tooltip--right__top":T===v.length-1?"tooltip--right__bottom":"tooltip--center__right",g=n.answers.filter(v=>v.isCorrect);return React$2.useEffect(()=>{g.length===1?h(!1):h(!0)},[g.length,f,n.answers]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:n.text})}),f&&!l?jsxRuntimeExports.jsx("div",{className:"test--questions__intertitle test--questions__intertitle--multiresponse",children:d("tests.chooseMoreOneAnswer")}):null,u.map((v,T)=>jsxRuntimeExports.jsxs("div",{className:"test--response__fakeinput",children:[f?jsxRuntimeExports.jsx("input",{checked:e&&p(v.id),disabled:l&&!p(v.id),readOnly:l,type:"checkbox",id:v.id,onChange:()=>l?null:t(v,n.id,T,"isCheckbox",v.id)}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("input",{checked:e&&v.id===a[n.id][0].id,disabled:l&&!x(v),type:"radio",name:"name",id:v.id,onChange:()=>l?null:t(v,n.id,T,"isRadio")})}),jsxRuntimeExports.jsxs("label",{htmlFor:v.id,className:`test--response__item ${x(v)}`,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:v.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${R(v)}`})]}),l?jsxRuntimeExports.jsxs("div",{className:`test--feedback__info ${S(v)?"":"test--feedback__info--hidden"}`,children:[jsxRuntimeExports.jsx("span",{className:`icon-info2 ${x(v)==="success"?"color--success":"color--error"}`}),jsxRuntimeExports.jsxs("div",{id:`tooltipFeedback-${T}`,className:`tooltip ${E(u,T)}`,children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsx("span",{children:d("test.feedback")})})}),jsxRuntimeExports.jsx("span",{children:jsxRuntimeExports.jsx("span",{children:v.feedback})})]})]}):null]},v.text))]})}const LABELS_INDEX=["A","B","C","D","E","F","G","H","I","J"];function FeedbackItem({selectedAnswers:l,correctQuestions:e,question:n,translate:t}){const a=f=>e.includes(f),o=(f,h)=>f.index<h.index?-1:f.index>h.index?1:0,d=l.sort(o);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:n})}),d.map(f=>jsxRuntimeExports.jsxs("div",{className:"test--response__itemwrap",children:[jsxRuntimeExports.jsxs("div",{className:`test--response__item ${a(f.id)?"success":"failed"}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX[f.index]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:f.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${a(f.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")," ",l.length>1?LABELS_INDEX[f.index]:""]})})}),jsxRuntimeExports.jsx("span",{children:f.feedback})]})]},f.text))]})}function Container({questions:l,setTime:e,saveInterval:n,result:t,setTries:a,tries:o,time:d,showResults:f,answered:h,answerPage:u,updateForm:p,disabled:x,translate:R,soundActions:S,paused:E,view:g,correctQuestions:v,feedbacksOnlyWhenReview:T}){const b=document.querySelector(".test--container"),[_,w]=React$2.useState(0),[C,P]=React$2.useState(),D=l[_].id,[N]=S;React$2.useEffect(()=>{if(d>=0&&!x&&!E){const re=setInterval(()=>{C||e(ae=>ae-1)},1e3);return n(re),()=>{clearInterval(re)}}},[x,C,E,n,e,d]);const k=()=>{b.scrollTo(0,0),N("click-ui"),h&&(t[D][0].feedback&&!x&&!T?P(!0):(u(!1),w(_+1)))},F=()=>{N("click-ui"),w(_-1)},M=()=>{b.scrollTo(0,0),l[_+1]?(P(!1),u(!1),w(_+1)):f()},U=()=>{b.scrollTo(0,0),a(o+1),t[D][0].feedback&&!x&&!T?P(!0):f()},$=Math.floor(d/60),B=d%60;React$2.useEffect(()=>{if(g==="review"){const re=t[`q${_}`][0].id,ae=document.querySelector(`#${re}`);b.scrollTo(0,ae.offsetTop)}},[_,b,t,g]);const J=()=>{if(h){const re=v[l[_].id.substring(1)].answers,ae=t[D],Q=ae.find(ne=>ne.isCorrect===!1);let K=0;return ae.forEach(ne=>{re.includes(ne.id)&&(K+=1)}),!Q&&K===re.length}return!1};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[g==="review"||C?jsxRuntimeExports.jsx("div",{"data-testid":"feedbackWrapper",className:`test-feedback-header ${J()?"success":"failed"}`,children:jsxRuntimeExports.jsxs("h2",{children:[jsxRuntimeExports.jsx("span",{className:`${J()?"icon-correct-thumb":"icon-incorrect-thumb"}`}),jsxRuntimeExports.jsx("span",{className:"test-feedback-header__title",children:J()?R("tests.resolvedQuestion"):R("tests.notResolvedQuestion")})]})}):null,jsxRuntimeExports.jsxs("div",{className:"test--questions",children:[jsxRuntimeExports.jsx("div",{className:"test--questions__container",children:C?jsxRuntimeExports.jsx(FeedbackItem,{selectedAnswers:t[D],correctQuestions:v[l[_].id.substring(1)].answers,question:l[_].text,translate:R}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"test--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:LangIsRtl()?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[_+1,"/",l.length," ",jsxRuntimeExports.jsx("span",{children:R("tests.question")})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{children:R("tests.question")})," ",_+1,"/",l.length]})}),g!=="review"&&d>=0?jsxRuntimeExports.jsx("div",{dir:"ltr",className:`count-down ${d<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{id:"test-time",children:[$<10?`0${$}`:$," : ",B<10?`0${B}`:B]})}):null]}),jsxRuntimeExports.jsx(Questions,{result:t,disabled:x,answered:h,updateForm:p,question:l[_],correctQuestions:x?v[l[_].id.substring(1)].answers:[],translate:R},l[_].id)]})}),jsxRuntimeExports.jsxs("div",{className:`test--buttons ${g==="review"?"reviewmode":"next"}`,children:[g==="review"?jsxRuntimeExports.jsx("button",{disabled:_===0,id:"back-button",onClick:()=>F(),type:"button",className:`gat--btn__navigation ${_===0?"disabled":""}`,"aria-label":LangIsRtl()?R("survey.next"):R("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}):null,!C&&l[_+1]?jsxRuntimeExports.jsx("button",{disabled:!h,id:"next-button","data-testid":"nextButton",onClick:()=>k(),type:"button",className:`gat--btn__navigation ${h?"":"disabled"}`,"aria-label":LangIsRtl()?R("survey.previous"):R("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null,C?jsxRuntimeExports.jsx("button",{id:"next-button","data-testid":"nextFeedbackButton",onClick:()=>M(),type:"button",className:"gat--btn__navigation",children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null,!C&&l[_].id.substring(1)===(l.length-1).toString()?jsxRuntimeExports.jsx("button",{disabled:!h,id:"continue-button","data-testid":"continueButton",onClick:()=>{N("click-ui"),h&&U()},type:"button",className:`gat--btn__navigation ${h?"":"disabled"}`,"aria-label":LangIsRtl()?R("survey.previous"):R("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null]})]})]})}function ResultsComponent({result:l,time:e,mandatory:n,correctQuestions:t,isFirst:a,reviewTest:o,finishTest:d,restartTest:f,timeOver:h,timeOverText:u,emitEvent:p,minimumPercentage:x}){const R=React$2.useRef(),[S,E]=React$2.useState(0),[g,v]=React$2.useState(),[T,b]=React$2.useState([]),[_,w]=React$2.useState([]),[C,P]=React$2.useState(),D=React$2.useCallback(()=>{const K=[];return t.forEach(ne=>K.push(ne.answers)),K},[t]),N=React$2.useCallback(()=>{const K=[];return Object.values(l).forEach(ne=>{if(ne.length>1){const ue=ne.find(te=>te.isCorrect===!1),fe=[];ue?K.push([]):(ne.forEach(te=>{te.isCorrect&&fe.push(te.id)}),K.push(fe))}else ne[0].isCorrect?K.push([ne[0].id]):ne[0].isCorrect===!1&&K.push("")}),K},[l]),k=React$2.useCallback(()=>{let K=0;if(_.length>0)return T.forEach((ne,ue)=>{ne.length>1?ne.every(fe=>{var te;return(te=_[ue])==null?void 0:te.includes(fe)})&&(K+=1):ne.length===1&&_[ue]&&ne[0]===_[ue][0]&&(K+=1)}),K},[T,_]);React$2.useEffect(()=>{C===void 0&&(b(D),w(N),P(k))},[D,N,k,C]);const F=t.length,M=k()===F,U=C<x,$=C>=x,B=!n||$,J=Math.trunc(S/F*100),re=(K,ne)=>p({type:"translate",payload:K,values:ne}),ae={"--chart-color":"var(--color-error)"};React$2.useEffect(()=>{if(S<C){const K=setInterval(()=>{E(ne=>ne+1)},100);return v(K),()=>{clearInterval(K)}}},[C,S]),React$2.useEffect(()=>{S>=C&&clearInterval(g)},[C,g,S]);const Q=()=>{R.current=!0,d()};return jsxRuntimeExports.jsxs("div",{"data-testid":"resultsWrapper",className:`test--results ${U||h?"test--results--failed":""}`,children:[a&&M?jsxRuntimeExports.jsxs("div",{"data-testid":"fireworks",className:"fireworks",children:[jsxRuntimeExports.jsx("div",{className:"before"}),jsxRuntimeExports.jsx("div",{className:"after"})]}):null,!h&&U?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:re("tests.NotFinishedSuccessfully")})}):null,!h&&$||M?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:re("tests.finishedSuccessfully")})}):null,h?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:u})}),jsxRuntimeExports.jsx("div",{className:"test--results__time",id:"results-time",children:jsxRuntimeExports.jsx("span",{children:re("tests.time",e)})})]}):null,jsxRuntimeExports.jsxs("div",{className:`chart center chart${J}`,children:[jsxRuntimeExports.jsxs("div",{className:"chart-slice",children:[jsxRuntimeExports.jsx("div",{className:"chart-bar",style:U||h?ae:{}}),jsxRuntimeExports.jsx("div",{className:"chart-fill",style:U||h?ae:{}})]}),jsxRuntimeExports.jsxs("span",{className:"chart-value",children:[jsxRuntimeExports.jsxs("div",{className:"test--results__chart",children:[jsxRuntimeExports.jsx("span",{"data-testid":"correctPoints",children:S}),jsxRuntimeExports.jsxs("span",{"data-testid":"totalCorrectAnswers",children:["/",F]})]}),jsxRuntimeExports.jsx("div",{className:"test--results__chart--label",children:jsxRuntimeExports.jsx("span",{children:re("tests.success")})})]})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__minimum",children:[jsxRuntimeExports.jsx("div",{className:"icon-bell"}),jsxRuntimeExports.jsx("div",{children:re("tests.minimumQuestionsMessage",{minimumPercentage:x})})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__buttons",children:[h?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__secondary",id:"review-button",onClick:()=>o(),type:"button",children:jsxRuntimeExports.jsx("span",{children:re("tests.review")})}),B?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary","data-testid":"restartButton",id:"restart-button",onClick:()=>f(),type:"button",children:jsxRuntimeExports.jsx("span",{children:re("tests.restart")})}),B?jsxRuntimeExports.jsx("button",{disabled:R.current===!0,className:`gat--btn gat--btn__primary ${R.current===!0&&"disabled"}`,"data-testid":"finishButton",id:"finish-button",onClick:()=>Q(),type:"button",children:jsxRuntimeExports.jsx("span",{children:re("tests.continue")})}):null]})]})}function TestComponent({test:l,countdown:e={},emitEvent:n,soundActions:t,audio:a,required:o,pause:d,minimumPercentage:f=100,feedbacksOnlyWhenReview:h}){const{questions:u}=l,[p,x]=React$2.useState({}),[R,S]=React$2.useState(),[E,g]=React$2.useState(0),[v,T]=React$2.useState([]),[b,_]=React$2.useState(e.time),[w,C]=React$2.useState(!1),[P,D]=React$2.useState("test"),[N,k]=React$2.useState(!0),[F,M]=React$2.useState({}),[U,$]=React$2.useState({}),[B,J]=React$2.useState(!1),re=o||l.required||!1,ae=React$2.useRef({}),[Q,K]=React$2.useState(),[ne,ue]=t,fe=(q,ee,le,ce,he)=>{const ve={...q,index:le};if(E>0&&(ve.rewards=ve.rewards.filter(Re=>!U[q.id]||Re.points<0)),p[ee]){const Re=p[ee].find(Le=>Le.id===he);if(Re){if(Re.id===q.id){const Le=p[ee].find(Ke=>Ke.id===he),Oe=p[ee].indexOf(Le);if(p[ee].splice(Oe,1),p[ee].length===0){C(!1);return}}}else p[ee].push(ve)}else p[ee]=[ve];let be;ce==="isRadio"?be={...p,[ee]:[ve]}:be={...p},x(be),M(be),$({...U,[q.id]:{...q}}),C(!0)};React$2.useEffect(()=>{a!=null&&a.url&&ne(a.url,"tts")},[ne,a]);const te=u.map(q=>{const ee=q.answers.filter(ce=>ce.isCorrect),le=[];return ee.forEach(ce=>{le.push(ce.id)}),{question:q.id,answers:le}});React$2.useEffect(()=>{v.length===0&&T(te)},[v.length,te]),React$2.useEffect(()=>{if(f){const q=Math.ceil(u.length*f/100);K(q)}},[u.length,f]),React$2.useEffect(()=>{b===0&&(clearInterval(R),C(!1),J(!0),D("results"),ue("tts"))},[R,ue,b]);const H=()=>{clearInterval(R),C(!1),D("results");const q={...F};M(q),ue("tts")},W=()=>{const q={correctQuestions:v.length,result:p,status:"resolved"};Object.keys(p).forEach(le=>{p[le].forEach(ce=>{ae.current[ce.id]&&(ce.rewards=[])})}),n({type:"saveTest",payload:q})},V=()=>{const q=()=>{M({}),$({}),D("test"),x({}),_(e.time),J(!1),a!=null&&a.url&&ne(a.url,"tts")},ee=Object.values(p);ee.forEach(ce=>{ce.forEach(he=>{he.isCorrect&&(ae.current[he.id]?he.rewards=[]:ae.current[he.id]=!0)})});let le=ee.reduce((ce,he)=>{const ve=[];return he.forEach(be=>{ve.push(be.rewards)}),[...ce,...ve.flat()]},[]);B&&e.rewards&&(le=[...le,...e.rewards]),n({type:"addPoints",payload:le,complex:!0,finish:!1,onFinish:q()}),n({type:"failTest"})},z=(q,ee)=>n({type:"translate",payload:q,values:ee});return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--container__overlay"}),jsxRuntimeExports.jsx("div",{"data-testid":"wrapperTest",className:"test--container",dir:"auto",children:P!=="results"?jsxRuntimeExports.jsx(Container,{result:p,time:b,setTries:g,tries:E,answerPage:C,setTime:_,paused:d,saveInterval:S,disabled:P!=="test",answered:w||P!=="test",questions:u,updateForm:fe,showResults:H,translate:z,soundActions:t,view:P,correctQuestions:v,feedbacksOnlyWhenReview:h}):jsxRuntimeExports.jsx(ResultsComponent,{reviewTest:()=>{k(!1),D("review")},isFirst:N,finishTest:W,time:b,mandatory:re,restartTest:V,result:p,correctQuestions:v,timeOver:B,timeOverText:e.text,emitEvent:n,soundActions:t,minimumPercentage:Q})})]})}const OPTIONS=["yes","no"],LETTERS=["A","B"];function ApplicableBox({setSurveyData:l,survey:e,id:n,translate:t,changePage:a}){const o=d=>{l({...e,[n]:d}),a()};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:OPTIONS.map((d,f)=>jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>o(d),className:`unset-button survey--response__item ${e[n]===d?"selected":""}`,children:[jsxRuntimeExports.jsx("div",{className:"survey--response__index",children:LETTERS[f]}),jsxRuntimeExports.jsx("div",{className:"survey--response__text",children:t(`survey.${d}`)})]},d))})}const OPINION_OPTIONS=[0,1,2,3,4,5,6,7,8,9,10];function OpinionBox({setSurveyData:l,survey:e,id:n,translate:t,changePage:a}){const o=d=>{l({...e,[n]:d}),a()};return jsxRuntimeExports.jsxs("div",{className:"survey--page__item","aria-label":"opinion box",children:[jsxRuntimeExports.jsx("div",{className:"survey--points",children:OPINION_OPTIONS.map(d=>jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>o(d),className:`unset-button survey--points__item survey--points__item--colorized ${e[n]===d?"selected":""}`,children:d},d))}),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:l,survey:e,id:n,literalLabel:t}){const a=o=>{l({...e,[n]:o})};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:jsxRuntimeExports.jsx("textarea",{ref:o=>{o&&o.focus()},className:"survey--textarea",id:t,value:e[n],onChange:o=>a(o.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:l,soundActions:e}){const[n,t]=React$2.useState(INIT_SURVEY),[a,o]=React$2.useState(0),[d,f]=React$2.useState(!1),[h]=e,u=(R,S)=>l({type:"translate",payload:R,values:S}),p=(R=!1)=>{if(h("click-ui"),!R&&a+1>=PAGES.length)f(!0);else{R&&f(!1);const S=R?a-1:a+1;o(S)}},x=PAGES[a].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:u("survey.numQuestion",{init:a+1,page:PAGES.length})})}),jsxRuntimeExports.jsx("div",{children:u("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsx("label",{className:"survey--questions__item",htmlFor:u(`survey.question${a+1}`,{ordinal:a+1}),children:u(`survey.question${a+1}`,{ordinal:a+1})}),jsxRuntimeExports.jsx(x,{setSurveyData:t,id:PAGES[a].id,survey:n,translate:u,changePage:R=>p(!1),literalLabel:u(`survey.question${a+1}`,{ordinal:a+1})})]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next",children:[jsxRuntimeExports.jsx("button",{id:"survey-button-back",type:"button",disabled:a===0,onClick:()=>p(!0),className:`gat--btn__navigation ${a===0?"disabled":""}`,"aria-label":LangIsRtl()?u("survey.next"):u("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),d&&a===PAGES.length-1?jsxRuntimeExports.jsx("button",{id:"survey-button",type:"button",disabled:!n[PAGES[a].id],onClick:()=>{h("click-ui"),l({type:"saveSurvey",payload:n})},className:`gat--btn gat--btn__primary ${n[PAGES[a].id]?"":"disabled"} not-transition`,children:u("survey.finish")}):null,!d&&a!==PAGES.length?jsxRuntimeExports.jsx("button",{id:"survey-button",type:"button",disabled:!n[PAGES[a].id],onClick:()=>p(!1),className:`gat--btn__navigation ${n[PAGES[a].id]?"":"disabled"}`,"aria-label":LangIsRtl()?u("survey.previous"):u("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null]})]})})]})}function EndScreen({onFinish:l,translate:e}){return React$2.useEffect(()=>{let n;return l&&(n=setTimeout(()=>{l()},2e3)),()=>{n&&clearTimeout(n)}},[l]),jsxRuntimeExports.jsx("div",{"data-testid":"endScreen",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:l,description:e,translate:n}){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",{"data-testid":"auto-start-button",type:"button",className:"gat--btn gat--btn__primary auto-evaluation__button auto-evaluation__button--start",onClick:l,children:jsxRuntimeExports.jsx("span",{children:n("auto-evaluation.start")})})]})}function AutoEvaluation({description:l,questions:e,type:n,emitEvent:t,soundActions:a}){var w,C,P;const[o,d]=React$2.useState(null),[f,h]=React$2.useState("start"),[u,p]=React$2.useState(!1),[x,R]=React$2.useState(0),[S,E]=React$2.useState({current:{questions:[],type:n}}),[g]=a,v=D=>t({type:"translate",payload:D}),T=D=>{D.code==="Enter"&&D.target.blur()},b=()=>{g("click-ui"),t({type:"saveSurveyPrePos",payload:S.current})};React$2.useEffect(()=>{!e.length&&f==="questions"&&h("end")},[e,f]);const _=(D,N=!1)=>{var F;const k=D!==null?D:(F=S.current.questions.find(M=>M.id===e[x].id))==null?void 0:F.answer;if(g("click-ui"),N)R(x-1),p(!1);else{const M=S.current.questions.findIndex($=>$.id===e[x].id),U=[...S.current.questions];M>-1?U.splice(M,1,{id:e[x].id,answer:k}):U.push({id:e[x].id,answer:k}),E({...S,current:{...S.current,questions:U}}),x===e.length-1?p(!0):(R(x+1),p(!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:[f==="start"&&jsxRuntimeExports.jsx(StartScreen,{description:l,onNext:()=>{h("questions"),g("click-ui")},translate:v}),f==="questions"&&jsxRuntimeExports.jsxs("div",{"data-testid":"survey--questions",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:[v("auto-evaluation.question")," ",x+1," ",v("storylines.misc.of")," ",e.length]})}),jsxRuntimeExports.jsx("div",{children:v("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"survey--questions__item","aria-label":"survey questions item",children:(w=e[x])==null?void 0:w.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((D,N)=>{var k;return jsxRuntimeExports.jsx("button",{"data-testid":`button-option-${0+N}`,type:"button",onTouchStart:()=>{d(N)},onTouchEnd:()=>{d(null)},onKeyUp:F=>{T(F)},onClick:()=>{_(N,!1)},className:`survey--points__item survey--points__item--simple ${((k=S.current.questions[x])==null?void 0:k.answer)===N||o===N?"selected":""}`,children:N},`${0+N}`)})})})]},`${e[x]}`)]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next","aria-label":"test buttons",children:[jsxRuntimeExports.jsx("button",{"data-testid":"back-button",type:"button",disabled:x===0,onClick:()=>_(null,!0),"aria-label":LangIsRtl()?v("survey.next"):v("survey.previous"),className:`gat--btn__navigation ${x===0?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back","aria-label":"icon button"})}),u?jsxRuntimeExports.jsx("button",{"data-testid":"finish-button",type:"button",onClick:()=>{h("end"),g("click-ui")},className:`gat--btn gat--btn__primary auto-evaluation__button not-transition
|
|
252
|
+
`,EMPTY_PROPS={};function applyNodeProps(l,e,n=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,a=e.onDragEnd||e.onDragMove;t&&!a&&(console.warn(DRAGGABLE_WARNING),dragWarningShowed=!0)}for(var o in n)if(!propsToSkip[o]){var d=o.slice(0,2)==="on",f=n[o]!==e[o];if(d&&f){var h=o.substr(2).toLowerCase();h.substr(0,7)==="content"&&(h="content"+h.substr(7,1).toUpperCase()+h.substr(8)),l.off(h,n[o])}var u=!e.hasOwnProperty(o);u&&l.setAttr(o,void 0)}var p=e._useStrictMode,x={},R=!1;const S={};for(var o in e)if(!propsToSkip[o]){var d=o.slice(0,2)==="on",E=n[o]!==e[o];if(d&&E){var h=o.substr(2).toLowerCase();h.substr(0,7)==="content"&&(h="content"+h.substr(7,1).toUpperCase()+h.substr(8)),e[o]&&(S[h]=e[o])}!d&&(e[o]!==n[o]||p&&e[o]!==l.getAttr(o))&&(R=!0,x[o]=e[o])}R&&(l.setAttrs(x),updatePicture(l));for(var h in S)l.on(h+EVENTS_NAMESPACE,S[h])}function updatePicture(l){if(!Global.Konva.autoDrawEnabled){var e=l.getLayer()||l.getStage();e&&e.batchDraw()}}var schedulerExports=requireScheduler();const NO_CONTEXT={},UPDATE_SIGNAL={};Konva.Node.prototype._applyProps=applyNodeProps;function appendInitialChild(l,e){if(typeof e=="string"){console.error(`Do not use plain text as child of Konva.Node. You are using text: ${e}`);return}l.add(e),updatePicture(l)}function createInstance(l,e,n){let t=Konva[l];t||(console.error(`Konva has no node with the type ${l}. Group will be used instead. If you use minimal version of react-konva, just import required nodes into Konva: "import "konva/lib/shapes/${l}" 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 a={},o={};for(var d in e){var f=d.slice(0,2)==="on";f?o[d]=e[d]:a[d]=e[d]}const h=new t(a);return applyNodeProps(h,o),h}function createTextInstance(l,e,n){console.error(`Text components are not supported for now in ReactKonva. Your text is: "${l}"`)}function finalizeInitialChildren(l,e,n){return!1}function getPublicInstance(l){return l}function prepareForCommit(){return null}function preparePortalMount(){return null}function prepareUpdate(l,e,n,t){return UPDATE_SIGNAL}function resetAfterCommit(){}function resetTextContent(l){}function shouldDeprioritizeSubtree(l,e){return!1}function getRootHostContext(){return NO_CONTEXT}function getChildHostContext(){return NO_CONTEXT}const scheduleTimeout=setTimeout,cancelTimeout=clearTimeout,noTimeout=-1;function shouldSetTextContent(l,e){return!1}const isPrimaryRenderer=!1,warnsIfNotActing=!0,supportsMutation=!0;function appendChild(l,e){e.parent===l?e.moveToTop():l.add(e),updatePicture(l)}function appendChildToContainer(l,e){e.parent===l?e.moveToTop():l.add(e),updatePicture(l)}function insertBefore(l,e,n){e._remove(),l.add(e),e.setZIndex(n.getZIndex()),updatePicture(l)}function insertInContainerBefore(l,e,n){insertBefore(l,e,n)}function removeChild(l,e){e.destroy(),e.off(EVENTS_NAMESPACE),updatePicture(l)}function removeChildFromContainer(l,e){e.destroy(),e.off(EVENTS_NAMESPACE),updatePicture(l)}function commitTextUpdate(l,e,n){console.error(`Text components are not yet supported in ReactKonva. You text is: "${n}"`)}function commitMount(l,e,n){}function commitUpdate(l,e,n,t,a){applyNodeProps(l,a,t)}function hideInstance(l){l.hide(),updatePicture(l)}function hideTextInstance(l){}function unhideInstance(l,e){(e.visible==null||e.visible)&&l.show()}function unhideTextInstance(l,e){}function clearContainer(l){}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=(l,e,n)=>e in l?__defProp(l,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):l[e]=n,__spreadValues=(l,e)=>{for(var n in e||(e={}))__hasOwnProp.call(e,n)&&__defNormalProp(l,n,e[n]);if(__getOwnPropSymbols)for(var n of __getOwnPropSymbols(e))__propIsEnum.call(e,n)&&__defNormalProp(l,n,e[n]);return l},__spreadProps=(l,e)=>__defProps(l,__getOwnPropDescs(e));function traverseFiber(l,e,n){if(!l)return;if(n(l)===!0)return l;let t=e?l.return:l.child;for(;t;){const a=traverseFiber(t,e,n);if(a)return a;t=e?null:t.sibling}}function wrapContext(l){try{return Object.defineProperties(l,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return l}}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 l=React__namespace.useContext(FiberContext);if(l===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,l,l==null?void 0:l.alternate]){if(!t)continue;const a=traverseFiber(t,!1,o=>{let d=o.memoizedState;for(;d;){if(d.memoizedState===e)return!0;d=d.next}});if(a)return a}},[l,e])}function useContextMap(){var l,e;const n=useFiber(),[t]=React__namespace.useState(()=>new Map);t.clear();let a=n;for(;a;){const o=(l=a.type)==null?void 0:l._context;o&&o!==FiberContext&&!t.has(o)&&t.set(o,(e=ReactCurrentDispatcher==null?void 0:ReactCurrentDispatcher.current)==null?void 0:e.readContext(wrapContext(o))),a=a.return}return t}function useContextBridge(){const l=useContextMap();return React__namespace.useMemo(()=>Array.from(l.keys()).reduce((e,n)=>t=>React__namespace.createElement(e,null,React__namespace.createElement(n.Provider,__spreadProps(__spreadValues({},t),{value:l.get(n)}))),e=>React__namespace.createElement(FiberProvider,__spreadValues({},e))),[l])}function usePrevious(l){const e=React$2.useRef({});return React$2.useLayoutEffect(()=>{e.current=l}),React$2.useLayoutEffect(()=>()=>{e.current={}},[]),e.current}const StageWrap=l=>{const e=React$2.useRef(),n=React$2.useRef(),t=React$2.useRef(),a=usePrevious(l),o=useContextBridge(),d=f=>{const{forwardedRef:h}=l;h&&(typeof h=="function"?h(f):h.current=f)};return React$2.useLayoutEffect(()=>(n.current=new Konva.Stage({width:l.width,height:l.height,container:e.current}),d(n.current),t.current=KonvaRenderer.createContainer(n.current,constantsExports.LegacyRoot,!1,null),KonvaRenderer.updateContainer(React$2.createElement(o,{},l.children),t.current),()=>{Konva.isBrowser&&(d(null),KonvaRenderer.updateContainer(null,t.current,null),n.current.destroy())}),[]),React$2.useLayoutEffect(()=>{d(n.current),applyNodeProps(n.current,l,a),KonvaRenderer.updateContainer(React$2.createElement(o,{},l.children),t.current,null)}),React$2.createElement("div",{ref:e,id:l.id,accessKey:l.accessKey,className:l.className,role:l.role,style:l.style,tabIndex:l.tabIndex,title:l.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((l,e)=>React$2.createElement(FiberProvider,{},React$2.createElement(StageWrap,{...l,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(l,e){i.usingClientEntryPoint=!0;try{return m.createRoot(l,e)}finally{i.usingClientEntryPoint=!1}},client.hydrateRoot=function(l,e,n){i.usingClientEntryPoint=!0;try{return m.hydrateRoot(l,e,n)}finally{i.usingClientEntryPoint=!1}}}var __rest=function(l,e){var n={};for(var t in l)Object.prototype.hasOwnProperty.call(l,t)&&e.indexOf(t)<0&&(n[t]=l[t]);if(l!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,t=Object.getOwnPropertySymbols(l);a<t.length;a++)e.indexOf(t[a])<0&&Object.prototype.propertyIsEnumerable.call(l,t[a])&&(n[t[a]]=l[t[a]]);return n};const needForceStyle=l=>{const e=window.getComputedStyle(l).position;return!(e==="absolute"||e==="relative")};function useEvent(l=()=>{}){const e=React$2.useRef(l);return e.current=l,React$2.useCallback((...n)=>e.current.apply(null,n),[])}const Html=({children:l,groupProps:e,divProps:n,transform:t,transformFunc:a})=>{const o=React$2.useRef(null);React$2.useRef();const[d]=React$2.useState(()=>document.createElement("div")),f=React$2.useMemo(()=>client.createRoot(d),[d]),h=t??!0,u=useEvent(()=>{if(h&&o.current){let E=o.current.getAbsoluteTransform().decompose();a&&(E=a(E)),d.style.position="absolute",d.style.zIndex="10",d.style.top="0px",d.style.left="0px",d.style.transform=`translate(${E.x}px, ${E.y}px) rotate(${E.rotation}deg) scaleX(${E.scaleX}) scaleY(${E.scaleY})`,d.style.transformOrigin="top left"}else d.style.position="",d.style.zIndex="",d.style.top="",d.style.left="",d.style.transform="",d.style.transformOrigin="";const p=n||{},{style:x}=p,R=__rest(p,["style"]);Object.assign(d.style,x),Object.assign(d,R)});return React$2.useLayoutEffect(()=>{var p;const x=o.current;if(!x)return;const R=(p=x.getStage())===null||p===void 0?void 0:p.container();if(R)return R.appendChild(d),h&&needForceStyle(R)&&(R.style.position="relative"),x.on("absoluteTransformChange",u),u(),()=>{var S;x.off("absoluteTransformChange",u),(S=d.parentNode)===null||S===void 0||S.removeChild(d)}},[h]),React$2.useLayoutEffect(()=>{u()},[n,a]),React$2.useLayoutEffect(()=>{f.render(l)}),React$2.useLayoutEffect(()=>()=>{setTimeout(()=>{f.unmount()})},[]),React$2.createElement(Group,Object.assign({ref:o},e))};function Area({area:l,finished:e,isClicked:n,isBad:t,hasHighlights:a,completed:o,onClick:d,onClickOutside:f}){const h=React$2.useRef(),[u,p]=React$2.useState(),x=t?"rgba(255, 99, 77, 0.32)":"rgba(75, 215, 169, 0.32)",R=t?"#ff634d":"#4bd7a9",S=DeviceDetection(),E=()=>{var _,w,C;a&&!o&&!n&&((_=h.current)==null||_.setAttr("fill","rgba(130, 134, 142, 0.4)"),(w=h.current)==null||w.setAttr("stroke","rgba(255, 255, 255, 0.3)"),(C=h.current)==null||C.to({duration:.25,opacity:1}))},g=()=>{var _;a&&!o&&!n&&((_=h.current)==null||_.to({duration:.25,opacity:0}))};React$2.useEffect(()=>{var _,w,C;o&&!e&&(t?(C=h.current)==null||C.to({duration:.25,opacity:0}):((_=h.current)==null||_.to({duration:.25,opacity:1}),(w=h.current)==null||w.globalCompositeOperation("destination-out")))},[o,e,t]);const v=()=>{var _,w;o||(t?f(l):d(l),(_=h.current)==null||_.setAttr("fill",x),(w=h.current)==null||w.setAttr("stroke",R))},T=l.scaleX?l.scaleX:1,b=l.scaleY?l.scaleY:1;return React$2.useLayoutEffect(()=>{const _=h.current.getStage();_.on("stage-loaded",()=>{const w=h.current.getClientRect({relativeTo:h.current.getParent()});p({x:w.x+w.width/2,y:w.y+w.height/2}),_.batchDraw()})},[l]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[u?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...u},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:l.id})}):null,jsxRuntimeExports.jsx(Line,{name:l.id,ref:h,onFocus:()=>E(),onMouseOver:()=>E(),onMouseLeave:g,onClick:()=>v(),onTap:()=>v(),x:l.x,y:l.y,scale:{x:T,y:b},skew:{x:l.skewX,y:l.skewY},rotation:l.rotation,points:l.points,shape:"poly",fill:e?"":x,stroke:e||n?R:"",strokeWidth:S?10:4,opacity:e||n?1:0,closed:!0})]})}Area.defaultProps={finished:!1,isBad:!1,isClicked:!1,hasHighlights:!1,completed:!1,onClick:()=>{},onClickOutside:()=>{}};const useWindowSize=()=>{const[l,e]=React$2.useState([0,0]);return React$2.useLayoutEffect(()=>{function n(){e([window.innerWidth,window.innerHeight])}return window.addEventListener("resize",n),n(),()=>window.removeEventListener("resize",n)},[]),l};function KonvaMapper({areas:l,badAreas:e,imageUrl:n,completed:t,onClick:a,onClickOutside:o,hasHighlights:d,clickedZones:f}){const h=React$2.useRef(),u=React$2.useRef(),p=React$2.useRef(),x=React$2.useRef(),R=React$2.useRef(),S=React$2.useRef(),E=React$2.useRef(),[g,v]=React$2.useState(new window.Image),[T,b]=useWindowSize(),_=e.find(P=>P.id==="AllArea")||!1,w=e.filter(P=>P.id!=="AllArea");React$2.useEffect(()=>{E.current&&u.current&&t&&(E.current.to({duration:.25,opacity:.5}),u.current.setAttr("visible",!0))},[t]);const C=P=>{_&&!P.target.attrs.shape&&o(_)};return React$2.useEffect(()=>{g.src=n,g.addEventListener("load",()=>{if(h.current){const P={x:T/2,y:b/2,width:g.width,height:g.height,offsetX:g.width/2,offsetY:g.height/2,scale:{x:Math.min(T/g.width,b/g.height),y:Math.min(T/g.width,b/g.height)}};x.current&&x.current.setAttrs(P),R.current&&R.current.setAttrs(P),u.current&&u.current.setAttrs(P),p.current&&p.current.setAttrs(P),S.current&&S.current.setAttrs(P),h.current.batchDraw(),v(g),h.current.fire("stage-loaded")}})},[g,b,n,T]),jsxRuntimeExports.jsxs(Stage,{ref:h,width:T,height:b,onClick:C,onTouchEnd:C,children:[jsxRuntimeExports.jsx(Layer,{children:jsxRuntimeExports.jsx(Image$2,{ref:S,image:g})}),jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Rect,{ref:E,width:T,height:b,fill:"black",opacity:0}),jsxRuntimeExports.jsx(Group,{ref:R,children:w.map((P,D)=>jsxRuntimeExports.jsx(Area,{hasHighlights:d,completed:t,onClick:a,onClickOutside:o,area:P,isBad:!0},P.name+"_"+D))}),jsxRuntimeExports.jsx(Group,{ref:x,children:l.map((P,D)=>jsxRuntimeExports.jsx(Area,{hasHighlights:d,completed:t,onClick:a,onClickOutside:o,area:P,isClicked:f.some(N=>N.index===P.index)},P.name+"_"+D))}),jsxRuntimeExports.jsx(Group,{ref:p,visible:!1,children:w.map((P,D)=>jsxRuntimeExports.jsx(Area,{hasHighlights:d,completed:t,onClick:a,onClickOutside:o,area:P,isBad:!0,finished:!0},P.name+"_"+D))}),jsxRuntimeExports.jsx(Group,{ref:u,visible:!1,children:l.map((P,D)=>jsxRuntimeExports.jsx(Area,{hasHighlights:d,completed:t,onClick:a,onClickOutside:o,area:P,finished:!0},P.name+"_"+D))})]})]})}KonvaMapper.defaultProps={hasHighlights:!1,onClick:()=>{},completed:!1,onClickOutside:()=>{}};function TimerDialog({retry:l,translate:e,onInit:n}){return jsxRuntimeExports.jsx("div",{className:"timer-dialog",children:jsxRuntimeExports.jsxs("div",{className:"timer-dialog__container",children:[jsxRuntimeExports.jsx("div",{className:"timer-dialog__title",children:e("storylines.misc.ready")}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:n,children:jsxRuntimeExports.jsx("span",{children:e(l?"storylines.misc.start":"storylines.misc.retry")})})]})})}function CountDown({time:l}){const e=Math.floor(l/60),n=l%60;return jsxRuntimeExports.jsx("div",{className:`count-down count-down--in-puzzle-frame ${l<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{children:[e<10?`0${e}`:e," : ",n<10?`0${Math.floor(n)}`:Math.floor(n)]})})}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(l){var Xe,Ye;const{soundActions:e,emitEvent:n,handleClick:t,disableExit:a,setResolveAction:o,info:d,image:f,areas:h,badAreas:u,hasClickOrder:p,timer:x,hasClickOnce:R,hasHighlights:S,hasImageReview:E,defaultCompleted:g,className:v,emitFinish:T,emitResolve:b,translateFromParent:_,specificFeedbacks:w,slideNumber:C,emitResetPuzzle:P,firstTryForFrame:D,puzzlesAutoCompleted:N,emitOpenPopupCounterInfo:k,pause:F,keyboardControl:M}=l,[U,$]=React$2.useState([]),[B,J]=React$2.useState(!1),[re,ae]=React$2.useState(!1),[Q,K]=React$2.useState({show:!1,success:!1,text:"",rewards:[]}),ne=React$2.useRef(!1),[ue,fe]=React$2.useState(!0),[te,H]=React$2.useState(!1),W=React$2.useRef(null),V=React$2.useRef(null),z=React$2.useRef(null),q=React$2.useRef(null),ee=React$2.useRef(null),le=React$2.useRef(null),ce=React$2.useRef(null),he=React$2.useRef(null),ve=React$2.useRef(null),[be,Re]=React$2.useState(x),Le=Pe=>_?_(Pe):n({type:"translate",payload:Pe}),[Oe]=e,{solution:Ke}=d,St=f.img.url||defaultImg,it=h.map((Pe,Ae)=>({index:Ae,shape:"poly",...Pe})),gt=u.map((Pe,Ae)=>({index:Ae,shape:"poly",...Pe})),Ge=React$2.useCallback(()=>{if(!ue){const Pe=setInterval(()=>{Re(Ae=>Ae>1?Ae-1:0)},1e3);ve.current=Pe}},[ue]),Me=React$2.useCallback((Pe,Ae)=>{T?T(Pe,Ae):n({type:"addPoints",payload:Pe})},[n,T]);React$2.useEffect(()=>{B&&a(!0)},[B,a]),React$2.useEffect(()=>{J(g)},[g]);const De=React$2.useCallback(()=>{clearInterval(z.current)},[]),Ve=React$2.useCallback(()=>{clearInterval(ve.current)},[]),ct=React$2.useCallback(Pe=>{ee.current=Date.now(),q.current?(ce.current=q.current-ee.current,De()):(ce.current=ee.current-(ee.current-Pe*1e3),De())},[De]),dt=React$2.useCallback(()=>{K(()=>{var Pe,Ae;return{show:!0,success:!1,text:(Pe=d==null?void 0:d.timerFeedback)!=null&&Pe.desc?d.timerFeedback.desc:"",rewards:(Ae=d==null?void 0:d.timerFeedback)==null?void 0:Ae.rewards}}),H(!0),Ve(),De()},[Ve,De,(Xe=d.timerFeedback)==null?void 0:Xe.desc,(Ye=d.timerFeedback)==null?void 0:Ye.rewards]),rt=React$2.useCallback(()=>{clearInterval(z.current),z.current=setInterval(()=>{V.current=Date.now(),V.current>q.current&&dt()},250)},[dt]);React$2.useEffect(()=>{var Pe;if((h.length===U.length||R&&U.length>0)&&!B){J(!0);const Ae=U[U.length-1],_e=w==null?void 0:w.correctFeedbacks.find(Ie=>Ie.id===Ae.id);(!((Pe=w==null?void 0:w.correctFeedbacks)!=null&&Pe.length)||w!=null&&w.correctFeedbacks.some(Ie=>!Ie.desc)||R)&&(K(Ie=>({...Ie,show:!0,success:!0,text:_e?_e.desc:d.solution.right.desc,rewards:_e?_e.rewards:d.solution.right.rewards})),x&&(Ve(),ct()))}},[U,h.length,w,R,B,d.solution.right,ct,x,Ve]),React$2.useEffect(()=>{o(Pe=>{x&&(Ve(),fe(!1),Q.show?K(Ae=>({...Ae,show:!1,success:!1,text:"",rewards:[]})):De()),J(!0),ae(!0),setTimeout(()=>{b?b(Pe):Pe()},4e3)})},[o,b,Oe,x,Q.show,De,Ve]),React$2.useEffect(()=>{re&&a(!0)},[re,a]);const xt=(Pe,Ae=!1)=>{var _e,Ie;if(!B){const{rewards:tt,desc:Gt}=Ke.wrong;let Dt=Gt,ke=tt;const mt=(_e=w==null?void 0:w.wrongFeedbacks)==null?void 0:_e.find(Pt=>Pt.id===Pe.id);mt&&(Dt=mt.desc,ke=mt.rewards),p&&($([]),Ae&&(Ie=d==null?void 0:d.orderFeedback)!=null&&Ie.desc&&(Dt=d.orderFeedback.desc,ke=d.orderFeedback.rewards)),x&&(Ve(),ct()),K(Pt=>({...Pt,show:!0,success:!1,text:Dt,rewards:ke})),Oe("fail")}},Et=React$2.useCallback(()=>{le.current=Date.now();const Pe=le.current+ce.current;V.current=null,q.current=Pe,(x||te)&&(Q.success?h.length===U.length||R&&U.length>0?Ve():(Re(ce.current*.001),Ge(),rt()):($([]),fe(!0),P())),Me(Q.rewards,Q.success),Oe("click-ui"),K(Ae=>({...Ae,show:!1,success:!1,text:"",rewards:[]}))},[x,te,Me,Q.rewards,Q.success,Oe,h.length,U.length,R,P,Ve,Ge,rt]),Qe=Pe=>{var Ae,_e;if(!U.some(Ie=>Ie.index===Pe.index)&&!Q.show&&!B){Oe("click-ui");let Ie=Ke.right.desc,{rewards:tt}=Ke.right;const Gt=[...U,Pe];if(p&&Pe.index===U.length||!p){if(x&&ct(be),t(),(Ae=w==null?void 0:w.correctFeedbacks)!=null&&Ae.length){const Dt=(_e=w.correctFeedbacks)==null?void 0:_e.find(ke=>ke.id===Pe.id);Dt&&(Ie=Dt.desc,tt=Dt.rewards),!Ie&&h.length>Gt.length&&!R?Me(tt,!0):Ie&&!R&&(K(ke=>({...ke,show:!0,success:!0,text:Ie,rewards:tt})),x&&Ve())}$(Gt)}else xt(Pe,!0)}},Be=React$2.useCallback(()=>{Ve(),Re(x),Ge(),!ne.current&&D&&k(),fe(!1),W.current=Date.now(),q.current=W.current+x*1e3,rt()},[Ve,x,Ge,D,rt,k]);return React$2.useEffect(()=>{x&&C>0&&!he.current&&(D&&Object.keys(N).length&&N[C-1]?(fe(!0),he.current=!0):fe(!1))},[g,D,N,C,x]),React$2.useEffect(()=>{x&&be===0&&dt()},[be,dt,x]),React$2.useEffect(()=>{x&&(F?(Ve(),ct()):Ge())},[Ve,rt,F,ct,Ge,x]),jsxRuntimeExports.jsxs("div",{className:v,children:[Q.show?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:Oe,text:Q.text,success:Q.success,translate:Le,hasTimeout:!Q.text,delay:x?1e3:2e3,functionOnClose:Et,timeExpired:te,keyboardControl:M}):null,jsxRuntimeExports.jsx(KonvaMapper,{completed:B,imageUrl:St,areas:R&&U.length?[U[0]]:it,badAreas:gt,clickedZones:U,onClick:Qe,onClickOutside:xt,hasHighlights:S,emitEvent:n}),E?jsxRuntimeExports.jsx(ImageReview,{}):null,x&&ue?jsxRuntimeExports.jsx(TimerDialog,{retry:D||N[C-1],translate:Le,onInit:Be}):null,x?jsxRuntimeExports.jsx(CountDown,{time:be}):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(l){const e=(n,t)=>{t?(l.emitEvent({type:"addPoints",complex:!0,finish:!0,payload:n}),l.emitEvent({type:"passPuzzle"})):(l.emitEvent({type:"addPoints",payload:n,finish:!1}),l.emitEvent({type:"failPuzzle"}))};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...l,emitFinish:e,name:"image-click-puzzle"})}const GREEN="#44d7ab",ORANGE="#FFB34B",RED="#FF634D",getDistance=(l,e)=>Math.max(Math.abs(l[0]-e[0]),Math.abs(l[1]-e[1])),generatePasswordPositions=(l,e,n,t)=>{const a=[],o=l;for(const d of e.toLowerCase()){const f=Math.floor(Math.random()*n),h=Math.floor(Math.random()*t);o[f][h].value=d,a.push({char:d,position:[f,h]})}return[o,a]},paintedGridPassword=(l,e,n,t)=>{const a=l;for(let o=0;o<e;o+=1)for(let d=0;d<n;d+=1)switch(t.reduce((h,u)=>{const p=[o,d],x=getDistance(u.position,p);return x<h?x:h},9999)){case 0:a[o][d].hiddenColor=GREEN;break;case 1:a[o][d].hiddenColor=ORANGE;break;case 2:a[o][d].hiddenColor=RED;break}return a},resetColors=(l,e,n)=>{const t=n;for(let a=0;a<l;a+=1)for(let o=0;o<e;o+=1)t[a][o].color="",t[a][o].hiddenColor=RED;return t},repaintGridPassword=(l,e,n,t)=>{const a=resetColors(n,t,l),[o,d]=generatePasswordPositions(a,e,n,t);return paintedGridPassword(o,n,t,d)},prepareAcceptedChars=(l,e)=>e.split("").filter(n=>!l.includes(n)).join(""),generateBasicGrid=(l,e,n)=>{const t=[];for(let a=0;a<l;a+=1){const o=[];for(let d=0;d<e;d+=1){const f={color:"",hiddenColor:RED,value:n[Math.floor(Math.random()*n.length)]};o.push(f)}t.push(o)}return t},makeSomeNoise=({numberOfColumns:l,numberOfRows:e,password:n})=>{const t=LangIsRtl()?"٠١٢٣٤٥٦٧٨٩شزذيثبلاهتنمورخحضقسفعدصطغظ":"0123456789abcdefghijklmnopqrstuvwxyz",a=prepareAcceptedChars(n,t),o=generateBasicGrid(e,l,a),[d,f]=generatePasswordPositions(o,n,e,l);return paintedGridPassword(d,e,l,f)};function DrawItem({item:l,rowIndex:e,columnIndex:n,setCursorPosition:t,cursorPosition:a}){const o=Math.abs(e-a[0])<3&&Math.abs(n-a[1])<3;return jsxRuntimeExports.jsx("span",{className:"puzzle--cracker__item",style:{backgroundColor:`${o?l.hiddenColor:l.color}`,flexGrow:1,textAlign:"center"},onMouseOver:()=>{t([e,n])},onFocus:()=>{t([e,n])},children:l.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:l,rowIndex:e,setCursorPosition:n,cursorPosition:t}){return l.length?jsxRuntimeExports.jsx("div",{className:"puzzle--cracker",children:l.map((a,o)=>jsxRuntimeExports.jsx(DrawItem,{item:a,rowIndex:e,columnIndex:o,setCursorPosition:n,cursorPosition:t},o))}):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:l,cursorPosition:e,setCursorPosition:n}){return jsxRuntimeExports.jsx("div",{className:"puzzle--cracker__canvas",children:l.map((t,a)=>jsxRuntimeExports.jsx(DrawRow,{row:t,rowIndex:a,cursorPosition:e,setCursorPosition:n},a))})}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:l,soundActions:e,info:n,velocity:t,password:a,disableExit:o,difficulty:d,setResolveAction:f}){const[h]=e,u=fe=>l({type:"translate",payload:fe}),p=React$2.useRef(),x=React$2.useRef(),{solution:R}=n,[S,E]=React$2.useState(a.toLowerCase()),[g,v]=React$2.useState(),[T,b]=React$2.useState(Array(a.toLowerCase().length).fill("")),[_,w]=React$2.useState(!1),[C,P]=React$2.useState([0,0]),D=u("puzzle.cracker.crackedPassword"),N=n.solution.right.desc&&n.solution.right.desc!==""?n.solution.right.desc:"",k=u("puzzle.cracker.congratulations"),[F,M]=React$2.useState([[]]),{visibleRows:U,visibleColumns:$}=DIFFICULTY_MAP[d];let B=U==="auto"?Math.ceil(window.innerHeight*.025):U;B=B>=20?B:20,React$2.useEffect(()=>{_&&o(!0)},[_,o]),React$2.useEffect(()=>{f(fe=>{h("score"),w(!0),setTimeout(()=>{l({type:"hidePuzzleButtons",payload:!1}),fe()},0)})},[f,h]);const J=()=>{h("click-ui");const{rewards:fe}=R.right;l({type:"addPoints",complex:!0,finish:!0,payload:fe}),l({type:"passPuzzle"})},re=()=>a.toLowerCase().split("").map((te,H)=>({char:te,index:H,used:!1})),ae=fe=>fe.filter(te=>te.used===!1).map(te=>te.char).join(""),Q=fe=>{if(fe[0].length>0&&!_){const te=[...fe];return te.push(te.shift()),te}return fe};let K=0;const ne=fe=>{if(x.current!==void 0){const te=fe-x.current;K+=te,K>1e3/VELOCITY_MAP[t]&&(M(Q),K=0)}x.current=fe,p.current=requestAnimationFrame(ne)};React$2.useEffect(()=>{E(a.toLowerCase());const fe=makeSomeNoise({numberOfColumns:$,numberOfRows:B,password:a.toLowerCase()});return M(fe),v(re()),p.current=requestAnimationFrame(ne),()=>cancelAnimationFrame(p.current)},[]);const ue=()=>{if(F.length<=1)return;const[fe,te]=C,H=F[fe][te];if(H.hiddenColor===GREEN){const W=g.filter(V=>V.char===H.value.toLowerCase()&&V.used===!1)[0];if(W){const{index:V}=W;h("score");const z=g;z[V].used=!0,v(z);const q=[...T];q[V]=H.value;const ee=ae(z);E(ee);const le=repaintGridPassword(F,ee,B,$);M(le),b(q)}}S<=0&&(h("score"),w(!0))};return React$2.useEffect(()=>{_||ue()},[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((fe,te)=>jsxRuntimeExports.jsx("span",{className:"puzzle--pieces__item",children:fe&&jsxRuntimeExports.jsx("span",{className:"character success-transition-animation","data-testid":`solution${te}`,children:fe})},`${fe+te}`))})]}),jsxRuntimeExports.jsx(DrawGrid,{grid:_?[[]]:F,cursorPosition:C,setCursorPosition:P}),_&&D&&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:[`${D} ${a.toLowerCase()}`," "]}),jsxRuntimeExports.jsxs("span",{children:[k," "]}),N!==""&&jsxRuntimeExports.jsx("span",{children:N})]}),jsxRuntimeExports.jsx("div",{className:"position--absolute bottom center",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary gat--btn__cracker",onClick:J,children:u("screens.continue")})})]})]})}CrackerPuzzleComponent.defaultProps={velocity:"slow",difficulty:"easy",context:{},info:{}};const ARABIC=/[\u0600-\u06FF]/,restrictCharacters=(l,e)=>{let n=!1;return e==="or"&&(n=l===""||l===" "||l===","||l==="."||l==="/"),e==="and"&&(n=l&&l!==" "&&l!==","&&l!=="."&&l!==""&&l!=="/"),n},sortChar=(l,e)=>l.char>e.char?1:l.char<e.char?-1:0,analyzeChars=l=>{const e={anyArabic:!1,anyNumber:!1,anyWestern:!1};for(let n=0;n<l.length;n+=1){const t=l[n].charCodeAt(0);t>=65&&t<=90?e.anyWestern=!0:t>=48&&t<=57?e.anyNumber=!0:ARABIC.test(l[n])&&(e.anyArabic=!0)}return e},makeChar=l=>{const e="شزذيثبلاهتنمورخحضثقسفعدصطغظ",n="ABCDEFGHIJKLMNOPQRSTUVWXYZ",t="0123456789";let a="";return l.anyWestern&&(a+=n),l.anyNumber&&(a+=t),l.anyArabic&&(a+=e),a.charAt(Math.floor(Math.random()*a.length))},MAX_POOL_LETTERS=26,MAX_EXTRA_LETTERS=8,AnswerPanel=({answer:l,flickerPosition:e,show:n=!1,showCorrectSolution:t})=>{const a=[];let o=0;return l.forEach(d=>{a[o]||(a[o]=[]),a[o]=[...a[o],d],d.char===" "&&(o+=1),t||(d.positionInitial=d.index)}),a.map((d,f)=>jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__word","data-testid":`result-${f}`,children:n?d.map((h,u)=>jsxRuntimeExports.jsx("span",{className:"puzzle--hanged__letter active",children:h},`${h+u}`)):d.filter(({char:h})=>h!==" ").map(({char:h,fixed:u},p)=>jsxRuntimeExports.jsx("span",{className:`puzzle--hanged__letter ${u?"":"active"} ${d[p].positionInitial===e?"fakeFocus":""}`,children:h},`${h+p}`))},`${d+f}`))},defaultImage="https://min.gamelearn.io/css-resources/gamelearn/resources/partenon.jpg";function HangedPuzzleComponent({soundActions:l,emitEvent:e,disableExit:n,question:t,image:a,info:o,answer:d,hintUsed:f,setResolveAction:h,setHintAction:u,keyboardControl:p}){var le;const[x]=l,R=((le=a.img)==null?void 0:le.url)||defaultImage,[S,E]=React$2.useState(0),[g,v]=React$2.useState(!1),[T,b]=React$2.useState([]),[_,w]=React$2.useState(!1),[C,P]=React$2.useState([]),[D,N]=React$2.useState(""),[k,F]=React$2.useState(!1),[M,U]=React$2.useState([]),[$,B]=React$2.useState(!1),J=d.toUpperCase().split(""),re=J.filter(ce=>restrictCharacters(ce,"and")),ae=ce=>e({type:"translate",payload:ce}),Q=React$2.useCallback(()=>{const ce=re.map(be=>({char:be}));let he=[];const ve=analyzeChars(re);for(;he.length<MAX_EXTRA_LETTERS;){const be=makeChar(ve);he=[...he,{char:be}]}return[...ce,...he]},[re]),K=d.toUpperCase().split("").map((ce,he)=>restrictCharacters(ce,"or")?{index:he,letter:ce,char:ce,fixed:!0}:{index:he,letter:ce,char:""}),ne=React$2.useCallback(()=>{let ce=Q();for(;ce.length>MAX_POOL_LETTERS;){const he=Math.trunc(Math.random()*(ce.length-1))+1,ve=ce[he],be=K.find((Re,Le)=>ve.char===Re.letter&&!K[Le].fixed);be&&(ce.splice(he,1),K[be.index]={...be,char:be.letter,fixed:!0})}f&&(ce=[],K.forEach(({letter:he})=>{he!==" "&&ce.push({char:he})})),P(K),b(ce)},[K,f,Q]),ue=(ce,he)=>T.map((be,Re)=>Re===he?{...be,deleted:!0}:{...be}),fe=(ce,he,ve)=>{const be=he.map((Le,Oe)=>ve.find(St=>St.poolIndex===Oe)?{char:Le.char}:Le);b(be),P(ce);const Re=ce.find(Le=>Le.char==="");E(Re.index)},te=(ce,he)=>{x("click-ui");let ve=!1;const be=C.map(Oe=>!Oe.char&&!ve?(ve=!0,{...Oe,char:ce,poolIndex:he}):Oe),Re=ue(ce,he),Le=be.filter(Oe=>Oe.char).length;b(Re),P(be),H(),Le===C.length&&q(be,Re)},H=()=>{var ce;if(g){const he=C.find(ve=>ve.index!==S&&ve.letter!==" "&&ve.char===""&&ve.poolIndex===!1);he&&E(he.index)}else{const he=C.find(ve=>ve.char==="");E(he.index+1),((ce=C[he.index+1])==null?void 0:ce.letter)===" "&&E(he.index+2)}},W=()=>{x("click-ui");const ce=C.map((he,ve)=>C[C.length-1-ve]).find(he=>he.char&&!he.fixed);if(ce){const he=C.map(Re=>Re.index===ce.index?{...ce,char:""}:Re);let ve=!1;const be=T.map((Re,Le)=>Le===ce.poolIndex&&(Re.deleted||!ve)?(ve=!0,{char:Re.char}):Re);b(be),P(he),E(ce.index)}},V=()=>{n(!0),N("");const ce=[...M,...o.solution.right.rewards];x("score"),e({type:"hidePuzzleButtons",payload:!1}),e({type:"addPoints",complex:!0,finish:!0,payload:ce}),e({type:"passPuzzle"})},z=()=>{x("fail"),e({type:"hidePuzzleButtons",payload:!1}),U([...M,...o.solution.wrong.rewards]),N(""),F(!1),e({type:"failPuzzle"}),v(!0)},q=(ce,he)=>{let ve=[];F(!0);const be=ce.map((Le,Oe)=>J[Oe]===Le.char?{...Le,fixed:!0}:(ve=[...ve,Le],{...Le,poolIndex:!1,char:""})),Re=be.filter(Le=>Le.fixed).length;e({type:"hidePuzzleButtons",payload:!0}),Re===J.length?(N("success"),o.solution.right.desc===""&&setTimeout(()=>{V()},2e3)):(N("failed"),fe(be,he,ve),o.solution.wrong.desc===""&&setTimeout(()=>{z()},2e3))},ee=()=>{if(D==="success")V();else{z();const ce=C.find(he=>he.char==="");E(ce.index)}};return React$2.useEffect(()=>{_||(w(!0),ne()),h(ce=>{B(!0),setTimeout(()=>{e({type:"hidePuzzleButtons",payload:!1}),ce()},2e3)}),u(ce=>{const he=[];K.forEach(({letter:ve})=>{ve!==" "&&he.push({char:ve})}),b(he),ce()})},[ne,_,d,h,e,M,o.resolve.rewards,K,u]),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged",style:{backgroundImage:`url("${R}")`},children:[D?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:x,text:o.solution[D==="success"?"right":"wrong"].desc,success:D==="success",translate:ae,functionOnClose:ee,keyboardControl:p}):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 ${D}`,"data-testid":`${D}`,children:$?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:$,answer:d.split(""),show:!0})}):jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:$,flickerPosition:S,answer:C})}),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__keyboard",children:[T.sort((ce,he)=>sortChar(ce,he)).map((ce,he)=>jsxRuntimeExports.jsx("button",{"data-testid":`key-${ce.char}`,type:"button",onClick:()=>{!ce.deleted&&!D&&!k&&(te(ce.char,he),x("click-ui"))},className:`puzzle--hanged__keyboard--item ${ce.deleted||k?"disabled":""}`,children:ce.char},`${ce+he}`)),jsxRuntimeExports.jsx("button",{onClick:k?null:()=>W(),type:"button",disabled:k?"disabled":null,"aria-label":ae("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:l,description:e,nodeId:n,setInfo:t,emitEvent:a,disableExit:o,setResolveAction:d,soundActions:f,setSelected:h,selected:u,pause:p,loadPuzzleStatus:x,index:R,setIndex:S,slidesCompleted:E,setSlidesCompleted:g,keyboardControl:v,totalCorrects:T}){const b=React$2.useRef([]),_=React$2.useRef(0),w=React$2.useRef(0),C=`chained-image-click-puzzle_${R}_${n}`,[P]=f,D=Q=>{b.current=[...b.current,...Q]},N=React$2.useCallback(Q=>{P("score"),a({type:"hidePuzzleButtons",payload:!1}),a({type:"addPoints",complex:!0,finish:!0,payload:[...b.current,...Q]}),a({type:"passPuzzle"})},[P,a]),[k,F]=React$2.useState(!1),M=l[R],{info:U,specificFeedbacks:$}=M;U.description=e,React$2.useEffect(()=>{_.current=0,w.current=0,F(!1)},[R]);const B=React$2.useCallback((Q,K=!1)=>{var ue;let ne={...E};if(K){if((ue=$==null?void 0:$.correctFeedbacks)!=null&&ue.length&&!M.hasClickOnce){const fe=$.correctFeedbacks.length;k&&fe?(_.current>0?h(u+(fe-_.current)):h(u+fe),_.current=fe):_.current+=1}else{let fe=u;w.current&&(fe-=w.current),_.current=M.areas.length,h(fe+_.current)}_.current===M.areas.length&&(R+1>=l.length?N(Q):S(R+1),ne={...ne,[R]:!0},g(ne)),D(Q)}else a({type:"addPoints",payload:Q,finish:!1}),a({type:"failPuzzle"}),M.hasClickOrder&&(h(u-_.current),_.current===0&&Object.entries(E).length===0?h(0):_.current=0),Object.entries(E).length===0&&M.hasClickOrder&&!u&&h(0)},[E,$,M.hasClickOnce,M.areas.length,M.hasClickOrder,k,h,u,R,l.length,g,N,S,a]),J=()=>{for(let Q=0;Q<b.current.length;Q=Q+1)if(b.current[Q].points>0)return!0;return!1},re=()=>{F(!0),R>=l.length-1&&h(T),P("score"),R+1>=l.length&&J()?(U.resolve.rewards.forEach(Q=>{b.current.forEach(K=>{K.id===Q.id&&(Q.points=Q.points+K.points)})}),a({type:"puzzleAction",action:"resolve",payload:{element:C,rewards:U.resolve.rewards,finish:!0}})):a({type:"puzzleAction",action:"resolve",payload:{element:C,rewards:U.resolve.rewards,finish:R+1>=l.length}})};React$2.useEffect(()=>{t({...U,hintId:C})},[U,C,t]),React$2.useEffect(()=>{x&&R!==l.length-1&&B([],!0)},[R,l.length,x,B]);const ae=()=>{const Q=M.hasClickOnce?M.areas.length:1;w.current+=Q,h(u+Q)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...M,puzzle:{name:C,component:"chained-image-click-puzzle"},specificFeedbacks:$,emitFinish:B,emitError:D,emitResolve:re,isLast:R+1===l.length,defaultCompleted:E[R]||!!x,hideContinue:R+1!==l.length,handleClick:ae,emitEvent:a,disableExit:o,soundActions:f,setResolveAction:d,pause:p,keyboardControl:v},R)}function ChainedImageClickPuzzleComponent(l){const{setInfo:e,emitEvent:n,nodeId:t,list:a,description:o,soundActions:d,showFrames:f,disableExit:h,setResolveAction:u,pause:p,keyboardControl:x}=l,[R,S]=React$2.useState(0),[E,g]=React$2.useState(0),[v,T]=React$2.useState({}),b=`chained-image-click-puzzle_${E}_${t}`,_=React$2.useMemo(()=>n({type:"loadObjectStatus",payload:b}),[n,b]),w=a.reduce((P,D)=>P+D.areas.length,0),C={list:a,description:o,nodeId:t,disableExit:h,setResolveAction:u,emitEvent:n,soundActions:d,setInfo:e,setSelected:S,selected:R,index:E,setIndex:g,slidesCompleted:v,setSlidesCompleted:T,loadPuzzleStatus:_,pause:p,keyboardControl:x,totalCorrects:w};return jsxRuntimeExports.jsxs("div",{className:"puzzle--image__click",children:[f?jsxRuntimeExports.jsxs("div",{className:"puzzle-image__info",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[R," / ",w]})]}):null,jsxRuntimeExports.jsx(CurrentImageClickPuzzle,{...C})]})}function CurrentFramePuzzle({list:l,index:e,puzzlesCompiledRef:n,framesCompleted:t,handleFinish:a,accRewards:o,setRewards:d,setIndex:f,setFramesCompleted:h,loadPuzzleStatus:u,soundActions:p,setResolveAction:x,disableExit:R,description:S,translateFromParent:E,setInfo:g,emitEvent:v,nodeId:T,setSelected:b,selected:_,emitResetPuzzle:w,firstTryForFrame:C,setPuzzlesAutoCompleted:P,puzzlesAutoCompleted:D,emitOpenPopupCounterInfo:N,resetValues:k,setResetValues:F,pause:M,keyboardControl:U,totalCorrects:$}){var q;const[B]=p,[J,re]=React$2.useState(!1),ae=l[e],{info:Q,specificFeedbacks:K}=ae;Q.description=S;const ne=React$2.useRef(0),ue=React$2.useRef(0),fe=`frame-image-click-puzzle_${e}_${T}`;React$2.useEffect(()=>{n.current+=1},[n]),React$2.useEffect(()=>{g({...Q,hintId:fe})},[g,Q,fe]),React$2.useEffect(()=>{k&&(ue.current=0,ne.current=0,b(0),F(!1))},[k,F,b]),React$2.useEffect(()=>{ue.current=0,ne.current=0,re(!1)},[e]);const te=React$2.useCallback((ee,le=!1)=>{var he;let ce={...t};if(le){if((he=K==null?void 0:K.correctFeedbacks)!=null&&he.length&&!ae.hasClickOnce){const ve=K.correctFeedbacks.length;J&&ve?(ue.current>0?b(_+(ve-ue.current)):b(_+ve),ue.current=ve):ue.current+=1}else{let ve=_;ne.current&&(ve-=ne.current),ue.current=ae.areas.length,D[0]&&Object.entries(t).length===0?b(ue.current):b(ve+ue.current)}ue.current===ae.areas.length&&(e+1>=l.length&&a(ee),ce={...ce,[e]:!0},h(ce),f(e+1>l.length-1?0:e+1)),d(ee)}else v({type:"addPoints",payload:ee,finish:!1}),v({type:"failPuzzle"}),ae.hasClickOrder&&(b(_-ue.current),ue.current=0)},[t,(q=K==null?void 0:K.correctFeedbacks)==null?void 0:q.length,ae.hasClickOnce,ae.areas.length,ae.hasClickOrder,d,J,b,_,D,e,l.length,h,f,a,v]),H=React$2.useCallback(()=>{for(let ee=0;ee<o.current.length;ee=ee+1)if(o.current[ee].points>0)return!0;return!1},[o]),W=React$2.useCallback(()=>{re(!0),e>=l.length-1&&b($),B("score"),v({type:"hidePuzzleButtons",payload:!1}),P(ee=>({...ee,[e]:!0})),e+1>=l.length&&H()?(Q.resolve.rewards.forEach(ee=>{o.current.forEach(le=>{le.id===ee.id&&(ee.points=ee.points+le.points)})}),v({type:"puzzleAction",action:"resolve",payload:{element:fe,rewards:Q.resolve.rewards,finish:!0}})):v({type:"puzzleAction",action:"resolve",payload:{element:fe,rewards:Q.resolve.rewards,finish:e+1>=l.length}})},[e,l.length,B,v,P,H,b,$,Q.resolve.rewards,fe,o]),V=React$2.useCallback(()=>{h({}),ue.current=0,ne.current=0,w()},[w,h]);React$2.useEffect(()=>{u&&e!==l.length-1&&te([],!0)},[t,e,l.length,u,te]);const z=()=>{const ee=ae.hasClickOnce?ae.areas.length:1;ne.current+=ee,b(_+ee)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...ae,className:"puzzle-frame__canvas",puzzle:{name:"",component:"frame-click-puzzle"},specificFeedbacks:K,emitFinish:te,emitResolve:W,hideContinue:!0,disableInfo:n.current>1,defaultCompleted:t[e]||!!u,soundActions:p,setResolveAction:x,disableExit:R,translateFromParent:E,emitEvent:v,slideNumber:e,handleClick:z,emitResetPuzzle:V,firstTryForFrame:C,puzzlesAutoCompleted:D,emitOpenPopupCounterInfo:N,pause:M,keyboardControl:U},e)}function Tooltip({emitEvent:l}){const e=n=>l({type:"translate",payload:n});return jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle-frame__info--tooltip",children:e("puzzles.counterTooltip")})}function Counter({current:l,total:e,tooltip:n,emitEvent:t}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[n?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:[l," / ",e]})]})]})}function FrameImageClickComponent({emitEvent:l,nodeId:e,list:n,description:t,showFrames:a,soundActions:o,disableExit:d,setResolveAction:f,setInfo:h,pause:u,keyboardControl:p}){const[x,R]=React$2.useState({}),S=React$2.useRef([]),[E,g]=React$2.useState(0),[v,T]=React$2.useState({}),[b,_]=React$2.useState(0),w=React$2.useRef(0),[C,P]=React$2.useState(!0),[D,N]=React$2.useState(!0),[k,F]=React$2.useState(!1),M=n.reduce((ue,fe)=>ue+fe.areas.length,0),U=ue=>{S.current=[...S.current,...ue]},$=`frame-image-click-puzzle_${E}_${e}`,B=React$2.useMemo(()=>l({type:"loadObjectStatus",payload:$}),[l,$]),J=React$2.useCallback(ue=>{l({type:"addPoints",complex:!0,finish:!0,payload:[...S.current,...ue]}),l({type:"passPuzzle"})},[l]),re=React$2.useCallback(()=>{N(!1),S.current=[],_(0),g(0),T({}),P(!0),F(!0)},[]),ae=ue=>l({type:"translate",payload:ue}),Q=()=>{P(!0)},ne={firstTryForFrame:D,list:n,description:t,index:E,puzzlesCompiledRef:w,framesCompleted:v,handleFinish:J,setRewards:U,accRewards:S,setSelected:_,selected:b,setIndex:g,setFramesCompleted:T,loadPuzzleStatus:B,soundActions:o,setResolveAction:f,disableExit:d,translateFromParent:ae,setInfo:h,emitEvent:l,nodeId:e,emitResetPuzzle:re,resetValues:k,setResetValues:F,setPuzzlesAutoCompleted:R,puzzlesAutoCompleted:x,emitOpenPopupCounterInfo:()=>{E===0&&P(!1)},pause:u,keyboardControl:p,totalCorrects:M};return jsxRuntimeExports.jsxs("div",{className:"puzzle-frame",children:[jsxRuntimeExports.jsx(CurrentFramePuzzle,{...ne}),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",{"data-testid":"puzzle-frame-progress",style:{width:`${b/M*100}%`},className:"puzzle-frame__progress--handle"})})}),a?jsxRuntimeExports.jsx("button",{"data-testid":"puzzle-frame-counter-button",disabled:C,"aria-hidden":C,type:"button",className:"puzzle-frame__info",onClick:Q,children:jsxRuntimeExports.jsx(Counter,{current:b,total:M,tooltip:!C,emitEvent:l})}):null]})]})}FrameImageClickComponent.defaultProps={description:"",context:{},nodeId:0,showFrames:!1};function EditButton({action:l,className:e}){return jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,"aria-label":`${l} edit button`,onKeyUp:()=>{},className:`puzzle--webBuilder__edit ${e}`,onClick:l,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:l,usingTemplate:e,openPopup:n,onSave:t,header:a,translate:o}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[l?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:[a.logo?jsxRuntimeExports.jsx("img",{src:path+a.logo,alt:"",title:""}):jsxRuntimeExports.jsxs("span",{children:[jsxRuntimeExports.jsx("b",{children:o("webbuilder.bank.header.title")}),jsxRuntimeExports.jsx("b",{children:o("webbuilder.bank.header.logo")})]}),jsxRuntimeExports.jsx(EditButton,{action:()=>n("PopupImageComponent",{text:"Documents",images:imagesOptions,onSave:d=>t({logo:d})})})]}),jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsxs("ul",{className:"bank--navigation",children:[jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:o("webbuilder.bank.header.account")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:o("webbuilder.bank.header.invest")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:o("webbuilder.bank.header.loans")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:o("webbuilder.bank.header.mortgage")})]}),l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>n("PopupColorComponent",{colors:colorOptions,onSave:d=>t({color:d})})})]})]})}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:l,usingTemplate:e,header:n,translate:t}){const a=l?e.header.userImage:n.userImage,o=l?e.header.username:n.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+a})`}}),jsxRuntimeExports.jsx("span",{className:"facebook--header__user--text",children:t(o||"webbuilder.facebook.header.userName")})]})]})}FacebookHeader.defaultProps={showingReference:!1,usingTemplate:{},header:{}};function WebBuilderHeader(l){const{isFacebook:e,header:n,showingReference:t,usingTemplate:a}=l,o=t?a.header.color:n.color;return jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__header ${e?"":"bank"}`,style:e?{}:{backgroundColor:`${o}`},children:jsxRuntimeExports.jsx("div",{className:`${e?"facebook":"bank"}--header`,children:e?jsxRuntimeExports.jsx(FacebookHeader,{...l}):jsxRuntimeExports.jsx(BankHeader,{...l})})})}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:l,usingTemplate:e,header:n,onSave:t,translate:a,openPopup:o}){const d=l?e.header.userImage:n.userImage,f=l?e.header.username:n.username,h=l?e.header.bgImage:n.bgImage;return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__front",style:{backgroundImage:`url(${path+h})`},children:[jsxRuntimeExports.jsxs("div",{className:"facebook--user",children:[jsxRuntimeExports.jsx("span",{className:"facebook--user__circle",style:{backgroundImage:`url(${path+d})`},children:l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{o("PopupImageComponent",{images:imagesOptions,onSave:u=>t({userImage:u})})}})}),jsxRuntimeExports.jsx("span",{className:"facebook--user__text",children:a(f||"webbuilder.facebook.header.userName")}),l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{o("PopupTextComponent",{options:userOptions,onSave:u=>t({username:u})})}})]}),l?null:jsxRuntimeExports.jsx(EditButton,{className:"position--absolute right top",action:()=>{o("PopupImageComponent",{images:imagesOptions,onSave:u=>t({bgImage:u})})}})]})}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:l,usingTemplate:e,body:n,onSave:t,openPopup:a,translate:o}){const d=l?e.body.work:n.work,f=l?e.body.studies:n.studies,h=l?e.body.home:n.home,u=l?e.body.mail:n.mail;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("ul",{className:"facebook--sidebar",dir:"auto",children:[jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${d||l?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-work"}),jsxRuntimeExports.jsx("span",{className:"text",children:o(d||"webbuilder.facebook.body.work")})]}),l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupTextComponent",{options:workOptions,onSave:p=>t({work:p})})}})]}),jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${f||l?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-education"}),jsxRuntimeExports.jsx("span",{className:"text",children:o(f||"webbuilder.facebook.body.studies")})]}),l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupTextComponent",{options:studiesOptions,onSave:p=>t({studies:p})})}})]}),jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${h||l?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-home"}),jsxRuntimeExports.jsx("span",{className:"text",children:o(h||"webbuilder.facebook.body.home")})]}),l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupTextComponent",{options:homeOptions,onSave:p=>t({home:p})})}})]})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--board",children:[jsxRuntimeExports.jsx("div",{className:"facebook--mail__label",children:"E-mail"}),jsxRuntimeExports.jsxs("div",{className:`facebook--mail__box ${u||l?"active":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-mail"}),jsxRuntimeExports.jsx("span",{className:"text",children:o(u||"webbuilder.facebook.body.email")})]}),l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupTextComponent",{options:mailOptions,onSave:p=>t({mail:p})})}})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs",children:[jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-edit"}),o("webbuilder.facebook.body.editPost")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-photo"}),o("webbuilder.facebook.body.editPhoto")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-video"}),o("webbuilder.facebook.body.liveVideo")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-events"}),o("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:o("webbuilder.facebook.body.think")})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--chips",children:[jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:o("webbuilder.facebook.body.photo")}),jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:o("webbuilder.facebook.body.label")}),jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:o("webbuilder.facebook.body.feeling")})]})]})]})]})}FacebookBody.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},body:{}};function BankBody({showingReference:l,usingTemplate:e,body:n,onSave:t,openPopup:a,translate:o}){const d=l?e.body.bgImage:n.bgImage,f=l?e.body.btnColor:n.btnColor,h=o(l?e.body.bankTitle:"webbuilder.bank.body.image.title"),u=o(l?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+d})`},children:jsxRuntimeExports.jsxs("div",{className:"bank--image__text",children:[jsxRuntimeExports.jsx("span",{className:"title",children:n.bankTitle&&!l?o(n.bankTitle):h}),jsxRuntimeExports.jsx("span",{children:n.bankDesc&&!l?o(n.bankDesc):u}),l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupTextComponent",{options:titleOptions,onSave:p=>t({bankTitle:p.title,bankDesc:p.desc})})}}),l?null:jsxRuntimeExports.jsx(EditButton,{className:"position--absolute top right",action:()=>{a("PopupImageComponent",{images:imagesOptions,onSave:p=>t({bgImage:p})})}})]})}),jsxRuntimeExports.jsx("div",{dir:"auto",className:"bank--sidebar",children:jsxRuntimeExports.jsxs("div",{className:"bank--form",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__title",children:o("webbuilder.bank.body.password.title")}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:o("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:o("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:o("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:`${f}`},children:o("webbuilder.save")}),l?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupColorComponent",{colors:colorOptions2,onSave:p=>t({btnColor:p})})}})]})]})})]})}function WebBuilderBody(l){const{isFacebook:e}=l;return jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__body ${e?"":"bank"}`,children:e?jsxRuntimeExports.jsx(FacebookBody,{...l}):jsxRuntimeExports.jsx(BankBody,{...l})})}WebBuilderBody.defaultProps={isFacebook:!1};WebBuilderBody.propTypes={isFacebook:PropTypes.bool};function CurrentButton({translate:l,backActive:e,action:n}){return jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__topbar--buttons",children:jsxRuntimeExports.jsx("button",{type:"button",className:"puzzle--webBuilder__topbar--buttons__item",onClick:n,children:l(`webbuilder.${e?"return":"showReference"}`)})})}function WebBuilderTopBar({backActive:l,displayButton:e,clickAction:n,translate:t}){return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__topbar",children:[e?jsxRuntimeExports.jsx(CurrentButton,{backActive:l,action:n,translate:t}):null,jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__title",children:"web builder 3.0"})]})}function FeedbackResult({onNext:l,success:e,showButton:n,translate:t}){const a=t(e?"webbuilder.feedback.successTitle":"webbuilder.feedback.failTitle"),o=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:a}),jsxRuntimeExports.jsx("div",{className:"description",children:o})]}),n?jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__secondary ${e?"green":"red"}`,onClick:l,style:{marginRight:"64px"},children:t("webbuilder.continue")}):null]})}FeedbackResult.defaultProps={onNext:()=>{},success:!1,showButton:!0};function PublishButton({onPublish:l,translate:e}){return jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,onKeyUp:()=>{},"aria-label":"publish",className:"position--absolute bottom center",onClick:l,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:l,onSave:e,closingAction:n,translate:t,soundActions:a}){const[o]=a,[d,f]=React$2.useState(),h=d===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:l.map(u=>jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__color--select ${d===u?"selected":""}`,style:{borderColor:`${u}`},onClick:()=>f(u),children:jsxRuntimeExports.jsx("span",{style:{backgroundColor:`${u}`}})},u+Date.now()))})]})})}),jsxRuntimeExports.jsxs("div",{className:"popup--buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:n,children:jsxRuntimeExports.jsx("span",{children:t("webbuilder.cancel")})}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${h?"disabled":""}`,onClick:h?null:()=>{o("click-ui"),e(d)},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:l,onSave:e,closingAction:n,translate:t,soundActions:a}){const[o]=a,[d,f]=React$2.useState(),h=!d;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:n,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:l.map(u=>jsxRuntimeExports.jsxs("li",{className:"folder-item-file",children:[jsxRuntimeExports.jsx("div",{className:"folder-item-file__imagewrap",onClick:()=>f(u),onKeyUp:()=>{},role:"button",tabIndex:0,children:jsxRuntimeExports.jsx("img",{alt:u.src,src:path+u.src})}),jsxRuntimeExports.jsx("div",{className:"folder-item-file__title",title:u.src,children:u.src})]},u.src+Date.now()))})}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:n,children:t("webbuilder.cancel")}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${h?"disabled":""}`,onClick:h?null:()=>{o("click-ui"),e(d.src)},children:t("webbuilder.open")})]})]})]})})}PopupImageComponent.defaultProps={closingAction:()=>{},onSave:()=>{},images:[]};function Selected({item:l,translate:e}){return l instanceof Object?e(l.title.toString()):jsxRuntimeExports.jsx("span",{children:e(l||"webbuilder.textSelect.title")})}function PopupTextComponent({closingAction:l,onSave:e,options:n,translate:t,soundActions:a}){const[o]=a,[d,f]=React$2.useState(""),h=d==="",[u,p]=React$2.useState(!1),x=u?"puzzle--webBuilder__select--item open":"puzzle--webBuilder__select--item",R=()=>{p(!u)};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:x,onClick:()=>R(),role:"presentation",children:[jsxRuntimeExports.jsx(Selected,{item:d,translate:t}),jsxRuntimeExports.jsx("span",{className:"icon-down-arrow"}),jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__dropdown",children:n.map(S=>S instanceof Object?jsxRuntimeExports.jsxs("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{f(S)},children:[jsxRuntimeExports.jsx("span",{children:t(S.title)}),jsxRuntimeExports.jsx("span",{className:"subtitle",children:t(S.desc)})]},S.title):jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{f(S)},children:t(S)},S))})]})]})})}),jsxRuntimeExports.jsxs("div",{className:"popup--buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:l,children:t("webbuilder.cancel")}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${h?"disabled":""}`,disabled:h,onClick:()=>{o("click-ui"),e(d)},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:l,close:e,translate:n,soundActions:t,...a}){const o=POPUPS[l];return o?jsxRuntimeExports.jsx(o,{type:l,...a.props,closingAction:e,translate:n,soundActions:t}):null}function DisplayingFeedback({feed:l,resolved:e,translate:n,onNext:t}){return l==="success"?jsxRuntimeExports.jsx(FeedbackResult,{success:!0,showButton:!e,onNext:t,translate:n}):l==="failed"?jsxRuntimeExports.jsx(FeedbackResult,{onNext:t,translate:n}):null}function WebBuilderPuzzleComponent({type:l,info:e,emitEvent:n,setResolveAction:t,soundActions:a,disableExit:o,keyboardControl:d}){const[f,h]=React$2.useState(!1),[u,p]=React$2.useState(!1),[x,R]=React$2.useState(!1),[S,E]=React$2.useState(!1),[g,v]=React$2.useState(!1),[T,b]=React$2.useState(null),_=l==="facebook",w=_?FacebookTemplate:BankTemplate,[C,P]=React$2.useState({type:"",props:{}}),[D,N]=React$2.useState(defaultHeader),[k,F]=React$2.useState(defaultBody),[M]=a,U=H=>n({type:"translate",payload:H}),$=()=>{P({type:"",props:{}})},B=(H,W={})=>{P({type:H,props:W})},J=()=>{if(e.solution){const{rewards:H}=e.solution.right,{rewards:W}=e.solution.wrong;M(x?"fail":"score"),n({type:"addPoints",complex:!0,finish:!0,payload:x?W:H}),n({type:"passPuzzle"})}},re=d({disabled:T!=="success",forward:J,escape:J});React$2.useEffect(()=>re(),[re]);const ae=(H,W)=>{const V=Object.keys(H),z={existing:0,equal:0};return V.forEach(q=>{W[q]!==null&&W[q]!==""&&(z.existing+=1),H[q]===W[q]&&(z.equal+=1)}),z},Q=(H,W)=>{const V=Object.keys(w.header).length,z=Object.keys(w.body).length,q=ae(w.header,H),ee=ae(w.body,W),le=ee.existing+q.existing===V+z,ce=ee.equal+q.equal===V+z;return{exist:le,equal:ce}},K=()=>{M("click-ui");const{exist:H,equal:W}=Q(D,k);n({type:"hidePuzzleButtons",payload:!0}),H&&!W?(g&&v(!1),b("failed"),R(!0),n({type:"failPuzzle"})):H&&W&&(g&&(o(!1),v(!1)),E(!0),b("success"))},ne=H=>{if(Object.keys(H).length>0){const W={...D,...H};N(W),$();const{exist:V}=Q(W,k);v(!!V)}},ue=H=>{if(Object.keys(H).length>0){const W={...k,...H};F(W),$();const{exist:V}=Q(D,W);v(!!V)}};React$2.useEffect(()=>{t(H=>{p(!0),b("success"),h(!1),setTimeout(()=>{b(""),H()},4e3)}),o(!0)},[t,o,e.resolve.rewards,n]);const fe={showingReference:f||u,isFacebook:_,openPopup:B,usingTemplate:w,translate:U},te=()=>{T==="failed"?(b(null),n({type:"hidePuzzleButtons",payload:!1})):T==="success"&&J()};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(PopupComponent,{type:C.type,...C,close:$,soundActions:a,translate:U}),jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder",children:[jsxRuntimeExports.jsx(WebBuilderTopBar,{backActive:f,displayButton:!u&&!S,translate:U,clickAction:()=>{M("click-ui"),h(!f)}}),jsxRuntimeExports.jsx(WebBuilderHeader,{...fe,header:D,onSave:ne}),_?jsxRuntimeExports.jsx(WebBuilderFront,{...fe,header:D,onSave:ne}):null,jsxRuntimeExports.jsx(WebBuilderBody,{...fe,body:k,onSave:ue})]}),!g&&!f?jsxRuntimeExports.jsx(DisplayingFeedback,{feed:T,onNext:te,resolved:u,translate:U}):null,g&&!f?jsxRuntimeExports.jsx(PublishButton,{onPublish:K,translate:U}):null]})}function CardImage({img:l}){const n=(l||{}).url;return jsxRuntimeExports.jsx("img",{src:n,alt:""})}function CardText({text:l,hasImage:e}){return l?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:l||"_"})})}):null}function CardNumber({order:l}){return l?jsxRuntimeExports.jsx("div",{className:"card-selector-item__order",children:jsxRuntimeExports.jsx("div",{children:l})}):null}function CardSuccess({order:l}){return jsxRuntimeExports.jsxs("div",{className:"card-selector-item__feedback card-selector-item__feedback--success ",children:[jsxRuntimeExports.jsx(CardNumber,{order:l}),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:l,correct:e,order:n,wrongOrder:t,isEmpty:a}){return!a&&l&&e&&!t?jsxRuntimeExports.jsx(CardSuccess,{order:n}):!a&&l?jsxRuntimeExports.jsx(CardFail,{}):null}function Card({card:l,handleClick:e,flipped:n,cardIndex:t,wrongOrder:a}){const o=()=>!(l.img||l.text),d=()=>!!(n&&!l.correct||!n);return jsxRuntimeExports.jsxs("button",{"data-testid":`card-${t}`,type:"button",order:l.order,onClick:()=>{!o()&&d()&&e(t)},className:`unset-button card-selector-item ${o()?"card-selector-item--empty":""}`,"aria-label":l.text?l.text:null,children:[jsxRuntimeExports.jsx(CardImage,{img:l.img}),jsxRuntimeExports.jsx(CardText,{text:l.text,hasImage:!!l.img}),jsxRuntimeExports.jsx(CardContainer,{isEmpty:o(),flipped:n,wrongOrder:a,order:l.order,correct:l.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:l,currentOrder:e,setCurrentOrder:n,handleError:t,feedbackIsShown:a,resolvePuzzle:o,soundActions:d,onFinish:f,handleSuccess:h,resolveWithAnyCard:u}){const[p,x]=React$2.useState(Array(l.length).fill(!1)),[R,S]=React$2.useState(Array(l.length).fill(!1)),[E,g]=React$2.useState(0),[v,T]=React$2.useState(!1),[b]=d,_=l.filter(M=>M.correct===!0).length,w=l.filter(M=>M.order).length>0,C=React$2.useCallback(()=>{x(Array(l.length).fill(!1)),S(Array(l.length).fill(!1)),g(0),n(1)},[l.length,n]),P=()=>{setTimeout(()=>{C()},1e3)};function D(M,U=M){const $=Array.from(p);$[M]=U,x($)}const N=React$2.useCallback(()=>{const M=[];l.forEach((U,$)=>{U.correct===!0&&M.push($)}),x(M)},[l]);React$2.useEffect(()=>{o&&N()},[N,o]),React$2.useEffect(()=>{(u&&E||E===_&&_>0)&&(f(),T(!0),g(0))},[E,f,_,u]);const k=M=>{D(M),h(l[M].id||null),g(E+1)},F=M=>{var U,$;if(!v&&!a)if(b("click-ui"),l[M].correct&&!w)k(M);else if(w){if(l[M].order===e)n(e+1),k(M);else if(D(M),l[M].order!==e){const B=Array.from(R);B[M]=M,S(B),t(((U=l[M])==null?void 0:U.id)||null,l[M].correct),P()}}else t((($=l[M])==null?void 0:$.id)||null),D(M),setTimeout(()=>{D(M,!1)},1e3)};return jsxRuntimeExports.jsx("div",{className:`cards-selector__content cards-selector__content-${l.length}`,children:l&&l.map((M,U)=>jsxRuntimeExports.jsx(Card,{setCurrentOrder:n,card:M,handleClick:()=>F(U),flipped:p.includes(U),wrongOrder:R.includes(U),cardIndex:U},`cardPuzzle ${l.indexOf(M)}`))})}Board.defaultProps={setCurrentOrder:()=>{},handleError:()=>{},onFinish:()=>{},handleSuccess:()=>{},documentsDict:{},cards:[],currentOrder:1,resolvePuzzle:!1,feedbackIsShown:!1,resolveWithAnyCard:!1};function CardsSelectorPuzzleComponent({emitEvent:l,info:e,cards:n,resolveWithAnyCard:t,specificFeedbacks:a,disableExit:o,setResolveAction:d,soundActions:f,backgroundImage:h,nodeId:u,keyboardControl:p,hideBackgroundImageTheme:x=!1}){var te,H;const[R,S]=React$2.useState(!1),[E,g]=React$2.useState(1),[v,T]=React$2.useState(!1),[b,_]=React$2.useState(!1),[w,C]=React$2.useState(!1),[P,D]=React$2.useState([]),[N,k]=React$2.useState(!1),[F,M]=React$2.useState(""),[U]=f,$=W=>l({type:"translate",payload:W}),B=`cards-selector-puzzle_${u}`,J=React$2.useCallback(W=>{T(!1),C(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"addPoints",complex:!0,finish:!0,payload:W}),l({type:"passPuzzle"})},[l]),re=React$2.useCallback(()=>{var q,ee;l({type:"hidePuzzleButtons",payload:!0}),T(!0);const{rewards:W}=((q=e==null?void 0:e.solution)==null?void 0:q.right)||{},V=((ee=a==null?void 0:a.correctFeedbacks)==null?void 0:ee.map(le=>le.rewards).flat())||[],z=[...P,...W,...V];U("score"),J(z)},[P,J,l,(te=e==null?void 0:e.solution)==null?void 0:te.right,U,a==null?void 0:a.correctFeedbacks]),ae=()=>{S(!0),e.solution.right.desc&&!(a!=null&&a.specificCorrectFeedbacks)&&M(e.solution.right.desc),C(!0)},Q=()=>{v||R?re():(T(!1),o(!1),C(!1),l({type:"hidePuzzleButtons",payload:!1})),M("")},K=W=>{if(_(!0),a!=null&&a.specificCorrectFeedbacks){const V=a.correctFeedbacks.find(z=>z.id===W);V!=null&&V.desc&&(M(V.desc),C(!0))}U("score"),l({type:"hidePuzzleButtons",payload:!0})},ne=(W,V=!1)=>{var z,q;if(_(!1),V)M((z=e.orderFeedback)==null?void 0:z.desc),C(!0),D([...P,...((q=e.orderFeedback)==null?void 0:q.rewards)||[]]);else if(a!=null&&a.specificWrongFeedbacks){const ee=a.wrongFeedbacks.find(le=>le.id===W);ee!=null&&ee.desc?(M(ee.desc),C(!0)):(C(!0),setTimeout(()=>{Q(),l({type:"hidePuzzleButtons",payload:!1})},2e3)),D([...P,...(ee==null?void 0:ee.rewards)||[]])}else e.solution.wrong.desc?(M(e.solution.wrong.desc),C(!0)):(C(!0),setTimeout(()=>{Q(),l({type:"hidePuzzleButtons",payload:!1})},3e3));o(!0),!(a!=null&&a.specificWrongFeedbacks)&&!V&&D([...P,...e.solution.wrong.rewards]),U("fail"),l({type:"hidePuzzleButtons",payload:!0}),l({type:"failPuzzle"})};React$2.useEffect(()=>{R&&o(!0)},[o,R]),React$2.useEffect(()=>{d(()=>{var V;l({type:"hidePuzzleButtons",payload:!0}),k(!0);const W=[...P,...((V=e==null?void 0:e.resolve)==null?void 0:V.rewards)||{}];setTimeout(()=>{T(!1),C(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:B,rewards:W,finish:!0}})},2e3)})},[d,o,P,(H=e==null?void 0:e.resolve)==null?void 0:H.rewards,l,B]);const ue=React$2.useMemo(()=>{let W="";return W="cards-selector",h!=null&&h.url&&(W+=" cards-selector--with-custom-bg"),x&&(W+=" disable-background-image"),W},[h==null?void 0:h.url,x]),fe={backgroundImage:h!=null&&h.url?`url('${h.url}')`:""};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:ue,style:fe,children:jsxRuntimeExports.jsx(Board,{setCurrentOrder:g,currentOrder:E,cards:n,onFinish:ae,resolveWithAnyCard:t,handleError:ne,feedbackIsShown:w,resolvePuzzle:N,soundActions:f,handleSuccess:K})}),w&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:v||b,text:F,hasTimeout:!F,translate:$,functionOnClose:Q,keyboardControl:p})]})}CardsSelectorPuzzleComponent.defaultProps={cards:[],info:{},resolveWithAnyCard:!1,backgroundImage:{url:""}};function Fakecursor(){return jsxRuntimeExports.jsx("span",{className:"fakecursor",children:"|"})}function FixedComponent({delay:l,index:e,length:n,textToPrint:t,setDoneTyping:a,nextParagraphType:o,isWriting:d}){const[f,h]=React$2.useState(!0),[u,p]=React$2.useState(""),[x,R]=React$2.useState(!1);React$2.useEffect(()=>{R(e===n-1)},[e,n]);const S=T=>{if(!T||!T.length)return"";const b=T.replace(/<script.*?>.*?<\/script>/gim,""),_=document.createElement("DIV");return _.innerHTML=b,_.textContent||_.innerText||""};React$2.useEffect(()=>{const T=()=>{const _=t.trim().split(" ");return b(_,_.length-1).join(" ")},b=(_,w)=>{if(w<0)return[""];const C=[..._];if(S(_[w]).length!==0){const P=_[w];return C[w]=`<span class="lastWord" >${P}</span>`,C}return b(_,w-1)};o==="election"?p(T()):setTimeout(()=>{p(t)},200)},[o,t]);const E=()=>{a(!0),h(!1)},g=t.split("<p>");g.shift();const v=g.length>1;return f&&t!==""&&u!==""?jsxRuntimeExports.jsx("span",{className:`writer-inline ${v?"multiple":""} ${x?"Typist":""}`,"data-testid":`result-${e}`,children:jsxRuntimeExports.jsx(Typist,{startDelay:300,avgTypingDelay:l,stdTypingDelay:10,onCharacterTyped:d,onTypingDone:E,cursor:{hideWhenDone:!0,hideWhenDoneDelay:200},blink:!0,children:HTMLReactParser$1(t)})}):jsxRuntimeExports.jsxs("span",{className:`writer-inline ${v?"multiple":""} ${x?"Typist":""}`,"data-testid":`result-${e}`,children:[HTMLReactParser$1(u),o==="election"&&x&&jsxRuntimeExports.jsx(Fakecursor,{})]})}FixedComponent.defaultProps={delay:0,textToPrint:"",setDoneTyping:()=>{},nextParagraphType:"",isWriting:()=>{}};function SingleElection({option:l,decisionInspected:e,setCurrentDecisionSelected:n,index:t,setCurrentDecisionInspected:a,soundActions:o}){const[d]=o,f=R=>R.previewText!==""?HTMLReactParser$1(R.previewText):HTMLReactParser$1(R.fullText),h=R=>R.previewText!==""?e===t?"icon-eye inspected":"icon-eye":"",u=()=>{d("click-ui"),n(t)},p=R=>{R.keyCode===13&&x(R)},x=R=>{R.preventDefault(),R.stopPropagation(),e===t?(R.target.style.background="",a("")):a(t)};return jsxRuntimeExports.jsxs("div",{className:"single-election",children:[jsxRuntimeExports.jsxs("button",{className:"single-election__cta",type:"button",onClick:()=>u(),children:[jsxRuntimeExports.jsx("div",{className:"single-election__btn",children:jsxRuntimeExports.jsx("span",{children:f(l)})}),jsxRuntimeExports.jsx("div",{onClick:x,onKeyDown:p,className:h(l),"aria-label":"Inspect",role:"button",tabIndex:0})]}),e===t&&jsxRuntimeExports.jsx("div",{className:"single-election__complete",children:jsxRuntimeExports.jsx("div",{children:HTMLReactParser$1(l.fullText)})})]})}SingleElection.defaultProps={setCurrentDecisionSelected:()=>{},setCurrentDecisionInspected:()=>{},option:{},index:0};function SingleElectionRender({decisionInspected:l,opt:e,index:n,setCurrentDecisionSelected:t,setCurrentDecisionInspected:a,soundActions:o}){return e&&e.fullText&&e.fullText!==""?jsxRuntimeExports.jsx(SingleElection,{decisionInspected:l,setCurrentDecisionSelected:t,setCurrentDecisionInspected:a,option:e,soundActions:o,index:n}):null}function ElectionComponent({textWithOpts:l,setCurrentDecisionSelected:e,printed:n,soundActions:t}){const[a,o]=React$2.useState("");return React$2.useEffect(()=>{n()},[n]),jsxRuntimeExports.jsx("div",{className:`elections-box pos${a+1}-${l.filter(d=>!!d.fullText).length}`,children:l&&l.map((d,f)=>jsxRuntimeExports.jsx(SingleElectionRender,{opt:d,soundActions:t,index:f,setCurrentDecisionSelected:e,setCurrentDecisionInspected:o,decisionInspected:a},f))})}ElectionComponent.defaultProps={textWithOpts:[],setCurrentDecisionSelected:()=>{},printed:()=>{}};function FeedbackElement({decision:l}){const{title:e,body:n}=l.feedback;return jsxRuntimeExports.jsx("div",{children:n!==""&&jsxRuntimeExports.jsxs("div",{className:"writer-feedback-decision-item",children:[e&&jsxRuntimeExports.jsxs("div",{dir:"auto",className:"writer-feedback-decision-item__title",children:[e," "]}),n&&jsxRuntimeExports.jsxs("div",{dir:"auto",className:"writer-feedback-decision-item__message",children:[l.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:n})]})]})})}FeedbackElement.defaultProps={decision:{}};function FeedbackComponent({emitEvent:l,closingAction:e,feedbackIsDone:n,decisionsList:t,texts:a,retryAction:o,retry:d,skip:f,checkCorrect:h,rewardsStack:u,setFailed:p,soundActions:x}){const[R]=x,S=g=>l({type:"translate",payload:g}),E=()=>{R("click-ui"),e(),p(),n()};return jsxRuntimeExports.jsxs("div",{className:`writer-feedback ${u.length?"":"start"}`,children:[jsxRuntimeExports.jsx("div",{className:"writer-feedback__title",children:S("puzzles.feedback")}),jsxRuntimeExports.jsx("div",{className:"writer-feedback__decisions",children:t.map(g=>a[g.currenTextParagraph].electionTexts[g.index].feedback.body?jsxRuntimeExports.jsx(FeedbackElement,{decision:a[g.currenTextParagraph].electionTexts[g.index]},g.index):null)}),jsxRuntimeExports.jsxs("div",{className:"writer-feedback__btns",children:[f&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary writer-feedback__btn-mobile",onClick:()=>{E()},children:S("puzzles.skip")}),d&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>{h()?E():(R("click-ui"),o())},children:S(h()?"puzzles.continue":"puzzles.retry")}),!d&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>E(),children:S("puzzles.continue")})]})]})}FeedbackComponent.defaultProps={emitEvent:()=>{},closingAction:()=>{},feedbackIsDone:()=>{},decisionsList:[],texts:[],retryAction:()=>{},retry:!1,skip:!1,checkCorrect:()=>{},nodeId:"0"};function FinishedTextComponent({textToPrint:l,correct:e}){const n=l.split("<p>");n.shift();const t=n.length>1;return jsxRuntimeExports.jsx("span",{className:`writer-inline ${t?"multiple":""} ${e}`,children:HTMLReactParser$1(l)})}FinishedTextComponent.defaultProps={correct:"",textToPrint:""};function WriterPuzzleComponent({emitEvent:l,styles:e,nodeId:n,retry:t,skip:a,type:o,info:d,setResolveAction:f,documentTitle:h,documentTitle_labelId:u,texts:p,soundActions:x,backgroundImage:R,hideBackgroundImageTheme:S=!1}){const E=rt=>l({type:"translate",payload:rt}),g=React$2.useRef(),[v,T]=React$2.useState(!1),[b,_]=React$2.useState(!1),[w,C]=React$2.useState(0),[P,D]=React$2.useState({[`text_${w}`]:{...p[w],id:`text_${w}`,correct:""}}),[N,k]=React$2.useState(!1),[F,M]=React$2.useState([]),[U,$]=React$2.useState(!1),[B,J]=React$2.useState(!1),[re,ae]=React$2.useState(!1),[Q,K]=React$2.useState(!0),[ne,ue]=React$2.useState([]),[fe,te]=React$2.useState(!0),[H]=x,W=React$2.useRef({}),V=rt=>{let xt;return rt.electionTexts.forEach((Et,Qe)=>{Et.correct&&(xt=Qe)}),xt},z=React$2.useCallback(rt=>F.filter(Et=>Et.currenTextParagraph===rt)[0].fullText_labelId,[F]),q=React$2.useCallback(()=>p.map((rt,xt)=>{if(rt.type==="fixed")return rt.fullText_labelId??rt.fullText;if(rt.type==="election"){const Et=V(rt);return Et>=0?rt.electionTexts[Et].fullText_labelId:z(xt)}return""}),[z,p]),ee=12,le=()=>{if(F){const rt=F.length;let xt=0;for(let Et=0;Et<rt;Et+=1)F[Et].isCorrect==="none"&&(xt+=1);return xt===rt}return!0},ce=React$2.useCallback(()=>{if(F){const rt=F.length;let xt=0;for(let Et=0;Et<rt;Et+=1)F[Et].isCorrect==="green"&&(xt+=1);return xt===rt}return!0},[F]),he=()=>!!(F&&F.length),ve=()=>F.find(rt=>{const{feedback:xt}=p[rt.currenTextParagraph].electionTexts[rt.index];return xt.body!==""}),be=React$2.useCallback(()=>{const rt=q();l({type:"finishMedia",payload:{name:u,text:rt,documentType:o,type:"text"}})},[q,u,l,o]),Re=React$2.useCallback(rt=>{const xt=ce();H(b?"fail":xt?"score":"fail"),l({type:"addPoints",complex:!0,finish:!0,payload:rt||ne,onFinish:o!=="view"?be:null}),l({type:"passPuzzle"})},[ce,l,b,be,H,ne,o]);React$2.useEffect(()=>{v&&te(!1),f(()=>{Re(d.resolve.rewards)})},[l,Re,v,be,d.resolve.rewards,f,o]);const Le=()=>{T(!1),C(0),M([]),ue([]),_(!1),ae(!1),k(!1),J(!1),$(!1),D({text_0:{...p[0],id:"text_0",correct:""}}),K(!0),l({type:"addPoints",complex:!0,finish:!1,payload:ne}),l({type:"failPuzzle"})},Oe=()=>{he()?le()&&($(!0),Re()):($(!0),ae(!0),Re()),U?(K(!1),re&&!B?J(!0):(B||!re&&!B)&&(!re&&!B&&t?ce()?Re():Le():Re())):($(!0),ve()&&ae(!0))},Ke=()=>{const rt=p[w].electionTexts.filter(Et=>Et.correct).length,xt=p[w].electionTexts;return rt===0||rt===xt},St=rt=>{const xt=p[w].electionTexts[rt],Et=xt.feedback.rewards;Et&&Et[0]&&Et[0].points&&(W.current[`t${w}_e${rt}`]||(xt.correct&&(W.current[`t${w}_e${rt}`]=!0),ue([...ne,...Et])));const Qe=()=>Ke()?"none":xt.correct?"green":"red",Be={currenTextParagraph:w,fullText:xt.fullText,index:rt,isCorrect:Qe()};D({...P,[`text_${w}`]:{type:"fixed",fullText:xt.fullText,correct:Be.isCorrect}}),M([...F,Be])},it=()=>{g.current.scrollTop=g.current.scrollHeight+100},gt=()=>{if(g.current.querySelector(".wrapfixed").offsetHeight>g.current.offsetHeight){const rt=g.current.querySelector(".wrapfixed").offsetHeight;g.current.scrollTo({top:rt,behavior:"smooth"})}},Ge=(rt,xt,Et)=>{const Qe=rt.fullText,Be=p[Et+1]?p[Et+1].type:"",Xe=P[`text_${Et+1}`]&&P[`text_${Et+1}`].type?P[`text_${Et+1}`].type:Be;return jsxRuntimeExports.jsx(FixedComponent,{length:xt,doneTyping:N,index:Et,delay:ee,setDoneTyping:k,nextParagraphType:Xe,isWriting:gt,textToPrint:Qe},Et.toString())},Me=(rt,xt)=>{const Et=rt.fullText;return jsxRuntimeExports.jsx(FinishedTextComponent,{textToPrint:Et,correct:rt.correct},xt)},De=rt=>jsxRuntimeExports.jsx(ElectionComponent,{soundActions:x,textWithOpts:rt.electionTexts,setCurrentDecisionSelected:St,printed:it,disableExit:fe},rt.electionTexts),Ve=(rt,xt,Et)=>rt.type==="fixed"?Ge(rt,xt,Et):De(rt);React$2.useEffect(()=>{N===!0&&(()=>{p[w+1]?(D({...P,[`text_${w+1}`]:{...p[w+1],id:`text_${w+1}`,correct:""}}),C(w+1),k(!1)):T(!0)})()},[N,w,P,p]);const ct=React$2.useMemo(()=>{let rt=`writer-puzzle writer-puzzle--${e}`;return S&&(rt+=" disable-background-image"),rt},[S,e]),dt={backgroundImage:R!=null&&R.url?`url('${R.url}')`:""};return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:ct,style:dt,children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__overlay",children:[B&&jsxRuntimeExports.jsx(FeedbackComponent,{emitEvent:l,texts:p,setFailed:()=>_(!0),decisionsList:F,closingAction:Oe,retry:t,skip:a,checkCorrect:ce,retryAction:Le,rewardsStack:ne,nodeId:n,soundActions:x}),!B&&jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__container",children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"writer-puzzle__title",children:h!==""&&h}),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:g,children:[jsxRuntimeExports.jsx("div",{className:"wrapfixed",children:Q&&!U&&Object.values(P).map((rt,xt)=>Ve(rt,Object.values(P).length-1,xt))}),U&&Object.values(P).map((rt,xt)=>Me(rt,xt))]})}),v&&jsxRuntimeExports.jsx("div",{className:"writer-puzzle__footer",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:Oe,children:E("screens.continue")})})]})]})})})}WriterPuzzleComponent.defaultProps={emitEvent:()=>{},info:{},styles:"",nodeId:"0",retry:!1,skip:!1,type:"",documentTitle:"",texts:[]};function Image$1({document:l,name:e,isWallpaper:n}){const t=(l==null?void 0:l.url)||null;return jsxRuntimeExports.jsx("div",{className:`puzzle--terminal__image ${n?"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:l,solution:e,showContinue:n,info:t,resolvePuzzle:a,backFile:o,translate:d,soundActions:f,keyboardControl:h}){var b;const{fileId:u}=l,p=((b=l.document)==null?void 0:b.url)||"",[x]=f,R={image:{component:Image$1,props:{...l,url:p,soundActions:f}},video:{component:VideoVisor,props:{...l,url:p,endVideo:a,soundActions:f,translate:d}},embedded_video:{component:VideoVisor,props:{...l,url:p,soundActions:f}},pdf:{component:PdfVisor,props:{...l,url:p,translate:d,soundActions:f,emitNumberOfPages:()=>{},endPdf:()=>{},keyboardControl:h}},application:{component:PdfVisor,props:{...l,url:p,translate:d,soundActions:f,emitNumberOfPages:()=>{},keyboardControl:h,endPdf:()=>{}}}};if(!R[l.type])return null;const S=R[l.type].component,E=R[l.type].props,v=l.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:x,shortText:!0,success:u===T,text:u===T?t.solution.right.desc:t.solution.wrong.desc,functionOnClose:u===T?a:o,additionalStyle:ICONS$1[l.type],secondText:v,translate:d,puzzleHeaderClass:"puzzle--terminal__visor--message",keyboardControl:h}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__visor--body",children:jsxRuntimeExports.jsx(S,{...E})}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__button",children:u===T&&n?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary green",type:"button",onClick:a,children:d("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:l,selectItem:e}){const n=l.name;return jsxRuntimeExports.jsx("li",{className:"puzzle--terminal__folder__list--item",children:jsxRuntimeExports.jsxs("button",{type:"button",title:n,className:`unset-button puzzle--terminal__item id-${l.id}`,onClick:()=>l.fixed?null:e(l),children:[jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__icon ${ICONS[l.type]}`}),jsxRuntimeExports.jsx("span",{children:n})]})})}function FilesGroup({initFile:l,backFile:e,file:n,closeFolder:t,selectItem:a}){return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:n.id==="init"?jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:n.children.map((o,d)=>jsxRuntimeExports.jsx(Item,{selectItem:a,item:o},`${`${d}${o.id}`}`))}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:l.children.map((o,d)=>jsxRuntimeExports.jsx(Item,{selectItem:a,item:o},`${d+o.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[n.type]}`}),jsxRuntimeExports.jsx("span",{className:"text",children:n.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:n.children.map((o,d)=>jsxRuntimeExports.jsx(Item,{selectItem:a,item:o},`${d+o.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:l,items:e,backgroundImage:n,solution:t,info:a,disableExit:o,soundActions:d,setResolveAction:f,nodeId:h,keyboardControl:u}){const[p,x]=React$2.useState({}),[R]=React$2.useState(!1),[S,E]=React$2.useState([]),g=React$2.useRef([]),[v]=d,T=k=>l({type:"translate",payload:k}),b=`terminal-puzzle_${h}`,_=React$2.useMemo(()=>({name:"init",children:[...FIXED_ITEMS,...e],id:"init"}),[e]),w=React$2.useCallback(k=>{v("click-ui"),x(k),E([...S,k]),k.type!=="folder"&&(l({type:"hidePuzzleButtons",payload:!0}),o(!0))},[S,o,l,v]);React$2.useEffect(()=>{x(_),E([_])},[_]),React$2.useEffect(()=>{f(()=>{g.current=[...g.current,...a.resolve.rewards];const k=g.current.map(F=>{var re;const{name:M,points:U,type:$,id:B}=F,J={name:M,points:U,type:$,id:B};return(re=F==null?void 0:F.document)!=null&&re.resourceId&&(J.id=F.document.resourceId),J});l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:b,rewards:k,finish:!0}})})},[f,a.resolve.rewards,l,b]);const C=()=>{g.current=[...g.current,...a.solution.wrong.rewards];const k=S.length-1,F=S.filter((M,U)=>k>U);x(S[k-1]),E(F),o(!1),l({type:"hidePuzzleButtons",payload:!1})},P=()=>{v("click-ui");const k=S[0];x(k),E([k])},D=()=>{g.current=[...g.current,...a.solution.right.rewards];const k=g.current.map(F=>{var re;const{name:M,points:U,type:$,id:B}=F,J={name:M,points:U,type:$,id:B};return(re=F==null?void 0:F.document)!=null&&re.resourceId&&(J.id=F.document.resourceId),J});l({type:"hidePuzzleButtons",payload:!1}),v("score"),l({type:"addPoints",complex:!0,finish:!0,payload:k}),l({type:"passPuzzle"})},N=(n==null?void 0:n.url)||DEFAULT_IMG;return jsxRuntimeExports.jsx("div",{className:"puzzle--terminal",children:p.children?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Image$1,{isWallpaper:!0,document:{url:N}}),jsxRuntimeExports.jsx(FilesGroup,{backFile:C,initFile:_,selectItem:w,breadcrumb:S,closeFolder:P,file:p,translate:T})]}):jsxRuntimeExports.jsx(Visor,{soundActions:d,backFile:C,resolvePuzzle:D,info:a,showContinue:!R,solution:t,file:p,translate:T,keyboardControl:u})})}function DragItemPuzzleComponent({area:l,image:e,resolveObject:n,info:t,hasHighlights:a,consume:o,disableExit:d,emitEvent:f,soundActions:h,keyboardControl:u}){const{solution:p}=t,x=React$2.useRef(),R=React$2.useRef(),S=React$2.useRef(),E=React$2.useRef(),g=React$2.useRef({}),[v,T]=React$2.useState(""),[b,_]=React$2.useState(!1),[w,C]=React$2.useState(),[P]=React$2.useState(new window.Image),D=React$2.useRef([]),[N]=h,k=fe=>f({type:"translate",payload:fe});React$2.useEffect(()=>{d(v!=="")},[v,d]);const F=(fe,te)=>(fe.x+fe.width>te.x&&fe.x+fe.width<=te.x+te.width||te.x+te.width>fe.x&&te.x+te.width<=fe.x+fe.width)&&(fe.y+fe.height>te.y&&fe.y+fe.height<=te.y+te.height||te.y+te.height>fe.y&&te.y+te.height<=fe.y+fe.height),M=()=>{x&&a&&(x.current.to({duration:.25,opacity:.75}),R.current.to({duration:.25,opacity:.4}))},U=()=>{x&&a&&(x.current.to({duration:.25,opacity:0}),R.current.to({duration:.25,opacity:0}))},$=React$2.useCallback(fe=>{let te=!1;if(fe){const H=S.current;H.setPointersPositions(fe);const W=H.getPointerPosition(),V=x.current.getClientRect({relativeTo:H});te=F({...W,width:1,height:1},V)}return te},[]),B=React$2.useCallback(fe=>fe&&n.uid===JSON.parse(fe).uid,[n.uid]),J=React$2.useCallback(()=>{T(""),f({type:"hidePuzzleButtons",payload:!1}),f({type:"addPoints",complex:!0,finish:!0,payload:D.current}),f({type:"passPuzzle"}),o&&f({type:"consumeItem",payload:{uid:n.uid,targetId:n.uid,name:n.name}}),f({type:"closeUI",ui:"inventory"})},[o,f,n.name,n.uid]),re=React$2.useCallback(()=>{T("success"),f({type:"hidePuzzleButtons",payload:!0}),D.current=[...D.current,...p.right.rewards],setTimeout(()=>{J()},2e3)},[f,J,p.right.rewards]),ae=React$2.useCallback(()=>{f({type:"openUI",ui:"inventory",onFinish:()=>{}}),T(""),f({type:"hidePuzzleButtons",payload:!1}),f({type:"failPuzzle"}),D.current=[...D.current,...p.wrong.rewards]},[f,p.wrong.rewards]),Q=React$2.useCallback(fe=>{const te=fe.dataTransfer.getData("item");S.current.setPointersPositions(fe);const H=$(fe);f({type:"hidePuzzleButtons",payload:!0}),H&&B(te)?(T("success"),f({type:"closeUI",ui:"inventory"}),t.solution.right.desc===""&&re()):(f({type:"closeUI",ui:"inventory"}),T("failed"),t.solution.wrong.desc===""&&setTimeout(()=>{ae()},2e3))},[$,B,f,re,ae,t.solution.right.desc,t.solution.wrong.desc]),K=()=>{v==="success"?re():ae()};React$2.useEffect(()=>{const fe=e.img.url||"";P.src=fe,P.onload=()=>{E.current&&(g.current={x:E.current.clientWidth/2,y:E.current.clientHeight/2,width:P.width,height:P.height,offsetX:P.width/2,offsetY:P.height/2,scale:{x:Math.min(E.current.clientWidth/P.width,E.current.clientHeight/P.height),y:Math.min(E.current.clientWidth/P.width,E.current.clientHeight/P.height)}},_(!0))}},[P,e.img.url]);const ne=fe=>{fe!==null&&(x.current=fe)},ue=fe=>{if(fe!==null&&(R.current=fe,x.current)){const{x:te,y:H,width:W,height:V}=x.current.getClientRect();fe.setAttr("x",te),fe.setAttr("y",H),fe.setAttr("height",V),fe.setAttr("width",W)}};return React$2.useLayoutEffect(()=>{if(x.current&&b){const fe=x.current.getClientRect({relativeTo:x.current.getParent()});C({x:fe.x+fe.width/2,y:fe.y+fe.height/2})}},[b]),jsxRuntimeExports.jsxs("div",{className:"puzzle--drag__mask100",onDrop:Q,onDragOver:fe=>{fe.preventDefault()},children:[jsxRuntimeExports.jsx("div",{className:"puzzle--drag__mask",children:jsxRuntimeExports.jsx("div",{ref:E,"data-testid":"mask_canvas",className:"puzzle--drag__mask--canvas",children:b?jsxRuntimeExports.jsx(Stage,{ref:S,width:E.current.clientWidth,height:E.current.clientHeight,children:jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Image$2,{image:P,...g.current}),jsxRuntimeExports.jsxs(Group,{...g.current,children:[w?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...w},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:"object-area-projection"})}):null,jsxRuntimeExports.jsx(Line,{onMouseEnter:M,onMouseLeave:U,ref:ne,...l,shape:"poly",fill:"#262a31d9",stroke:"white",strokeWidth:1,opacity:0,dash:[3,2],closed:!0,draggable:!1})]}),jsxRuntimeExports.jsx(Text,{onMouseEnter:M,onMouseLeave:U,ref:ue,text:k("puzzle.drag.dropzone"),fontSize:12,align:"center",verticalAlign:"middle",fill:"#ffffff",opacity:0})]})}):null})}),v!==""?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:t.solution[v==="success"?"right":"wrong"].desc,success:v==="success",translate:k,playSound:N,functionOnClose:K,keyboardControl:u}):null]})}const LABELS_INDEX$1=["A","B","C","D","E","F","G","H","I","J"];function Questions({disabled:l,answered:e,question:n,updateForm:t,result:a,correctQuestions:o,translate:d}){const[f,h]=React$2.useState(!1),u=n.answers.filter(v=>v.text),p=v=>{let T=!1;return a[n.id].find(b=>b.id===v)&&(T=!0),T},x=v=>{let T="";return f?(e&&p(v.id)&&(T="selected"),l&&p(v.id)&&o.includes(v.id)&&(T="success"),l&&p(v.id)&&!o.includes(v.id)&&(T="failed")):(e&&v.id===a[n.id][0].id&&(T="selected"),l&&v.id===a[n.id][0].id&&(T=a[n.id][0].isCorrect?"success":"failed")),T},R=v=>{const T=x(v);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":""},S=v=>l&&v.feedback&&(f&&p(v.id)||v.id===a[n.id][0].id),E=(v,T)=>T===0?"tooltip--right__top":T===v.length-1?"tooltip--right__bottom":"tooltip--center__right",g=n.answers.filter(v=>v.isCorrect);return React$2.useEffect(()=>{g.length===1?h(!1):h(!0)},[g.length,f,n.answers]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:n.text})}),f&&!l?jsxRuntimeExports.jsx("div",{className:"test--questions__intertitle test--questions__intertitle--multiresponse",children:d("tests.chooseMoreOneAnswer")}):null,u.map((v,T)=>jsxRuntimeExports.jsxs("div",{className:"test--response__fakeinput",children:[f?jsxRuntimeExports.jsx("input",{checked:e&&p(v.id),disabled:l&&!p(v.id),readOnly:l,type:"checkbox",id:v.id,onChange:()=>l?null:t(v,n.id,T,"isCheckbox",v.id)}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("input",{checked:e&&v.id===a[n.id][0].id,disabled:l&&!x(v),type:"radio",name:"name",id:v.id,onChange:()=>l?null:t(v,n.id,T,"isRadio")})}),jsxRuntimeExports.jsxs("label",{htmlFor:v.id,className:`test--response__item ${x(v)}`,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:v.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${R(v)}`})]}),l?jsxRuntimeExports.jsxs("div",{className:`test--feedback__info ${S(v)?"":"test--feedback__info--hidden"}`,children:[jsxRuntimeExports.jsx("span",{className:`icon-info2 ${x(v)==="success"?"color--success":"color--error"}`}),jsxRuntimeExports.jsxs("div",{id:`tooltipFeedback-${T}`,className:`tooltip ${E(u,T)}`,children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsx("span",{children:d("test.feedback")})})}),jsxRuntimeExports.jsx("span",{children:jsxRuntimeExports.jsx("span",{children:v.feedback})})]})]}):null]},v.text))]})}const LABELS_INDEX=["A","B","C","D","E","F","G","H","I","J"];function FeedbackItem({selectedAnswers:l,correctQuestions:e,question:n,translate:t}){const a=f=>e.includes(f),o=(f,h)=>f.index<h.index?-1:f.index>h.index?1:0,d=l.sort(o);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:n})}),d.map(f=>jsxRuntimeExports.jsxs("div",{className:"test--response__itemwrap",children:[jsxRuntimeExports.jsxs("div",{className:`test--response__item ${a(f.id)?"success":"failed"}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX[f.index]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:f.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${a(f.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")," ",l.length>1?LABELS_INDEX[f.index]:""]})})}),jsxRuntimeExports.jsx("span",{children:f.feedback})]})]},f.text))]})}function Container({questions:l,setTime:e,saveInterval:n,result:t,setTries:a,tries:o,time:d,showResults:f,answered:h,answerPage:u,updateForm:p,disabled:x,translate:R,soundActions:S,paused:E,view:g,correctQuestions:v,feedbacksOnlyWhenReview:T}){const b=document.querySelector(".test--container"),[_,w]=React$2.useState(0),[C,P]=React$2.useState(),D=l[_].id,[N]=S;React$2.useEffect(()=>{if(d>=0&&!x&&!E){const re=setInterval(()=>{C||e(ae=>ae-1)},1e3);return n(re),()=>{clearInterval(re)}}},[x,C,E,n,e,d]);const k=()=>{b.scrollTo(0,0),N("click-ui"),h&&(t[D][0].feedback&&!x&&!T?P(!0):(u(!1),w(_+1)))},F=()=>{N("click-ui"),w(_-1)},M=()=>{b.scrollTo(0,0),l[_+1]?(P(!1),u(!1),w(_+1)):f()},U=()=>{b.scrollTo(0,0),a(o+1),t[D][0].feedback&&!x&&!T?P(!0):f()},$=Math.floor(d/60),B=d%60;React$2.useEffect(()=>{if(g==="review"){const re=t[`q${_}`][0].id,ae=document.querySelector(`#${re}`);b.scrollTo(0,ae.offsetTop)}},[_,b,t,g]);const J=()=>{if(h){const re=v[l[_].id.substring(1)].answers,ae=t[D],Q=ae.find(ne=>ne.isCorrect===!1);let K=0;return ae.forEach(ne=>{re.includes(ne.id)&&(K+=1)}),!Q&&K===re.length}return!1};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[g==="review"||C?jsxRuntimeExports.jsx("div",{"data-testid":"feedbackWrapper",className:`test-feedback-header ${J()?"success":"failed"}`,children:jsxRuntimeExports.jsxs("h2",{children:[jsxRuntimeExports.jsx("span",{className:`${J()?"icon-correct-thumb":"icon-incorrect-thumb"}`}),jsxRuntimeExports.jsx("span",{className:"test-feedback-header__title",children:J()?R("tests.resolvedQuestion"):R("tests.notResolvedQuestion")})]})}):null,jsxRuntimeExports.jsxs("div",{className:"test--questions",children:[jsxRuntimeExports.jsx("div",{className:"test--questions__container",children:C?jsxRuntimeExports.jsx(FeedbackItem,{selectedAnswers:t[D],correctQuestions:v[l[_].id.substring(1)].answers,question:l[_].text,translate:R}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"test--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:LangIsRtl()?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[_+1,"/",l.length," ",jsxRuntimeExports.jsx("span",{children:R("tests.question")})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{children:R("tests.question")})," ",_+1,"/",l.length]})}),g!=="review"&&d>=0?jsxRuntimeExports.jsx("div",{dir:"ltr",className:`count-down ${d<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{id:"test-time",children:[$<10?`0${$}`:$," : ",B<10?`0${B}`:B]})}):null]}),jsxRuntimeExports.jsx(Questions,{result:t,disabled:x,answered:h,updateForm:p,question:l[_],correctQuestions:x?v[l[_].id.substring(1)].answers:[],translate:R},l[_].id)]})}),jsxRuntimeExports.jsxs("div",{className:`test--buttons ${g==="review"?"reviewmode":"next"}`,children:[g==="review"?jsxRuntimeExports.jsx("button",{disabled:_===0,id:"back-button",onClick:()=>F(),type:"button",className:`gat--btn__navigation ${_===0?"disabled":""}`,"aria-label":LangIsRtl()?R("survey.next"):R("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}):null,!C&&l[_+1]?jsxRuntimeExports.jsx("button",{disabled:!h,id:"next-button","data-testid":"nextButton",onClick:()=>k(),type:"button",className:`gat--btn__navigation ${h?"":"disabled"}`,"aria-label":LangIsRtl()?R("survey.previous"):R("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null,C?jsxRuntimeExports.jsx("button",{id:"next-button","data-testid":"nextFeedbackButton",onClick:()=>M(),type:"button",className:"gat--btn__navigation",children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null,!C&&l[_].id.substring(1)===(l.length-1).toString()?jsxRuntimeExports.jsx("button",{disabled:!h,id:"continue-button","data-testid":"continueButton",onClick:()=>{N("click-ui"),h&&U()},type:"button",className:`gat--btn__navigation ${h?"":"disabled"}`,"aria-label":LangIsRtl()?R("survey.previous"):R("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null]})]})]})}function ResultsComponent({result:l,time:e,mandatory:n,correctQuestions:t,isFirst:a,reviewTest:o,finishTest:d,restartTest:f,timeOver:h,timeOverText:u,emitEvent:p,minimumPercentage:x}){const R=React$2.useRef(),[S,E]=React$2.useState(0),[g,v]=React$2.useState(),[T,b]=React$2.useState([]),[_,w]=React$2.useState([]),[C,P]=React$2.useState(),D=React$2.useCallback(()=>{const K=[];return t.forEach(ne=>K.push(ne.answers)),K},[t]),N=React$2.useCallback(()=>{const K=[];return Object.values(l).forEach(ne=>{if(ne.length>1){const ue=ne.find(te=>te.isCorrect===!1),fe=[];ue?K.push([]):(ne.forEach(te=>{te.isCorrect&&fe.push(te.id)}),K.push(fe))}else ne[0].isCorrect?K.push([ne[0].id]):ne[0].isCorrect===!1&&K.push("")}),K},[l]),k=React$2.useCallback(()=>{let K=0;if(_.length>0)return T.forEach((ne,ue)=>{ne.length>1?ne.every(fe=>{var te;return(te=_[ue])==null?void 0:te.includes(fe)})&&(K+=1):ne.length===1&&_[ue]&&ne[0]===_[ue][0]&&(K+=1)}),K},[T,_]);React$2.useEffect(()=>{C===void 0&&(b(D),w(N),P(k))},[D,N,k,C]);const F=t.length,M=k()===F,U=C<x,$=C>=x,B=!n||$,J=Math.trunc(S/F*100),re=(K,ne)=>p({type:"translate",payload:K,values:ne}),ae={"--chart-color":"var(--color-error)"};React$2.useEffect(()=>{if(S<C){const K=setInterval(()=>{E(ne=>ne+1)},100);return v(K),()=>{clearInterval(K)}}},[C,S]),React$2.useEffect(()=>{S>=C&&clearInterval(g)},[C,g,S]);const Q=()=>{R.current=!0,d()};return jsxRuntimeExports.jsxs("div",{"data-testid":"resultsWrapper",className:`test--results ${U||h?"test--results--failed":""}`,children:[a&&M?jsxRuntimeExports.jsxs("div",{"data-testid":"fireworks",className:"fireworks",children:[jsxRuntimeExports.jsx("div",{className:"before"}),jsxRuntimeExports.jsx("div",{className:"after"})]}):null,!h&&U?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:re("tests.NotFinishedSuccessfully")})}):null,!h&&$||M?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:re("tests.finishedSuccessfully")})}):null,h?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:u})}),jsxRuntimeExports.jsx("div",{className:"test--results__time",id:"results-time",children:jsxRuntimeExports.jsx("span",{children:re("tests.time",e)})})]}):null,jsxRuntimeExports.jsxs("div",{className:`chart center chart${J}`,children:[jsxRuntimeExports.jsxs("div",{className:"chart-slice",children:[jsxRuntimeExports.jsx("div",{className:"chart-bar",style:U||h?ae:{}}),jsxRuntimeExports.jsx("div",{className:"chart-fill",style:U||h?ae:{}})]}),jsxRuntimeExports.jsxs("span",{className:"chart-value",children:[jsxRuntimeExports.jsxs("div",{className:"test--results__chart",children:[jsxRuntimeExports.jsx("span",{"data-testid":"correctPoints",children:S}),jsxRuntimeExports.jsxs("span",{"data-testid":"totalCorrectAnswers",children:["/",F]})]}),jsxRuntimeExports.jsx("div",{className:"test--results__chart--label",children:jsxRuntimeExports.jsx("span",{children:re("tests.success")})})]})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__minimum",children:[jsxRuntimeExports.jsx("div",{className:"icon-bell"}),jsxRuntimeExports.jsx("div",{children:re("tests.minimumQuestionsMessage",{minimumPercentage:x})})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__buttons",children:[h?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__secondary",id:"review-button",onClick:()=>o(),type:"button",children:jsxRuntimeExports.jsx("span",{children:re("tests.review")})}),B?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary","data-testid":"restartButton",id:"restart-button",onClick:()=>f(),type:"button",children:jsxRuntimeExports.jsx("span",{children:re("tests.restart")})}),B?jsxRuntimeExports.jsx("button",{disabled:R.current===!0,className:`gat--btn gat--btn__primary ${R.current===!0&&"disabled"}`,"data-testid":"finishButton",id:"finish-button",onClick:()=>Q(),type:"button",children:jsxRuntimeExports.jsx("span",{children:re("tests.continue")})}):null]})]})}function TestComponent({test:l,countdown:e={},emitEvent:n,soundActions:t,audio:a,required:o,pause:d,minimumPercentage:f=100,feedbacksOnlyWhenReview:h}){const{questions:u}=l,[p,x]=React$2.useState({}),[R,S]=React$2.useState(),[E,g]=React$2.useState(0),[v,T]=React$2.useState([]),[b,_]=React$2.useState(e.time),[w,C]=React$2.useState(!1),[P,D]=React$2.useState("test"),[N,k]=React$2.useState(!0),[F,M]=React$2.useState({}),[U,$]=React$2.useState({}),[B,J]=React$2.useState(!1),re=o||l.required||!1,ae=React$2.useRef({}),[Q,K]=React$2.useState(),[ne,ue]=t,fe=(q,ee,le,ce,he)=>{const ve={...q,index:le};if(E>0&&(ve.rewards=ve.rewards.filter(Re=>!U[q.id]||Re.points<0)),p[ee]){const Re=p[ee].find(Le=>Le.id===he);if(Re){if(Re.id===q.id){const Le=p[ee].find(Ke=>Ke.id===he),Oe=p[ee].indexOf(Le);if(p[ee].splice(Oe,1),p[ee].length===0){C(!1);return}}}else p[ee].push(ve)}else p[ee]=[ve];let be;ce==="isRadio"?be={...p,[ee]:[ve]}:be={...p},x(be),M(be),$({...U,[q.id]:{...q}}),C(!0)};React$2.useEffect(()=>{a!=null&&a.url&&ne(a.url,"tts")},[ne,a]);const te=u.map(q=>{const ee=q.answers.filter(ce=>ce.isCorrect),le=[];return ee.forEach(ce=>{le.push(ce.id)}),{question:q.id,answers:le}});React$2.useEffect(()=>{v.length===0&&T(te)},[v.length,te]),React$2.useEffect(()=>{if(f){const q=Math.ceil(u.length*f/100);K(q)}},[u.length,f]),React$2.useEffect(()=>{b===0&&(clearInterval(R),C(!1),J(!0),D("results"),ue("tts"))},[R,ue,b]);const H=()=>{clearInterval(R),C(!1),D("results");const q={...F};M(q),ue("tts")},W=()=>{const q={correctQuestions:v.length,result:p,status:"resolved"};Object.keys(p).forEach(le=>{p[le].forEach(ce=>{ae.current[ce.id]&&(ce.rewards=[])})}),n({type:"saveTest",payload:q})},V=()=>{const q=()=>{M({}),$({}),D("test"),x({}),_(e.time),J(!1),a!=null&&a.url&&ne(a.url,"tts")},ee=Object.values(p);ee.forEach(ce=>{ce.forEach(he=>{he.isCorrect&&(ae.current[he.id]?he.rewards=[]:ae.current[he.id]=!0)})});let le=ee.reduce((ce,he)=>{const ve=[];return he.forEach(be=>{ve.push(be.rewards)}),[...ce,...ve.flat()]},[]);B&&e.rewards&&(le=[...le,...e.rewards]),n({type:"addPoints",payload:le,complex:!0,finish:!1,onFinish:q()}),n({type:"failTest"})},z=(q,ee)=>n({type:"translate",payload:q,values:ee});return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--container__overlay"}),jsxRuntimeExports.jsx("div",{"data-testid":"wrapperTest",className:"test--container",dir:"auto",children:P!=="results"?jsxRuntimeExports.jsx(Container,{result:p,time:b,setTries:g,tries:E,answerPage:C,setTime:_,paused:d,saveInterval:S,disabled:P!=="test",answered:w||P!=="test",questions:u,updateForm:fe,showResults:H,translate:z,soundActions:t,view:P,correctQuestions:v,feedbacksOnlyWhenReview:h}):jsxRuntimeExports.jsx(ResultsComponent,{reviewTest:()=>{k(!1),D("review")},isFirst:N,finishTest:W,time:b,mandatory:re,restartTest:V,result:p,correctQuestions:v,timeOver:B,timeOverText:e.text,emitEvent:n,soundActions:t,minimumPercentage:Q})})]})}const OPTIONS=["yes","no"],LETTERS=["A","B"];function ApplicableBox({setSurveyData:l,survey:e,id:n,translate:t,changePage:a}){const o=d=>{l({...e,[n]:d}),a()};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:OPTIONS.map((d,f)=>jsxRuntimeExports.jsxs("button",{"data-testid":`applicablebox-${OPTIONS[f]}`,type:"button",onClick:()=>o(d),className:`unset-button survey--response__item ${e[n]===d?"selected":""}`,children:[jsxRuntimeExports.jsx("div",{className:"survey--response__index",children:LETTERS[f]}),jsxRuntimeExports.jsx("div",{className:"survey--response__text",children:t(`survey.${d}`)})]},d))})}const OPINION_OPTIONS=[0,1,2,3,4,5,6,7,8,9,10];function OpinionBox({setSurveyData:l,survey:e,id:n,translate:t,changePage:a}){const o=d=>{l({...e,[n]:d}),a()};return jsxRuntimeExports.jsxs("div",{className:"survey--page__item","aria-label":"opinion box",children:[jsxRuntimeExports.jsx("div",{className:"survey--points",children:OPINION_OPTIONS.map(d=>jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>o(d),className:`unset-button survey--points__item survey--points__item--colorized ${e[n]===d?"selected":""}`,children:d},d))}),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:l,survey:e,id:n,literalLabel:t}){const a=o=>{l({...e,[n]:o})};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:jsxRuntimeExports.jsx("textarea",{ref:o=>{o&&o.focus()},className:"survey--textarea",id:t,value:e[n],onChange:o=>a(o.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:l,soundActions:e}){const[n,t]=React$2.useState(INIT_SURVEY),[a,o]=React$2.useState(0),[d,f]=React$2.useState(!1),[h]=e,u=(R,S)=>l({type:"translate",payload:R,values:S}),p=(R=!1)=>{if(h("click-ui"),!R&&a+1>=PAGES.length)f(!0);else{R&&f(!1);const S=R?a-1:a+1;o(S)}},x=PAGES[a].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:u("survey.numQuestion",{init:a+1,page:PAGES.length})})}),jsxRuntimeExports.jsx("div",{children:u("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsx("label",{className:"survey--questions__item","data-testid":`survey.question${a+1}`,htmlFor:u(`survey.question${a+1}`,{ordinal:a+1}),children:u(`survey.question${a+1}`,{ordinal:a+1})}),jsxRuntimeExports.jsx(x,{setSurveyData:t,id:PAGES[a].id,survey:n,translate:u,changePage:R=>p(!1),literalLabel:u(`survey.question${a+1}`,{ordinal:a+1})})]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next",children:[jsxRuntimeExports.jsx("button",{"data-testid":"backButton",id:"survey-button-back",type:"button",disabled:a===0,onClick:()=>p(!0),className:`gat--btn__navigation ${a===0?"disabled":""}`,"aria-label":LangIsRtl()?u("survey.next"):u("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),d&&a===PAGES.length-1?jsxRuntimeExports.jsx("button",{"data-testid":"survey.finish",id:"survey-button",type:"button",disabled:!n[PAGES[a].id],onClick:()=>{h("click-ui"),l({type:"saveSurvey",payload:n})},className:`gat--btn gat--btn__primary ${n[PAGES[a].id]?"":"disabled"} not-transition`,children:u("survey.finish")}):null,!d&&a!==PAGES.length?jsxRuntimeExports.jsx("button",{"data-testid":"nextButton",id:"survey-button",type:"button",disabled:!n[PAGES[a].id],onClick:()=>p(!1),className:`gat--btn__navigation ${n[PAGES[a].id]?"":"disabled"}`,"aria-label":LangIsRtl()?u("survey.previous"):u("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null]})]})})]})}function EndScreen({onFinish:l,translate:e}){return React$2.useEffect(()=>{let n;return l&&(n=setTimeout(()=>{l()},2e3)),()=>{n&&clearTimeout(n)}},[l]),jsxRuntimeExports.jsx("div",{"data-testid":"endScreen",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:l,description:e,translate:n}){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",{"data-testid":"auto-start-button",type:"button",className:"gat--btn gat--btn__primary auto-evaluation__button auto-evaluation__button--start",onClick:l,children:jsxRuntimeExports.jsx("span",{children:n("auto-evaluation.start")})})]})}function AutoEvaluation({description:l,questions:e,type:n,emitEvent:t,soundActions:a}){var w,C,P;const[o,d]=React$2.useState(null),[f,h]=React$2.useState("start"),[u,p]=React$2.useState(!1),[x,R]=React$2.useState(0),[S,E]=React$2.useState({current:{questions:[],type:n}}),[g]=a,v=D=>t({type:"translate",payload:D}),T=D=>{D.code==="Enter"&&D.target.blur()},b=()=>{g("click-ui"),t({type:"saveSurveyPrePos",payload:S.current})};React$2.useEffect(()=>{!e.length&&f==="questions"&&h("end")},[e,f]);const _=(D,N=!1)=>{var F;const k=D!==null?D:(F=S.current.questions.find(M=>M.id===e[x].id))==null?void 0:F.answer;if(g("click-ui"),N)R(x-1),p(!1);else{const M=S.current.questions.findIndex($=>$.id===e[x].id),U=[...S.current.questions];M>-1?U.splice(M,1,{id:e[x].id,answer:k}):U.push({id:e[x].id,answer:k}),E({...S,current:{...S.current,questions:U}}),x===e.length-1?p(!0):(R(x+1),p(!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:[f==="start"&&jsxRuntimeExports.jsx(StartScreen,{description:l,onNext:()=>{h("questions"),g("click-ui")},translate:v}),f==="questions"&&jsxRuntimeExports.jsxs("div",{"data-testid":"survey--questions",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:[v("auto-evaluation.question")," ",x+1," ",v("storylines.misc.of")," ",e.length]})}),jsxRuntimeExports.jsx("div",{children:v("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"survey--questions__item","aria-label":"survey questions item",children:(w=e[x])==null?void 0:w.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((D,N)=>{var k;return jsxRuntimeExports.jsx("button",{"data-testid":`button-option-${0+N}`,type:"button",onTouchStart:()=>{d(N)},onTouchEnd:()=>{d(null)},onKeyUp:F=>{T(F)},onClick:()=>{_(N,!1)},className:`survey--points__item survey--points__item--simple ${((k=S.current.questions[x])==null?void 0:k.answer)===N||o===N?"selected":""}`,children:N},`${0+N}`)})})})]},`${e[x]}`)]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next","aria-label":"test buttons",children:[jsxRuntimeExports.jsx("button",{"data-testid":"back-button",type:"button",disabled:x===0,onClick:()=>_(null,!0),"aria-label":LangIsRtl()?v("survey.next"):v("survey.previous"),className:`gat--btn__navigation ${x===0?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back","aria-label":"icon button"})}),u?jsxRuntimeExports.jsx("button",{"data-testid":"finish-button",type:"button",onClick:()=>{h("end"),g("click-ui")},className:`gat--btn gat--btn__primary auto-evaluation__button not-transition
|
|
253
253
|
`,children:jsxRuntimeExports.jsx("span",{children:v("auto-evaluation.end")})}):jsxRuntimeExports.jsx("button",{"data-testid":"forward-button",type:"button",onClick:()=>_(null,!1),disabled:((C=S.current.questions[x])==null?void 0:C.answer)===void 0,"aria-label":LangIsRtl()?v("survey.previous"):v("survey.next"),className:`gat--btn__navigation ${((P=S.current.questions[x])==null?void 0:P.answer)===void 0?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]}),f==="end"&&jsxRuntimeExports.jsx(EndScreen,{onFinish:b,translate:v})]})]})}function PatternComponent({img:l,name:e,viewed:n,emitEvent:t,soundActions:a,keyboardControl:o}){const[d]=a,f=x=>t({type:"translate",payload:x}),h=()=>{d("click-ui"),t({type:"emitSavePattern",payload:{imgId:l.resourceId,name:e,viewed:!0,url:p,type:"pattern"}})},u=o({disabled:n,forward:h,escape:h});if(React$2.useEffect(()=>u(),[u]),!l)return null;const p=l.url;return jsxRuntimeExports.jsx("div",{className:n?"notes--results":"readings--container pattern-wrap--overlay",children:jsxRuntimeExports.jsx("div",{className:n?"notes--results__text":"pattern-wrap",children:n?jsxRuntimeExports.jsx("div",{children:p&&jsxRuntimeExports.jsx("img",{src:p,alt:"pattern"})}):jsxRuntimeExports.jsxs("div",{className:"pattern",children:[jsxRuntimeExports.jsxs("div",{className:"pattern__header",children:[jsxRuntimeExports.jsx("div",{className:"pattern__title",children:f("phone.pattern")}),jsxRuntimeExports.jsx("button",{type:"button","aria-label":f("storylines.misc.closePiece"),className:"pattern__close gat--btn__round gat--btn__close",onClick:()=>h(),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})]}),jsxRuntimeExports.jsx("figure",{className:"pattern__figure",children:p&&jsxRuntimeExports.jsx("img",{src:p,alt:"pattern"})})]})})})}const getRecursiveJSX=(l,e=0,n,t,a)=>{var o,d;if((o=l.props)!=null&&o.children){const f=l.type,{children:h,...u}=l.props;if(l.props["data-text-id"]){if(u.dir="auto",u.onClick=p=>t(p,u["data-text-id"]||-1),n!=null&&n.hasHighlights){const p=[...n.correctTexts,...n.wrongTexts];for(let x=0;x<p.length;x+=1)u["data-text-id"]===p[x].id&&(u.className="text-click__hover-correct")}}else n!=null&&n.allWrong&&!l.props["data-text-id"]&&(u.onClick=p=>t(p,"allWrong"));return Array.isArray(h)?jsxRuntimeExports.jsx(f,{...u,children:h.map((p,x)=>getRecursiveJSX(p,x,n,t))},`${l.type}_${e}`):jsxRuntimeExports.jsx(f,{...u,children:getRecursiveJSX(h,e,n,t)},`${l.type}_${e}`)}return((d=l.props)==null?void 0:d.children)!==null?l.split(" ").filter(f=>f!=="").map(f=>jsxRuntimeExports.jsx("span",{dir:"auto",children:f},f)):null};function TextClickPuzzleComponent({emitEvent:l,showFrames:e,styles:n,list:t,soundActions:a,description:o,setInfo:d,setResolveAction:f,keyboardControl:h,backgroundImage:u,hideBackgroundImageTheme:p=!1,nodeId:x}){const R=`textclick-puzzle_${x}`,[S,E]=React$2.useState({result:null,show:!1,text:"",timeout:!1}),[g]=a,[v,T]=React$2.useState(0),[b,_]=React$2.useState(0),[w,C]=React$2.useState(0),P=React$2.useRef(0),D=React$2.useRef([]),[N,k]=React$2.useState(0),[F,M]=React$2.useState(),U=React$2.useCallback(V=>l({type:"translate",payload:V}),[l]),$=React$2.useRef(null),B=React$2.useCallback(()=>P.current===t[v].correctTexts.length||t[v].hasClickOnce&&P.current>=1,[v,t]),J=React$2.useCallback((V,z)=>{V&&l({type:"hidePuzzleButtons",payload:!0}),E(q=>({...q,show:V,...z}))},[l]),re=React$2.useCallback(()=>{if(B())if(E(V=>({...V,result:!1})),P.current=0,w===b){const V=D.current.reduce((z,q)=>{const ee=z.findIndex(le=>le.id===q.id);return ee>=0?z[ee].points+=q.points:z.push({...q}),z},[]);l({type:"addPoints",complex:!0,finish:!0,payload:V}),l({type:"passPuzzle"})}else $.current=null,T(v+1),k(0),M(!0),setTimeout(()=>{M(!1)},1200)},[B,w,b,l,v]),ae=React$2.useCallback(()=>{l({type:"hidePuzzleButtons",payload:!1}),re(),E(z=>({...z,show:!1,text:""}));const V=document.querySelectorAll(".text-click__failed");V.length>0&&V.forEach(z=>z.classList.remove("text-click__failed"))},[l,re]),Q=React$2.useCallback((V,z)=>{var q,ee;V.forEach(le=>le.classList.add("text-click__success")),C(w+1),P.current+=1,g("score"),(q=t[v].info.solution.right)!=null&&q.desc?B()&&(D.current=[...D.current,...t[v].info.solution.right.rewards],J(!0,{result:!0,text:t[v].info.solution.right.desc,timeout:!1})):t[v].info.solution.right.desc===""&&(z!=null&&z.desc)?(D.current=((ee=z==null?void 0:z.rewards)==null?void 0:ee.length)>0?[...D.current,...(z==null?void 0:z.rewards)||{}]:[...D.current],J(!0,{result:!0,text:z.desc,timeout:!1})):t[v].specificFeedbacks.specificCorrectFeedbacks?(D.current=[...D.current,...(z==null?void 0:z.rewards)||{}],B()&&J(!0,{result:!0,timeout:!0})):B()&&(D.current=[...D.current,...t[v].info.solution.right.rewards],J(!0,{result:!0,timeout:!0}))},[w,g,t,v,B,J]),K=React$2.useCallback((V,z)=>{var q;V.forEach(ee=>ee.classList.add("text-click__failed")),g("fail"),l({type:"failPuzzle"}),t[v].info.solution.wrong.desc!==""?(D.current=[...D.current,...t[v].info.solution.wrong.rewards],J(!0,{result:!1,text:t[v].info.solution.wrong.desc,timeout:!1})):t[v].info.solution.wrong.desc===""&&(z!=null&&z.desc)?(D.current=(q=z==null?void 0:z.rewards)!=null&&q.length?[...D.current,...(z==null?void 0:z.rewards)||{}]:[...D.current],J(!0,{result:!1,text:z.desc,timeout:!1})):t[v].specificFeedbacks.specificWrongFeedbacks?(D.current=[...D.current,...(z==null?void 0:z.rewards)||{}],J(!0,{result:!1,timeout:!0})):(D.current=[...D.current,...t[v].info.solution.wrong.rewards],J(!0,{result:!1,timeout:!0}))},[g,l,t,v,J]),ne=React$2.useCallback((V,z)=>{var be,Re,Le,Oe;V.stopPropagation();const q=document.querySelectorAll(`[data-text-id="${z}"]`),ee=document.querySelectorAll("[data-text-id]"),le=t[v].correctTexts.find(Ke=>Ke.id===z),ce=t[v].wrongTexts.find(Ke=>Ke.id===z),he=(Re=(be=t[v])==null?void 0:be.specificFeedbacks)==null?void 0:Re.correctFeedbacks.find(Ke=>Ke.id===z),ve=(Oe=(Le=t[v])==null?void 0:Le.specificFeedbacks)==null?void 0:Oe.wrongFeedbacks.find(Ke=>Ke.id===z);g("click-ui"),t[v].hasClickOrder?t[v].correctTexts[N].id===z?(k(N+1),Q(q,he)):t[v].correctTexts.find(Ke=>Ke.id===z)&&t[v].correctTexts[N].id!==z?(ee.forEach(Ke=>Ke.classList.remove("text-click__success")),k(0),C(0),P.current=0,J(!0,{result:!1,text:t[v].info.orderFeedback.desc||U("puzzles.incorrectOrder"),timeout:!1}),T(0)):K(q,ve):(le==null?void 0:le.id)===z?Q(q,he):((ce==null?void 0:ce.id)===z||z==="allWrong")&&K(q,ve)},[t,v,g,N,Q,J,U,K]),ue=React$2.useCallback(V=>getRecursiveJSX(V,0,t[v],ne),[v,t,ne]),fe=React$2.useCallback(()=>{let V=0;for(let z=0;z<t.length;z+=1)if(t[z].hasClickOnce)V+=1,_(V);else for(let q=0;q<t[z].correctTexts.length;q+=1)V+=1,_(V)},[t]);React$2.useEffect(()=>{var V;if(t!=null&&t[v]&&d({...t[v].info,description:o}),(V=t[v])!=null&&V.text){const z=HTMLReactParser$1(t[v].text);$.current=ue(z),fe()}else $.current=""},[v,o,fe,t,ue,d]);const te=()=>{for(let V=0;V<D.current.length;V=V+1)if(D.current[V].points>0)return!0;return!1};React$2.useEffect(()=>{f(()=>{l({type:"hidePuzzleButtons",payload:!0});const V=document.querySelectorAll(".text-click [data-text-id]"),z=t[v].correctTexts.map(ee=>ee.id);V.forEach(ee=>{z.includes(ee.getAttribute("data-text-id"))&&ee.classList.add("text-click__success")});const q=t[v].info.resolve.rewards;v+1<t.length?(setTimeout(()=>{l({type:"puzzleAction",action:"addPoints",payload:{element:R,rewards:q,finish:!1,payload:q}});let ee=0;t.forEach((le,ce)=>{ce<=v&&(ee+=le.correctTexts.length)}),C(ee),$.current=null,P.current=0,M(!0),T(v+1)},2e3),setTimeout(()=>{M(!1),l({type:"hidePuzzleButtons",payload:!1})},3200)):v+1>=t.length&&te()?setTimeout(()=>{q.forEach(ee=>{D.current.forEach(le=>{le.id===ee.id&&(ee.points=ee.points+le.points)})}),l({type:"puzzleAction",action:"resolve",payload:{element:R,rewards:q,finish:!0}})},2e3):setTimeout(()=>{l({type:"puzzleAction",action:"resolve",payload:{element:R,rewards:q,finish:v+1>=t.length}})},2e3)})},[f,l,t,v,R]);const H=React$2.useMemo(()=>{let V=`text-click text-click--${n}`;return p&&(V+=" disable-background-image"),V},[p,n]),W={pointerEvents:S.show?"none":null,backgroundImage:u!=null&&u.url?`url('${u.url}')`:""};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{"data-testid":"wrapperDiv",className:H,style:W,children:[jsxRuntimeExports.jsx("div",{className:"text-click__overlay",children:jsxRuntimeExports.jsx("div",{className:`text-click__container ${F?"slideInLeft":""} `,children:jsxRuntimeExports.jsx("div",{className:"text-click__body",children:jsxRuntimeExports.jsx("div",{className:"text-click__scroll",dir:LangIsRtl()?"rtl":"auto",children:$.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",{"data-testid":"slideCounter",className:"text-click__slide",children:[w," / ",b]})]})]}),S.show&&jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:g,success:S.result,text:S.text,translate:U,functionOnClose:ae,hasTimeout:S.timeout,keyboardControl:h})]})}function _assertThisInitialized(l){if(l===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return l}function _inheritsLoose(l,e){l.prototype=Object.create(e.prototype),l.prototype.constructor=l,l.__proto__=e}/*!
|
|
254
254
|
* GSAP 3.12.4
|
|
255
255
|
* https://gsap.com
|