@gamelearn/arcade-components 3.26.0 → 3.27.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,7 +63,7 @@ object-assign
63
63
  */var objectAssign,hasRequiredObjectAssign;function requireObjectAssign(){if(hasRequiredObjectAssign)return objectAssign;hasRequiredObjectAssign=1;var l=Object.getOwnPropertySymbols,e=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;function t(o){if(o==null)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(o)}function a(){try{if(!Object.assign)return!1;var o=new String("abc");if(o[5]="de",Object.getOwnPropertyNames(o)[0]==="5")return!1;for(var d={},h=0;h<10;h++)d["_"+String.fromCharCode(h)]=h;var f=Object.getOwnPropertyNames(d).map(function(p){return d[p]});if(f.join("")!=="0123456789")return!1;var u={};return"abcdefghijklmnopqrst".split("").forEach(function(p){u[p]=p}),Object.keys(Object.assign({},u)).join("")==="abcdefghijklmnopqrst"}catch{return!1}}return objectAssign=a()?Object.assign:function(o,d){for(var h,f=t(o),u,p=1;p<arguments.length;p++){h=Object(arguments[p]);for(var E in h)e.call(h,E)&&(f[E]=h[E]);if(l){u=l(h);for(var T=0;T<u.length;T++)n.call(h,u[T])&&(f[u[T]]=h[u[T]])}}return f},objectAssign}var ReactPropTypesSecret_1,hasRequiredReactPropTypesSecret;function requireReactPropTypesSecret(){if(hasRequiredReactPropTypesSecret)return ReactPropTypesSecret_1;hasRequiredReactPropTypesSecret=1;var l="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return ReactPropTypesSecret_1=l,ReactPropTypesSecret_1}var checkPropTypes_1,hasRequiredCheckPropTypes;function requireCheckPropTypes(){if(hasRequiredCheckPropTypes)return checkPropTypes_1;hasRequiredCheckPropTypes=1;var l=function(){};if(process.env.NODE_ENV!=="production"){var e=requireReactPropTypesSecret(),n={},t=Function.call.bind(Object.prototype.hasOwnProperty);l=function(o){var d="Warning: "+o;typeof console<"u"&&console.error(d);try{throw new Error(d)}catch{}}}function a(o,d,h,f,u){if(process.env.NODE_ENV!=="production"){for(var p in o)if(t(o,p)){var E;try{if(typeof o[p]!="function"){var T=Error((f||"React class")+": "+h+" type `"+p+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof o[p]+"`.");throw T.name="Invariant Violation",T}E=o[p](d,p,f,h,null,e)}catch(S){E=S}if(E&&!(E instanceof Error)&&l((f||"React class")+": type specification of "+h+" `"+p+"` is invalid; the type checker function must return `null` or an `Error` but returned a "+typeof E+". You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument)."),E instanceof Error&&!(E.message in n)){n[E.message]=!0;var v=u?u():"";l("Failed "+h+" type: "+E.message+(v??""))}}}}return a.resetWarningCache=function(){process.env.NODE_ENV!=="production"&&(n={})},checkPropTypes_1=a,checkPropTypes_1}var factoryWithTypeCheckers,hasRequiredFactoryWithTypeCheckers;function requireFactoryWithTypeCheckers(){if(hasRequiredFactoryWithTypeCheckers)return factoryWithTypeCheckers;hasRequiredFactoryWithTypeCheckers=1;var l=requireReactIs(),e=requireObjectAssign(),n=requireReactPropTypesSecret(),t=requireCheckPropTypes(),a=Function.call.bind(Object.prototype.hasOwnProperty),o=function(){};process.env.NODE_ENV!=="production"&&(o=function(h){var f="Warning: "+h;typeof console<"u"&&console.error(f);try{throw new Error(f)}catch{}});function d(){return null}return factoryWithTypeCheckers=function(h,f){var u=typeof Symbol=="function"&&Symbol.iterator,p="@@iterator";function E(K){var ne=K&&(u&&K[u]||K[p]);if(typeof ne=="function")return ne}var T="<<anonymous>>",v={array:b("array"),bool:b("boolean"),func:b("function"),number:b("number"),object:b("object"),string:b("string"),symbol:b("symbol"),any:R(),arrayOf:_,element:w(),elementType:C(),instanceOf:N,node:F(),objectOf:D,oneOf:P,oneOfType:k,shape:M,exact:I};function S(K,ne){return K===ne?K!==0||1/K===1/ne:K!==K&&ne!==ne}function g(K){this.message=K,this.stack=""}g.prototype=Error.prototype;function y(K){if(process.env.NODE_ENV!=="production")var ne={},ue=0;function pe(H,W,V,B,Y,re,le){if(B=B||T,re=re||V,le!==n){if(f){var fe=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types");throw fe.name="Invariant Violation",fe}else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var de=B+":"+V;!ne[de]&&ue<3&&(o("You are manually calling a React.PropTypes validation function for the `"+re+"` prop on `"+B+"`. This is deprecated and will throw in the standalone `prop-types` package. You may be seeing this warning due to a third-party PropTypes library. See https://fb.me/react-warning-dont-call-proptypes for details."),ne[de]=!0,ue++)}}return W[V]==null?H?W[V]===null?new g("The "+Y+" `"+re+"` is marked as required "+("in `"+B+"`, but its value is `null`.")):new g("The "+Y+" `"+re+"` is marked as required in "+("`"+B+"`, but its value is `undefined`.")):null:K(W,V,B,Y,re)}var J=pe.bind(null,!1);return J.isRequired=pe.bind(null,!0),J}function b(K){function ne(ue,pe,J,H,W,V){var B=ue[pe],Y=X(B);if(Y!==K){var re=te(B);return new g("Invalid "+H+" `"+W+"` of type "+("`"+re+"` supplied to `"+J+"`, expected ")+("`"+K+"`."))}return null}return y(ne)}function R(){return y(d)}function _(K){function ne(ue,pe,J,H,W){if(typeof K!="function")return new g("Property `"+W+"` of component `"+J+"` has invalid PropType notation inside arrayOf.");var V=ue[pe];if(!Array.isArray(V)){var B=X(V);return new g("Invalid "+H+" `"+W+"` of type "+("`"+B+"` supplied to `"+J+"`, expected an array."))}for(var Y=0;Y<V.length;Y++){var re=K(V,Y,J,H,W+"["+Y+"]",n);if(re instanceof Error)return re}return null}return y(ne)}function w(){function K(ne,ue,pe,J,H){var W=ne[ue];if(!h(W)){var V=X(W);return new g("Invalid "+J+" `"+H+"` of type "+("`"+V+"` supplied to `"+pe+"`, expected a single ReactElement."))}return null}return y(K)}function C(){function K(ne,ue,pe,J,H){var W=ne[ue];if(!l.isValidElementType(W)){var V=X(W);return new g("Invalid "+J+" `"+H+"` of type "+("`"+V+"` supplied to `"+pe+"`, expected a single ReactElement type."))}return null}return y(K)}function N(K){function ne(ue,pe,J,H,W){if(!(ue[pe]instanceof K)){var V=K.name||T,B=ee(ue[pe]);return new g("Invalid "+H+" `"+W+"` of type "+("`"+B+"` supplied to `"+J+"`, expected ")+("instance of `"+V+"`."))}return null}return y(ne)}function P(K){if(!Array.isArray(K))return process.env.NODE_ENV!=="production"&&(arguments.length>1?o("Invalid arguments supplied to oneOf, expected an array, got "+arguments.length+" arguments. A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z])."):o("Invalid argument supplied to oneOf, expected an array.")),d;function ne(ue,pe,J,H,W){for(var V=ue[pe],B=0;B<K.length;B++)if(S(V,K[B]))return null;var Y=JSON.stringify(K,function(le,fe){var de=te(fe);return de==="symbol"?String(fe):fe});return new g("Invalid "+H+" `"+W+"` of value `"+String(V)+"` "+("supplied to `"+J+"`, expected one of "+Y+"."))}return y(ne)}function D(K){function ne(ue,pe,J,H,W){if(typeof K!="function")return new g("Property `"+W+"` of component `"+J+"` has invalid PropType notation inside objectOf.");var V=ue[pe],B=X(V);if(B!=="object")return new g("Invalid "+H+" `"+W+"` of type "+("`"+B+"` supplied to `"+J+"`, expected an object."));for(var Y in V)if(a(V,Y)){var re=K(V,Y,J,H,W+"."+Y,n);if(re instanceof Error)return re}return null}return y(ne)}function k(K){if(!Array.isArray(K))return process.env.NODE_ENV!=="production"&&o("Invalid argument supplied to oneOfType, expected an instance of array."),d;for(var ne=0;ne<K.length;ne++){var ue=K[ne];if(typeof ue!="function")return o("Invalid argument supplied to oneOfType. Expected an array of check functions, but received "+ae(ue)+" at index "+ne+"."),d}function pe(J,H,W,V,B){for(var Y=0;Y<K.length;Y++){var re=K[Y];if(re(J,H,W,V,B,n)==null)return null}return new g("Invalid "+V+" `"+B+"` supplied to "+("`"+W+"`."))}return y(pe)}function F(){function K(ne,ue,pe,J,H){return $(ne[ue])?null:new g("Invalid "+J+" `"+H+"` supplied to "+("`"+pe+"`, expected a ReactNode."))}return y(K)}function M(K){function ne(ue,pe,J,H,W){var V=ue[pe],B=X(V);if(B!=="object")return new g("Invalid "+H+" `"+W+"` of type `"+B+"` "+("supplied to `"+J+"`, expected `object`."));for(var Y in K){var re=K[Y];if(re){var le=re(V,Y,J,H,W+"."+Y,n);if(le)return le}}return null}return y(ne)}function I(K){function ne(ue,pe,J,H,W){var V=ue[pe],B=X(V);if(B!=="object")return new g("Invalid "+H+" `"+W+"` of type `"+B+"` "+("supplied to `"+J+"`, expected `object`."));var Y=e({},ue[pe],K);for(var re in Y){var le=K[re];if(!le)return new g("Invalid "+H+" `"+W+"` key `"+re+"` supplied to `"+J+"`.\nBad object: "+JSON.stringify(ue[pe],null," ")+`
64
64
  Valid keys: `+JSON.stringify(Object.keys(K),null," "));var fe=le(V,re,J,H,W+"."+re,n);if(fe)return fe}return null}return y(ne)}function $(K){switch(typeof K){case"number":case"string":case"undefined":return!0;case"boolean":return!K;case"object":if(Array.isArray(K))return K.every($);if(K===null||h(K))return!0;var ne=E(K);if(ne){var ue=ne.call(K),pe;if(ne!==K.entries){for(;!(pe=ue.next()).done;)if(!$(pe.value))return!1}else for(;!(pe=ue.next()).done;){var J=pe.value;if(J&&!$(J[1]))return!1}}else return!1;return!0;default:return!1}}function z(K,ne){return K==="symbol"?!0:ne?ne["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&ne instanceof Symbol:!1}function X(K){var ne=typeof K;return Array.isArray(K)?"array":K instanceof RegExp?"object":z(ne,K)?"symbol":ne}function te(K){if(typeof K>"u"||K===null)return""+K;var ne=X(K);if(ne==="object"){if(K instanceof Date)return"date";if(K instanceof RegExp)return"regexp"}return ne}function ae(K){var ne=te(K);switch(ne){case"array":case"object":return"an "+ne;case"boolean":case"date":case"regexp":return"a "+ne;default:return ne}}function ee(K){return!K.constructor||!K.constructor.name?T:K.constructor.name}return v.checkPropTypes=t,v.resetWarningCache=t.resetWarningCache,v.PropTypes=v,v},factoryWithTypeCheckers}var factoryWithThrowingShims,hasRequiredFactoryWithThrowingShims;function requireFactoryWithThrowingShims(){if(hasRequiredFactoryWithThrowingShims)return factoryWithThrowingShims;hasRequiredFactoryWithThrowingShims=1;var l=requireReactPropTypesSecret();function e(){}function n(){}return n.resetWarningCache=e,factoryWithThrowingShims=function(){function t(d,h,f,u,p,E){if(E!==l){var T=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw T.name="Invariant Violation",T}}t.isRequired=t;function a(){return t}var o={array:t,bool:t,func:t,number:t,object:t,string:t,symbol:t,any:t,arrayOf:a,element:t,elementType:t,instanceOf:a,node:t,objectOf:a,oneOf:a,oneOfType:a,shape:a,exact:a,checkPropTypes:n,resetWarningCache:e};return o.PropTypes=o,o},factoryWithThrowingShims}if(process.env.NODE_ENV!=="production"){var ReactIs=requireReactIs(),throwOnDirectAccess=!0;propTypes.exports=requireFactoryWithTypeCheckers()(ReactIs.isElement,throwOnDirectAccess)}else propTypes.exports=requireFactoryWithThrowingShims()();var propTypesExports=propTypes.exports;const PropTypes=getDefaultExportFromCjs(propTypesExports);function BufferBar({time:l,setTimePoint:e,mandatory:n,mandatoryHasBeenViewed:t,viewed:a}){const o=Math.trunc(l.current*1e3/l.duration)/10,d=React$2.useRef(),[h,f]=React$2.useState(!1),u=Math.trunc(l.current/60)<10?["0",Math.trunc(l.current/60)].join("").trim():Math.trunc(l.current/60),p=Math.trunc(l.current%60)<10?["0",Math.trunc(l.current%60)].join("").trim():Math.trunc(l.current%60),E=(g,y)=>{f(!0);let b=g.offsetX;g.changedTouches&&(b=g.changedTouches[0].clientX);const R=y.offsetWidth+y.offsetLeft;b<=R&&b>=y.offsetLeft&&e(b,y.offsetWidth,y.offsetLeft)},T=()=>{window.onmousemove=null,window.onmouseup=null,f(!1)},v=g=>{window.onmousemove=y=>E(y,g),window.onmouseup=y=>T()},S=(g,y)=>{(!n||n&&t||a)&&(g.preventDefault(),e(g.clientX,y.offsetWidth,y.offsetLeft),v(y),f(!0))};return jsxRuntimeExports.jsx("div",{id:"buffer",ref:d,className:"video--controls__bar",onMouseDown:g=>{const y=d.current;S(g,y)},onTouchMove:g=>{const y=d.current;E(g,y)},onTouchStart:g=>{const y=d.current;f(!0),e(g.changedTouches[0].clientX,y.offsetWidth,y.offsetLeft)},children:jsxRuntimeExports.jsx("div",{className:"video--controls__progress",style:{width:`${o}%`},children:jsxRuntimeExports.jsx("span",{className:h?"video--controls__handle active":"video--controls__handle",children:h?jsxRuntimeExports.jsxs("div",{className:"video--current__time active",children:[u,":",p]}):null})})})}BufferBar.defaultProps={time:{current:0,duration:0},setTimePoint:()=>{}};BufferBar.propTypes={time:PropTypes.shape({current:PropTypes.number,duration:PropTypes.number}),setTimePoint:PropTypes.func};function Timer({time:l}){const e=Math.trunc(l.current/60)<10?["0",Math.trunc(l.current/60)].join("").trim():Math.trunc(l.current/60),n=Math.trunc(l.current%60)<10?["0",Math.trunc(l.current%60)].join("").trim():Math.trunc(l.current%60),t=Math.trunc(l.duration/60)<10?["0",Math.trunc(l.duration/60)].join("").trim():Math.trunc(l.duration/60),a=Math.trunc(l.duration%60)<10?["0",Math.trunc(l.duration%60)].join("").trim():Math.trunc(l.duration%60);return jsxRuntimeExports.jsxs("div",{className:"video--time",children:[jsxRuntimeExports.jsxs("span",{className:"time",children:[e,":",n]}),jsxRuntimeExports.jsxs("span",{className:"duration",children:[t,":",a]})]})}Timer.defaultProps={time:{current:0,duration:0}};Timer.propTypes={time:PropTypes.shape({current:PropTypes.number,duration:PropTypes.number})};function ControlButtons({pauseVideo:l,paused:e,translate:n}){return jsxRuntimeExports.jsx("div",{className:"video--controls__buttons",children:jsxRuntimeExports.jsx("button",{id:"playPause","aria-label":n(e?"storylines.misc.play":"storylines.misc.pause"),className:e?"unset-button icon-play":"unset-button icon-pause",type:"button",onClick:()=>{l(),document.querySelector("#playPause").blur()}})})}ControlButtons.defaultProps={paused:!1,pauseVideo:()=>{}};function FinishedVideoButtons({restart:l,translate:e}){return jsxRuntimeExports.jsx("div",{className:"video--extra__actions video--extra__actions--widthTransparencyLayer position--absolute z-index1",children:jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>{l()},className:"gat--btn gat--btn__secondary","aria-label":e("video.replay"),children:[jsxRuntimeExports.jsx("span",{className:"icon-rewind"}),jsxRuntimeExports.jsx("span",{id:"video.replay"})]})})}FinishedVideoButtons.defaultProps={restart:()=>{},finished:!1};function PlayInitButton({play:l,finished:e,paused:n}){return e||!n?jsxRuntimeExports.jsx("div",{}):jsxRuntimeExports.jsx("div",{className:"video--extra__actions position--absolute z-index1",children:jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,"aria-label":"play video",onKeyUp:()=>{},onClick:()=>{l()},className:"play--video__button",children:jsxRuntimeExports.jsx("span",{className:"icon-play-outline"})})})}PlayInitButton.defaultProps={play:()=>{},finished:!1,paused:!1};function skipButton({viewed:l,mandatory:e,finished:n,skip:t,mandatoryHasBeenViewed:a,translate:o}){return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:e&&l||!e||n||a?jsxRuntimeExports.jsx("div",{className:"position--absolute right top z-index2",children:jsxRuntimeExports.jsx("button",{className:"gat--btn__round gat--btn__close",type:"button","aria-label":o("storylines.misc.closePiece"),onKeyUp:()=>{},onClick:()=>{t()},children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})}):null})}skipButton.defaultProps={mandatory:!1,viewed:!1,finished:!1,skip:()=>{}};function VolumeBar({volume:l,muted:e,setVolume:n,mute:t}){const a=React$2.useRef(),o=e?0:Math.floor(l*100),d=(p,E)=>{const T=E.offsetWidth+E.offsetLeft;let v=p.clientX;p.changedTouches&&(v=p.changedTouches[0].clientX),v<=T&&v>=E.offsetLeft&&n(v,E.offsetWidth,E.offsetLeft)},h=()=>{window.onmousemove=null,window.onmouseup=null},f=p=>{window.onmousemove=E=>d(E,p),window.onmouseup=E=>h()},u=(p,E)=>{p.preventDefault(),n(p.clientX,E.offsetWidth,E.offsetLeft),f(E)};return jsxRuntimeExports.jsxs("div",{className:"video--sound",children:[jsxRuntimeExports.jsx("span",{onClick:()=>t(),className:o===0?"icon-sound-off":"icon-sound"}),jsxRuntimeExports.jsx("div",{ref:a,onMouseDown:p=>{const E=a.current;u(p,E)},onTouchMove:p=>{const E=a.current;d(p,E)},onTouchStart:p=>{const E=a.current;n(p.changedTouches[0].clientX,E.offsetWidth,E.offsetLeft)},id:"volume",className:"video--sound__level",children:jsxRuntimeExports.jsx("span",{style:{width:`${o<10?10:o}%`},className:"video--sound__progress",children:jsxRuntimeExports.jsx("span",{className:"video--handle"})})})]})}VolumeBar.defaultProps={volume:0,muted:!1,setVolume:()=>{},mute:()=>{}};VolumeBar.propTypes={volume:PropTypes.number,setVolume:PropTypes.func,mute:PropTypes.func,muted:PropTypes.bool};function VideoControllers({pause:l,mandatory:e,viewed:n,skip:t,rewind:a,paused:o,time:d,finished:h,restart:f,volume:u,muted:p,mute:E,setVolume:T,setTimePoint:v,audioAnimation:S,mandatoryHasBeenViewed:g,translate:y,visibility:b,withoutControls:R,documentType:_}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(skipButton,{mandatory:e,finished:h,viewed:n,skip:t,rewind:a,mandatoryHasBeenViewed:g,translate:y}),R?null:jsxRuntimeExports.jsxs("div",{className:`video--controls-wrap ${b?"video--controls-wrap--hidden":""}`,children:[S?null:jsxRuntimeExports.jsx(PlayInitButton,{play:l,paused:o,finished:h}),h&&(_==="document"||_==="lesson")?jsxRuntimeExports.jsx(FinishedVideoButtons,{restart:f,translate:y}):null,jsxRuntimeExports.jsxs("div",{className:"video--controls",children:[jsxRuntimeExports.jsx(BufferBar,{mandatory:e,mandatoryHasBeenViewed:g,time:d,setTimePoint:v,finished:h,viewed:n}),jsxRuntimeExports.jsxs("div",{className:"video--controls__actions",children:[jsxRuntimeExports.jsx(Timer,{time:d}),S?jsxRuntimeExports.jsx("div",{className:"audio-animation-wrap",children:jsxRuntimeExports.jsx("div",{className:`audio-animation ${o?"audio-animation--notAnimate ":null}`})}):null,jsxRuntimeExports.jsx(ControlButtons,{paused:o,pauseVideo:l,translate:y}),jsxRuntimeExports.jsx(VolumeBar,{muted:p,mute:E,volume:u,setVolume:T})]})]})]})]})}VideoControllers.defaultProps={audioAnimation:!1,paused:!1,mandatory:!1,viewed:!1,volume:0,muted:!1,finished:!1,restart:()=>{},pause:()=>{},skip:()=>{},rewind:()=>{},setTimePoint:()=>{},setVolume:()=>{},mute:()=>{},time:{current:0,duration:0}};VideoControllers.propTypes={audioAnimation:PropTypes.bool,paused:PropTypes.bool,mandatory:PropTypes.bool,muted:PropTypes.bool,volume:PropTypes.number,viewed:PropTypes.bool,pause:PropTypes.func,finished:PropTypes.bool,restart:PropTypes.func,skip:PropTypes.func,rewind:PropTypes.func,mute:PropTypes.func,setTimePoint:PropTypes.func,setVolume:PropTypes.func,time:PropTypes.shape({current:PropTypes.number,duration:PropTypes.number})};const defaultBgImageForAudio="https://min.gamelearn.io/css-resources/gamelearn/resources/bgAudioPiece.jpg";function VideoVisor({documentType:l,url:e,required:n,viewed:t,backgroundImage:a,soundActions:o,endVideo:d,translate:h,autoPlay:f,withoutControls:u}){const[p,E]=React$2.useState(!1),[T]=o,[v,S]=React$2.useState(0),[g,y]=React$2.useState(0),[b,R]=React$2.useState(!1),[_,w]=React$2.useState(!0),[C,N]=React$2.useState(!1),[P,D]=React$2.useState(),[k,F]=React$2.useState(0),[M,I]=React$2.useState(!1),$=e&&e.match(/\.m3u8(\?.+=.+)*$/i)&&Hls.isSupported(),z=e&&(e.match(/youtube/i)||e.match(/vimeo/i)),X=e&&(e.match(/.mp3/i)||e.match(/.ogg/i)||e.match(/.wav/i)||e.match(/.m4a/i)),te={ref:de=>{D(de)},src:e,style:{height:"100%",width:"100%"}},ae=()=>{n&&E(!0),R(!1),P.pause(),w(!0),N(!0),I(!1),l!=="document"&&l!=="lesson"&&d()},ee=()=>{d()},K=()=>{w(!1),R(!1)},ne=()=>{R(!0)},ue=()=>{R(!1),S(P.duration)};React$2.useEffect(()=>{let de;if(P){if($){de=new Hls;const ge=`${e}?v=${Math.floor(Math.random()*99999999)}`;de.loadSource(ge),de.attachMedia(P),de.on(Hls.Events.FRAG_LOAD_PROGRESS,(Ee,Re)=>{const{stats:Oe}=Re;y(Oe.loaded*100/Oe.total)})}return()=>{de&&de.destroy(),de=null}}},[$,e,P]);const pe=()=>{P.currentTime-=15},J=()=>{T("click-ui"),_?(P.play(),N(!1)):P.pause(),w(!_)},H=(de,ge,Ee)=>{N(!1),P.currentTime=ge?parseFloat((de-Ee)/ge*P.duration):0},W=()=>{N(!1),P.currentTime=0,J()},V=()=>{T("click-ui"),P.muted=!P.muted},B=(de,ge,Ee)=>{P.muted=!1;const Re=de-Ee>=0?(de-Ee)/ge:0;P.volume=Re*100>10?Re:0,F(P.volume)};React$2.useEffect(()=>{let de;return!M&&!_&&(de=setTimeout(()=>{I(!0),clearTimeout(de)},3e3)),()=>clearTimeout(de)},[M,_]);const Y=()=>{M&&I(!1)},re=a||defaultBgImageForAudio,le=re===defaultBgImageForAudio?"cover":"contain",fe={backgroundImage:`url("${re}")`,backgroundSize:le,backgroundRepeat:"no-repeat",backgroundPosition:"center center"};return jsxRuntimeExports.jsx("div",{className:`video ${n&&!p&&!t?"forward-disabled":""}`,style:X?fe:null,children:z?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"position--absolute right top z-index2",children:jsxRuntimeExports.jsx("button",{type:"button","aria-label":h("storylines.misc.closePiece"),className:"gat--btn__round gat--btn__close",onClick:()=>{T("click-ui"),d()},children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})}),jsxRuntimeExports.jsx("iframe",{className:"embeddedVideo",title:"title",...te})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(VideoControllers,{documentType:l,visibility:M,mandatoryHasBeenViewed:p,audioAnimation:!!X,skip:d,mandatory:n,viewed:t,volume:P?P.volume:0,mute:V,muted:P?P.muted:!1,paused:_,finished:C,restart:W,setTimePoint:H,time:{duration:v,current:P?P.currentTime:0},rewind:pe,pause:J,volumeState:k,setVolume:B,translate:h,withoutControls:u}),jsxRuntimeExports.jsx("video",{"data-testid":"video-visor-video",autoPlay:f,onMouseMove:()=>Y(),onClick:()=>{Y()},onFocus:()=>{Y()},onCanPlayThrough:ue,onWaiting:ne,onEnded:ae,onError:ee,onPlaying:K,...te,children:jsxRuntimeExports.jsx("track",{kind:"captions"})}),b?jsxRuntimeExports.jsxs("div",{className:"video-loading-container",style:{top:0,left:0},children:[jsxRuntimeExports.jsx("div",{className:"video-loading-container-bg opacity-wrapper"}),jsxRuntimeExports.jsx("div",{className:"popup-alert warning",children:jsxRuntimeExports.jsx("div",{className:"popup-message",children:jsxRuntimeExports.jsx("p",{children:Math.floor(g)})})})]}):null]})})}VideoVisor.defaultProps={url:"",name:"",backgroundImage:null,documentType:"",required:!1,viewed:!1,endVideo:()=>{}};function VideoComponent({emitEvent:l,getEvent:e,name:n,documentType:t,document:a,documentId_labelId:o,soundActions:d,required:h,viewed:f,visible:u,img:p,imgId_labelId:E,withoutControls:T,autoPlay:v,keyboardControl:S}){const g=w=>e({type:"translate",payload:w}),{url:y}=a,b=React$2.useMemo(()=>({documentId:o,imgId:E,required:h,name:n,type:"video",viewed:f,documentType:t}),[o,E,h,n,f,t]),R=React$2.useCallback(()=>{l({type:"finishMedia",payload:b})},[l,b]);React$2.useEffect(()=>{u||R()},[R,u]);const _=S({disabled:f,forward:R,escape:R});return React$2.useEffect(()=>_(),[_]),u?jsxRuntimeExports.jsx(VideoVisor,{autoPlay:v,withoutControls:T,backgroundImage:p==null?void 0:p.url,url:y,soundActions:d,documentType:t,required:h,viewed:f,endVideo:()=>R(),translate:g}):null}function ChangeCamera({targetUid:l,emitEvent:e,success:n=!0,onFinish:t=()=>{},transition:a={type:"pan",speed:10}}){const{change:o}=arcadeThreeCore.CameraControls.useStore(),d=fiber.useThree(f=>f.camera),h=React$2.useRef();return React$2.useEffect(()=>{const f=()=>{e({type:"changeCamera",payload:{targetUid:l,transition:a}}),setTimeout(()=>{n&&e({type:"success"}),t()},200)};return d.addEventListener("transitionEnd",f),()=>{d.removeEventListener("transitionEnd",f)}},[d,e,t,n,l,a]),React$2.useEffect(()=>{o&&h.current!==l&&(o(l,a),h.current=l)},[o,l,a]),null}var htmlReactParser={exports:{}},lib$4={},possibleStandardNamesOptimized$1={},SAME$1=0;possibleStandardNamesOptimized$1.SAME=SAME$1;var CAMELCASE$1=1;possibleStandardNamesOptimized$1.CAMELCASE=CAMELCASE$1;possibleStandardNamesOptimized$1.possibleStandardNames={accept:0,acceptCharset:1,"accept-charset":"acceptCharset",accessKey:1,action:0,allowFullScreen:1,alt:0,as:0,async:0,autoCapitalize:1,autoComplete:1,autoCorrect:1,autoFocus:1,autoPlay:1,autoSave:1,capture:0,cellPadding:1,cellSpacing:1,challenge:0,charSet:1,checked:0,children:0,cite:0,class:"className",classID:1,className:1,cols:0,colSpan:1,content:0,contentEditable:1,contextMenu:1,controls:0,controlsList:1,coords:0,crossOrigin:1,dangerouslySetInnerHTML:1,data:0,dateTime:1,default:0,defaultChecked:1,defaultValue:1,defer:0,dir:0,disabled:0,disablePictureInPicture:1,disableRemotePlayback:1,download:0,draggable:0,encType:1,enterKeyHint:1,for:"htmlFor",form:0,formMethod:1,formAction:1,formEncType:1,formNoValidate:1,formTarget:1,frameBorder:1,headers:0,height:0,hidden:0,high:0,href:0,hrefLang:1,htmlFor:1,httpEquiv:1,"http-equiv":"httpEquiv",icon:0,id:0,innerHTML:1,inputMode:1,integrity:0,is:0,itemID:1,itemProp:1,itemRef:1,itemScope:1,itemType:1,keyParams:1,keyType:1,kind:0,label:0,lang:0,list:0,loop:0,low:0,manifest:0,marginWidth:1,marginHeight:1,max:0,maxLength:1,media:0,mediaGroup:1,method:0,min:0,minLength:1,multiple:0,muted:0,name:0,noModule:1,nonce:0,noValidate:1,open:0,optimum:0,pattern:0,placeholder:0,playsInline:1,poster:0,preload:0,profile:0,radioGroup:1,readOnly:1,referrerPolicy:1,rel:0,required:0,reversed:0,role:0,rows:0,rowSpan:1,sandbox:0,scope:0,scoped:0,scrolling:0,seamless:0,selected:0,shape:0,size:0,sizes:0,span:0,spellCheck:1,src:0,srcDoc:1,srcLang:1,srcSet:1,start:0,step:0,style:0,summary:0,tabIndex:1,target:0,title:0,type:0,useMap:1,value:0,width:0,wmode:0,wrap:0,about:0,accentHeight:1,"accent-height":"accentHeight",accumulate:0,additive:0,alignmentBaseline:1,"alignment-baseline":"alignmentBaseline",allowReorder:1,alphabetic:0,amplitude:0,arabicForm:1,"arabic-form":"arabicForm",ascent:0,attributeName:1,attributeType:1,autoReverse:1,azimuth:0,baseFrequency:1,baselineShift:1,"baseline-shift":"baselineShift",baseProfile:1,bbox:0,begin:0,bias:0,by:0,calcMode:1,capHeight:1,"cap-height":"capHeight",clip:0,clipPath:1,"clip-path":"clipPath",clipPathUnits:1,clipRule:1,"clip-rule":"clipRule",color:0,colorInterpolation:1,"color-interpolation":"colorInterpolation",colorInterpolationFilters:1,"color-interpolation-filters":"colorInterpolationFilters",colorProfile:1,"color-profile":"colorProfile",colorRendering:1,"color-rendering":"colorRendering",contentScriptType:1,contentStyleType:1,cursor:0,cx:0,cy:0,d:0,datatype:0,decelerate:0,descent:0,diffuseConstant:1,direction:0,display:0,divisor:0,dominantBaseline:1,"dominant-baseline":"dominantBaseline",dur:0,dx:0,dy:0,edgeMode:1,elevation:0,enableBackground:1,"enable-background":"enableBackground",end:0,exponent:0,externalResourcesRequired:1,fill:0,fillOpacity:1,"fill-opacity":"fillOpacity",fillRule:1,"fill-rule":"fillRule",filter:0,filterRes:1,filterUnits:1,floodOpacity:1,"flood-opacity":"floodOpacity",floodColor:1,"flood-color":"floodColor",focusable:0,fontFamily:1,"font-family":"fontFamily",fontSize:1,"font-size":"fontSize",fontSizeAdjust:1,"font-size-adjust":"fontSizeAdjust",fontStretch:1,"font-stretch":"fontStretch",fontStyle:1,"font-style":"fontStyle",fontVariant:1,"font-variant":"fontVariant",fontWeight:1,"font-weight":"fontWeight",format:0,from:0,fx:0,fy:0,g1:0,g2:0,glyphName:1,"glyph-name":"glyphName",glyphOrientationHorizontal:1,"glyph-orientation-horizontal":"glyphOrientationHorizontal",glyphOrientationVertical:1,"glyph-orientation-vertical":"glyphOrientationVertical",glyphRef:1,gradientTransform:1,gradientUnits:1,hanging:0,horizAdvX:1,"horiz-adv-x":"horizAdvX",horizOriginX:1,"horiz-origin-x":"horizOriginX",ideographic:0,imageRendering:1,"image-rendering":"imageRendering",in2:0,in:0,inlist:0,intercept:0,k1:0,k2:0,k3:0,k4:0,k:0,kernelMatrix:1,kernelUnitLength:1,kerning:0,keyPoints:1,keySplines:1,keyTimes:1,lengthAdjust:1,letterSpacing:1,"letter-spacing":"letterSpacing",lightingColor:1,"lighting-color":"lightingColor",limitingConeAngle:1,local:0,markerEnd:1,"marker-end":"markerEnd",markerHeight:1,markerMid:1,"marker-mid":"markerMid",markerStart:1,"marker-start":"markerStart",markerUnits:1,markerWidth:1,mask:0,maskContentUnits:1,maskUnits:1,mathematical:0,mode:0,numOctaves:1,offset:0,opacity:0,operator:0,order:0,orient:0,orientation:0,origin:0,overflow:0,overlinePosition:1,"overline-position":"overlinePosition",overlineThickness:1,"overline-thickness":"overlineThickness",paintOrder:1,"paint-order":"paintOrder",panose1:0,"panose-1":"panose1",pathLength:1,patternContentUnits:1,patternTransform:1,patternUnits:1,pointerEvents:1,"pointer-events":"pointerEvents",points:0,pointsAtX:1,pointsAtY:1,pointsAtZ:1,prefix:0,preserveAlpha:1,preserveAspectRatio:1,primitiveUnits:1,property:0,r:0,radius:0,refX:1,refY:1,renderingIntent:1,"rendering-intent":"renderingIntent",repeatCount:1,repeatDur:1,requiredExtensions:1,requiredFeatures:1,resource:0,restart:0,result:0,results:0,rotate:0,rx:0,ry:0,scale:0,security:0,seed:0,shapeRendering:1,"shape-rendering":"shapeRendering",slope:0,spacing:0,specularConstant:1,specularExponent:1,speed:0,spreadMethod:1,startOffset:1,stdDeviation:1,stemh:0,stemv:0,stitchTiles:1,stopColor:1,"stop-color":"stopColor",stopOpacity:1,"stop-opacity":"stopOpacity",strikethroughPosition:1,"strikethrough-position":"strikethroughPosition",strikethroughThickness:1,"strikethrough-thickness":"strikethroughThickness",string:0,stroke:0,strokeDasharray:1,"stroke-dasharray":"strokeDasharray",strokeDashoffset:1,"stroke-dashoffset":"strokeDashoffset",strokeLinecap:1,"stroke-linecap":"strokeLinecap",strokeLinejoin:1,"stroke-linejoin":"strokeLinejoin",strokeMiterlimit:1,"stroke-miterlimit":"strokeMiterlimit",strokeWidth:1,"stroke-width":"strokeWidth",strokeOpacity:1,"stroke-opacity":"strokeOpacity",suppressContentEditableWarning:1,suppressHydrationWarning:1,surfaceScale:1,systemLanguage:1,tableValues:1,targetX:1,targetY:1,textAnchor:1,"text-anchor":"textAnchor",textDecoration:1,"text-decoration":"textDecoration",textLength:1,textRendering:1,"text-rendering":"textRendering",to:0,transform:0,typeof:0,u1:0,u2:0,underlinePosition:1,"underline-position":"underlinePosition",underlineThickness:1,"underline-thickness":"underlineThickness",unicode:0,unicodeBidi:1,"unicode-bidi":"unicodeBidi",unicodeRange:1,"unicode-range":"unicodeRange",unitsPerEm:1,"units-per-em":"unitsPerEm",unselectable:0,vAlphabetic:1,"v-alphabetic":"vAlphabetic",values:0,vectorEffect:1,"vector-effect":"vectorEffect",version:0,vertAdvY:1,"vert-adv-y":"vertAdvY",vertOriginX:1,"vert-origin-x":"vertOriginX",vertOriginY:1,"vert-origin-y":"vertOriginY",vHanging:1,"v-hanging":"vHanging",vIdeographic:1,"v-ideographic":"vIdeographic",viewBox:1,viewTarget:1,visibility:0,vMathematical:1,"v-mathematical":"vMathematical",vocab:0,widths:0,wordSpacing:1,"word-spacing":"wordSpacing",writingMode:1,"writing-mode":"writingMode",x1:0,x2:0,x:0,xChannelSelector:1,xHeight:1,"x-height":"xHeight",xlinkActuate:1,"xlink:actuate":"xlinkActuate",xlinkArcrole:1,"xlink:arcrole":"xlinkArcrole",xlinkHref:1,"xlink:href":"xlinkHref",xlinkRole:1,"xlink:role":"xlinkRole",xlinkShow:1,"xlink:show":"xlinkShow",xlinkTitle:1,"xlink:title":"xlinkTitle",xlinkType:1,"xlink:type":"xlinkType",xmlBase:1,"xml:base":"xmlBase",xmlLang:1,"xml:lang":"xmlLang",xmlns:0,"xml:space":"xmlSpace",xmlnsXlink:1,"xmlns:xlink":"xmlnsXlink",xmlSpace:1,y1:0,y2:0,y:0,yChannelSelector:1,z:0,zoomAndPan:1};Object.defineProperty(lib$4,"__esModule",{value:!0});function _slicedToArray(l,e){return _arrayWithHoles(l)||_iterableToArrayLimit(l,e)||_unsupportedIterableToArray(l,e)||_nonIterableRest()}function _arrayWithHoles(l){if(Array.isArray(l))return l}function _iterableToArrayLimit(l,e){var n=l==null?null:typeof Symbol<"u"&&l[Symbol.iterator]||l["@@iterator"];if(n!=null){var t=[],a=!0,o=!1,d,h;try{for(n=n.call(l);!(a=(d=n.next()).done)&&(t.push(d.value),!(e&&t.length===e));a=!0);}catch(f){o=!0,h=f}finally{try{!a&&n.return!=null&&n.return()}finally{if(o)throw h}}return t}}function _unsupportedIterableToArray(l,e){if(l){if(typeof l=="string")return _arrayLikeToArray(l,e);var n=Object.prototype.toString.call(l).slice(8,-1);if(n==="Object"&&l.constructor&&(n=l.constructor.name),n==="Map"||n==="Set")return Array.from(l);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(l,e)}}function _arrayLikeToArray(l,e){(e==null||e>l.length)&&(e=l.length);for(var n=0,t=new Array(e);n<e;n++)t[n]=l[n];return t}function _nonIterableRest(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
65
65
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var RESERVED=0,STRING=1,BOOLEANISH_STRING=2,BOOLEAN=3,OVERLOADED_BOOLEAN=4,NUMERIC=5,POSITIVE_NUMERIC=6;function getPropertyInfo(l){return properties.hasOwnProperty(l)?properties[l]:null}function PropertyInfoRecord(l,e,n,t,a,o,d){this.acceptsBooleans=e===BOOLEANISH_STRING||e===BOOLEAN||e===OVERLOADED_BOOLEAN,this.attributeName=t,this.attributeNamespace=a,this.mustUseProperty=n,this.propertyName=l,this.type=e,this.sanitizeURL=o,this.removeEmptyString=d}var properties={},reservedProps=["children","dangerouslySetInnerHTML","defaultValue","defaultChecked","innerHTML","suppressContentEditableWarning","suppressHydrationWarning","style"];reservedProps.forEach(function(l){properties[l]=new PropertyInfoRecord(l,RESERVED,!1,l,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var e=_slicedToArray(l,2),n=e[0],t=e[1];properties[n]=new PropertyInfoRecord(n,STRING,!1,t,null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,BOOLEANISH_STRING,!1,l.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,BOOLEANISH_STRING,!1,l,null,!1,!1)});["allowFullScreen","async","autoFocus","autoPlay","controls","default","defer","disabled","disablePictureInPicture","disableRemotePlayback","formNoValidate","hidden","loop","noModule","noValidate","open","playsInline","readOnly","required","reversed","scoped","seamless","itemScope"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,BOOLEAN,!1,l.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,BOOLEAN,!0,l,null,!1,!1)});["capture","download"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,OVERLOADED_BOOLEAN,!1,l,null,!1,!1)});["cols","rows","size","span"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,POSITIVE_NUMERIC,!1,l,null,!1,!1)});["rowSpan","start"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,NUMERIC,!1,l.toLowerCase(),null,!1,!1)});var CAMELIZE=/[\-\:]([a-z])/g,capitalize$1=function l(e){return e[1].toUpperCase()};["accent-height","alignment-baseline","arabic-form","baseline-shift","cap-height","clip-path","clip-rule","color-interpolation","color-interpolation-filters","color-profile","color-rendering","dominant-baseline","enable-background","fill-opacity","fill-rule","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","glyph-name","glyph-orientation-horizontal","glyph-orientation-vertical","horiz-adv-x","horiz-origin-x","image-rendering","letter-spacing","lighting-color","marker-end","marker-mid","marker-start","overline-position","overline-thickness","paint-order","panose-1","pointer-events","rendering-intent","shape-rendering","stop-color","stop-opacity","strikethrough-position","strikethrough-thickness","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-anchor","text-decoration","text-rendering","underline-position","underline-thickness","unicode-bidi","unicode-range","units-per-em","v-alphabetic","v-hanging","v-ideographic","v-mathematical","vector-effect","vert-adv-y","vert-origin-x","vert-origin-y","word-spacing","writing-mode","xmlns:xlink","x-height"].forEach(function(l){var e=l.replace(CAMELIZE,capitalize$1);properties[e]=new PropertyInfoRecord(e,STRING,!1,l,null,!1,!1)});["xlink:actuate","xlink:arcrole","xlink:role","xlink:show","xlink:title","xlink:type"].forEach(function(l){var e=l.replace(CAMELIZE,capitalize$1);properties[e]=new PropertyInfoRecord(e,STRING,!1,l,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(l){var e=l.replace(CAMELIZE,capitalize$1);properties[e]=new PropertyInfoRecord(e,STRING,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,STRING,!1,l.toLowerCase(),null,!1,!1)});var xlinkHref="xlinkHref";properties[xlinkHref]=new PropertyInfoRecord("xlinkHref",STRING,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(l){properties[l]=new PropertyInfoRecord(l,STRING,!1,l.toLowerCase(),null,!0,!0)});var _require=possibleStandardNamesOptimized$1,CAMELCASE=_require.CAMELCASE,SAME=_require.SAME,possibleStandardNamesOptimized=_require.possibleStandardNames,ATTRIBUTE_NAME_START_CHAR=":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",ATTRIBUTE_NAME_CHAR=ATTRIBUTE_NAME_START_CHAR+"\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040",isCustomAttribute=RegExp.prototype.test.bind(new RegExp("^(data|aria)-["+ATTRIBUTE_NAME_CHAR+"]*$")),possibleStandardNames=Object.keys(possibleStandardNamesOptimized).reduce(function(l,e){var n=possibleStandardNamesOptimized[e];return n===SAME?l[e]=e:n===CAMELCASE?l[e.toLowerCase()]=e:l[e]=n,l},{});lib$4.BOOLEAN=BOOLEAN;lib$4.BOOLEANISH_STRING=BOOLEANISH_STRING;lib$4.NUMERIC=NUMERIC;lib$4.OVERLOADED_BOOLEAN=OVERLOADED_BOOLEAN;lib$4.POSITIVE_NUMERIC=POSITIVE_NUMERIC;lib$4.RESERVED=RESERVED;lib$4.STRING=STRING;lib$4.getPropertyInfo=getPropertyInfo;lib$4.isCustomAttribute=isCustomAttribute;lib$4.possibleStandardNames=possibleStandardNames;var cjs={},COMMENT_REGEX=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,NEWLINE_REGEX=/\n/g,WHITESPACE_REGEX=/^\s*/,PROPERTY_REGEX=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,COLON_REGEX=/^:\s*/,VALUE_REGEX=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,SEMICOLON_REGEX=/^[;\s]*/,TRIM_REGEX=/^\s+|\s+$/g,NEWLINE=`
66
- `,FORWARD_SLASH="/",ASTERISK="*",EMPTY_STRING$1="",TYPE_COMMENT="comment",TYPE_DECLARATION="declaration",inlineStyleParser=function(l,e){if(typeof l!="string")throw new TypeError("First argument must be a string");if(!l)return[];e=e||{};var n=1,t=1;function a(S){var g=S.match(NEWLINE_REGEX);g&&(n+=g.length);var y=S.lastIndexOf(NEWLINE);t=~y?S.length-y:t+S.length}function o(){var S={line:n,column:t};return function(g){return g.position=new d(S),u(),g}}function d(S){this.start=S,this.end={line:n,column:t},this.source=e.source}d.prototype.content=l;function h(S){var g=new Error(e.source+":"+n+":"+t+": "+S);if(g.reason=S,g.filename=e.source,g.line=n,g.column=t,g.source=l,!e.silent)throw g}function f(S){var g=S.exec(l);if(g){var y=g[0];return a(y),l=l.slice(y.length),g}}function u(){f(WHITESPACE_REGEX)}function p(S){var g;for(S=S||[];g=E();)g!==!1&&S.push(g);return S}function E(){var S=o();if(!(FORWARD_SLASH!=l.charAt(0)||ASTERISK!=l.charAt(1))){for(var g=2;EMPTY_STRING$1!=l.charAt(g)&&(ASTERISK!=l.charAt(g)||FORWARD_SLASH!=l.charAt(g+1));)++g;if(g+=2,EMPTY_STRING$1===l.charAt(g-1))return h("End of comment missing");var y=l.slice(2,g-2);return t+=2,a(y),l=l.slice(g),t+=2,S({type:TYPE_COMMENT,comment:y})}}function T(){var S=o(),g=f(PROPERTY_REGEX);if(g){if(E(),!f(COLON_REGEX))return h("property missing ':'");var y=f(VALUE_REGEX),b=S({type:TYPE_DECLARATION,property:trim(g[0].replace(COMMENT_REGEX,EMPTY_STRING$1)),value:y?trim(y[0].replace(COMMENT_REGEX,EMPTY_STRING$1)):EMPTY_STRING$1});return f(SEMICOLON_REGEX),b}}function v(){var S=[];p(S);for(var g;g=T();)g!==!1&&(S.push(g),p(S));return S}return u(),v()};function trim(l){return l?l.replace(TRIM_REGEX,EMPTY_STRING$1):EMPTY_STRING$1}var parse=inlineStyleParser;function StyleToObject(l,e){var n=null;if(!l||typeof l!="string")return n;for(var t,a=parse(l),o=typeof e=="function",d,h,f=0,u=a.length;f<u;f++)t=a[f],d=t.property,h=t.value,o?e(d,h,t):h&&(n||(n={}),n[d]=h);return n}var styleToObject=StyleToObject,utilities$4={};utilities$4.__esModule=!0;utilities$4.camelCase=void 0;var CUSTOM_PROPERTY_REGEX=/^--[a-zA-Z0-9-]+$/,HYPHEN_REGEX=/-([a-z])/g,NO_HYPHEN_REGEX=/^[^-]+$/,VENDOR_PREFIX_REGEX=/^-(webkit|moz|ms|o|khtml)-/,MS_VENDOR_PREFIX_REGEX=/^-(ms)-/,skipCamelCase=function(l){return!l||NO_HYPHEN_REGEX.test(l)||CUSTOM_PROPERTY_REGEX.test(l)},capitalize=function(l,e){return e.toUpperCase()},trimHyphen=function(l,e){return"".concat(e,"-")},camelCase=function(l,e){return e===void 0&&(e={}),skipCamelCase(l)?l:(l=l.toLowerCase(),e.reactCompat?l=l.replace(MS_VENDOR_PREFIX_REGEX,trimHyphen):l=l.replace(VENDOR_PREFIX_REGEX,trimHyphen),l.replace(HYPHEN_REGEX,capitalize))};utilities$4.camelCase=camelCase;(function(l){var e=commonjsGlobal&&commonjsGlobal.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};l.__esModule=!0;var n=e(styleToObject),t=utilities$4;function a(o,d){var h={};return!o||typeof o!="string"||(0,n.default)(o,function(f,u){f&&u&&(h[(0,t.camelCase)(f,d)]=u)}),h}l.default=a})(cjs);var React$1=React$2,styleToJS=cjs.default;function invertObject(l,e){if(!l||typeof l!="object")throw new TypeError("First argument must be an object");var n,t,a=typeof e=="function",o={},d={};for(n in l){if(t=l[n],a&&(o=e(n,t),o&&o.length===2)){d[o[0]]=o[1];continue}typeof t=="string"&&(d[t]=n)}return d}function isCustomComponent(l,e){if(l.indexOf("-")===-1)return e&&typeof e.is=="string";switch(l){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var styleToJSOptions={reactCompat:!0};function setStyleProp$1(l,e){if(l!=null)try{e.style=styleToJS(l,styleToJSOptions)}catch{e.style={}}}var PRESERVE_CUSTOM_ATTRIBUTES=React$1.version.split(".")[0]>=16,elementsWithNoTextChildren=new Set(["tr","tbody","thead","tfoot","colgroup","table","head","html","frameset"]);function canTextBeChildOfNode$1(l){return!elementsWithNoTextChildren.has(l.name)}var utilities$3={PRESERVE_CUSTOM_ATTRIBUTES,invertObject,isCustomComponent,setStyleProp:setStyleProp$1,canTextBeChildOfNode:canTextBeChildOfNode$1,elementsWithNoTextChildren},reactProperty=lib$4,utilities$2=utilities$3,attributesToProps$2=function l(e){e=e||{};var n={reset:!0,submit:!0},t,a,o,d,h,f={},u=e.type&&n[e.type];for(t in e){if(o=e[t],reactProperty.isCustomAttribute(t)){f[t]=o;continue}if(a=t.toLowerCase(),d=getPropName(a),d){switch(h=reactProperty.getPropertyInfo(d),(d==="checked"||d==="value")&&!u&&(d=getPropName("default"+a)),f[d]=o,h&&h.type){case reactProperty.BOOLEAN:f[d]=!0;break;case reactProperty.OVERLOADED_BOOLEAN:o===""&&(f[d]=!0);break}continue}utilities$2.PRESERVE_CUSTOM_ATTRIBUTES&&(f[t]=o)}return utilities$2.setStyleProp(e.style,f),f};function getPropName(l){return reactProperty.possibleStandardNames[l]}var React=React$2,attributesToProps$1=attributesToProps$2,utilities$1=utilities$3,setStyleProp=utilities$1.setStyleProp,canTextBeChildOfNode=utilities$1.canTextBeChildOfNode;function domToReact$1(l,e){e=e||{};for(var n=e.library||React,t=n.cloneElement,a=n.createElement,o=n.isValidElement,d=[],h,f,u=typeof e.replace=="function",p,E,T,v=e.trim,S=0,g=l.length;S<g;S++){if(h=l[S],u&&(p=e.replace(h),o(p))){g>1&&(p=t(p,{key:p.key||S})),d.push(p);continue}if(h.type==="text"){if(f=!h.data.trim().length,f&&h.parent&&!canTextBeChildOfNode(h.parent)||v&&f)continue;d.push(h.data);continue}switch(E=h.attribs,skipAttributesToProps(h)?setStyleProp(E.style,E):E&&(E=attributesToProps$1(E)),T=null,h.type){case"script":case"style":h.children[0]&&(E.dangerouslySetInnerHTML={__html:h.children[0].data});break;case"tag":h.name==="textarea"&&h.children[0]?E.defaultValue=h.children[0].data:h.children&&h.children.length&&(T=domToReact$1(h.children,e));break;default:continue}g>1&&(E.key=S),d.push(a(h.name,E,T))}return d.length===1?d[0]:d}function skipAttributesToProps(l){return utilities$1.PRESERVE_CUSTOM_ATTRIBUTES&&l.type==="tag"&&utilities$1.isCustomComponent(l.name,l.attribs)}var domToReact_1=domToReact$1,CASE_SENSITIVE_TAG_NAMES$1=["animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussainBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"],constants$2={CASE_SENSITIVE_TAG_NAMES:CASE_SENSITIVE_TAG_NAMES$1},node={},lib$3={},hasRequiredLib$1;function requireLib$1(){return hasRequiredLib$1||(hasRequiredLib$1=1,function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Doctype=l.CDATA=l.Tag=l.Style=l.Script=l.Comment=l.Directive=l.Text=l.Root=l.isTag=l.ElementType=void 0;var e;(function(t){t.Root="root",t.Text="text",t.Directive="directive",t.Comment="comment",t.Script="script",t.Style="style",t.Tag="tag",t.CDATA="cdata",t.Doctype="doctype"})(e=l.ElementType||(l.ElementType={}));function n(t){return t.type===e.Tag||t.type===e.Script||t.type===e.Style}l.isTag=n,l.Root=e.Root,l.Text=e.Text,l.Directive=e.Directive,l.Comment=e.Comment,l.Script=e.Script,l.Style=e.Style,l.Tag=e.Tag,l.CDATA=e.CDATA,l.Doctype=e.Doctype}(lib$3)),lib$3}var __extends=commonjsGlobal&&commonjsGlobal.__extends||function(){var l=function(e,n){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,a){t.__proto__=a}||function(t,a){for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(t[o]=a[o])},l(e,n)};return function(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");l(e,n);function t(){this.constructor=e}e.prototype=n===null?Object.create(n):(t.prototype=n.prototype,new t)}}(),__assign=commonjsGlobal&&commonjsGlobal.__assign||function(){return __assign=Object.assign||function(l){for(var e,n=1,t=arguments.length;n<t;n++){e=arguments[n];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(l[a]=e[a])}return l},__assign.apply(this,arguments)};Object.defineProperty(node,"__esModule",{value:!0});node.cloneNode=node.hasChildren=node.isDocument=node.isDirective=node.isComment=node.isText=node.isCDATA=node.isTag=node.Element=node.Document=node.NodeWithChildren=node.ProcessingInstruction=node.Comment=node.Text=node.DataNode=node.Node=void 0;var domelementtype_1=requireLib$1(),nodeTypes=new Map([[domelementtype_1.ElementType.Tag,1],[domelementtype_1.ElementType.Script,1],[domelementtype_1.ElementType.Style,1],[domelementtype_1.ElementType.Directive,1],[domelementtype_1.ElementType.Text,3],[domelementtype_1.ElementType.CDATA,4],[domelementtype_1.ElementType.Comment,8],[domelementtype_1.ElementType.Root,9]]),Node$2=function(){function l(e){this.type=e,this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(l.prototype,"nodeType",{get:function(){var e;return(e=nodeTypes.get(this.type))!==null&&e!==void 0?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"parentNode",{get:function(){return this.parent},set:function(e){this.parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"previousSibling",{get:function(){return this.prev},set:function(e){this.prev=e},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"nextSibling",{get:function(){return this.next},set:function(e){this.next=e},enumerable:!1,configurable:!0}),l.prototype.cloneNode=function(e){return e===void 0&&(e=!1),cloneNode(this,e)},l}();node.Node=Node$2;var DataNode=function(l){__extends(e,l);function e(n,t){var a=l.call(this,n)||this;return a.data=t,a}return Object.defineProperty(e.prototype,"nodeValue",{get:function(){return this.data},set:function(n){this.data=n},enumerable:!1,configurable:!0}),e}(Node$2);node.DataNode=DataNode;var Text$4=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Text,n)||this}return e}(DataNode);node.Text=Text$4;var Comment$1=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Comment,n)||this}return e}(DataNode);node.Comment=Comment$1;var ProcessingInstruction$1=function(l){__extends(e,l);function e(n,t){var a=l.call(this,domelementtype_1.ElementType.Directive,t)||this;return a.name=n,a}return e}(DataNode);node.ProcessingInstruction=ProcessingInstruction$1;var NodeWithChildren=function(l){__extends(e,l);function e(n,t){var a=l.call(this,n)||this;return a.children=t,a}return Object.defineProperty(e.prototype,"firstChild",{get:function(){var n;return(n=this.children[0])!==null&&n!==void 0?n:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastChild",{get:function(){return this.children.length>0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"childNodes",{get:function(){return this.children},set:function(n){this.children=n},enumerable:!1,configurable:!0}),e}(Node$2);node.NodeWithChildren=NodeWithChildren;var Document=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Root,n)||this}return e}(NodeWithChildren);node.Document=Document;var Element$1=function(l){__extends(e,l);function e(n,t,a,o){a===void 0&&(a=[]),o===void 0&&(o=n==="script"?domelementtype_1.ElementType.Script:n==="style"?domelementtype_1.ElementType.Style:domelementtype_1.ElementType.Tag);var d=l.call(this,o,a)||this;return d.name=n,d.attribs=t,d}return Object.defineProperty(e.prototype,"tagName",{get:function(){return this.name},set:function(n){this.name=n},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"attributes",{get:function(){var n=this;return Object.keys(this.attribs).map(function(t){var a,o;return{name:t,value:n.attribs[t],namespace:(a=n["x-attribsNamespace"])===null||a===void 0?void 0:a[t],prefix:(o=n["x-attribsPrefix"])===null||o===void 0?void 0:o[t]}})},enumerable:!1,configurable:!0}),e}(NodeWithChildren);node.Element=Element$1;function isTag(l){return(0,domelementtype_1.isTag)(l)}node.isTag=isTag;function isCDATA(l){return l.type===domelementtype_1.ElementType.CDATA}node.isCDATA=isCDATA;function isText(l){return l.type===domelementtype_1.ElementType.Text}node.isText=isText;function isComment(l){return l.type===domelementtype_1.ElementType.Comment}node.isComment=isComment;function isDirective(l){return l.type===domelementtype_1.ElementType.Directive}node.isDirective=isDirective;function isDocument(l){return l.type===domelementtype_1.ElementType.Root}node.isDocument=isDocument;function hasChildren(l){return Object.prototype.hasOwnProperty.call(l,"children")}node.hasChildren=hasChildren;function cloneNode(l,e){e===void 0&&(e=!1);var n;if(isText(l))n=new Text$4(l.data);else if(isComment(l))n=new Comment$1(l.data);else if(isTag(l)){var t=e?cloneChildren(l.children):[],a=new Element$1(l.name,__assign({},l.attribs),t);t.forEach(function(f){return f.parent=a}),l.namespace!=null&&(a.namespace=l.namespace),l["x-attribsNamespace"]&&(a["x-attribsNamespace"]=__assign({},l["x-attribsNamespace"])),l["x-attribsPrefix"]&&(a["x-attribsPrefix"]=__assign({},l["x-attribsPrefix"])),n=a}else if(isCDATA(l)){var t=e?cloneChildren(l.children):[],o=new NodeWithChildren(domelementtype_1.ElementType.CDATA,t);t.forEach(function(u){return u.parent=o}),n=o}else if(isDocument(l)){var t=e?cloneChildren(l.children):[],d=new Document(t);t.forEach(function(u){return u.parent=d}),l["x-mode"]&&(d["x-mode"]=l["x-mode"]),n=d}else if(isDirective(l)){var h=new ProcessingInstruction$1(l.name,l.data);l["x-name"]!=null&&(h["x-name"]=l["x-name"],h["x-publicId"]=l["x-publicId"],h["x-systemId"]=l["x-systemId"]),n=h}else throw new Error("Not implemented yet: ".concat(l.type));return n.startIndex=l.startIndex,n.endIndex=l.endIndex,l.sourceCodeLocation!=null&&(n.sourceCodeLocation=l.sourceCodeLocation),n}node.cloneNode=cloneNode;function cloneChildren(l){for(var e=l.map(function(t){return cloneNode(t,!0)}),n=1;n<e.length;n++)e[n].prev=e[n-1],e[n-1].next=e[n];return e}var constants$1=constants$2,domhandler=node,CASE_SENSITIVE_TAG_NAMES=constants$1.CASE_SENSITIVE_TAG_NAMES,Comment=domhandler.Comment,Element=domhandler.Element,ProcessingInstruction=domhandler.ProcessingInstruction,Text$3=domhandler.Text,caseSensitiveTagNamesMap={},tagName;for(var i$1=0,len=CASE_SENSITIVE_TAG_NAMES.length;i$1<len;i$1++)tagName=CASE_SENSITIVE_TAG_NAMES[i$1],caseSensitiveTagNamesMap[tagName.toLowerCase()]=tagName;function getCaseSensitiveTagName(l){return caseSensitiveTagNamesMap[l]}function formatAttributes(l){for(var e={},n,t=0,a=l.length;t<a;t++)n=l[t],e[n.name]=n.value;return e}function formatTagName(l){l=l.toLowerCase();var e=getCaseSensitiveTagName(l);return e||l}function formatDOM$1(l,e,n){e=e||null;for(var t=[],a=0,o=l.length;a<o;a++){var d=l[a],h;switch(d.nodeType){case 1:h=new Element(formatTagName(d.nodeName),formatAttributes(d.attributes)),h.children=formatDOM$1(d.childNodes,h);break;case 3:h=new Text$3(d.nodeValue);break;case 8:h=new Comment(d.nodeValue);break;default:continue}var f=t[a-1]||null;f&&(f.next=h),h.parent=e,h.prev=f,h.next=null,t.push(h)}return n&&(h=new ProcessingInstruction(n.substring(0,n.indexOf(" ")).toLowerCase(),n),h.next=t[0]||null,h.parent=e,t.unshift(h),t[1]&&(t[1].prev=t[0])),t}function isIE$1(){return/(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent)}var utilities={formatAttributes,formatDOM:formatDOM$1,isIE:isIE$1},HTML="html",HEAD="head",BODY="body",FIRST_TAG_REGEX=/<([a-zA-Z]+[0-9]?)/,HEAD_TAG_REGEX=/<head.*>/i,BODY_TAG_REGEX=/<body.*>/i,parseFromDocument=function(){throw new Error("This browser does not support `document.implementation.createHTMLDocument`")},parseFromString=function(){throw new Error("This browser does not support `DOMParser.prototype.parseFromString`")};if(typeof window.DOMParser=="function"){var domParser=new window.DOMParser,mimeType="text/html";parseFromString=function(l,e){return e&&(l="<"+e+">"+l+"</"+e+">"),domParser.parseFromString(l,mimeType)},parseFromDocument=parseFromString}if(document.implementation){var isIE=utilities.isIE,doc=document.implementation.createHTMLDocument(isIE()?"html-dom-parser":void 0);parseFromDocument=function(l,e){return e?(doc.documentElement.getElementsByTagName(e)[0].innerHTML=l,doc):(doc.documentElement.innerHTML=l,doc)}}var template=document.createElement("template"),parseFromTemplate;template.content&&(parseFromTemplate=function(l){return template.innerHTML=l,template.content.childNodes});function domparser$1(l){var e,n=l.match(FIRST_TAG_REGEX);n&&n[1]&&(e=n[1].toLowerCase());var t,a,o;switch(e){case HTML:return t=parseFromString(l),HEAD_TAG_REGEX.test(l)||(a=t.getElementsByTagName(HEAD)[0],a&&a.parentNode.removeChild(a)),BODY_TAG_REGEX.test(l)||(a=t.getElementsByTagName(BODY)[0],a&&a.parentNode.removeChild(a)),t.getElementsByTagName(HTML);case HEAD:case BODY:return o=parseFromDocument(l).getElementsByTagName(e),BODY_TAG_REGEX.test(l)&&HEAD_TAG_REGEX.test(l)?o[0].parentNode.childNodes:o;default:return parseFromTemplate?parseFromTemplate(l):parseFromDocument(l,BODY).getElementsByTagName(BODY)[0].childNodes}}var domparser_1=domparser$1,domparser=domparser_1,formatDOM=utilities.formatDOM,DIRECTIVE_REGEX=/<(![a-zA-Z\s]+)>/;function HTMLDOMParser(l){if(typeof l!="string")throw new TypeError("First argument must be a string");if(l==="")return[];var e=l.match(DIRECTIVE_REGEX),n;return e&&e[1]&&(n=e[1]),formatDOM(domparser(l),null,n)}var htmlToDom=HTMLDOMParser,lib$2={},hasRequiredLib;function requireLib(){return hasRequiredLib||(hasRequiredLib=1,function(l){var e=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(f,u,p,E){E===void 0&&(E=p);var T=Object.getOwnPropertyDescriptor(u,p);(!T||("get"in T?!u.__esModule:T.writable||T.configurable))&&(T={enumerable:!0,get:function(){return u[p]}}),Object.defineProperty(f,E,T)}:function(f,u,p,E){E===void 0&&(E=p),f[E]=u[p]}),n=commonjsGlobal&&commonjsGlobal.__exportStar||function(f,u){for(var p in f)p!=="default"&&!Object.prototype.hasOwnProperty.call(u,p)&&e(u,f,p)};Object.defineProperty(l,"__esModule",{value:!0}),l.DomHandler=void 0;var t=requireLib$1(),a=node;n(node,l);var o=/\s+/g,d={normalizeWhitespace:!1,withStartIndices:!1,withEndIndices:!1,xmlMode:!1},h=function(){function f(u,p,E){this.dom=[],this.root=new a.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof p=="function"&&(E=p,p=d),typeof u=="object"&&(p=u,u=void 0),this.callback=u??null,this.options=p??d,this.elementCB=E??null}return f.prototype.onparserinit=function(u){this.parser=u},f.prototype.onreset=function(){this.dom=[],this.root=new a.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},f.prototype.onend=function(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))},f.prototype.onerror=function(u){this.handleCallback(u)},f.prototype.onclosetag=function(){this.lastNode=null;var u=this.tagStack.pop();this.options.withEndIndices&&(u.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(u)},f.prototype.onopentag=function(u,p){var E=this.options.xmlMode?t.ElementType.Tag:void 0,T=new a.Element(u,p,void 0,E);this.addNode(T),this.tagStack.push(T)},f.prototype.ontext=function(u){var p=this.options.normalizeWhitespace,E=this.lastNode;if(E&&E.type===t.ElementType.Text)p?E.data=(E.data+u).replace(o," "):E.data+=u,this.options.withEndIndices&&(E.endIndex=this.parser.endIndex);else{p&&(u=u.replace(o," "));var T=new a.Text(u);this.addNode(T),this.lastNode=T}},f.prototype.oncomment=function(u){if(this.lastNode&&this.lastNode.type===t.ElementType.Comment){this.lastNode.data+=u;return}var p=new a.Comment(u);this.addNode(p),this.lastNode=p},f.prototype.oncommentend=function(){this.lastNode=null},f.prototype.oncdatastart=function(){var u=new a.Text(""),p=new a.NodeWithChildren(t.ElementType.CDATA,[u]);this.addNode(p),u.parent=p,this.lastNode=u},f.prototype.oncdataend=function(){this.lastNode=null},f.prototype.onprocessinginstruction=function(u,p){var E=new a.ProcessingInstruction(u,p);this.addNode(E)},f.prototype.handleCallback=function(u){if(typeof this.callback=="function")this.callback(u,this.dom);else if(u)throw u},f.prototype.addNode=function(u){var p=this.tagStack[this.tagStack.length-1],E=p.children[p.children.length-1];this.options.withStartIndices&&(u.startIndex=this.parser.startIndex),this.options.withEndIndices&&(u.endIndex=this.parser.endIndex),p.children.push(u),E&&(u.prev=E,E.next=u),u.parent=p,this.lastNode=null},f}();l.DomHandler=h,l.default=h}(lib$2)),lib$2}var domToReact=domToReact_1,attributesToProps=attributesToProps$2,htmlToDOM=htmlToDom;htmlToDOM=typeof htmlToDOM.default=="function"?htmlToDOM.default:htmlToDOM;var domParserOptions={lowerCaseAttributeNames:!1};function HTMLReactParser(l,e){if(typeof l!="string")throw new TypeError("First argument must be a string");return l===""?[]:(e=e||{},domToReact(htmlToDOM(l,e.htmlparser2||domParserOptions),e))}HTMLReactParser.domToReact=domToReact;HTMLReactParser.htmlToDOM=htmlToDOM;HTMLReactParser.attributesToProps=attributesToProps;HTMLReactParser.Element=requireLib().Element;htmlReactParser.exports=HTMLReactParser;htmlReactParser.exports.default=HTMLReactParser;var htmlReactParserExports=htmlReactParser.exports;const HTMLReactParser$1=getDefaultExportFromCjs(htmlReactParserExports);HTMLReactParser$1.domToReact;HTMLReactParser$1.htmlToDOM;HTMLReactParser$1.attributesToProps;HTMLReactParser$1.Element;function LectureButtons({goToLecture:l,close:e,minutes:n,seconds:t,btnText:a}){return jsxRuntimeExports.jsx("div",{className:"lectures--buttons",children:l?jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__navigation",onClick:()=>e(),"aria-label":a,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__count","data-testid":"countdown",children:jsxRuntimeExports.jsxs("span",{children:[n<10?`0${n}`:n,":",t<10?`0${t}`:t]})})})}LectureButtons.defaultProps={goToLecture:!1,close:()=>{},minutes:0,seconds:0};const noop$1=()=>{},ttsCache={},useEkho=({voice:l,text:e,audioType:n,loop:t=!1,started:a=!0,audio:o,soundActions:d,getEvent:h,volume:f=.5,onFinish:u=noop$1,onError:p=noop$1,onStart:E=noop$1,pauseTTS:T})=>{const[v,S,g,y]=d,b=!o&&!l,[R,_]=React$2.useState(!1),w=React$2.useRef({url:"",cc:"tts"}),C=React$2.useCallback(F=>h({type:"translate",payload:F}),[h]),N=React$2.useCallback(({id:F,type:M="base"})=>{var z;const I=C("usedVoices"),$=C("gameCharacters");return M==="base"?I==null?void 0:I[F]:M==="character"?(z=$==null?void 0:$[F])==null?void 0:z.voiceId:null},[C]),P=React$2.useCallback((F,M="tts")=>{w.current.url!==F&&(w.current={url:F,cc:M},v(F,M,t,f,u,E,p))},[v,t,f,u,E,p]),D=React$2.useCallback(async F=>{if(R&&F.voiceId&&F.text){let M=ttsCache[`${F.voiceId}_${F.text}`];try{M||(M=await h({type:"getSpeech",payload:F}),ttsCache[`${F.voiceId}_${F.text}`]=M),P(M)}catch{p()}}else p()},[h,R,p,P]),k=React$2.useCallback(()=>{w.current.url&&S(w.current.cc)},[S]);return React$2.useEffect(()=>(_(!0),()=>{_(!1),k()}),[k]),React$2.useEffect(()=>{T?g():y()},[g,T,y]),React$2.useEffect(()=>{b&&k()},[b,k]),React$2.useEffect(()=>{if(R&&a)if(n==="voice"&&(l!=null&&l.id)){const F=N(l);D({voiceId:F,text:e==null?void 0:e.replace("&#39;","'")})}else(n==="file"||!n)&&o?P(o==null?void 0:o.url):p()},[o,n,N,R,p,D,P,a,e,l]),k},cleanTextOfHtmlTags=l=>{const e=/<\/p>|<\/h1>|<\/h2>|<\/h3>|<\/h4>|<\/h5>|<\/h6>|<\/li>/gi,n=/&quot;/gi;if(l)return l.replace(e,"").replace(n,"").replace(/(<([^>]+)>)/gi,"")},READING_TIME=.2;function LecturesComponent({emitEvent:l,getEvent:e,name:n,name_labelId:t,required:a,text:o,text_labelId:d,visible:h,documentType:f,viewed:u,soundActions:p,backgroundImage:E,hideBackgroundImageTheme:T=!1,keyboardControl:v,audio:S,audioType:g,audioVolume:y,voice:b,pause:R,styles:_}){const[w,C]=React$2.useState(),[N,P]=React$2.useState(!1),[D,k]=React$2.useState(0),F=o,M=Math.trunc(F.split(" ").length*READING_TIME),I=!a||a&&D>=M||a&&!h,[$]=p,z=`${n}. ${cleanTextOfHtmlTags(o)}`;useEkho({audioType:g,voice:b,text:z,audio:S,soundActions:p,getEvent:e,volume:y,pauseTTS:R});const X=J=>e({type:"translate",payload:J}),te=React$2.useCallback(()=>{I&&($("click-ui"),l({type:"finishMedia",payload:{name:t,type:"text",text:d,documentType:f}}))},[f,l,I,t,d,$]),ae=v({disabled:u,forward:te,escape:te});React$2.useEffect(()=>ae(),[ae]),React$2.useEffect(()=>{if(!h&&!N&&(te(),P(!0)),a&&h){const J=setInterval(()=>{k(H=>H+1)},1e3);return C(J),()=>{clearInterval(J)}}},[te,a,N,h]),React$2.useEffect(()=>{D===M&&clearInterval(w)},[w,D,M]);const ee=M-D,K=Math.floor(ee/60),ne=ee%60,ue=React$2.useMemo(()=>{let J="";return u?J="notes--results":(J="lectures--container",_&&(J+=` lectures--container--${_}`),E!=null&&E.url&&(J+=" lectures--container--with-custom-bg"),_&&T&&(J+=" disable-background-image")),J},[E==null?void 0:E.url,T,_,u]),pe={backgroundImage:E!=null&&E.url?`url('${E.url}')`:""};return h?jsxRuntimeExports.jsx("div",{className:ue,style:pe,children:jsxRuntimeExports.jsx("div",{className:u?"":"lectures__overlay",children:jsxRuntimeExports.jsxs("div",{className:u?"notes--results__text":`lectures lectures--${_}`,children:[jsxRuntimeExports.jsx("div",{className:"lectures--title",children:n}),jsxRuntimeExports.jsxs("div",{className:"lectures--text",dir:"auto",children:[jsxRuntimeExports.jsx("div",{children:F?HTMLReactParser$1(F):null}),u?null:jsxRuntimeExports.jsx(LectureButtons,{goToLecture:I,close:te,minutes:K,seconds:ne,btnText:X("screens.continue")})]})]})})}):null}LecturesComponent.defaultProps={emitEvent:()=>{},name:"",text:"",visible:!1,documentType:"",viewed:!1,required:!1,context:{},styles:""};function Slot({character:l,active:e,slot:n,lowQuality:t}){var T;const a=l.type==="image",o=l.type==="character",d=l.type==="object",h=(T=l==null?void 0:l.resource)==null?void 0:T.url,f=()=>a?`url(${h})`:o&&t?`url(${h.replace("character.glb","face.png")})`:d&&t?`url(${h.replace("object.glb","thumbnail.png")})`:"",u=()=>a?"contain":o||d?"auto 95%":"",p=()=>a?"center":o||d?"center bottom":"",E=a||t?{backgroundImage:f(),backgroundRepeat:"no-repeat",backgroundPosition:p(),backgroundSize:u()}:{};return jsxRuntimeExports.jsx("div",{className:`conversation--character__item ${e?"active":""} ${n}`,style:E,children:e&&l.name?jsxRuntimeExports.jsx("span",{className:"conversation--character__name",children:l.name}):null},l.name)}Slot.propTypes={character:PropTypes.shape({name:PropTypes.string,url:PropTypes.string,type:PropTypes.string,emotion:PropTypes.string,uid:PropTypes.string,resource:PropTypes.shape({resourceId:PropTypes.string,url:PropTypes.string})}),active:PropTypes.bool,slot:PropTypes.number};Slot.defaultProps={character:{name:"",url:"",type:"",resource:{resourceId:""}},active:!1,slot:0};function toTrianglesDrawMode(l,e){if(e===three.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===three.TriangleFanDrawMode||e===three.TriangleStripDrawMode){let n=l.getIndex();if(n===null){const d=[],h=l.getAttribute("position");if(h!==void 0){for(let f=0;f<h.count;f++)d.push(f);l.setIndex(d),n=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const t=n.count-2,a=[];if(e===three.TriangleFanDrawMode)for(let d=1;d<=t;d++)a.push(n.getX(0)),a.push(n.getX(d)),a.push(n.getX(d+1));else for(let d=0;d<t;d++)d%2===0?(a.push(n.getX(d)),a.push(n.getX(d+1)),a.push(n.getX(d+2))):(a.push(n.getX(d+2)),a.push(n.getX(d+1)),a.push(n.getX(d)));a.length/3!==t&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=l.clone();return o.setIndex(a),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}class GLTFLoader extends three.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(n){return new GLTFMaterialsClearcoatExtension(n)}),this.register(function(n){return new GLTFTextureBasisUExtension(n)}),this.register(function(n){return new GLTFTextureWebPExtension(n)}),this.register(function(n){return new GLTFTextureAVIFExtension(n)}),this.register(function(n){return new GLTFMaterialsSheenExtension(n)}),this.register(function(n){return new GLTFMaterialsTransmissionExtension(n)}),this.register(function(n){return new GLTFMaterialsVolumeExtension(n)}),this.register(function(n){return new GLTFMaterialsIorExtension(n)}),this.register(function(n){return new GLTFMaterialsEmissiveStrengthExtension(n)}),this.register(function(n){return new GLTFMaterialsSpecularExtension(n)}),this.register(function(n){return new GLTFMaterialsIridescenceExtension(n)}),this.register(function(n){return new GLTFMaterialsAnisotropyExtension(n)}),this.register(function(n){return new GLTFMaterialsBumpExtension(n)}),this.register(function(n){return new GLTFLightsExtension(n)}),this.register(function(n){return new GLTFMeshoptCompression(n)}),this.register(function(n){return new GLTFMeshGpuInstancing(n)})}load(e,n,t,a){const o=this;let d;if(this.resourcePath!=="")d=this.resourcePath;else if(this.path!==""){const u=three.LoaderUtils.extractUrlBase(e);d=three.LoaderUtils.resolveURL(u,this.path)}else d=three.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const h=function(u){a?a(u):console.error(u),o.manager.itemError(e),o.manager.itemEnd(e)},f=new three.FileLoader(this.manager);f.setPath(this.path),f.setResponseType("arraybuffer"),f.setRequestHeader(this.requestHeader),f.setWithCredentials(this.withCredentials),f.load(e,function(u){try{o.parse(u,d,function(p){n(p),o.manager.itemEnd(e)},h)}catch(p){h(p)}},t,h)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,n,t,a){let o;const d={},h={},f=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(f.decode(new Uint8Array(e,0,4))===BINARY_EXTENSION_HEADER_MAGIC){try{d[EXTENSIONS.KHR_BINARY_GLTF]=new GLTFBinaryExtension(e)}catch(E){a&&a(E);return}o=JSON.parse(d[EXTENSIONS.KHR_BINARY_GLTF].content)}else o=JSON.parse(f.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){a&&a(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const u=new GLTFParser(o,{path:n||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let p=0;p<this.pluginCallbacks.length;p++){const E=this.pluginCallbacks[p](u);E.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),h[E.name]=E,d[E.name]=!0}if(o.extensionsUsed)for(let p=0;p<o.extensionsUsed.length;++p){const E=o.extensionsUsed[p],T=o.extensionsRequired||[];switch(E){case EXTENSIONS.KHR_MATERIALS_UNLIT:d[E]=new GLTFMaterialsUnlitExtension;break;case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:d[E]=new GLTFDracoMeshCompressionExtension(o,this.dracoLoader);break;case EXTENSIONS.KHR_TEXTURE_TRANSFORM:d[E]=new GLTFTextureTransformExtension;break;case EXTENSIONS.KHR_MESH_QUANTIZATION:d[E]=new GLTFMeshQuantizationExtension;break;default:T.indexOf(E)>=0&&h[E]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+E+'".')}}u.setExtensions(d),u.setPlugins(h),u.parse(t,a)}parseAsync(e,n){const t=this;return new Promise(function(a,o){t.parse(e,n,a,o)})}}function GLTFRegistry(){let l={};return{get:function(e){return l[e]},add:function(e,n){l[e]=n},remove:function(e){delete l[e]},removeAll:function(){l={}}}}const EXTENSIONS={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class GLTFLightsExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,n=this.parser.json.nodes||[];for(let t=0,a=n.length;t<a;t++){const o=n[t];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const n=this.parser,t="light:"+e;let a=n.cache.get(t);if(a)return a;const o=n.json,f=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let u;const p=new three.Color(16777215);f.color!==void 0&&p.setRGB(f.color[0],f.color[1],f.color[2],three.LinearSRGBColorSpace);const E=f.range!==void 0?f.range:0;switch(f.type){case"directional":u=new three.DirectionalLight(p),u.target.position.set(0,0,-1),u.add(u.target);break;case"point":u=new three.PointLight(p),u.distance=E;break;case"spot":u=new three.SpotLight(p),u.distance=E,f.spot=f.spot||{},f.spot.innerConeAngle=f.spot.innerConeAngle!==void 0?f.spot.innerConeAngle:0,f.spot.outerConeAngle=f.spot.outerConeAngle!==void 0?f.spot.outerConeAngle:Math.PI/4,u.angle=f.spot.outerConeAngle,u.penumbra=1-f.spot.innerConeAngle/f.spot.outerConeAngle,u.target.position.set(0,0,-1),u.add(u.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+f.type)}return u.position.set(0,0,0),u.decay=2,assignExtrasToUserData(u,f),f.intensity!==void 0&&(u.intensity=f.intensity),u.name=n.createUniqueName(f.name||"light_"+e),a=Promise.resolve(u),n.cache.add(t,a),a}getDependency(e,n){if(e==="light")return this._loadLight(n)}createNodeAttachment(e){const n=this,t=this.parser,o=t.json.nodes[e],h=(o.extensions&&o.extensions[this.name]||{}).light;return h===void 0?null:this._loadLight(h).then(function(f){return t._getNodeRef(n.cache,h,f)})}}class GLTFMaterialsUnlitExtension{constructor(){this.name=EXTENSIONS.KHR_MATERIALS_UNLIT}getMaterialType(){return three.MeshBasicMaterial}extendParams(e,n,t){const a=[];e.color=new three.Color(1,1,1),e.opacity=1;const o=n.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const d=o.baseColorFactor;e.color.setRGB(d[0],d[1],d[2],three.LinearSRGBColorSpace),e.opacity=d[3]}o.baseColorTexture!==void 0&&a.push(t.assignTexture(e,"map",o.baseColorTexture,three.SRGBColorSpace))}return Promise.all(a)}}class GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=a.extensions[this.name].emissiveStrength;return o!==void 0&&(n.emissiveIntensity=o),Promise.resolve()}}class GLTFMaterialsClearcoatExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];if(d.clearcoatFactor!==void 0&&(n.clearcoat=d.clearcoatFactor),d.clearcoatTexture!==void 0&&o.push(t.assignTexture(n,"clearcoatMap",d.clearcoatTexture)),d.clearcoatRoughnessFactor!==void 0&&(n.clearcoatRoughness=d.clearcoatRoughnessFactor),d.clearcoatRoughnessTexture!==void 0&&o.push(t.assignTexture(n,"clearcoatRoughnessMap",d.clearcoatRoughnessTexture)),d.clearcoatNormalTexture!==void 0&&(o.push(t.assignTexture(n,"clearcoatNormalMap",d.clearcoatNormalTexture)),d.clearcoatNormalTexture.scale!==void 0)){const h=d.clearcoatNormalTexture.scale;n.clearcoatNormalScale=new three.Vector2(h,h)}return Promise.all(o)}}class GLTFMaterialsIridescenceExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.iridescenceFactor!==void 0&&(n.iridescence=d.iridescenceFactor),d.iridescenceTexture!==void 0&&o.push(t.assignTexture(n,"iridescenceMap",d.iridescenceTexture)),d.iridescenceIor!==void 0&&(n.iridescenceIOR=d.iridescenceIor),n.iridescenceThicknessRange===void 0&&(n.iridescenceThicknessRange=[100,400]),d.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessRange[0]=d.iridescenceThicknessMinimum),d.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessRange[1]=d.iridescenceThicknessMaximum),d.iridescenceThicknessTexture!==void 0&&o.push(t.assignTexture(n,"iridescenceThicknessMap",d.iridescenceThicknessTexture)),Promise.all(o)}}class GLTFMaterialsSheenExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[];n.sheenColor=new three.Color(0,0,0),n.sheenRoughness=0,n.sheen=1;const d=a.extensions[this.name];if(d.sheenColorFactor!==void 0){const h=d.sheenColorFactor;n.sheenColor.setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace)}return d.sheenRoughnessFactor!==void 0&&(n.sheenRoughness=d.sheenRoughnessFactor),d.sheenColorTexture!==void 0&&o.push(t.assignTexture(n,"sheenColorMap",d.sheenColorTexture,three.SRGBColorSpace)),d.sheenRoughnessTexture!==void 0&&o.push(t.assignTexture(n,"sheenRoughnessMap",d.sheenRoughnessTexture)),Promise.all(o)}}class GLTFMaterialsTransmissionExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.transmissionFactor!==void 0&&(n.transmission=d.transmissionFactor),d.transmissionTexture!==void 0&&o.push(t.assignTexture(n,"transmissionMap",d.transmissionTexture)),Promise.all(o)}}class GLTFMaterialsVolumeExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];n.thickness=d.thicknessFactor!==void 0?d.thicknessFactor:0,d.thicknessTexture!==void 0&&o.push(t.assignTexture(n,"thicknessMap",d.thicknessTexture)),n.attenuationDistance=d.attenuationDistance||1/0;const h=d.attenuationColor||[1,1,1];return n.attenuationColor=new three.Color().setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace),Promise.all(o)}}class GLTFMaterialsIorExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=a.extensions[this.name];return n.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class GLTFMaterialsSpecularExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];n.specularIntensity=d.specularFactor!==void 0?d.specularFactor:1,d.specularTexture!==void 0&&o.push(t.assignTexture(n,"specularIntensityMap",d.specularTexture));const h=d.specularColorFactor||[1,1,1];return n.specularColor=new three.Color().setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace),d.specularColorTexture!==void 0&&o.push(t.assignTexture(n,"specularColorMap",d.specularColorTexture,three.SRGBColorSpace)),Promise.all(o)}}class GLTFMaterialsBumpExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return n.bumpScale=d.bumpFactor!==void 0?d.bumpFactor:1,d.bumpTexture!==void 0&&o.push(t.assignTexture(n,"bumpMap",d.bumpTexture)),Promise.all(o)}}class GLTFMaterialsAnisotropyExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.anisotropyStrength!==void 0&&(n.anisotropy=d.anisotropyStrength),d.anisotropyRotation!==void 0&&(n.anisotropyRotation=d.anisotropyRotation),d.anisotropyTexture!==void 0&&o.push(t.assignTexture(n,"anisotropyMap",d.anisotropyTexture)),Promise.all(o)}}class GLTFTextureBasisUExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_TEXTURE_BASISU}loadTexture(e){const n=this.parser,t=n.json,a=t.textures[e];if(!a.extensions||!a.extensions[this.name])return null;const o=a.extensions[this.name],d=n.options.ktx2Loader;if(!d){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return n.loadTextureImage(e,o.source,d)}}class GLTFTextureWebPExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const n=this.name,t=this.parser,a=t.json,o=a.textures[e];if(!o.extensions||!o.extensions[n])return null;const d=o.extensions[n],h=a.images[d.source];let f=t.textureLoader;if(h.uri){const u=t.options.manager.getHandler(h.uri);u!==null&&(f=u)}return this.detectSupport().then(function(u){if(u)return t.loadTextureImage(e,d.source,f);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return t.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class GLTFTextureAVIFExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const n=this.name,t=this.parser,a=t.json,o=a.textures[e];if(!o.extensions||!o.extensions[n])return null;const d=o.extensions[n],h=a.images[d.source];let f=t.textureLoader;if(h.uri){const u=t.options.manager.getHandler(h.uri);u!==null&&(f=u)}return this.detectSupport().then(function(u){if(u)return t.loadTextureImage(e,d.source,f);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return t.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class GLTFMeshoptCompression{constructor(e){this.name=EXTENSIONS.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const n=this.parser.json,t=n.bufferViews[e];if(t.extensions&&t.extensions[this.name]){const a=t.extensions[this.name],o=this.parser.getDependency("buffer",a.buffer),d=this.parser.options.meshoptDecoder;if(!d||!d.supported){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(h){const f=a.byteOffset||0,u=a.byteLength||0,p=a.count,E=a.byteStride,T=new Uint8Array(h,f,u);return d.decodeGltfBufferAsync?d.decodeGltfBufferAsync(p,E,T,a.mode,a.filter).then(function(v){return v.buffer}):d.ready.then(function(){const v=new ArrayBuffer(p*E);return d.decodeGltfBuffer(new Uint8Array(v),p,E,T,a.mode,a.filter),v})})}else return null}}class GLTFMeshGpuInstancing{constructor(e){this.name=EXTENSIONS.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const n=this.parser.json,t=n.nodes[e];if(!t.extensions||!t.extensions[this.name]||t.mesh===void 0)return null;const a=n.meshes[t.mesh];for(const u of a.primitives)if(u.mode!==WEBGL_CONSTANTS.TRIANGLES&&u.mode!==WEBGL_CONSTANTS.TRIANGLE_STRIP&&u.mode!==WEBGL_CONSTANTS.TRIANGLE_FAN&&u.mode!==void 0)return null;const d=t.extensions[this.name].attributes,h=[],f={};for(const u in d)h.push(this.parser.getDependency("accessor",d[u]).then(p=>(f[u]=p,f[u])));return h.length<1?null:(h.push(this.parser.createNodeMesh(e)),Promise.all(h).then(u=>{const p=u.pop(),E=p.isGroup?p.children:[p],T=u[0].count,v=[];for(const S of E){const g=new three.Matrix4,y=new three.Vector3,b=new three.Quaternion,R=new three.Vector3(1,1,1),_=new three.InstancedMesh(S.geometry,S.material,T);for(let w=0;w<T;w++)f.TRANSLATION&&y.fromBufferAttribute(f.TRANSLATION,w),f.ROTATION&&b.fromBufferAttribute(f.ROTATION,w),f.SCALE&&R.fromBufferAttribute(f.SCALE,w),_.setMatrixAt(w,g.compose(y,b,R));for(const w in f)if(w==="_COLOR_0"){const C=f[w];_.instanceColor=new three.InstancedBufferAttribute(C.array,C.itemSize,C.normalized)}else w!=="TRANSLATION"&&w!=="ROTATION"&&w!=="SCALE"&&S.geometry.setAttribute(w,f[w]);three.Object3D.prototype.copy.call(_,S),this.parser.assignFinalMaterial(_),v.push(_)}return p.isGroup?(p.clear(),p.add(...v),p):v[0]}))}}const BINARY_EXTENSION_HEADER_MAGIC="glTF",BINARY_EXTENSION_HEADER_LENGTH=12,BINARY_EXTENSION_CHUNK_TYPES={JSON:1313821514,BIN:5130562};class GLTFBinaryExtension{constructor(e){this.name=EXTENSIONS.KHR_BINARY_GLTF,this.content=null,this.body=null;const n=new DataView(e,0,BINARY_EXTENSION_HEADER_LENGTH),t=new TextDecoder;if(this.header={magic:t.decode(new Uint8Array(e.slice(0,4))),version:n.getUint32(4,!0),length:n.getUint32(8,!0)},this.header.magic!==BINARY_EXTENSION_HEADER_MAGIC)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const a=this.header.length-BINARY_EXTENSION_HEADER_LENGTH,o=new DataView(e,BINARY_EXTENSION_HEADER_LENGTH);let d=0;for(;d<a;){const h=o.getUint32(d,!0);d+=4;const f=o.getUint32(d,!0);if(d+=4,f===BINARY_EXTENSION_CHUNK_TYPES.JSON){const u=new Uint8Array(e,BINARY_EXTENSION_HEADER_LENGTH+d,h);this.content=t.decode(u)}else if(f===BINARY_EXTENSION_CHUNK_TYPES.BIN){const u=BINARY_EXTENSION_HEADER_LENGTH+d;this.body=e.slice(u,u+h)}d+=h}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class GLTFDracoMeshCompressionExtension{constructor(e,n){if(!n)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=EXTENSIONS.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=n,this.dracoLoader.preload()}decodePrimitive(e,n){const t=this.json,a=this.dracoLoader,o=e.extensions[this.name].bufferView,d=e.extensions[this.name].attributes,h={},f={},u={};for(const p in d){const E=ATTRIBUTES[p]||p.toLowerCase();h[E]=d[p]}for(const p in e.attributes){const E=ATTRIBUTES[p]||p.toLowerCase();if(d[p]!==void 0){const T=t.accessors[e.attributes[p]],v=WEBGL_COMPONENT_TYPES[T.componentType];u[E]=v.name,f[E]=T.normalized===!0}}return n.getDependency("bufferView",o).then(function(p){return new Promise(function(E,T){a.decodeDracoFile(p,function(v){for(const S in v.attributes){const g=v.attributes[S],y=f[S];y!==void 0&&(g.normalized=y)}E(v)},h,u,three.LinearSRGBColorSpace,T)})})}}class GLTFTextureTransformExtension{constructor(){this.name=EXTENSIONS.KHR_TEXTURE_TRANSFORM}extendTexture(e,n){return(n.texCoord===void 0||n.texCoord===e.channel)&&n.offset===void 0&&n.rotation===void 0&&n.scale===void 0||(e=e.clone(),n.texCoord!==void 0&&(e.channel=n.texCoord),n.offset!==void 0&&e.offset.fromArray(n.offset),n.rotation!==void 0&&(e.rotation=n.rotation),n.scale!==void 0&&e.repeat.fromArray(n.scale),e.needsUpdate=!0),e}}class GLTFMeshQuantizationExtension{constructor(){this.name=EXTENSIONS.KHR_MESH_QUANTIZATION}}class GLTFCubicSplineInterpolant extends three.Interpolant{constructor(e,n,t,a){super(e,n,t,a)}copySampleValue_(e){const n=this.resultBuffer,t=this.sampleValues,a=this.valueSize,o=e*a*3+a;for(let d=0;d!==a;d++)n[d]=t[o+d];return n}interpolate_(e,n,t,a){const o=this.resultBuffer,d=this.sampleValues,h=this.valueSize,f=h*2,u=h*3,p=a-n,E=(t-n)/p,T=E*E,v=T*E,S=e*u,g=S-u,y=-2*v+3*T,b=v-T,R=1-y,_=b-T+E;for(let w=0;w!==h;w++){const C=d[g+w+h],N=d[g+w+f]*p,P=d[S+w+h],D=d[S+w]*p;o[w]=R*C+_*N+y*P+b*D}return o}}const _q=new three.Quaternion;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(e,n,t,a){const o=super.interpolate_(e,n,t,a);return _q.fromArray(o).normalize().toArray(o),o}}const WEBGL_CONSTANTS={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},WEBGL_COMPONENT_TYPES={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},WEBGL_FILTERS={9728:three.NearestFilter,9729:three.LinearFilter,9984:three.NearestMipmapNearestFilter,9985:three.LinearMipmapNearestFilter,9986:three.NearestMipmapLinearFilter,9987:three.LinearMipmapLinearFilter},WEBGL_WRAPPINGS={33071:three.ClampToEdgeWrapping,33648:three.MirroredRepeatWrapping,10497:three.RepeatWrapping},WEBGL_TYPE_SIZES={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ATTRIBUTES={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},PATH_PROPERTIES={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},INTERPOLATION={CUBICSPLINE:void 0,LINEAR:three.InterpolateLinear,STEP:three.InterpolateDiscrete},ALPHA_MODES={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function createDefaultMaterial(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new three.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:three.FrontSide})),l.DefaultMaterial}function addUnknownExtensionsToUserData(l,e,n){for(const t in n.extensions)l[t]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[t]=n.extensions[t])}function assignExtrasToUserData(l,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(l.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function addMorphTargets(l,e,n){let t=!1,a=!1,o=!1;for(let u=0,p=e.length;u<p;u++){const E=e[u];if(E.POSITION!==void 0&&(t=!0),E.NORMAL!==void 0&&(a=!0),E.COLOR_0!==void 0&&(o=!0),t&&a&&o)break}if(!t&&!a&&!o)return Promise.resolve(l);const d=[],h=[],f=[];for(let u=0,p=e.length;u<p;u++){const E=e[u];if(t){const T=E.POSITION!==void 0?n.getDependency("accessor",E.POSITION):l.attributes.position;d.push(T)}if(a){const T=E.NORMAL!==void 0?n.getDependency("accessor",E.NORMAL):l.attributes.normal;h.push(T)}if(o){const T=E.COLOR_0!==void 0?n.getDependency("accessor",E.COLOR_0):l.attributes.color;f.push(T)}}return Promise.all([Promise.all(d),Promise.all(h),Promise.all(f)]).then(function(u){const p=u[0],E=u[1],T=u[2];return t&&(l.morphAttributes.position=p),a&&(l.morphAttributes.normal=E),o&&(l.morphAttributes.color=T),l.morphTargetsRelative=!0,l})}function updateMorphTargets(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let n=0,t=e.weights.length;n<t;n++)l.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(l.morphTargetInfluences.length===n.length){l.morphTargetDictionary={};for(let t=0,a=n.length;t<a;t++)l.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function createPrimitiveKey(l){let e;const n=l.extensions&&l.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION];if(n?e="draco:"+n.bufferView+":"+n.indices+":"+createAttributesKey(n.attributes):e=l.indices+":"+createAttributesKey(l.attributes)+":"+l.mode,l.targets!==void 0)for(let t=0,a=l.targets.length;t<a;t++)e+=":"+createAttributesKey(l.targets[t]);return e}function createAttributesKey(l){let e="";const n=Object.keys(l).sort();for(let t=0,a=n.length;t<a;t++)e+=n[t]+":"+l[n[t]]+";";return e}function getNormalizedComponentScale(l){switch(l){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function getImageURIMimeType(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const _identityMatrix=new three.Matrix4;class GLTFParser{constructor(e={},n={}){this.json=e,this.extensions={},this.plugins={},this.options=n,this.cache=new GLTFRegistry,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let t=!1,a=!1,o=-1;typeof navigator<"u"&&(t=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,a=navigator.userAgent.indexOf("Firefox")>-1,o=a?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||t||a&&o<98?this.textureLoader=new three.TextureLoader(this.options.manager):this.textureLoader=new three.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new three.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,n){const t=this,a=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(d){return d._markDefs&&d._markDefs()}),Promise.all(this._invokeAll(function(d){return d.beforeRoot&&d.beforeRoot()})).then(function(){return Promise.all([t.getDependencies("scene"),t.getDependencies("animation"),t.getDependencies("camera")])}).then(function(d){const h={scene:d[0][a.scene||0],scenes:d[0],animations:d[1],cameras:d[2],asset:a.asset,parser:t,userData:{}};return addUnknownExtensionsToUserData(o,h,a),assignExtrasToUserData(h,a),Promise.all(t._invokeAll(function(f){return f.afterRoot&&f.afterRoot(h)})).then(function(){e(h)})}).catch(n)}_markDefs(){const e=this.json.nodes||[],n=this.json.skins||[],t=this.json.meshes||[];for(let a=0,o=n.length;a<o;a++){const d=n[a].joints;for(let h=0,f=d.length;h<f;h++)e[d[h]].isBone=!0}for(let a=0,o=e.length;a<o;a++){const d=e[a];d.mesh!==void 0&&(this._addNodeRef(this.meshCache,d.mesh),d.skin!==void 0&&(t[d.mesh].isSkinnedMesh=!0)),d.camera!==void 0&&this._addNodeRef(this.cameraCache,d.camera)}}_addNodeRef(e,n){n!==void 0&&(e.refs[n]===void 0&&(e.refs[n]=e.uses[n]=0),e.refs[n]++)}_getNodeRef(e,n,t){if(e.refs[n]<=1)return t;const a=t.clone(),o=(d,h)=>{const f=this.associations.get(d);f!=null&&this.associations.set(h,f);for(const[u,p]of d.children.entries())o(p,h.children[u])};return o(t,a),a.name+="_instance_"+e.uses[n]++,a}_invokeOne(e){const n=Object.values(this.plugins);n.push(this);for(let t=0;t<n.length;t++){const a=e(n[t]);if(a)return a}return null}_invokeAll(e){const n=Object.values(this.plugins);n.unshift(this);const t=[];for(let a=0;a<n.length;a++){const o=e(n[a]);o&&t.push(o)}return t}getDependency(e,n){const t=e+":"+n;let a=this.cache.get(t);if(!a){switch(e){case"scene":a=this.loadScene(n);break;case"node":a=this._invokeOne(function(o){return o.loadNode&&o.loadNode(n)});break;case"mesh":a=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(n)});break;case"accessor":a=this.loadAccessor(n);break;case"bufferView":a=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(n)});break;case"buffer":a=this.loadBuffer(n);break;case"material":a=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(n)});break;case"texture":a=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(n)});break;case"skin":a=this.loadSkin(n);break;case"animation":a=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(n)});break;case"camera":a=this.loadCamera(n);break;default:if(a=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,n)}),!a)throw new Error("Unknown type: "+e);break}this.cache.add(t,a)}return a}getDependencies(e){let n=this.cache.get(e);if(!n){const t=this,a=this.json[e+(e==="mesh"?"es":"s")]||[];n=Promise.all(a.map(function(o,d){return t.getDependency(e,d)})),this.cache.add(e,n)}return n}loadBuffer(e){const n=this.json.buffers[e],t=this.fileLoader;if(n.type&&n.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+n.type+" buffer type is not supported.");if(n.uri===void 0&&e===0)return Promise.resolve(this.extensions[EXTENSIONS.KHR_BINARY_GLTF].body);const a=this.options;return new Promise(function(o,d){t.load(three.LoaderUtils.resolveURL(n.uri,a.path),o,void 0,function(){d(new Error('THREE.GLTFLoader: Failed to load buffer "'+n.uri+'".'))})})}loadBufferView(e){const n=this.json.bufferViews[e];return this.getDependency("buffer",n.buffer).then(function(t){const a=n.byteLength||0,o=n.byteOffset||0;return t.slice(o,o+a)})}loadAccessor(e){const n=this,t=this.json,a=this.json.accessors[e];if(a.bufferView===void 0&&a.sparse===void 0){const d=WEBGL_TYPE_SIZES[a.type],h=WEBGL_COMPONENT_TYPES[a.componentType],f=a.normalized===!0,u=new h(a.count*d);return Promise.resolve(new three.BufferAttribute(u,d,f))}const o=[];return a.bufferView!==void 0?o.push(this.getDependency("bufferView",a.bufferView)):o.push(null),a.sparse!==void 0&&(o.push(this.getDependency("bufferView",a.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",a.sparse.values.bufferView))),Promise.all(o).then(function(d){const h=d[0],f=WEBGL_TYPE_SIZES[a.type],u=WEBGL_COMPONENT_TYPES[a.componentType],p=u.BYTES_PER_ELEMENT,E=p*f,T=a.byteOffset||0,v=a.bufferView!==void 0?t.bufferViews[a.bufferView].byteStride:void 0,S=a.normalized===!0;let g,y;if(v&&v!==E){const b=Math.floor(T/v),R="InterleavedBuffer:"+a.bufferView+":"+a.componentType+":"+b+":"+a.count;let _=n.cache.get(R);_||(g=new u(h,b*v,a.count*v/p),_=new three.InterleavedBuffer(g,v/p),n.cache.add(R,_)),y=new three.InterleavedBufferAttribute(_,f,T%v/p,S)}else h===null?g=new u(a.count*f):g=new u(h,T,a.count*f),y=new three.BufferAttribute(g,f,S);if(a.sparse!==void 0){const b=WEBGL_TYPE_SIZES.SCALAR,R=WEBGL_COMPONENT_TYPES[a.sparse.indices.componentType],_=a.sparse.indices.byteOffset||0,w=a.sparse.values.byteOffset||0,C=new R(d[1],_,a.sparse.count*b),N=new u(d[2],w,a.sparse.count*f);h!==null&&(y=new three.BufferAttribute(y.array.slice(),y.itemSize,y.normalized));for(let P=0,D=C.length;P<D;P++){const k=C[P];if(y.setX(k,N[P*f]),f>=2&&y.setY(k,N[P*f+1]),f>=3&&y.setZ(k,N[P*f+2]),f>=4&&y.setW(k,N[P*f+3]),f>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return y})}loadTexture(e){const n=this.json,t=this.options,o=n.textures[e].source,d=n.images[o];let h=this.textureLoader;if(d.uri){const f=t.manager.getHandler(d.uri);f!==null&&(h=f)}return this.loadTextureImage(e,o,h)}loadTextureImage(e,n,t){const a=this,o=this.json,d=o.textures[e],h=o.images[n],f=(h.uri||h.bufferView)+":"+d.sampler;if(this.textureCache[f])return this.textureCache[f];const u=this.loadImageSource(n,t).then(function(p){p.flipY=!1,p.name=d.name||h.name||"",p.name===""&&typeof h.uri=="string"&&h.uri.startsWith("data:image/")===!1&&(p.name=h.uri);const T=(o.samplers||{})[d.sampler]||{};return p.magFilter=WEBGL_FILTERS[T.magFilter]||three.LinearFilter,p.minFilter=WEBGL_FILTERS[T.minFilter]||three.LinearMipmapLinearFilter,p.wrapS=WEBGL_WRAPPINGS[T.wrapS]||three.RepeatWrapping,p.wrapT=WEBGL_WRAPPINGS[T.wrapT]||three.RepeatWrapping,a.associations.set(p,{textures:e}),p}).catch(function(){return null});return this.textureCache[f]=u,u}loadImageSource(e,n){const t=this,a=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(E=>E.clone());const d=a.images[e],h=self.URL||self.webkitURL;let f=d.uri||"",u=!1;if(d.bufferView!==void 0)f=t.getDependency("bufferView",d.bufferView).then(function(E){u=!0;const T=new Blob([E],{type:d.mimeType});return f=h.createObjectURL(T),f});else if(d.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const p=Promise.resolve(f).then(function(E){return new Promise(function(T,v){let S=T;n.isImageBitmapLoader===!0&&(S=function(g){const y=new three.Texture(g);y.needsUpdate=!0,T(y)}),n.load(three.LoaderUtils.resolveURL(E,o.path),S,void 0,v)})}).then(function(E){return u===!0&&h.revokeObjectURL(f),E.userData.mimeType=d.mimeType||getImageURIMimeType(d.uri),E}).catch(function(E){throw console.error("THREE.GLTFLoader: Couldn't load texture",f),E});return this.sourceCache[e]=p,p}assignTexture(e,n,t,a){const o=this;return this.getDependency("texture",t.index).then(function(d){if(!d)return null;if(t.texCoord!==void 0&&t.texCoord>0&&(d=d.clone(),d.channel=t.texCoord),o.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]){const h=t.extensions!==void 0?t.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]:void 0;if(h){const f=o.associations.get(d);d=o.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM].extendTexture(d,h),o.associations.set(d,f)}}return a!==void 0&&(d.colorSpace=a),e[n]=d,d})}assignFinalMaterial(e){const n=e.geometry;let t=e.material;const a=n.attributes.tangent===void 0,o=n.attributes.color!==void 0,d=n.attributes.normal===void 0;if(e.isPoints){const h="PointsMaterial:"+t.uuid;let f=this.cache.get(h);f||(f=new three.PointsMaterial,three.Material.prototype.copy.call(f,t),f.color.copy(t.color),f.map=t.map,f.sizeAttenuation=!1,this.cache.add(h,f)),t=f}else if(e.isLine){const h="LineBasicMaterial:"+t.uuid;let f=this.cache.get(h);f||(f=new three.LineBasicMaterial,three.Material.prototype.copy.call(f,t),f.color.copy(t.color),f.map=t.map,this.cache.add(h,f)),t=f}if(a||o||d){let h="ClonedMaterial:"+t.uuid+":";a&&(h+="derivative-tangents:"),o&&(h+="vertex-colors:"),d&&(h+="flat-shading:");let f=this.cache.get(h);f||(f=t.clone(),o&&(f.vertexColors=!0),d&&(f.flatShading=!0),a&&(f.normalScale&&(f.normalScale.y*=-1),f.clearcoatNormalScale&&(f.clearcoatNormalScale.y*=-1)),this.cache.add(h,f),this.associations.set(f,this.associations.get(t))),t=f}e.material=t}getMaterialType(){return three.MeshStandardMaterial}loadMaterial(e){const n=this,t=this.json,a=this.extensions,o=t.materials[e];let d;const h={},f=o.extensions||{},u=[];if(f[EXTENSIONS.KHR_MATERIALS_UNLIT]){const E=a[EXTENSIONS.KHR_MATERIALS_UNLIT];d=E.getMaterialType(),u.push(E.extendParams(h,o,n))}else{const E=o.pbrMetallicRoughness||{};if(h.color=new three.Color(1,1,1),h.opacity=1,Array.isArray(E.baseColorFactor)){const T=E.baseColorFactor;h.color.setRGB(T[0],T[1],T[2],three.LinearSRGBColorSpace),h.opacity=T[3]}E.baseColorTexture!==void 0&&u.push(n.assignTexture(h,"map",E.baseColorTexture,three.SRGBColorSpace)),h.metalness=E.metallicFactor!==void 0?E.metallicFactor:1,h.roughness=E.roughnessFactor!==void 0?E.roughnessFactor:1,E.metallicRoughnessTexture!==void 0&&(u.push(n.assignTexture(h,"metalnessMap",E.metallicRoughnessTexture)),u.push(n.assignTexture(h,"roughnessMap",E.metallicRoughnessTexture))),d=this._invokeOne(function(T){return T.getMaterialType&&T.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(T){return T.extendMaterialParams&&T.extendMaterialParams(e,h)})))}o.doubleSided===!0&&(h.side=three.DoubleSide);const p=o.alphaMode||ALPHA_MODES.OPAQUE;if(p===ALPHA_MODES.BLEND?(h.transparent=!0,h.depthWrite=!1):(h.transparent=!1,p===ALPHA_MODES.MASK&&(h.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&d!==three.MeshBasicMaterial&&(u.push(n.assignTexture(h,"normalMap",o.normalTexture)),h.normalScale=new three.Vector2(1,1),o.normalTexture.scale!==void 0)){const E=o.normalTexture.scale;h.normalScale.set(E,E)}if(o.occlusionTexture!==void 0&&d!==three.MeshBasicMaterial&&(u.push(n.assignTexture(h,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(h.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&d!==three.MeshBasicMaterial){const E=o.emissiveFactor;h.emissive=new three.Color().setRGB(E[0],E[1],E[2],three.LinearSRGBColorSpace)}return o.emissiveTexture!==void 0&&d!==three.MeshBasicMaterial&&u.push(n.assignTexture(h,"emissiveMap",o.emissiveTexture,three.SRGBColorSpace)),Promise.all(u).then(function(){const E=new d(h);return o.name&&(E.name=o.name),assignExtrasToUserData(E,o),n.associations.set(E,{materials:e}),o.extensions&&addUnknownExtensionsToUserData(a,E,o),E})}createUniqueName(e){const n=three.PropertyBinding.sanitizeNodeName(e||"");return n in this.nodeNamesUsed?n+"_"+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(e){const n=this,t=this.extensions,a=this.primitiveCache;function o(h){return t[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(h,n).then(function(f){return addPrimitiveAttributes(f,h,n)})}const d=[];for(let h=0,f=e.length;h<f;h++){const u=e[h],p=createPrimitiveKey(u),E=a[p];if(E)d.push(E.promise);else{let T;u.extensions&&u.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]?T=o(u):T=addPrimitiveAttributes(new three.BufferGeometry,u,n),a[p]={primitive:u,promise:T},d.push(T)}}return Promise.all(d)}loadMesh(e){const n=this,t=this.json,a=this.extensions,o=t.meshes[e],d=o.primitives,h=[];for(let f=0,u=d.length;f<u;f++){const p=d[f].material===void 0?createDefaultMaterial(this.cache):this.getDependency("material",d[f].material);h.push(p)}return h.push(n.loadGeometries(d)),Promise.all(h).then(function(f){const u=f.slice(0,f.length-1),p=f[f.length-1],E=[];for(let v=0,S=p.length;v<S;v++){const g=p[v],y=d[v];let b;const R=u[v];if(y.mode===WEBGL_CONSTANTS.TRIANGLES||y.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP||y.mode===WEBGL_CONSTANTS.TRIANGLE_FAN||y.mode===void 0)b=o.isSkinnedMesh===!0?new three.SkinnedMesh(g,R):new three.Mesh(g,R),b.isSkinnedMesh===!0&&b.normalizeSkinWeights(),y.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP?b.geometry=toTrianglesDrawMode(b.geometry,three.TriangleStripDrawMode):y.mode===WEBGL_CONSTANTS.TRIANGLE_FAN&&(b.geometry=toTrianglesDrawMode(b.geometry,three.TriangleFanDrawMode));else if(y.mode===WEBGL_CONSTANTS.LINES)b=new three.LineSegments(g,R);else if(y.mode===WEBGL_CONSTANTS.LINE_STRIP)b=new three.Line(g,R);else if(y.mode===WEBGL_CONSTANTS.LINE_LOOP)b=new three.LineLoop(g,R);else if(y.mode===WEBGL_CONSTANTS.POINTS)b=new three.Points(g,R);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+y.mode);Object.keys(b.geometry.morphAttributes).length>0&&updateMorphTargets(b,o),b.name=n.createUniqueName(o.name||"mesh_"+e),assignExtrasToUserData(b,o),y.extensions&&addUnknownExtensionsToUserData(a,b,y),n.assignFinalMaterial(b),E.push(b)}for(let v=0,S=E.length;v<S;v++)n.associations.set(E[v],{meshes:e,primitives:v});if(E.length===1)return o.extensions&&addUnknownExtensionsToUserData(a,E[0],o),E[0];const T=new three.Group;o.extensions&&addUnknownExtensionsToUserData(a,T,o),n.associations.set(T,{meshes:e});for(let v=0,S=E.length;v<S;v++)T.add(E[v]);return T})}loadCamera(e){let n;const t=this.json.cameras[e],a=t[t.type];if(!a){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return t.type==="perspective"?n=new three.PerspectiveCamera(three.MathUtils.radToDeg(a.yfov),a.aspectRatio||1,a.znear||1,a.zfar||2e6):t.type==="orthographic"&&(n=new three.OrthographicCamera(-a.xmag,a.xmag,a.ymag,-a.ymag,a.znear,a.zfar)),t.name&&(n.name=this.createUniqueName(t.name)),assignExtrasToUserData(n,t),Promise.resolve(n)}loadSkin(e){const n=this.json.skins[e],t=[];for(let a=0,o=n.joints.length;a<o;a++)t.push(this._loadNodeShallow(n.joints[a]));return n.inverseBindMatrices!==void 0?t.push(this.getDependency("accessor",n.inverseBindMatrices)):t.push(null),Promise.all(t).then(function(a){const o=a.pop(),d=a,h=[],f=[];for(let u=0,p=d.length;u<p;u++){const E=d[u];if(E){h.push(E);const T=new three.Matrix4;o!==null&&T.fromArray(o.array,u*16),f.push(T)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',n.joints[u])}return new three.Skeleton(h,f)})}loadAnimation(e){const n=this.json,t=this,a=n.animations[e],o=a.name?a.name:"animation_"+e,d=[],h=[],f=[],u=[],p=[];for(let E=0,T=a.channels.length;E<T;E++){const v=a.channels[E],S=a.samplers[v.sampler],g=v.target,y=g.node,b=a.parameters!==void 0?a.parameters[S.input]:S.input,R=a.parameters!==void 0?a.parameters[S.output]:S.output;g.node!==void 0&&(d.push(this.getDependency("node",y)),h.push(this.getDependency("accessor",b)),f.push(this.getDependency("accessor",R)),u.push(S),p.push(g))}return Promise.all([Promise.all(d),Promise.all(h),Promise.all(f),Promise.all(u),Promise.all(p)]).then(function(E){const T=E[0],v=E[1],S=E[2],g=E[3],y=E[4],b=[];for(let R=0,_=T.length;R<_;R++){const w=T[R],C=v[R],N=S[R],P=g[R],D=y[R];if(w===void 0)continue;w.updateMatrix&&w.updateMatrix();const k=t._createAnimationTracks(w,C,N,P,D);if(k)for(let F=0;F<k.length;F++)b.push(k[F])}return new three.AnimationClip(o,void 0,b)})}createNodeMesh(e){const n=this.json,t=this,a=n.nodes[e];return a.mesh===void 0?null:t.getDependency("mesh",a.mesh).then(function(o){const d=t._getNodeRef(t.meshCache,a.mesh,o);return a.weights!==void 0&&d.traverse(function(h){if(h.isMesh)for(let f=0,u=a.weights.length;f<u;f++)h.morphTargetInfluences[f]=a.weights[f]}),d})}loadNode(e){const n=this.json,t=this,a=n.nodes[e],o=t._loadNodeShallow(e),d=[],h=a.children||[];for(let u=0,p=h.length;u<p;u++)d.push(t.getDependency("node",h[u]));const f=a.skin===void 0?Promise.resolve(null):t.getDependency("skin",a.skin);return Promise.all([o,Promise.all(d),f]).then(function(u){const p=u[0],E=u[1],T=u[2];T!==null&&p.traverse(function(v){v.isSkinnedMesh&&v.bind(T,_identityMatrix)});for(let v=0,S=E.length;v<S;v++)p.add(E[v]);return p})}_loadNodeShallow(e){const n=this.json,t=this.extensions,a=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=n.nodes[e],d=o.name?a.createUniqueName(o.name):"",h=[],f=a._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(e)});return f&&h.push(f),o.camera!==void 0&&h.push(a.getDependency("camera",o.camera).then(function(u){return a._getNodeRef(a.cameraCache,o.camera,u)})),a._invokeAll(function(u){return u.createNodeAttachment&&u.createNodeAttachment(e)}).forEach(function(u){h.push(u)}),this.nodeCache[e]=Promise.all(h).then(function(u){let p;if(o.isBone===!0?p=new three.Bone:u.length>1?p=new three.Group:u.length===1?p=u[0]:p=new three.Object3D,p!==u[0])for(let E=0,T=u.length;E<T;E++)p.add(u[E]);if(o.name&&(p.userData.name=o.name,p.name=d),assignExtrasToUserData(p,o),o.extensions&&addUnknownExtensionsToUserData(t,p,o),o.matrix!==void 0){const E=new three.Matrix4;E.fromArray(o.matrix),p.applyMatrix4(E)}else o.translation!==void 0&&p.position.fromArray(o.translation),o.rotation!==void 0&&p.quaternion.fromArray(o.rotation),o.scale!==void 0&&p.scale.fromArray(o.scale);return a.associations.has(p)||a.associations.set(p,{}),a.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const n=this.extensions,t=this.json.scenes[e],a=this,o=new three.Group;t.name&&(o.name=a.createUniqueName(t.name)),assignExtrasToUserData(o,t),t.extensions&&addUnknownExtensionsToUserData(n,o,t);const d=t.nodes||[],h=[];for(let f=0,u=d.length;f<u;f++)h.push(a.getDependency("node",d[f]));return Promise.all(h).then(function(f){for(let p=0,E=f.length;p<E;p++)o.add(f[p]);const u=p=>{const E=new Map;for(const[T,v]of a.associations)(T instanceof three.Material||T instanceof three.Texture)&&E.set(T,v);return p.traverse(T=>{const v=a.associations.get(T);v!=null&&E.set(T,v)}),E};return a.associations=u(o),o})}_createAnimationTracks(e,n,t,a,o){const d=[],h=e.name?e.name:e.uuid,f=[];PATH_PROPERTIES[o.path]===PATH_PROPERTIES.weights?e.traverse(function(T){T.morphTargetInfluences&&f.push(T.name?T.name:T.uuid)}):f.push(h);let u;switch(PATH_PROPERTIES[o.path]){case PATH_PROPERTIES.weights:u=three.NumberKeyframeTrack;break;case PATH_PROPERTIES.rotation:u=three.QuaternionKeyframeTrack;break;case PATH_PROPERTIES.position:case PATH_PROPERTIES.scale:u=three.VectorKeyframeTrack;break;default:switch(t.itemSize){case 1:u=three.NumberKeyframeTrack;break;case 2:case 3:default:u=three.VectorKeyframeTrack;break}break}const p=a.interpolation!==void 0?INTERPOLATION[a.interpolation]:three.InterpolateLinear,E=this._getArrayFromAccessor(t);for(let T=0,v=f.length;T<v;T++){const S=new u(f[T]+"."+PATH_PROPERTIES[o.path],n.array,E,p);a.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(S),d.push(S)}return d}_getArrayFromAccessor(e){let n=e.array;if(e.normalized){const t=getNormalizedComponentScale(n.constructor),a=new Float32Array(n.length);for(let o=0,d=n.length;o<d;o++)a[o]=n[o]*t;n=a}return n}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const a=this instanceof three.QuaternionKeyframeTrack?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant;return new a(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function computeBounds(l,e,n){const t=e.attributes,a=new three.Box3;if(t.POSITION!==void 0){const h=n.json.accessors[t.POSITION],f=h.min,u=h.max;if(f!==void 0&&u!==void 0){if(a.set(new three.Vector3(f[0],f[1],f[2]),new three.Vector3(u[0],u[1],u[2])),h.normalized){const p=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[h.componentType]);a.min.multiplyScalar(p),a.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const h=new three.Vector3,f=new three.Vector3;for(let u=0,p=o.length;u<p;u++){const E=o[u];if(E.POSITION!==void 0){const T=n.json.accessors[E.POSITION],v=T.min,S=T.max;if(v!==void 0&&S!==void 0){if(f.setX(Math.max(Math.abs(v[0]),Math.abs(S[0]))),f.setY(Math.max(Math.abs(v[1]),Math.abs(S[1]))),f.setZ(Math.max(Math.abs(v[2]),Math.abs(S[2]))),T.normalized){const g=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[T.componentType]);f.multiplyScalar(g)}h.max(f)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}a.expandByVector(h)}l.boundingBox=a;const d=new three.Sphere;a.getCenter(d.center),d.radius=a.min.distanceTo(a.max)/2,l.boundingSphere=d}function addPrimitiveAttributes(l,e,n){const t=e.attributes,a=[];function o(d,h){return n.getDependency("accessor",d).then(function(f){l.setAttribute(h,f)})}for(const d in t){const h=ATTRIBUTES[d]||d.toLowerCase();h in l.attributes||a.push(o(t[d],h))}if(e.indices!==void 0&&!l.index){const d=n.getDependency("accessor",e.indices).then(function(h){l.setIndex(h)});a.push(d)}return three.ColorManagement.workingColorSpace!==three.LinearSRGBColorSpace&&"COLOR_0"in t&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${three.ColorManagement.workingColorSpace}" not supported.`),assignExtrasToUserData(l,e),computeBounds(l,e,n),Promise.all(a).then(function(){return e.targets!==void 0?addMorphTargets(l,e.targets,n):l})}const defaultCamPos=[0,14.63,16],isMobile=DeviceDetection(),loader$1=new GLTFLoader,box=new three.Box3,worldPos=new three.Vector3,size=new three.Vector3;function Panel({character:l,ttsStarted:e,active:n,visible:t}){var v,S,g,y,b;const a=React$2.useRef(null),o=React$2.useRef(null),d=l.type==="character",[h,f]=React$2.useState(!1),u=React$2.useRef(),p=React$2.useMemo(()=>{var R,_,w,C,N,P,D,k;return d?l.animationId&&((R=l.animation)!=null&&R.url)?l.animation:(C=(w=(_=l==null?void 0:l.resource)==null?void 0:_.animations)==null?void 0:w[l.emotion])!=null&&C.url?(P=(N=l==null?void 0:l.resource)==null?void 0:N.animations)==null?void 0:P[l.emotion]:(k=(D=l==null?void 0:l.resource)==null?void 0:D.animations)==null?void 0:k.neutral:{}},[l.emotion,l==null?void 0:l.animationId,l==null?void 0:l.animation,(v=l==null?void 0:l.resource)==null?void 0:v.animations,d]),E=React$2.useCallback(()=>{if(u.current){const R=u.current.userData.animator;R.getAction("idle")&&R.mix("idle",.1)}},[]);React$2.useEffect(()=>{var R,_,w;if(t)if(n)if(e){const C=(w=(_=(R=l==null?void 0:l.resource)==null?void 0:R.animations)==null?void 0:_.talking)==null?void 0:w.url;if(C&&u.current){const N=u.current.userData.animator,P=`${C}_talking`;N.getAction(P)?(N.mix(P,.1),f(!0)):loader$1.load(C,({animations:D})=>{if(!u.current)return;const k=N.getAction("idle").getClip();N.register(P,mixWithTalkingClip(D[0],k)),N.mix(P,.1),f(!0)})}}else E();else h&&E()},[(y=(g=(S=l==null?void 0:l.resource)==null?void 0:S.animations)==null?void 0:g.talking)==null?void 0:y.url,e,n,E,h,t]);const T=React$2.useCallback(R=>{if(l.type==="character"){const _=R.getObjectByName("Head_M",!0);_?(_.updateMatrixWorld(!0),box.setFromObject(R),box.getSize(size),_.getWorldPosition(worldPos),a.current.lookAt(worldPos)):a.current.position.setY(size.y-1.5*1.3),a.current.zoom=1.5}else cameraFitAnyObject(R,a.current),a.current.zoom=1;a.current.updateProjectionMatrix()},[l]);return fiber.useFrame(({gl:R,scene:_})=>{if(a.current&&o.current){const w=document.querySelectorAll(".conversation--character__item")[l.slot];if(w){const C=w.getBoundingClientRect(),N=w.parentNode.getBoundingClientRect(),[P,D]=[C.right-C.left,C.bottom-C.top];if(a.current.aspect=P/D,a.current.updateProjectionMatrix(),d&&u.current){box.setFromObject(u.current),box.getSize(size);const M=u.current.getObjectByName("Head_M",!0);M?(M.getWorldPosition(worldPos),a.current.lookAt(worldPos)):a.current.position.setY(size.y-1.5*1.3),a.current.zoom=1.5}const k={top:C.top-N.top,right:C.right-N.right,left:C.left-N.left,bottom:C.bottom-N.bottom},F=isMobile?24:40;k.bottom+=n?-F:F,R.setViewport(k.left,k.bottom,P,D),R.setScissor(k.left,k.bottom,P,D),o.current.environment=_.environment,R.render(o.current,a.current)}}},1),l.type==="image"?null:jsxRuntimeExports.jsxs("scene",{ref:o,children:[(b=l.resource)!=null&&b.url?jsxRuntimeExports.jsx(arcadeThreeCore.SceneResource,{ref:u,name:`char_${l.uid}`,url:l.resource.url,animationUrl:p.url,type:l.type,onRender:T,texturable:!0,interactive:!0,merge:l.type!=="character",visible:t}):null,jsxRuntimeExports.jsx(drei.PerspectiveCamera,{ref:a,fov:35,position:defaultCamPos,rotation:[0,0,0],onUpdate:R=>{R.layers.enableAll()},manual:!0}),jsxRuntimeExports.jsx(LightSet,{})]})}function PanelsWrapper({characters:l,slots:e,ttsStarted:n,flex:t,currentMessage:a,lod:o}){const[d,h]=React$2.useState(!1);return fiber.useFrame(({gl:f})=>{f.setScissorTest(!1),f.clear(!0,!0),f.setScissorTest(!0)}),React$2.useEffect(()=>{const f=()=>{h(!0)};return arcadeThreeCore.ProgressManager.addEventListener("loaded",f),()=>{arcadeThreeCore.ProgressManager.removeEventListener("loaded",f)}},[]),jsxRuntimeExports.jsx(arcadeThreeCore.QualityManager,{lod:o,active:!0,children:e.map((f,u)=>{let p=null;const E=l.findIndex(T=>T&&T.uid===f.uid);if(E>=0){const T=t?E:u;return p={...l[E]},p.slot=T,jsxRuntimeExports.jsx(Panel,{character:p,active:a.position===T,ttsStarted:n,visible:d},`${`${p.uid}_${u}`}_${E}`)}return null})})}function Scene(l){return l.lowQuality?null:jsxRuntimeExports.jsxs(arcadeThreeCore.Renderer,{className:"conversation--canvas",style:{position:"absolute",width:"100%",height:"100%"},gl:{antialias:!0},fullscreen:!1,onCreated:({gl:e})=>{e.setClearColor("white",0)},children:[jsxRuntimeExports.jsx(arcadeThreeCore.SettingsController,{current:{animate:l.pause}}),jsxRuntimeExports.jsx(arcadeThreeCore.EnvironmentWrapper,{url:"https://min.gamelearn.io/statics/envs/envmap_1k.hdr"}),jsxRuntimeExports.jsx(PanelsWrapper,{...l})]})}function SlotList({characters:l,actors:e,lodSettings:n,ttsStarted:t,currentMessage:a,flex:o,slots:d,children:h,pause:f,getEvent:u}){const p=({character:b,active:R,slot:_})=>({character:b,active:R,emotion:R?a.emotion:"neutral",slot:_}),E=React$2.useMemo(()=>u({type:"currentLod"}),[u]),T=E==="divideby64",v=d.reduce((b,R)=>{var C,N;const _=e==null?void 0:e.find(P=>P.uid===R.uid),w={...R};if(R.character)w.name=R.alias||R.character.name,w.resource=w.character.resource,w.position=w.position>=0?w.position:-1,delete w.character,w.type="character",b.push(w);else if(_){const{resource:P}=_;w.name=R.alias||R.name,w.position=w.position>=0?w.position:-1,w.resource=P,w.type=_.type,b.push(w)}else R.type?(w.name=R.alias||((C=R.character)==null?void 0:C.name)||R.name,w.resource=((N=w.character)==null?void 0:N.resource)||R.resource,w.position=w.position>=0?w.position:-1,delete w.character,w.type=R.type,b.push(w)):o||b.push(null);return b},[]),S=v.length&&v.some(b=>b),g=l.filter(b=>d.find(R=>b.uid===R.uid));function y(){return S?v.map((b,R)=>b?jsxRuntimeExports.jsx(Slot,{lowQuality:T,...p({character:b,active:a.position===b.position,slot:R})},`${b.uid+R}`):jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${R}`},`void_${0+R}`)):o?g.map((b,R)=>{const _=a.position===R;return jsxRuntimeExports.jsx(Slot,{...p({character:b,active:_,slot:R})},`${b.uid+R}`)}):d.length>0?d.map((b,R)=>{const _=l.find(w=>w.uid===b.uid);if(_){const w=a.position===R;return _.name=b.alias||_.name,jsxRuntimeExports.jsx(Slot,{...p({character:_,active:w,slot:R})},`${_.uid+R}`)}return jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${R}`},`${0+R}`)}):null}return jsxRuntimeExports.jsxs("div",{className:"conversation--characters",children:[jsxRuntimeExports.jsx(Scene,{characters:S?v:g,slots:d,flex:o,currentMessage:a,lodSettings:n,ttsStarted:t,pause:f,lod:E,lowQuality:T}),h||jsxRuntimeExports.jsx(y,{})]})}SlotList.defaultProps={characters:[],currentMessage:{},flex:!0,slots:[]};function Options({inherited:l,options:e,selectedChoice:n,selectChoice:t,showingResults:a,simplifiedOptions:o,required:d}){const[h,f]=React$2.useState(null),u=E=>{o?(f(E),setTimeout(()=>{t(E),f(null)},1e3)):t(E)},p=E=>!!(a&&(n==null?void 0:n.id)===E.id||(n==null?void 0:n.right)===!0||a&&!d);return e==null?void 0:e.filter(E=>E.text).map(E=>jsxRuntimeExports.jsxs("div",{className:`${l?"conversation--question custom-radio":"custom-radio"}
66
+ `,FORWARD_SLASH="/",ASTERISK="*",EMPTY_STRING$1="",TYPE_COMMENT="comment",TYPE_DECLARATION="declaration",inlineStyleParser=function(l,e){if(typeof l!="string")throw new TypeError("First argument must be a string");if(!l)return[];e=e||{};var n=1,t=1;function a(S){var g=S.match(NEWLINE_REGEX);g&&(n+=g.length);var y=S.lastIndexOf(NEWLINE);t=~y?S.length-y:t+S.length}function o(){var S={line:n,column:t};return function(g){return g.position=new d(S),u(),g}}function d(S){this.start=S,this.end={line:n,column:t},this.source=e.source}d.prototype.content=l;function h(S){var g=new Error(e.source+":"+n+":"+t+": "+S);if(g.reason=S,g.filename=e.source,g.line=n,g.column=t,g.source=l,!e.silent)throw g}function f(S){var g=S.exec(l);if(g){var y=g[0];return a(y),l=l.slice(y.length),g}}function u(){f(WHITESPACE_REGEX)}function p(S){var g;for(S=S||[];g=E();)g!==!1&&S.push(g);return S}function E(){var S=o();if(!(FORWARD_SLASH!=l.charAt(0)||ASTERISK!=l.charAt(1))){for(var g=2;EMPTY_STRING$1!=l.charAt(g)&&(ASTERISK!=l.charAt(g)||FORWARD_SLASH!=l.charAt(g+1));)++g;if(g+=2,EMPTY_STRING$1===l.charAt(g-1))return h("End of comment missing");var y=l.slice(2,g-2);return t+=2,a(y),l=l.slice(g),t+=2,S({type:TYPE_COMMENT,comment:y})}}function T(){var S=o(),g=f(PROPERTY_REGEX);if(g){if(E(),!f(COLON_REGEX))return h("property missing ':'");var y=f(VALUE_REGEX),b=S({type:TYPE_DECLARATION,property:trim(g[0].replace(COMMENT_REGEX,EMPTY_STRING$1)),value:y?trim(y[0].replace(COMMENT_REGEX,EMPTY_STRING$1)):EMPTY_STRING$1});return f(SEMICOLON_REGEX),b}}function v(){var S=[];p(S);for(var g;g=T();)g!==!1&&(S.push(g),p(S));return S}return u(),v()};function trim(l){return l?l.replace(TRIM_REGEX,EMPTY_STRING$1):EMPTY_STRING$1}var parse=inlineStyleParser;function StyleToObject(l,e){var n=null;if(!l||typeof l!="string")return n;for(var t,a=parse(l),o=typeof e=="function",d,h,f=0,u=a.length;f<u;f++)t=a[f],d=t.property,h=t.value,o?e(d,h,t):h&&(n||(n={}),n[d]=h);return n}var styleToObject=StyleToObject,utilities$4={};utilities$4.__esModule=!0;utilities$4.camelCase=void 0;var CUSTOM_PROPERTY_REGEX=/^--[a-zA-Z0-9-]+$/,HYPHEN_REGEX=/-([a-z])/g,NO_HYPHEN_REGEX=/^[^-]+$/,VENDOR_PREFIX_REGEX=/^-(webkit|moz|ms|o|khtml)-/,MS_VENDOR_PREFIX_REGEX=/^-(ms)-/,skipCamelCase=function(l){return!l||NO_HYPHEN_REGEX.test(l)||CUSTOM_PROPERTY_REGEX.test(l)},capitalize=function(l,e){return e.toUpperCase()},trimHyphen=function(l,e){return"".concat(e,"-")},camelCase=function(l,e){return e===void 0&&(e={}),skipCamelCase(l)?l:(l=l.toLowerCase(),e.reactCompat?l=l.replace(MS_VENDOR_PREFIX_REGEX,trimHyphen):l=l.replace(VENDOR_PREFIX_REGEX,trimHyphen),l.replace(HYPHEN_REGEX,capitalize))};utilities$4.camelCase=camelCase;(function(l){var e=commonjsGlobal&&commonjsGlobal.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};l.__esModule=!0;var n=e(styleToObject),t=utilities$4;function a(o,d){var h={};return!o||typeof o!="string"||(0,n.default)(o,function(f,u){f&&u&&(h[(0,t.camelCase)(f,d)]=u)}),h}l.default=a})(cjs);var React$1=React$2,styleToJS=cjs.default;function invertObject(l,e){if(!l||typeof l!="object")throw new TypeError("First argument must be an object");var n,t,a=typeof e=="function",o={},d={};for(n in l){if(t=l[n],a&&(o=e(n,t),o&&o.length===2)){d[o[0]]=o[1];continue}typeof t=="string"&&(d[t]=n)}return d}function isCustomComponent(l,e){if(l.indexOf("-")===-1)return e&&typeof e.is=="string";switch(l){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var styleToJSOptions={reactCompat:!0};function setStyleProp$1(l,e){if(l!=null)try{e.style=styleToJS(l,styleToJSOptions)}catch{e.style={}}}var PRESERVE_CUSTOM_ATTRIBUTES=React$1.version.split(".")[0]>=16,elementsWithNoTextChildren=new Set(["tr","tbody","thead","tfoot","colgroup","table","head","html","frameset"]);function canTextBeChildOfNode$1(l){return!elementsWithNoTextChildren.has(l.name)}var utilities$3={PRESERVE_CUSTOM_ATTRIBUTES,invertObject,isCustomComponent,setStyleProp:setStyleProp$1,canTextBeChildOfNode:canTextBeChildOfNode$1,elementsWithNoTextChildren},reactProperty=lib$4,utilities$2=utilities$3,attributesToProps$2=function l(e){e=e||{};var n={reset:!0,submit:!0},t,a,o,d,h,f={},u=e.type&&n[e.type];for(t in e){if(o=e[t],reactProperty.isCustomAttribute(t)){f[t]=o;continue}if(a=t.toLowerCase(),d=getPropName(a),d){switch(h=reactProperty.getPropertyInfo(d),(d==="checked"||d==="value")&&!u&&(d=getPropName("default"+a)),f[d]=o,h&&h.type){case reactProperty.BOOLEAN:f[d]=!0;break;case reactProperty.OVERLOADED_BOOLEAN:o===""&&(f[d]=!0);break}continue}utilities$2.PRESERVE_CUSTOM_ATTRIBUTES&&(f[t]=o)}return utilities$2.setStyleProp(e.style,f),f};function getPropName(l){return reactProperty.possibleStandardNames[l]}var React=React$2,attributesToProps$1=attributesToProps$2,utilities$1=utilities$3,setStyleProp=utilities$1.setStyleProp,canTextBeChildOfNode=utilities$1.canTextBeChildOfNode;function domToReact$1(l,e){e=e||{};for(var n=e.library||React,t=n.cloneElement,a=n.createElement,o=n.isValidElement,d=[],h,f,u=typeof e.replace=="function",p,E,T,v=e.trim,S=0,g=l.length;S<g;S++){if(h=l[S],u&&(p=e.replace(h),o(p))){g>1&&(p=t(p,{key:p.key||S})),d.push(p);continue}if(h.type==="text"){if(f=!h.data.trim().length,f&&h.parent&&!canTextBeChildOfNode(h.parent)||v&&f)continue;d.push(h.data);continue}switch(E=h.attribs,skipAttributesToProps(h)?setStyleProp(E.style,E):E&&(E=attributesToProps$1(E)),T=null,h.type){case"script":case"style":h.children[0]&&(E.dangerouslySetInnerHTML={__html:h.children[0].data});break;case"tag":h.name==="textarea"&&h.children[0]?E.defaultValue=h.children[0].data:h.children&&h.children.length&&(T=domToReact$1(h.children,e));break;default:continue}g>1&&(E.key=S),d.push(a(h.name,E,T))}return d.length===1?d[0]:d}function skipAttributesToProps(l){return utilities$1.PRESERVE_CUSTOM_ATTRIBUTES&&l.type==="tag"&&utilities$1.isCustomComponent(l.name,l.attribs)}var domToReact_1=domToReact$1,CASE_SENSITIVE_TAG_NAMES$1=["animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussainBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"],constants$2={CASE_SENSITIVE_TAG_NAMES:CASE_SENSITIVE_TAG_NAMES$1},node={},lib$3={},hasRequiredLib$1;function requireLib$1(){return hasRequiredLib$1||(hasRequiredLib$1=1,function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Doctype=l.CDATA=l.Tag=l.Style=l.Script=l.Comment=l.Directive=l.Text=l.Root=l.isTag=l.ElementType=void 0;var e;(function(t){t.Root="root",t.Text="text",t.Directive="directive",t.Comment="comment",t.Script="script",t.Style="style",t.Tag="tag",t.CDATA="cdata",t.Doctype="doctype"})(e=l.ElementType||(l.ElementType={}));function n(t){return t.type===e.Tag||t.type===e.Script||t.type===e.Style}l.isTag=n,l.Root=e.Root,l.Text=e.Text,l.Directive=e.Directive,l.Comment=e.Comment,l.Script=e.Script,l.Style=e.Style,l.Tag=e.Tag,l.CDATA=e.CDATA,l.Doctype=e.Doctype}(lib$3)),lib$3}var __extends=commonjsGlobal&&commonjsGlobal.__extends||function(){var l=function(e,n){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,a){t.__proto__=a}||function(t,a){for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(t[o]=a[o])},l(e,n)};return function(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");l(e,n);function t(){this.constructor=e}e.prototype=n===null?Object.create(n):(t.prototype=n.prototype,new t)}}(),__assign=commonjsGlobal&&commonjsGlobal.__assign||function(){return __assign=Object.assign||function(l){for(var e,n=1,t=arguments.length;n<t;n++){e=arguments[n];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(l[a]=e[a])}return l},__assign.apply(this,arguments)};Object.defineProperty(node,"__esModule",{value:!0});node.cloneNode=node.hasChildren=node.isDocument=node.isDirective=node.isComment=node.isText=node.isCDATA=node.isTag=node.Element=node.Document=node.NodeWithChildren=node.ProcessingInstruction=node.Comment=node.Text=node.DataNode=node.Node=void 0;var domelementtype_1=requireLib$1(),nodeTypes=new Map([[domelementtype_1.ElementType.Tag,1],[domelementtype_1.ElementType.Script,1],[domelementtype_1.ElementType.Style,1],[domelementtype_1.ElementType.Directive,1],[domelementtype_1.ElementType.Text,3],[domelementtype_1.ElementType.CDATA,4],[domelementtype_1.ElementType.Comment,8],[domelementtype_1.ElementType.Root,9]]),Node$2=function(){function l(e){this.type=e,this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(l.prototype,"nodeType",{get:function(){var e;return(e=nodeTypes.get(this.type))!==null&&e!==void 0?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"parentNode",{get:function(){return this.parent},set:function(e){this.parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"previousSibling",{get:function(){return this.prev},set:function(e){this.prev=e},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"nextSibling",{get:function(){return this.next},set:function(e){this.next=e},enumerable:!1,configurable:!0}),l.prototype.cloneNode=function(e){return e===void 0&&(e=!1),cloneNode(this,e)},l}();node.Node=Node$2;var DataNode=function(l){__extends(e,l);function e(n,t){var a=l.call(this,n)||this;return a.data=t,a}return Object.defineProperty(e.prototype,"nodeValue",{get:function(){return this.data},set:function(n){this.data=n},enumerable:!1,configurable:!0}),e}(Node$2);node.DataNode=DataNode;var Text$4=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Text,n)||this}return e}(DataNode);node.Text=Text$4;var Comment$1=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Comment,n)||this}return e}(DataNode);node.Comment=Comment$1;var ProcessingInstruction$1=function(l){__extends(e,l);function e(n,t){var a=l.call(this,domelementtype_1.ElementType.Directive,t)||this;return a.name=n,a}return e}(DataNode);node.ProcessingInstruction=ProcessingInstruction$1;var NodeWithChildren=function(l){__extends(e,l);function e(n,t){var a=l.call(this,n)||this;return a.children=t,a}return Object.defineProperty(e.prototype,"firstChild",{get:function(){var n;return(n=this.children[0])!==null&&n!==void 0?n:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastChild",{get:function(){return this.children.length>0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"childNodes",{get:function(){return this.children},set:function(n){this.children=n},enumerable:!1,configurable:!0}),e}(Node$2);node.NodeWithChildren=NodeWithChildren;var Document=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Root,n)||this}return e}(NodeWithChildren);node.Document=Document;var Element$1=function(l){__extends(e,l);function e(n,t,a,o){a===void 0&&(a=[]),o===void 0&&(o=n==="script"?domelementtype_1.ElementType.Script:n==="style"?domelementtype_1.ElementType.Style:domelementtype_1.ElementType.Tag);var d=l.call(this,o,a)||this;return d.name=n,d.attribs=t,d}return Object.defineProperty(e.prototype,"tagName",{get:function(){return this.name},set:function(n){this.name=n},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"attributes",{get:function(){var n=this;return Object.keys(this.attribs).map(function(t){var a,o;return{name:t,value:n.attribs[t],namespace:(a=n["x-attribsNamespace"])===null||a===void 0?void 0:a[t],prefix:(o=n["x-attribsPrefix"])===null||o===void 0?void 0:o[t]}})},enumerable:!1,configurable:!0}),e}(NodeWithChildren);node.Element=Element$1;function isTag(l){return(0,domelementtype_1.isTag)(l)}node.isTag=isTag;function isCDATA(l){return l.type===domelementtype_1.ElementType.CDATA}node.isCDATA=isCDATA;function isText(l){return l.type===domelementtype_1.ElementType.Text}node.isText=isText;function isComment(l){return l.type===domelementtype_1.ElementType.Comment}node.isComment=isComment;function isDirective(l){return l.type===domelementtype_1.ElementType.Directive}node.isDirective=isDirective;function isDocument(l){return l.type===domelementtype_1.ElementType.Root}node.isDocument=isDocument;function hasChildren(l){return Object.prototype.hasOwnProperty.call(l,"children")}node.hasChildren=hasChildren;function cloneNode(l,e){e===void 0&&(e=!1);var n;if(isText(l))n=new Text$4(l.data);else if(isComment(l))n=new Comment$1(l.data);else if(isTag(l)){var t=e?cloneChildren(l.children):[],a=new Element$1(l.name,__assign({},l.attribs),t);t.forEach(function(f){return f.parent=a}),l.namespace!=null&&(a.namespace=l.namespace),l["x-attribsNamespace"]&&(a["x-attribsNamespace"]=__assign({},l["x-attribsNamespace"])),l["x-attribsPrefix"]&&(a["x-attribsPrefix"]=__assign({},l["x-attribsPrefix"])),n=a}else if(isCDATA(l)){var t=e?cloneChildren(l.children):[],o=new NodeWithChildren(domelementtype_1.ElementType.CDATA,t);t.forEach(function(u){return u.parent=o}),n=o}else if(isDocument(l)){var t=e?cloneChildren(l.children):[],d=new Document(t);t.forEach(function(u){return u.parent=d}),l["x-mode"]&&(d["x-mode"]=l["x-mode"]),n=d}else if(isDirective(l)){var h=new ProcessingInstruction$1(l.name,l.data);l["x-name"]!=null&&(h["x-name"]=l["x-name"],h["x-publicId"]=l["x-publicId"],h["x-systemId"]=l["x-systemId"]),n=h}else throw new Error("Not implemented yet: ".concat(l.type));return n.startIndex=l.startIndex,n.endIndex=l.endIndex,l.sourceCodeLocation!=null&&(n.sourceCodeLocation=l.sourceCodeLocation),n}node.cloneNode=cloneNode;function cloneChildren(l){for(var e=l.map(function(t){return cloneNode(t,!0)}),n=1;n<e.length;n++)e[n].prev=e[n-1],e[n-1].next=e[n];return e}var constants$1=constants$2,domhandler=node,CASE_SENSITIVE_TAG_NAMES=constants$1.CASE_SENSITIVE_TAG_NAMES,Comment=domhandler.Comment,Element=domhandler.Element,ProcessingInstruction=domhandler.ProcessingInstruction,Text$3=domhandler.Text,caseSensitiveTagNamesMap={},tagName;for(var i$1=0,len=CASE_SENSITIVE_TAG_NAMES.length;i$1<len;i$1++)tagName=CASE_SENSITIVE_TAG_NAMES[i$1],caseSensitiveTagNamesMap[tagName.toLowerCase()]=tagName;function getCaseSensitiveTagName(l){return caseSensitiveTagNamesMap[l]}function formatAttributes(l){for(var e={},n,t=0,a=l.length;t<a;t++)n=l[t],e[n.name]=n.value;return e}function formatTagName(l){l=l.toLowerCase();var e=getCaseSensitiveTagName(l);return e||l}function formatDOM$1(l,e,n){e=e||null;for(var t=[],a=0,o=l.length;a<o;a++){var d=l[a],h;switch(d.nodeType){case 1:h=new Element(formatTagName(d.nodeName),formatAttributes(d.attributes)),h.children=formatDOM$1(d.childNodes,h);break;case 3:h=new Text$3(d.nodeValue);break;case 8:h=new Comment(d.nodeValue);break;default:continue}var f=t[a-1]||null;f&&(f.next=h),h.parent=e,h.prev=f,h.next=null,t.push(h)}return n&&(h=new ProcessingInstruction(n.substring(0,n.indexOf(" ")).toLowerCase(),n),h.next=t[0]||null,h.parent=e,t.unshift(h),t[1]&&(t[1].prev=t[0])),t}function isIE$1(){return/(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent)}var utilities={formatAttributes,formatDOM:formatDOM$1,isIE:isIE$1},HTML="html",HEAD="head",BODY="body",FIRST_TAG_REGEX=/<([a-zA-Z]+[0-9]?)/,HEAD_TAG_REGEX=/<head.*>/i,BODY_TAG_REGEX=/<body.*>/i,parseFromDocument=function(){throw new Error("This browser does not support `document.implementation.createHTMLDocument`")},parseFromString=function(){throw new Error("This browser does not support `DOMParser.prototype.parseFromString`")};if(typeof window.DOMParser=="function"){var domParser=new window.DOMParser,mimeType="text/html";parseFromString=function(l,e){return e&&(l="<"+e+">"+l+"</"+e+">"),domParser.parseFromString(l,mimeType)},parseFromDocument=parseFromString}if(document.implementation){var isIE=utilities.isIE,doc=document.implementation.createHTMLDocument(isIE()?"html-dom-parser":void 0);parseFromDocument=function(l,e){return e?(doc.documentElement.getElementsByTagName(e)[0].innerHTML=l,doc):(doc.documentElement.innerHTML=l,doc)}}var template=document.createElement("template"),parseFromTemplate;template.content&&(parseFromTemplate=function(l){return template.innerHTML=l,template.content.childNodes});function domparser$1(l){var e,n=l.match(FIRST_TAG_REGEX);n&&n[1]&&(e=n[1].toLowerCase());var t,a,o;switch(e){case HTML:return t=parseFromString(l),HEAD_TAG_REGEX.test(l)||(a=t.getElementsByTagName(HEAD)[0],a&&a.parentNode.removeChild(a)),BODY_TAG_REGEX.test(l)||(a=t.getElementsByTagName(BODY)[0],a&&a.parentNode.removeChild(a)),t.getElementsByTagName(HTML);case HEAD:case BODY:return o=parseFromDocument(l).getElementsByTagName(e),BODY_TAG_REGEX.test(l)&&HEAD_TAG_REGEX.test(l)?o[0].parentNode.childNodes:o;default:return parseFromTemplate?parseFromTemplate(l):parseFromDocument(l,BODY).getElementsByTagName(BODY)[0].childNodes}}var domparser_1=domparser$1,domparser=domparser_1,formatDOM=utilities.formatDOM,DIRECTIVE_REGEX=/<(![a-zA-Z\s]+)>/;function HTMLDOMParser(l){if(typeof l!="string")throw new TypeError("First argument must be a string");if(l==="")return[];var e=l.match(DIRECTIVE_REGEX),n;return e&&e[1]&&(n=e[1]),formatDOM(domparser(l),null,n)}var htmlToDom=HTMLDOMParser,lib$2={},hasRequiredLib;function requireLib(){return hasRequiredLib||(hasRequiredLib=1,function(l){var e=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(f,u,p,E){E===void 0&&(E=p);var T=Object.getOwnPropertyDescriptor(u,p);(!T||("get"in T?!u.__esModule:T.writable||T.configurable))&&(T={enumerable:!0,get:function(){return u[p]}}),Object.defineProperty(f,E,T)}:function(f,u,p,E){E===void 0&&(E=p),f[E]=u[p]}),n=commonjsGlobal&&commonjsGlobal.__exportStar||function(f,u){for(var p in f)p!=="default"&&!Object.prototype.hasOwnProperty.call(u,p)&&e(u,f,p)};Object.defineProperty(l,"__esModule",{value:!0}),l.DomHandler=void 0;var t=requireLib$1(),a=node;n(node,l);var o=/\s+/g,d={normalizeWhitespace:!1,withStartIndices:!1,withEndIndices:!1,xmlMode:!1},h=function(){function f(u,p,E){this.dom=[],this.root=new a.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof p=="function"&&(E=p,p=d),typeof u=="object"&&(p=u,u=void 0),this.callback=u??null,this.options=p??d,this.elementCB=E??null}return f.prototype.onparserinit=function(u){this.parser=u},f.prototype.onreset=function(){this.dom=[],this.root=new a.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},f.prototype.onend=function(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))},f.prototype.onerror=function(u){this.handleCallback(u)},f.prototype.onclosetag=function(){this.lastNode=null;var u=this.tagStack.pop();this.options.withEndIndices&&(u.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(u)},f.prototype.onopentag=function(u,p){var E=this.options.xmlMode?t.ElementType.Tag:void 0,T=new a.Element(u,p,void 0,E);this.addNode(T),this.tagStack.push(T)},f.prototype.ontext=function(u){var p=this.options.normalizeWhitespace,E=this.lastNode;if(E&&E.type===t.ElementType.Text)p?E.data=(E.data+u).replace(o," "):E.data+=u,this.options.withEndIndices&&(E.endIndex=this.parser.endIndex);else{p&&(u=u.replace(o," "));var T=new a.Text(u);this.addNode(T),this.lastNode=T}},f.prototype.oncomment=function(u){if(this.lastNode&&this.lastNode.type===t.ElementType.Comment){this.lastNode.data+=u;return}var p=new a.Comment(u);this.addNode(p),this.lastNode=p},f.prototype.oncommentend=function(){this.lastNode=null},f.prototype.oncdatastart=function(){var u=new a.Text(""),p=new a.NodeWithChildren(t.ElementType.CDATA,[u]);this.addNode(p),u.parent=p,this.lastNode=u},f.prototype.oncdataend=function(){this.lastNode=null},f.prototype.onprocessinginstruction=function(u,p){var E=new a.ProcessingInstruction(u,p);this.addNode(E)},f.prototype.handleCallback=function(u){if(typeof this.callback=="function")this.callback(u,this.dom);else if(u)throw u},f.prototype.addNode=function(u){var p=this.tagStack[this.tagStack.length-1],E=p.children[p.children.length-1];this.options.withStartIndices&&(u.startIndex=this.parser.startIndex),this.options.withEndIndices&&(u.endIndex=this.parser.endIndex),p.children.push(u),E&&(u.prev=E,E.next=u),u.parent=p,this.lastNode=null},f}();l.DomHandler=h,l.default=h}(lib$2)),lib$2}var domToReact=domToReact_1,attributesToProps=attributesToProps$2,htmlToDOM=htmlToDom;htmlToDOM=typeof htmlToDOM.default=="function"?htmlToDOM.default:htmlToDOM;var domParserOptions={lowerCaseAttributeNames:!1};function HTMLReactParser(l,e){if(typeof l!="string")throw new TypeError("First argument must be a string");return l===""?[]:(e=e||{},domToReact(htmlToDOM(l,e.htmlparser2||domParserOptions),e))}HTMLReactParser.domToReact=domToReact;HTMLReactParser.htmlToDOM=htmlToDOM;HTMLReactParser.attributesToProps=attributesToProps;HTMLReactParser.Element=requireLib().Element;htmlReactParser.exports=HTMLReactParser;htmlReactParser.exports.default=HTMLReactParser;var htmlReactParserExports=htmlReactParser.exports;const HTMLReactParser$1=getDefaultExportFromCjs(htmlReactParserExports);HTMLReactParser$1.domToReact;HTMLReactParser$1.htmlToDOM;HTMLReactParser$1.attributesToProps;HTMLReactParser$1.Element;function LectureButtons({goToLecture:l,close:e,minutes:n,seconds:t,btnText:a}){return jsxRuntimeExports.jsx("div",{className:"lectures--buttons",children:l?jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__navigation",onClick:()=>e(),"aria-label":a,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__count","data-testid":"countdown",children:jsxRuntimeExports.jsxs("span",{children:[n<10?`0${n}`:n,":",t<10?`0${t}`:t]})})})}LectureButtons.defaultProps={goToLecture:!1,close:()=>{},minutes:0,seconds:0};const noop$1=()=>{},ttsCache={},useEkho=({voice:l,text:e,audioType:n,loop:t=!1,started:a=!0,audio:o,soundActions:d,getEvent:h,volume:f=.5,onFinish:u=noop$1,onError:p=noop$1,onStart:E=noop$1,pauseTTS:T})=>{const[v,S,g,y]=d,b=!o&&!l,[R,_]=React$2.useState(!1),w=React$2.useRef({url:"",cc:"tts"}),C=React$2.useCallback(F=>h({type:"translate",payload:F}),[h]),N=React$2.useCallback(({id:F,type:M="base"})=>{var z;const I=C("usedVoices"),$=C("gameCharacters");return M==="base"?I==null?void 0:I[F]:M==="character"?(z=$==null?void 0:$[F])==null?void 0:z.voiceId:null},[C]),P=React$2.useCallback((F,M="tts")=>{w.current.url!==F&&(w.current={url:F,cc:M},v(F,M,t,f,u,E,p))},[v,t,f,u,E,p]),D=React$2.useCallback(async F=>{if(R&&F.voiceId&&F.text){let M=ttsCache[`${F.voiceId}_${F.text}`];try{M||(M=await h({type:"getSpeech",payload:F}),ttsCache[`${F.voiceId}_${F.text}`]=M),P(M)}catch{p()}}else p()},[h,R,p,P]),k=React$2.useCallback(()=>{w.current.url&&S(w.current.cc)},[S]);return React$2.useEffect(()=>(_(!0),()=>{_(!1),k()}),[k]),React$2.useEffect(()=>{T?g():y()},[g,T,y]),React$2.useEffect(()=>{b&&k()},[b,k]),React$2.useEffect(()=>{if(R&&a)if(n==="voice"&&(l!=null&&l.id)){const F=N(l);D({voiceId:F,text:e})}else(n==="file"||!n)&&o?P(o==null?void 0:o.url):p()},[o,n,N,R,p,D,P,a,e,l]),k},cleanTextOfHtmlTags=l=>{const e=/<\/p>|<\/h1>|<\/h2>|<\/h3>|<\/h4>|<\/h5>|<\/h6>|<\/li>/gi,n=/&quot;/gi;if(l)return l.replace(e,"").replace(n,"").replace(/(<([^>]+)>)/gi,"")},READING_TIME=.2;function LecturesComponent({emitEvent:l,getEvent:e,name:n,name_labelId:t,required:a,text:o,text_labelId:d,visible:h,documentType:f,viewed:u,soundActions:p,backgroundImage:E,hideBackgroundImageTheme:T=!1,keyboardControl:v,audio:S,audioType:g,audioVolume:y,voice:b,pause:R,styles:_}){const[w,C]=React$2.useState(),[N,P]=React$2.useState(!1),[D,k]=React$2.useState(0),F=o,M=Math.trunc(F.split(" ").length*READING_TIME),I=!a||a&&D>=M||a&&!h,[$]=p,z=`${n}. ${cleanTextOfHtmlTags(o)}`;useEkho({audioType:g,voice:b,text:z,audio:S,soundActions:p,getEvent:e,volume:y,pauseTTS:R});const X=J=>e({type:"translate",payload:J}),te=React$2.useCallback(()=>{I&&($("click-ui"),l({type:"finishMedia",payload:{name:t,type:"text",text:d,documentType:f}}))},[f,l,I,t,d,$]),ae=v({disabled:u,forward:te,escape:te});React$2.useEffect(()=>ae(),[ae]),React$2.useEffect(()=>{if(!h&&!N&&(te(),P(!0)),a&&h){const J=setInterval(()=>{k(H=>H+1)},1e3);return C(J),()=>{clearInterval(J)}}},[te,a,N,h]),React$2.useEffect(()=>{D===M&&clearInterval(w)},[w,D,M]);const ee=M-D,K=Math.floor(ee/60),ne=ee%60,ue=React$2.useMemo(()=>{let J="";return u?J="notes--results":(J="lectures--container",_&&(J+=` lectures--container--${_}`),E!=null&&E.url&&(J+=" lectures--container--with-custom-bg"),_&&T&&(J+=" disable-background-image")),J},[E==null?void 0:E.url,T,_,u]),pe={backgroundImage:E!=null&&E.url?`url('${E.url}')`:""};return h?jsxRuntimeExports.jsx("div",{className:ue,style:pe,children:jsxRuntimeExports.jsx("div",{className:u?"":"lectures__overlay",children:jsxRuntimeExports.jsxs("div",{className:u?"notes--results__text":`lectures lectures--${_}`,children:[jsxRuntimeExports.jsx("div",{className:"lectures--title",children:n}),jsxRuntimeExports.jsxs("div",{className:"lectures--text",dir:"auto",children:[jsxRuntimeExports.jsx("div",{children:F?HTMLReactParser$1(F):null}),u?null:jsxRuntimeExports.jsx(LectureButtons,{goToLecture:I,close:te,minutes:K,seconds:ne,btnText:X("screens.continue")})]})]})})}):null}LecturesComponent.defaultProps={emitEvent:()=>{},name:"",text:"",visible:!1,documentType:"",viewed:!1,required:!1,context:{},styles:""};function Slot({character:l,active:e,slot:n,lowQuality:t}){var T;const a=l.type==="image",o=l.type==="character",d=l.type==="object",h=(T=l==null?void 0:l.resource)==null?void 0:T.url,f=()=>a?`url(${h})`:o&&t?`url(${h.replace("character.glb","face.png")})`:d&&t?`url(${h.replace("object.glb","thumbnail.png")})`:"",u=()=>a?"contain":o||d?"auto 95%":"",p=()=>a?"center":o||d?"center bottom":"",E=a||t?{backgroundImage:f(),backgroundRepeat:"no-repeat",backgroundPosition:p(),backgroundSize:u()}:{};return jsxRuntimeExports.jsx("div",{className:`conversation--character__item ${e?"active":""} ${n}`,style:E,children:e&&l.name?jsxRuntimeExports.jsx("span",{className:"conversation--character__name",children:l.name}):null},l.name)}Slot.propTypes={character:PropTypes.shape({name:PropTypes.string,url:PropTypes.string,type:PropTypes.string,emotion:PropTypes.string,uid:PropTypes.string,resource:PropTypes.shape({resourceId:PropTypes.string,url:PropTypes.string})}),active:PropTypes.bool,slot:PropTypes.number};Slot.defaultProps={character:{name:"",url:"",type:"",resource:{resourceId:""}},active:!1,slot:0};function toTrianglesDrawMode(l,e){if(e===three.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===three.TriangleFanDrawMode||e===three.TriangleStripDrawMode){let n=l.getIndex();if(n===null){const d=[],h=l.getAttribute("position");if(h!==void 0){for(let f=0;f<h.count;f++)d.push(f);l.setIndex(d),n=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const t=n.count-2,a=[];if(e===three.TriangleFanDrawMode)for(let d=1;d<=t;d++)a.push(n.getX(0)),a.push(n.getX(d)),a.push(n.getX(d+1));else for(let d=0;d<t;d++)d%2===0?(a.push(n.getX(d)),a.push(n.getX(d+1)),a.push(n.getX(d+2))):(a.push(n.getX(d+2)),a.push(n.getX(d+1)),a.push(n.getX(d)));a.length/3!==t&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=l.clone();return o.setIndex(a),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}class GLTFLoader extends three.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(n){return new GLTFMaterialsClearcoatExtension(n)}),this.register(function(n){return new GLTFTextureBasisUExtension(n)}),this.register(function(n){return new GLTFTextureWebPExtension(n)}),this.register(function(n){return new GLTFTextureAVIFExtension(n)}),this.register(function(n){return new GLTFMaterialsSheenExtension(n)}),this.register(function(n){return new GLTFMaterialsTransmissionExtension(n)}),this.register(function(n){return new GLTFMaterialsVolumeExtension(n)}),this.register(function(n){return new GLTFMaterialsIorExtension(n)}),this.register(function(n){return new GLTFMaterialsEmissiveStrengthExtension(n)}),this.register(function(n){return new GLTFMaterialsSpecularExtension(n)}),this.register(function(n){return new GLTFMaterialsIridescenceExtension(n)}),this.register(function(n){return new GLTFMaterialsAnisotropyExtension(n)}),this.register(function(n){return new GLTFMaterialsBumpExtension(n)}),this.register(function(n){return new GLTFLightsExtension(n)}),this.register(function(n){return new GLTFMeshoptCompression(n)}),this.register(function(n){return new GLTFMeshGpuInstancing(n)})}load(e,n,t,a){const o=this;let d;if(this.resourcePath!=="")d=this.resourcePath;else if(this.path!==""){const u=three.LoaderUtils.extractUrlBase(e);d=three.LoaderUtils.resolveURL(u,this.path)}else d=three.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const h=function(u){a?a(u):console.error(u),o.manager.itemError(e),o.manager.itemEnd(e)},f=new three.FileLoader(this.manager);f.setPath(this.path),f.setResponseType("arraybuffer"),f.setRequestHeader(this.requestHeader),f.setWithCredentials(this.withCredentials),f.load(e,function(u){try{o.parse(u,d,function(p){n(p),o.manager.itemEnd(e)},h)}catch(p){h(p)}},t,h)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,n,t,a){let o;const d={},h={},f=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(f.decode(new Uint8Array(e,0,4))===BINARY_EXTENSION_HEADER_MAGIC){try{d[EXTENSIONS.KHR_BINARY_GLTF]=new GLTFBinaryExtension(e)}catch(E){a&&a(E);return}o=JSON.parse(d[EXTENSIONS.KHR_BINARY_GLTF].content)}else o=JSON.parse(f.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){a&&a(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const u=new GLTFParser(o,{path:n||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let p=0;p<this.pluginCallbacks.length;p++){const E=this.pluginCallbacks[p](u);E.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),h[E.name]=E,d[E.name]=!0}if(o.extensionsUsed)for(let p=0;p<o.extensionsUsed.length;++p){const E=o.extensionsUsed[p],T=o.extensionsRequired||[];switch(E){case EXTENSIONS.KHR_MATERIALS_UNLIT:d[E]=new GLTFMaterialsUnlitExtension;break;case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:d[E]=new GLTFDracoMeshCompressionExtension(o,this.dracoLoader);break;case EXTENSIONS.KHR_TEXTURE_TRANSFORM:d[E]=new GLTFTextureTransformExtension;break;case EXTENSIONS.KHR_MESH_QUANTIZATION:d[E]=new GLTFMeshQuantizationExtension;break;default:T.indexOf(E)>=0&&h[E]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+E+'".')}}u.setExtensions(d),u.setPlugins(h),u.parse(t,a)}parseAsync(e,n){const t=this;return new Promise(function(a,o){t.parse(e,n,a,o)})}}function GLTFRegistry(){let l={};return{get:function(e){return l[e]},add:function(e,n){l[e]=n},remove:function(e){delete l[e]},removeAll:function(){l={}}}}const EXTENSIONS={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class GLTFLightsExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,n=this.parser.json.nodes||[];for(let t=0,a=n.length;t<a;t++){const o=n[t];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const n=this.parser,t="light:"+e;let a=n.cache.get(t);if(a)return a;const o=n.json,f=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let u;const p=new three.Color(16777215);f.color!==void 0&&p.setRGB(f.color[0],f.color[1],f.color[2],three.LinearSRGBColorSpace);const E=f.range!==void 0?f.range:0;switch(f.type){case"directional":u=new three.DirectionalLight(p),u.target.position.set(0,0,-1),u.add(u.target);break;case"point":u=new three.PointLight(p),u.distance=E;break;case"spot":u=new three.SpotLight(p),u.distance=E,f.spot=f.spot||{},f.spot.innerConeAngle=f.spot.innerConeAngle!==void 0?f.spot.innerConeAngle:0,f.spot.outerConeAngle=f.spot.outerConeAngle!==void 0?f.spot.outerConeAngle:Math.PI/4,u.angle=f.spot.outerConeAngle,u.penumbra=1-f.spot.innerConeAngle/f.spot.outerConeAngle,u.target.position.set(0,0,-1),u.add(u.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+f.type)}return u.position.set(0,0,0),u.decay=2,assignExtrasToUserData(u,f),f.intensity!==void 0&&(u.intensity=f.intensity),u.name=n.createUniqueName(f.name||"light_"+e),a=Promise.resolve(u),n.cache.add(t,a),a}getDependency(e,n){if(e==="light")return this._loadLight(n)}createNodeAttachment(e){const n=this,t=this.parser,o=t.json.nodes[e],h=(o.extensions&&o.extensions[this.name]||{}).light;return h===void 0?null:this._loadLight(h).then(function(f){return t._getNodeRef(n.cache,h,f)})}}class GLTFMaterialsUnlitExtension{constructor(){this.name=EXTENSIONS.KHR_MATERIALS_UNLIT}getMaterialType(){return three.MeshBasicMaterial}extendParams(e,n,t){const a=[];e.color=new three.Color(1,1,1),e.opacity=1;const o=n.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const d=o.baseColorFactor;e.color.setRGB(d[0],d[1],d[2],three.LinearSRGBColorSpace),e.opacity=d[3]}o.baseColorTexture!==void 0&&a.push(t.assignTexture(e,"map",o.baseColorTexture,three.SRGBColorSpace))}return Promise.all(a)}}class GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=a.extensions[this.name].emissiveStrength;return o!==void 0&&(n.emissiveIntensity=o),Promise.resolve()}}class GLTFMaterialsClearcoatExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];if(d.clearcoatFactor!==void 0&&(n.clearcoat=d.clearcoatFactor),d.clearcoatTexture!==void 0&&o.push(t.assignTexture(n,"clearcoatMap",d.clearcoatTexture)),d.clearcoatRoughnessFactor!==void 0&&(n.clearcoatRoughness=d.clearcoatRoughnessFactor),d.clearcoatRoughnessTexture!==void 0&&o.push(t.assignTexture(n,"clearcoatRoughnessMap",d.clearcoatRoughnessTexture)),d.clearcoatNormalTexture!==void 0&&(o.push(t.assignTexture(n,"clearcoatNormalMap",d.clearcoatNormalTexture)),d.clearcoatNormalTexture.scale!==void 0)){const h=d.clearcoatNormalTexture.scale;n.clearcoatNormalScale=new three.Vector2(h,h)}return Promise.all(o)}}class GLTFMaterialsIridescenceExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.iridescenceFactor!==void 0&&(n.iridescence=d.iridescenceFactor),d.iridescenceTexture!==void 0&&o.push(t.assignTexture(n,"iridescenceMap",d.iridescenceTexture)),d.iridescenceIor!==void 0&&(n.iridescenceIOR=d.iridescenceIor),n.iridescenceThicknessRange===void 0&&(n.iridescenceThicknessRange=[100,400]),d.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessRange[0]=d.iridescenceThicknessMinimum),d.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessRange[1]=d.iridescenceThicknessMaximum),d.iridescenceThicknessTexture!==void 0&&o.push(t.assignTexture(n,"iridescenceThicknessMap",d.iridescenceThicknessTexture)),Promise.all(o)}}class GLTFMaterialsSheenExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[];n.sheenColor=new three.Color(0,0,0),n.sheenRoughness=0,n.sheen=1;const d=a.extensions[this.name];if(d.sheenColorFactor!==void 0){const h=d.sheenColorFactor;n.sheenColor.setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace)}return d.sheenRoughnessFactor!==void 0&&(n.sheenRoughness=d.sheenRoughnessFactor),d.sheenColorTexture!==void 0&&o.push(t.assignTexture(n,"sheenColorMap",d.sheenColorTexture,three.SRGBColorSpace)),d.sheenRoughnessTexture!==void 0&&o.push(t.assignTexture(n,"sheenRoughnessMap",d.sheenRoughnessTexture)),Promise.all(o)}}class GLTFMaterialsTransmissionExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.transmissionFactor!==void 0&&(n.transmission=d.transmissionFactor),d.transmissionTexture!==void 0&&o.push(t.assignTexture(n,"transmissionMap",d.transmissionTexture)),Promise.all(o)}}class GLTFMaterialsVolumeExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];n.thickness=d.thicknessFactor!==void 0?d.thicknessFactor:0,d.thicknessTexture!==void 0&&o.push(t.assignTexture(n,"thicknessMap",d.thicknessTexture)),n.attenuationDistance=d.attenuationDistance||1/0;const h=d.attenuationColor||[1,1,1];return n.attenuationColor=new three.Color().setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace),Promise.all(o)}}class GLTFMaterialsIorExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=a.extensions[this.name];return n.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class GLTFMaterialsSpecularExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];n.specularIntensity=d.specularFactor!==void 0?d.specularFactor:1,d.specularTexture!==void 0&&o.push(t.assignTexture(n,"specularIntensityMap",d.specularTexture));const h=d.specularColorFactor||[1,1,1];return n.specularColor=new three.Color().setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace),d.specularColorTexture!==void 0&&o.push(t.assignTexture(n,"specularColorMap",d.specularColorTexture,three.SRGBColorSpace)),Promise.all(o)}}class GLTFMaterialsBumpExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return n.bumpScale=d.bumpFactor!==void 0?d.bumpFactor:1,d.bumpTexture!==void 0&&o.push(t.assignTexture(n,"bumpMap",d.bumpTexture)),Promise.all(o)}}class GLTFMaterialsAnisotropyExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.anisotropyStrength!==void 0&&(n.anisotropy=d.anisotropyStrength),d.anisotropyRotation!==void 0&&(n.anisotropyRotation=d.anisotropyRotation),d.anisotropyTexture!==void 0&&o.push(t.assignTexture(n,"anisotropyMap",d.anisotropyTexture)),Promise.all(o)}}class GLTFTextureBasisUExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_TEXTURE_BASISU}loadTexture(e){const n=this.parser,t=n.json,a=t.textures[e];if(!a.extensions||!a.extensions[this.name])return null;const o=a.extensions[this.name],d=n.options.ktx2Loader;if(!d){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return n.loadTextureImage(e,o.source,d)}}class GLTFTextureWebPExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const n=this.name,t=this.parser,a=t.json,o=a.textures[e];if(!o.extensions||!o.extensions[n])return null;const d=o.extensions[n],h=a.images[d.source];let f=t.textureLoader;if(h.uri){const u=t.options.manager.getHandler(h.uri);u!==null&&(f=u)}return this.detectSupport().then(function(u){if(u)return t.loadTextureImage(e,d.source,f);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return t.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class GLTFTextureAVIFExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const n=this.name,t=this.parser,a=t.json,o=a.textures[e];if(!o.extensions||!o.extensions[n])return null;const d=o.extensions[n],h=a.images[d.source];let f=t.textureLoader;if(h.uri){const u=t.options.manager.getHandler(h.uri);u!==null&&(f=u)}return this.detectSupport().then(function(u){if(u)return t.loadTextureImage(e,d.source,f);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return t.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class GLTFMeshoptCompression{constructor(e){this.name=EXTENSIONS.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const n=this.parser.json,t=n.bufferViews[e];if(t.extensions&&t.extensions[this.name]){const a=t.extensions[this.name],o=this.parser.getDependency("buffer",a.buffer),d=this.parser.options.meshoptDecoder;if(!d||!d.supported){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(h){const f=a.byteOffset||0,u=a.byteLength||0,p=a.count,E=a.byteStride,T=new Uint8Array(h,f,u);return d.decodeGltfBufferAsync?d.decodeGltfBufferAsync(p,E,T,a.mode,a.filter).then(function(v){return v.buffer}):d.ready.then(function(){const v=new ArrayBuffer(p*E);return d.decodeGltfBuffer(new Uint8Array(v),p,E,T,a.mode,a.filter),v})})}else return null}}class GLTFMeshGpuInstancing{constructor(e){this.name=EXTENSIONS.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const n=this.parser.json,t=n.nodes[e];if(!t.extensions||!t.extensions[this.name]||t.mesh===void 0)return null;const a=n.meshes[t.mesh];for(const u of a.primitives)if(u.mode!==WEBGL_CONSTANTS.TRIANGLES&&u.mode!==WEBGL_CONSTANTS.TRIANGLE_STRIP&&u.mode!==WEBGL_CONSTANTS.TRIANGLE_FAN&&u.mode!==void 0)return null;const d=t.extensions[this.name].attributes,h=[],f={};for(const u in d)h.push(this.parser.getDependency("accessor",d[u]).then(p=>(f[u]=p,f[u])));return h.length<1?null:(h.push(this.parser.createNodeMesh(e)),Promise.all(h).then(u=>{const p=u.pop(),E=p.isGroup?p.children:[p],T=u[0].count,v=[];for(const S of E){const g=new three.Matrix4,y=new three.Vector3,b=new three.Quaternion,R=new three.Vector3(1,1,1),_=new three.InstancedMesh(S.geometry,S.material,T);for(let w=0;w<T;w++)f.TRANSLATION&&y.fromBufferAttribute(f.TRANSLATION,w),f.ROTATION&&b.fromBufferAttribute(f.ROTATION,w),f.SCALE&&R.fromBufferAttribute(f.SCALE,w),_.setMatrixAt(w,g.compose(y,b,R));for(const w in f)if(w==="_COLOR_0"){const C=f[w];_.instanceColor=new three.InstancedBufferAttribute(C.array,C.itemSize,C.normalized)}else w!=="TRANSLATION"&&w!=="ROTATION"&&w!=="SCALE"&&S.geometry.setAttribute(w,f[w]);three.Object3D.prototype.copy.call(_,S),this.parser.assignFinalMaterial(_),v.push(_)}return p.isGroup?(p.clear(),p.add(...v),p):v[0]}))}}const BINARY_EXTENSION_HEADER_MAGIC="glTF",BINARY_EXTENSION_HEADER_LENGTH=12,BINARY_EXTENSION_CHUNK_TYPES={JSON:1313821514,BIN:5130562};class GLTFBinaryExtension{constructor(e){this.name=EXTENSIONS.KHR_BINARY_GLTF,this.content=null,this.body=null;const n=new DataView(e,0,BINARY_EXTENSION_HEADER_LENGTH),t=new TextDecoder;if(this.header={magic:t.decode(new Uint8Array(e.slice(0,4))),version:n.getUint32(4,!0),length:n.getUint32(8,!0)},this.header.magic!==BINARY_EXTENSION_HEADER_MAGIC)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const a=this.header.length-BINARY_EXTENSION_HEADER_LENGTH,o=new DataView(e,BINARY_EXTENSION_HEADER_LENGTH);let d=0;for(;d<a;){const h=o.getUint32(d,!0);d+=4;const f=o.getUint32(d,!0);if(d+=4,f===BINARY_EXTENSION_CHUNK_TYPES.JSON){const u=new Uint8Array(e,BINARY_EXTENSION_HEADER_LENGTH+d,h);this.content=t.decode(u)}else if(f===BINARY_EXTENSION_CHUNK_TYPES.BIN){const u=BINARY_EXTENSION_HEADER_LENGTH+d;this.body=e.slice(u,u+h)}d+=h}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class GLTFDracoMeshCompressionExtension{constructor(e,n){if(!n)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=EXTENSIONS.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=n,this.dracoLoader.preload()}decodePrimitive(e,n){const t=this.json,a=this.dracoLoader,o=e.extensions[this.name].bufferView,d=e.extensions[this.name].attributes,h={},f={},u={};for(const p in d){const E=ATTRIBUTES[p]||p.toLowerCase();h[E]=d[p]}for(const p in e.attributes){const E=ATTRIBUTES[p]||p.toLowerCase();if(d[p]!==void 0){const T=t.accessors[e.attributes[p]],v=WEBGL_COMPONENT_TYPES[T.componentType];u[E]=v.name,f[E]=T.normalized===!0}}return n.getDependency("bufferView",o).then(function(p){return new Promise(function(E,T){a.decodeDracoFile(p,function(v){for(const S in v.attributes){const g=v.attributes[S],y=f[S];y!==void 0&&(g.normalized=y)}E(v)},h,u,three.LinearSRGBColorSpace,T)})})}}class GLTFTextureTransformExtension{constructor(){this.name=EXTENSIONS.KHR_TEXTURE_TRANSFORM}extendTexture(e,n){return(n.texCoord===void 0||n.texCoord===e.channel)&&n.offset===void 0&&n.rotation===void 0&&n.scale===void 0||(e=e.clone(),n.texCoord!==void 0&&(e.channel=n.texCoord),n.offset!==void 0&&e.offset.fromArray(n.offset),n.rotation!==void 0&&(e.rotation=n.rotation),n.scale!==void 0&&e.repeat.fromArray(n.scale),e.needsUpdate=!0),e}}class GLTFMeshQuantizationExtension{constructor(){this.name=EXTENSIONS.KHR_MESH_QUANTIZATION}}class GLTFCubicSplineInterpolant extends three.Interpolant{constructor(e,n,t,a){super(e,n,t,a)}copySampleValue_(e){const n=this.resultBuffer,t=this.sampleValues,a=this.valueSize,o=e*a*3+a;for(let d=0;d!==a;d++)n[d]=t[o+d];return n}interpolate_(e,n,t,a){const o=this.resultBuffer,d=this.sampleValues,h=this.valueSize,f=h*2,u=h*3,p=a-n,E=(t-n)/p,T=E*E,v=T*E,S=e*u,g=S-u,y=-2*v+3*T,b=v-T,R=1-y,_=b-T+E;for(let w=0;w!==h;w++){const C=d[g+w+h],N=d[g+w+f]*p,P=d[S+w+h],D=d[S+w]*p;o[w]=R*C+_*N+y*P+b*D}return o}}const _q=new three.Quaternion;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(e,n,t,a){const o=super.interpolate_(e,n,t,a);return _q.fromArray(o).normalize().toArray(o),o}}const WEBGL_CONSTANTS={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},WEBGL_COMPONENT_TYPES={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},WEBGL_FILTERS={9728:three.NearestFilter,9729:three.LinearFilter,9984:three.NearestMipmapNearestFilter,9985:three.LinearMipmapNearestFilter,9986:three.NearestMipmapLinearFilter,9987:three.LinearMipmapLinearFilter},WEBGL_WRAPPINGS={33071:three.ClampToEdgeWrapping,33648:three.MirroredRepeatWrapping,10497:three.RepeatWrapping},WEBGL_TYPE_SIZES={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ATTRIBUTES={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},PATH_PROPERTIES={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},INTERPOLATION={CUBICSPLINE:void 0,LINEAR:three.InterpolateLinear,STEP:three.InterpolateDiscrete},ALPHA_MODES={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function createDefaultMaterial(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new three.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:three.FrontSide})),l.DefaultMaterial}function addUnknownExtensionsToUserData(l,e,n){for(const t in n.extensions)l[t]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[t]=n.extensions[t])}function assignExtrasToUserData(l,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(l.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function addMorphTargets(l,e,n){let t=!1,a=!1,o=!1;for(let u=0,p=e.length;u<p;u++){const E=e[u];if(E.POSITION!==void 0&&(t=!0),E.NORMAL!==void 0&&(a=!0),E.COLOR_0!==void 0&&(o=!0),t&&a&&o)break}if(!t&&!a&&!o)return Promise.resolve(l);const d=[],h=[],f=[];for(let u=0,p=e.length;u<p;u++){const E=e[u];if(t){const T=E.POSITION!==void 0?n.getDependency("accessor",E.POSITION):l.attributes.position;d.push(T)}if(a){const T=E.NORMAL!==void 0?n.getDependency("accessor",E.NORMAL):l.attributes.normal;h.push(T)}if(o){const T=E.COLOR_0!==void 0?n.getDependency("accessor",E.COLOR_0):l.attributes.color;f.push(T)}}return Promise.all([Promise.all(d),Promise.all(h),Promise.all(f)]).then(function(u){const p=u[0],E=u[1],T=u[2];return t&&(l.morphAttributes.position=p),a&&(l.morphAttributes.normal=E),o&&(l.morphAttributes.color=T),l.morphTargetsRelative=!0,l})}function updateMorphTargets(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let n=0,t=e.weights.length;n<t;n++)l.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(l.morphTargetInfluences.length===n.length){l.morphTargetDictionary={};for(let t=0,a=n.length;t<a;t++)l.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function createPrimitiveKey(l){let e;const n=l.extensions&&l.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION];if(n?e="draco:"+n.bufferView+":"+n.indices+":"+createAttributesKey(n.attributes):e=l.indices+":"+createAttributesKey(l.attributes)+":"+l.mode,l.targets!==void 0)for(let t=0,a=l.targets.length;t<a;t++)e+=":"+createAttributesKey(l.targets[t]);return e}function createAttributesKey(l){let e="";const n=Object.keys(l).sort();for(let t=0,a=n.length;t<a;t++)e+=n[t]+":"+l[n[t]]+";";return e}function getNormalizedComponentScale(l){switch(l){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function getImageURIMimeType(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const _identityMatrix=new three.Matrix4;class GLTFParser{constructor(e={},n={}){this.json=e,this.extensions={},this.plugins={},this.options=n,this.cache=new GLTFRegistry,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let t=!1,a=!1,o=-1;typeof navigator<"u"&&(t=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,a=navigator.userAgent.indexOf("Firefox")>-1,o=a?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||t||a&&o<98?this.textureLoader=new three.TextureLoader(this.options.manager):this.textureLoader=new three.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new three.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,n){const t=this,a=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(d){return d._markDefs&&d._markDefs()}),Promise.all(this._invokeAll(function(d){return d.beforeRoot&&d.beforeRoot()})).then(function(){return Promise.all([t.getDependencies("scene"),t.getDependencies("animation"),t.getDependencies("camera")])}).then(function(d){const h={scene:d[0][a.scene||0],scenes:d[0],animations:d[1],cameras:d[2],asset:a.asset,parser:t,userData:{}};return addUnknownExtensionsToUserData(o,h,a),assignExtrasToUserData(h,a),Promise.all(t._invokeAll(function(f){return f.afterRoot&&f.afterRoot(h)})).then(function(){e(h)})}).catch(n)}_markDefs(){const e=this.json.nodes||[],n=this.json.skins||[],t=this.json.meshes||[];for(let a=0,o=n.length;a<o;a++){const d=n[a].joints;for(let h=0,f=d.length;h<f;h++)e[d[h]].isBone=!0}for(let a=0,o=e.length;a<o;a++){const d=e[a];d.mesh!==void 0&&(this._addNodeRef(this.meshCache,d.mesh),d.skin!==void 0&&(t[d.mesh].isSkinnedMesh=!0)),d.camera!==void 0&&this._addNodeRef(this.cameraCache,d.camera)}}_addNodeRef(e,n){n!==void 0&&(e.refs[n]===void 0&&(e.refs[n]=e.uses[n]=0),e.refs[n]++)}_getNodeRef(e,n,t){if(e.refs[n]<=1)return t;const a=t.clone(),o=(d,h)=>{const f=this.associations.get(d);f!=null&&this.associations.set(h,f);for(const[u,p]of d.children.entries())o(p,h.children[u])};return o(t,a),a.name+="_instance_"+e.uses[n]++,a}_invokeOne(e){const n=Object.values(this.plugins);n.push(this);for(let t=0;t<n.length;t++){const a=e(n[t]);if(a)return a}return null}_invokeAll(e){const n=Object.values(this.plugins);n.unshift(this);const t=[];for(let a=0;a<n.length;a++){const o=e(n[a]);o&&t.push(o)}return t}getDependency(e,n){const t=e+":"+n;let a=this.cache.get(t);if(!a){switch(e){case"scene":a=this.loadScene(n);break;case"node":a=this._invokeOne(function(o){return o.loadNode&&o.loadNode(n)});break;case"mesh":a=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(n)});break;case"accessor":a=this.loadAccessor(n);break;case"bufferView":a=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(n)});break;case"buffer":a=this.loadBuffer(n);break;case"material":a=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(n)});break;case"texture":a=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(n)});break;case"skin":a=this.loadSkin(n);break;case"animation":a=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(n)});break;case"camera":a=this.loadCamera(n);break;default:if(a=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,n)}),!a)throw new Error("Unknown type: "+e);break}this.cache.add(t,a)}return a}getDependencies(e){let n=this.cache.get(e);if(!n){const t=this,a=this.json[e+(e==="mesh"?"es":"s")]||[];n=Promise.all(a.map(function(o,d){return t.getDependency(e,d)})),this.cache.add(e,n)}return n}loadBuffer(e){const n=this.json.buffers[e],t=this.fileLoader;if(n.type&&n.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+n.type+" buffer type is not supported.");if(n.uri===void 0&&e===0)return Promise.resolve(this.extensions[EXTENSIONS.KHR_BINARY_GLTF].body);const a=this.options;return new Promise(function(o,d){t.load(three.LoaderUtils.resolveURL(n.uri,a.path),o,void 0,function(){d(new Error('THREE.GLTFLoader: Failed to load buffer "'+n.uri+'".'))})})}loadBufferView(e){const n=this.json.bufferViews[e];return this.getDependency("buffer",n.buffer).then(function(t){const a=n.byteLength||0,o=n.byteOffset||0;return t.slice(o,o+a)})}loadAccessor(e){const n=this,t=this.json,a=this.json.accessors[e];if(a.bufferView===void 0&&a.sparse===void 0){const d=WEBGL_TYPE_SIZES[a.type],h=WEBGL_COMPONENT_TYPES[a.componentType],f=a.normalized===!0,u=new h(a.count*d);return Promise.resolve(new three.BufferAttribute(u,d,f))}const o=[];return a.bufferView!==void 0?o.push(this.getDependency("bufferView",a.bufferView)):o.push(null),a.sparse!==void 0&&(o.push(this.getDependency("bufferView",a.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",a.sparse.values.bufferView))),Promise.all(o).then(function(d){const h=d[0],f=WEBGL_TYPE_SIZES[a.type],u=WEBGL_COMPONENT_TYPES[a.componentType],p=u.BYTES_PER_ELEMENT,E=p*f,T=a.byteOffset||0,v=a.bufferView!==void 0?t.bufferViews[a.bufferView].byteStride:void 0,S=a.normalized===!0;let g,y;if(v&&v!==E){const b=Math.floor(T/v),R="InterleavedBuffer:"+a.bufferView+":"+a.componentType+":"+b+":"+a.count;let _=n.cache.get(R);_||(g=new u(h,b*v,a.count*v/p),_=new three.InterleavedBuffer(g,v/p),n.cache.add(R,_)),y=new three.InterleavedBufferAttribute(_,f,T%v/p,S)}else h===null?g=new u(a.count*f):g=new u(h,T,a.count*f),y=new three.BufferAttribute(g,f,S);if(a.sparse!==void 0){const b=WEBGL_TYPE_SIZES.SCALAR,R=WEBGL_COMPONENT_TYPES[a.sparse.indices.componentType],_=a.sparse.indices.byteOffset||0,w=a.sparse.values.byteOffset||0,C=new R(d[1],_,a.sparse.count*b),N=new u(d[2],w,a.sparse.count*f);h!==null&&(y=new three.BufferAttribute(y.array.slice(),y.itemSize,y.normalized));for(let P=0,D=C.length;P<D;P++){const k=C[P];if(y.setX(k,N[P*f]),f>=2&&y.setY(k,N[P*f+1]),f>=3&&y.setZ(k,N[P*f+2]),f>=4&&y.setW(k,N[P*f+3]),f>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return y})}loadTexture(e){const n=this.json,t=this.options,o=n.textures[e].source,d=n.images[o];let h=this.textureLoader;if(d.uri){const f=t.manager.getHandler(d.uri);f!==null&&(h=f)}return this.loadTextureImage(e,o,h)}loadTextureImage(e,n,t){const a=this,o=this.json,d=o.textures[e],h=o.images[n],f=(h.uri||h.bufferView)+":"+d.sampler;if(this.textureCache[f])return this.textureCache[f];const u=this.loadImageSource(n,t).then(function(p){p.flipY=!1,p.name=d.name||h.name||"",p.name===""&&typeof h.uri=="string"&&h.uri.startsWith("data:image/")===!1&&(p.name=h.uri);const T=(o.samplers||{})[d.sampler]||{};return p.magFilter=WEBGL_FILTERS[T.magFilter]||three.LinearFilter,p.minFilter=WEBGL_FILTERS[T.minFilter]||three.LinearMipmapLinearFilter,p.wrapS=WEBGL_WRAPPINGS[T.wrapS]||three.RepeatWrapping,p.wrapT=WEBGL_WRAPPINGS[T.wrapT]||three.RepeatWrapping,a.associations.set(p,{textures:e}),p}).catch(function(){return null});return this.textureCache[f]=u,u}loadImageSource(e,n){const t=this,a=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(E=>E.clone());const d=a.images[e],h=self.URL||self.webkitURL;let f=d.uri||"",u=!1;if(d.bufferView!==void 0)f=t.getDependency("bufferView",d.bufferView).then(function(E){u=!0;const T=new Blob([E],{type:d.mimeType});return f=h.createObjectURL(T),f});else if(d.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const p=Promise.resolve(f).then(function(E){return new Promise(function(T,v){let S=T;n.isImageBitmapLoader===!0&&(S=function(g){const y=new three.Texture(g);y.needsUpdate=!0,T(y)}),n.load(three.LoaderUtils.resolveURL(E,o.path),S,void 0,v)})}).then(function(E){return u===!0&&h.revokeObjectURL(f),E.userData.mimeType=d.mimeType||getImageURIMimeType(d.uri),E}).catch(function(E){throw console.error("THREE.GLTFLoader: Couldn't load texture",f),E});return this.sourceCache[e]=p,p}assignTexture(e,n,t,a){const o=this;return this.getDependency("texture",t.index).then(function(d){if(!d)return null;if(t.texCoord!==void 0&&t.texCoord>0&&(d=d.clone(),d.channel=t.texCoord),o.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]){const h=t.extensions!==void 0?t.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]:void 0;if(h){const f=o.associations.get(d);d=o.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM].extendTexture(d,h),o.associations.set(d,f)}}return a!==void 0&&(d.colorSpace=a),e[n]=d,d})}assignFinalMaterial(e){const n=e.geometry;let t=e.material;const a=n.attributes.tangent===void 0,o=n.attributes.color!==void 0,d=n.attributes.normal===void 0;if(e.isPoints){const h="PointsMaterial:"+t.uuid;let f=this.cache.get(h);f||(f=new three.PointsMaterial,three.Material.prototype.copy.call(f,t),f.color.copy(t.color),f.map=t.map,f.sizeAttenuation=!1,this.cache.add(h,f)),t=f}else if(e.isLine){const h="LineBasicMaterial:"+t.uuid;let f=this.cache.get(h);f||(f=new three.LineBasicMaterial,three.Material.prototype.copy.call(f,t),f.color.copy(t.color),f.map=t.map,this.cache.add(h,f)),t=f}if(a||o||d){let h="ClonedMaterial:"+t.uuid+":";a&&(h+="derivative-tangents:"),o&&(h+="vertex-colors:"),d&&(h+="flat-shading:");let f=this.cache.get(h);f||(f=t.clone(),o&&(f.vertexColors=!0),d&&(f.flatShading=!0),a&&(f.normalScale&&(f.normalScale.y*=-1),f.clearcoatNormalScale&&(f.clearcoatNormalScale.y*=-1)),this.cache.add(h,f),this.associations.set(f,this.associations.get(t))),t=f}e.material=t}getMaterialType(){return three.MeshStandardMaterial}loadMaterial(e){const n=this,t=this.json,a=this.extensions,o=t.materials[e];let d;const h={},f=o.extensions||{},u=[];if(f[EXTENSIONS.KHR_MATERIALS_UNLIT]){const E=a[EXTENSIONS.KHR_MATERIALS_UNLIT];d=E.getMaterialType(),u.push(E.extendParams(h,o,n))}else{const E=o.pbrMetallicRoughness||{};if(h.color=new three.Color(1,1,1),h.opacity=1,Array.isArray(E.baseColorFactor)){const T=E.baseColorFactor;h.color.setRGB(T[0],T[1],T[2],three.LinearSRGBColorSpace),h.opacity=T[3]}E.baseColorTexture!==void 0&&u.push(n.assignTexture(h,"map",E.baseColorTexture,three.SRGBColorSpace)),h.metalness=E.metallicFactor!==void 0?E.metallicFactor:1,h.roughness=E.roughnessFactor!==void 0?E.roughnessFactor:1,E.metallicRoughnessTexture!==void 0&&(u.push(n.assignTexture(h,"metalnessMap",E.metallicRoughnessTexture)),u.push(n.assignTexture(h,"roughnessMap",E.metallicRoughnessTexture))),d=this._invokeOne(function(T){return T.getMaterialType&&T.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(T){return T.extendMaterialParams&&T.extendMaterialParams(e,h)})))}o.doubleSided===!0&&(h.side=three.DoubleSide);const p=o.alphaMode||ALPHA_MODES.OPAQUE;if(p===ALPHA_MODES.BLEND?(h.transparent=!0,h.depthWrite=!1):(h.transparent=!1,p===ALPHA_MODES.MASK&&(h.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&d!==three.MeshBasicMaterial&&(u.push(n.assignTexture(h,"normalMap",o.normalTexture)),h.normalScale=new three.Vector2(1,1),o.normalTexture.scale!==void 0)){const E=o.normalTexture.scale;h.normalScale.set(E,E)}if(o.occlusionTexture!==void 0&&d!==three.MeshBasicMaterial&&(u.push(n.assignTexture(h,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(h.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&d!==three.MeshBasicMaterial){const E=o.emissiveFactor;h.emissive=new three.Color().setRGB(E[0],E[1],E[2],three.LinearSRGBColorSpace)}return o.emissiveTexture!==void 0&&d!==three.MeshBasicMaterial&&u.push(n.assignTexture(h,"emissiveMap",o.emissiveTexture,three.SRGBColorSpace)),Promise.all(u).then(function(){const E=new d(h);return o.name&&(E.name=o.name),assignExtrasToUserData(E,o),n.associations.set(E,{materials:e}),o.extensions&&addUnknownExtensionsToUserData(a,E,o),E})}createUniqueName(e){const n=three.PropertyBinding.sanitizeNodeName(e||"");return n in this.nodeNamesUsed?n+"_"+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(e){const n=this,t=this.extensions,a=this.primitiveCache;function o(h){return t[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(h,n).then(function(f){return addPrimitiveAttributes(f,h,n)})}const d=[];for(let h=0,f=e.length;h<f;h++){const u=e[h],p=createPrimitiveKey(u),E=a[p];if(E)d.push(E.promise);else{let T;u.extensions&&u.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]?T=o(u):T=addPrimitiveAttributes(new three.BufferGeometry,u,n),a[p]={primitive:u,promise:T},d.push(T)}}return Promise.all(d)}loadMesh(e){const n=this,t=this.json,a=this.extensions,o=t.meshes[e],d=o.primitives,h=[];for(let f=0,u=d.length;f<u;f++){const p=d[f].material===void 0?createDefaultMaterial(this.cache):this.getDependency("material",d[f].material);h.push(p)}return h.push(n.loadGeometries(d)),Promise.all(h).then(function(f){const u=f.slice(0,f.length-1),p=f[f.length-1],E=[];for(let v=0,S=p.length;v<S;v++){const g=p[v],y=d[v];let b;const R=u[v];if(y.mode===WEBGL_CONSTANTS.TRIANGLES||y.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP||y.mode===WEBGL_CONSTANTS.TRIANGLE_FAN||y.mode===void 0)b=o.isSkinnedMesh===!0?new three.SkinnedMesh(g,R):new three.Mesh(g,R),b.isSkinnedMesh===!0&&b.normalizeSkinWeights(),y.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP?b.geometry=toTrianglesDrawMode(b.geometry,three.TriangleStripDrawMode):y.mode===WEBGL_CONSTANTS.TRIANGLE_FAN&&(b.geometry=toTrianglesDrawMode(b.geometry,three.TriangleFanDrawMode));else if(y.mode===WEBGL_CONSTANTS.LINES)b=new three.LineSegments(g,R);else if(y.mode===WEBGL_CONSTANTS.LINE_STRIP)b=new three.Line(g,R);else if(y.mode===WEBGL_CONSTANTS.LINE_LOOP)b=new three.LineLoop(g,R);else if(y.mode===WEBGL_CONSTANTS.POINTS)b=new three.Points(g,R);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+y.mode);Object.keys(b.geometry.morphAttributes).length>0&&updateMorphTargets(b,o),b.name=n.createUniqueName(o.name||"mesh_"+e),assignExtrasToUserData(b,o),y.extensions&&addUnknownExtensionsToUserData(a,b,y),n.assignFinalMaterial(b),E.push(b)}for(let v=0,S=E.length;v<S;v++)n.associations.set(E[v],{meshes:e,primitives:v});if(E.length===1)return o.extensions&&addUnknownExtensionsToUserData(a,E[0],o),E[0];const T=new three.Group;o.extensions&&addUnknownExtensionsToUserData(a,T,o),n.associations.set(T,{meshes:e});for(let v=0,S=E.length;v<S;v++)T.add(E[v]);return T})}loadCamera(e){let n;const t=this.json.cameras[e],a=t[t.type];if(!a){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return t.type==="perspective"?n=new three.PerspectiveCamera(three.MathUtils.radToDeg(a.yfov),a.aspectRatio||1,a.znear||1,a.zfar||2e6):t.type==="orthographic"&&(n=new three.OrthographicCamera(-a.xmag,a.xmag,a.ymag,-a.ymag,a.znear,a.zfar)),t.name&&(n.name=this.createUniqueName(t.name)),assignExtrasToUserData(n,t),Promise.resolve(n)}loadSkin(e){const n=this.json.skins[e],t=[];for(let a=0,o=n.joints.length;a<o;a++)t.push(this._loadNodeShallow(n.joints[a]));return n.inverseBindMatrices!==void 0?t.push(this.getDependency("accessor",n.inverseBindMatrices)):t.push(null),Promise.all(t).then(function(a){const o=a.pop(),d=a,h=[],f=[];for(let u=0,p=d.length;u<p;u++){const E=d[u];if(E){h.push(E);const T=new three.Matrix4;o!==null&&T.fromArray(o.array,u*16),f.push(T)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',n.joints[u])}return new three.Skeleton(h,f)})}loadAnimation(e){const n=this.json,t=this,a=n.animations[e],o=a.name?a.name:"animation_"+e,d=[],h=[],f=[],u=[],p=[];for(let E=0,T=a.channels.length;E<T;E++){const v=a.channels[E],S=a.samplers[v.sampler],g=v.target,y=g.node,b=a.parameters!==void 0?a.parameters[S.input]:S.input,R=a.parameters!==void 0?a.parameters[S.output]:S.output;g.node!==void 0&&(d.push(this.getDependency("node",y)),h.push(this.getDependency("accessor",b)),f.push(this.getDependency("accessor",R)),u.push(S),p.push(g))}return Promise.all([Promise.all(d),Promise.all(h),Promise.all(f),Promise.all(u),Promise.all(p)]).then(function(E){const T=E[0],v=E[1],S=E[2],g=E[3],y=E[4],b=[];for(let R=0,_=T.length;R<_;R++){const w=T[R],C=v[R],N=S[R],P=g[R],D=y[R];if(w===void 0)continue;w.updateMatrix&&w.updateMatrix();const k=t._createAnimationTracks(w,C,N,P,D);if(k)for(let F=0;F<k.length;F++)b.push(k[F])}return new three.AnimationClip(o,void 0,b)})}createNodeMesh(e){const n=this.json,t=this,a=n.nodes[e];return a.mesh===void 0?null:t.getDependency("mesh",a.mesh).then(function(o){const d=t._getNodeRef(t.meshCache,a.mesh,o);return a.weights!==void 0&&d.traverse(function(h){if(h.isMesh)for(let f=0,u=a.weights.length;f<u;f++)h.morphTargetInfluences[f]=a.weights[f]}),d})}loadNode(e){const n=this.json,t=this,a=n.nodes[e],o=t._loadNodeShallow(e),d=[],h=a.children||[];for(let u=0,p=h.length;u<p;u++)d.push(t.getDependency("node",h[u]));const f=a.skin===void 0?Promise.resolve(null):t.getDependency("skin",a.skin);return Promise.all([o,Promise.all(d),f]).then(function(u){const p=u[0],E=u[1],T=u[2];T!==null&&p.traverse(function(v){v.isSkinnedMesh&&v.bind(T,_identityMatrix)});for(let v=0,S=E.length;v<S;v++)p.add(E[v]);return p})}_loadNodeShallow(e){const n=this.json,t=this.extensions,a=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=n.nodes[e],d=o.name?a.createUniqueName(o.name):"",h=[],f=a._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(e)});return f&&h.push(f),o.camera!==void 0&&h.push(a.getDependency("camera",o.camera).then(function(u){return a._getNodeRef(a.cameraCache,o.camera,u)})),a._invokeAll(function(u){return u.createNodeAttachment&&u.createNodeAttachment(e)}).forEach(function(u){h.push(u)}),this.nodeCache[e]=Promise.all(h).then(function(u){let p;if(o.isBone===!0?p=new three.Bone:u.length>1?p=new three.Group:u.length===1?p=u[0]:p=new three.Object3D,p!==u[0])for(let E=0,T=u.length;E<T;E++)p.add(u[E]);if(o.name&&(p.userData.name=o.name,p.name=d),assignExtrasToUserData(p,o),o.extensions&&addUnknownExtensionsToUserData(t,p,o),o.matrix!==void 0){const E=new three.Matrix4;E.fromArray(o.matrix),p.applyMatrix4(E)}else o.translation!==void 0&&p.position.fromArray(o.translation),o.rotation!==void 0&&p.quaternion.fromArray(o.rotation),o.scale!==void 0&&p.scale.fromArray(o.scale);return a.associations.has(p)||a.associations.set(p,{}),a.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const n=this.extensions,t=this.json.scenes[e],a=this,o=new three.Group;t.name&&(o.name=a.createUniqueName(t.name)),assignExtrasToUserData(o,t),t.extensions&&addUnknownExtensionsToUserData(n,o,t);const d=t.nodes||[],h=[];for(let f=0,u=d.length;f<u;f++)h.push(a.getDependency("node",d[f]));return Promise.all(h).then(function(f){for(let p=0,E=f.length;p<E;p++)o.add(f[p]);const u=p=>{const E=new Map;for(const[T,v]of a.associations)(T instanceof three.Material||T instanceof three.Texture)&&E.set(T,v);return p.traverse(T=>{const v=a.associations.get(T);v!=null&&E.set(T,v)}),E};return a.associations=u(o),o})}_createAnimationTracks(e,n,t,a,o){const d=[],h=e.name?e.name:e.uuid,f=[];PATH_PROPERTIES[o.path]===PATH_PROPERTIES.weights?e.traverse(function(T){T.morphTargetInfluences&&f.push(T.name?T.name:T.uuid)}):f.push(h);let u;switch(PATH_PROPERTIES[o.path]){case PATH_PROPERTIES.weights:u=three.NumberKeyframeTrack;break;case PATH_PROPERTIES.rotation:u=three.QuaternionKeyframeTrack;break;case PATH_PROPERTIES.position:case PATH_PROPERTIES.scale:u=three.VectorKeyframeTrack;break;default:switch(t.itemSize){case 1:u=three.NumberKeyframeTrack;break;case 2:case 3:default:u=three.VectorKeyframeTrack;break}break}const p=a.interpolation!==void 0?INTERPOLATION[a.interpolation]:three.InterpolateLinear,E=this._getArrayFromAccessor(t);for(let T=0,v=f.length;T<v;T++){const S=new u(f[T]+"."+PATH_PROPERTIES[o.path],n.array,E,p);a.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(S),d.push(S)}return d}_getArrayFromAccessor(e){let n=e.array;if(e.normalized){const t=getNormalizedComponentScale(n.constructor),a=new Float32Array(n.length);for(let o=0,d=n.length;o<d;o++)a[o]=n[o]*t;n=a}return n}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const a=this instanceof three.QuaternionKeyframeTrack?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant;return new a(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function computeBounds(l,e,n){const t=e.attributes,a=new three.Box3;if(t.POSITION!==void 0){const h=n.json.accessors[t.POSITION],f=h.min,u=h.max;if(f!==void 0&&u!==void 0){if(a.set(new three.Vector3(f[0],f[1],f[2]),new three.Vector3(u[0],u[1],u[2])),h.normalized){const p=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[h.componentType]);a.min.multiplyScalar(p),a.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const h=new three.Vector3,f=new three.Vector3;for(let u=0,p=o.length;u<p;u++){const E=o[u];if(E.POSITION!==void 0){const T=n.json.accessors[E.POSITION],v=T.min,S=T.max;if(v!==void 0&&S!==void 0){if(f.setX(Math.max(Math.abs(v[0]),Math.abs(S[0]))),f.setY(Math.max(Math.abs(v[1]),Math.abs(S[1]))),f.setZ(Math.max(Math.abs(v[2]),Math.abs(S[2]))),T.normalized){const g=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[T.componentType]);f.multiplyScalar(g)}h.max(f)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}a.expandByVector(h)}l.boundingBox=a;const d=new three.Sphere;a.getCenter(d.center),d.radius=a.min.distanceTo(a.max)/2,l.boundingSphere=d}function addPrimitiveAttributes(l,e,n){const t=e.attributes,a=[];function o(d,h){return n.getDependency("accessor",d).then(function(f){l.setAttribute(h,f)})}for(const d in t){const h=ATTRIBUTES[d]||d.toLowerCase();h in l.attributes||a.push(o(t[d],h))}if(e.indices!==void 0&&!l.index){const d=n.getDependency("accessor",e.indices).then(function(h){l.setIndex(h)});a.push(d)}return three.ColorManagement.workingColorSpace!==three.LinearSRGBColorSpace&&"COLOR_0"in t&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${three.ColorManagement.workingColorSpace}" not supported.`),assignExtrasToUserData(l,e),computeBounds(l,e,n),Promise.all(a).then(function(){return e.targets!==void 0?addMorphTargets(l,e.targets,n):l})}const defaultCamPos=[0,14.63,16],isMobile=DeviceDetection(),loader$1=new GLTFLoader,box=new three.Box3,worldPos=new three.Vector3,size=new three.Vector3;function Panel({character:l,ttsStarted:e,active:n,visible:t}){var v,S,g,y,b;const a=React$2.useRef(null),o=React$2.useRef(null),d=l.type==="character",[h,f]=React$2.useState(!1),u=React$2.useRef(),p=React$2.useMemo(()=>{var R,_,w,C,N,P,D,k;return d?l.animationId&&((R=l.animation)!=null&&R.url)?l.animation:(C=(w=(_=l==null?void 0:l.resource)==null?void 0:_.animations)==null?void 0:w[l.emotion])!=null&&C.url?(P=(N=l==null?void 0:l.resource)==null?void 0:N.animations)==null?void 0:P[l.emotion]:(k=(D=l==null?void 0:l.resource)==null?void 0:D.animations)==null?void 0:k.neutral:{}},[l.emotion,l==null?void 0:l.animationId,l==null?void 0:l.animation,(v=l==null?void 0:l.resource)==null?void 0:v.animations,d]),E=React$2.useCallback(()=>{if(u.current){const R=u.current.userData.animator;R.getAction("idle")&&R.mix("idle",.1)}},[]);React$2.useEffect(()=>{var R,_,w;if(t)if(n)if(e){const C=(w=(_=(R=l==null?void 0:l.resource)==null?void 0:R.animations)==null?void 0:_.talking)==null?void 0:w.url;if(C&&u.current){const N=u.current.userData.animator,P=`${C}_talking`;N.getAction(P)?(N.mix(P,.1),f(!0)):loader$1.load(C,({animations:D})=>{if(!u.current)return;const k=N.getAction("idle").getClip();N.register(P,mixWithTalkingClip(D[0],k)),N.mix(P,.1),f(!0)})}}else E();else h&&E()},[(y=(g=(S=l==null?void 0:l.resource)==null?void 0:S.animations)==null?void 0:g.talking)==null?void 0:y.url,e,n,E,h,t]);const T=React$2.useCallback(R=>{if(l.type==="character"){const _=R.getObjectByName("Head_M",!0);_?(_.updateMatrixWorld(!0),box.setFromObject(R),box.getSize(size),_.getWorldPosition(worldPos),a.current.lookAt(worldPos)):a.current.position.setY(size.y-1.5*1.3),a.current.zoom=1.5}else cameraFitAnyObject(R,a.current),a.current.zoom=1;a.current.updateProjectionMatrix()},[l]);return fiber.useFrame(({gl:R,scene:_})=>{if(a.current&&o.current){const w=document.querySelectorAll(".conversation--character__item")[l.slot];if(w){const C=w.getBoundingClientRect(),N=w.parentNode.getBoundingClientRect(),[P,D]=[C.right-C.left,C.bottom-C.top];if(a.current.aspect=P/D,a.current.updateProjectionMatrix(),d&&u.current){box.setFromObject(u.current),box.getSize(size);const M=u.current.getObjectByName("Head_M",!0);M?(M.getWorldPosition(worldPos),a.current.lookAt(worldPos)):a.current.position.setY(size.y-1.5*1.3),a.current.zoom=1.5}const k={top:C.top-N.top,right:C.right-N.right,left:C.left-N.left,bottom:C.bottom-N.bottom},F=isMobile?24:40;k.bottom+=n?-F:F,R.setViewport(k.left,k.bottom,P,D),R.setScissor(k.left,k.bottom,P,D),o.current.environment=_.environment,R.render(o.current,a.current)}}},1),l.type==="image"?null:jsxRuntimeExports.jsxs("scene",{ref:o,children:[(b=l.resource)!=null&&b.url?jsxRuntimeExports.jsx(arcadeThreeCore.SceneResource,{ref:u,name:`char_${l.uid}`,url:l.resource.url,animationUrl:p.url,type:l.type,onRender:T,texturable:!0,interactive:!0,merge:l.type!=="character",visible:t}):null,jsxRuntimeExports.jsx(drei.PerspectiveCamera,{ref:a,fov:35,position:defaultCamPos,rotation:[0,0,0],onUpdate:R=>{R.layers.enableAll()},manual:!0}),jsxRuntimeExports.jsx(LightSet,{})]})}function PanelsWrapper({characters:l,slots:e,ttsStarted:n,flex:t,currentMessage:a,lod:o}){const[d,h]=React$2.useState(!1);return fiber.useFrame(({gl:f})=>{f.setScissorTest(!1),f.clear(!0,!0),f.setScissorTest(!0)}),React$2.useEffect(()=>{const f=()=>{h(!0)};return arcadeThreeCore.ProgressManager.addEventListener("loaded",f),()=>{arcadeThreeCore.ProgressManager.removeEventListener("loaded",f)}},[]),jsxRuntimeExports.jsx(arcadeThreeCore.QualityManager,{lod:o,active:!0,children:e.map((f,u)=>{let p=null;const E=l.findIndex(T=>T&&T.uid===f.uid);if(E>=0){const T=t?E:u;return p={...l[E]},p.slot=T,jsxRuntimeExports.jsx(Panel,{character:p,active:a.position===T,ttsStarted:n,visible:d},`${`${p.uid}_${u}`}_${E}`)}return null})})}function Scene(l){return l.lowQuality?null:jsxRuntimeExports.jsxs(arcadeThreeCore.Renderer,{className:"conversation--canvas",style:{position:"absolute",width:"100%",height:"100%"},gl:{antialias:!0},fullscreen:!1,onCreated:({gl:e})=>{e.setClearColor("white",0)},children:[jsxRuntimeExports.jsx(arcadeThreeCore.SettingsController,{current:{animate:l.pause}}),jsxRuntimeExports.jsx(arcadeThreeCore.EnvironmentWrapper,{url:"https://min.gamelearn.io/statics/envs/envmap_1k.hdr"}),jsxRuntimeExports.jsx(PanelsWrapper,{...l})]})}function SlotList({characters:l,actors:e,lodSettings:n,ttsStarted:t,currentMessage:a,flex:o,slots:d,children:h,pause:f,getEvent:u}){const p=({character:b,active:R,slot:_})=>({character:b,active:R,emotion:R?a.emotion:"neutral",slot:_}),E=React$2.useMemo(()=>u({type:"currentLod"}),[u]),T=E==="divideby64",v=d.reduce((b,R)=>{var C,N;const _=e==null?void 0:e.find(P=>P.uid===R.uid),w={...R};if(R.character)w.name=R.alias||R.character.name,w.resource=w.character.resource,w.position=w.position>=0?w.position:-1,delete w.character,w.type="character",b.push(w);else if(_){const{resource:P}=_;w.name=R.alias||R.name,w.position=w.position>=0?w.position:-1,w.resource=P,w.type=_.type,b.push(w)}else R.type?(w.name=R.alias||((C=R.character)==null?void 0:C.name)||R.name,w.resource=((N=w.character)==null?void 0:N.resource)||R.resource,w.position=w.position>=0?w.position:-1,delete w.character,w.type=R.type,b.push(w)):o||b.push(null);return b},[]),S=v.length&&v.some(b=>b),g=l.filter(b=>d.find(R=>b.uid===R.uid));function y(){return S?v.map((b,R)=>b?jsxRuntimeExports.jsx(Slot,{lowQuality:T,...p({character:b,active:a.position===b.position,slot:R})},`${b.uid+R}`):jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${R}`},`void_${0+R}`)):o?g.map((b,R)=>{const _=a.position===R;return jsxRuntimeExports.jsx(Slot,{...p({character:b,active:_,slot:R})},`${b.uid+R}`)}):d.length>0?d.map((b,R)=>{const _=l.find(w=>w.uid===b.uid);if(_){const w=a.position===R;return _.name=b.alias||_.name,jsxRuntimeExports.jsx(Slot,{...p({character:_,active:w,slot:R})},`${_.uid+R}`)}return jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${R}`},`${0+R}`)}):null}return jsxRuntimeExports.jsxs("div",{className:"conversation--characters",children:[jsxRuntimeExports.jsx(Scene,{characters:S?v:g,slots:d,flex:o,currentMessage:a,lodSettings:n,ttsStarted:t,pause:f,lod:E,lowQuality:T}),h||jsxRuntimeExports.jsx(y,{})]})}SlotList.defaultProps={characters:[],currentMessage:{},flex:!0,slots:[]};function Options({inherited:l,options:e,selectedChoice:n,selectChoice:t,showingResults:a,simplifiedOptions:o,required:d}){const[h,f]=React$2.useState(null),u=E=>{o?(f(E),setTimeout(()=>{t(E),f(null)},1e3)):t(E)},p=E=>!!(a&&(n==null?void 0:n.id)===E.id||(n==null?void 0:n.right)===!0||a&&!d);return e==null?void 0:e.filter(E=>E.text).map(E=>jsxRuntimeExports.jsxs("div",{className:`${l?"conversation--question custom-radio":"custom-radio"}
67
67
  ${(h==null?void 0:h.id)===E.id?"radio-text-clicked":""}`,children:[jsxRuntimeExports.jsx("input",{onChange:()=>{u(E)},className:"radio",type:"radio",id:E.text_labelId,name:E.id,checked:(n==null?void 0:n.id)===E.id,disabled:p(E)}),jsxRuntimeExports.jsx("label",{className:`${E.right?"radio-text-success":"radio-text-fail"}`,htmlFor:E.text_labelId,children:HTMLReactParser$1(E.text)})]},`${E.id}_${E.text_labelId}`))}const noop=()=>{};function BasicDecision({children:l,question:e,showingResults:n,selected:t,required:a,failed:o,onNext:d,translate:h,hasRewards:f,options:u}){const[p,E]=React$2.useState(!1);function T(){(t==null?void 0:t.id)!==void 0&&!p&&(E(!0),d())}return jsxRuntimeExports.jsxs("div",{className:`popup popup__large popup__basicDecision ${n&&(t!=null&&t.feedback)?"popup__feedback":""}`,children:[jsxRuntimeExports.jsx("div",{className:"popup--info",children:n?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[l,!(t!=null&&t.feedback)&&f.length===0&&jsxRuntimeExports.jsx("span",{className:"popup--info__title",children:e!==""&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:e})}),!(t!=null&&t.feedback)&&f.length>0&&jsxRuntimeExports.jsx("span",{className:"popup--info__title",children:e})]}):jsxRuntimeExports.jsx("span",{className:"popup--info__title",children:e})}),jsxRuntimeExports.jsx("div",{className:"popup__questions",dir:"auto",children:u}),jsxRuntimeExports.jsx("div",{className:"popup--buttons",children:(a?!o:(t==null?void 0:t.id)!==void 0)?jsxRuntimeExports.jsx("button",{"data-testid":"continueButtonDecision",type:"button",className:`gat--btn__navigation ${p||(t==null?void 0:t.id)===void 0?"disabled":""}`,onClick:()=>T(),"aria-label":h("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null})]})}function ComplexDecision({question:l,inScene:e,disabled:n,onNext:t,children:a,simplifiedOptions:o}){return jsxRuntimeExports.jsxs("div",{dir:"auto",className:`conversation--body ${e?"conversation--body--inScene":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"conversation--message",children:[l!==""&&jsxRuntimeExports.jsx("div",{className:"conversation--main__text",children:HTMLReactParser$1(l)}),a]}),jsxRuntimeExports.jsxs("div",{style:{visibility:o?"hidden":"visible"},className:"conversation--controls conversation--controls--fixedbottom",children:[jsxRuntimeExports.jsx("div",{className:"gat--btn__round disabled",children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{"data-testid":"continueButtonComplexDecision",className:`gat--btn__round ${n?"disabled":""}`,type:"button",onClick:()=>!n&&t(),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})}function DecisionBody({options:l,question:e,inherited:n,branched:t,changeOption:a,onNext:o,failed:d,showingResults:h,currentSelectedChoice:f,children:u,translate:p,hasRewards:E,inScene:T,required:v,simplifiedOptions:S}){const g=R=>{h&&d&&a(R),o(R)},y=!h&&(f==null?void 0:f.id)!==void 0||!d,b={inherited:n,selectedChoice:f,selectChoice:(!v||t)&&(f==null?void 0:f.id)!==void 0||v&&!d?noop:g,options:l,showingResults:h,simplifiedOptions:S,required:v};return n?jsxRuntimeExports.jsx(ComplexDecision,{disabled:!y,question:e,inScene:T,onNext:()=>o(f),simplifiedOptions:S,children:jsxRuntimeExports.jsx(Options,{...b})}):jsxRuntimeExports.jsx(BasicDecision,{question:e,showingResults:h,selected:f,required:v,failed:d,onNext:()=>o(f),translate:p,hasRewards:E,options:jsxRuntimeExports.jsx(Options,{...b}),children:u})}function Wrapper({children:l,inherit:e}){return e?jsxRuntimeExports.jsx("div",{className:"conversation--feedback",children:l}):l}function FeedBack({choice:l,inherited:e,question:n}){return l.feedback?jsxRuntimeExports.jsx(Wrapper,{inherit:e,children:l.feedback&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"conversation--feedback__title",children:n}),jsxRuntimeExports.jsxs("div",{className:"conversation--feedback__text",dir:"auto",children:[l.right?jsxRuntimeExports.jsx("span",{className:"icon-check-circle-black color--success"}):jsxRuntimeExports.jsx("span",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("div",{className:"conversation--feedback__wysiwyg",children:HTMLReactParser$1(l.feedback)})]})]})}):null}function DecisionComponent({emitEvent:l,getEvent:e,soundActions:n,keyboardControl:t,inScene:a,...o}){var I,$;const{inheritProps:d={},decisionNumber:h,required:f,question:u,onAddPoints:p,onFinish:E,branched:T,simplifiedOptions:v}=o,S=Object.keys(d).length>0,[g,y]=React$2.useState("options"),[b,R]=React$2.useState({}),[_]=n,w=f&&!(b!=null&&b.right),C=React$2.useRef(),N=z=>{var X;(X=z.audio)!=null&&X.url&&_(z.audio.url,"audio_file",!1,z.audioVolume)},P={...d,slots:d.slots?d.slots:d.characters,currentMessage:{position:null,emotion:""},emitEvent:l,getEvent:e};d&&d.flex&&P.slots&&(P.characters=P.characters.filter(z=>P.slots.find(X=>X.uid===z.uid)));const D=z=>{l({type:"decisionJournal",payload:{choice:z,decisionNumber:h}})},k=z=>{if(!w&&g==="results")_("click-ui"),S?v?E&&(D(z),E(z,()=>{R({}),y("options")})):(p&&p(z),D(z),l({type:"addPoints",payload:z==null?void 0:z.rewards,finish:!1,complex:!0,onFinish:()=>{E?E(z,()=>{R({}),y("options")}):l({type:"success"}),R({}),y("options")}})):(D(z),l({type:"addPoints",payload:z==null?void 0:z.rewards,finish:!0,complex:!0}));else if(Object.keys(z).length>0)if(_("click-ui"),v)if(z!=null&&z.rewards.filter(X=>X.type==="var").length){D({...z,simplified:!0});const X=z==null?void 0:z.rewards.filter(te=>te.type==="var");l({type:"addPoints",payload:X,finish:!1,complex:!0,onFinish:()=>{E?E(z,()=>{R({}),y("options")}):l({type:"success"}),R({}),y("options")}})}else D({...z,simplified:!0}),E(z,()=>{R({}),y("options")});else z.right?_("score"):(_("fail"),T||(S||f?(D(z),l({type:"addPoints",payload:z==null?void 0:z.rewards,finish:!1,complex:!0})):f||(R({}),y("options")))),R(z),N(z),y("results")},F={...o,selectView:y,selectedView:g,emitEvent:l,inherited:S,branched:T,soundActions:n,showingResults:g==="results",currentSelectedChoice:b,hasRewards:(b==null?void 0:b.rewards)||[],failed:w,inScene:a,required:f,simplifiedOptions:v,changeOption:z=>{_("click-ui"),R(z),y("options")},onNext:k,translate:z=>e({type:"translate",payload:z})},M=t({disabled:g!=="results",repeat:!1,forward:()=>{if(C.current!==b)C.current=b;else return;k(b)}});return React$2.useEffect(()=>M(),[M]),S?jsxRuntimeExports.jsx("div",{className:`conversation--layer
68
68
  ${b!=null&&b.feedback?"":"conversation--layer__defaultFeedback"}
69
69
  ${g==="results"?"conversation--layer__feedback":""}`,children:jsxRuntimeExports.jsxs("div",{className:`conversation ${a?"conversation--inScene":""}`,style:(I=d.background)!=null&&I.img?{backgroundImage:`url("${($=d.background.img)==null?void 0:$.url}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...P,children:g==="results"&&(b!=null&&b.feedback)?jsxRuntimeExports.jsx(FeedBack,{question:u,soundActions:n,inherited:S,choice:b,rewards:(b==null?void 0:b.rewards)||[],emitEvent:l}):null}),jsxRuntimeExports.jsx(DecisionBody,{...F})]})}):jsxRuntimeExports.jsx("div",{className:"popup--layer popup--layer--transparent",children:jsxRuntimeExports.jsx(DecisionBody,{...F,children:jsxRuntimeExports.jsx(FeedBack,{question:u,soundActions:n,inherited:S,choice:b,rewards:(b==null?void 0:b.rewards)||[],emitEvent:l})})})}function ImageComponent({emitEvent:l,img:e,imgName:n,documentType:t,visible:a,viewed:o,imgId_labelId:d,soundActions:h,keyboardControl:f,getEvent:u}){const p=b=>u({type:"translate",payload:b}),[E,T]=React$2.useState(!1),v=e.url,[S]=h,g=React$2.useCallback(()=>{S("click-ui"),l({type:"finishMedia",payload:{imgId:d,name:n,imgName:n,documentType:t,type:"image"}})},[S,d,n,t,l]),y=f({disabled:o,forward:g,escape:g});return React$2.useEffect(()=>y(),[y]),React$2.useEffect(()=>{!a&&!E&&(T(!0),g())},[g,a,E]),a?jsxRuntimeExports.jsx("div",{className:o?"notes--results":"readings--container readings--container--darkopacity",children:jsxRuntimeExports.jsxs("div",{className:o?"notes--results__text":"readings readings--image",children:[v&&jsxRuntimeExports.jsx("img",{src:v,alt:n}),o?null:jsxRuntimeExports.jsx("div",{className:v?"readings--image--closeBtn":"position--absolute top right",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__round gat--btn__close",onClick:g,"aria-label":p("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})})]})}):null}function VoiceOver({name:l}){return jsxRuntimeExports.jsx("div",{className:"conversation--voice__over",children:jsxRuntimeExports.jsx("span",{children:l||"Voice-Over"})})}function ThinkFul({text:l}){return jsxRuntimeExports.jsxs("div",{className:"conversation--voice__over",children:[jsxRuntimeExports.jsx("span",{className:"icon-bubble-thinkful-black"}),jsxRuntimeExports.jsxs("span",{children:["[",l,"]"]})]})}function Message({current:l,translate:e}){var t,a;const n=l.text;return jsxRuntimeExports.jsxs("div",{className:`conversation--message ${l.voiceOver||(t=l==null?void 0:l.emotion)!=null&&t.includes("think")?"voice--over":""}`,children:[l.voiceOver?jsxRuntimeExports.jsx(VoiceOver,{name:l.name}):null,(a=l==null?void 0:l.emotion)!=null&&a.includes("think")?jsxRuntimeExports.jsx(ThinkFul,{text:e("emotion.thinking")}):null,jsxRuntimeExports.jsx("div",{className:"conversation--main__text",children:HTMLReactParser$1(n)})]})}Message.defaultProps={current:{},voiceOver:!1};const cleanStyle={width:"100%",height:"100%",position:"static"};function HtmlWrap(l){const e=document.querySelector(".screens--container");return React$2.useEffect(()=>(l.onMount&&l.onMount(),()=>{l.onUnMount&&l.onUnMount()}),[]),jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{zIndexRange:[6,6],style:cleanStyle,portal:e?{current:e}:void 0,onOcclude:()=>{},calculatePosition:()=>[0,0],wrapperClass:"htmlpro-wrap-100-h",children:l.children})}const characterMs$3=75,minMs$1=1400;function ConversationalProComponent({keyboardControl:l,emitEvent:e,getEvent:n,pause:t,lines:a,edges:o,characters:d,actors:h,background:f,soundActions:u,lodSettings:p,autoPlay:E,autoEnd:T,progress:v}){var Et,$e,pt;const S=a.length-1<=(v==null?void 0:v.line)?a.length-1:(v==null?void 0:v.line)||0,[g,y]=React$2.useState(!1),[b,R]=React$2.useState(!0),[_,w]=React$2.useState(!!E),[C,N]=React$2.useState(!1),[P,D]=React$2.useState(S),[k,F]=React$2.useState(!1),[M]=u,{start:I,stop:$}=useTimeout(),z=((Et=f==null?void 0:f.img)==null?void 0:Et.url)||null,X=a[P],{voiceOver:te,decision:ae}=X;let{flex:ee}=X,K=[];const ne=!!o,ue=te||X.type==="conversationalNarration",pe=ae||X.type==="conversationalDecision",J=X.type==="conversationalCamera",[H,W]=React$2.useState([]),V=React$2.useMemo(()=>H[H.length-1],[H]),B=React$2.useCallback(()=>{const He=o.find(Pe=>Pe.fromId===V)||o.find(Pe=>Pe.toId===V),Ye=a.find(Pe=>Pe.id===(He==null?void 0:He.fromId));return!V&&(v==null?void 0:v.line)>=0?{decision:!0}:Ye},[o,a,V,v==null?void 0:v.line]),Y=React$2.useCallback(()=>{if(ne){const Ye=B();return Ye==null?void 0:Ye.decision}const He=a[P-1]?a[P-1]:{};return P>0&&(He==null?void 0:He.decision)},[ne,B,a,P]),re=React$2.useCallback(()=>{if(ne){const Ye=B();return(Ye==null?void 0:Ye.type)==="conversationalCamera"}const He=a[P-1]?a[P-1]:{};return P>0&&(He==null?void 0:He.type)==="conversationalCamera"},[ne,a,P,B]),le=React$2.useCallback(He=>n({type:"translate",payload:He}),[n]),fe=React$2.useMemo(()=>{var Ye,Pe;if(pe)return{};if(ue)return X;const He=(Ye=X==null?void 0:X.slots)==null?void 0:Ye.find(we=>we.uid&&we.talking);return He||((Pe=X==null?void 0:X.slots)==null?void 0:Pe.find(we=>we.uid&&we.text))},[X,ue,pe]),de=a.slice(0,P+1).reverse().find(He=>He.slots),ge=!pe&&(($e=X.slots)==null?void 0:$e.filter(He=>He.uid).length),Ee=characterMs$3*(((pt=fe==null?void 0:fe.text)==null?void 0:pt.length)||0);let Re=[];X.slots?Re=X.slots:de&&(Re=de.slots);const Oe=Re.filter(He=>He.uid).map(He=>{const Ye=(d||h||[]).find(Pe=>Pe.uid===He.uid);return Ye&&(He.resource=Ye.resource,He.type=Ye.type),He.resource||(He.resource={}),He}),Ne={characters:Oe,lodSettings:p,actors:h,currentMessage:fe||{},slots:ue?K:X.slots,flex:ee,pause:t,getEvent:n};if(ue){const He=a.slice(P).find(Pe=>Pe.slots),Ye=de||He;Ye&&(K=Ye.slots,ee=Ye.flex)}else if(!pe&&ge&&(X.slots.forEach(He=>{const Ye=Oe.findIndex(Pe=>Pe.uid===He.uid);Ye>=0&&(Oe[Ye].emotion=He.emotion)}),fe&&fe.uid)){const He=X.slots.findIndex(Pe=>Pe.uid===fe.uid),Ye=Oe.findIndex(Pe=>Pe.uid===fe.uid);Oe.forEach(Pe=>{Pe.uid===fe.uid&&(Pe.name=fe.alias)}),fe.position=ee?Ye:He}const Xe=React$2.useCallback(()=>{e({type:"success"})},[e]),ft=React$2.useCallback((He,Ye)=>{const Pe=[3,2,1][He.id],ye=o.filter(De=>De.fromId===X.id).find(De=>parseInt(De.fromPointIndex)===Pe);if(ye){const De=a.findIndex(qe=>qe.id===ye.toId);ye.fromId===ye.toId?Ye():De>=0?(D(De),e({type:"notifyProgress",payload:{line:De}})):Xe()}else Xe()},[X.id,o,e,Xe,a]),nt=React$2.useCallback((He=!0)=>{const Ye=He?["fromId","toId"]:["toId","fromId"],Pe=o.filter(De=>De[Ye[0]]===X.id),we=Pe.length===1?Pe[0]:Pe.find(De=>De[Ye[1]]===V);if(!(we!=null&&we[Ye[0]])){Xe();return}He||W(H.slice(0,-1));const ye=a.findIndex(De=>De.id===we[Ye[1]]);ye>=0?(D(ye),e({type:"notifyProgress",payload:{line:ye}})):Xe()},[X.id,o,H,e,Xe,V,a]),St=React$2.useCallback(He=>{if(ne){if(He){const Ye=[3,2,1][He.id],we=o.filter(ye=>ye.fromId===X.id).find(ye=>parseInt(ye.fromPointIndex)===Ye);if(we){const ye=a.findIndex(De=>De.id===we.toId);ye>=0&&e({type:"notifyProgress",payload:{line:ye}})}else e({type:"saveNode"})}}else if(P<a.length-1){const Pe=P+1;e({type:"notifyProgress",payload:{line:Pe}})}else e({type:"saveNode"})},[o,a,e,P,X.id,ne]),ze=React$2.useCallback((He,Ye)=>{let Pe=!1;if(F(!1),W([...H,X.id]),R(!1),N(!1),ne)He?ft(He,Ye):nt();else if(P<a.length-1){const ye=P+1;D(ye),e({type:"notifyProgress",payload:{line:ye}}),Ye&&Ye()}else T||pe||J?Xe():Pe=!0;Pe||R(!0)},[H,X.id,ne,P,a.length,T,pe,J,ft,nt,e,Xe]),Me=()=>{if(R(!1),F(!1),N(!1),ne)nt(!1);else if(!Y()){const He=P-1;D(He),e({type:"notifyProgress",payload:{line:He}})}R(!0)},ke=React$2.useCallback(()=>ne?X&&X.type!=="conversationalDecision"&&!o.find(He=>He.fromId===X.id):P===a.length-1,[P,X,o,ne,a.length]),We=()=>{M("click-ui"),ke()?Xe():(w(!1),ze())},tt=()=>{M("click-ui"),w(!1),Me()},ct=_&&!pe&&!t&&!J,Dt=React$2.useMemo(()=>P===0||Y()||re(),[P,Y,re]);useEkho({audioType:X==null?void 0:X.audioType,volume:X==null?void 0:X.audioVolume,voice:X==null?void 0:X.voice,started:b,slide:P,text:cleanTextOfHtmlTags(fe==null?void 0:fe.text),audio:X==null?void 0:X.audio,soundActions:u,getEvent:n,pauseTTS:t,onStart:()=>{var He;(He=fe==null?void 0:fe.emotion)!=null&&He.includes("think")||F(!0)},onError:()=>{N(!0)},onFinish:()=>{F(!1),ct&&ze()}}),React$2.useEffect(()=>{var Ye;let He;return pe?()=>{}:(((X==null?void 0:X.audioType)==="none"||C)&&!((Ye=fe==null?void 0:fe.emotion)!=null&&Ye.includes("think"))&&(F(!0),He=setTimeout(()=>{F(!1)},Ee<minMs$1?minMs$1:Ee)),()=>{He&&clearTimeout(He)})},[C,X,fe==null?void 0:fe.emotion,Ee,pe]),React$2.useEffect(()=>(ct&&((X==null?void 0:X.audioType)==="none"||C)&&(!ke()||ke()&&T)&&I(ze,Ee<minMs$1?minMs$1:Ee),()=>{$()}),[fe,I,$,ze,X==null?void 0:X.audioType,ct,C,T,a,ke,Ee]),React$2.useEffect(()=>{if(ne&&!g){const He=v==null?void 0:v.line;if(He>=0){y(!0),D(He);return}const Ye=a.filter(Pe=>!o.find(we=>we.toId===Pe.id));if(Ye.length){const Pe=Ye[0],we=a.indexOf(Pe);we>=0&&(y(!0),D(we))}}},[o,ne,a,g,v==null?void 0:v.line]);const rt=l({disabled:pe,repeat:!1,forward:We,rewind:Dt?null:tt});if(React$2.useEffect(()=>rt(),[rt]),J)return jsxRuntimeExports.jsx(ChangeCamera,{...X,transition:{type:"none"},emitEvent:e,success:!1,onFinish:ze},`change-camera-${P}`);if(pe){const He=a[P].id?a.filter(Pe=>Pe.decision).findIndex(Pe=>Pe.id===a[P].id)+1:a.filter(Pe=>Pe.decision).findIndex(Pe=>Pe===a[P])+1,Ye={...X.payload,decisionNumber:He,required:!ne,branched:ne,onAddPoints:St,onFinish:ze,keyboardControl:l,emitEvent:e,getEvent:n,soundActions:u,inheritProps:{characters:Oe,background:f,flex:de?de.flex:!0,slots:de?de.slots:[]}};return jsxRuntimeExports.jsx(HtmlWrap,{children:jsxRuntimeExports.jsx(DecisionComponent,{...Ye})})}return jsxRuntimeExports.jsx(HtmlWrap,{children:jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{"data-testid":"conversational-pro-image",className:"conversation",style:z?{backgroundImage:`url("${z}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...Ne,ttsStarted:k}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",dir:"auto",children:[fe?jsxRuntimeExports.jsx(Message,{current:fe,translate:le}):null,jsxRuntimeExports.jsxs("div",{className:"conversation--controls",children:[jsxRuntimeExports.jsx("button",{"data-testid":"conversational-pro-button-back",className:`gat--btn__round ${Dt?"disabled":""}`,disabled:Dt?!0:"",type:"button",onClick:tt,"aria-label":LangIsRtl()?le("storylines.misc.forward"):le("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{"data-testid":"conversational-pro-button-next",className:`gat--btn__round ${_&&ke()?"glowing-animation":""}`,type:"button",onClick:We,"aria-label":LangIsRtl()?le("storylines.misc.rewind"):le("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})]})})})}ConversationalProComponent.defaultProps={background:{},emitEvent:()=>{},soundActions:[()=>{},()=>{}]};function ConversationalComponent({emitEvent:l,getEvent:e,soundActions:n,messages:t,characters:a,alias:o,background:d,lodSettings:h}){var y;const[f,u]=React$2.useState(0),[p]=n,E=((y=d==null?void 0:d.img)==null?void 0:y.url)||null,T=t[f],v=a.map((b,R)=>({...b,name:o[R]?o[R]:b.name,uid:R})),S=()=>{const b=t.length-1;p("click-ui"),f+1<=b?u(f+1):l({type:"success"})},g=()=>{f>0&&(u(f-1),p("click-ui"))};return jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{"data-testid":"conversation-component",className:"conversation arcade-conversation",style:E?{backgroundImage:`url("${E}")`}:{},children:[jsxRuntimeExports.jsx(SlotList,{characters:v,lodSettings:h,currentMessage:T,slots:v,emitEvent:l,getEvent:e,flex:!0}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",children:[T?jsxRuntimeExports.jsx(Message,{current:T,voiceOver:T.emotion===null}):jsxRuntimeExports.jsx("div",{}),jsxRuntimeExports.jsxs("div",{className:"conversation--controls arcade-conversation--controls",children:[jsxRuntimeExports.jsx("button",{"data-testid":"conversational-back-button",className:`gat--btn__round ${f>0?"":"visibility--hidden"}`,type:"button",onClick:g,children:jsxRuntimeExports.jsx("span",{className:"icon-back"})}),jsxRuntimeExports.jsx("button",{"data-testid":"conversational-next-button",className:"gat--btn__round",type:"button",onClick:S,children:jsxRuntimeExports.jsx("span",{className:"icon-next"})})]})]})]})})}function Vignette({vignette:l,alias:e,translate:n,backgroundImageCover:t}){var u;const o=(l.img||{url:"https://min.gamelearn.io/css-resources/gamelearn/resources/conversation.jpg"}).url,[d,h]=React$2.useState(!0),f=p=>{document.querySelector(`#${p}`).focus(),h(!d)};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{"data-testid":"comic-image",className:`comic-image ${t?"comic-image--cover":""}`,children:o&&jsxRuntimeExports.jsx("img",{src:o,alt:"comic pic"})}),(u=l==null?void 0:l.textData)!=null&&u.text?jsxRuntimeExports.jsxs("div",{"data-testid":"comicCollapsable",className:`comic-collapsable ${d?"comic-collapsable--opened":""}`,children:[jsxRuntimeExports.jsx("button",{id:"buttonDown","data-testid":"buttonDown",onClick:()=>f("buttonUp"),type:"button",className:"un-btn comic-collapsable__headertoggle","aria-label":n("comic.toggleText"),children:jsxRuntimeExports.jsx("span",{className:"icon-down-arrow"})}),jsxRuntimeExports.jsxs("div",{className:"comic-collapsable__text",children:[e?jsxRuntimeExports.jsxs("b",{children:[e,": "]}):null,HTMLReactParser$1(l.textData.text)]})]}):null,jsxRuntimeExports.jsx("button",{id:"buttonUp","data-testid":"buttonUp",tabIndex:d?"-1":"0","aria-hidden":d,className:`unset-button comic-buttonup
@@ -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",h=n[o]!==e[o];if(d&&h){var f=o.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),l.off(f,n[o])}var u=!e.hasOwnProperty(o);u&&l.setAttr(o,void 0)}var p=e._useStrictMode,E={},T=!1;const v={};for(var o in e)if(!propsToSkip[o]){var d=o.slice(0,2)==="on",S=n[o]!==e[o];if(d&&S){var f=o.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),e[o]&&(v[f]=e[o])}!d&&(e[o]!==n[o]||p&&e[o]!==l.getAttr(o))&&(T=!0,E[o]=e[o])}T&&(l.setAttrs(E),updatePicture(l));for(var f in v)l.on(f+EVENTS_NAMESPACE,v[f])}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 h=d.slice(0,2)==="on";h?o[d]=e[d]:a[d]=e[d]}const f=new t(a);return applyNodeProps(f,o),f}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=h=>{const{forwardedRef:f}=l;f&&(typeof f=="function"?f(h):f.current=h)};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")),h=React$2.useMemo(()=>client.createRoot(d),[d]),f=t??!0,u=useEvent(()=>{if(f&&o.current){let S=o.current.getAbsoluteTransform().decompose();a&&(S=a(S)),d.style.position="absolute",d.style.zIndex="10",d.style.top="0px",d.style.left="0px",d.style.transform=`translate(${S.x}px, ${S.y}px) rotate(${S.rotation}deg) scaleX(${S.scaleX}) scaleY(${S.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:E}=p,T=__rest(p,["style"]);Object.assign(d.style,E),Object.assign(d,T)});return React$2.useLayoutEffect(()=>{var p;const E=o.current;if(!E)return;const T=(p=E.getStage())===null||p===void 0?void 0:p.container();if(T)return T.appendChild(d),f&&needForceStyle(T)&&(T.style.position="relative"),E.on("absoluteTransformChange",u),u(),()=>{var v;E.off("absoluteTransformChange",u),(v=d.parentNode)===null||v===void 0||v.removeChild(d)}},[f]),React$2.useLayoutEffect(()=>{u()},[n,a]),React$2.useLayoutEffect(()=>{h.render(l)}),React$2.useLayoutEffect(()=>()=>{setTimeout(()=>{h.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:h}){const f=React$2.useRef(),[u,p]=React$2.useState(),E=t?"rgba(255, 99, 77, 0.32)":"rgba(75, 215, 169, 0.32)",T=t?"#ff634d":"#4bd7a9",v=DeviceDetection(),S=()=>{var _,w,C;a&&!o&&!n&&((_=f.current)==null||_.setAttr("fill","rgba(130, 134, 142, 0.4)"),(w=f.current)==null||w.setAttr("stroke","rgba(255, 255, 255, 0.3)"),(C=f.current)==null||C.to({duration:.25,opacity:1}))},g=()=>{var _;a&&!o&&!n&&((_=f.current)==null||_.to({duration:.25,opacity:0}))};React$2.useEffect(()=>{var _,w,C;o&&!e&&(t?(C=f.current)==null||C.to({duration:.25,opacity:0}):((_=f.current)==null||_.to({duration:.25,opacity:1}),(w=f.current)==null||w.globalCompositeOperation("destination-out")))},[o,e,t]);const y=()=>{var _,w;o||(t?h(l):d(l),(_=f.current)==null||_.setAttr("fill",E),(w=f.current)==null||w.setAttr("stroke",T))},b=l.scaleX?l.scaleX:1,R=l.scaleY?l.scaleY:1;return React$2.useLayoutEffect(()=>{const _=f.current.getStage();_.on("stage-loaded",()=>{const w=f.current.getClientRect({relativeTo:f.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:f,onFocus:()=>S(),onMouseOver:()=>S(),onMouseLeave:g,onClick:()=>y(),onTap:()=>y(),x:l.x,y:l.y,scale:{x:b,y:R},skew:{x:l.skewX,y:l.skewY},rotation:l.rotation,points:l.points,shape:"poly",fill:e?"":E,stroke:e||n?T:"",strokeWidth:v?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(){const t=document.querySelector("#root");e([t.clientWidth,t.clientHeight])}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:h}){const f=React$2.useRef(),u=React$2.useRef(),p=React$2.useRef(),E=React$2.useRef(),T=React$2.useRef(),v=React$2.useRef(),S=React$2.useRef(),[g,y]=React$2.useState(new window.Image),[b,R]=useWindowSize(),_=e.find(N=>N.id==="AllArea")||!1,w=e.filter(N=>N.id!=="AllArea");React$2.useEffect(()=>{S.current&&u.current&&t&&(S.current.to({duration:.25,opacity:.5}),u.current.setAttr("visible",!0))},[t]);const C=N=>{_&&!N.target.attrs.shape&&o(_)};return React$2.useEffect(()=>{g.src=n,g.addEventListener("load",()=>{if(f.current){const N={x:b/2,y:R/2,width:g.width,height:g.height,offsetX:g.width/2,offsetY:g.height/2,scale:{x:Math.min(b/g.width,R/g.height),y:Math.min(b/g.width,R/g.height)}};E.current&&E.current.setAttrs(N),T.current&&T.current.setAttrs(N),u.current&&u.current.setAttrs(N),p.current&&p.current.setAttrs(N),v.current&&v.current.setAttrs(N),f.current.batchDraw(),y(g),f.current.fire("stage-loaded")}})},[g,R,n,b]),jsxRuntimeExports.jsxs(Stage,{ref:f,width:b,height:R,onClick:C,onTouchEnd:C,children:[jsxRuntimeExports.jsx(Layer,{children:jsxRuntimeExports.jsx(Image$2,{ref:v,image:g})}),jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Rect,{ref:S,width:b,height:R,fill:"black",opacity:0}),jsxRuntimeExports.jsx(Group,{ref:T,children:w.map((N,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:d,completed:t,onClick:a,onClickOutside:o,area:N,isBad:!0},N.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:E,children:l.map((N,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:d,completed:t,onClick:a,onClickOutside:o,area:N,isClicked:h.some(D=>D.index===N.index)},N.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:p,visible:!1,children:w.map((N,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:d,completed:t,onClick:a,onClickOutside:o,area:N,isBad:!0,finished:!0},N.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:u,visible:!1,children:l.map((N,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:d,completed:t,onClick:a,onClickOutside:o,area:N,finished:!0},N.name+"_"+P))})]})]})}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 Ye,Pe,we;const{soundActions:e,emitEvent:n,getEvent:t,handleClick:a,disableExit:o,setResolveAction:d,info:h,image:f,areas:u,badAreas:p,hasClickOrder:E,timer:T,hasClickOnce:v,hasHighlights:S,hasImageReview:g,defaultCompleted:y,className:b,emitFinish:R,emitResolve:_,translateFromParent:w,specificFeedbacks:C,slideNumber:N,emitResetPuzzle:P,firstTryForFrame:D,puzzlesAutoCompleted:k,emitOpenPopupCounterInfo:F,pause:M,keyboardControl:I}=l,[$,z]=React$2.useState([]),[X,te]=React$2.useState(!1),[ae,ee]=React$2.useState(!1),[K,ne]=React$2.useState({show:!1,success:!1,text:"",rewards:[]}),ue=React$2.useRef(!1),[pe,J]=React$2.useState(!0),[H,W]=React$2.useState(!1),V=React$2.useRef(null),B=React$2.useRef(null),Y=React$2.useRef(null),re=React$2.useRef(null),le=React$2.useRef(null),fe=React$2.useRef(null),de=React$2.useRef(null),ge=React$2.useRef(null),Ee=React$2.useRef(null),[Re,Oe]=React$2.useState(T),Ne=ye=>w?w(ye):t({type:"translate",payload:ye}),[Xe]=e,{solution:ft}=h,nt=((Ye=f==null?void 0:f.img)==null?void 0:Ye.url)||defaultImg,St=u.map((ye,De)=>({index:De,shape:"poly",...ye})),ze=p.map((ye,De)=>({index:De,shape:"poly",...ye})),Me=React$2.useCallback(()=>{if(!pe){const ye=setInterval(()=>{Oe(De=>De>1?De-1:0)},1e3);Ee.current=ye}},[pe]),ke=React$2.useCallback((ye,De)=>{R?R(ye,De):n({type:"addPoints",payload:ye})},[n,R]);React$2.useEffect(()=>{X&&o(!0)},[X,o]),React$2.useEffect(()=>{te(y)},[y]);const We=React$2.useCallback(()=>{clearInterval(Y.current)},[]),tt=React$2.useCallback(()=>{clearInterval(Ee.current)},[]),ct=React$2.useCallback(ye=>{le.current=Date.now(),re.current?(de.current=re.current-le.current,We()):(de.current=le.current-(le.current-ye*1e3),We())},[We]),Dt=React$2.useCallback(()=>{ne(()=>{var ye,De;return{show:!0,success:!1,text:(ye=h==null?void 0:h.timerFeedback)!=null&&ye.desc?h.timerFeedback.desc:"",rewards:(De=h==null?void 0:h.timerFeedback)==null?void 0:De.rewards}}),W(!0),tt(),We()},[tt,We,(Pe=h.timerFeedback)==null?void 0:Pe.desc,(we=h.timerFeedback)==null?void 0:we.rewards]),rt=React$2.useCallback(()=>{clearInterval(Y.current),Y.current=setInterval(()=>{B.current=Date.now(),B.current>re.current&&Dt()},250)},[Dt]);React$2.useEffect(()=>{var ye;if((u.length===$.length||v&&$.length>0)&&!X){te(!0);const De=$[$.length-1],qe=C==null?void 0:C.correctFeedbacks.find(Lt=>Lt.id===De.id);(!((ye=C==null?void 0:C.correctFeedbacks)!=null&&ye.length)||C!=null&&C.correctFeedbacks.some(Lt=>!Lt.desc)||v)&&(ne(Lt=>({...Lt,show:!0,success:!0,text:qe?qe.desc:h.solution.right.desc,rewards:qe?qe.rewards:h.solution.right.rewards})),T&&(tt(),ct()))}},[$,u.length,C,v,X,h.solution.right,ct,T,tt]),React$2.useEffect(()=>{d(ye=>{T&&(tt(),J(!1),K.show?ne(De=>({...De,show:!1,success:!1,text:"",rewards:[]})):We()),te(!0),ee(!0),setTimeout(()=>{_?_(ye):ye()},4e3)})},[d,_,Xe,T,K.show,We,tt]),React$2.useEffect(()=>{ae&&o(!0)},[ae,o]);const Et=(ye,De=!1)=>{var qe,Lt;if(!X){const{rewards:kt,desc:Le}=ft.wrong;let ht=Le,wt=kt;const at=(qe=C==null?void 0:C.wrongFeedbacks)==null?void 0:qe.find(Pt=>Pt.id===ye.id);at&&(ht=at.desc,wt=at.rewards),E&&(z([]),De&&(Lt=h==null?void 0:h.orderFeedback)!=null&&Lt.desc&&(ht=h.orderFeedback.desc,wt=h.orderFeedback.rewards)),T&&(tt(),ct()),ne(Pt=>({...Pt,show:!0,success:!1,text:ht,rewards:wt})),Xe("fail")}},$e=React$2.useCallback(()=>{fe.current=Date.now();const ye=fe.current+de.current;B.current=null,re.current=ye,(T||H)&&(K.success?u.length===$.length||v&&$.length>0?tt():(Oe(de.current*.001),Me(),rt()):(z([]),J(!0),P())),ke(K.rewards,K.success),Xe("click-ui"),ne(De=>({...De,show:!1,success:!1,text:"",rewards:[]}))},[T,H,ke,K.rewards,K.success,Xe,u.length,$.length,v,P,tt,Me,rt]),pt=ye=>{var De,qe;if(!$.some(Lt=>Lt.index===ye.index)&&!K.show&&!X){Xe("click-ui");let Lt=ft.right.desc,{rewards:kt}=ft.right;const Le=[...$,ye];if(E&&ye.index===$.length||!E){if(T&&ct(Re),a(),(De=C==null?void 0:C.correctFeedbacks)!=null&&De.length){const ht=(qe=C.correctFeedbacks)==null?void 0:qe.find(wt=>wt.id===ye.id);ht&&(Lt=ht.desc,kt=ht.rewards),!Lt&&u.length>Le.length&&!v?ke(kt,!0):Lt&&!v&&(ne(wt=>({...wt,show:!0,success:!0,text:Lt,rewards:kt})),T&&tt())}z(Le)}else Et(ye,!0)}},He=React$2.useCallback(()=>{tt(),Oe(T),Me(),!ue.current&&D&&F(),J(!1),V.current=Date.now(),re.current=V.current+T*1e3,rt()},[tt,T,Me,D,rt,F]);return React$2.useEffect(()=>{T&&N>0&&!ge.current&&(D&&Object.keys(k).length&&k[N-1]?(J(!0),ge.current=!0):J(!1))},[y,D,k,N,T]),React$2.useEffect(()=>{T&&Re===0&&Dt()},[Re,Dt,T]),React$2.useEffect(()=>{T&&(M?(tt(),ct()):Me())},[tt,rt,M,ct,Me,T]),jsxRuntimeExports.jsxs("div",{className:b,children:[K.show?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:Xe,text:K.text,success:K.success,translate:Ne,hasTimeout:!K.text,delay:T?1e3:2e3,functionOnClose:$e,timeExpired:H,keyboardControl:I}):null,jsxRuntimeExports.jsx(KonvaMapper,{completed:X,imageUrl:nt,areas:v&&$.length?[$[0]]:St,badAreas:ze,clickedZones:$,onClick:pt,onClickOutside:Et,hasHighlights:S,emitEvent:n}),g?jsxRuntimeExports.jsx(ImageReview,{}):null,T&&pe?jsxRuntimeExports.jsx(TimerDialog,{retry:D||k[N-1],translate:Ne,onInit:He}):null,T?jsxRuntimeExports.jsx(CountDown,{time:Re}):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:()=>{},getEvent:()=>{}};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 h=Math.floor(Math.random()*n),f=Math.floor(Math.random()*t);o[h][f].value=d,a.push({char:d,position:[h,f]})}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((f,u)=>{const p=[o,d],E=getDistance(u.position,p);return E<f?E:f},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 h={color:"",hiddenColor:RED,value:n[Math.floor(Math.random()*n.length)]};o.push(h)}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,h]=generatePasswordPositions(o,n,e,l);return paintedGridPassword(d,e,l,h)};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:h,getEvent:f}){const[u]=e,p=J=>f({type:"translate",payload:J}),E=React$2.useRef(),T=React$2.useRef(),{solution:v}=n,[S,g]=React$2.useState(a.toLowerCase()),[y,b]=React$2.useState(),[R,_]=React$2.useState(Array(a.toLowerCase().length).fill("")),[w,C]=React$2.useState(!1),[N,P]=React$2.useState([0,0]),D=p("puzzle.cracker.crackedPassword"),k=n.solution.right.desc&&n.solution.right.desc!==""?n.solution.right.desc:"",F=p("puzzle.cracker.congratulations"),[M,I]=React$2.useState([[]]),{visibleRows:$,visibleColumns:z}=DIFFICULTY_MAP[d];let X=$==="auto"?Math.ceil(window.innerHeight*.025):$;X=X>=20?X:20,React$2.useEffect(()=>{w&&o(!0)},[w,o]),React$2.useEffect(()=>{h(J=>{u("score"),C(!0),setTimeout(()=>{l({type:"hidePuzzleButtons",payload:!1}),J()},0)})},[h,u]);const te=()=>{u("click-ui");const{rewards:J}=v.right;l({type:"addPoints",complex:!0,finish:!0,payload:J}),l({type:"passPuzzle"})},ae=()=>a.toLowerCase().split("").map((H,W)=>({char:H,index:W,used:!1})),ee=J=>J.filter(H=>H.used===!1).map(H=>H.char).join(""),K=J=>{if(J[0].length>0&&!w){const H=[...J];return H.push(H.shift()),H}return J};let ne=0;const ue=J=>{if(T.current!==void 0){const H=J-T.current;ne+=H,ne>1e3/VELOCITY_MAP[t]&&(I(K),ne=0)}T.current=J,E.current=requestAnimationFrame(ue)};React$2.useEffect(()=>{g(a.toLowerCase());const J=makeSomeNoise({numberOfColumns:z,numberOfRows:X,password:a.toLowerCase()});return I(J),b(ae()),E.current=requestAnimationFrame(ue),()=>cancelAnimationFrame(E.current)},[]);const pe=()=>{if(M.length<=1)return;const[J,H]=N,W=M[J][H];if(W.hiddenColor===GREEN){const V=y.filter(B=>B.char===W.value.toLowerCase()&&B.used===!1)[0];if(V){const{index:B}=V;u("score");const Y=y;Y[B].used=!0,b(Y);const re=[...R];re[B]=W.value;const le=ee(Y);g(le);const fe=repaintGridPassword(M,le,X,z);I(fe),_(re)}}S<=0&&(u("score"),C(!0))};return React$2.useEffect(()=>{w||pe()},[N]),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:R.map((J,H)=>jsxRuntimeExports.jsx("span",{className:"puzzle--pieces__item",children:J&&jsxRuntimeExports.jsx("span",{className:"character success-transition-animation","data-testid":`solution${H}`,children:J})},`${J+H}`))})]}),jsxRuntimeExports.jsx(DrawGrid,{grid:w?[[]]:M,cursorPosition:N,setCursorPosition:P}),w&&D&&F&&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:[F," "]}),k!==""&&jsxRuntimeExports.jsx("span",{children:k})]}),jsxRuntimeExports.jsx("div",{className:"position--absolute bottom center",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary gat--btn__cracker",onClick:te,children:p("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,h)=>jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__word","data-testid":`result-${h}`,children:n?d.map((f,u)=>jsxRuntimeExports.jsx("span",{className:"puzzle--hanged__letter active",children:f},`${f+u}`)):d.filter(({char:f})=>f!==" ").map(({char:f,fixed:u},p)=>jsxRuntimeExports.jsx("span",{className:`puzzle--hanged__letter ${u?"":"active"} ${d[p].positionInitial===e?"fakeFocus":""}`,children:f},`${f+p}`))},`${d+h}`))},defaultImage="https://min.gamelearn.io/css-resources/gamelearn/resources/partenon.jpg";function HangedPuzzleComponent({soundActions:l,emitEvent:e,getEvent:n,disableExit:t,question:a,image:o,info:d,answer:h,hintUsed:f,setResolveAction:u,setHintAction:p,keyboardControl:E}){var fe;const[T]=l,v=((fe=o.img)==null?void 0:fe.url)||defaultImage,[S,g]=React$2.useState(0),[y,b]=React$2.useState(!1),[R,_]=React$2.useState([]),[w,C]=React$2.useState(!1),[N,P]=React$2.useState([]),[D,k]=React$2.useState(""),[F,M]=React$2.useState(!1),[I,$]=React$2.useState([]),[z,X]=React$2.useState(!1),te=h.toUpperCase().split(""),ae=te.filter(de=>restrictCharacters(de,"and")),ee=de=>n({type:"translate",payload:de}),K=React$2.useCallback(()=>{const de=ae.map(Re=>({char:Re}));let ge=[];const Ee=analyzeChars(ae);for(;ge.length<MAX_EXTRA_LETTERS;){const Re=makeChar(Ee);ge=[...ge,{char:Re}]}return[...de,...ge]},[ae]),ne=h.toUpperCase().split("").map((de,ge)=>restrictCharacters(de,"or")?{index:ge,letter:de,char:de,fixed:!0}:{index:ge,letter:de,char:""}),ue=React$2.useCallback(()=>{let de=K();for(;de.length>MAX_POOL_LETTERS;){const ge=Math.trunc(Math.random()*(de.length-1))+1,Ee=de[ge],Re=ne.find((Oe,Ne)=>Ee.char===Oe.letter&&!ne[Ne].fixed);Re&&(de.splice(ge,1),ne[Re.index]={...Re,char:Re.letter,fixed:!0})}f&&(de=[],ne.forEach(({letter:ge})=>{ge!==" "&&de.push({char:ge})})),P(ne),_(de)},[ne,f,K]),pe=(de,ge)=>R.map((Re,Oe)=>Oe===ge?{...Re,deleted:!0}:{...Re}),J=(de,ge,Ee)=>{const Re=ge.map((Ne,Xe)=>Ee.find(nt=>nt.poolIndex===Xe)?{char:Ne.char}:Ne);_(Re),P(de);const Oe=de.find(Ne=>Ne.char==="");g(Oe.index)},H=(de,ge)=>{T("click-ui");let Ee=!1;const Re=N.map(Xe=>!Xe.char&&!Ee?(Ee=!0,{...Xe,char:de,poolIndex:ge}):Xe),Oe=pe(de,ge),Ne=Re.filter(Xe=>Xe.char).length;_(Oe),P(Re),W(),Ne===N.length&&re(Re,Oe)},W=()=>{var de;if(y){const ge=N.find(Ee=>Ee.index!==S&&Ee.letter!==" "&&Ee.char===""&&Ee.poolIndex===!1);ge&&g(ge.index)}else{const ge=N.find(Ee=>Ee.char==="");g(ge.index+1),((de=N[ge.index+1])==null?void 0:de.letter)===" "&&g(ge.index+2)}},V=()=>{T("click-ui");const de=N.map((ge,Ee)=>N[N.length-1-Ee]).find(ge=>ge.char&&!ge.fixed);if(de){const ge=N.map(Oe=>Oe.index===de.index?{...de,char:""}:Oe);let Ee=!1;const Re=R.map((Oe,Ne)=>Ne===de.poolIndex&&(Oe.deleted||!Ee)?(Ee=!0,{char:Oe.char}):Oe);_(Re),P(ge),g(de.index)}},B=()=>{t(!0),k("");const de=[...I,...d.solution.right.rewards];T("score"),e({type:"hidePuzzleButtons",payload:!1}),e({type:"addPoints",complex:!0,finish:!0,payload:de}),e({type:"passPuzzle"})},Y=()=>{T("fail"),e({type:"hidePuzzleButtons",payload:!1}),$([...I,...d.solution.wrong.rewards]),k(""),M(!1),e({type:"failPuzzle"}),b(!0)},re=(de,ge)=>{let Ee=[];M(!0);const Re=de.map((Ne,Xe)=>te[Xe]===Ne.char?{...Ne,fixed:!0}:(Ee=[...Ee,Ne],{...Ne,poolIndex:!1,char:""})),Oe=Re.filter(Ne=>Ne.fixed).length;e({type:"hidePuzzleButtons",payload:!0}),Oe===te.length?(k("success"),d.solution.right.desc===""&&setTimeout(()=>{B()},2e3)):(k("failed"),J(Re,ge,Ee),d.solution.wrong.desc===""&&setTimeout(()=>{Y()},2e3))},le=()=>{if(D==="success")B();else{Y();const de=N.find(ge=>ge.char==="");g(de.index)}};return React$2.useEffect(()=>{w||(C(!0),ue()),u(de=>{X(!0),setTimeout(()=>{e({type:"hidePuzzleButtons",payload:!1}),de()},2e3)}),p(de=>{const ge=[];ne.forEach(({letter:Ee})=>{Ee!==" "&&ge.push({char:Ee})}),_(ge),de()})},[ue,w,h,u,e,I,d.resolve.rewards,ne,p]),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged",style:{backgroundImage:`url("${v}")`},children:[D?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:T,text:d.solution[D==="success"?"right":"wrong"].desc,success:D==="success",translate:ee,functionOnClose:le,keyboardControl:E}):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:a}),jsxRuntimeExports.jsx("div",{dir:"auto",className:`puzzle--hanged__solution ${D}`,"data-testid":`${D}`,children:z?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:z,answer:h.split(""),show:!0})}):jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:z,flickerPosition:S,answer:N})}),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__keyboard",children:[R.sort((de,ge)=>sortChar(de,ge)).map((de,ge)=>jsxRuntimeExports.jsx("button",{"data-testid":`key-${de.char}`,type:"button",onClick:()=>{!de.deleted&&!D&&!F&&(H(de.char,ge),T("click-ui"))},className:`puzzle--hanged__keyboard--item ${de.deleted||F?"disabled":""}`,children:de.char},`${de+ge}`)),jsxRuntimeExports.jsx("button",{onClick:F?null:()=>V(),type:"button",disabled:F?"disabled":null,"aria-label":ee("puzzles.hanged-puzzle.deleteButton"),className:`puzzle--hanged__keyboard--item delete ${F?"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,getEvent:o,disableExit:d,setResolveAction:h,soundActions:f,setSelected:u,selected:p,pause:E,loadPuzzleStatus:T,index:v,setIndex:S,slidesCompleted:g,setSlidesCompleted:y,keyboardControl:b,totalCorrects:R}){const _=React$2.useRef([]),w=React$2.useRef(0),C=React$2.useRef(0),N=`chained-image-click-puzzle_${v}_${n}`,[P]=f,D=K=>{_.current=[..._.current,...K]},k=React$2.useCallback(K=>{P("score"),a({type:"hidePuzzleButtons",payload:!1}),a({type:"addPoints",complex:!0,finish:!0,payload:[..._.current,...K]}),a({type:"passPuzzle"})},[P,a]),[F,M]=React$2.useState(!1),I=l[v],{info:$,specificFeedbacks:z}=I;$.description=e,React$2.useEffect(()=>{w.current=0,C.current=0,M(!1)},[v]);const X=React$2.useCallback((K,ne=!1)=>{var pe;let ue={...g};if(ne){if((pe=z==null?void 0:z.correctFeedbacks)!=null&&pe.length&&!I.hasClickOnce){const J=z.correctFeedbacks.length;F&&J?(w.current>0?u(p+(J-w.current)):u(p+J),w.current=J):w.current+=1}else{let J=p;C.current&&(J-=C.current),w.current=I.areas.length,u(J+w.current)}w.current===I.areas.length&&(v+1>=l.length?k(K):S(v+1),ue={...ue,[v]:!0},y(ue)),D(K)}else a({type:"addPoints",payload:K,finish:!1}),a({type:"failPuzzle"}),I.hasClickOrder&&(u(p-w.current),w.current===0&&Object.entries(g).length===0?u(0):w.current=0),Object.entries(g).length===0&&I.hasClickOrder&&!p&&u(0)},[g,z,I.hasClickOnce,I.areas.length,I.hasClickOrder,F,u,p,v,l.length,y,k,S,a]),te=()=>{for(let K=0;K<_.current.length;K=K+1)if(_.current[K].points>0)return!0;return!1},ae=()=>{M(!0),v>=l.length-1&&u(R),P("score"),v+1>=l.length&&te()?($.resolve.rewards.forEach(K=>{_.current.forEach(ne=>{ne.id===K.id&&(K.points=K.points+ne.points)})}),a({type:"puzzleAction",action:"resolve",payload:{element:N,rewards:$.resolve.rewards,finish:!0}})):a({type:"puzzleAction",action:"resolve",payload:{element:N,rewards:$.resolve.rewards,finish:v+1>=l.length}})};React$2.useEffect(()=>{t({...$,hintId:N})},[$,N,t]),React$2.useEffect(()=>{T&&v!==l.length-1&&X([],!0)},[v,l.length,T,X]);const ee=()=>{const K=I.hasClickOnce?I.areas.length:1;C.current+=K,u(p+K)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...I,puzzle:{name:N,component:"chained-image-click-puzzle"},specificFeedbacks:z,emitFinish:X,emitError:D,emitResolve:ae,isLast:v+1===l.length,defaultCompleted:g[v]||!!T,hideContinue:v+1!==l.length,handleClick:ee,emitEvent:a,getEvent:o,disableExit:d,soundActions:f,setResolveAction:h,pause:E,keyboardControl:b},v)}function ChainedImageClickPuzzleComponent(l){const{setInfo:e,emitEvent:n,nodeId:t,list:a,description:o,soundActions:d,showFrames:h,disableExit:f,setResolveAction:u,pause:p,keyboardControl:E,getEvent:T}=l,[v,S]=React$2.useState(0),[g,y]=React$2.useState(0),[b,R]=React$2.useState({}),_=`chained-image-click-puzzle_${g}_${t}`,w=React$2.useMemo(()=>T({type:"loadObjectStatus",payload:_}),[T,_]),C=a.reduce((P,D)=>P+D.areas.length,0),N={list:a,description:o,nodeId:t,disableExit:f,setResolveAction:u,emitEvent:n,soundActions:d,setInfo:e,setSelected:S,selected:v,index:g,setIndex:y,slidesCompleted:b,setSlidesCompleted:R,loadPuzzleStatus:w,pause:p,keyboardControl:E,totalCorrects:C};return jsxRuntimeExports.jsxs("div",{className:"puzzle--image__click",children:[h?jsxRuntimeExports.jsxs("div",{className:"puzzle-image__info",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[v," / ",C]})]}):null,jsxRuntimeExports.jsx(CurrentImageClickPuzzle,{...N})]})}function CurrentFramePuzzle({list:l,index:e,puzzlesCompiledRef:n,framesCompleted:t,handleFinish:a,accRewards:o,setRewards:d,setIndex:h,setFramesCompleted:f,loadPuzzleStatus:u,soundActions:p,setResolveAction:E,disableExit:T,description:v,translateFromParent:S,setInfo:g,emitEvent:y,nodeId:b,setSelected:R,selected:_,emitResetPuzzle:w,firstTryForFrame:C,setPuzzlesAutoCompleted:N,puzzlesAutoCompleted:P,emitOpenPopupCounterInfo:D,resetValues:k,setResetValues:F,pause:M,keyboardControl:I,totalCorrects:$,getEvent:z}){var re;const[X]=p,[te,ae]=React$2.useState(!1),ee=l[e],{info:K,specificFeedbacks:ne}=ee;K.description=v;const ue=React$2.useRef(0),pe=React$2.useRef(0),J=`frame-image-click-puzzle_${e}_${b}`;React$2.useEffect(()=>{n.current+=1},[n]),React$2.useEffect(()=>{g({...K,hintId:J})},[g,K,J]),React$2.useEffect(()=>{k&&(pe.current=0,ue.current=0,R(0),F(!1))},[k,F,R]),React$2.useEffect(()=>{pe.current=0,ue.current=0,ae(!1)},[e]);const H=React$2.useCallback((le,fe=!1)=>{var ge;let de={...t};if(fe){if((ge=ne==null?void 0:ne.correctFeedbacks)!=null&&ge.length&&!ee.hasClickOnce){const Ee=ne.correctFeedbacks.length;te&&Ee?(pe.current>0?R(_+(Ee-pe.current)):R(_+Ee),pe.current=Ee):pe.current+=1}else{let Ee=_;ue.current&&(Ee-=ue.current),pe.current=ee.areas.length,P[0]&&Object.entries(t).length===0?R(pe.current):R(Ee+pe.current)}pe.current===ee.areas.length&&(e+1>=l.length&&a(le),de={...de,[e]:!0},f(de),h(e+1>l.length-1?0:e+1)),d(le)}else y({type:"addPoints",payload:le,finish:!1}),y({type:"failPuzzle"}),ee.hasClickOrder&&(R(_-pe.current),pe.current=0)},[t,(re=ne==null?void 0:ne.correctFeedbacks)==null?void 0:re.length,ee.hasClickOnce,ee.areas.length,ee.hasClickOrder,d,te,R,_,P,e,l.length,f,h,a,y]),W=React$2.useCallback(()=>{for(let le=0;le<o.current.length;le=le+1)if(o.current[le].points>0)return!0;return!1},[o]),V=React$2.useCallback(()=>{ae(!0),e>=l.length-1&&R($),X("score"),y({type:"hidePuzzleButtons",payload:!1}),N(le=>({...le,[e]:!0})),e+1>=l.length&&W()?(K.resolve.rewards.forEach(le=>{o.current.forEach(fe=>{fe.id===le.id&&(le.points=le.points+fe.points)})}),y({type:"puzzleAction",action:"resolve",payload:{element:J,rewards:K.resolve.rewards,finish:!0}})):y({type:"puzzleAction",action:"resolve",payload:{element:J,rewards:K.resolve.rewards,finish:e+1>=l.length}})},[e,l.length,X,y,N,W,R,$,K.resolve.rewards,J,o]),B=React$2.useCallback(()=>{f({}),pe.current=0,ue.current=0,w()},[w,f]);React$2.useEffect(()=>{u&&e!==l.length-1&&H([],!0)},[t,e,l.length,u,H]);const Y=()=>{const le=ee.hasClickOnce?ee.areas.length:1;ue.current+=le,R(_+le)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...ee,className:"puzzle-frame__canvas",puzzle:{name:"",component:"frame-click-puzzle"},specificFeedbacks:ne,emitFinish:H,emitResolve:V,hideContinue:!0,disableInfo:n.current>1,defaultCompleted:t[e]||!!u,soundActions:p,setResolveAction:E,disableExit:T,translateFromParent:S,emitEvent:y,getEvent:z,slideNumber:e,handleClick:Y,emitResetPuzzle:B,firstTryForFrame:C,puzzlesAutoCompleted:P,emitOpenPopupCounterInfo:D,pause:M,keyboardControl:I},e)}function Tooltip({getEvent: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,getEvent:t}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[n?jsxRuntimeExports.jsx(Tooltip,{getEvent: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:h,setInfo:f,getEvent:u,pause:p,keyboardControl:E}){const[T,v]=React$2.useState({}),S=React$2.useRef([]),[g,y]=React$2.useState(0),[b,R]=React$2.useState({}),[_,w]=React$2.useState(0),C=React$2.useRef(0),[N,P]=React$2.useState(!0),[D,k]=React$2.useState(!0),[F,M]=React$2.useState(!1),I=n.reduce((pe,J)=>pe+J.areas.length,0),$=pe=>{S.current=[...S.current,...pe]},z=`frame-image-click-puzzle_${g}_${e}`,X=React$2.useMemo(()=>u({type:"loadObjectStatus",payload:z}),[u,z]),te=React$2.useCallback(pe=>{l({type:"addPoints",complex:!0,finish:!0,payload:[...S.current,...pe]}),l({type:"passPuzzle"})},[l]),ae=React$2.useCallback(()=>{k(!1),S.current=[],w(0),y(0),R({}),P(!0),M(!0)},[]),ee=pe=>u({type:"translate",payload:pe}),K=()=>{P(!0)},ue={firstTryForFrame:D,list:n,description:t,index:g,puzzlesCompiledRef:C,framesCompleted:b,handleFinish:te,setRewards:$,accRewards:S,setSelected:w,selected:_,setIndex:y,setFramesCompleted:R,loadPuzzleStatus:X,soundActions:o,setResolveAction:h,disableExit:d,translateFromParent:ee,setInfo:f,emitEvent:l,nodeId:e,emitResetPuzzle:ae,resetValues:F,setResetValues:M,setPuzzlesAutoCompleted:v,puzzlesAutoCompleted:T,emitOpenPopupCounterInfo:()=>{g===0&&P(!1)},pause:p,keyboardControl:E,totalCorrects:I,getEvent:u};return jsxRuntimeExports.jsxs("div",{className:"puzzle-frame",children:[jsxRuntimeExports.jsx(CurrentFramePuzzle,{...ue}),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:`${_/I*100}%`},className:"puzzle-frame__progress--handle"})})}),a?jsxRuntimeExports.jsx("button",{"data-testid":"puzzle-frame-counter-button",disabled:N,"aria-hidden":N,type:"button",className:"puzzle-frame__info",onClick:K,children:jsxRuntimeExports.jsx(Counter,{current:_,total:I,tooltip:!N,getEvent:u})}):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,h=l?e.header.username:n.username,f=l?e.header.bgImage:n.bgImage;return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__front",style:{backgroundImage:`url(${path+f})`},children:[jsxRuntimeExports.jsxs("div",{className:"facebook--user",children:[jsxRuntimeExports.jsx("span",{className:"facebook--user__circle",style:{backgroundImage:`url(${path+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(h||"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,h=l?e.body.studies:n.studies,f=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 ${h||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(h||"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 ${f||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(f||"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,h=l?e.body.btnColor:n.btnColor,f=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):f}),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:`${h}`},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,h]=React$2.useState(),f=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:()=>h(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 ${f?"disabled":""}`,onClick:f?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,h]=React$2.useState(),f=!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:()=>h(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 ${f?"disabled":""}`,onClick:f?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,h]=React$2.useState(""),f=d==="",[u,p]=React$2.useState(!1),E=u?"puzzle--webBuilder__select--item open":"puzzle--webBuilder__select--item",T=()=>{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:E,onClick:()=>T(),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(v=>v instanceof Object?jsxRuntimeExports.jsxs("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{h(v)},children:[jsxRuntimeExports.jsx("span",{children:t(v.title)}),jsxRuntimeExports.jsx("span",{className:"subtitle",children:t(v.desc)})]},v.title):jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{h(v)},children:t(v)},v))})]})]})})}),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 ${f?"disabled":""}`,disabled:f,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,getEvent:t,setResolveAction:a,soundActions:o,disableExit:d,keyboardControl:h}){const[f,u]=React$2.useState(!1),[p,E]=React$2.useState(!1),[T,v]=React$2.useState(!1),[S,g]=React$2.useState(!1),[y,b]=React$2.useState(!1),[R,_]=React$2.useState(null),w=l==="facebook",C=w?FacebookTemplate:BankTemplate,[N,P]=React$2.useState({type:"",props:{}}),[D,k]=React$2.useState(defaultHeader),[F,M]=React$2.useState(defaultBody),[I]=o,$=W=>t({type:"translate",payload:W}),z=()=>{P({type:"",props:{}})},X=(W,V={})=>{P({type:W,props:V})},te=()=>{if(e.solution){const{rewards:W}=e.solution.right,{rewards:V}=e.solution.wrong;I(T?"fail":"score"),n({type:"addPoints",complex:!0,finish:!0,payload:T?V:W}),n({type:"passPuzzle"})}},ae=h({disabled:R!=="success",forward:te,escape:te});React$2.useEffect(()=>ae(),[ae]);const ee=(W,V)=>{const B=Object.keys(W),Y={existing:0,equal:0};return B.forEach(re=>{V[re]!==null&&V[re]!==""&&(Y.existing+=1),W[re]===V[re]&&(Y.equal+=1)}),Y},K=(W,V)=>{const B=Object.keys(C.header).length,Y=Object.keys(C.body).length,re=ee(C.header,W),le=ee(C.body,V),fe=le.existing+re.existing===B+Y,de=le.equal+re.equal===B+Y;return{exist:fe,equal:de}},ne=()=>{I("click-ui");const{exist:W,equal:V}=K(D,F);n({type:"hidePuzzleButtons",payload:!0}),W&&!V?(y&&b(!1),_("failed"),v(!0),n({type:"failPuzzle"})):W&&V&&(y&&(d(!1),b(!1)),g(!0),_("success"))},ue=W=>{if(Object.keys(W).length>0){const V={...D,...W};k(V),z();const{exist:B}=K(V,F);b(!!B)}},pe=W=>{if(Object.keys(W).length>0){const V={...F,...W};M(V),z();const{exist:B}=K(D,V);b(!!B)}};React$2.useEffect(()=>{a(W=>{E(!0),_("success"),u(!1),setTimeout(()=>{_(""),W()},4e3)}),d(!0)},[a,d,e.resolve.rewards,n]);const J={showingReference:f||p,isFacebook:w,openPopup:X,usingTemplate:C,translate:$},H=()=>{R==="failed"?(_(null),n({type:"hidePuzzleButtons",payload:!1})):R==="success"&&te()};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(PopupComponent,{type:N.type,...N,close:z,soundActions:o,translate:$}),jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder",children:[jsxRuntimeExports.jsx(WebBuilderTopBar,{backActive:f,displayButton:!p&&!S,translate:$,clickAction:()=>{I("click-ui"),u(!f)}}),jsxRuntimeExports.jsx(WebBuilderHeader,{...J,header:D,onSave:ue}),w?jsxRuntimeExports.jsx(WebBuilderFront,{...J,header:D,onSave:ue}):null,jsxRuntimeExports.jsx(WebBuilderBody,{...J,body:F,onSave:pe})]}),!y&&!f?jsxRuntimeExports.jsx(DisplayingFeedback,{feed:R,onNext:H,resolved:p,translate:$}):null,y&&!f?jsxRuntimeExports.jsx(PublishButton,{onPublish:ne,translate:$}):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:h,handleSuccess:f,resolveWithAnyCard:u}){const[p,E]=React$2.useState(Array(l.length).fill(!1)),[T,v]=React$2.useState(Array(l.length).fill(!1)),[S,g]=React$2.useState(0),[y,b]=React$2.useState(!1),[R]=d,_=l.filter(M=>M.correct===!0).length,w=l.filter(M=>M.order).length>0,C=React$2.useCallback(()=>{E(Array(l.length).fill(!1)),v(Array(l.length).fill(!1)),g(0),n(1)},[l.length,n]),N=()=>{setTimeout(()=>{C()},1e3)};function P(M,I=M){const $=Array.from(p);$[M]=I,E($)}const D=React$2.useCallback(()=>{const M=[];l.forEach((I,$)=>{I.correct===!0&&M.push($)}),E(M)},[l]);React$2.useEffect(()=>{o&&D()},[D,o]),React$2.useEffect(()=>{(u&&S||S===_&&_>0)&&(h(),b(!0),g(0))},[S,h,_,u]);const k=M=>{P(M),f(l[M].id||null),g(S+1)},F=M=>{var I,$;if(!y&&!a)if(R("click-ui"),l[M].correct&&!w)k(M);else if(w){if(l[M].order===e)n(e+1),k(M);else if(P(M),l[M].order!==e){const z=Array.from(T);z[M]=M,v(z),t(((I=l[M])==null?void 0:I.id)||null,l[M].correct),N()}}else t((($=l[M])==null?void 0:$.id)||null),P(M),setTimeout(()=>{P(M,!1)},1e3)};return jsxRuntimeExports.jsx("div",{className:`cards-selector__content cards-selector__content-${l.length}`,children:l&&l.map((M,I)=>jsxRuntimeExports.jsx(Card,{setCurrentOrder:n,card:M,handleClick:()=>F(I),flipped:p.includes(I),wrongOrder:T.includes(I),cardIndex:I},`cardPuzzle ${l.indexOf(M)}`))})}Board.defaultProps={setCurrentOrder:()=>{},handleError:()=>{},onFinish:()=>{},handleSuccess:()=>{},documentsDict:{},cards:[],currentOrder:1,resolvePuzzle:!1,feedbackIsShown:!1,resolveWithAnyCard:!1};function CardsSelectorPuzzleComponent({emitEvent:l,getEvent:e,info:n,cards:t,resolveWithAnyCard:a,specificFeedbacks:o,disableExit:d,setResolveAction:h,soundActions:f,backgroundImage:u,nodeId:p,keyboardControl:E,hideBackgroundImageTheme:T=!1}){var H,W;const[v,S]=React$2.useState(!1),[g,y]=React$2.useState(1),[b,R]=React$2.useState(!1),[_,w]=React$2.useState(!1),[C,N]=React$2.useState(!1),[P,D]=React$2.useState([]),[k,F]=React$2.useState(!1),[M,I]=React$2.useState(""),[$]=f,z=V=>e({type:"translate",payload:V}),X=`cards-selector-puzzle_${p}`,te=React$2.useCallback(V=>{R(!1),N(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"addPoints",complex:!0,finish:!0,payload:V}),l({type:"passPuzzle"})},[l]),ae=React$2.useCallback(()=>{var re,le;l({type:"hidePuzzleButtons",payload:!0}),R(!0);const{rewards:V}=((re=n==null?void 0:n.solution)==null?void 0:re.right)||{},B=((le=o==null?void 0:o.correctFeedbacks)==null?void 0:le.map(fe=>fe.rewards).flat())||[],Y=[...P,...V,...B];$("score"),te(Y)},[P,te,l,(H=n==null?void 0:n.solution)==null?void 0:H.right,$,o==null?void 0:o.correctFeedbacks]),ee=()=>{S(!0),n.solution.right.desc&&!(o!=null&&o.specificCorrectFeedbacks)&&I(n.solution.right.desc),N(!0)},K=()=>{b||v?ae():(R(!1),d(!1),N(!1),l({type:"hidePuzzleButtons",payload:!1})),I("")},ne=V=>{if(w(!0),o!=null&&o.specificCorrectFeedbacks){const B=o.correctFeedbacks.find(Y=>Y.id===V);B!=null&&B.desc&&(I(B.desc),N(!0))}$("score"),l({type:"hidePuzzleButtons",payload:!0})},ue=(V,B=!1)=>{var Y,re;if(w(!1),B)I((Y=n.orderFeedback)==null?void 0:Y.desc),N(!0),D([...P,...((re=n.orderFeedback)==null?void 0:re.rewards)||[]]);else if(o!=null&&o.specificWrongFeedbacks){const le=o.wrongFeedbacks.find(fe=>fe.id===V);le!=null&&le.desc?(I(le.desc),N(!0)):(N(!0),setTimeout(()=>{K(),l({type:"hidePuzzleButtons",payload:!1})},2e3)),D([...P,...(le==null?void 0:le.rewards)||[]])}else n.solution.wrong.desc?(I(n.solution.wrong.desc),N(!0)):(N(!0),setTimeout(()=>{K(),l({type:"hidePuzzleButtons",payload:!1})},3e3));d(!0),!(o!=null&&o.specificWrongFeedbacks)&&!B&&D([...P,...n.solution.wrong.rewards]),$("fail"),l({type:"hidePuzzleButtons",payload:!0}),l({type:"failPuzzle"})};React$2.useEffect(()=>{v&&d(!0)},[d,v]),React$2.useEffect(()=>{h(()=>{var B;l({type:"hidePuzzleButtons",payload:!0}),F(!0);const V=[...P,...((B=n==null?void 0:n.resolve)==null?void 0:B.rewards)||{}];setTimeout(()=>{R(!1),N(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:X,rewards:V,finish:!0}})},2e3)})},[h,d,P,(W=n==null?void 0:n.resolve)==null?void 0:W.rewards,l,X]);const pe=React$2.useMemo(()=>{let V="";return V="cards-selector",u!=null&&u.url&&(V+=" cards-selector--with-custom-bg"),T&&(V+=" disable-background-image"),V},[u==null?void 0:u.url,T]),J={backgroundImage:u!=null&&u.url?`url('${u.url}')`:""};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:pe,style:J,children:jsxRuntimeExports.jsx(Board,{setCurrentOrder:y,currentOrder:g,cards:t,onFinish:ee,resolveWithAnyCard:a,handleError:ue,feedbackIsShown:C,resolvePuzzle:k,soundActions:f,handleSuccess:ne})}),C&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:b||_,text:M,hasTimeout:!M,translate:z,functionOnClose:K,keyboardControl:E})]})}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[h,f]=React$2.useState(!0),[u,p]=React$2.useState(""),[E,T]=React$2.useState(!1);React$2.useEffect(()=>{T(e===n-1)},[e,n]);const v=b=>{if(!b||!b.length)return"";const R=b.replace(/<script.*?>.*?<\/script>/gim,""),_=document.createElement("DIV");return _.innerHTML=R,_.textContent||_.innerText||""};React$2.useEffect(()=>{const b=()=>{const _=t.trim().split(" ");return R(_,_.length-1).join(" ")},R=(_,w)=>{if(w<0)return[""];const C=[..._];if(v(_[w]).length!==0){const N=_[w];return C[w]=`<span class="lastWord" >${N}</span>`,C}return R(_,w-1)};o==="election"?p(b()):setTimeout(()=>{p(t)},200)},[o,t]);const S=()=>{a(!0),f(!1)},g=t.split("<p>");g.shift();const y=g.length>1;return h&&t!==""&&u!==""?jsxRuntimeExports.jsx("span",{className:`writer-inline ${y?"multiple":""} ${E?"Typist":""}`,"data-testid":`result-${e}`,children:jsxRuntimeExports.jsx(Typist,{startDelay:300,avgTypingDelay:l,stdTypingDelay:10,onCharacterTyped:d,onTypingDone:S,cursor:{hideWhenDone:!0,hideWhenDoneDelay:200},blink:!0,children:HTMLReactParser$1(t)})}):jsxRuntimeExports.jsxs("span",{className:`writer-inline ${y?"multiple":""} ${E?"Typist":""}`,"data-testid":`result-${e}`,children:[HTMLReactParser$1(u),o==="election"&&E&&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,h=T=>T.previewText!==""?HTMLReactParser$1(T.previewText):HTMLReactParser$1(T.fullText),f=T=>T.previewText!==""?e===t?"icon-eye inspected":"icon-eye":"",u=()=>{d("click-ui"),n(t)},p=T=>{T.keyCode===13&&E(T)},E=T=>{T.preventDefault(),T.stopPropagation(),e===t?(T.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:h(l)})}),jsxRuntimeExports.jsx("div",{onClick:E,onKeyDown:p,className:f(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,h)=>jsxRuntimeExports.jsx(SingleElectionRender,{opt:d,soundActions:t,index:h,setCurrentDecisionSelected:e,setCurrentDecisionInspected:o,decisionInspected:a},h))})}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({getEvent:l,closingAction:e,feedbackIsDone:n,decisionsList:t,texts:a,retryAction:o,retry:d,skip:h,checkCorrect:f,rewardsStack:u,setFailed:p,soundActions:E}){const[T]=E,v=g=>l({type:"translate",payload:g}),S=()=>{T("click-ui"),e(),p(),n()};return jsxRuntimeExports.jsxs("div",{className:`writer-feedback ${u.length?"":"start"}`,children:[jsxRuntimeExports.jsx("div",{className:"writer-feedback__title",children:v("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:[h&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary writer-feedback__btn-mobile",onClick:()=>{S()},children:v("puzzles.skip")}),d&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>{f()?S():(T("click-ui"),o())},children:v(f()?"puzzles.continue":"puzzles.retry")}),!d&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>S(),children:v("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,getEvent:e,styles:n,nodeId:t,retry:a,skip:o,type:d,info:h,setResolveAction:f,documentTitle:u,documentTitle_labelId:p,texts:E,soundActions:T,backgroundImage:v,hideBackgroundImageTheme:S=!1}){const g=rt=>e({type:"translate",payload:rt}),y=React$2.useRef(),[b,R]=React$2.useState(!1),[_,w]=React$2.useState(!1),[C,N]=React$2.useState(0),[P,D]=React$2.useState({[`text_${C}`]:{...E[C],id:`text_${C}`,correct:""}}),[k,F]=React$2.useState(!1),[M,I]=React$2.useState([]),[$,z]=React$2.useState(!1),[X,te]=React$2.useState(!1),[ae,ee]=React$2.useState(!1),[K,ne]=React$2.useState(!0),[ue,pe]=React$2.useState([]),[J,H]=React$2.useState(!0),[W]=T,V=React$2.useRef({}),B=rt=>{let Et;return rt.electionTexts.forEach(($e,pt)=>{$e.correct&&(Et=pt)}),Et},Y=React$2.useCallback(rt=>M.filter($e=>$e.currenTextParagraph===rt)[0].fullText_labelId,[M]),re=React$2.useCallback(()=>E.map((rt,Et)=>{if(rt.type==="fixed")return rt.fullText_labelId??rt.fullText;if(rt.type==="election"){const $e=B(rt);return $e>=0?rt.electionTexts[$e].fullText_labelId:Y(Et)}return""}),[Y,E]),le=12,fe=()=>{if(M){const rt=M.length;let Et=0;for(let $e=0;$e<rt;$e+=1)M[$e].isCorrect==="none"&&(Et+=1);return Et===rt}return!0},de=React$2.useCallback(()=>{if(M){const rt=M.length;let Et=0;for(let $e=0;$e<rt;$e+=1)M[$e].isCorrect==="green"&&(Et+=1);return Et===rt}return!0},[M]),ge=()=>!!(M&&M.length),Ee=()=>M.find(rt=>{const{feedback:Et}=E[rt.currenTextParagraph].electionTexts[rt.index];return Et.body!==""}),Re=React$2.useCallback(()=>{const rt=re();l({type:"finishMedia",payload:{name:p,text:rt,documentType:d,type:"text"}})},[re,p,l,d]),Oe=React$2.useCallback(rt=>{const Et=de();W(_?"fail":Et?"score":"fail"),l({type:"addPoints",complex:!0,finish:!0,payload:rt||ue,onFinish:d!=="view"?Re:null}),l({type:"passPuzzle"})},[de,l,_,Re,W,ue,d]);React$2.useEffect(()=>{b&&H(!1),f(()=>{Oe(h.resolve.rewards)})},[l,Oe,b,Re,h.resolve.rewards,f,d]);const Ne=()=>{R(!1),N(0),I([]),pe([]),w(!1),ee(!1),F(!1),te(!1),z(!1),D({text_0:{...E[0],id:"text_0",correct:""}}),ne(!0),l({type:"addPoints",complex:!0,finish:!1,payload:ue}),l({type:"failPuzzle"})},Xe=()=>{ge()?fe()&&(z(!0),Oe()):(z(!0),ee(!0),Oe()),$?(ne(!1),ae&&!X?te(!0):(X||!ae&&!X)&&(!ae&&!X&&a?de()?Oe():Ne():Oe())):(z(!0),Ee()&&ee(!0))},ft=()=>{const rt=E[C].electionTexts.filter($e=>$e.correct).length,Et=E[C].electionTexts;return rt===0||rt===Et},nt=rt=>{const Et=E[C].electionTexts[rt],$e=Et.feedback.rewards;$e&&$e[0]&&$e[0].points&&(V.current[`t${C}_e${rt}`]||(Et.correct&&(V.current[`t${C}_e${rt}`]=!0),pe([...ue,...$e])));const pt=()=>ft()?"none":Et.correct?"green":"red",He={currenTextParagraph:C,fullText:Et.fullText,index:rt,isCorrect:pt()};D({...P,[`text_${C}`]:{type:"fixed",fullText:Et.fullText,correct:He.isCorrect}}),I([...M,He])},St=()=>{y.current.scrollTop=y.current.scrollHeight+100},ze=()=>{if(y.current.querySelector(".wrapfixed").offsetHeight>y.current.offsetHeight){const rt=y.current.querySelector(".wrapfixed").offsetHeight;y.current.scrollTo({top:rt,behavior:"smooth"})}},Me=(rt,Et,$e)=>{const pt=rt.fullText,He=E[$e+1]?E[$e+1].type:"",Ye=P[`text_${$e+1}`]&&P[`text_${$e+1}`].type?P[`text_${$e+1}`].type:He;return jsxRuntimeExports.jsx(FixedComponent,{length:Et,doneTyping:k,index:$e,delay:le,setDoneTyping:F,nextParagraphType:Ye,isWriting:ze,textToPrint:pt},$e.toString())},ke=(rt,Et)=>{const $e=rt.fullText;return jsxRuntimeExports.jsx(FinishedTextComponent,{textToPrint:$e,correct:rt.correct},Et)},We=rt=>jsxRuntimeExports.jsx(ElectionComponent,{soundActions:T,textWithOpts:rt.electionTexts,setCurrentDecisionSelected:nt,printed:St,disableExit:J},rt.electionTexts),tt=(rt,Et,$e)=>rt.type==="fixed"?Me(rt,Et,$e):We(rt);React$2.useEffect(()=>{k===!0&&(()=>{E[C+1]?(D({...P,[`text_${C+1}`]:{...E[C+1],id:`text_${C+1}`,correct:""}}),N(C+1),F(!1)):R(!0)})()},[k,C,P,E]);const ct=React$2.useMemo(()=>{let rt=`writer-puzzle writer-puzzle--${n}`;return S&&(rt+=" disable-background-image"),rt},[S,n]),Dt={backgroundImage:v!=null&&v.url?`url('${v.url}')`:""};return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:ct,style:Dt,children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__overlay",children:[X&&jsxRuntimeExports.jsx(FeedbackComponent,{getEvent:e,texts:E,setFailed:()=>w(!0),decisionsList:M,closingAction:Xe,retry:a,skip:o,checkCorrect:de,retryAction:Ne,rewardsStack:ue,nodeId:t,soundActions:T}),!X&&jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__container",children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"writer-puzzle__title",children:u!==""&&u}),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:y,children:[jsxRuntimeExports.jsx("div",{className:"wrapfixed",children:K&&!$&&Object.values(P).map((rt,Et)=>tt(rt,Object.values(P).length-1,Et))}),$&&Object.values(P).map((rt,Et)=>ke(rt,Et))]})}),b&&jsxRuntimeExports.jsx("div",{className:"writer-puzzle__footer",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:Xe,children:g("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:h,keyboardControl:f}){var R;const{fileId:u}=l,p=((R=l.document)==null?void 0:R.url)||"",[E]=h,T={image:{component:Image$1,props:{...l,url:p,soundActions:h}},video:{component:VideoVisor,props:{...l,url:p,endVideo:a,soundActions:h,translate:d}},embedded_video:{component:VideoVisor,props:{...l,url:p,soundActions:h}},pdf:{component:PdfVisor,props:{...l,url:p,translate:d,soundActions:h,emitNumberOfPages:()=>{},endPdf:()=>{},keyboardControl:f}},application:{component:PdfVisor,props:{...l,url:p,translate:d,soundActions:h,emitNumberOfPages:()=>{},keyboardControl:f,endPdf:()=>{}}}};if(!T[l.type])return null;const v=T[l.type].component,S=T[l.type].props,y=l.name.replace(/.jpg|.png|.pdf|.mp4/gi,""),b=e.fileId;return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__visor",children:[jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:E,shortText:!0,success:u===b,text:u===b?t.solution.right.desc:t.solution.wrong.desc,functionOnClose:u===b?a:o,additionalStyle:ICONS$1[l.type],secondText:y,translate:d,puzzleHeaderClass:"puzzle--terminal__visor--message",keyboardControl:f}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__visor--body",children:jsxRuntimeExports.jsx(v,{...S})}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__button",children:u===b&&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,getEvent:e,items:n,backgroundImage:t,solution:a,info:o,disableExit:d,soundActions:h,setResolveAction:f,nodeId:u,keyboardControl:p}){const[E,T]=React$2.useState({}),[v]=React$2.useState(!1),[S,g]=React$2.useState([]),y=React$2.useRef([]),[b]=h,R=F=>e({type:"translate",payload:F}),_=`terminal-puzzle_${u}`,w=React$2.useMemo(()=>({name:"init",children:[...FIXED_ITEMS,...n],id:"init"}),[n]),C=React$2.useCallback(F=>{b("click-ui"),T(F),g([...S,F]),F.type!=="folder"&&(l({type:"hidePuzzleButtons",payload:!0}),d(!0))},[S,d,l,b]);React$2.useEffect(()=>{T(w),g([w])},[w]),React$2.useEffect(()=>{f(()=>{y.current=[...y.current,...o.resolve.rewards];const F=y.current.map(M=>{var ae;const{name:I,points:$,type:z,id:X}=M,te={name:I,points:$,type:z,id:X};return(ae=M==null?void 0:M.document)!=null&&ae.resourceId&&(te.id=M.document.resourceId),te});l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:_,rewards:F,finish:!0}})})},[f,o.resolve.rewards,l,_]);const N=()=>{y.current=[...y.current,...o.solution.wrong.rewards];const F=S.length-1,M=S.filter((I,$)=>F>$);T(S[F-1]),g(M),d(!1),l({type:"hidePuzzleButtons",payload:!1})},P=()=>{b("click-ui");const F=S[0];T(F),g([F])},D=()=>{y.current=[...y.current,...o.solution.right.rewards];const F=y.current.map(M=>{var ae;const{name:I,points:$,type:z,id:X}=M,te={name:I,points:$,type:z,id:X};return(ae=M==null?void 0:M.document)!=null&&ae.resourceId&&(te.id=M.document.resourceId),te});l({type:"hidePuzzleButtons",payload:!1}),b("score"),l({type:"addPoints",complex:!0,finish:!0,payload:F}),l({type:"passPuzzle"})},k=(t==null?void 0:t.url)||DEFAULT_IMG;return jsxRuntimeExports.jsx("div",{className:"puzzle--terminal",children:E.children?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Image$1,{isWallpaper:!0,document:{url:k}}),jsxRuntimeExports.jsx(FilesGroup,{backFile:N,initFile:w,selectItem:C,breadcrumb:S,closeFolder:P,file:E,translate:R})]}):jsxRuntimeExports.jsx(Visor,{soundActions:h,backFile:N,resolvePuzzle:D,info:o,showContinue:!v,solution:a,file:E,translate:R,keyboardControl:p})})}function DragItemPuzzleComponent({area:l,image:e,resolveObject:n,info:t,hasHighlights:a,getEvent:o,consume:d,disableExit:h,emitEvent:f,soundActions:u,keyboardControl:p}){const{solution:E}=t,T=React$2.useRef(),v=React$2.useRef(),S=React$2.useRef(),g=React$2.useRef(),y=React$2.useRef({}),[b,R]=React$2.useState(""),[_,w]=React$2.useState(!1),[C,N]=React$2.useState(),[P]=React$2.useState(new window.Image),D=React$2.useRef([]),[k]=u,F=J=>o({type:"translate",payload:J});React$2.useEffect(()=>{h(b!=="")},[b,h]);const M=(J,H)=>(J.x+J.width>H.x&&J.x+J.width<=H.x+H.width||H.x+H.width>J.x&&H.x+H.width<=J.x+J.width)&&(J.y+J.height>H.y&&J.y+J.height<=H.y+H.height||H.y+H.height>J.y&&H.y+H.height<=J.y+J.height),I=()=>{T&&a&&(T.current.to({duration:.25,opacity:.75}),v.current.to({duration:.25,opacity:.4}))},$=()=>{T&&a&&(T.current.to({duration:.25,opacity:0}),v.current.to({duration:.25,opacity:0}))},z=React$2.useCallback(J=>{let H=!1;if(J){const W=S.current;W.setPointersPositions(J);const V=W.getPointerPosition(),B=T.current.getClientRect({relativeTo:W});H=M({...V,width:1,height:1},B)}return H},[]),X=React$2.useCallback(J=>J&&n.uid===JSON.parse(J).uid,[n.uid]),te=React$2.useCallback(()=>{R(""),f({type:"hidePuzzleButtons",payload:!1}),f({type:"addPoints",complex:!0,finish:!0,payload:D.current}),f({type:"passPuzzle"}),d&&f({type:"consumeItem",payload:{uid:n.uid,targetId:n.uid,name:n.name}}),f({type:"closeUI",ui:"inventory"})},[d,f,n.name,n.uid]),ae=React$2.useCallback(()=>{R("success"),f({type:"hidePuzzleButtons",payload:!0}),D.current=[...D.current,...E.right.rewards],setTimeout(()=>{te()},2e3)},[f,te,E.right.rewards]),ee=React$2.useCallback(()=>{f({type:"openUI",ui:"inventory",onFinish:()=>{}}),R(""),f({type:"hidePuzzleButtons",payload:!1}),f({type:"failPuzzle"}),D.current=[...D.current,...E.wrong.rewards]},[f,E.wrong.rewards]),K=React$2.useCallback(J=>{const H=J.dataTransfer.getData("item");S.current.setPointersPositions(J);const W=z(J);f({type:"hidePuzzleButtons",payload:!0}),W&&X(H)?(R("success"),f({type:"closeUI",ui:"inventory"}),t.solution.right.desc===""&&ae()):(f({type:"closeUI",ui:"inventory"}),R("failed"),t.solution.wrong.desc===""&&setTimeout(()=>{ee()},2e3))},[z,X,f,ae,ee,t.solution.right.desc,t.solution.wrong.desc]),ne=()=>{b==="success"?ae():ee()};React$2.useEffect(()=>{const J=e.img.url||"";P.src=J,P.onload=()=>{g.current&&(y.current={x:g.current.clientWidth/2,y:g.current.clientHeight/2,width:P.width,height:P.height,offsetX:P.width/2,offsetY:P.height/2,scale:{x:Math.min(g.current.clientWidth/P.width,g.current.clientHeight/P.height),y:Math.min(g.current.clientWidth/P.width,g.current.clientHeight/P.height)}},w(!0))}},[P,e.img.url]);const ue=J=>{J!==null&&(T.current=J)},pe=J=>{if(J!==null&&(v.current=J,T.current)){const{x:H,y:W,width:V,height:B}=T.current.getClientRect();J.setAttr("x",H),J.setAttr("y",W),J.setAttr("height",B),J.setAttr("width",V)}};return React$2.useLayoutEffect(()=>{if(T.current&&_){const J=T.current.getClientRect({relativeTo:T.current.getParent()});N({x:J.x+J.width/2,y:J.y+J.height/2})}},[_]),jsxRuntimeExports.jsxs("div",{className:"puzzle--drag__mask100",onDrop:K,onDragOver:J=>{J.preventDefault()},children:[jsxRuntimeExports.jsx("div",{className:"puzzle--drag__mask",children:jsxRuntimeExports.jsx("div",{ref:g,"data-testid":"mask_canvas",className:"puzzle--drag__mask--canvas",children:_?jsxRuntimeExports.jsx(Stage,{ref:S,width:g.current.clientWidth,height:g.current.clientHeight,children:jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Image$2,{image:P,...y.current}),jsxRuntimeExports.jsxs(Group,{...y.current,children:[C?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...C},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:"object-area-projection"})}):null,jsxRuntimeExports.jsx(Line,{onMouseEnter:I,onMouseLeave:$,ref:ue,...l,shape:"poly",fill:"#262a31d9",stroke:"white",strokeWidth:1,opacity:0,dash:[3,2],closed:!0,draggable:!1})]}),jsxRuntimeExports.jsx(Text,{onMouseEnter:I,onMouseLeave:$,ref:pe,text:F("puzzle.drag.dropzone"),fontSize:12,align:"center",verticalAlign:"middle",fill:"#ffffff",opacity:0})]})}):null})}),b!==""?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:t.solution[b==="success"?"right":"wrong"].desc,success:b==="success",translate:F,playSound:k,functionOnClose:ne,keyboardControl:p}):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[h,f]=React$2.useState(!1),u=n.answers.filter(y=>y.text),p=y=>{let b=!1;return a[n.id].find(R=>R.id===y)&&(b=!0),b},E=y=>{let b="";return h?(e&&p(y.id)&&(b="selected"),l&&p(y.id)&&o.includes(y.id)&&(b="success"),l&&p(y.id)&&!o.includes(y.id)&&(b="failed")):(e&&y.id===a[n.id][0].id&&(b="selected"),l&&y.id===a[n.id][0].id&&(b=a[n.id][0].isCorrect?"success":"failed")),b},T=y=>{const b=E(y);return b==="selected"?"icon-check-circle-black color--selected":b==="success"?"icon-check-circle-black color--success":b==="failed"?"icon-error-circle-black color--error":""},v=y=>l&&y.feedback&&(h&&p(y.id)||y.id===a[n.id][0].id),S=(y,b)=>b===0?"tooltip--right__top":b===y.length-1?"tooltip--right__bottom":"tooltip--center__right",g=n.answers.filter(y=>y.isCorrect);return React$2.useEffect(()=>{g.length===1?f(!1):f(!0)},[g.length,h,n.answers]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:n.text})}),h&&!l?jsxRuntimeExports.jsx("div",{className:"test--questions__intertitle test--questions__intertitle--multiresponse",children:d("tests.chooseMoreOneAnswer")}):null,u.map((y,b)=>jsxRuntimeExports.jsxs("div",{className:"test--response__fakeinput",children:[h?jsxRuntimeExports.jsx("input",{checked:e&&p(y.id),disabled:l&&!p(y.id),readOnly:l,type:"checkbox",id:y.id,onChange:()=>l?null:t(y,n.id,b,"isCheckbox",y.id)}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("input",{checked:e&&y.id===a[n.id][0].id,disabled:l&&!E(y),type:"radio",name:"name",id:y.id,onChange:()=>l?null:t(y,n.id,b,"isRadio")})}),jsxRuntimeExports.jsxs("label",{htmlFor:y.id,className:`test--response__item ${E(y)}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX$1[b]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:y.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${T(y)}`})]}),l?jsxRuntimeExports.jsxs("div",{className:`test--feedback__info ${v(y)?"":"test--feedback__info--hidden"}`,children:[jsxRuntimeExports.jsx("span",{className:`icon-info2 ${E(y)==="success"?"color--success":"color--error"}`}),jsxRuntimeExports.jsxs("div",{id:`tooltipFeedback-${b}`,className:`tooltip ${S(u,b)}`,children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsx("span",{children:d("test.feedback")})})}),jsxRuntimeExports.jsx("span",{children:jsxRuntimeExports.jsx("span",{children:y.feedback})})]})]}):null]},y.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=h=>e.includes(h),o=(h,f)=>h.index<f.index?-1:h.index>f.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(h=>jsxRuntimeExports.jsxs("div",{className:"test--response__itemwrap",children:[jsxRuntimeExports.jsxs("div",{className:`test--response__item ${a(h.id)?"success":"failed"}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX[h.index]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:h.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${a(h.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[h.index]:""]})})}),jsxRuntimeExports.jsx("span",{children:h.feedback})]})]},h.text))]})}function Container({questions:l,setTime:e,saveInterval:n,result:t,setTries:a,tries:o,time:d,showResults:h,answered:f,answerPage:u,updateForm:p,disabled:E,translate:T,soundActions:v,paused:S,view:g,correctQuestions:y,feedbacksOnlyWhenReview:b}){const R=document.querySelector(".test--container"),[_,w]=React$2.useState(0),[C,N]=React$2.useState(),P=l[_].id,[D]=v;React$2.useEffect(()=>{if(d>=0&&!E&&!S){const te=setInterval(()=>{C||e(ae=>ae-1)},1e3);return n(te),()=>{clearInterval(te)}}},[E,C,S,n,e,d]);const k=()=>{R.scrollTo(0,0),D("click-ui"),f&&(t[P][0].feedback&&!E&&!b?N(!0):(u(!1),w(_+1)))},F=()=>{D("click-ui"),w(_-1)},M=()=>{R.scrollTo(0,0),l[_+1]?(N(!1),u(!1),w(_+1)):h()},I=()=>{R.scrollTo(0,0),a(o+1),t[P][0].feedback&&!E&&!b?N(!0):h()},$=Math.floor(d/60),z=d%60;React$2.useEffect(()=>{if(g==="review"){const te=t[`q${_}`][0].id,ae=document.querySelector(`#${te}`);R.scrollTo(0,ae.offsetTop)}},[_,R,t,g]);const X=()=>{if(f){const te=y[l[_].id.substring(1)].answers,ae=t[P],ee=ae.find(ne=>ne.isCorrect===!1);let K=0;return ae.forEach(ne=>{te.includes(ne.id)&&(K+=1)}),!ee&&K===te.length}return!1};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[g==="review"||C?jsxRuntimeExports.jsx("div",{"data-testid":"feedbackWrapper",className:`test-feedback-header ${X()?"success":"failed"}`,children:jsxRuntimeExports.jsxs("h2",{children:[jsxRuntimeExports.jsx("span",{className:`${X()?"icon-correct-thumb":"icon-incorrect-thumb"}`}),jsxRuntimeExports.jsx("span",{className:"test-feedback-header__title",children:X()?T("tests.resolvedQuestion"):T("tests.notResolvedQuestion")})]})}):null,jsxRuntimeExports.jsxs("div",{className:"test--questions",children:[jsxRuntimeExports.jsx("div",{className:"test--questions__container",children:C?jsxRuntimeExports.jsx(FeedbackItem,{selectedAnswers:t[P],correctQuestions:y[l[_].id.substring(1)].answers,question:l[_].text,translate:T}):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:T("tests.question")})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{children:T("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${$}`:$," : ",z<10?`0${z}`:z]})}):null]}),jsxRuntimeExports.jsx(Questions,{result:t,disabled:E,answered:f,updateForm:p,question:l[_],correctQuestions:E?y[l[_].id.substring(1)].answers:[],translate:T},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()?T("survey.next"):T("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}):null,!C&&l[_+1]?jsxRuntimeExports.jsx("button",{disabled:!f,id:"next-button","data-testid":"nextButton",onClick:()=>k(),type:"button",className:`gat--btn__navigation ${f?"":"disabled"}`,"aria-label":LangIsRtl()?T("survey.previous"):T("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:!f,id:"continue-button","data-testid":"continueButton",onClick:()=>{D("click-ui"),f&&I()},type:"button",className:`gat--btn__navigation ${f?"":"disabled"}`,"aria-label":LangIsRtl()?T("survey.previous"):T("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:h,timeOver:f,timeOverText:u,getEvent:p,minimumPercentage:E}){const T=React$2.useRef(),[v,S]=React$2.useState(0),[g,y]=React$2.useState(),[b,R]=React$2.useState([]),[_,w]=React$2.useState([]),[C,N]=React$2.useState(),P=React$2.useCallback(()=>{const K=[];return t.forEach(ne=>K.push(ne.answers)),K},[t]),D=React$2.useCallback(()=>{const K=[];return Object.values(l).forEach(ne=>{if(ne.length>1){const ue=ne.find(J=>J.isCorrect===!1),pe=[];ue?K.push([]):(ne.forEach(J=>{J.isCorrect&&pe.push(J.id)}),K.push(pe))}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 b.forEach((ne,ue)=>{ne.length>1?ne.every(pe=>{var J;return(J=_[ue])==null?void 0:J.includes(pe)})&&(K+=1):ne.length===1&&_[ue]&&ne[0]===_[ue][0]&&(K+=1)}),K},[b,_]);React$2.useEffect(()=>{C===void 0&&(R(P),w(D),N(k))},[P,D,k,C]);const F=t.length,M=k()===F,I=C<E,$=C>=E,z=!n||$,X=Math.trunc(v/F*100),te=(K,ne)=>p({type:"translate",payload:K,values:ne}),ae={"--chart-color":"var(--color-error)"};React$2.useEffect(()=>{if(v<C){const K=setInterval(()=>{S(ne=>ne+1)},100);return y(K),()=>{clearInterval(K)}}},[C,v]),React$2.useEffect(()=>{v>=C&&clearInterval(g)},[C,g,v]);const ee=()=>{T.current=!0,d()};return jsxRuntimeExports.jsxs("div",{"data-testid":"resultsWrapper",className:`test--results ${I||f?"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,!f&&I?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:te("tests.NotFinishedSuccessfully")})}):null,!f&&$||M?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:te("tests.finishedSuccessfully")})}):null,f?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:te("tests.time",e)})})]}):null,jsxRuntimeExports.jsxs("div",{className:`chart center chart${X}`,children:[jsxRuntimeExports.jsxs("div",{className:"chart-slice",children:[jsxRuntimeExports.jsx("div",{className:"chart-bar",style:I||f?ae:{}}),jsxRuntimeExports.jsx("div",{className:"chart-fill",style:I||f?ae:{}})]}),jsxRuntimeExports.jsxs("span",{className:"chart-value",children:[jsxRuntimeExports.jsxs("div",{className:"test--results__chart",children:[jsxRuntimeExports.jsx("span",{"data-testid":"correctPoints",children:v}),jsxRuntimeExports.jsxs("span",{"data-testid":"totalCorrectAnswers",children:["/",F]})]}),jsxRuntimeExports.jsx("div",{className:"test--results__chart--label",children:jsxRuntimeExports.jsx("span",{children:te("tests.success")})})]})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__minimum",children:[jsxRuntimeExports.jsx("div",{className:"icon-bell"}),jsxRuntimeExports.jsx("div",{children:te("tests.minimumQuestionsMessage",{minimumPercentage:E})})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__buttons",children:[f?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__secondary",id:"review-button",onClick:()=>o(),type:"button",children:jsxRuntimeExports.jsx("span",{children:te("tests.review")})}),z?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary","data-testid":"restartButton",id:"restart-button",onClick:()=>h(),type:"button",children:jsxRuntimeExports.jsx("span",{children:te("tests.restart")})}),z?jsxRuntimeExports.jsx("button",{disabled:T.current===!0,className:`gat--btn gat--btn__primary ${T.current===!0&&"disabled"}`,"data-testid":"finishButton",id:"finish-button",onClick:()=>ee(),type:"button",children:jsxRuntimeExports.jsx("span",{children:te("tests.continue")})}):null]})]})}function TestComponent({test:l,countdown:e={},emitEvent:n,getEvent:t,soundActions:a,audio:o,required:d,pause:h,minimumPercentage:f=100,feedbacksOnlyWhenReview:u}){const{questions:p}=l,[E,T]=React$2.useState({}),[v,S]=React$2.useState(),[g,y]=React$2.useState(0),[b,R]=React$2.useState([]),[_,w]=React$2.useState(e.time),[C,N]=React$2.useState(!1),[P,D]=React$2.useState("test"),[k,F]=React$2.useState(!0),[M,I]=React$2.useState({}),[$,z]=React$2.useState({}),[X,te]=React$2.useState(!1),ae=d||l.required||!1,ee=React$2.useRef({}),[K,ne]=React$2.useState(),[ue,pe]=a,J=(re,le,fe,de,ge)=>{const Ee={...re,index:fe};if(g>0&&(Ee.rewards=Ee.rewards.filter(Oe=>!$[re.id]||Oe.points<0)),E[le]){const Oe=E[le].find(Ne=>Ne.id===ge);if(Oe){if(Oe.id===re.id){const Ne=E[le].find(ft=>ft.id===ge),Xe=E[le].indexOf(Ne);if(E[le].splice(Xe,1),E[le].length===0){N(!1);return}}}else E[le].push(Ee)}else E[le]=[Ee];let Re;de==="isRadio"?Re={...E,[le]:[Ee]}:Re={...E},T(Re),I(Re),z({...$,[re.id]:{...re}}),N(!0)};React$2.useEffect(()=>{o!=null&&o.url&&ue(o.url,"tts")},[ue,o]);const H=p.map(re=>{const le=re.answers.filter(de=>de.isCorrect),fe=[];return le.forEach(de=>{fe.push(de.id)}),{question:re.id,answers:fe}});React$2.useEffect(()=>{b.length===0&&R(H)},[b.length,H]),React$2.useEffect(()=>{if(f){const re=Math.ceil(p.length*f/100);ne(re)}},[p.length,f]),React$2.useEffect(()=>{_===0&&(clearInterval(v),N(!1),te(!0),D("results"),pe("tts"))},[v,pe,_]);const W=()=>{clearInterval(v),N(!1),D("results");const re={...M};I(re),pe("tts")},V=()=>{const re={correctQuestions:b.length,result:E,status:"resolved"};Object.keys(E).forEach(fe=>{E[fe].forEach(de=>{ee.current[de.id]&&(de.rewards=[])})}),n({type:"saveTest",payload:re})},B=()=>{const re=()=>{I({}),z({}),D("test"),T({}),w(e.time),te(!1),o!=null&&o.url&&ue(o.url,"tts")},le=Object.values(E);le.forEach(de=>{de.forEach(ge=>{ge.isCorrect&&(ee.current[ge.id]?ge.rewards=[]:ee.current[ge.id]=!0)})});let fe=le.reduce((de,ge)=>{const Ee=[];return ge.forEach(Re=>{Ee.push(Re.rewards)}),[...de,...Ee.flat()]},[]);X&&e.rewards&&(fe=[...fe,...e.rewards]),n({type:"addPoints",payload:fe,complex:!0,finish:!1,onFinish:re()}),n({type:"failTest"})},Y=(re,le)=>t({type:"translate",payload:re,values:le});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:E,time:_,setTries:y,tries:g,answerPage:N,setTime:w,paused:h,saveInterval:S,disabled:P!=="test",answered:C||P!=="test",questions:p,updateForm:J,showResults:W,translate:Y,soundActions:a,view:P,correctQuestions:b,feedbacksOnlyWhenReview:u}):jsxRuntimeExports.jsx(ResultsComponent,{reviewTest:()=>{F(!1),D("review")},isFirst:k,finishTest:V,time:_,mandatory:ae,restartTest:B,result:E,correctQuestions:b,timeOver:X,timeOverText:e.text,emitEvent:n,getEvent:t,soundActions:a,minimumPercentage:K})})]})}const OPTIONS=["yes","no"],LETTERS=["A","B"];function ApplicableBox({setSurveyData:l,survey:e,id:n,translate:t}){const a=o=>{l({...e,[n]:o})};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:OPTIONS.map((o,d)=>jsxRuntimeExports.jsxs("button",{"data-testid":`applicablebox-${OPTIONS[d]}`,type:"button",onClick:()=>a(o),className:`unset-button survey--response__item ${e[n]===o?"selected":""}`,children:[jsxRuntimeExports.jsx("div",{className:"survey--response__index",children:LETTERS[d]}),jsxRuntimeExports.jsx("div",{className:"survey--response__text",children:t(`survey.${o}`)})]},o))})}const OPINION_OPTIONS=[0,1,2,3,4,5,6,7,8,9,10];function OpinionBox({setSurveyData:l,survey:e,id:n,translate:t}){const a=o=>{l({...e,[n]:o})};return jsxRuntimeExports.jsxs("div",{className:"survey--page__item","aria-label":"opinion box",children:[jsxRuntimeExports.jsx("div",{className:"survey--points",children:OPINION_OPTIONS.map(o=>jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>a(o),className:`unset-button survey--points__item survey--points__item--colorized ${e[n]===o?"selected":""}`,children:o},o))}),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,getEvent:e,soundActions:n}){const[t,a]=React$2.useState(INIT_SURVEY),[o,d]=React$2.useState(0),[h,f]=React$2.useState(!1),[u]=n,p=(v,S)=>e({type:"translate",payload:v,values:S}),E=(v=!1)=>{if(u("click-ui"),!v&&o+1>=PAGES.length)f(!0);else{v&&f(!1);const S=v?o-1:o+1;d(S)}},T=PAGES[o].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:p("survey.numQuestion",{init:o+1,page:PAGES.length})})}),jsxRuntimeExports.jsx("div",{children:p("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsx("label",{className:"survey--questions__item","data-testid":`survey.question${o+1}`,htmlFor:p(`survey.question${o+1}`,{ordinal:o+1}),children:p(`survey.question${o+1}`,{ordinal:o+1})}),jsxRuntimeExports.jsx(T,{setSurveyData:a,id:PAGES[o].id,survey:t,translate:p,literalLabel:p(`survey.question${o+1}`,{ordinal:o+1})})]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next",children:[jsxRuntimeExports.jsx("button",{"data-testid":"backButton",id:"survey-button-back",type:"button",disabled:o===0,onClick:()=>E(!0),className:`gat--btn__navigation ${o===0?"disabled":""}`,"aria-label":LangIsRtl()?p("survey.next"):p("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),h&&o===PAGES.length-1?jsxRuntimeExports.jsx("button",{"data-testid":"survey.finish",id:"survey-button",type:"button",disabled:!t[PAGES[o].id],onClick:()=>{u("click-ui"),l({type:"saveSurvey",payload:t})},className:`gat--btn gat--btn__primary ${t[PAGES[o].id]?"":"disabled"} not-transition`,children:p("survey.finish")}):null,!h&&o!==PAGES.length?jsxRuntimeExports.jsx("button",{"data-testid":"nextButton",id:"survey-button",type:"button",disabled:!t[PAGES[o].id],onClick:()=>E(!1),className:`gat--btn__navigation ${t[PAGES[o].id]?"":"disabled"}`,"aria-label":LangIsRtl()?p("survey.previous"):p("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,getEvent:a,soundActions:o}){var C,N,P;const[d,h]=React$2.useState(null),[f,u]=React$2.useState("start"),[p,E]=React$2.useState(!1),[T,v]=React$2.useState(0),[S,g]=React$2.useState({current:{questions:[],type:n}}),[y]=o,b=D=>a({type:"translate",payload:D}),R=D=>{D.code==="Enter"&&D.target.blur()},_=()=>{y("click-ui"),t({type:"saveSurveyPrePos",payload:S.current})};React$2.useEffect(()=>{!e.length&&f==="questions"&&u("end")},[e,f]);const w=(D,k=!1)=>{var M;const F=D!==null?D:(M=S.current.questions.find(I=>I.id===e[T].id))==null?void 0:M.answer;if(y("click-ui"),k)v(T-1),E(!1);else{const I=S.current.questions.findIndex(z=>z.id===e[T].id),$=[...S.current.questions];I>-1?$.splice(I,1,{id:e[T].id,answer:F}):$.push({id:e[T].id,answer:F}),g({...S,current:{...S.current,questions:$}}),T===e.length-1?E(!0):(v(T+1),E(!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:()=>{u("questions"),y("click-ui")},translate:b}),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:[b("auto-evaluation.question")," ",T+1," ",b("storylines.misc.of")," ",e.length]})}),jsxRuntimeExports.jsx("div",{children:b("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"survey--questions__item","aria-label":"survey questions item",children:(C=e[T])==null?void 0:C.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,k)=>{var F;return jsxRuntimeExports.jsx("button",{"data-testid":`button-option-${0+k}`,type:"button",onTouchStart:()=>{h(k)},onTouchEnd:()=>{h(null)},onKeyUp:M=>{R(M)},onClick:()=>{w(k,!1)},className:`survey--points__item survey--points__item--simple ${((F=S.current.questions[T])==null?void 0:F.answer)===k||d===k?"selected":""}`,children:k},`${0+k}`)})})})]},`${e[T]}`)]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next","aria-label":"test buttons",children:[jsxRuntimeExports.jsx("button",{"data-testid":"back-button",type:"button",disabled:T===0,onClick:()=>w(null,!0),"aria-label":LangIsRtl()?b("survey.next"):b("survey.previous"),className:`gat--btn__navigation ${T===0?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back","aria-label":"icon button"})}),p?jsxRuntimeExports.jsx("button",{"data-testid":"finish-button",type:"button",onClick:()=>{u("end"),y("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",h=n[o]!==e[o];if(d&&h){var f=o.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),l.off(f,n[o])}var u=!e.hasOwnProperty(o);u&&l.setAttr(o,void 0)}var p=e._useStrictMode,E={},T=!1;const v={};for(var o in e)if(!propsToSkip[o]){var d=o.slice(0,2)==="on",S=n[o]!==e[o];if(d&&S){var f=o.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),e[o]&&(v[f]=e[o])}!d&&(e[o]!==n[o]||p&&e[o]!==l.getAttr(o))&&(T=!0,E[o]=e[o])}T&&(l.setAttrs(E),updatePicture(l));for(var f in v)l.on(f+EVENTS_NAMESPACE,v[f])}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 h=d.slice(0,2)==="on";h?o[d]=e[d]:a[d]=e[d]}const f=new t(a);return applyNodeProps(f,o),f}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=h=>{const{forwardedRef:f}=l;f&&(typeof f=="function"?f(h):f.current=h)};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")),h=React$2.useMemo(()=>client.createRoot(d),[d]),f=t??!0,u=useEvent(()=>{if(f&&o.current){let S=o.current.getAbsoluteTransform().decompose();a&&(S=a(S)),d.style.position="absolute",d.style.zIndex="10",d.style.top="0px",d.style.left="0px",d.style.transform=`translate(${S.x}px, ${S.y}px) rotate(${S.rotation}deg) scaleX(${S.scaleX}) scaleY(${S.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:E}=p,T=__rest(p,["style"]);Object.assign(d.style,E),Object.assign(d,T)});return React$2.useLayoutEffect(()=>{var p;const E=o.current;if(!E)return;const T=(p=E.getStage())===null||p===void 0?void 0:p.container();if(T)return T.appendChild(d),f&&needForceStyle(T)&&(T.style.position="relative"),E.on("absoluteTransformChange",u),u(),()=>{var v;E.off("absoluteTransformChange",u),(v=d.parentNode)===null||v===void 0||v.removeChild(d)}},[f]),React$2.useLayoutEffect(()=>{u()},[n,a]),React$2.useLayoutEffect(()=>{h.render(l)}),React$2.useLayoutEffect(()=>()=>{setTimeout(()=>{h.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:h}){const f=React$2.useRef(),[u,p]=React$2.useState(),E=t?"rgba(255, 99, 77, 0.32)":"rgba(75, 215, 169, 0.32)",T=t?"#ff634d":"#4bd7a9",v=DeviceDetection(),S=()=>{var _,w,C;a&&!o&&!n&&((_=f.current)==null||_.setAttr("fill","rgba(130, 134, 142, 0.4)"),(w=f.current)==null||w.setAttr("stroke","rgba(255, 255, 255, 0.3)"),(C=f.current)==null||C.to({duration:.25,opacity:1}))},g=()=>{var _;a&&!o&&!n&&((_=f.current)==null||_.to({duration:.25,opacity:0}))};React$2.useEffect(()=>{var _,w,C;o&&!e&&(t?(C=f.current)==null||C.to({duration:.25,opacity:0}):((_=f.current)==null||_.to({duration:.25,opacity:1}),(w=f.current)==null||w.globalCompositeOperation("destination-out")))},[o,e,t]);const y=()=>{var _,w;o||(t?h(l):d(l),(_=f.current)==null||_.setAttr("fill",E),(w=f.current)==null||w.setAttr("stroke",T))},b=l.scaleX?l.scaleX:1,R=l.scaleY?l.scaleY:1;return React$2.useLayoutEffect(()=>{const _=f.current.getStage();_.on("stage-loaded",()=>{const w=f.current.getClientRect({relativeTo:f.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:f,onFocus:()=>S(),onMouseOver:()=>S(),onMouseLeave:g,onClick:()=>y(),onTap:()=>y(),x:l.x,y:l.y,scale:{x:b,y:R},skew:{x:l.skewX,y:l.skewY},rotation:l.rotation,points:l.points,shape:"poly",fill:e?"":E,stroke:e||n?T:"",strokeWidth:v?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(){const t=document.querySelector("#root");e([t.clientWidth,t.clientHeight])}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:h}){const f=React$2.useRef(),u=React$2.useRef(),p=React$2.useRef(),E=React$2.useRef(),T=React$2.useRef(),v=React$2.useRef(),S=React$2.useRef(),[g,y]=React$2.useState(new window.Image),[b,R]=useWindowSize(),_=e.find(N=>N.id==="AllArea")||!1,w=e.filter(N=>N.id!=="AllArea");React$2.useEffect(()=>{S.current&&u.current&&t&&(S.current.to({duration:.25,opacity:.5}),u.current.setAttr("visible",!0))},[t]);const C=N=>{_&&!N.target.attrs.shape&&o(_)};return React$2.useEffect(()=>{g.src=n,g.addEventListener("load",()=>{if(f.current){const N={x:b/2,y:R/2,width:g.width,height:g.height,offsetX:g.width/2,offsetY:g.height/2,scale:{x:Math.min(b/g.width,R/g.height),y:Math.min(b/g.width,R/g.height)}};E.current&&E.current.setAttrs(N),T.current&&T.current.setAttrs(N),u.current&&u.current.setAttrs(N),p.current&&p.current.setAttrs(N),v.current&&v.current.setAttrs(N),f.current.batchDraw(),y(g),f.current.fire("stage-loaded")}})},[g,R,n,b]),jsxRuntimeExports.jsxs(Stage,{ref:f,width:b,height:R,onClick:C,onTouchEnd:C,children:[jsxRuntimeExports.jsx(Layer,{children:jsxRuntimeExports.jsx(Image$2,{ref:v,image:g})}),jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Rect,{ref:S,width:b,height:R,fill:"black",opacity:0}),jsxRuntimeExports.jsx(Group,{ref:T,children:w.map((N,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:d,completed:t,onClick:a,onClickOutside:o,area:N,isBad:!0},N.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:E,children:l.map((N,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:d,completed:t,onClick:a,onClickOutside:o,area:N,isClicked:h.some(D=>D.index===N.index)},N.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:p,visible:!1,children:w.map((N,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:d,completed:t,onClick:a,onClickOutside:o,area:N,isBad:!0,finished:!0},N.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:u,visible:!1,children:l.map((N,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:d,completed:t,onClick:a,onClickOutside:o,area:N,finished:!0},N.name+"_"+P))})]})]})}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 Ye,Pe,we;const{soundActions:e,emitEvent:n,getEvent:t,handleClick:a,disableExit:o,setResolveAction:d,info:h,image:f,areas:u,badAreas:p,hasClickOrder:E,timer:T,hasClickOnce:v,hasHighlights:S,hasImageReview:g,defaultCompleted:y,className:b,emitFinish:R,emitResolve:_,translateFromParent:w,specificFeedbacks:C,slideNumber:N,emitResetPuzzle:P,firstTryForFrame:D,puzzlesAutoCompleted:k,emitOpenPopupCounterInfo:F,pause:M,keyboardControl:I}=l,[$,z]=React$2.useState([]),[X,te]=React$2.useState(!1),[ae,ee]=React$2.useState(!1),[K,ne]=React$2.useState({show:!1,success:!1,text:"",rewards:[]}),ue=React$2.useRef(!1),[pe,J]=React$2.useState(!0),[H,W]=React$2.useState(!1),V=React$2.useRef(null),B=React$2.useRef(null),Y=React$2.useRef(null),re=React$2.useRef(null),le=React$2.useRef(null),fe=React$2.useRef(null),de=React$2.useRef(null),ge=React$2.useRef(null),Ee=React$2.useRef(null),[Re,Oe]=React$2.useState(T),Ne=ye=>w?w(ye):t({type:"translate",payload:ye}),[Xe]=e,{solution:ft}=h,nt=((Ye=f==null?void 0:f.img)==null?void 0:Ye.url)||defaultImg,St=u.map((ye,De)=>({index:De,shape:"poly",...ye})),ze=p.map((ye,De)=>({index:De,shape:"poly",...ye})),Me=React$2.useCallback(()=>{if(!pe){const ye=setInterval(()=>{Oe(De=>De>1?De-1:0)},1e3);Ee.current=ye}},[pe]),ke=React$2.useCallback((ye,De)=>{R?R(ye,De):n({type:"addPoints",payload:ye})},[n,R]);React$2.useEffect(()=>{X&&o(!0)},[X,o]),React$2.useEffect(()=>{te(y)},[y]);const We=React$2.useCallback(()=>{clearInterval(Y.current)},[]),tt=React$2.useCallback(()=>{clearInterval(Ee.current)},[]),ct=React$2.useCallback(ye=>{le.current=Date.now(),re.current?(de.current=re.current-le.current,We()):(de.current=le.current-(le.current-ye*1e3),We())},[We]),Dt=React$2.useCallback(()=>{ne(()=>{var ye,De;return{show:!0,success:!1,text:(ye=h==null?void 0:h.timerFeedback)!=null&&ye.desc?h.timerFeedback.desc:"",rewards:(De=h==null?void 0:h.timerFeedback)==null?void 0:De.rewards}}),W(!0),tt(),We()},[tt,We,(Pe=h.timerFeedback)==null?void 0:Pe.desc,(we=h.timerFeedback)==null?void 0:we.rewards]),rt=React$2.useCallback(()=>{clearInterval(Y.current),Y.current=setInterval(()=>{B.current=Date.now(),B.current>re.current&&Dt()},250)},[Dt]);React$2.useEffect(()=>{var ye;if((u.length===$.length||v&&$.length>0)&&!X){te(!0);const De=$[$.length-1],qe=C==null?void 0:C.correctFeedbacks.find(Lt=>Lt.id===De.id);(!((ye=C==null?void 0:C.correctFeedbacks)!=null&&ye.length)||C!=null&&C.correctFeedbacks.some(Lt=>!Lt.desc)||v)&&(ne(Lt=>({...Lt,show:!0,success:!0,text:qe?qe.desc:h.solution.right.desc,rewards:qe?qe.rewards:h.solution.right.rewards})),T&&(tt(),ct()))}},[$,u.length,C,v,X,h.solution.right,ct,T,tt]),React$2.useEffect(()=>{d(ye=>{T&&(tt(),J(!1),K.show?ne(De=>({...De,show:!1,success:!1,text:"",rewards:[]})):We()),te(!0),ee(!0),setTimeout(()=>{_?_(ye):ye()},4e3)})},[d,_,Xe,T,K.show,We,tt]),React$2.useEffect(()=>{ae&&o(!0)},[ae,o]);const Et=(ye,De=!1)=>{var qe,Lt;if(!X){const{rewards:kt,desc:Le}=ft.wrong;let ht=Le,wt=kt;const at=(qe=C==null?void 0:C.wrongFeedbacks)==null?void 0:qe.find(Pt=>Pt.id===ye.id);at&&(ht=at.desc,wt=at.rewards),E&&(z([]),De&&(Lt=h==null?void 0:h.orderFeedback)!=null&&Lt.desc&&(ht=h.orderFeedback.desc,wt=h.orderFeedback.rewards)),T&&(tt(),ct()),ne(Pt=>({...Pt,show:!0,success:!1,text:ht,rewards:wt})),Xe("fail")}},$e=React$2.useCallback(()=>{fe.current=Date.now();const ye=fe.current+de.current;B.current=null,re.current=ye,(T||H)&&(K.success?u.length===$.length||v&&$.length>0?tt():(Oe(de.current*.001),Me(),rt()):(z([]),J(!0),P())),ke(K.rewards,K.success),Xe("click-ui"),ne(De=>({...De,show:!1,success:!1,text:"",rewards:[]}))},[T,H,ke,K.rewards,K.success,Xe,u.length,$.length,v,P,tt,Me,rt]),pt=ye=>{var De,qe;if(!$.some(Lt=>Lt.index===ye.index)&&!K.show&&!X){Xe("click-ui");let Lt=ft.right.desc,{rewards:kt}=ft.right;const Le=[...$,ye];if(E&&ye.index===$.length||!E){if(T&&ct(Re),a(),(De=C==null?void 0:C.correctFeedbacks)!=null&&De.length){const ht=(qe=C.correctFeedbacks)==null?void 0:qe.find(wt=>wt.id===ye.id);ht&&(Lt=ht.desc,kt=ht.rewards),!Lt&&u.length>Le.length&&!v?ke(kt,!0):Lt&&!v&&(ne(wt=>({...wt,show:!0,success:!0,text:Lt,rewards:kt})),T&&tt())}z(Le)}else Et(ye,!0)}},He=React$2.useCallback(()=>{tt(),Oe(T),Me(),!ue.current&&D&&F(),J(!1),V.current=Date.now(),re.current=V.current+T*1e3,rt()},[tt,T,Me,D,rt,F]);return React$2.useEffect(()=>{T&&N>0&&!ge.current&&(D&&Object.keys(k).length&&k[N-1]?(J(!0),ge.current=!0):J(!1))},[y,D,k,N,T]),React$2.useEffect(()=>{T&&Re===0&&Dt()},[Re,Dt,T]),React$2.useEffect(()=>{T&&(M?(tt(),ct()):Me())},[tt,rt,M,ct,Me,T]),jsxRuntimeExports.jsxs("div",{className:b,children:[K.show?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:Xe,text:K.text,success:K.success,translate:Ne,hasTimeout:!K.text,delay:T?1e3:2e3,functionOnClose:$e,timeExpired:H,keyboardControl:I}):null,jsxRuntimeExports.jsx(KonvaMapper,{completed:X,imageUrl:nt,areas:v&&$.length?[$[0]]:St,badAreas:ze,clickedZones:$,onClick:pt,onClickOutside:Et,hasHighlights:S,emitEvent:n}),g?jsxRuntimeExports.jsx(ImageReview,{}):null,T&&pe?jsxRuntimeExports.jsx(TimerDialog,{retry:D||k[N-1],translate:Ne,onInit:He}):null,T?jsxRuntimeExports.jsx(CountDown,{time:Re}):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:()=>{},getEvent:()=>{}};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 h=Math.floor(Math.random()*n),f=Math.floor(Math.random()*t);o[h][f].value=d,a.push({char:d,position:[h,f]})}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((f,u)=>{const p=[o,d],E=getDistance(u.position,p);return E<f?E:f},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 h={color:"",hiddenColor:RED,value:n[Math.floor(Math.random()*n.length)]};o.push(h)}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,h]=generatePasswordPositions(o,n,e,l);return paintedGridPassword(d,e,l,h)};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:h,getEvent:f}){const[u]=e,p=J=>f({type:"translate",payload:J}),E=React$2.useRef(),T=React$2.useRef(),{solution:v}=n,[S,g]=React$2.useState(a.toLowerCase()),[y,b]=React$2.useState(),[R,_]=React$2.useState(Array(a.toLowerCase().length).fill("")),[w,C]=React$2.useState(!1),[N,P]=React$2.useState([0,0]),D=p("puzzle.cracker.crackedPassword"),k=n.solution.right.desc&&n.solution.right.desc!==""?n.solution.right.desc:"",F=p("puzzle.cracker.congratulations"),[M,I]=React$2.useState([[]]),{visibleRows:$,visibleColumns:z}=DIFFICULTY_MAP[d];let X=$==="auto"?Math.ceil(window.innerHeight*.025):$;X=X>=20?X:20,React$2.useEffect(()=>{w&&o(!0)},[w,o]),React$2.useEffect(()=>{h(J=>{u("score"),C(!0),setTimeout(()=>{l({type:"hidePuzzleButtons",payload:!1}),J()},0)})},[h,u]);const te=()=>{u("click-ui");const{rewards:J}=v.right;l({type:"addPoints",complex:!0,finish:!0,payload:J}),l({type:"passPuzzle"})},ae=()=>a.toLowerCase().split("").map((H,W)=>({char:H,index:W,used:!1})),ee=J=>J.filter(H=>H.used===!1).map(H=>H.char).join(""),K=J=>{if(J[0].length>0&&!w){const H=[...J];return H.push(H.shift()),H}return J};let ne=0;const ue=J=>{if(T.current!==void 0){const H=J-T.current;ne+=H,ne>1e3/VELOCITY_MAP[t]&&(I(K),ne=0)}T.current=J,E.current=requestAnimationFrame(ue)};React$2.useEffect(()=>{g(a.toLowerCase());const J=makeSomeNoise({numberOfColumns:z,numberOfRows:X,password:a.toLowerCase()});return I(J),b(ae()),E.current=requestAnimationFrame(ue),()=>cancelAnimationFrame(E.current)},[]);const pe=()=>{if(M.length<=1)return;const[J,H]=N,W=M[J][H];if(W.hiddenColor===GREEN){const V=y.filter(B=>B.char===W.value.toLowerCase()&&B.used===!1)[0];if(V){const{index:B}=V;u("score");const Y=y;Y[B].used=!0,b(Y);const re=[...R];re[B]=W.value;const le=ee(Y);g(le);const fe=repaintGridPassword(M,le,X,z);I(fe),_(re)}}S<=0&&(u("score"),C(!0))};return React$2.useEffect(()=>{w||pe()},[N]),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:R.map((J,H)=>jsxRuntimeExports.jsx("span",{className:"puzzle--pieces__item",children:J&&jsxRuntimeExports.jsx("span",{className:"character success-transition-animation","data-testid":`solution${H}`,children:J})},`${J+H}`))})]}),jsxRuntimeExports.jsx(DrawGrid,{grid:w?[[]]:M,cursorPosition:N,setCursorPosition:P}),w&&D&&F&&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:[F," "]}),k!==""&&jsxRuntimeExports.jsx("span",{children:k})]}),jsxRuntimeExports.jsx("div",{className:"position--absolute bottom center",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary gat--btn__cracker",onClick:te,children:p("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,h)=>jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__word","data-testid":`result-${h}`,children:n?d.map((f,u)=>jsxRuntimeExports.jsx("span",{className:"puzzle--hanged__letter active",children:f},`${f+u}`)):d.filter(({char:f})=>f!==" ").map(({char:f,fixed:u},p)=>jsxRuntimeExports.jsx("span",{className:`puzzle--hanged__letter ${u?"":"active"} ${d[p].positionInitial===e?"fakeFocus":""}`,children:f},`${f+p}`))},`${d+h}`))},defaultImage="https://min.gamelearn.io/css-resources/gamelearn/resources/partenon.jpg";function HangedPuzzleComponent({soundActions:l,emitEvent:e,getEvent:n,disableExit:t,question:a,image:o,info:d,answer:h,hintUsed:f,setResolveAction:u,setHintAction:p,keyboardControl:E}){var fe;const[T]=l,v=((fe=o.img)==null?void 0:fe.url)||defaultImage,[S,g]=React$2.useState(0),[y,b]=React$2.useState(!1),[R,_]=React$2.useState([]),[w,C]=React$2.useState(!1),[N,P]=React$2.useState([]),[D,k]=React$2.useState(""),[F,M]=React$2.useState(!1),[I,$]=React$2.useState([]),[z,X]=React$2.useState(!1),te=h.toUpperCase().split(""),ae=te.filter(de=>restrictCharacters(de,"and")),ee=de=>n({type:"translate",payload:de}),K=React$2.useCallback(()=>{const de=ae.map(Re=>({char:Re}));let ge=[];const Ee=analyzeChars(ae);for(;ge.length<MAX_EXTRA_LETTERS;){const Re=makeChar(Ee);ge=[...ge,{char:Re}]}return[...de,...ge]},[ae]),ne=h.toUpperCase().split("").map((de,ge)=>restrictCharacters(de,"or")?{index:ge,letter:de,char:de,fixed:!0}:{index:ge,letter:de,char:""}),ue=React$2.useCallback(()=>{let de=K();for(;de.length>MAX_POOL_LETTERS;){const ge=Math.trunc(Math.random()*(de.length-1))+1,Ee=de[ge],Re=ne.find((Oe,Ne)=>Ee.char===Oe.letter&&!ne[Ne].fixed);Re&&(de.splice(ge,1),ne[Re.index]={...Re,char:Re.letter,fixed:!0})}f&&(de=[],ne.forEach(({letter:ge})=>{ge!==" "&&de.push({char:ge})})),P(ne),_(de)},[ne,f,K]),pe=(de,ge)=>R.map((Re,Oe)=>Oe===ge?{...Re,deleted:!0}:{...Re}),J=(de,ge,Ee)=>{const Re=ge.map((Ne,Xe)=>Ee.find(nt=>nt.poolIndex===Xe)?{char:Ne.char}:Ne);_(Re),P(de);const Oe=de.find(Ne=>Ne.char==="");g(Oe.index)},H=(de,ge)=>{T("click-ui");let Ee=!1;const Re=N.map(Xe=>!Xe.char&&!Ee?(Ee=!0,{...Xe,char:de,poolIndex:ge}):Xe),Oe=pe(de,ge),Ne=Re.filter(Xe=>Xe.char).length;_(Oe),P(Re),W(),Ne===N.length&&re(Re,Oe)},W=()=>{var de;if(y){const ge=N.find(Ee=>Ee.index!==S&&Ee.letter!==" "&&Ee.char===""&&Ee.poolIndex===!1);ge&&g(ge.index)}else{const ge=N.find(Ee=>Ee.char==="");g(ge.index+1),((de=N[ge.index+1])==null?void 0:de.letter)===" "&&g(ge.index+2)}},V=()=>{T("click-ui");const de=N.map((ge,Ee)=>N[N.length-1-Ee]).find(ge=>ge.char&&!ge.fixed);if(de){const ge=N.map(Oe=>Oe.index===de.index?{...de,char:""}:Oe);let Ee=!1;const Re=R.map((Oe,Ne)=>Ne===de.poolIndex&&(Oe.deleted||!Ee)?(Ee=!0,{char:Oe.char}):Oe);_(Re),P(ge),g(de.index)}},B=()=>{t(!0),k("");const de=[...I,...d.solution.right.rewards];T("score"),e({type:"hidePuzzleButtons",payload:!1}),e({type:"addPoints",complex:!0,finish:!0,payload:de}),e({type:"passPuzzle"})},Y=()=>{T("fail"),e({type:"hidePuzzleButtons",payload:!1}),$([...I,...d.solution.wrong.rewards]),k(""),M(!1),e({type:"failPuzzle"}),b(!0)},re=(de,ge)=>{let Ee=[];M(!0);const Re=de.map((Ne,Xe)=>te[Xe]===Ne.char?{...Ne,fixed:!0}:(Ee=[...Ee,Ne],{...Ne,poolIndex:!1,char:""})),Oe=Re.filter(Ne=>Ne.fixed).length;e({type:"hidePuzzleButtons",payload:!0}),Oe===te.length?(k("success"),d.solution.right.desc===""&&setTimeout(()=>{B()},2e3)):(k("failed"),J(Re,ge,Ee),d.solution.wrong.desc===""&&setTimeout(()=>{Y()},2e3))},le=()=>{if(D==="success")B();else{Y();const de=N.find(ge=>ge.char==="");g(de.index)}};return React$2.useEffect(()=>{w||(C(!0),ue()),u(de=>{X(!0),setTimeout(()=>{e({type:"hidePuzzleButtons",payload:!1}),de()},2e3)}),p(de=>{const ge=[];ne.forEach(({letter:Ee})=>{Ee!==" "&&ge.push({char:Ee})}),_(ge),de()})},[ue,w,h,u,e,I,d.resolve.rewards,ne,p]),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged",style:{backgroundImage:`url("${v}")`},children:[D?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:T,text:d.solution[D==="success"?"right":"wrong"].desc,success:D==="success",translate:ee,functionOnClose:le,keyboardControl:E}):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:a}),jsxRuntimeExports.jsx("div",{dir:"auto",className:`puzzle--hanged__solution ${D}`,"data-testid":`${D}`,children:z?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:z,answer:h.split(""),show:!0})}):jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:z,flickerPosition:S,answer:N})}),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__keyboard",children:[R.sort((de,ge)=>sortChar(de,ge)).map((de,ge)=>jsxRuntimeExports.jsx("button",{"data-testid":`key-${de.char}`,type:"button",onClick:()=>{!de.deleted&&!D&&!F&&(H(de.char,ge),T("click-ui"))},className:`puzzle--hanged__keyboard--item ${de.deleted||F?"disabled":""}`,children:de.char},`${de+ge}`)),jsxRuntimeExports.jsx("button",{onClick:F?null:()=>V(),type:"button",disabled:F?"disabled":null,"aria-label":ee("puzzles.hanged-puzzle.deleteButton"),className:`puzzle--hanged__keyboard--item delete ${F?"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,getEvent:o,disableExit:d,setResolveAction:h,soundActions:f,setSelected:u,selected:p,pause:E,loadPuzzleStatus:T,index:v,setIndex:S,slidesCompleted:g,setSlidesCompleted:y,keyboardControl:b,totalCorrects:R}){const _=React$2.useRef([]),w=React$2.useRef(0),C=React$2.useRef(0),N=`chained-image-click-puzzle_${v}_${n}`,[P]=f,D=K=>{_.current=[..._.current,...K]},k=React$2.useCallback(K=>{P("score"),a({type:"hidePuzzleButtons",payload:!1}),a({type:"addPoints",complex:!0,finish:!0,payload:[..._.current,...K]}),a({type:"passPuzzle"})},[P,a]),[F,M]=React$2.useState(!1),I=l[v],{info:$,specificFeedbacks:z}=I;$.description=e,React$2.useEffect(()=>{w.current=0,C.current=0,M(!1)},[v]);const X=React$2.useCallback((K,ne=!1)=>{var pe;let ue={...g};if(ne){if((pe=z==null?void 0:z.correctFeedbacks)!=null&&pe.length&&!I.hasClickOnce){const J=z.correctFeedbacks.length;F&&J?(w.current>0?u(p+(J-w.current)):u(p+J),w.current=J):w.current+=1}else{let J=p;C.current&&(J-=C.current),w.current=I.areas.length,u(J+w.current)}w.current===I.areas.length&&(v+1>=l.length?k(K):S(v+1),ue={...ue,[v]:!0},y(ue)),D(K)}else a({type:"addPoints",payload:K,finish:!1}),a({type:"failPuzzle"}),I.hasClickOrder&&(u(p-w.current),w.current===0&&Object.entries(g).length===0?u(0):w.current=0),Object.entries(g).length===0&&I.hasClickOrder&&!p&&u(0)},[g,z,I.hasClickOnce,I.areas.length,I.hasClickOrder,F,u,p,v,l.length,y,k,S,a]),te=()=>{for(let K=0;K<_.current.length;K=K+1)if(_.current[K].points>0)return!0;return!1},ae=()=>{M(!0),v>=l.length-1&&u(R),P("score"),v+1>=l.length&&te()?($.resolve.rewards.forEach(K=>{_.current.forEach(ne=>{ne.id===K.id&&(K.points=K.points+ne.points)})}),a({type:"puzzleAction",action:"resolve",payload:{element:N,rewards:$.resolve.rewards,finish:!0}})):a({type:"puzzleAction",action:"resolve",payload:{element:N,rewards:$.resolve.rewards,finish:v+1>=l.length}})};React$2.useEffect(()=>{t({...$,hintId:N})},[$,N,t]),React$2.useEffect(()=>{T&&v!==l.length-1&&X([],!0)},[v,l.length,T,X]);const ee=()=>{const K=I.hasClickOnce?I.areas.length:1;C.current+=K,u(p+K)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...I,puzzle:{name:N,component:"chained-image-click-puzzle"},specificFeedbacks:z,emitFinish:X,emitError:D,emitResolve:ae,isLast:v+1===l.length,defaultCompleted:g[v]||!!T,hideContinue:v+1!==l.length,handleClick:ee,emitEvent:a,getEvent:o,disableExit:d,soundActions:f,setResolveAction:h,pause:E,keyboardControl:b},v)}function ChainedImageClickPuzzleComponent(l){const{setInfo:e,emitEvent:n,nodeId:t,list:a,description:o,soundActions:d,showFrames:h,disableExit:f,setResolveAction:u,pause:p,keyboardControl:E,getEvent:T}=l,[v,S]=React$2.useState(0),[g,y]=React$2.useState(0),[b,R]=React$2.useState({}),_=`chained-image-click-puzzle_${g}_${t}`,w=React$2.useMemo(()=>T({type:"loadObjectStatus",payload:_}),[T,_]),C=a.reduce((P,D)=>P+D.areas.length,0),N={list:a,description:o,nodeId:t,disableExit:f,setResolveAction:u,emitEvent:n,soundActions:d,setInfo:e,setSelected:S,selected:v,index:g,setIndex:y,slidesCompleted:b,setSlidesCompleted:R,loadPuzzleStatus:w,pause:p,keyboardControl:E,totalCorrects:C};return jsxRuntimeExports.jsxs("div",{className:"puzzle--image__click",children:[h?jsxRuntimeExports.jsxs("div",{className:"puzzle-image__info",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[v," / ",C]})]}):null,jsxRuntimeExports.jsx(CurrentImageClickPuzzle,{...N})]})}function CurrentFramePuzzle({list:l,index:e,puzzlesCompiledRef:n,framesCompleted:t,handleFinish:a,accRewards:o,setRewards:d,setIndex:h,setFramesCompleted:f,loadPuzzleStatus:u,soundActions:p,setResolveAction:E,disableExit:T,description:v,translateFromParent:S,setInfo:g,emitEvent:y,nodeId:b,setSelected:R,selected:_,emitResetPuzzle:w,firstTryForFrame:C,setPuzzlesAutoCompleted:N,puzzlesAutoCompleted:P,emitOpenPopupCounterInfo:D,resetValues:k,setResetValues:F,pause:M,keyboardControl:I,totalCorrects:$,getEvent:z}){var re;const[X]=p,[te,ae]=React$2.useState(!1),ee=l[e],{info:K,specificFeedbacks:ne}=ee;K.description=v;const ue=React$2.useRef(0),pe=React$2.useRef(0),J=`frame-image-click-puzzle_${e}_${b}`;React$2.useEffect(()=>{n.current+=1},[n]),React$2.useEffect(()=>{g({...K,hintId:J})},[g,K,J]),React$2.useEffect(()=>{k&&(pe.current=0,ue.current=0,R(0),F(!1))},[k,F,R]),React$2.useEffect(()=>{pe.current=0,ue.current=0,ae(!1)},[e]);const H=React$2.useCallback((le,fe=!1)=>{var ge;let de={...t};if(fe){if((ge=ne==null?void 0:ne.correctFeedbacks)!=null&&ge.length&&!ee.hasClickOnce){const Ee=ne.correctFeedbacks.length;te&&Ee?(pe.current>0?R(_+(Ee-pe.current)):R(_+Ee),pe.current=Ee):pe.current+=1}else{let Ee=_;ue.current&&(Ee-=ue.current),pe.current=ee.areas.length,P[0]&&Object.entries(t).length===0?R(pe.current):R(Ee+pe.current)}pe.current===ee.areas.length&&(e+1>=l.length&&a(le),de={...de,[e]:!0},f(de),h(e+1>l.length-1?0:e+1)),d(le)}else y({type:"addPoints",payload:le,finish:!1}),y({type:"failPuzzle"}),ee.hasClickOrder&&(R(_-pe.current),pe.current=0)},[t,(re=ne==null?void 0:ne.correctFeedbacks)==null?void 0:re.length,ee.hasClickOnce,ee.areas.length,ee.hasClickOrder,d,te,R,_,P,e,l.length,f,h,a,y]),W=React$2.useCallback(()=>{for(let le=0;le<o.current.length;le=le+1)if(o.current[le].points>0)return!0;return!1},[o]),V=React$2.useCallback(()=>{ae(!0),e>=l.length-1&&R($),X("score"),y({type:"hidePuzzleButtons",payload:!1}),N(le=>({...le,[e]:!0})),e+1>=l.length&&W()?(K.resolve.rewards.forEach(le=>{o.current.forEach(fe=>{fe.id===le.id&&(le.points=le.points+fe.points)})}),y({type:"puzzleAction",action:"resolve",payload:{element:J,rewards:K.resolve.rewards,finish:!0}})):y({type:"puzzleAction",action:"resolve",payload:{element:J,rewards:K.resolve.rewards,finish:e+1>=l.length}})},[e,l.length,X,y,N,W,R,$,K.resolve.rewards,J,o]),B=React$2.useCallback(()=>{f({}),pe.current=0,ue.current=0,w()},[w,f]);React$2.useEffect(()=>{u&&e!==l.length-1&&H([],!0)},[t,e,l.length,u,H]);const Y=()=>{const le=ee.hasClickOnce?ee.areas.length:1;ue.current+=le,R(_+le)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...ee,className:"puzzle-frame__canvas",puzzle:{name:"",component:"frame-click-puzzle"},specificFeedbacks:ne,emitFinish:H,emitResolve:V,hideContinue:!0,disableInfo:n.current>1,defaultCompleted:t[e]||!!u,soundActions:p,setResolveAction:E,disableExit:T,translateFromParent:S,emitEvent:y,getEvent:z,slideNumber:e,handleClick:Y,emitResetPuzzle:B,firstTryForFrame:C,puzzlesAutoCompleted:P,emitOpenPopupCounterInfo:D,pause:M,keyboardControl:I},e)}function Tooltip({getEvent: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,getEvent:t}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[n?jsxRuntimeExports.jsx(Tooltip,{getEvent: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:h,setInfo:f,getEvent:u,pause:p,keyboardControl:E}){const[T,v]=React$2.useState({}),S=React$2.useRef([]),[g,y]=React$2.useState(0),[b,R]=React$2.useState({}),[_,w]=React$2.useState(0),C=React$2.useRef(0),[N,P]=React$2.useState(!0),[D,k]=React$2.useState(!0),[F,M]=React$2.useState(!1),I=n.reduce((pe,J)=>pe+J.areas.length,0),$=pe=>{S.current=[...S.current,...pe]},z=`frame-image-click-puzzle_${g}_${e}`,X=React$2.useMemo(()=>u({type:"loadObjectStatus",payload:z}),[u,z]),te=React$2.useCallback(pe=>{l({type:"addPoints",complex:!0,finish:!0,payload:[...S.current,...pe]}),l({type:"passPuzzle"})},[l]),ae=React$2.useCallback(()=>{k(!1),S.current=[],w(0),y(0),R({}),P(!0),M(!0)},[]),ee=pe=>u({type:"translate",payload:pe}),K=()=>{P(!0)},ue={firstTryForFrame:D,list:n,description:t,index:g,puzzlesCompiledRef:C,framesCompleted:b,handleFinish:te,setRewards:$,accRewards:S,setSelected:w,selected:_,setIndex:y,setFramesCompleted:R,loadPuzzleStatus:X,soundActions:o,setResolveAction:h,disableExit:d,translateFromParent:ee,setInfo:f,emitEvent:l,nodeId:e,emitResetPuzzle:ae,resetValues:F,setResetValues:M,setPuzzlesAutoCompleted:v,puzzlesAutoCompleted:T,emitOpenPopupCounterInfo:()=>{g===0&&P(!1)},pause:p,keyboardControl:E,totalCorrects:I,getEvent:u};return jsxRuntimeExports.jsxs("div",{className:"puzzle-frame",children:[jsxRuntimeExports.jsx(CurrentFramePuzzle,{...ue}),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:`${_/I*100}%`},className:"puzzle-frame__progress--handle"})})}),a?jsxRuntimeExports.jsx("button",{"data-testid":"puzzle-frame-counter-button",disabled:N,"aria-hidden":N,type:"button",className:"puzzle-frame__info",onClick:K,children:jsxRuntimeExports.jsx(Counter,{current:_,total:I,tooltip:!N,getEvent:u})}):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,h=l?e.header.username:n.username,f=l?e.header.bgImage:n.bgImage;return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__front",style:{backgroundImage:`url(${path+f})`},children:[jsxRuntimeExports.jsxs("div",{className:"facebook--user",children:[jsxRuntimeExports.jsx("span",{className:"facebook--user__circle",style:{backgroundImage:`url(${path+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(h||"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,h=l?e.body.studies:n.studies,f=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 ${h||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(h||"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 ${f||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(f||"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,h=l?e.body.btnColor:n.btnColor,f=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):f}),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:`${h}`},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,h]=React$2.useState(),f=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:()=>h(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 ${f?"disabled":""}`,onClick:f?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,h]=React$2.useState(),f=!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:()=>h(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 ${f?"disabled":""}`,onClick:f?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,h]=React$2.useState(""),f=d==="",[u,p]=React$2.useState(!1),E=u?"puzzle--webBuilder__select--item open":"puzzle--webBuilder__select--item",T=()=>{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:E,onClick:()=>T(),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(v=>v instanceof Object?jsxRuntimeExports.jsxs("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{h(v)},children:[jsxRuntimeExports.jsx("span",{children:t(v.title)}),jsxRuntimeExports.jsx("span",{className:"subtitle",children:t(v.desc)})]},v.title):jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{h(v)},children:t(v)},v))})]})]})})}),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 ${f?"disabled":""}`,disabled:f,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,getEvent:t,setResolveAction:a,soundActions:o,disableExit:d,keyboardControl:h}){const[f,u]=React$2.useState(!1),[p,E]=React$2.useState(!1),[T,v]=React$2.useState(!1),[S,g]=React$2.useState(!1),[y,b]=React$2.useState(!1),[R,_]=React$2.useState(null),w=l==="facebook",C=w?FacebookTemplate:BankTemplate,[N,P]=React$2.useState({type:"",props:{}}),[D,k]=React$2.useState(defaultHeader),[F,M]=React$2.useState(defaultBody),[I]=o,$=W=>t({type:"translate",payload:W}),z=()=>{P({type:"",props:{}})},X=(W,V={})=>{P({type:W,props:V})},te=()=>{if(e.solution){const{rewards:W}=e.solution.right,{rewards:V}=e.solution.wrong;I(T?"fail":"score"),n({type:"addPoints",complex:!0,finish:!0,payload:T?V:W}),n({type:"passPuzzle"})}},ae=h({disabled:R!=="success",forward:te,escape:te});React$2.useEffect(()=>ae(),[ae]);const ee=(W,V)=>{const B=Object.keys(W),Y={existing:0,equal:0};return B.forEach(re=>{V[re]!==null&&V[re]!==""&&(Y.existing+=1),W[re]===V[re]&&(Y.equal+=1)}),Y},K=(W,V)=>{const B=Object.keys(C.header).length,Y=Object.keys(C.body).length,re=ee(C.header,W),le=ee(C.body,V),fe=le.existing+re.existing===B+Y,de=le.equal+re.equal===B+Y;return{exist:fe,equal:de}},ne=()=>{I("click-ui");const{exist:W,equal:V}=K(D,F);n({type:"hidePuzzleButtons",payload:!0}),W&&!V?(y&&b(!1),_("failed"),v(!0),n({type:"failPuzzle"})):W&&V&&(y&&(d(!1),b(!1)),g(!0),_("success"))},ue=W=>{if(Object.keys(W).length>0){const V={...D,...W};k(V),z();const{exist:B}=K(V,F);b(!!B)}},pe=W=>{if(Object.keys(W).length>0){const V={...F,...W};M(V),z();const{exist:B}=K(D,V);b(!!B)}};React$2.useEffect(()=>{a(W=>{E(!0),_("success"),u(!1),setTimeout(()=>{_(""),W()},4e3)}),d(!0)},[a,d,e.resolve.rewards,n]);const J={showingReference:f||p,isFacebook:w,openPopup:X,usingTemplate:C,translate:$},H=()=>{R==="failed"?(_(null),n({type:"hidePuzzleButtons",payload:!1})):R==="success"&&te()};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(PopupComponent,{type:N.type,...N,close:z,soundActions:o,translate:$}),jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder",children:[jsxRuntimeExports.jsx(WebBuilderTopBar,{backActive:f,displayButton:!p&&!S,translate:$,clickAction:()=>{I("click-ui"),u(!f)}}),jsxRuntimeExports.jsx(WebBuilderHeader,{...J,header:D,onSave:ue}),w?jsxRuntimeExports.jsx(WebBuilderFront,{...J,header:D,onSave:ue}):null,jsxRuntimeExports.jsx(WebBuilderBody,{...J,body:F,onSave:pe})]}),!y&&!f?jsxRuntimeExports.jsx(DisplayingFeedback,{feed:R,onNext:H,resolved:p,translate:$}):null,y&&!f?jsxRuntimeExports.jsx(PublishButton,{onPublish:ne,translate:$}):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:h,handleSuccess:f,resolveWithAnyCard:u}){const[p,E]=React$2.useState(Array(l.length).fill(!1)),[T,v]=React$2.useState(Array(l.length).fill(!1)),[S,g]=React$2.useState(0),[y,b]=React$2.useState(!1),[R]=d,_=l.filter(M=>M.correct===!0).length,w=l.filter(M=>M.order).length>0,C=React$2.useCallback(()=>{E(Array(l.length).fill(!1)),v(Array(l.length).fill(!1)),g(0),n(1)},[l.length,n]),N=()=>{setTimeout(()=>{C()},1e3)};function P(M,I=M){const $=Array.from(p);$[M]=I,E($)}const D=React$2.useCallback(()=>{const M=[];l.forEach((I,$)=>{I.correct===!0&&M.push($)}),E(M)},[l]);React$2.useEffect(()=>{o&&D()},[D,o]),React$2.useEffect(()=>{(u&&S||S===_&&_>0)&&(h(),b(!0),g(0))},[S,h,_,u]);const k=M=>{P(M),f(l[M].id||null),g(S+1)},F=M=>{var I,$;if(!y&&!a)if(R("click-ui"),l[M].correct&&!w)k(M);else if(w){if(l[M].order===e)n(e+1),k(M);else if(P(M),l[M].order!==e){const z=Array.from(T);z[M]=M,v(z),t(((I=l[M])==null?void 0:I.id)||null,l[M].correct),N()}}else t((($=l[M])==null?void 0:$.id)||null),P(M),setTimeout(()=>{P(M,!1)},1e3)};return jsxRuntimeExports.jsx("div",{className:`cards-selector__content cards-selector__content-${l.length}`,children:l&&l.map((M,I)=>jsxRuntimeExports.jsx(Card,{setCurrentOrder:n,card:M,handleClick:()=>F(I),flipped:p.includes(I),wrongOrder:T.includes(I),cardIndex:I},`cardPuzzle ${l.indexOf(M)}`))})}Board.defaultProps={setCurrentOrder:()=>{},handleError:()=>{},onFinish:()=>{},handleSuccess:()=>{},documentsDict:{},cards:[],currentOrder:1,resolvePuzzle:!1,feedbackIsShown:!1,resolveWithAnyCard:!1};function CardsSelectorPuzzleComponent({emitEvent:l,getEvent:e,info:n,cards:t,resolveWithAnyCard:a,specificFeedbacks:o,disableExit:d,setResolveAction:h,soundActions:f,backgroundImage:u,nodeId:p,keyboardControl:E,hideBackgroundImageTheme:T=!1}){var H,W;const[v,S]=React$2.useState(!1),[g,y]=React$2.useState(1),[b,R]=React$2.useState(!1),[_,w]=React$2.useState(!1),[C,N]=React$2.useState(!1),[P,D]=React$2.useState([]),[k,F]=React$2.useState(!1),[M,I]=React$2.useState(""),[$]=f,z=V=>e({type:"translate",payload:V}),X=`cards-selector-puzzle_${p}`,te=React$2.useCallback(V=>{R(!1),N(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"addPoints",complex:!0,finish:!0,payload:V}),l({type:"passPuzzle"})},[l]),ae=React$2.useCallback(()=>{var re,le;l({type:"hidePuzzleButtons",payload:!0}),R(!0);const{rewards:V}=((re=n==null?void 0:n.solution)==null?void 0:re.right)||{},B=((le=o==null?void 0:o.correctFeedbacks)==null?void 0:le.map(fe=>fe.rewards).flat())||[],Y=[...P,...V,...B];$("score"),te(Y)},[P,te,l,(H=n==null?void 0:n.solution)==null?void 0:H.right,$,o==null?void 0:o.correctFeedbacks]),ee=()=>{S(!0),n.solution.right.desc&&!(o!=null&&o.specificCorrectFeedbacks)&&I(n.solution.right.desc),N(!0)},K=()=>{b||v?ae():(R(!1),d(!1),N(!1),l({type:"hidePuzzleButtons",payload:!1})),I("")},ne=V=>{if(w(!0),o!=null&&o.specificCorrectFeedbacks){const B=o.correctFeedbacks.find(Y=>Y.id===V);B!=null&&B.desc&&(I(B.desc),N(!0))}$("score"),l({type:"hidePuzzleButtons",payload:!0})},ue=(V,B=!1)=>{var Y,re;if(w(!1),B)I((Y=n.orderFeedback)==null?void 0:Y.desc),N(!0),D([...P,...((re=n.orderFeedback)==null?void 0:re.rewards)||[]]);else if(o!=null&&o.specificWrongFeedbacks){const le=o.wrongFeedbacks.find(fe=>fe.id===V);le!=null&&le.desc?(I(le.desc),N(!0)):(N(!0),setTimeout(()=>{K(),l({type:"hidePuzzleButtons",payload:!1})},2e3)),D([...P,...(le==null?void 0:le.rewards)||[]])}else n.solution.wrong.desc?(I(n.solution.wrong.desc),N(!0)):(N(!0),setTimeout(()=>{K(),l({type:"hidePuzzleButtons",payload:!1})},3e3));d(!0),!(o!=null&&o.specificWrongFeedbacks)&&!B&&D([...P,...n.solution.wrong.rewards]),$("fail"),l({type:"hidePuzzleButtons",payload:!0}),l({type:"failPuzzle"})};React$2.useEffect(()=>{v&&d(!0)},[d,v]),React$2.useEffect(()=>{h(()=>{var B;l({type:"hidePuzzleButtons",payload:!0}),F(!0);const V=[...P,...((B=n==null?void 0:n.resolve)==null?void 0:B.rewards)||{}];setTimeout(()=>{R(!1),N(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:X,rewards:V,finish:!0}})},2e3)})},[h,d,P,(W=n==null?void 0:n.resolve)==null?void 0:W.rewards,l,X]);const pe=React$2.useMemo(()=>{let V="";return V="cards-selector",u!=null&&u.url&&(V+=" cards-selector--with-custom-bg"),T&&(V+=" disable-background-image"),V},[u==null?void 0:u.url,T]),J={backgroundImage:u!=null&&u.url?`url('${u.url}')`:""};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:pe,style:J,children:jsxRuntimeExports.jsx(Board,{setCurrentOrder:y,currentOrder:g,cards:t,onFinish:ee,resolveWithAnyCard:a,handleError:ue,feedbackIsShown:C,resolvePuzzle:k,soundActions:f,handleSuccess:ne})}),C&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:b||_,text:M,hasTimeout:!M,translate:z,functionOnClose:K,keyboardControl:E})]})}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[h,f]=React$2.useState(!0),[u,p]=React$2.useState(""),[E,T]=React$2.useState(!1);React$2.useEffect(()=>{T(e===n-1)},[e,n]);const v=b=>{if(!b||!b.length)return"";const R=b.replace(/<script.*?>.*?<\/script>/gim,""),_=document.createElement("DIV");return _.innerHTML=R,_.textContent||_.innerText||""};React$2.useEffect(()=>{const b=()=>{const _=t.trim().split(" ");return R(_,_.length-1).join(" ")},R=(_,w)=>{if(w<0)return[""];const C=[..._];if(v(_[w]).length!==0){const N=_[w];return C[w]=`<span class="lastWord" >${N}</span>`,C}return R(_,w-1)};o==="election"?p(b()):setTimeout(()=>{p(t)},200)},[o,t]);const S=()=>{a(!0),f(!1)},g=t.split("<p>");g.shift();const y=g.length>1;return h&&t!==""&&u!==""?jsxRuntimeExports.jsx("span",{className:`writer-inline ${y?"multiple":""} ${E?"Typist":""}`,"data-testid":`result-${e}`,children:jsxRuntimeExports.jsx(Typist,{startDelay:300,avgTypingDelay:l,stdTypingDelay:10,onCharacterTyped:d,onTypingDone:S,cursor:{hideWhenDone:!0,hideWhenDoneDelay:200},blink:!0,children:HTMLReactParser$1(t)})}):jsxRuntimeExports.jsxs("span",{className:`writer-inline ${y?"multiple":""} ${E?"Typist":""}`,"data-testid":`result-${e}`,children:[HTMLReactParser$1(u),o==="election"&&E&&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,h=T=>T.previewText!==""?HTMLReactParser$1(T.previewText):HTMLReactParser$1(T.fullText),f=T=>T.previewText!==""?e===t?"icon-eye inspected":"icon-eye":"",u=()=>{d("click-ui"),n(t)},p=T=>{T.keyCode===13&&E(T)},E=T=>{T.preventDefault(),T.stopPropagation(),e===t?(T.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:h(l)})}),jsxRuntimeExports.jsx("div",{onClick:E,onKeyDown:p,className:f(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,h)=>jsxRuntimeExports.jsx(SingleElectionRender,{opt:d,soundActions:t,index:h,setCurrentDecisionSelected:e,setCurrentDecisionInspected:o,decisionInspected:a},h))})}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({getEvent:l,closingAction:e,feedbackIsDone:n,decisionsList:t,texts:a,retryAction:o,retry:d,skip:h,checkCorrect:f,rewardsStack:u,setFailed:p,soundActions:E}){const[T]=E,v=g=>l({type:"translate",payload:g}),S=()=>{T("click-ui"),e(),p(),n()};return jsxRuntimeExports.jsxs("div",{className:`writer-feedback ${u.length?"":"start"}`,children:[jsxRuntimeExports.jsx("div",{className:"writer-feedback__title",children:v("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:[h&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary writer-feedback__btn-mobile",onClick:()=>{S()},children:v("puzzles.skip")}),d&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>{f()?S():(T("click-ui"),o())},children:v(f()?"puzzles.continue":"puzzles.retry")}),!d&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>S(),children:v("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,getEvent:e,styles:n,nodeId:t,retry:a,skip:o,type:d,info:h,setResolveAction:f,documentTitle:u,documentTitle_labelId:p,texts:E,soundActions:T,backgroundImage:v,hideBackgroundImageTheme:S=!1}){const g=rt=>e({type:"translate",payload:rt}),y=React$2.useRef(),[b,R]=React$2.useState(!1),[_,w]=React$2.useState(!1),[C,N]=React$2.useState(0),[P,D]=React$2.useState({[`text_${C}`]:{...E[C],id:`text_${C}`,correct:""}}),[k,F]=React$2.useState(!1),[M,I]=React$2.useState([]),[$,z]=React$2.useState(!1),[X,te]=React$2.useState(!1),[ae,ee]=React$2.useState(!1),[K,ne]=React$2.useState(!0),[ue,pe]=React$2.useState([]),[J,H]=React$2.useState(!0),[W]=T,V=React$2.useRef({}),B=rt=>{let Et;return rt.electionTexts.forEach(($e,pt)=>{$e.correct&&(Et=pt)}),Et},Y=React$2.useCallback(rt=>M.filter($e=>$e.currenTextParagraph===rt)[0].fullText_labelId,[M]),re=React$2.useCallback(()=>E.map((rt,Et)=>{if(rt.type==="fixed")return rt.fullText_labelId??rt.fullText;if(rt.type==="election"){const $e=B(rt);return $e>=0?rt.electionTexts[$e].fullText_labelId:Y(Et)}return""}),[Y,E]),le=12,fe=()=>{if(M){const rt=M.length;let Et=0;for(let $e=0;$e<rt;$e+=1)M[$e].isCorrect==="none"&&(Et+=1);return Et===rt}return!0},de=React$2.useCallback(()=>{if(M){const rt=M.length;let Et=0;for(let $e=0;$e<rt;$e+=1)M[$e].isCorrect==="green"&&(Et+=1);return Et===rt}return!0},[M]),ge=()=>!!(M&&M.length),Ee=()=>M.find(rt=>{const{feedback:Et}=E[rt.currenTextParagraph].electionTexts[rt.index];return Et.body!==""}),Re=React$2.useCallback(()=>{const rt=re();l({type:"finishMedia",payload:{name:p,text:rt,documentType:d,type:"text"}})},[re,p,l,d]),Oe=React$2.useCallback(rt=>{const Et=de();W(_?"fail":Et?"score":"fail"),l({type:"addPoints",complex:!0,finish:!0,payload:rt||ue,onFinish:d!=="view"?Re:null}),l({type:"passPuzzle"})},[de,l,_,Re,W,ue,d]);React$2.useEffect(()=>{b&&H(!1),f(()=>{Oe(h.resolve.rewards)})},[l,Oe,b,Re,h.resolve.rewards,f,d]);const Ne=()=>{R(!1),N(0),I([]),pe([]),w(!1),ee(!1),F(!1),te(!1),z(!1),D({text_0:{...E[0],id:"text_0",correct:""}}),ne(!0),l({type:"addPoints",complex:!0,finish:!1,payload:ue}),l({type:"failPuzzle"})},Xe=()=>{ge()?fe()&&(z(!0),Oe()):(z(!0),ee(!0),Oe()),$?(ne(!1),ae&&!X?te(!0):(X||!ae&&!X)&&(!ae&&!X&&a?de()?Oe():Ne():Oe())):(z(!0),Ee()&&ee(!0))},ft=()=>{const rt=E[C].electionTexts.filter($e=>$e.correct).length,Et=E[C].electionTexts;return rt===0||rt===Et},nt=rt=>{const Et=E[C].electionTexts[rt],$e=Et.feedback.rewards;$e&&$e[0]&&$e[0].points&&(V.current[`t${C}_e${rt}`]||(Et.correct&&(V.current[`t${C}_e${rt}`]=!0),pe([...ue,...$e])));const pt=()=>ft()?"none":Et.correct?"green":"red",He={currenTextParagraph:C,fullText:Et.fullText,index:rt,isCorrect:pt()};D({...P,[`text_${C}`]:{type:"fixed",fullText:Et.fullText,correct:He.isCorrect}}),I([...M,He])},St=()=>{y.current.scrollTop=y.current.scrollHeight+100},ze=()=>{if(y.current.querySelector(".wrapfixed").offsetHeight>y.current.offsetHeight){const rt=y.current.querySelector(".wrapfixed").offsetHeight;y.current.scrollTo({top:rt,behavior:"smooth"})}},Me=(rt,Et,$e)=>{const pt=rt.fullText,He=E[$e+1]?E[$e+1].type:"",Ye=P[`text_${$e+1}`]&&P[`text_${$e+1}`].type?P[`text_${$e+1}`].type:He;return jsxRuntimeExports.jsx(FixedComponent,{length:Et,doneTyping:k,index:$e,delay:le,setDoneTyping:F,nextParagraphType:Ye,isWriting:ze,textToPrint:pt},$e.toString())},ke=(rt,Et)=>{const $e=rt.fullText;return jsxRuntimeExports.jsx(FinishedTextComponent,{textToPrint:$e,correct:rt.correct},Et)},We=rt=>jsxRuntimeExports.jsx(ElectionComponent,{soundActions:T,textWithOpts:rt.electionTexts,setCurrentDecisionSelected:nt,printed:St,disableExit:J},rt.electionTexts),tt=(rt,Et,$e)=>rt.type==="fixed"?Me(rt,Et,$e):We(rt);React$2.useEffect(()=>{k===!0&&(()=>{E[C+1]?(D({...P,[`text_${C+1}`]:{...E[C+1],id:`text_${C+1}`,correct:""}}),N(C+1),F(!1)):R(!0)})()},[k,C,P,E]);const ct=React$2.useMemo(()=>{let rt=`writer-puzzle writer-puzzle--${n}`;return S&&(rt+=" disable-background-image"),rt},[S,n]),Dt={backgroundImage:v!=null&&v.url?`url('${v.url}')`:""};return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:ct,style:Dt,children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__overlay",children:[X&&jsxRuntimeExports.jsx(FeedbackComponent,{getEvent:e,texts:E,setFailed:()=>w(!0),decisionsList:M,closingAction:Xe,retry:a,skip:o,checkCorrect:de,retryAction:Ne,rewardsStack:ue,nodeId:t,soundActions:T}),!X&&jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__container",children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"writer-puzzle__title",children:u!==""&&u}),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:y,children:[jsxRuntimeExports.jsx("div",{className:"wrapfixed",children:K&&!$&&Object.values(P).map((rt,Et)=>tt(rt,Object.values(P).length-1,Et))}),$&&Object.values(P).map((rt,Et)=>ke(rt,Et))]})}),b&&jsxRuntimeExports.jsx("div",{className:"writer-puzzle__footer",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:Xe,children:g("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:h,keyboardControl:f}){var R;const{fileId:u}=l,p=((R=l.document)==null?void 0:R.url)||"",[E]=h,T={image:{component:Image$1,props:{...l,url:p,soundActions:h}},video:{component:VideoVisor,props:{...l,url:p,endVideo:a,soundActions:h,translate:d}},embedded_video:{component:VideoVisor,props:{...l,url:p,soundActions:h}},pdf:{component:PdfVisor,props:{...l,url:p,translate:d,soundActions:h,emitNumberOfPages:()=>{},endPdf:()=>{},keyboardControl:f}},application:{component:PdfVisor,props:{...l,url:p,translate:d,soundActions:h,emitNumberOfPages:()=>{},keyboardControl:f,endPdf:()=>{}}}};if(!T[l.type])return null;const v=T[l.type].component,S=T[l.type].props,y=l.name.replace(/.jpg|.png|.pdf|.mp4/gi,""),b=e.fileId;return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__visor",children:[jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:E,shortText:!0,success:u===b,text:u===b?t.solution.right.desc:t.solution.wrong.desc,functionOnClose:u===b?a:o,additionalStyle:ICONS$1[l.type],secondText:y,translate:d,puzzleHeaderClass:"puzzle--terminal__visor--message",keyboardControl:f}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__visor--body",children:jsxRuntimeExports.jsx(v,{...S})}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__button",children:u===b&&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,getEvent:e,items:n,backgroundImage:t,solution:a,info:o,disableExit:d,soundActions:h,setResolveAction:f,nodeId:u,keyboardControl:p}){const[E,T]=React$2.useState({}),[v]=React$2.useState(!1),[S,g]=React$2.useState([]),y=React$2.useRef([]),[b]=h,R=F=>e({type:"translate",payload:F}),_=`terminal-puzzle_${u}`,w=React$2.useMemo(()=>({name:"init",children:[...FIXED_ITEMS,...n],id:"init"}),[n]),C=React$2.useCallback(F=>{b("click-ui"),T(F),g([...S,F]),F.type!=="folder"&&(l({type:"hidePuzzleButtons",payload:!0}),d(!0))},[S,d,l,b]);React$2.useEffect(()=>{T(w),g([w])},[w]),React$2.useEffect(()=>{f(()=>{y.current=[...y.current,...o.resolve.rewards];const F=y.current.map(M=>{var ae;const{name:I,points:$,type:z,id:X}=M,te={name:I,points:$,type:z,id:X};return(ae=M==null?void 0:M.document)!=null&&ae.resourceId&&(te.id=M.document.resourceId),te});l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:_,rewards:F,finish:!0}})})},[f,o.resolve.rewards,l,_]);const N=()=>{y.current=[...y.current,...o.solution.wrong.rewards];const F=S.length-1,M=S.filter((I,$)=>F>$);T(S[F-1]),g(M),d(!1),l({type:"hidePuzzleButtons",payload:!1})},P=()=>{b("click-ui");const F=S[0];T(F),g([F])},D=()=>{y.current=[...y.current,...o.solution.right.rewards];const F=y.current.map(M=>{var ae;const{name:I,points:$,type:z,id:X}=M,te={name:I,points:$,type:z,id:X};return(ae=M==null?void 0:M.document)!=null&&ae.resourceId&&(te.id=M.document.resourceId),te});l({type:"hidePuzzleButtons",payload:!1}),b("score"),l({type:"addPoints",complex:!0,finish:!0,payload:F}),l({type:"passPuzzle"})},k=(t==null?void 0:t.url)||DEFAULT_IMG;return jsxRuntimeExports.jsx("div",{className:"puzzle--terminal",children:E.children?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Image$1,{isWallpaper:!0,document:{url:k}}),jsxRuntimeExports.jsx(FilesGroup,{backFile:N,initFile:w,selectItem:C,breadcrumb:S,closeFolder:P,file:E,translate:R})]}):jsxRuntimeExports.jsx(Visor,{soundActions:h,backFile:N,resolvePuzzle:D,info:o,showContinue:!v,solution:a,file:E,translate:R,keyboardControl:p})})}function DragItemPuzzleComponent({area:l,image:e,resolveObject:n,info:t,hasHighlights:a,getEvent:o,consume:d,disableExit:h,emitEvent:f,soundActions:u,keyboardControl:p}){const{solution:E}=t,T=React$2.useRef(),v=React$2.useRef(),S=React$2.useRef(),g=React$2.useRef(),y=React$2.useRef({}),[b,R]=React$2.useState(""),[_,w]=React$2.useState(!1),[C,N]=React$2.useState(),[P]=React$2.useState(new window.Image),D=React$2.useRef([]),[k]=u,F=J=>o({type:"translate",payload:J});React$2.useEffect(()=>{h(b!=="")},[b,h]);const M=(J,H)=>(J.x+J.width>H.x&&J.x+J.width<=H.x+H.width||H.x+H.width>J.x&&H.x+H.width<=J.x+J.width)&&(J.y+J.height>H.y&&J.y+J.height<=H.y+H.height||H.y+H.height>J.y&&H.y+H.height<=J.y+J.height),I=()=>{T&&a&&(T.current.to({duration:.25,opacity:.75}),v.current.to({duration:.25,opacity:.4}))},$=()=>{T&&a&&(T.current.to({duration:.25,opacity:0}),v.current.to({duration:.25,opacity:0}))},z=React$2.useCallback(J=>{let H=!1;if(J){const W=S.current;W.setPointersPositions(J);const V=W.getPointerPosition(),B=T.current.getClientRect({relativeTo:W});H=M({...V,width:1,height:1},B)}return H},[]),X=React$2.useCallback(J=>J&&n.uid===JSON.parse(J).uid,[n.uid]),te=React$2.useCallback(()=>{R(""),f({type:"hidePuzzleButtons",payload:!1}),f({type:"addPoints",complex:!0,finish:!0,payload:D.current}),f({type:"passPuzzle"}),d&&f({type:"consumeItem",payload:{uid:n.uid,targetId:n.uid,name:n.name}})},[d,f,n.name,n.uid]),ae=React$2.useCallback(()=>{R("success"),f({type:"hidePuzzleButtons",payload:!0}),D.current=[...D.current,...E.right.rewards],setTimeout(()=>{te()},2e3)},[f,te,E.right.rewards]),ee=React$2.useCallback(()=>{R(""),f({type:"hidePuzzleButtons",payload:!1}),f({type:"failPuzzle"}),D.current=[...D.current,...E.wrong.rewards]},[f,E.wrong.rewards]),K=React$2.useCallback(J=>{const H=J.dataTransfer.getData("item");S.current.setPointersPositions(J);const W=z(J);f({type:"hidePuzzleButtons",payload:!0}),W&&X(H)?(R("success"),t.solution.right.desc===""&&ae()):(R("failed"),t.solution.wrong.desc===""&&setTimeout(()=>{ee()},2e3))},[z,X,f,ae,ee,t.solution.right.desc,t.solution.wrong.desc]),ne=()=>{b==="success"?ae():ee()};React$2.useEffect(()=>{const J=e.img.url||"";P.src=J,P.onload=()=>{g.current&&(y.current={x:g.current.clientWidth/2,y:g.current.clientHeight/2,width:P.width,height:P.height,offsetX:P.width/2,offsetY:P.height/2,scale:{x:Math.min(g.current.clientWidth/P.width,g.current.clientHeight/P.height),y:Math.min(g.current.clientWidth/P.width,g.current.clientHeight/P.height)}},w(!0))}},[P,e.img.url]);const ue=J=>{J!==null&&(T.current=J)},pe=J=>{if(J!==null&&(v.current=J,T.current)){const{x:H,y:W,width:V,height:B}=T.current.getClientRect();J.setAttr("x",H),J.setAttr("y",W),J.setAttr("height",B),J.setAttr("width",V)}};return React$2.useLayoutEffect(()=>{if(T.current&&_){const J=T.current.getClientRect({relativeTo:T.current.getParent()});N({x:J.x+J.width/2,y:J.y+J.height/2})}},[_]),jsxRuntimeExports.jsxs("div",{className:"puzzle--drag__mask100",onDrop:K,onDragOver:J=>{J.preventDefault()},children:[jsxRuntimeExports.jsx("div",{className:"puzzle--drag__mask",children:jsxRuntimeExports.jsx("div",{ref:g,"data-testid":"mask_canvas",className:"puzzle--drag__mask--canvas",children:_?jsxRuntimeExports.jsx(Stage,{ref:S,width:g.current.clientWidth,height:g.current.clientHeight,children:jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Image$2,{image:P,...y.current}),jsxRuntimeExports.jsxs(Group,{...y.current,children:[C?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...C},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:"object-area-projection"})}):null,jsxRuntimeExports.jsx(Line,{onMouseEnter:I,onMouseLeave:$,ref:ue,...l,shape:"poly",fill:"#262a31d9",stroke:"white",strokeWidth:1,opacity:0,dash:[3,2],closed:!0,draggable:!1})]}),jsxRuntimeExports.jsx(Text,{onMouseEnter:I,onMouseLeave:$,ref:pe,text:F("puzzle.drag.dropzone"),fontSize:12,align:"center",verticalAlign:"middle",fill:"#ffffff",opacity:0})]})}):null})}),b!==""?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:t.solution[b==="success"?"right":"wrong"].desc,success:b==="success",translate:F,playSound:k,functionOnClose:ne,keyboardControl:p}):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[h,f]=React$2.useState(!1),u=n.answers.filter(y=>y.text),p=y=>{let b=!1;return a[n.id].find(R=>R.id===y)&&(b=!0),b},E=y=>{let b="";return h?(e&&p(y.id)&&(b="selected"),l&&p(y.id)&&o.includes(y.id)&&(b="success"),l&&p(y.id)&&!o.includes(y.id)&&(b="failed")):(e&&y.id===a[n.id][0].id&&(b="selected"),l&&y.id===a[n.id][0].id&&(b=a[n.id][0].isCorrect?"success":"failed")),b},T=y=>{const b=E(y);return b==="selected"?"icon-check-circle-black color--selected":b==="success"?"icon-check-circle-black color--success":b==="failed"?"icon-error-circle-black color--error":""},v=y=>l&&y.feedback&&(h&&p(y.id)||y.id===a[n.id][0].id),S=(y,b)=>b===0?"tooltip--right__top":b===y.length-1?"tooltip--right__bottom":"tooltip--center__right",g=n.answers.filter(y=>y.isCorrect);return React$2.useEffect(()=>{g.length===1?f(!1):f(!0)},[g.length,h,n.answers]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:n.text})}),h&&!l?jsxRuntimeExports.jsx("div",{className:"test--questions__intertitle test--questions__intertitle--multiresponse",children:d("tests.chooseMoreOneAnswer")}):null,u.map((y,b)=>jsxRuntimeExports.jsxs("div",{className:"test--response__fakeinput",children:[h?jsxRuntimeExports.jsx("input",{checked:e&&p(y.id),disabled:l&&!p(y.id),readOnly:l,type:"checkbox",id:y.id,onChange:()=>l?null:t(y,n.id,b,"isCheckbox",y.id)}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("input",{checked:e&&y.id===a[n.id][0].id,disabled:l&&!E(y),type:"radio",name:"name",id:y.id,onChange:()=>l?null:t(y,n.id,b,"isRadio")})}),jsxRuntimeExports.jsxs("label",{htmlFor:y.id,className:`test--response__item ${E(y)}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX$1[b]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:y.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${T(y)}`})]}),l?jsxRuntimeExports.jsxs("div",{className:`test--feedback__info ${v(y)?"":"test--feedback__info--hidden"}`,children:[jsxRuntimeExports.jsx("span",{className:`icon-info2 ${E(y)==="success"?"color--success":"color--error"}`}),jsxRuntimeExports.jsxs("div",{id:`tooltipFeedback-${b}`,className:`tooltip ${S(u,b)}`,children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsx("span",{children:d("test.feedback")})})}),jsxRuntimeExports.jsx("span",{children:jsxRuntimeExports.jsx("span",{children:y.feedback})})]})]}):null]},y.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=h=>e.includes(h),o=(h,f)=>h.index<f.index?-1:h.index>f.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(h=>jsxRuntimeExports.jsxs("div",{className:"test--response__itemwrap",children:[jsxRuntimeExports.jsxs("div",{className:`test--response__item ${a(h.id)?"success":"failed"}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX[h.index]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:h.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${a(h.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[h.index]:""]})})}),jsxRuntimeExports.jsx("span",{children:h.feedback})]})]},h.text))]})}function Container({questions:l,setTime:e,saveInterval:n,result:t,setTries:a,tries:o,time:d,showResults:h,answered:f,answerPage:u,updateForm:p,disabled:E,translate:T,soundActions:v,paused:S,view:g,correctQuestions:y,feedbacksOnlyWhenReview:b}){const R=document.querySelector(".test--container"),[_,w]=React$2.useState(0),[C,N]=React$2.useState(),P=l[_].id,[D]=v;React$2.useEffect(()=>{if(d>=0&&!E&&!S){const te=setInterval(()=>{C||e(ae=>ae-1)},1e3);return n(te),()=>{clearInterval(te)}}},[E,C,S,n,e,d]);const k=()=>{R.scrollTo(0,0),D("click-ui"),f&&(t[P][0].feedback&&!E&&!b?N(!0):(u(!1),w(_+1)))},F=()=>{D("click-ui"),w(_-1)},M=()=>{R.scrollTo(0,0),l[_+1]?(N(!1),u(!1),w(_+1)):h()},I=()=>{R.scrollTo(0,0),a(o+1),t[P][0].feedback&&!E&&!b?N(!0):h()},$=Math.floor(d/60),z=d%60;React$2.useEffect(()=>{if(g==="review"){const te=t[`q${_}`][0].id,ae=document.querySelector(`#${te}`);R.scrollTo(0,ae.offsetTop)}},[_,R,t,g]);const X=()=>{if(f){const te=y[l[_].id.substring(1)].answers,ae=t[P],ee=ae.find(ne=>ne.isCorrect===!1);let K=0;return ae.forEach(ne=>{te.includes(ne.id)&&(K+=1)}),!ee&&K===te.length}return!1};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[g==="review"||C?jsxRuntimeExports.jsx("div",{"data-testid":"feedbackWrapper",className:`test-feedback-header ${X()?"success":"failed"}`,children:jsxRuntimeExports.jsxs("h2",{children:[jsxRuntimeExports.jsx("span",{className:`${X()?"icon-correct-thumb":"icon-incorrect-thumb"}`}),jsxRuntimeExports.jsx("span",{className:"test-feedback-header__title",children:X()?T("tests.resolvedQuestion"):T("tests.notResolvedQuestion")})]})}):null,jsxRuntimeExports.jsxs("div",{className:"test--questions",children:[jsxRuntimeExports.jsx("div",{className:"test--questions__container",children:C?jsxRuntimeExports.jsx(FeedbackItem,{selectedAnswers:t[P],correctQuestions:y[l[_].id.substring(1)].answers,question:l[_].text,translate:T}):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:T("tests.question")})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{children:T("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${$}`:$," : ",z<10?`0${z}`:z]})}):null]}),jsxRuntimeExports.jsx(Questions,{result:t,disabled:E,answered:f,updateForm:p,question:l[_],correctQuestions:E?y[l[_].id.substring(1)].answers:[],translate:T},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()?T("survey.next"):T("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}):null,!C&&l[_+1]?jsxRuntimeExports.jsx("button",{disabled:!f,id:"next-button","data-testid":"nextButton",onClick:()=>k(),type:"button",className:`gat--btn__navigation ${f?"":"disabled"}`,"aria-label":LangIsRtl()?T("survey.previous"):T("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:!f,id:"continue-button","data-testid":"continueButton",onClick:()=>{D("click-ui"),f&&I()},type:"button",className:`gat--btn__navigation ${f?"":"disabled"}`,"aria-label":LangIsRtl()?T("survey.previous"):T("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:h,timeOver:f,timeOverText:u,getEvent:p,minimumPercentage:E}){const T=React$2.useRef(),[v,S]=React$2.useState(0),[g,y]=React$2.useState(),[b,R]=React$2.useState([]),[_,w]=React$2.useState([]),[C,N]=React$2.useState(),P=React$2.useCallback(()=>{const K=[];return t.forEach(ne=>K.push(ne.answers)),K},[t]),D=React$2.useCallback(()=>{const K=[];return Object.values(l).forEach(ne=>{if(ne.length>1){const ue=ne.find(J=>J.isCorrect===!1),pe=[];ue?K.push([]):(ne.forEach(J=>{J.isCorrect&&pe.push(J.id)}),K.push(pe))}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 b.forEach((ne,ue)=>{ne.length>1?ne.every(pe=>{var J;return(J=_[ue])==null?void 0:J.includes(pe)})&&(K+=1):ne.length===1&&_[ue]&&ne[0]===_[ue][0]&&(K+=1)}),K},[b,_]);React$2.useEffect(()=>{C===void 0&&(R(P),w(D),N(k))},[P,D,k,C]);const F=t.length,M=k()===F,I=C<E,$=C>=E,z=!n||$,X=Math.trunc(v/F*100),te=(K,ne)=>p({type:"translate",payload:K,values:ne}),ae={"--chart-color":"var(--color-error)"};React$2.useEffect(()=>{if(v<C){const K=setInterval(()=>{S(ne=>ne+1)},100);return y(K),()=>{clearInterval(K)}}},[C,v]),React$2.useEffect(()=>{v>=C&&clearInterval(g)},[C,g,v]);const ee=()=>{T.current=!0,d()};return jsxRuntimeExports.jsxs("div",{"data-testid":"resultsWrapper",className:`test--results ${I||f?"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,!f&&I?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:te("tests.NotFinishedSuccessfully")})}):null,!f&&$||M?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:te("tests.finishedSuccessfully")})}):null,f?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:te("tests.time",e)})})]}):null,jsxRuntimeExports.jsxs("div",{className:`chart center chart${X}`,children:[jsxRuntimeExports.jsxs("div",{className:"chart-slice",children:[jsxRuntimeExports.jsx("div",{className:"chart-bar",style:I||f?ae:{}}),jsxRuntimeExports.jsx("div",{className:"chart-fill",style:I||f?ae:{}})]}),jsxRuntimeExports.jsxs("span",{className:"chart-value",children:[jsxRuntimeExports.jsxs("div",{className:"test--results__chart",children:[jsxRuntimeExports.jsx("span",{"data-testid":"correctPoints",children:v}),jsxRuntimeExports.jsxs("span",{"data-testid":"totalCorrectAnswers",children:["/",F]})]}),jsxRuntimeExports.jsx("div",{className:"test--results__chart--label",children:jsxRuntimeExports.jsx("span",{children:te("tests.success")})})]})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__minimum",children:[jsxRuntimeExports.jsx("div",{className:"icon-bell"}),jsxRuntimeExports.jsx("div",{children:te("tests.minimumQuestionsMessage",{minimumPercentage:E})})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__buttons",children:[f?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__secondary",id:"review-button",onClick:()=>o(),type:"button",children:jsxRuntimeExports.jsx("span",{children:te("tests.review")})}),z?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary","data-testid":"restartButton",id:"restart-button",onClick:()=>h(),type:"button",children:jsxRuntimeExports.jsx("span",{children:te("tests.restart")})}),z?jsxRuntimeExports.jsx("button",{disabled:T.current===!0,className:`gat--btn gat--btn__primary ${T.current===!0&&"disabled"}`,"data-testid":"finishButton",id:"finish-button",onClick:()=>ee(),type:"button",children:jsxRuntimeExports.jsx("span",{children:te("tests.continue")})}):null]})]})}function TestComponent({test:l,countdown:e={},emitEvent:n,getEvent:t,soundActions:a,audio:o,required:d,pause:h,minimumPercentage:f=100,feedbacksOnlyWhenReview:u}){const{questions:p}=l,[E,T]=React$2.useState({}),[v,S]=React$2.useState(),[g,y]=React$2.useState(0),[b,R]=React$2.useState([]),[_,w]=React$2.useState(e.time),[C,N]=React$2.useState(!1),[P,D]=React$2.useState("test"),[k,F]=React$2.useState(!0),[M,I]=React$2.useState({}),[$,z]=React$2.useState({}),[X,te]=React$2.useState(!1),ae=d||l.required||!1,ee=React$2.useRef({}),[K,ne]=React$2.useState(),[ue,pe]=a,J=(re,le,fe,de,ge)=>{const Ee={...re,index:fe};if(g>0&&(Ee.rewards=Ee.rewards.filter(Oe=>!$[re.id]||Oe.points<0)),E[le]){const Oe=E[le].find(Ne=>Ne.id===ge);if(Oe){if(Oe.id===re.id){const Ne=E[le].find(ft=>ft.id===ge),Xe=E[le].indexOf(Ne);if(E[le].splice(Xe,1),E[le].length===0){N(!1);return}}}else E[le].push(Ee)}else E[le]=[Ee];let Re;de==="isRadio"?Re={...E,[le]:[Ee]}:Re={...E},T(Re),I(Re),z({...$,[re.id]:{...re}}),N(!0)};React$2.useEffect(()=>{o!=null&&o.url&&ue(o.url,"tts")},[ue,o]);const H=p.map(re=>{const le=re.answers.filter(de=>de.isCorrect),fe=[];return le.forEach(de=>{fe.push(de.id)}),{question:re.id,answers:fe}});React$2.useEffect(()=>{b.length===0&&R(H)},[b.length,H]),React$2.useEffect(()=>{if(f){const re=Math.ceil(p.length*f/100);ne(re)}},[p.length,f]),React$2.useEffect(()=>{_===0&&(clearInterval(v),N(!1),te(!0),D("results"),pe("tts"))},[v,pe,_]);const W=()=>{clearInterval(v),N(!1),D("results");const re={...M};I(re),pe("tts")},V=()=>{const re={correctQuestions:b.length,result:E,status:"resolved"};Object.keys(E).forEach(fe=>{E[fe].forEach(de=>{ee.current[de.id]&&(de.rewards=[])})}),n({type:"saveTest",payload:re})},B=()=>{const re=()=>{I({}),z({}),D("test"),T({}),w(e.time),te(!1),o!=null&&o.url&&ue(o.url,"tts")},le=Object.values(E);le.forEach(de=>{de.forEach(ge=>{ge.isCorrect&&(ee.current[ge.id]?ge.rewards=[]:ee.current[ge.id]=!0)})});let fe=le.reduce((de,ge)=>{const Ee=[];return ge.forEach(Re=>{Ee.push(Re.rewards)}),[...de,...Ee.flat()]},[]);X&&e.rewards&&(fe=[...fe,...e.rewards]),n({type:"addPoints",payload:fe,complex:!0,finish:!1,onFinish:re()}),n({type:"failTest"})},Y=(re,le)=>t({type:"translate",payload:re,values:le});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:E,time:_,setTries:y,tries:g,answerPage:N,setTime:w,paused:h,saveInterval:S,disabled:P!=="test",answered:C||P!=="test",questions:p,updateForm:J,showResults:W,translate:Y,soundActions:a,view:P,correctQuestions:b,feedbacksOnlyWhenReview:u}):jsxRuntimeExports.jsx(ResultsComponent,{reviewTest:()=>{F(!1),D("review")},isFirst:k,finishTest:V,time:_,mandatory:ae,restartTest:B,result:E,correctQuestions:b,timeOver:X,timeOverText:e.text,emitEvent:n,getEvent:t,soundActions:a,minimumPercentage:K})})]})}const OPTIONS=["yes","no"],LETTERS=["A","B"];function ApplicableBox({setSurveyData:l,survey:e,id:n,translate:t}){const a=o=>{l({...e,[n]:o})};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:OPTIONS.map((o,d)=>jsxRuntimeExports.jsxs("button",{"data-testid":`applicablebox-${OPTIONS[d]}`,type:"button",onClick:()=>a(o),className:`unset-button survey--response__item ${e[n]===o?"selected":""}`,children:[jsxRuntimeExports.jsx("div",{className:"survey--response__index",children:LETTERS[d]}),jsxRuntimeExports.jsx("div",{className:"survey--response__text",children:t(`survey.${o}`)})]},o))})}const OPINION_OPTIONS=[0,1,2,3,4,5,6,7,8,9,10];function OpinionBox({setSurveyData:l,survey:e,id:n,translate:t}){const a=o=>{l({...e,[n]:o})};return jsxRuntimeExports.jsxs("div",{className:"survey--page__item","aria-label":"opinion box",children:[jsxRuntimeExports.jsx("div",{className:"survey--points",children:OPINION_OPTIONS.map(o=>jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>a(o),className:`unset-button survey--points__item survey--points__item--colorized ${e[n]===o?"selected":""}`,children:o},o))}),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,getEvent:e,soundActions:n}){const[t,a]=React$2.useState(INIT_SURVEY),[o,d]=React$2.useState(0),[h,f]=React$2.useState(!1),[u]=n,p=(v,S)=>e({type:"translate",payload:v,values:S}),E=(v=!1)=>{if(u("click-ui"),!v&&o+1>=PAGES.length)f(!0);else{v&&f(!1);const S=v?o-1:o+1;d(S)}},T=PAGES[o].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:p("survey.numQuestion",{init:o+1,page:PAGES.length})})}),jsxRuntimeExports.jsx("div",{children:p("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsx("label",{className:"survey--questions__item","data-testid":`survey.question${o+1}`,htmlFor:p(`survey.question${o+1}`,{ordinal:o+1}),children:p(`survey.question${o+1}`,{ordinal:o+1})}),jsxRuntimeExports.jsx(T,{setSurveyData:a,id:PAGES[o].id,survey:t,translate:p,literalLabel:p(`survey.question${o+1}`,{ordinal:o+1})})]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next",children:[jsxRuntimeExports.jsx("button",{"data-testid":"backButton",id:"survey-button-back",type:"button",disabled:o===0,onClick:()=>E(!0),className:`gat--btn__navigation ${o===0?"disabled":""}`,"aria-label":LangIsRtl()?p("survey.next"):p("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),h&&o===PAGES.length-1?jsxRuntimeExports.jsx("button",{"data-testid":"survey.finish",id:"survey-button",type:"button",disabled:!t[PAGES[o].id],onClick:()=>{u("click-ui"),l({type:"saveSurvey",payload:t})},className:`gat--btn gat--btn__primary ${t[PAGES[o].id]?"":"disabled"} not-transition`,children:p("survey.finish")}):null,!h&&o!==PAGES.length?jsxRuntimeExports.jsx("button",{"data-testid":"nextButton",id:"survey-button",type:"button",disabled:!t[PAGES[o].id],onClick:()=>E(!1),className:`gat--btn__navigation ${t[PAGES[o].id]?"":"disabled"}`,"aria-label":LangIsRtl()?p("survey.previous"):p("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,getEvent:a,soundActions:o}){var C,N,P;const[d,h]=React$2.useState(null),[f,u]=React$2.useState("start"),[p,E]=React$2.useState(!1),[T,v]=React$2.useState(0),[S,g]=React$2.useState({current:{questions:[],type:n}}),[y]=o,b=D=>a({type:"translate",payload:D}),R=D=>{D.code==="Enter"&&D.target.blur()},_=()=>{y("click-ui"),t({type:"saveSurveyPrePos",payload:S.current})};React$2.useEffect(()=>{!e.length&&f==="questions"&&u("end")},[e,f]);const w=(D,k=!1)=>{var M;const F=D!==null?D:(M=S.current.questions.find(I=>I.id===e[T].id))==null?void 0:M.answer;if(y("click-ui"),k)v(T-1),E(!1);else{const I=S.current.questions.findIndex(z=>z.id===e[T].id),$=[...S.current.questions];I>-1?$.splice(I,1,{id:e[T].id,answer:F}):$.push({id:e[T].id,answer:F}),g({...S,current:{...S.current,questions:$}}),T===e.length-1?E(!0):(v(T+1),E(!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:()=>{u("questions"),y("click-ui")},translate:b}),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:[b("auto-evaluation.question")," ",T+1," ",b("storylines.misc.of")," ",e.length]})}),jsxRuntimeExports.jsx("div",{children:b("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"survey--questions__item","aria-label":"survey questions item",children:(C=e[T])==null?void 0:C.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,k)=>{var F;return jsxRuntimeExports.jsx("button",{"data-testid":`button-option-${0+k}`,type:"button",onTouchStart:()=>{h(k)},onTouchEnd:()=>{h(null)},onKeyUp:M=>{R(M)},onClick:()=>{w(k,!1)},className:`survey--points__item survey--points__item--simple ${((F=S.current.questions[T])==null?void 0:F.answer)===k||d===k?"selected":""}`,children:k},`${0+k}`)})})})]},`${e[T]}`)]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next","aria-label":"test buttons",children:[jsxRuntimeExports.jsx("button",{"data-testid":"back-button",type:"button",disabled:T===0,onClick:()=>w(null,!0),"aria-label":LangIsRtl()?b("survey.next"):b("survey.previous"),className:`gat--btn__navigation ${T===0?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back","aria-label":"icon button"})}),p?jsxRuntimeExports.jsx("button",{"data-testid":"finish-button",type:"button",onClick:()=>{u("end"),y("click-ui")},className:`gat--btn gat--btn__primary auto-evaluation__button not-transition
253
253
  `,children:jsxRuntimeExports.jsx("span",{children:b("auto-evaluation.end")})}):jsxRuntimeExports.jsx("button",{"data-testid":"forward-button",type:"button",onClick:()=>w(null,!1),disabled:((N=S.current.questions[T])==null?void 0:N.answer)===void 0,"aria-label":LangIsRtl()?b("survey.previous"):b("survey.next"),className:`gat--btn__navigation ${((P=S.current.questions[T])==null?void 0:P.answer)===void 0?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]}),f==="end"&&jsxRuntimeExports.jsx(EndScreen,{onFinish:_,translate:b})]})]})}function PatternComponent({img:l,name:e,viewed:n,emitEvent:t,getEvent:a,soundActions:o,keyboardControl:d}){const[h]=o,f=T=>a({type:"translate",payload:T}),u=()=>{h("click-ui"),t({type:"savePattern",payload:{imgId:l.resourceId,name:e,viewed:!0,url:E,type:"pattern"}})},p=d({disabled:n,forward:u,escape:u});if(React$2.useEffect(()=>p(),[p]),!l)return null;const E=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:E&&jsxRuntimeExports.jsx("img",{src:E,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:()=>u(),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})]}),jsxRuntimeExports.jsx("figure",{className:"pattern__figure",children:E&&jsxRuntimeExports.jsx("img",{src:E,alt:"pattern"})})]})})})}const getRecursiveJSX=(l,e=0,n,t,a)=>{var o,d;if((o=l.props)!=null&&o.children){const h=l.type,{children:f,...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 E=0;E<p.length;E+=1)u["data-text-id"]===p[E].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(f)?jsxRuntimeExports.jsx(h,{...u,children:f.map((p,E)=>getRecursiveJSX(p,E,n,t))},`${l.type}_${e}`):jsxRuntimeExports.jsx(h,{...u,children:getRecursiveJSX(f,e,n,t)},`${l.type}_${e}`)}return((d=l.props)==null?void 0:d.children)!==null?l.split(" ").filter(h=>h!=="").map(h=>jsxRuntimeExports.jsx("span",{dir:"auto",children:h},h)):null};function TextClickPuzzleComponent({emitEvent:l,getEvent:e,showFrames:n,styles:t,list:a,soundActions:o,description:d,setInfo:h,setResolveAction:f,keyboardControl:u,backgroundImage:p,hideBackgroundImageTheme:E=!1,nodeId:T}){const v=`textclick-puzzle_${T}`,[S,g]=React$2.useState({result:null,show:!1,text:"",timeout:!1}),[y]=o,[b,R]=React$2.useState(0),[_,w]=React$2.useState(0),[C,N]=React$2.useState(0),P=React$2.useRef(0),D=React$2.useRef([]),[k,F]=React$2.useState(0),[M,I]=React$2.useState(),$=React$2.useCallback(B=>e({type:"translate",payload:B}),[e]),z=React$2.useRef(null),X=React$2.useCallback(()=>P.current===a[b].correctTexts.length||a[b].hasClickOnce&&P.current>=1,[b,a]),te=React$2.useCallback((B,Y)=>{B&&l({type:"hidePuzzleButtons",payload:!0}),g(re=>({...re,show:B,...Y}))},[l]),ae=React$2.useCallback(()=>{if(X())if(g(B=>({...B,result:!1})),P.current=0,C===_){const B=D.current.reduce((Y,re)=>{const le=Y.findIndex(fe=>fe.id===re.id);return le>=0?Y[le].points+=re.points:Y.push({...re}),Y},[]);l({type:"addPoints",complex:!0,finish:!0,payload:B}),l({type:"passPuzzle"})}else z.current=null,R(b+1),F(0),I(!0),setTimeout(()=>{I(!1)},1200)},[X,C,_,l,b]),ee=React$2.useCallback(()=>{l({type:"hidePuzzleButtons",payload:!1}),ae(),g(Y=>({...Y,show:!1,text:""}));const B=document.querySelectorAll(".text-click__failed");B.length>0&&B.forEach(Y=>Y.classList.remove("text-click__failed"))},[l,ae]),K=React$2.useCallback((B,Y)=>{var re,le;B.forEach(fe=>fe.classList.add("text-click__success")),N(C+1),P.current+=1,y("score"),(re=a[b].info.solution.right)!=null&&re.desc?X()&&(D.current=[...D.current,...a[b].info.solution.right.rewards],te(!0,{result:!0,text:a[b].info.solution.right.desc,timeout:!1})):a[b].info.solution.right.desc===""&&(Y!=null&&Y.desc)?(D.current=((le=Y==null?void 0:Y.rewards)==null?void 0:le.length)>0?[...D.current,...(Y==null?void 0:Y.rewards)||{}]:[...D.current],te(!0,{result:!0,text:Y.desc,timeout:!1})):a[b].specificFeedbacks.specificCorrectFeedbacks?(D.current=[...D.current,...(Y==null?void 0:Y.rewards)||{}],X()&&te(!0,{result:!0,timeout:!0})):X()&&(D.current=[...D.current,...a[b].info.solution.right.rewards],te(!0,{result:!0,timeout:!0}))},[C,y,a,b,X,te]),ne=React$2.useCallback((B,Y)=>{var re;B.forEach(le=>le.classList.add("text-click__failed")),y("fail"),l({type:"failPuzzle"}),a[b].info.solution.wrong.desc!==""?(D.current=[...D.current,...a[b].info.solution.wrong.rewards],te(!0,{result:!1,text:a[b].info.solution.wrong.desc,timeout:!1})):a[b].info.solution.wrong.desc===""&&(Y!=null&&Y.desc)?(D.current=(re=Y==null?void 0:Y.rewards)!=null&&re.length?[...D.current,...(Y==null?void 0:Y.rewards)||{}]:[...D.current],te(!0,{result:!1,text:Y.desc,timeout:!1})):a[b].specificFeedbacks.specificWrongFeedbacks?(D.current=[...D.current,...(Y==null?void 0:Y.rewards)||{}],te(!0,{result:!1,timeout:!0})):(D.current=[...D.current,...a[b].info.solution.wrong.rewards],te(!0,{result:!1,timeout:!0}))},[y,l,a,b,te]),ue=React$2.useCallback((B,Y)=>{var Re,Oe,Ne,Xe;B.stopPropagation();const re=document.querySelectorAll(`[data-text-id="${Y}"]`),le=document.querySelectorAll("[data-text-id]"),fe=a[b].correctTexts.find(ft=>ft.id===Y),de=a[b].wrongTexts.find(ft=>ft.id===Y),ge=(Oe=(Re=a[b])==null?void 0:Re.specificFeedbacks)==null?void 0:Oe.correctFeedbacks.find(ft=>ft.id===Y),Ee=(Xe=(Ne=a[b])==null?void 0:Ne.specificFeedbacks)==null?void 0:Xe.wrongFeedbacks.find(ft=>ft.id===Y);y("click-ui"),a[b].hasClickOrder?a[b].correctTexts[k].id===Y?(F(k+1),K(re,ge)):a[b].correctTexts.find(ft=>ft.id===Y)&&a[b].correctTexts[k].id!==Y?(le.forEach(ft=>ft.classList.remove("text-click__success")),F(0),N(0),P.current=0,te(!0,{result:!1,text:a[b].info.orderFeedback.desc||$("puzzles.incorrectOrder"),timeout:!1}),R(0)):ne(re,Ee):(fe==null?void 0:fe.id)===Y?K(re,ge):((de==null?void 0:de.id)===Y||Y==="allWrong")&&ne(re,Ee)},[a,b,y,k,K,te,$,ne]),pe=React$2.useCallback(B=>getRecursiveJSX(B,0,a[b],ue),[b,a,ue]),J=React$2.useCallback(()=>{let B=0;for(let Y=0;Y<a.length;Y+=1)if(a[Y].hasClickOnce)B+=1,w(B);else for(let re=0;re<a[Y].correctTexts.length;re+=1)B+=1,w(B)},[a]);React$2.useEffect(()=>{var B;if(a!=null&&a[b]&&h({...a[b].info,description:d}),(B=a[b])!=null&&B.text){const Y=HTMLReactParser$1(a[b].text);z.current=pe(Y),J()}else z.current=""},[b,d,J,a,pe,h]);const H=()=>{for(let B=0;B<D.current.length;B=B+1)if(D.current[B].points>0)return!0;return!1};React$2.useEffect(()=>{f(()=>{l({type:"hidePuzzleButtons",payload:!0});const B=document.querySelectorAll(".text-click [data-text-id]"),Y=a[b].correctTexts.map(le=>le.id);B.forEach(le=>{Y.includes(le.getAttribute("data-text-id"))&&le.classList.add("text-click__success")});const re=a[b].info.resolve.rewards;b+1<a.length?(setTimeout(()=>{l({type:"puzzleAction",action:"addPoints",payload:{element:v,rewards:re,finish:!1,payload:re}});let le=0;a.forEach((fe,de)=>{de<=b&&(le+=fe.correctTexts.length)}),N(le),z.current=null,P.current=0,I(!0),R(b+1)},2e3),setTimeout(()=>{I(!1),l({type:"hidePuzzleButtons",payload:!1})},3200)):b+1>=a.length&&H()?setTimeout(()=>{re.forEach(le=>{D.current.forEach(fe=>{fe.id===le.id&&(le.points=le.points+fe.points)})}),l({type:"puzzleAction",action:"resolve",payload:{element:v,rewards:re,finish:!0}})},2e3):setTimeout(()=>{l({type:"puzzleAction",action:"resolve",payload:{element:v,rewards:re,finish:b+1>=a.length}})},2e3)})},[f,l,a,b,v]);const W=React$2.useMemo(()=>{let B=`text-click text-click--${t}`;return E&&(B+=" disable-background-image"),B},[E,t]),V={pointerEvents:S.show?"none":null,backgroundImage:p!=null&&p.url?`url('${p.url}')`:""};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{"data-testid":"wrapperDiv",className:W,style:V,children:[jsxRuntimeExports.jsx("div",{className:"text-click__overlay",children:jsxRuntimeExports.jsx("div",{className:`text-click__container ${M?"slideInLeft":""} `,children:jsxRuntimeExports.jsx("div",{className:"text-click__body",children:jsxRuntimeExports.jsx("div",{className:"text-click__scroll",dir:LangIsRtl()?"rtl":"auto",children:z.current})})})}),n&&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:[C," / ",_]})]})]}),S.show&&jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:y,success:S.result,text:S.text,translate:$,functionOnClose:ee,hasTimeout:S.timeout,keyboardControl:u})]})}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