@gamelearn/arcade-components 3.2.2 → 3.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -68,7 +68,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
68
68
  ${x.feedback?"":"conversation--layer__defaultFeedback"}
69
69
  ${_==="results"?"conversation--layer__feedback":""}`,children:V}):V,D=({children:V})=>jsxRuntimeExports.jsx("div",{className:"popup--layer popup--layer--transparent",children:V}),F=({children:V})=>{var Z,q;let W={};return W=(Z=a.background)!=null&&Z.img?{backgroundImage:`url("${(q=a.background.img)==null?void 0:q.url}")`}:null,jsxRuntimeExports.jsxs("div",{className:`conversation ${t?"conversation--inScene":""}`,style:W,children:[jsxRuntimeExports.jsx(SlotList,{...T,children:V}),jsxRuntimeExports.jsx(DecisionBody,{...O})]})},G=()=>p?jsxRuntimeExports.jsx(F,{children:_==="results"&&x.feedback?jsxRuntimeExports.jsx(FeedBack,{question:f,soundActions:e,inherited:p,choice:x,rewards:x.rewards||[],emitEvent:o}):null}):jsxRuntimeExports.jsx(D,{children:jsxRuntimeExports.jsx(DecisionBody,{...O,children:jsxRuntimeExports.jsx(FeedBack,{question:f,soundActions:e,inherited:p,choice:x,rewards:x.rewards||[],emitEvent:o})})});return jsxRuntimeExports.jsx(k,{children:jsxRuntimeExports.jsx(G,{})})}function ImageComponent({emitEvent:o,img:e,imgName:r,documentType:t,visible:n,viewed:a,imgId_labelId:u,soundActions:l,keyboardControl:f}){const c=g=>o({type:"translate",payload:g}),[h,y]=React$2.useState(!1),E=e.url,[p]=l,_=React$2.useCallback(()=>{p("click-ui"),o({type:"finishMedia",payload:{imgId:u,name:r,imgName:r,documentType:t,type:"image"}})},[p,u,r,t,o]);return f(null,a?null:_,a?null:_),React$2.useEffect(()=>{!n&&!h&&(y(!0),_())},[_,n,h]),n?jsxRuntimeExports.jsx("div",{className:a?"notes--results":"readings--container readings--container--darkopacity",children:jsxRuntimeExports.jsxs("div",{className:a?"notes--results__text":"readings readings--image",children:[E&&jsxRuntimeExports.jsx("img",{src:E,alt:r}),a?null:jsxRuntimeExports.jsx("div",{className:E?"readings--image--closeBtn":"position--absolute top right",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__round gat--btn__close",onClick:_,"aria-label":c("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})})]})}):null}function VoiceOver({name:o}){return jsxRuntimeExports.jsx("div",{className:"conversation--voice__over",children:jsxRuntimeExports.jsx("span",{children:o||"Voice-Over"})})}function ThinkFul({text:o}){return jsxRuntimeExports.jsxs("div",{className:"conversation--voice__over",children:[jsxRuntimeExports.jsx("span",{className:"icon-bubble-thinkful-black"}),jsxRuntimeExports.jsxs("span",{children:["[",o,"]"]})]})}function Message({current:o,translate:e}){var t,n;const r=o.text;return jsxRuntimeExports.jsxs("div",{className:`conversation--message ${o.voiceOver||(t=o==null?void 0:o.emotion)!=null&&t.includes("think")?"voice--over":""}`,children:[o.voiceOver?jsxRuntimeExports.jsx(VoiceOver,{name:o.name}):null,(n=o==null?void 0:o.emotion)!=null&&n.includes("think")?jsxRuntimeExports.jsx(ThinkFul,{text:e("emotion.thinking")}):null,jsxRuntimeExports.jsx("span",{className:"conversation--main__text",children:r})]})}Message.defaultProps={current:{},voiceOver:!1};const characterMs$2=75,minMs$1=1400;function ConversationalProComponent({keyboardControl:o,emitEvent:e,pause:r,lines:t,edges:n,characters:a,actors:u,background:l,soundActions:f,lodSettings:c,autoPlay:h,autoEnd:y,progress:E}){var et,at,Kt;const p=(E==null?void 0:E.line)||0,[_,g]=React$2.useState(!1),[x,C]=React$2.useState(!0),[R,S]=React$2.useState(!!h),[A,T]=React$2.useState(!1),[w,P]=React$2.useState(p),[O,k]=React$2.useState(!1),[D]=f,{start:F,stop:G}=useTimeout(),V=((et=l==null?void 0:l.img)==null?void 0:et.url)||null,W=t[w],{voiceOver:Z,decision:q}=W;let z=[];const U=!!n,I=Z||W.type==="conversationalNarration",$=q||W.type==="conversationalDecision";let{flex:B}=W;const[X,Q]=React$2.useState([]),J=React$2.useMemo(()=>X[X.length-1],[X]),ne=React$2.useCallback(()=>{const Xe=n.find(pe=>pe.fromId===J)||n.find(pe=>pe.toId===J),it=t.find(pe=>pe.id===(Xe==null?void 0:Xe.fromId));return!J&&(E==null?void 0:E.line)>=0?{decision:!0}:it},[n,t,J,E==null?void 0:E.line]),se=React$2.useCallback(()=>{if(U){const it=ne();return it==null?void 0:it.decision}const Xe=t[w-1]?t[w-1]:{};return w>0&&(Xe==null?void 0:Xe.decision)},[U,ne,t,w]),ee=React$2.useCallback(Xe=>e({type:"translate",payload:Xe}),[e]),ie=React$2.useMemo(()=>{var it,pe;if($)return{};if(I)return W;const Xe=(it=W==null?void 0:W.slots)==null?void 0:it.find(ge=>ge.uid&&ge.talking);return Xe||((pe=W==null?void 0:W.slots)==null?void 0:pe.find(ge=>ge.uid&&ge.text))},[W,I,$]),oe=t.slice(0,w+1).reverse().find(Xe=>Xe.slots),fe=!$&&((at=W.slots)==null?void 0:at.filter(Xe=>Xe.uid).length),de=characterMs$2*(((Kt=ie==null?void 0:ie.text)==null?void 0:Kt.length)||0);let ce=[];W.slots?ce=W.slots:oe&&(ce=oe.slots);const Se=ce.filter(Xe=>Xe.uid).map(Xe=>{const it=(a||u||[]).find(pe=>pe.uid===Xe.uid);return it&&(Xe.resource=it.resource,Xe.type=it.type),Xe.resource||(Xe.resource={}),Xe}),ke={characters:Se,lodSettings:c,actors:u,currentMessage:ie||{},slots:I?z:W.slots,flex:B,pause:r,emitEvent:e};if(I){const Xe=t.slice(w).find(pe=>pe.slots),it=oe||Xe;it&&(z=it.slots,B=it.flex)}else if(!$&&fe&&(W.slots.forEach(Xe=>{const it=Se.findIndex(pe=>pe.uid===Xe.uid);it>=0&&(Se[it].emotion=Xe.emotion)}),ie&&ie.uid)){const Xe=W.slots.findIndex(pe=>pe.uid===ie.uid),it=Se.findIndex(pe=>pe.uid===ie.uid);Se.forEach(pe=>{pe.uid===ie.uid&&(pe.name=ie.alias)}),ie.position=B?it:Xe}const Ne=React$2.useCallback(()=>{e({type:"success"})},[e]),We=React$2.useCallback((Xe,it)=>{const pe=[3,2,1][Xe.id],ye=n.filter(Oe=>Oe.fromId===W.id).find(Oe=>parseInt(Oe.fromPointIndex)===pe);if(ye){const Oe=t.findIndex(Ge=>Ge.id===ye.toId);ye.fromId===ye.toId?it():Oe>=0?(P(Oe),e({type:"notifyProgress",payload:{line:Oe}})):Ne()}else Ne()},[W.id,n,e,Ne,t]),Ke=React$2.useCallback((Xe=!0)=>{const it=Xe?["fromId","toId"]:["toId","fromId"],pe=n.filter(Oe=>Oe[it[0]]===W.id),ge=pe.length===1?pe[0]:pe.find(Oe=>Oe[it[1]]===J);if(!(ge!=null&&ge[it[0]]))return;Xe||Q(X.slice(0,-1));const ye=t.findIndex(Oe=>Oe.id===ge[it[1]]);ye>=0?(P(ye),e({type:"notifyProgress",payload:{line:ye}})):Ne()},[W.id,n,X,e,Ne,J,t]),Qe=React$2.useCallback(Xe=>{if(U){if(Xe){const it=[3,2,1][Xe.id],ge=n.filter(ye=>ye.fromId===W.id).find(ye=>parseInt(ye.fromPointIndex)===it);if(ge){const ye=t.findIndex(Oe=>Oe.id===ge.toId);ye>=0&&e({type:"notifyProgress",payload:{line:ye}})}else e({type:"saveNode"})}}else if(w<t.length-1){const pe=w+1;e({type:"notifyProgress",payload:{line:pe}})}else e({type:"saveNode"})},[n,t,e,w,W.id,U]),pt=React$2.useCallback((Xe,it)=>{let pe=!1;if(k(!1),Q([...X,W.id]),C(!1),T(!1),U)Xe?We(Xe,it):Ke();else if(w<t.length-1){const ye=w+1;P(ye),e({type:"notifyProgress",payload:{line:ye}})}else y||W.decision?Ne():pe=!0;pe||C(!0)},[y,e,w,W.decision,W.id,Ne,Ke,We,U,t.length,X]),vt=()=>{if(C(!1),k(!1),T(!1),U)Ke(!1);else if(!se()){const Xe=w-1;P(Xe),e({type:"notifyProgress",payload:{line:Xe}})}C(!0)},ct=React$2.useCallback(()=>U?W&&W.type!=="conversationalDecision"&&!n.find(Xe=>Xe.fromId===W.id):w===t.length-1,[w,W,n,U,t.length]),mt=()=>{D("click-ui"),ct()?Ne():(S(!1),pt())},Vt=()=>{D("click-ui"),S(!1),vt()},kt=R&&!$&&!r,Ie=React$2.useMemo(()=>w===0||se(),[w,se]);if(useEkho({audioType:W==null?void 0:W.audioType,volume:W==null?void 0:W.audioVolume,voice:W==null?void 0:W.voice,started:x,slide:w,text:ie==null?void 0:ie.text,audio:W==null?void 0:W.audio,soundActions:f,emitEvent:e,pauseTTS:r,onStart:()=>{var Xe;(Xe=ie==null?void 0:ie.emotion)!=null&&Xe.includes("think")||k(!0)},onError:()=>{T(!0)},onFinish:()=>{k(!1),kt&&pt()}}),React$2.useEffect(()=>{var it;let Xe;return $?()=>{}:(((W==null?void 0:W.audioType)==="none"||A)&&!((it=ie==null?void 0:ie.emotion)!=null&&it.includes("think"))&&(k(!0),Xe=setTimeout(()=>{k(!1)},de<minMs$1?minMs$1:de)),()=>{Xe&&clearTimeout(Xe)})},[A,W,ie==null?void 0:ie.emotion,de,$]),React$2.useEffect(()=>(kt&&((W==null?void 0:W.audioType)==="none"||A)&&(!ct()||ct()&&y)&&F(pt,de<minMs$1?minMs$1:de),()=>{G()}),[ie,F,G,pt,W==null?void 0:W.audioType,kt,A,y,t,ct,de]),React$2.useEffect(()=>{if(U&&!_){const Xe=E==null?void 0:E.line;if(Xe>=0){g(!0),P(Xe);return}const it=t.filter(pe=>!n.find(ge=>ge.toId===pe.id));if(it.length){const pe=it[0],ge=t.indexOf(pe);ge>=0&&(g(!0),P(ge))}}},[n,U,t,_,E==null?void 0:E.line]),o($||Ie?null:Vt,$?null:mt),$){const Xe={...W.payload,decisionNumber:t.filter(it=>it.decision).findIndex(it=>it.id===t[w].id)+1,required:!U,branched:U,onAddPoints:Qe,onFinish:pt,keyboardControl:o,emitEvent:e,soundActions:f,inheritProps:{characters:Se,background:l,flex:oe?oe.flex:!0,slots:oe?oe.slots:[]}};return jsxRuntimeExports.jsx(DecisionComponent,{...Xe})}return jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{className:"conversation",style:V?{backgroundImage:`url("${V}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...ke,ttsStarted:O}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",dir:"auto",children:[ie?jsxRuntimeExports.jsx(Message,{current:ie,translate:ee}):null,jsxRuntimeExports.jsxs("div",{className:"conversation--controls",children:[jsxRuntimeExports.jsx("button",{className:`gat--btn__round ${Ie?"disabled":""}`,disabled:Ie?!0:"",type:"button",onClick:Vt,"aria-label":LangIsRtl()?ee("storylines.misc.forward"):ee("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{className:`gat--btn__round ${R&&ct()?"glowing-animation":""}`,type:"button",onClick:mt,"aria-label":LangIsRtl()?ee("storylines.misc.rewind"):ee("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})]})})}ConversationalProComponent.defaultProps={background:{},emitEvent:()=>{},soundActions:[()=>{},()=>{}]};function ConversationalComponent({emitEvent:o,soundActions:e,messages:r,characters:t,alias:n,background:a,lodSettings:u}){var g;const[l,f]=React$2.useState(0),[c]=e,h=((g=a==null?void 0:a.img)==null?void 0:g.url)||null,y=r[l],E=t.map((x,C)=>({...x,name:n[C]?n[C]:x.name,uid:C})),p=()=>{const x=r.length-1;c("click-ui"),l+1<=x?f(l+1):o({type:"success"})},_=()=>{l>0&&(f(l-1),c("click-ui"))};return jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{className:"conversation arcade-conversation",style:h?{backgroundImage:`url("${h}")`}:{},children:[jsxRuntimeExports.jsx(SlotList,{characters:E,lodSettings:u,currentMessage:y,slots:E,emitEvent:o,flex:!0}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",children:[y?jsxRuntimeExports.jsx(Message,{current:y,voiceOver:y.emotion===null}):jsxRuntimeExports.jsx("div",{}),jsxRuntimeExports.jsxs("div",{className:"conversation--controls arcade-conversation--controls",children:[jsxRuntimeExports.jsx("button",{className:`gat--btn__round ${l>0?"":"visibility--hidden"}`,type:"button",onClick:_,children:jsxRuntimeExports.jsx("span",{className:"icon-back"})}),jsxRuntimeExports.jsx("button",{className:"gat--btn__round",type:"button",onClick:p,children:jsxRuntimeExports.jsx("span",{className:"icon-next"})})]})]})]})})}function Vignette({vignette:o,alias:e,translate:r}){var f;const n=(o.img||{url:"https://min.gamelearn.io/css-resources/gamelearn/resources/conversation.jpg"}).url,[a,u]=React$2.useState(!0),l=c=>{document.querySelector(`#${c}`).focus(),u(!a)};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"comic--image",children:n&&jsxRuntimeExports.jsx("img",{src:n,alt:"comic pic"})}),(f=o==null?void 0:o.textData)!=null&&f.text?jsxRuntimeExports.jsxs("div",{className:`comic-collapsable ${a?"comic-collapsable--opened":""}`,children:[jsxRuntimeExports.jsx("button",{id:"buttonDown",onClick:()=>l("buttonUp"),type:"button",className:"un-btn comic-collapsable__headertoggle","aria-label":r("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,o.textData.text]})]}):null,jsxRuntimeExports.jsx("button",{id:"buttonUp",tabIndex:a?"-1":"0","aria-hidden":a,className:`unset-button comic-buttonup
70
70
  ${a?"":"comic-buttonup--visible"}`,type:"button",onClick:()=>l("buttonDown"),"aria-label":r("comic.toggleText"),children:jsxRuntimeExports.jsx("span",{className:"icon-up-arrow"})})]})}function Slide({slide:o,transition:e,translate:r}){const t=o.transitionEffects||e;return jsxRuntimeExports.jsx("div",{className:`comic--slide__item ${t}`,"aria-label":"comic slide item",children:o.vignettes.map(n=>jsxRuntimeExports.jsx(Vignette,{vignette:n,alias:o.alias,"aria-hidden":"true",translate:r},`Vignete ${n.vignetteOrder}`))})}const characterMs$1=75;function ComicComponent({slides:o,emitEvent:e,soundActions:r=[()=>{},()=>{}],autoPlay:t,autoEnd:n,pause:a,progress:u,keyboardControl:l}){var V,W,Z,q,z,U,I,$;const f=(u==null?void 0:u.slide)||0,c=B=>e({type:"translate",payload:B}),[h,y]=React$2.useState(!0),[E,p]=React$2.useState(!!t),[_,g]=React$2.useState(!1),{start:x,stop:C}=useTimeout(),[R,S]=React$2.useState(f),[A,T]=React$2.useState("slide-animation"),[w]=r,P=o==null?void 0:o[R],O=React$2.useCallback(()=>{y(!1),e({type:"success"})},[e]),k=React$2.useCallback(()=>{if(y(!1),g(!1),R+1<o.length&&!a){const B=R+1;T("slide-animation"),S(B),y(!0),e({type:"notifyProgress",payload:{slide:B}})}else n&&!a&&O()},[R,o.length,a,n,e,O]),D=React$2.useCallback(()=>{if(y(!1),g(!1),R-1>=0){const B=R-1;T("slide-animation"),S(B),y(!0),w("click-ui"),e({type:"notifyProgress",payload:{slide:B}})}},[w,R,e]),F=()=>{w("click-ui"),p(!1),k()},G=()=>{w("click-ui"),p(!1),D()};return l(R>0?G:null,R+1>=o.length&&O||(R+1<o.length?F:null),R+1>=o.length?O:null),useEkho({audioType:(V=o==null?void 0:o[R])==null?void 0:V.audioType,voice:(W=o==null?void 0:o[R])==null?void 0:W.voice,text:(q=(Z=o==null?void 0:o[R])==null?void 0:Z.vignettes[0].textData)==null?void 0:q.text,audio:(z=o==null?void 0:o[R])==null?void 0:z.audio,slide:R,started:h,soundActions:r,emitEvent:e,pauseTTS:a,volume:(U=o==null?void 0:o[R])!=null&&U.audioVolume||((I=o==null?void 0:o[R])==null?void 0:I.audioVolume)===0?($=o==null?void 0:o[R])==null?void 0:$.audioVolume:.5,onError:()=>{g(!0)},onFinish:()=>{E&&!(P!=null&&P.slideTimer)&&k()}}),React$2.useEffect(()=>{var B,X;if(E){if(P!=null&&P.slideTimer)x(k,P.slideTimer*1e3);else if((P==null?void 0:P.audioType)==="none"&&!a||_&&!a){const Q=characterMs$1*(((X=(B=P==null?void 0:P.vignettes[0])==null?void 0:B.textData)==null?void 0:X.text.length)||0);x(k,Q<1400?1400:Q)}}return()=>{C()}},[_,E,k,a,P==null?void 0:P.audio,P==null?void 0:P.audioType,P==null?void 0:P.slideTimer,P==null?void 0:P.vignettes,x,C]),o!=null&&o.length?jsxRuntimeExports.jsx("div",{dir:LangIsRtl()?"rtl":"auto",className:"comic component growIn-animation",role:"main","aria-label":"Comic",children:jsxRuntimeExports.jsxs("div",{className:"comic--slider",role:"navigation","aria-label":"Slider",children:[o[R]&&jsxRuntimeExports.jsx(Slide,{slide:o[R],transition:A,soundActions:r,emitEvent:e,role:"complementary","aria-hidden":"true",translate:c},`comic page ${o[R].slideOrder}`),R>0&&jsxRuntimeExports.jsx("button",{type:"button",className:"comic-control comic-control--left gat--btn__round","data-testid":"btn-bck",onClick:G,"aria-label":LangIsRtl()?c("comic.next"):c("comic.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),R<o.length&&jsxRuntimeExports.jsx("button",{type:"button",className:`comic-control comic-control--right gat--btn__round
71
- ${E&&R+1>=o.length?"glowing-animation":""}`,"data-testid":"btn-nxt",onClick:()=>{R+1<o.length?F():(w("click-ui"),O())},"aria-label":LangIsRtl()?c("comic.previous"):c("comic.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})}):null}function CartelComponent({img:o,text:e,audio:r,audioType:t,voice:n,emitEvent:a,soundActions:u,audioVolume:l,pause:f,keyboardControl:c}){const h=R=>a({type:"translate",payload:R}),y=(o==null?void 0:o.url)||"https://min.gamelearn.io/css-resources/gamelearn/resources/conversation.jpg",E=React$2.useRef(),p=React$2.useRef(),[_]=u;useEkho({audioType:t,voice:n,text:e,audio:r,soundActions:u,emitEvent:a,volume:l,pauseTTS:f});const g=()=>{_("click-ui"),a({type:"success"})};c(null,g,g);const x=(R,S)=>window.matchMedia("(min-width: 1280px)").matches?S:R,C=React$2.useCallback(()=>{if(e&&p.current){const R=p.current.naturalWidth/p.current.naturalHeight;let S=p.current.height*R,A=p.current.height;if(S>p.current.width&&(S=p.current.width,A=p.current.width/R),E.current.style.width=`${S}px`,window.innerHeight<p.current.width)E.current.style.bottom=`${x(24,48)+x(36,100)}px`;else{const T=(window.innerHeight-A)/2+x(36,100);E.current.style.bottom=`${T}px`}}},[e]);return React$2.useEffect(()=>{p.current&&new ResizeObserver(()=>x(24,48)&&C()).observe(p.current)}),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"cartel",children:jsxRuntimeExports.jsxs("div",{className:"cartel__imagewrap",children:[jsxRuntimeExports.jsx("img",{ref:p,onLoad:C,className:"cartel__image",src:y,alt:"cartel pic"}),e?jsxRuntimeExports.jsx("div",{ref:E,className:"cartel__textwrap",children:jsxRuntimeExports.jsx("div",{className:"cartel__text",children:jsxRuntimeExports.jsx("span",{children:e})})}):null]})}),jsxRuntimeExports.jsx("div",{className:"position--absolute center right",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__round",onClick:()=>g(),"aria-label":h("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})})]})}var Typist$1={exports:{}};(function(o){o.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var a=r[n]={exports:{},id:n,loaded:!1};return e[n].call(a.exports,a,a.exports,t),a.loaded=!0,a.exports}return t.m=e,t.c=r,t.p="",t(0)}([function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0});var n=Object.assign||function(k){for(var D=1;D<arguments.length;D++){var F=arguments[D];for(var G in F)Object.prototype.hasOwnProperty.call(F,G)&&(k[G]=F[G])}return k},a=function(){function k(D,F){for(var G=0;G<F.length;G++){var V=F[G];V.enumerable=V.enumerable||!1,V.configurable=!0,"value"in V&&(V.writable=!0),Object.defineProperty(D,V.key,V)}}return function(D,F,G){return F&&k(D.prototype,F),G&&k(D,G),D}}(),u=t(1),l=S(u),f=t(2),c=S(f),h=t(10),y=S(h),E=t(12),p=S(E),_=t(13),g=S(_),x=t(14),C=R(x);function R(k){if(k&&k.__esModule)return k;var D={};if(k!=null)for(var F in k)Object.prototype.hasOwnProperty.call(k,F)&&(D[F]=k[F]);return D.default=k,D}function S(k){return k&&k.__esModule?k:{default:k}}function A(k,D){if(!(k instanceof D))throw new TypeError("Cannot call a class as a function")}function T(k,D){if(!k)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D&&(typeof D=="object"||typeof D=="function")?D:k}function w(k,D){if(typeof D!="function"&&D!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof D);k.prototype=Object.create(D&&D.prototype,{constructor:{value:k,enumerable:!1,writable:!0,configurable:!0}}),D&&(Object.setPrototypeOf?Object.setPrototypeOf(k,D):k.__proto__=D)}var P=["🔙","⏰"],O=function(k){w(D,k);function D(F){A(this,D);var G=T(this,(D.__proto__||Object.getPrototypeOf(D)).call(this,F));return G.state={textLines:[],isDone:!1},G.onTypingDone=function(){G.mounted&&(G.setState({isDone:!0}),G.props.onTypingDone())},G.delayGenerator=function(V,W,Z,q){var z=G.props.avgTypingDelay,U=G.props.stdTypingDelay;return G.props.delayGenerator(z,U,{line:V,lineIdx:W,character:Z,charIdx:q,defDelayGenerator:function(){var $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:z,B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:U;return C.gaussianRnd($,B)}})},G.typeLine=function(V,W){if(!G.mounted)return Promise.resolve();var Z=V,q=G.props.onLineTyped;return C.isBackspaceElement(V)?(V.props.delay>0&&(G.introducedDelay=V.props.delay),Z="🔙".repeat(V.props.count)):C.isDelayElement(V)&&(G.introducedDelay=V.props.ms,Z="⏰"),new Promise(function(z,U){G.setState({textLines:G.state.textLines.concat([""])},function(){C.eachPromise(Z,G.typeCharacter,Z,W).then(function(){return q(Z,W)}).then(z).catch(U)})})},G.typeCharacter=function(V,W,Z,q){if(!G.mounted)return Promise.resolve();var z=G.props.onCharacterTyped;return new Promise(function(U){var I=G.state.textLines.slice();C.sleep(G.introducedDelay).then(function(){G.introducedDelay=null;var $=V==="🔙",B=V==="⏰";if(B){U();return}if($&&q>0){for(var X=q-1,Q=I[X],J=X;J>=0&&!(Q.length>0&&!P.includes(Q[0]));J--)X=J,Q=I[X];I[X]=Q.substr(0,Q.length-1)}else I[q]+=V;G.setState({textLines:I},function(){var ne=G.delayGenerator(Z,q,V,W);z(V,W),setTimeout(U,ne)})})})},G.mounted=!1,G.linesToType=[],G.introducedDelay=null,F.children&&(G.linesToType=C.extractTextFromElement(F.children)),G}return a(D,[{key:"componentDidMount",value:function(){this.mounted=!0;var G=this.props,V=G.children,W=G.startDelay;V?W>0&&typeof window<"u"?setTimeout(this.typeAllLines.bind(this),W):this.typeAllLines():this.onTypingDone()}},{key:"shouldComponentUpdate",value:function(G,V){if(V.textLines.length!==this.state.textLines.length)return!0;for(var W=0;W<V.textLines.length;W++){var Z=this.state.textLines[W],q=V.textLines[W];if(Z!==q)return!0}return this.state.isDone!==V.isDone}},{key:"componentWillUnmount",value:function(){this.mounted=!1}},{key:"typeAllLines",value:function(){var G=this,V=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.linesToType;return C.eachPromise(V,this.typeLine).then(function(){return G.onTypingDone()})}},{key:"render",value:function(){var G=this.props,V=G.className,W=G.cursor,Z=this.state.isDone,q=C.cloneElementWithSpecifiedText({element:this.props.children,textLines:this.state.textLines});return l.default.createElement("div",{className:"Typist "+V},q,l.default.createElement(y.default,n({isDone:Z},W)))}}]),D}(u.Component);O.propTypes={children:c.default.node,className:c.default.string,avgTypingDelay:c.default.number,stdTypingDelay:c.default.number,startDelay:c.default.number,cursor:c.default.object,onCharacterTyped:c.default.func,onLineTyped:c.default.func,onTypingDone:c.default.func,delayGenerator:c.default.func},O.defaultProps={className:"",avgTypingDelay:70,stdTypingDelay:25,startDelay:0,cursor:{},onCharacterTyped:function(){},onLineTyped:function(){},onTypingDone:function(){},delayGenerator:C.gaussianRnd},r.default=O,O.Backspace=p.default,O.Delay=g.default},function(e,r){e.exports=React$2},function(e,r,t){if(process.env.NODE_ENV!=="production"){var n=typeof Symbol=="function"&&Symbol.for&&Symbol.for("react.element")||60103,a=function(l){return typeof l=="object"&&l!==null&&l.$$typeof===n},u=!0;e.exports=t(3)(a,u)}else e.exports=t(9)()},function(e,r,t){var n=t(4),a=t(5),u=t(6),l=t(7),f=t(8);e.exports=function(c,h){var y=typeof Symbol=="function"&&Symbol.iterator,E="@@iterator";function p(I){var $=I&&(y&&I[y]||I[E]);if(typeof $=="function")return $}var _="<<anonymous>>",g={array:S("array"),bool:S("boolean"),func:S("function"),number:S("number"),object:S("object"),string:S("string"),symbol:S("symbol"),any:A(),arrayOf:T,element:w(),instanceOf:P,node:F(),objectOf:k,oneOf:O,oneOfType:D,shape:G};function x(I,$){return I===$?I!==0||1/I===1/$:I!==I&&$!==$}function C(I){this.message=I,this.stack=""}C.prototype=Error.prototype;function R(I){if(process.env.NODE_ENV!=="production")var $={},B=0;function X(J,ne,se,ee,ie,oe,fe){if(ee=ee||_,oe=oe||se,fe!==l){if(h)a(!1,"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");else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var de=ee+":"+se;!$[de]&&B<3&&(u(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. 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.",oe,ee),$[de]=!0,B++)}}return ne[se]==null?J?ne[se]===null?new C("The "+ie+" `"+oe+"` is marked as required "+("in `"+ee+"`, but its value is `null`.")):new C("The "+ie+" `"+oe+"` is marked as required in "+("`"+ee+"`, but its value is `undefined`.")):null:I(ne,se,ee,ie,oe)}var Q=X.bind(null,!1);return Q.isRequired=X.bind(null,!0),Q}function S(I){function $(B,X,Q,J,ne,se){var ee=B[X],ie=Z(ee);if(ie!==I){var oe=q(ee);return new C("Invalid "+J+" `"+ne+"` of type "+("`"+oe+"` supplied to `"+Q+"`, expected ")+("`"+I+"`."))}return null}return R($)}function A(){return R(n.thatReturnsNull)}function T(I){function $(B,X,Q,J,ne){if(typeof I!="function")return new C("Property `"+ne+"` of component `"+Q+"` has invalid PropType notation inside arrayOf.");var se=B[X];if(!Array.isArray(se)){var ee=Z(se);return new C("Invalid "+J+" `"+ne+"` of type "+("`"+ee+"` supplied to `"+Q+"`, expected an array."))}for(var ie=0;ie<se.length;ie++){var oe=I(se,ie,Q,J,ne+"["+ie+"]",l);if(oe instanceof Error)return oe}return null}return R($)}function w(){function I($,B,X,Q,J){var ne=$[B];if(!c(ne)){var se=Z(ne);return new C("Invalid "+Q+" `"+J+"` of type "+("`"+se+"` supplied to `"+X+"`, expected a single ReactElement."))}return null}return R(I)}function P(I){function $(B,X,Q,J,ne){if(!(B[X]instanceof I)){var se=I.name||_,ee=U(B[X]);return new C("Invalid "+J+" `"+ne+"` of type "+("`"+ee+"` supplied to `"+Q+"`, expected ")+("instance of `"+se+"`."))}return null}return R($)}function O(I){if(!Array.isArray(I))return process.env.NODE_ENV!=="production"&&u(!1,"Invalid argument supplied to oneOf, expected an instance of array."),n.thatReturnsNull;function $(B,X,Q,J,ne){for(var se=B[X],ee=0;ee<I.length;ee++)if(x(se,I[ee]))return null;var ie=JSON.stringify(I);return new C("Invalid "+J+" `"+ne+"` of value `"+se+"` "+("supplied to `"+Q+"`, expected one of "+ie+"."))}return R($)}function k(I){function $(B,X,Q,J,ne){if(typeof I!="function")return new C("Property `"+ne+"` of component `"+Q+"` has invalid PropType notation inside objectOf.");var se=B[X],ee=Z(se);if(ee!=="object")return new C("Invalid "+J+" `"+ne+"` of type "+("`"+ee+"` supplied to `"+Q+"`, expected an object."));for(var ie in se)if(se.hasOwnProperty(ie)){var oe=I(se,ie,Q,J,ne+"."+ie,l);if(oe instanceof Error)return oe}return null}return R($)}function D(I){if(!Array.isArray(I))return process.env.NODE_ENV!=="production"&&u(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),n.thatReturnsNull;for(var $=0;$<I.length;$++){var B=I[$];if(typeof B!="function")return u(!1,"Invalid argument supplid to oneOfType. Expected an array of check functions, but received %s at index %s.",z(B),$),n.thatReturnsNull}function X(Q,J,ne,se,ee){for(var ie=0;ie<I.length;ie++){var oe=I[ie];if(oe(Q,J,ne,se,ee,l)==null)return null}return new C("Invalid "+se+" `"+ee+"` supplied to "+("`"+ne+"`."))}return R(X)}function F(){function I($,B,X,Q,J){return V($[B])?null:new C("Invalid "+Q+" `"+J+"` supplied to "+("`"+X+"`, expected a ReactNode."))}return R(I)}function G(I){function $(B,X,Q,J,ne){var se=B[X],ee=Z(se);if(ee!=="object")return new C("Invalid "+J+" `"+ne+"` of type `"+ee+"` "+("supplied to `"+Q+"`, expected `object`."));for(var ie in I){var oe=I[ie];if(oe){var fe=oe(se,ie,Q,J,ne+"."+ie,l);if(fe)return fe}}return null}return R($)}function V(I){switch(typeof I){case"number":case"string":case"undefined":return!0;case"boolean":return!I;case"object":if(Array.isArray(I))return I.every(V);if(I===null||c(I))return!0;var $=p(I);if($){var B=$.call(I),X;if($!==I.entries){for(;!(X=B.next()).done;)if(!V(X.value))return!1}else for(;!(X=B.next()).done;){var Q=X.value;if(Q&&!V(Q[1]))return!1}}else return!1;return!0;default:return!1}}function W(I,$){return I==="symbol"||$["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&$ instanceof Symbol}function Z(I){var $=typeof I;return Array.isArray(I)?"array":I instanceof RegExp?"object":W($,I)?"symbol":$}function q(I){if(typeof I>"u"||I===null)return""+I;var $=Z(I);if($==="object"){if(I instanceof Date)return"date";if(I instanceof RegExp)return"regexp"}return $}function z(I){var $=q(I);switch($){case"array":case"object":return"an "+$;case"boolean":case"date":case"regexp":return"a "+$;default:return $}}function U(I){return!I.constructor||!I.constructor.name?_:I.constructor.name}return g.checkPropTypes=f,g.PropTypes=g,g}},function(e,r){function t(a){return function(){return a}}var n=function(){};n.thatReturns=t,n.thatReturnsFalse=t(!1),n.thatReturnsTrue=t(!0),n.thatReturnsNull=t(null),n.thatReturnsThis=function(){return this},n.thatReturnsArgument=function(a){return a},e.exports=n},function(e,r){var t=function(u){};process.env.NODE_ENV!=="production"&&(t=function(u){if(u===void 0)throw new Error("invariant requires an error message argument")});function n(a,u,l,f,c,h,y,E){if(t(u),!a){var p;if(u===void 0)p=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var _=[l,f,c,h,y,E],g=0;p=new Error(u.replace(/%s/g,function(){return _[g++]})),p.name="Invariant Violation"}throw p.framesToPop=1,p}}e.exports=n},function(e,r,t){var n=t(4),a=n;process.env.NODE_ENV!=="production"&&function(){var u=function(f){for(var c=arguments.length,h=Array(c>1?c-1:0),y=1;y<c;y++)h[y-1]=arguments[y];var E=0,p="Warning: "+f.replace(/%s/g,function(){return h[E++]});typeof console<"u"&&console.error(p);try{throw new Error(p)}catch{}};a=function(f,c){if(c===void 0)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(c.indexOf("Failed Composite propType: ")!==0&&!f){for(var h=arguments.length,y=Array(h>2?h-2:0),E=2;E<h;E++)y[E-2]=arguments[E];u.apply(void 0,[c].concat(y))}}}(),e.exports=a},function(e,r){var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=t},function(e,r,t){if(process.env.NODE_ENV!=="production")var n=t(5),a=t(6),u=t(7),l={};function f(c,h,y,E,p){if(process.env.NODE_ENV!=="production"){for(var _ in c)if(c.hasOwnProperty(_)){var g;try{n(typeof c[_]=="function","%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",E||"React class",y,_),g=c[_](h,_,E,y,null,u)}catch(C){g=C}if(a(!g||g instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. 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||"React class",y,_,typeof g),g instanceof Error&&!(g.message in l)){l[g.message]=!0;var x=p?p():"";a(!1,"Failed %s type: %s%s",y,g.message,x??"")}}}}e.exports=f},function(e,r,t){var n=t(4),a=t(5),u=t(7);e.exports=function(){function l(h,y,E,p,_,g){g!==u&&a(!1,"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")}l.isRequired=l;function f(){return l}var c={array:l,bool:l,func:l,number:l,object:l,string:l,symbol:l,any:l,arrayOf:f,element:l,instanceOf:f,node:l,objectOf:f,oneOf:f,oneOfType:f,shape:f};return c.checkPropTypes=n,c.PropTypes=c,c}},function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function _(g,x){for(var C=0;C<x.length;C++){var R=x[C];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(g,R.key,R)}}return function(g,x,C){return x&&_(g.prototype,x),C&&_(g,C),g}}(),a=t(1),u=c(a),l=t(2),f=c(l);t(11);function c(_){return _&&_.__esModule?_:{default:_}}function h(_,g){if(!(_ instanceof g))throw new TypeError("Cannot call a class as a function")}function y(_,g){if(!_)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:_}function E(_,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);_.prototype=Object.create(g&&g.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(_,g):_.__proto__=g)}var p=function(_){E(g,_);function g(x){h(this,g);var C=y(this,(g.__proto__||Object.getPrototypeOf(g)).call(this,x));return C._isReRenderingCursor=!1,C.state={shouldRender:C.props.show},C}return n(g,[{key:"componentWillReceiveProps",value:function(C){var R=this,S=!this.props.isDone&&C.isDone&&this.props.hideWhenDone;S&&setTimeout(function(){return R.setState({shouldRender:!1})},this.props.hideWhenDoneDelay)}},{key:"componentDidUpdate",value:function(){var C=this.props,R=C.show,S=C.isDone;R&&(S||this._isReRenderingCursor||this._reRenderCursor())}},{key:"_reRenderCursor",value:function(){var C=this;this._isReRenderingCursor=!0,this.setState({shouldRender:!1},function(){C.setState({shouldRender:!0},function(){C._isReRenderingCursor=!1})})}},{key:"render",value:function(){if(this.state.shouldRender){var C=this.props.blink?" Cursor--blinking":"";return u.default.createElement("span",{className:"Cursor"+C},this.props.element)}return null}}]),g}(a.Component);p.propTypes={blink:f.default.bool,show:f.default.bool,element:f.default.node,hideWhenDone:f.default.bool,hideWhenDoneDelay:f.default.number,isDone:f.default.bool},p.defaultProps={blink:!0,show:!0,element:"|",hideWhenDone:!1,hideWhenDoneDelay:1e3,isDone:!1},r.default=p},function(e,r){},function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0});var n=t(1),a=f(n),u=t(2),l=f(u);function f(h){return h&&h.__esModule?h:{default:h}}var c=function(){return a.default.createElement("noscript",null)};c.componentName="Backspace",c.propTypes={count:l.default.number,delay:l.default.number},c.defaultProps={count:1,delay:0},r.default=c},function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0});var n=t(1),a=f(n),u=t(2),l=f(u);function f(h){return h&&h.__esModule?h:{default:h}}var c=function(){return a.default.createElement("noscript",null)};c.componentName="Delay",c.propTypes={ms:l.default.number.isRequired},r.default=c},function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0}),r.sleep=void 0;var n=function(){function R(S,A){var T=[],w=!0,P=!1,O=void 0;try{for(var k=S[Symbol.iterator](),D;!(w=(D=k.next()).done)&&(T.push(D.value),!(A&&T.length===A));w=!0);}catch(F){P=!0,O=F}finally{try{!w&&k.return&&k.return()}finally{if(P)throw O}}return T}return function(S,A){if(Array.isArray(S))return S;if(Symbol.iterator in Object(S))return R(S,A);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();r.gaussianRnd=c,r.eachPromise=h,r.exclude=y,r.isBackspaceElement=E,r.isDelayElement=p,r.extractTextFromElement=_,r.cloneElement=g,r.cloneElementWithSpecifiedText=C;var a=t(1),u=l(a);function l(R){return R&&R.__esModule?R:{default:R}}function f(R){if(Array.isArray(R)){for(var S=0,A=Array(R.length);S<R.length;S++)A[S]=R[S];return A}else return Array.from(R)}r.sleep=function(S){return new Promise(function(A){return S!=null?setTimeout(A,S):A()})};function c(R,S){for(var A=12,T=0,w=0;w<A;w++)T+=Math.random();return T-=A/2,Math.round(T*S)+R}function h(R,S){for(var A=arguments.length,T=Array(A>2?A-2:0),w=2;w<A;w++)T[w-2]=arguments[w];var P=function(k,D,F){return k.then(function(){return S.apply(void 0,[D,F].concat(T))})};return Array.from(R).reduce(P,Promise.resolve())}function y(R,S){var A={};for(var T in R)S.indexOf(T)===-1&&(A[T]=R[T]);return A}function E(R){return R&&R.type&&R.type.componentName==="Backspace"}function p(R){return R&&R.type&&R.type.componentName==="Delay"}function _(R){for(var S=R?[R]:[],A=[];S.length>0;){var T=S.pop();if(u.default.isValidElement(T))E(T)||p(T)?A.unshift(T):u.default.Children.forEach(T.props.children,function(G){S.push(G)});else if(Array.isArray(T)){var w=!0,P=!1,O=void 0;try{for(var k=T[Symbol.iterator](),D;!(w=(D=k.next()).done);w=!0){var F=D.value;S.push(F)}}catch(G){P=!0,O=G}finally{try{!w&&k.return&&k.return()}finally{if(P)throw O}}}else A.unshift(T)}return A}function g(R,S){var A=R.type,T=y(R.props,["children"]),w=new Date().getUTCMilliseconds(),P=w+Math.random()+Math.random();return T.key="Typist-element-"+A+"-"+P,u.default.createElement.apply(u.default,[A,T].concat(f(S)))}function x(R,S,A){if(A>=S.length)return[null,A];var T=A,w=function(F){var G=x(F,S,T),V=n(G,2),W=V[0],Z=V[1];return T=Z,W},P=u.default.isValidElement(R)&&!(E(R)||p(R));if(P){var O=u.default.Children.map(R.props.children,w)||[];return[g(R,O),T]}if(Array.isArray(R)){var k=R.map(w);return[k,T]}return[S[T],T+1]}function C(R){var S=R.element,A=R.textLines;if(S)return x(S,A,0)[0]}}])})(Typist$1);var TypistExports=Typist$1.exports;const Typist=getDefaultExportFromCjs(TypistExports),languages={js:["var rows = prompt('How many rows for your multiplication table?');","var cols = prompt('How many columns for your multiplication table?');"," ","if(rows == '' || rows == null)"," rows = 10;"," ","if(cols== '' || cols== null)"," cols = 10;"," ","createTable(rows, cols);"," ","function createTable(rows, cols)","{"," var j=1;"," var output = '<table border='1' width='500' cellspacing='0'cellpadding='5'>';"," "," for(i=1;i<=rows;i++)"," {"," output = output + '<tr>';"," while(j<=cols)"," {"," output = output + '<td>' + i*j + '</td>';"," j = j+1;"," }"," output = output + '</tr>';"," j = 1;"," }"," "," output = output + '</table>';"," document.write(output);","}"],lua:["-- Ensure that that the element at i is in the right position,","-- and return a closure which can be used for continuing the sort."," ","function quicksorter(i, vec, low, high)"," if low >= high then"," return quicksorter"," else -- low < high"," -- partition the vector and initialize the child closures"," local middle = partition(vec, low, high)"," local left, right = quicksorter"," ","-- Create the promise"," local function self(i, vec, low, high)"," if i < middle then"," left = left(i, vec, low, middle-1)"," return self"," elseif i > middle then"," right = right(i, vec, middle+1, high)"," return self"," end"," end"," ","-- Force the promise until i is in the right position"," return self(i, vec, low, high)"," end","end"," ","function lazysort(vec, low, high)"," local sorter = quicksorter"," return function(i)"," sorter = sorter(i, vec, low, high)"," return vec[i]"," end","end"],python:["#ask the user to enter four pieces of information"," ","firstname = input('Enter your first name: ')","surname = input('Enter your surname: ')","email = input('Enter your email: ')","yearsteaching = input('Enter the number of years teaching: ')"," ","file = open('staff.csv','r') #opens the file in read mode","found=False #sets whether the user is found to False"," ","for line in file: #reads each line in the file"," staff = line.split(',') #splits the line into the list called staff"," if staff[2] == email: #checks if the email entered is in the list"," found=True #if it is changes found to True"," ","file.close() #closes the file"," ","if found==True: #after the loop checks if the user is found"," print('Staff member already exists in the file') #displays on screen","else:"," #if the email was not in the file"," writefile=open('staff.csv','a') #open the file in append mode"," writefile.write(firstname + ',' + surname + ',' + email + ',' + yearsteaching) #write the new information to the file"," writefile.close() #close the file"," print('Staff member added to file')"]},themes={theme1:{bg:1,color:1,typo:2},theme2:{bg:3,color:2,typo:3},theme3:{bg:5,color:4,typo:1},theme4:{bg:1,color:3,typo:2},theme5:{bg:2,color:5,typo:1},theme6:{bg:5,color:6,typo:2},theme7:{bg:1,color:7,typo:3}};function ProgressBar({progress:o,type:e}){const r=languages[e];if(r){const t=r.reduce((u,l)=>(u.length?u.length:u)+l.length),n=Math.floor(o*100/t),a=n===100?"puzzle--hacker__percentage percentage--label":"puzzle--hacker__percentage";return jsxRuntimeExports.jsx("div",{className:"puzzle--hacker__progress",children:jsxRuntimeExports.jsx("span",{className:"puzzle--hacker__progress--item",style:{width:`${Math.floor(o*100/t)}%`},children:jsxRuntimeExports.jsxs("span",{className:a,children:[n,"%"]})})})}return null}function Code({codeContainer:o}){const e=o,r=e.split("<br>");return r.length>0?r.map((t,n)=>{const a=t.replace(/ /g," ");return jsxRuntimeExports.jsx("p",{children:a},`line_${0+n}`)}):jsxRuntimeExports.jsx("p",{children:e})}function HackerPuzzleComponent({emitEvent:o,soundActions:e,info:r,themeNumber:t,type:n,writingSpeed:a,disableExit:u,setResolveAction:l}){const f=W=>o({type:"translate",payload:W}),[c]=e,{solution:h}=r,E=themes[`theme${t||1}`],[p,_]=React$2.useState(""),[g,x]=React$2.useState(0),[C,R]=React$2.useState(0),[S,A]=React$2.useState(!1),[T,w]=React$2.useState({start:0,end:0}),P=React$2.useRef(),O=React$2.useRef(),k=f("puzzle.hacker.congratulations"),D=(W,Z)=>W>Z.length?Z.length:W,F=()=>{c("click-ui");const{rewards:W}=h.right;o({type:"addPoints",complex:!0,finish:!0,payload:W}),o({type:"passPuzzle"})};React$2.useEffect(()=>{P.current.focus(),S&&u(!0)},[S]),React$2.useEffect(()=>{l(W=>{c("score"),A(!0),o({type:"hidePuzzleButtons",payload:!1}),W()})},[l]);const G=()=>{if(languages[n]&&!S){O.current&&(O.current.scrollTop=P.current.scrollHeight);const W=languages[n],Z=W[g],q=W.reduce((U,I)=>(U.length?U.length:U)+I.length),z=a>0?a:Math.floor(q/50)+g;if(Z){const U=Z.split(""),I=D(T.end,U),$=U.slice(T.start,I),B=p+$.join("");R(C+$.join("").length),_(B),I===U.length?g+1>=W.length?(c("score"),A(!0)):(x(g+1),_(`${p+$.join("")}<br>`),w({start:0,end:D(z,U)})):w({start:I,end:D(I+z,U)})}}},V=W=>{W.preventDefault(),G()};return jsxRuntimeExports.jsxs("div",{role:"button",tabIndex:0,"data-testid":"hacker",ref:P,onKeyDown:V,onTouchStart:V,className:`puzzle--hacker__container background-hacker-${E.bg}`,children:[jsxRuntimeExports.jsx("div",{className:"puzzle--hacker__header",children:jsxRuntimeExports.jsx("span",{className:"title",children:"Console"})}),jsxRuntimeExports.jsxs("div",{className:`puzzle--hacker__body color-hacker-${E.color} typography-hacker-${E.typo}`,children:[jsxRuntimeExports.jsxs("div",{className:"puzzle--hacker__code",ref:O,children:[jsxRuntimeExports.jsx(Code,{codeContainer:p}),S?jsxRuntimeExports.jsxs(Typist,{avgTypingDelay:110,onCharacterTyped:()=>{O.current&&(O.current.scrollTop=P.current.scrollHeight)},cursor:{hideWhenDone:!0},className:"puzzle--hacker__result",children:[jsxRuntimeExports.jsx(Typist.Delay,{ms:300}),h.right.desc?`// ${h.right.desc}`:`${k}`]}):null]}),jsxRuntimeExports.jsx(ProgressBar,{type:n,progress:C})]}),S?jsxRuntimeExports.jsx("div",{className:"position--absolute bottom center",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary gat--btn__cracker",onClick:F,children:f("screens.continue")})}):null]})}HackerPuzzleComponent.defaultProps={type:"",writingSpeed:0,context:{},info:{},themeNumber:1};const imagenPorDefecto="https://min.gamelearn.io/css-resources/gamelearn/resources/puzzle-login-low.png";function LoginPuzzleComponent({emitEvent:o,soundActions:e,info:r,user:t,login:n,password:a,image:u,setResolveAction:l,nodeId:f}){var I;const c=$=>o({type:"translate",payload:$}),h=`login-puzzle_${f}`,y=LangIsRtl(),[E,p]=React$2.useState(""),[_,g]=React$2.useState(""),[x,C]=React$2.useState(!1),[R,S]=React$2.useState(""),[A,T]=React$2.useState(""),[w,P]=React$2.useState(!1),[O,k]=React$2.useState(!1),[D,F]=React$2.useState(!1),[G]=e,[V,W]=React$2.useState([]),Z=((I=u.img)==null?void 0:I.url)||imagenPorDefecto,q=()=>{const{rewards:$}=r.solution.right,B=[...V,...$];o({type:"addPoints",complex:!0,finish:!0,payload:B}),o({type:"passPuzzle"})},z=()=>{G("click-ui");const $={login:!0,password:!1};n&&($.login=t===E),$.password=a===_,$.login&&$.password?(T("success"),P(!0),k(!1),G("score"),setTimeout(()=>{q()},2e3)):(W([...V,...r.solution.wrong.rewards]),G("fail"),T("failed"),k(!0),o({type:"failPuzzle"}))},U=$=>{let B="";if($.length>=0){for(let X=0;X<$.length;X+=1)B+="•";S(B)}};return React$2.useEffect(()=>{l(()=>{const $=[...V,...r.resolve.rewards];F(!0),setTimeout(()=>{o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:h,rewards:$,finish:!0}})},2e3)})},[V,r.resolve.rewards,o,l,h]),jsxRuntimeExports.jsx("div",{className:"puzzle--layer",style:{backgroundImage:`url("${Z}")`},children:jsxRuntimeExports.jsxs("div",{className:`puzzle--login ${t?"puzzle--login--withuser":""}`,children:[jsxRuntimeExports.jsx("span",{className:"icon-login-puzzle",children:" "}),jsxRuntimeExports.jsx("span",{className:"puzzle--login__title",children:c("puzzle.initSession")}),jsxRuntimeExports.jsxs("div",{children:[n&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--login__label",children:c("puzzle.user")}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:"puzzle--login__group",children:[D?jsxRuntimeExports.jsx("input",{dir:y?"rtl":"auto",disabled:w,"data-testid":"username",className:"puzzle--login__input success",type:"text",placeholder:t,value:t}):jsxRuntimeExports.jsx("input",{dir:y?"rtl":"auto",disabled:w,"data-testid":"username",className:`puzzle--login__input ${A}`,type:"text",placeholder:c("puzzle.user"),onChange:$=>{p($.target.value),T(""),k(!1)}}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check",children:" "})]})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--login__label",children:jsxRuntimeExports.jsx("span",{children:c("puzzle.password")})}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:"puzzle--login__group",children:[D?jsxRuntimeExports.jsx("input",{dir:y?"rtl":"auto",disabled:!0,"data-testid":"password",className:"puzzle--login__input puzzle--login__input--fakepassword success",type:"text",placeholder:a,value:a,style:{opacity:1}}):jsxRuntimeExports.jsx("input",{dir:y?"rtl":"auto",disabled:w,"data-testid":"password",className:`puzzle--login__input puzzle--login__input--fakepassword ${A}`,type:"text",placeholder:c("puzzle.password"),onFocus:()=>{C(!0)},onBlur:()=>{C(!1)},onChange:$=>{g($.target.value),U($.target.value),T(""),k(!1)}}),D?null:jsxRuntimeExports.jsx("div",{dir:y?"rtl":"auto",className:`login-fakepassword${x?" login-fakepassword--focus":""}${R.length?" login-fakepassword--fill":""} ${A||""}`,children:_?R:c("puzzle.password")}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check",children:" "})]})]})]}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${_.length!==0&&!w?"":"disabled"}`,onClick:z,children:c("puzzle.loginIn")}),!D&&O&&r.solution.wrong.desc!==""&&jsxRuntimeExports.jsx("div",{className:"puzzle--login__label--error",children:r.solution.wrong.desc})]})})}function FeedbackComponent$1({text:o,success:e,playSound:r,additionalStyle:t,functionOnClose:n,secondText:a,translate:u,shortText:l,hasTimeout:f,delay:c,timeExpired:h,keyboardControl:y}){const[E,p]=React$2.useState();React$2.useEffect(()=>{let x;return r&&r(e?"score":"fail"),o&&!l&&(x=setTimeout(()=>{p(!0)},1e3)),()=>{x&&clearTimeout(x)}},[r,e,l,o]),React$2.useEffect(()=>{let x;return f&&n&&(x=setTimeout(n,c)),()=>{x&&clearTimeout(x)}},[c,n,f]);const _=()=>e?"success":"failed",g=()=>e?"icon-correct-thumb":h?"icon-times-up":"icon-incorrect-thumb";return y(null,o&&n&&E?n:null,o&&n&&E||n&&l?n:null),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:`feedback-layer ${E?"feedback-layer--withexplain":""}`,children:[jsxRuntimeExports.jsxs("div",{className:`feedback-layer__header ${l?"feedback-layer__header--in-shortText":""} ${t||""} ${_()}`,children:[a&&jsxRuntimeExports.jsxs("span",{className:"puzzle--terminal__visor--file",children:[jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__icon ${t||""}`}),jsxRuntimeExports.jsx("span",{children:a})]}),jsxRuntimeExports.jsx("span",{className:"feedback-layer__maintitle",children:!o||!l?jsxRuntimeExports.jsx("div",{title:u(`tooltip.${e?"correct":"incorrect"}`),className:`${g()}`}):o}),l&&jsxRuntimeExports.jsx("button",{type:"button",className:"feedback-layer__closeX",onClick:()=>n(),"aria-label":u("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})]}),!l&&o!==""&&jsxRuntimeExports.jsx("div",{className:"feedback-layer__explainwrap",children:jsxRuntimeExports.jsxs("div",{className:"feedback-layer__explain",children:[jsxRuntimeExports.jsx("div",{dir:"auto",children:o}),o&&n&&E&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__navigation",onClick:()=>n(),"aria-label":u("storylines.misc.closePiece"),style:{display:"flex",margin:"auto",marginTop:"24px"},children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})})]})})}FeedbackComponent$1.defaultProps={text:"",hasTimeout:!1,delay:3e3,success:!1};const defaultImage$1="https://min.gamelearn.io/css-resources/gamelearn/resources/keyboard.jpg";function KeyboardPuzzleComponent({emitEvent:o,image:e,password:r,keyboard:t,info:n,disableExit:a,soundActions:u,setResolveAction:l,nodeId:f,keyboardControl:c}){var U;const[h,y]=React$2.useState(!1),[E,p]=React$2.useState(""),[_,g]=React$2.useState(""),[x,C]=React$2.useState(!1),[R,S]=React$2.useState(""),[A,T]=React$2.useState(!1),[w,P]=React$2.useState([]),O=I=>o({type:"translate",payload:I}),k=`keyboard-puzzle_${f}`,[D]=u,F=React$2.useCallback(I=>{C(!1),T(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"addPoints",complex:!0,finish:!0,payload:I})},[o]),G=()=>{if(x){y(!0);const{rewards:I}=n.solution.right,$=[...w,...I];D("score"),F($)}else o({type:"hidePuzzleButtons",payload:!1}),C(!1),a(!1),T(!1);S("")},V=I=>{I===r?(a(!1),p("success"),D("score"),o({type:"passPuzzle"}),C(!0),T(!0),n.solution.right.desc?S(n.solution.right.desc):setTimeout(()=>{const{rewards:$}=n.solution.right,B=[...w,...$];F(B)},3e3)):(T(!0),p("failed"),D("fail"),o({type:"failPuzzle"}),C(!1),P([...w,...n.solution.wrong.rewards]),o({type:"hidePuzzleButtons",payload:!1}),p(""),g(""),T(!0),n.solution.wrong.desc?S(n.solution.wrong.desc):setTimeout(()=>{G()},3e3))};React$2.useEffect(()=>{l(()=>{a(!1),D("score"),p("success"),C(!0),S(n.solution.right.desc),g(r),y(!0);const I=[...w,...n.resolve.rewards];setTimeout(()=>{C(!1),T(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:k,rewards:I,finish:!0}})},2e3)})},[l,a,n.solution.right.desc,D,n.resolve.rewards,w,r,o,k]);const W=(I,$)=>{const B=t[I][$];D("click-ui"),_.length<r.length+1&&(g(_+B),_.length+1===r.length&&V(_+B))},Z=()=>{D("click-ui"),g(_.substring(0,_.length-1))},q=((U=e.img)==null?void 0:U.url)||defaultImage$1,z={backgroundSize:q?"cover":"contain",backgroundImage:`url("${q}")`,backgroudPosition:"center center"};return jsxRuntimeExports.jsxs("div",{className:"puzzle--keyboard",style:z,children:[jsxRuntimeExports.jsx("div",{className:"puzzle--keyboard__header",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--keyboard__result",children:[r.split("").map((I,$)=>jsxRuntimeExports.jsx("div",{className:`puzzle--keyboard__result--item ${E}`,children:_.split("")[$]?_.split("")[$]:""},`${I+$}`)),h?jsxRuntimeExports.jsx("span",{className:"icon-circle-check"}):jsxRuntimeExports.jsx("button",{type:"button",onClick:Z,className:"puzzle--keyboard__delete","aria-label":O("puzzles.keyboard-puzzle.deleteButton"),children:jsxRuntimeExports.jsx("span",{className:"icon-delete-keyboard"})})]})}),jsxRuntimeExports.jsx("div",{className:"puzzle--keyboard__block",children:t.map((I,$)=>jsxRuntimeExports.jsx("div",{className:"puzzle--keyboard__row",children:(Array.isArray(I)?I:Object.values(I)).map((B,X)=>jsxRuntimeExports.jsx("button",{className:"puzzle--keyboard__character",type:"button",onClick:()=>W($,X),children:B},B))},`row_${0+$}`))}),A&&jsxRuntimeExports.jsx(FeedbackComponent$1,{translate:O,text:R,success:x,functionOnClose:G,keyboardControl:c})]})}var lib$1={exports:{}},_FullInternals={},_CoreInternals={},Global={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o._registerNode=o.Konva=o.glob=void 0;const e=Math.PI/180;function r(){return typeof window<"u"&&({}.toString.call(window)==="[object Window]"||{}.toString.call(window)==="[object global]")}o.glob=typeof commonjsGlobal<"u"?commonjsGlobal:typeof window<"u"?window:typeof WorkerGlobalScope<"u"?self:{},o.Konva={_global:o.glob,version:"9.3.0",isBrowser:r(),isUnminified:/param/.test((function(n){}).toString()),dblClickWindow:400,getAngle(n){return o.Konva.angleDeg?n*e:n},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,pixelRatio:typeof window<"u"&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return o.Konva.DD.isDragging},isDragReady(){return!!o.Konva.DD.node},releaseCanvasOnDestroy:!0,document:o.glob.document,_injectGlobal(n){o.glob.Konva=n}};const t=n=>{o.Konva[n.prototype.getClassName()]=n};o._registerNode=t,o.Konva._injectGlobal(o.Konva)})(Global);var Util={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Util=o.Transform=void 0;const e=Global;class r{constructor(A=[1,0,0,1,0,0]){this.dirty=!1,this.m=A&&A.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new r(this.m)}copyInto(A){A.m[0]=this.m[0],A.m[1]=this.m[1],A.m[2]=this.m[2],A.m[3]=this.m[3],A.m[4]=this.m[4],A.m[5]=this.m[5]}point(A){var T=this.m;return{x:T[0]*A.x+T[2]*A.y+T[4],y:T[1]*A.x+T[3]*A.y+T[5]}}translate(A,T){return this.m[4]+=this.m[0]*A+this.m[2]*T,this.m[5]+=this.m[1]*A+this.m[3]*T,this}scale(A,T){return this.m[0]*=A,this.m[1]*=A,this.m[2]*=T,this.m[3]*=T,this}rotate(A){var T=Math.cos(A),w=Math.sin(A),P=this.m[0]*T+this.m[2]*w,O=this.m[1]*T+this.m[3]*w,k=this.m[0]*-w+this.m[2]*T,D=this.m[1]*-w+this.m[3]*T;return this.m[0]=P,this.m[1]=O,this.m[2]=k,this.m[3]=D,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(A,T){var w=this.m[0]+this.m[2]*T,P=this.m[1]+this.m[3]*T,O=this.m[2]+this.m[0]*A,k=this.m[3]+this.m[1]*A;return this.m[0]=w,this.m[1]=P,this.m[2]=O,this.m[3]=k,this}multiply(A){var T=this.m[0]*A.m[0]+this.m[2]*A.m[1],w=this.m[1]*A.m[0]+this.m[3]*A.m[1],P=this.m[0]*A.m[2]+this.m[2]*A.m[3],O=this.m[1]*A.m[2]+this.m[3]*A.m[3],k=this.m[0]*A.m[4]+this.m[2]*A.m[5]+this.m[4],D=this.m[1]*A.m[4]+this.m[3]*A.m[5]+this.m[5];return this.m[0]=T,this.m[1]=w,this.m[2]=P,this.m[3]=O,this.m[4]=k,this.m[5]=D,this}invert(){var A=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),T=this.m[3]*A,w=-this.m[1]*A,P=-this.m[2]*A,O=this.m[0]*A,k=A*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),D=A*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=T,this.m[1]=w,this.m[2]=P,this.m[3]=O,this.m[4]=k,this.m[5]=D,this}getMatrix(){return this.m}decompose(){var A=this.m[0],T=this.m[1],w=this.m[2],P=this.m[3],O=this.m[4],k=this.m[5],D=A*P-T*w;let F={x:O,y:k,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(A!=0||T!=0){var G=Math.sqrt(A*A+T*T);F.rotation=T>0?Math.acos(A/G):-Math.acos(A/G),F.scaleX=G,F.scaleY=D/G,F.skewX=(A*w+T*P)/D,F.skewY=0}else if(w!=0||P!=0){var V=Math.sqrt(w*w+P*P);F.rotation=Math.PI/2-(P>0?Math.acos(-w/V):-Math.acos(w/V)),F.scaleX=D/V,F.scaleY=V,F.skewX=0,F.skewY=(A*w+T*P)/D}return F.rotation=o.Util._getRotation(F.rotation),F}}o.Transform=r;var t="[object Array]",n="[object Number]",a="[object String]",u="[object Boolean]",l=Math.PI/180,f=180/Math.PI,c="#",h="",y="0",E="Konva warning: ",p="Konva error: ",_="rgb(",g={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},x=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,C=[];const R=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(S){setTimeout(S,60)};o.Util={_isElement(S){return!!(S&&S.nodeType==1)},_isFunction(S){return!!(S&&S.constructor&&S.call&&S.apply)},_isPlainObject(S){return!!S&&S.constructor===Object},_isArray(S){return Object.prototype.toString.call(S)===t},_isNumber(S){return Object.prototype.toString.call(S)===n&&!isNaN(S)&&isFinite(S)},_isString(S){return Object.prototype.toString.call(S)===a},_isBoolean(S){return Object.prototype.toString.call(S)===u},isObject(S){return S instanceof Object},isValidSelector(S){if(typeof S!="string")return!1;var A=S[0];return A==="#"||A==="."||A===A.toUpperCase()},_sign(S){return S===0||S>0?1:-1},requestAnimFrame(S){C.push(S),C.length===1&&R(function(){const A=C;C=[],A.forEach(function(T){T()})})},createCanvasElement(){var S=document.createElement("canvas");try{S.style=S.style||{}}catch{}return S},createImageElement(){return document.createElement("img")},_isInDocument(S){for(;S=S.parentNode;)if(S==document)return!0;return!1},_urlToImage(S,A){var T=o.Util.createImageElement();T.onload=function(){A(T)},T.src=S},_rgbToHex(S,A,T){return((1<<24)+(S<<16)+(A<<8)+T).toString(16).slice(1)},_hexToRgb(S){S=S.replace(c,h);var A=parseInt(S,16);return{r:A>>16&255,g:A>>8&255,b:A&255}},getRandomColor(){for(var S=(Math.random()*16777215<<0).toString(16);S.length<6;)S=y+S;return c+S},getRGB(S){var A;return S in g?(A=g[S],{r:A[0],g:A[1],b:A[2]}):S[0]===c?this._hexToRgb(S.substring(1)):S.substr(0,4)===_?(A=x.exec(S.replace(/ /g,"")),{r:parseInt(A[1],10),g:parseInt(A[2],10),b:parseInt(A[3],10)}):{r:0,g:0,b:0}},colorToRGBA(S){return S=S||"black",o.Util._namedColorToRBA(S)||o.Util._hex3ColorToRGBA(S)||o.Util._hex4ColorToRGBA(S)||o.Util._hex6ColorToRGBA(S)||o.Util._hex8ColorToRGBA(S)||o.Util._rgbColorToRGBA(S)||o.Util._rgbaColorToRGBA(S)||o.Util._hslColorToRGBA(S)},_namedColorToRBA(S){var A=g[S.toLowerCase()];return A?{r:A[0],g:A[1],b:A[2],a:1}:null},_rgbColorToRGBA(S){if(S.indexOf("rgb(")===0){S=S.match(/rgb\(([^)]+)\)/)[1];var A=S.split(/ *, */).map(Number);return{r:A[0],g:A[1],b:A[2],a:1}}},_rgbaColorToRGBA(S){if(S.indexOf("rgba(")===0){S=S.match(/rgba\(([^)]+)\)/)[1];var A=S.split(/ *, */).map((T,w)=>T.slice(-1)==="%"?w===3?parseInt(T)/100:parseInt(T)/100*255:Number(T));return{r:A[0],g:A[1],b:A[2],a:A[3]}}},_hex8ColorToRGBA(S){if(S[0]==="#"&&S.length===9)return{r:parseInt(S.slice(1,3),16),g:parseInt(S.slice(3,5),16),b:parseInt(S.slice(5,7),16),a:parseInt(S.slice(7,9),16)/255}},_hex6ColorToRGBA(S){if(S[0]==="#"&&S.length===7)return{r:parseInt(S.slice(1,3),16),g:parseInt(S.slice(3,5),16),b:parseInt(S.slice(5,7),16),a:1}},_hex4ColorToRGBA(S){if(S[0]==="#"&&S.length===5)return{r:parseInt(S[1]+S[1],16),g:parseInt(S[2]+S[2],16),b:parseInt(S[3]+S[3],16),a:parseInt(S[4]+S[4],16)/255}},_hex3ColorToRGBA(S){if(S[0]==="#"&&S.length===4)return{r:parseInt(S[1]+S[1],16),g:parseInt(S[2]+S[2],16),b:parseInt(S[3]+S[3],16),a:1}},_hslColorToRGBA(S){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(S)){const[A,...T]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(S),w=Number(T[0])/360,P=Number(T[1])/100,O=Number(T[2])/100;let k,D,F;if(P===0)return F=O*255,{r:Math.round(F),g:Math.round(F),b:Math.round(F),a:1};O<.5?k=O*(1+P):k=O+P-O*P;const G=2*O-k,V=[0,0,0];for(let W=0;W<3;W++)D=w+1/3*-(W-1),D<0&&D++,D>1&&D--,6*D<1?F=G+(k-G)*6*D:2*D<1?F=k:3*D<2?F=G+(k-G)*(2/3-D)*6:F=G,V[W]=F*255;return{r:Math.round(V[0]),g:Math.round(V[1]),b:Math.round(V[2]),a:1}}},haveIntersection(S,A){return!(A.x>S.x+S.width||A.x+A.width<S.x||A.y>S.y+S.height||A.y+A.height<S.y)},cloneObject(S){var A={};for(var T in S)this._isPlainObject(S[T])?A[T]=this.cloneObject(S[T]):this._isArray(S[T])?A[T]=this.cloneArray(S[T]):A[T]=S[T];return A},cloneArray(S){return S.slice(0)},degToRad(S){return S*l},radToDeg(S){return S*f},_degToRad(S){return o.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),o.Util.degToRad(S)},_radToDeg(S){return o.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),o.Util.radToDeg(S)},_getRotation(S){return e.Konva.angleDeg?o.Util.radToDeg(S):S},_capitalize(S){return S.charAt(0).toUpperCase()+S.slice(1)},throw(S){throw new Error(p+S)},error(S){console.error(p+S)},warn(S){e.Konva.showWarnings&&console.warn(E+S)},each(S,A){for(var T in S)A(T,S[T])},_inRange(S,A,T){return A<=S&&S<T},_getProjectionToSegment(S,A,T,w,P,O){var k,D,F,G=(S-T)*(S-T)+(A-w)*(A-w);if(G==0)k=S,D=A,F=(P-T)*(P-T)+(O-w)*(O-w);else{var V=((P-S)*(T-S)+(O-A)*(w-A))/G;V<0?(k=S,D=A,F=(S-P)*(S-P)+(A-O)*(A-O)):V>1?(k=T,D=w,F=(T-P)*(T-P)+(w-O)*(w-O)):(k=S+V*(T-S),D=A+V*(w-A),F=(k-P)*(k-P)+(D-O)*(D-O))}return[k,D,F]},_getProjectionToLine(S,A,T){var w=o.Util.cloneObject(S),P=Number.MAX_VALUE;return A.forEach(function(O,k){if(!(!T&&k===A.length-1)){var D=A[(k+1)%A.length],F=o.Util._getProjectionToSegment(O.x,O.y,D.x,D.y,S.x,S.y),G=F[0],V=F[1],W=F[2];W<P&&(w.x=G,w.y=V,P=W)}}),w},_prepareArrayForTween(S,A,T){var w,P=[],O=[];if(S.length>A.length){var k=A;A=S,S=k}for(w=0;w<S.length;w+=2)P.push({x:S[w],y:S[w+1]});for(w=0;w<A.length;w+=2)O.push({x:A[w],y:A[w+1]});var D=[];return O.forEach(function(F){var G=o.Util._getProjectionToLine(F,P,T);D.push(G.x),D.push(G.y)}),D},_prepareToStringify(S){var A;S.visitedByCircularReferenceRemoval=!0;for(var T in S)if(S.hasOwnProperty(T)&&S[T]&&typeof S[T]=="object"){if(A=Object.getOwnPropertyDescriptor(S,T),S[T].visitedByCircularReferenceRemoval||o.Util._isElement(S[T]))if(A.configurable)delete S[T];else return null;else if(o.Util._prepareToStringify(S[T])===null)if(A.configurable)delete S[T];else return null}return delete S.visitedByCircularReferenceRemoval,S},_assign(S,A){for(var T in A)S[T]=A[T];return S},_getFirstPointerId(S){return S.touches?S.changedTouches[0].identifier:S.pointerId||999},releaseCanvas(...S){e.Konva.releaseCanvasOnDestroy&&S.forEach(A=>{A.width=0,A.height=0})},drawRoundedRectPath(S,A,T,w){let P=0,O=0,k=0,D=0;typeof w=="number"?P=O=k=D=Math.min(w,A/2,T/2):(P=Math.min(w[0]||0,A/2,T/2),O=Math.min(w[1]||0,A/2,T/2),D=Math.min(w[2]||0,A/2,T/2),k=Math.min(w[3]||0,A/2,T/2)),S.moveTo(P,0),S.lineTo(A-O,0),S.arc(A-O,O,O,Math.PI*3/2,0,!1),S.lineTo(A,T-D),S.arc(A-D,T-D,D,0,Math.PI/2,!1),S.lineTo(k,T),S.arc(k,T-k,k,Math.PI/2,Math.PI,!1),S.lineTo(0,P),S.arc(P,P,P,Math.PI,Math.PI*3/2,!1)}}})(Util);var Node$1={},Factory={},Validators={};Object.defineProperty(Validators,"__esModule",{value:!0});Validators.getComponentValidator=Validators.getBooleanValidator=Validators.getNumberArrayValidator=Validators.getFunctionValidator=Validators.getStringOrGradientValidator=Validators.getStringValidator=Validators.getNumberOrAutoValidator=Validators.getNumberOrArrayOfNumbersValidator=Validators.getNumberValidator=Validators.alphaComponent=Validators.RGBComponent=void 0;const Global_1$p=Global,Util_1$f=Util;function _formatValue(o){return Util_1$f.Util._isString(o)?'"'+o+'"':Object.prototype.toString.call(o)==="[object Number]"||Util_1$f.Util._isBoolean(o)?o:Object.prototype.toString.call(o)}function RGBComponent(o){return o>255?255:o<0?0:Math.round(o)}Validators.RGBComponent=RGBComponent;function alphaComponent(o){return o>1?1:o<1e-4?1e-4:o}Validators.alphaComponent=alphaComponent;function getNumberValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){return Util_1$f.Util._isNumber(o)||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),o}}Validators.getNumberValidator=getNumberValidator;function getNumberOrArrayOfNumbersValidator(o){if(Global_1$p.Konva.isUnminified)return function(e,r){let t=Util_1$f.Util._isNumber(e),n=Util_1$f.Util._isArray(e)&&e.length==o;return!t&&!n&&Util_1$f.Util.warn(_formatValue(e)+' is a not valid value for "'+r+'" attribute. The value should be a number or Array<number>('+o+")"),e}}Validators.getNumberOrArrayOfNumbersValidator=getNumberOrArrayOfNumbersValidator;function getNumberOrAutoValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){var r=Util_1$f.Util._isNumber(o),t=o==="auto";return r||t||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),o}}Validators.getNumberOrAutoValidator=getNumberOrAutoValidator;function getStringValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){return Util_1$f.Util._isString(o)||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),o}}Validators.getStringValidator=getStringValidator;function getStringOrGradientValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){const r=Util_1$f.Util._isString(o),t=Object.prototype.toString.call(o)==="[object CanvasGradient]"||o&&o.addColorStop;return r||t||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),o}}Validators.getStringOrGradientValidator=getStringOrGradientValidator;function getFunctionValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){return Util_1$f.Util._isFunction(o)||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a function.'),o}}Validators.getFunctionValidator=getFunctionValidator;function getNumberArrayValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){const r=Int8Array?Object.getPrototypeOf(Int8Array):null;return r&&o instanceof r||(Util_1$f.Util._isArray(o)?o.forEach(function(t){Util_1$f.Util._isNumber(t)||Util_1$f.Util.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")}):Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),o}}Validators.getNumberArrayValidator=getNumberArrayValidator;function getBooleanValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){var r=o===!0||o===!1;return r||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),o}}Validators.getBooleanValidator=getBooleanValidator;function getComponentValidator(o){if(Global_1$p.Konva.isUnminified)return function(e,r){return e==null||Util_1$f.Util.isObject(e)||Util_1$f.Util.warn(_formatValue(e)+' is a not valid value for "'+r+'" attribute. The value should be an object with properties '+o),e}}Validators.getComponentValidator=getComponentValidator;(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Factory=void 0;const e=Util,r=Validators;var t="get",n="set";o.Factory={addGetterSetter(a,u,l,f,c){o.Factory.addGetter(a,u,l),o.Factory.addSetter(a,u,f,c),o.Factory.addOverloadedGetterSetter(a,u)},addGetter(a,u,l){var f=t+e.Util._capitalize(u);a.prototype[f]=a.prototype[f]||function(){var c=this.attrs[u];return c===void 0?l:c}},addSetter(a,u,l,f){var c=n+e.Util._capitalize(u);a.prototype[c]||o.Factory.overWriteSetter(a,u,l,f)},overWriteSetter(a,u,l,f){var c=n+e.Util._capitalize(u);a.prototype[c]=function(h){return l&&h!==void 0&&h!==null&&(h=l.call(this,h,u)),this._setAttr(u,h),f&&f.call(this),this}},addComponentsGetterSetter(a,u,l,f,c){var h=l.length,y=e.Util._capitalize,E=t+y(u),p=n+y(u),_,g;a.prototype[E]=function(){var C={};for(_=0;_<h;_++)g=l[_],C[g]=this.getAttr(u+y(g));return C};var x=(0,r.getComponentValidator)(l);a.prototype[p]=function(C){var R=this.attrs[u],S;f&&(C=f.call(this,C)),x&&x.call(this,C,u);for(S in C)C.hasOwnProperty(S)&&this._setAttr(u+y(S),C[S]);return C||l.forEach(A=>{this._setAttr(u+y(A),void 0)}),this._fireChangeEvent(u,R,C),c&&c.call(this),this},o.Factory.addOverloadedGetterSetter(a,u)},addOverloadedGetterSetter(a,u){var l=e.Util._capitalize(u),f=n+l,c=t+l;a.prototype[u]=function(){return arguments.length?(this[f](arguments[0]),this):this[c]()}},addDeprecatedGetterSetter(a,u,l,f){e.Util.error("Adding deprecated "+u);var c=t+e.Util._capitalize(u),h=u+" property is deprecated and will be removed soon. Look at Konva change log for more information.";a.prototype[c]=function(){e.Util.error(h);var y=this.attrs[u];return y===void 0?l:y},o.Factory.addSetter(a,u,f,function(){e.Util.error(h)}),o.Factory.addOverloadedGetterSetter(a,u)},backCompat(a,u){e.Util.each(u,function(l,f){var c=a.prototype[f],h=t+e.Util._capitalize(l),y=n+e.Util._capitalize(l);function E(){c.apply(this,arguments),e.Util.error('"'+l+'" method is deprecated and will be removed soon. Use ""'+f+'" instead.')}a.prototype[l]=E,a.prototype[h]=E,a.prototype[y]=E})},afterSetFilter(){this._filterUpToDate=!1}}})(Factory);var Canvas$1={},Context$2={};Object.defineProperty(Context$2,"__esModule",{value:!0});Context$2.HitContext=Context$2.SceneContext=Context$2.Context=void 0;const Util_1$e=Util,Global_1$o=Global;function simplifyArray(o){var e=[],r=o.length,t=Util_1$e.Util,n,a;for(n=0;n<r;n++)a=o[n],t._isNumber(a)?a=Math.round(a*1e3)/1e3:t._isString(a)||(a=a+""),e.push(a);return e}var COMMA=",",OPEN_PAREN="(",CLOSE_PAREN=")",OPEN_PAREN_BRACKET="([",CLOSE_BRACKET_PAREN="])",SEMICOLON=";",DOUBLE_PAREN="()",EQUALS="=",CONTEXT_METHODS=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"],CONTEXT_PROPERTIES=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"];const traceArrMax=100;let Context$1=class{constructor(e){this.canvas=e,Global_1$o.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,r){var t=this.traceArr,n=t.length,a="",u,l,f,c;for(u=0;u<n;u++)l=t[u],f=l.method,f?(c=l.args,a+=f,e?a+=DOUBLE_PAREN:Util_1$e.Util._isArray(c[0])?a+=OPEN_PAREN_BRACKET+c.join(COMMA)+CLOSE_BRACKET_PAREN:(r&&(c=c.map(h=>typeof h=="number"?Math.floor(h):h)),a+=OPEN_PAREN+c.join(COMMA)+CLOSE_PAREN)):(a+=l.property,e||(a+=EQUALS+l.val)),a+=SEMICOLON;return a}clearTrace(){this.traceArr=[]}_trace(e){var r=this.traceArr,t;r.push(e),t=r.length,t>=traceArrMax&&r.shift()}reset(){var e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){var r=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,r.getWidth()/r.pixelRatio,r.getHeight()/r.pixelRatio)}_applyLineCap(e){const r=e.attrs.lineCap;r&&this.setAttr("lineCap",r)}_applyOpacity(e){var r=e.getAbsoluteOpacity();r!==1&&this.setAttr("globalAlpha",r)}_applyLineJoin(e){const r=e.attrs.lineJoin;r&&this.setAttr("lineJoin",r)}setAttr(e,r){this._context[e]=r}arc(e,r,t,n,a,u){this._context.arc(e,r,t,n,a,u)}arcTo(e,r,t,n,a){this._context.arcTo(e,r,t,n,a)}beginPath(){this._context.beginPath()}bezierCurveTo(e,r,t,n,a,u){this._context.bezierCurveTo(e,r,t,n,a,u)}clearRect(e,r,t,n){this._context.clearRect(e,r,t,n)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,r){var t=arguments;if(t.length===2)return this._context.createImageData(e,r);if(t.length===1)return this._context.createImageData(e)}createLinearGradient(e,r,t,n){return this._context.createLinearGradient(e,r,t,n)}createPattern(e,r){return this._context.createPattern(e,r)}createRadialGradient(e,r,t,n,a,u){return this._context.createRadialGradient(e,r,t,n,a,u)}drawImage(e,r,t,n,a,u,l,f,c){var h=arguments,y=this._context;h.length===3?y.drawImage(e,r,t):h.length===5?y.drawImage(e,r,t,n,a):h.length===9&&y.drawImage(e,r,t,n,a,u,l,f,c)}ellipse(e,r,t,n,a,u,l,f){this._context.ellipse(e,r,t,n,a,u,l,f)}isPointInPath(e,r,t,n){return t?this._context.isPointInPath(t,e,r,n):this._context.isPointInPath(e,r,n)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,r,t,n){this._context.fillRect(e,r,t,n)}strokeRect(e,r,t,n){this._context.strokeRect(e,r,t,n)}fillText(e,r,t,n){n?this._context.fillText(e,r,t,n):this._context.fillText(e,r,t)}measureText(e){return this._context.measureText(e)}getImageData(e,r,t,n){return this._context.getImageData(e,r,t,n)}lineTo(e,r){this._context.lineTo(e,r)}moveTo(e,r){this._context.moveTo(e,r)}rect(e,r,t,n){this._context.rect(e,r,t,n)}putImageData(e,r,t){this._context.putImageData(e,r,t)}quadraticCurveTo(e,r,t,n){this._context.quadraticCurveTo(e,r,t,n)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,r){this._context.scale(e,r)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):"mozDash"in this._context?this._context.mozDash=e:"webkitLineDash"in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,r,t,n,a,u){this._context.setTransform(e,r,t,n,a,u)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,r,t,n){this._context.strokeText(e,r,t,n)}transform(e,r,t,n,a,u){this._context.transform(e,r,t,n,a,u)}translate(e,r){this._context.translate(e,r)}_enableTrace(){var e=this,r=CONTEXT_METHODS.length,t=this.setAttr,n,a,u=function(l){var f=e[l],c;e[l]=function(){return a=simplifyArray(Array.prototype.slice.call(arguments,0)),c=f.apply(e,arguments),e._trace({method:l,args:a}),c}};for(n=0;n<r;n++)u(CONTEXT_METHODS[n]);e.setAttr=function(){t.apply(e,arguments);var l=arguments[0],f=arguments[1];(l==="shadowOffsetX"||l==="shadowOffsetY"||l==="shadowBlur")&&(f=f/this.canvas.getPixelRatio()),e._trace({property:l,val:f})}}_applyGlobalCompositeOperation(e){const r=e.attrs.globalCompositeOperation;var t=!r||r==="source-over";t||this.setAttr("globalCompositeOperation",r)}};Context$2.Context=Context$1;CONTEXT_PROPERTIES.forEach(function(o){Object.defineProperty(Context$1.prototype,o,{get(){return this._context[o]},set(e){this._context[o]=e}})});class SceneContext extends Context$1{constructor(e,{willReadFrequently:r=!1}={}){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:r})}_fillColor(e){var r=e.fill();this.setAttr("fillStyle",r),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){var r=e._getLinearGradient();r&&(this.setAttr("fillStyle",r),e._fillFunc(this))}_fillRadialGradient(e){const r=e._getRadialGradient();r&&(this.setAttr("fillStyle",r),e._fillFunc(this))}_fill(e){const r=e.fill(),t=e.getFillPriority();if(r&&t==="color"){this._fillColor(e);return}const n=e.getFillPatternImage();if(n&&t==="pattern"){this._fillPattern(e);return}const a=e.getFillLinearGradientColorStops();if(a&&t==="linear-gradient"){this._fillLinearGradient(e);return}const u=e.getFillRadialGradientColorStops();if(u&&t==="radial-gradient"){this._fillRadialGradient(e);return}r?this._fillColor(e):n?this._fillPattern(e):a?this._fillLinearGradient(e):u&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const r=e.getStrokeLinearGradientStartPoint(),t=e.getStrokeLinearGradientEndPoint(),n=e.getStrokeLinearGradientColorStops(),a=this.createLinearGradient(r.x,r.y,t.x,t.y);if(n){for(var u=0;u<n.length;u+=2)a.addColorStop(n[u],n[u+1]);this.setAttr("strokeStyle",a)}}_stroke(e){var r=e.dash(),t=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!t){this.save();var n=this.getCanvas().getPixelRatio();this.setTransform(n,0,0,n,0,0)}this._applyLineCap(e),r&&e.dashEnabled()&&(this.setLineDash(r),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");var a=e.getStrokeLinearGradientColorStops();a?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),t||this.restore()}}_applyShadow(e){var r,t,n,a=(r=e.getShadowRGBA())!==null&&r!==void 0?r:"black",u=(t=e.getShadowBlur())!==null&&t!==void 0?t:5,l=(n=e.getShadowOffset())!==null&&n!==void 0?n:{x:0,y:0},f=e.getAbsoluteScale(),c=this.canvas.getPixelRatio(),h=f.x*c,y=f.y*c;this.setAttr("shadowColor",a),this.setAttr("shadowBlur",u*Math.min(Math.abs(h),Math.abs(y))),this.setAttr("shadowOffsetX",l.x*h),this.setAttr("shadowOffsetY",l.y*y)}}Context$2.SceneContext=SceneContext;class HitContext extends Context$1{constructor(e){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){const a=e.getStrokeScaleEnabled();if(!a){this.save();var r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(e);var t=e.hitStrokeWidth(),n=t==="auto"?e.strokeWidth():t;this.setAttr("lineWidth",n),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),a||this.restore()}}}Context$2.HitContext=HitContext;Object.defineProperty(Canvas$1,"__esModule",{value:!0});Canvas$1.HitCanvas=Canvas$1.SceneCanvas=Canvas$1.Canvas=void 0;const Util_1$d=Util,Context_1=Context$2,Global_1$n=Global,Factory_1$z=Factory,Validators_1$y=Validators;var _pixelRatio;function getDevicePixelRatio(){if(_pixelRatio)return _pixelRatio;var o=Util_1$d.Util.createCanvasElement(),e=o.getContext("2d");return _pixelRatio=function(){var r=Global_1$n.Konva._global.devicePixelRatio||1,t=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return r/t}(),Util_1$d.Util.releaseCanvas(o),_pixelRatio}class Canvas{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var r=e||{},t=r.pixelRatio||Global_1$n.Konva.pixelRatio||getDevicePixelRatio();this.pixelRatio=t,this._canvas=Util_1$d.Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){var r=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/r,this.getHeight()/r)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";var r=this.pixelRatio,t=this.getContext()._context;t.scale(r,r)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";var r=this.pixelRatio,t=this.getContext()._context;t.scale(r,r)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,r){this.setWidth(e||0),this.setHeight(r||0)}toDataURL(e,r){try{return this._canvas.toDataURL(e,r)}catch{try{return this._canvas.toDataURL()}catch(n){return Util_1$d.Util.error("Unable to get data URL. "+n.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}Canvas$1.Canvas=Canvas;Factory_1$z.Factory.addGetterSetter(Canvas,"pixelRatio",void 0,(0,Validators_1$y.getNumberValidator)());class SceneCanvas extends Canvas{constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this.context=new Context_1.SceneContext(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}}Canvas$1.SceneCanvas=SceneCanvas;class HitCanvas extends Canvas{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new Context_1.HitContext(this),this.setSize(e.width,e.height)}}Canvas$1.HitCanvas=HitCanvas;var DragAndDrop={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.DD=void 0;const e=Global,r=Util;o.DD={get isDragging(){var t=!1;return o.DD._dragElements.forEach(n=>{n.dragStatus==="dragging"&&(t=!0)}),t},justDragged:!1,get node(){var t;return o.DD._dragElements.forEach(n=>{t=n.node}),t},_dragElements:new Map,_drag(t){const n=[];o.DD._dragElements.forEach((a,u)=>{const{node:l}=a,f=l.getStage();f.setPointersPositions(t),a.pointerId===void 0&&(a.pointerId=r.Util._getFirstPointerId(t));const c=f._changedPointerPositions.find(E=>E.id===a.pointerId);if(c){if(a.dragStatus!=="dragging"){var h=l.dragDistance(),y=Math.max(Math.abs(c.x-a.startPointerPos.x),Math.abs(c.y-a.startPointerPos.y));if(y<h||(l.startDrag({evt:t}),!l.isDragging()))return}l._setDragPosition(t,a),n.push(l)}}),n.forEach(a=>{a.fire("dragmove",{type:"dragmove",target:a,evt:t},!0)})},_endDragBefore(t){const n=[];o.DD._dragElements.forEach(a=>{const{node:u}=a,l=u.getStage();if(t&&l.setPointersPositions(t),!l._changedPointerPositions.find(h=>h.id===a.pointerId))return;(a.dragStatus==="dragging"||a.dragStatus==="stopped")&&(o.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,a.dragStatus="stopped");const c=a.node.getLayer()||a.node instanceof e.Konva.Stage&&a.node;c&&n.indexOf(c)===-1&&n.push(c)}),n.forEach(a=>{a.draw()})},_endDragAfter(t){o.DD._dragElements.forEach((n,a)=>{n.dragStatus==="stopped"&&n.node.fire("dragend",{type:"dragend",target:n.node,evt:t},!0),n.dragStatus!=="dragging"&&o.DD._dragElements.delete(a)})}},e.Konva.isBrowser&&(window.addEventListener("mouseup",o.DD._endDragBefore,!0),window.addEventListener("touchend",o.DD._endDragBefore,!0),window.addEventListener("mousemove",o.DD._drag),window.addEventListener("touchmove",o.DD._drag),window.addEventListener("mouseup",o.DD._endDragAfter,!1),window.addEventListener("touchend",o.DD._endDragAfter,!1))})(DragAndDrop);Object.defineProperty(Node$1,"__esModule",{value:!0});Node$1.Node=void 0;const Util_1$c=Util,Factory_1$y=Factory,Canvas_1$1=Canvas$1,Global_1$m=Global,DragAndDrop_1=DragAndDrop,Validators_1$x=Validators;var ABSOLUTE_OPACITY="absoluteOpacity",ALL_LISTENERS="allEventListeners",ABSOLUTE_TRANSFORM="absoluteTransform",ABSOLUTE_SCALE="absoluteScale",CANVAS="canvas",CHANGE="Change",CHILDREN="children",KONVA="konva",LISTENING="listening",MOUSEENTER="mouseenter",MOUSELEAVE="mouseleave",SET="set",SHAPE="Shape",SPACE$1=" ",STAGE="stage",TRANSFORM="transform",UPPER_STAGE="Stage",VISIBLE="visible",TRANSFORM_CHANGE_STR$1=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(SPACE$1);let idCounter=1;class Node{constructor(e){this._id=idCounter++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(e),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(e){(e===TRANSFORM||e===ABSOLUTE_TRANSFORM)&&this._cache.get(e)?this._cache.get(e).dirty=!0:e?this._cache.delete(e):this._cache.clear()}_getCache(e,r){var t=this._cache.get(e),n=e===TRANSFORM||e===ABSOLUTE_TRANSFORM,a=t===void 0||n&&t.dirty===!0;return a&&(t=r.call(this),this._cache.set(e,t)),t}_calculate(e,r,t){if(!this._attachedDepsListeners.get(e)){const n=r.map(a=>a+"Change.konva").join(SPACE$1);this.on(n,()=>{this._clearCache(e)}),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,t)}_getCanvasCache(){return this._cache.get(CANVAS)}_clearSelfAndDescendantCache(e){this._clearCache(e),e===ABSOLUTE_TRANSFORM&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(CANVAS)){const{scene:e,filter:r,hit:t}=this._cache.get(CANVAS);Util_1$c.Util.releaseCanvas(e,r,t),this._cache.delete(CANVAS)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){var r=e||{},t={};(r.x===void 0||r.y===void 0||r.width===void 0||r.height===void 0)&&(t=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));var n=Math.ceil(r.width||t.width),a=Math.ceil(r.height||t.height),u=r.pixelRatio,l=r.x===void 0?Math.floor(t.x):r.x,f=r.y===void 0?Math.floor(t.y):r.y,c=r.offset||0,h=r.drawBorder||!1,y=r.hitCanvasPixelRatio||1;if(!n||!a){Util_1$c.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}n+=c*2+1,a+=c*2+1,l-=c,f-=c;var E=new Canvas_1$1.SceneCanvas({pixelRatio:u,width:n,height:a}),p=new Canvas_1$1.SceneCanvas({pixelRatio:u,width:0,height:0,willReadFrequently:!0}),_=new Canvas_1$1.HitCanvas({pixelRatio:y,width:n,height:a}),g=E.getContext(),x=_.getContext();return _.isCache=!0,E.isCache=!0,this._cache.delete(CANVAS),this._filterUpToDate=!1,r.imageSmoothingEnabled===!1&&(E.getContext()._context.imageSmoothingEnabled=!1,p.getContext()._context.imageSmoothingEnabled=!1),g.save(),x.save(),g.translate(-l,-f),x.translate(-l,-f),this._isUnderCache=!0,this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY),this._clearSelfAndDescendantCache(ABSOLUTE_SCALE),this.drawScene(E,this),this.drawHit(_,this),this._isUnderCache=!1,g.restore(),x.restore(),h&&(g.save(),g.beginPath(),g.rect(0,0,n,a),g.closePath(),g.setAttr("strokeStyle","red"),g.setAttr("lineWidth",5),g.stroke(),g.restore()),this._cache.set(CANVAS,{scene:E,filter:p,hit:_,x:l,y:f}),this._requestDraw(),this}isCached(){return this._cache.has(CANVAS)}getClientRect(e){throw new Error('abstract "getClientRect" method call')}_transformedRect(e,r){var t=[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],n=1/0,a=1/0,u=-1/0,l=-1/0,f=this.getAbsoluteTransform(r);return t.forEach(function(c){var h=f.point(c);n===void 0&&(n=u=h.x,a=l=h.y),n=Math.min(n,h.x),a=Math.min(a,h.y),u=Math.max(u,h.x),l=Math.max(l,h.y)}),{x:n,y:a,width:u-n,height:l-a}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);const r=this._getCanvasCache();e.translate(r.x,r.y);var t=this._getCachedSceneCanvas(),n=t.pixelRatio;e.drawImage(t._canvas,0,0,t.width/n,t.height/n),e.restore()}_drawCachedHitCanvas(e){var r=this._getCanvasCache(),t=r.hit;e.save(),e.translate(r.x,r.y),e.drawImage(t._canvas,0,0,t.width/t.pixelRatio,t.height/t.pixelRatio),e.restore()}_getCachedSceneCanvas(){var e=this.filters(),r=this._getCanvasCache(),t=r.scene,n=r.filter,a=n.getContext(),u,l,f,c;if(e){if(!this._filterUpToDate){var h=t.pixelRatio;n.setSize(t.width/t.pixelRatio,t.height/t.pixelRatio);try{for(u=e.length,a.clear(),a.drawImage(t._canvas,0,0,t.getWidth()/h,t.getHeight()/h),l=a.getImageData(0,0,n.getWidth(),n.getHeight()),f=0;f<u;f++){if(c=e[f],typeof c!="function"){Util_1$c.Util.error("Filter should be type of function, but got "+typeof c+" instead. Please check correct filters");continue}c.call(this,l),a.putImageData(l,0,0)}}catch(y){Util_1$c.Util.error("Unable to apply filter. "+y.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return n}return t}on(e,r){if(this._cache&&this._cache.delete(ALL_LISTENERS),arguments.length===3)return this._delegate.apply(this,arguments);var t=e.split(SPACE$1),n=t.length,a,u,l,f,c;for(a=0;a<n;a++)u=t[a],l=u.split("."),f=l[0],c=l[1]||"",this.eventListeners[f]||(this.eventListeners[f]=[]),this.eventListeners[f].push({name:c,handler:r});return this}off(e,r){var t=(e||"").split(SPACE$1),n=t.length,a,u,l,f,c,h;if(this._cache&&this._cache.delete(ALL_LISTENERS),!e)for(u in this.eventListeners)this._off(u);for(a=0;a<n;a++)if(l=t[a],f=l.split("."),c=f[0],h=f[1],c)this.eventListeners[c]&&this._off(c,h,r);else for(u in this.eventListeners)this._off(u,h,r);return this}dispatchEvent(e){var r={target:this,type:e.type,evt:e};return this.fire(e.type,r),this}addEventListener(e,r){return this.on(e,function(t){r.call(this,t.evt)}),this}removeEventListener(e){return this.off(e),this}_delegate(e,r,t){var n=this;this.on(e,function(a){for(var u=a.target.findAncestors(r,!0,n),l=0;l<u.length;l++)a=Util_1$c.Util.cloneObject(a),a.currentTarget=u[l],t.call(u[l],a)})}remove(){return this.isDragging()&&this.stopDrag(),DragAndDrop_1.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY),this._clearSelfAndDescendantCache(ABSOLUTE_SCALE),this._clearSelfAndDescendantCache(STAGE),this._clearSelfAndDescendantCache(VISIBLE),this._clearSelfAndDescendantCache(LISTENING)}_remove(){this._clearCaches();var e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){var r="get"+Util_1$c.Util._capitalize(e);return Util_1$c.Util._isFunction(this[r])?this[r]():this.attrs[e]}getAncestors(){for(var e=this.getParent(),r=[];e;)r.push(e),e=e.getParent();return r}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{var r,t;if(!e)return this;for(r in e)r!==CHILDREN&&(t=SET+Util_1$c.Util._capitalize(r),Util_1$c.Util._isFunction(this[t])?this[t](e[r]):this._setAttr(r,e[r]))}),this}isListening(){return this._getCache(LISTENING,this._isListening)}_isListening(e){if(!this.listening())return!1;const t=this.getParent();return t&&t!==e&&this!==e?t._isListening(e):!0}isVisible(){return this._getCache(VISIBLE,this._isVisible)}_isVisible(e){if(!this.visible())return!1;const t=this.getParent();return t&&t!==e&&this!==e?t._isVisible(e):!0}shouldDrawHit(e,r=!1){if(e)return this._isVisible(e)&&this._isListening(e);var t=this.getLayer(),n=!1;DragAndDrop_1.DD._dragElements.forEach(u=>{u.dragStatus==="dragging"&&(u.node.nodeType==="Stage"||u.node.getLayer()===t)&&(n=!0)});var a=!r&&!Global_1$m.Konva.hitOnDragEnabled&&n;return this.isListening()&&this.isVisible()&&!a}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){var e=this.getDepth(),r=this,t=0,n,a,u,l;function f(h){for(n=[],a=h.length,u=0;u<a;u++)l=h[u],t++,l.nodeType!==SHAPE&&(n=n.concat(l.getChildren().slice())),l._id===r._id&&(u=a);n.length>0&&n[0].getDepth()<=e&&f(n)}const c=this.getStage();return r.nodeType!==UPPER_STAGE&&c&&f(c.getChildren()),t}getDepth(){for(var e=0,r=this.parent;r;)e++,r=r.parent;return e}_batchTransformChanges(e){this._batchingTransformChange=!0,e(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM)),this._needClearTransformCache=!1}setPosition(e){return this._batchTransformChanges(()=>{this.x(e.x),this.y(e.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const e=this.getStage();if(!e)return null;var r=e.getPointerPosition();if(!r)return null;var t=this.getAbsoluteTransform().copy();return t.invert(),t.point(r)}getAbsolutePosition(e){let r=!1,t=this.parent;for(;t;){if(t.isCached()){r=!0;break}t=t.parent}r&&!e&&(e=!0);var n=this.getAbsoluteTransform(e).getMatrix(),a=new Util_1$c.Transform,u=this.offset();return a.m=n.slice(),a.translate(u.x,u.y),a.getTranslation()}setAbsolutePosition(e){const{x:r,y:t,...n}=this._clearTransform();this.attrs.x=r,this.attrs.y=t,this._clearCache(TRANSFORM);var a=this._getAbsoluteTransform().copy();return a.invert(),a.translate(e.x,e.y),e={x:this.attrs.x+a.getTranslation().x,y:this.attrs.y+a.getTranslation().y},this._setTransform(n),this.setPosition({x:e.x,y:e.y}),this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM),this}_setTransform(e){var r;for(r in e)this.attrs[r]=e[r]}_clearTransform(){var e={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,e}move(e){var r=e.x,t=e.y,n=this.x(),a=this.y();return r!==void 0&&(n+=r),t!==void 0&&(a+=t),this.setPosition({x:n,y:a}),this}_eachAncestorReverse(e,r){var t=[],n=this.getParent(),a,u;if(!(r&&r._id===this._id)){for(t.unshift(this);n&&(!r||n._id!==r._id);)t.unshift(n),n=n.parent;for(a=t.length,u=0;u<a;u++)e(t[u])}}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return Util_1$c.Util.warn("Node has no parent. moveToTop function is ignored."),!1;var e=this.index,r=this.parent.getChildren().length;return e<r-1?(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0):!1}moveUp(){if(!this.parent)return Util_1$c.Util.warn("Node has no parent. moveUp function is ignored."),!1;var e=this.index,r=this.parent.getChildren().length;return e<r-1?(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0):!1}moveDown(){if(!this.parent)return Util_1$c.Util.warn("Node has no parent. moveDown function is ignored."),!1;var e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0):!1}moveToBottom(){if(!this.parent)return Util_1$c.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;var e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1}setZIndex(e){if(!this.parent)return Util_1$c.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&Util_1$c.Util.warn("Unexpected value "+e+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");var r=this.index;return this.parent.children.splice(r,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(ABSOLUTE_OPACITY,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){var e=this.opacity(),r=this.getParent();return r&&!r._isUnderCache&&(e*=r.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){var e={},r=this.getAttrs(),t,n,a,u,l;e.attrs={};for(t in r)n=r[t],l=Util_1$c.Util.isObject(n)&&!Util_1$c.Util._isPlainObject(n)&&!Util_1$c.Util._isArray(n),!l&&(a=typeof this[t]=="function"&&this[t],delete r[t],u=a?a.call(this):null,r[t]=n,u!==n&&(e.attrs[t]=n));return e.className=this.getClassName(),Util_1$c.Util._prepareToStringify(e)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,r,t){var n=[];r&&this._isMatch(e)&&n.push(this);for(var a=this.parent;a;){if(a===t)return n;a._isMatch(e)&&n.push(a),a=a.parent}return n}isAncestorOf(e){return!1}findAncestor(e,r,t){return this.findAncestors(e,r,t)[0]}_isMatch(e){if(!e)return!1;if(typeof e=="function")return e(this);var r=e.replace(/ /g,"").split(","),t=r.length,n,a;for(n=0;n<t;n++)if(a=r[n],Util_1$c.Util.isValidSelector(a)||(Util_1$c.Util.warn('Selector "'+a+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),Util_1$c.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),Util_1$c.Util.warn("Konva is awesome, right?")),a.charAt(0)==="#"){if(this.id()===a.slice(1))return!0}else if(a.charAt(0)==="."){if(this.hasName(a.slice(1)))return!0}else if(this.className===a||this.nodeType===a)return!0;return!1}getLayer(){var e=this.getParent();return e?e.getLayer():null}getStage(){return this._getCache(STAGE,this._getStage)}_getStage(){var e=this.getParent();return e?e.getStage():null}fire(e,r={},t){return r.target=r.target||this,t?this._fireAndBubble(e,r):this._fire(e,r),this}getAbsoluteTransform(e){return e?this._getAbsoluteTransform(e):this._getCache(ABSOLUTE_TRANSFORM,this._getAbsoluteTransform)}_getAbsoluteTransform(e){var r;if(e)return r=new Util_1$c.Transform,this._eachAncestorReverse(function(n){var a=n.transformsEnabled();a==="all"?r.multiply(n.getTransform()):a==="position"&&r.translate(n.x()-n.offsetX(),n.y()-n.offsetY())},e),r;r=this._cache.get(ABSOLUTE_TRANSFORM)||new Util_1$c.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(r):r.reset();var t=this.transformsEnabled();if(t==="all")r.multiply(this.getTransform());else if(t==="position"){const n=this.attrs.x||0,a=this.attrs.y||0,u=this.attrs.offsetX||0,l=this.attrs.offsetY||0;r.translate(n-u,a-l)}return r.dirty=!1,r}getAbsoluteScale(e){for(var r=this;r;)r._isUnderCache&&(e=r),r=r.getParent();const n=this.getAbsoluteTransform(e).decompose();return{x:n.scaleX,y:n.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(TRANSFORM,this._getTransform)}_getTransform(){var e,r,t=this._cache.get(TRANSFORM)||new Util_1$c.Transform;t.reset();var n=this.x(),a=this.y(),u=Global_1$m.Konva.getAngle(this.rotation()),l=(e=this.attrs.scaleX)!==null&&e!==void 0?e:1,f=(r=this.attrs.scaleY)!==null&&r!==void 0?r:1,c=this.attrs.skewX||0,h=this.attrs.skewY||0,y=this.attrs.offsetX||0,E=this.attrs.offsetY||0;return(n!==0||a!==0)&&t.translate(n,a),u!==0&&t.rotate(u),(c!==0||h!==0)&&t.skew(c,h),(l!==1||f!==1)&&t.scale(l,f),(y!==0||E!==0)&&t.translate(-1*y,-1*E),t.dirty=!1,t}clone(e){var r=Util_1$c.Util.cloneObject(this.attrs),t,n,a,u,l;for(t in e)r[t]=e[t];var f=new this.constructor(r);for(t in this.eventListeners)for(n=this.eventListeners[t],a=n.length,u=0;u<a;u++)l=n[u],l.name.indexOf(KONVA)<0&&(f.eventListeners[t]||(f.eventListeners[t]=[]),f.eventListeners[t].push(l));return f}_toKonvaCanvas(e){e=e||{};var r=this.getClientRect(),t=this.getStage(),n=e.x!==void 0?e.x:Math.floor(r.x),a=e.y!==void 0?e.y:Math.floor(r.y),u=e.pixelRatio||1,l=new Canvas_1$1.SceneCanvas({width:e.width||Math.ceil(r.width)||(t?t.width():0),height:e.height||Math.ceil(r.height)||(t?t.height():0),pixelRatio:u}),f=l.getContext();return e.imageSmoothingEnabled===!1&&(f._context.imageSmoothingEnabled=!1),f.save(),(n||a)&&f.translate(-1*n,-1*a),this.drawScene(l),f.restore(),l}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){e=e||{};var r=e.mimeType||null,t=e.quality||null,n=this._toKonvaCanvas(e).toDataURL(r,t);return e.callback&&e.callback(n),n}toImage(e){return new Promise((r,t)=>{try{const n=e==null?void 0:e.callback;n&&delete e.callback,Util_1$c.Util._urlToImage(this.toDataURL(e),function(a){r(a),n==null||n(a)})}catch(n){t(n)}})}toBlob(e){return new Promise((r,t)=>{try{const n=e==null?void 0:e.callback;n&&delete e.callback,this.toCanvas(e).toBlob(a=>{r(a),n==null||n(a)},e==null?void 0:e.mimeType,e==null?void 0:e.quality)}catch(n){t(n)}})}setSize(e){return this.width(e.width),this.height(e.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance!==void 0?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Global_1$m.Konva.dragDistance}_off(e,r,t){var n=this.eventListeners[e],a,u,l;for(a=0;a<n.length;a++)if(u=n[a].name,l=n[a].handler,(u!=="konva"||r==="konva")&&(!r||u===r)&&(!t||t===l)){if(n.splice(a,1),n.length===0){delete this.eventListeners[e];break}a--}}_fireChangeEvent(e,r,t){this._fire(e+CHANGE,{oldVal:r,newVal:t})}addName(e){if(!this.hasName(e)){var r=this.name(),t=r?r+" "+e:e;this.name(t)}return this}hasName(e){if(!e)return!1;const r=this.name();if(!r)return!1;var t=(r||"").split(/\s/g);return t.indexOf(e)!==-1}removeName(e){var r=(this.name()||"").split(/\s/g),t=r.indexOf(e);return t!==-1&&(r.splice(t,1),this.name(r.join(" "))),this}setAttr(e,r){var t=this[SET+Util_1$c.Util._capitalize(e)];return Util_1$c.Util._isFunction(t)?t.call(this,r):this._setAttr(e,r),this}_requestDraw(){if(Global_1$m.Konva.autoDrawEnabled){const e=this.getLayer()||this.getStage();e==null||e.batchDraw()}}_setAttr(e,r){var t=this.attrs[e];t===r&&!Util_1$c.Util.isObject(r)||(r==null?delete this.attrs[e]:this.attrs[e]=r,this._shouldFireChangeEvents&&this._fireChangeEvent(e,t,r),this._requestDraw())}_setComponentAttr(e,r,t){var n;t!==void 0&&(n=this.attrs[e],n||(this.attrs[e]=this.getAttr(e)),this.attrs[e][r]=t,this._fireChangeEvent(e,n,t))}_fireAndBubble(e,r,t){r&&this.nodeType===SHAPE&&(r.target=this);var n=(e===MOUSEENTER||e===MOUSELEAVE)&&(t&&(this===t||this.isAncestorOf&&this.isAncestorOf(t))||this.nodeType==="Stage"&&!t);if(!n){this._fire(e,r);var a=(e===MOUSEENTER||e===MOUSELEAVE)&&t&&t.isAncestorOf&&t.isAncestorOf(this)&&!t.isAncestorOf(this.parent);(r&&!r.cancelBubble||!r)&&this.parent&&this.parent.isListening()&&!a&&(t&&t.parent?this._fireAndBubble.call(this.parent,e,r,t):this._fireAndBubble.call(this.parent,e,r))}}_getProtoListeners(e){var r,t,n;const a=(r=this._cache.get(ALL_LISTENERS))!==null&&r!==void 0?r:{};let u=a==null?void 0:a[e];if(u===void 0){u=[];let l=Object.getPrototypeOf(this);for(;l;){const f=(n=(t=l.eventListeners)===null||t===void 0?void 0:t[e])!==null&&n!==void 0?n:[];u.push(...f),l=Object.getPrototypeOf(l)}a[e]=u,this._cache.set(ALL_LISTENERS,a)}return u}_fire(e,r){r=r||{},r.currentTarget=this,r.type=e;const t=this._getProtoListeners(e);if(t)for(var n=0;n<t.length;n++)t[n].handler.call(this,r);const a=this.eventListeners[e];if(a)for(var n=0;n<a.length;n++)a[n].handler.call(this,r)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){var r=e?e.pointerId:void 0,t=this.getStage(),n=this.getAbsolutePosition();if(t){var a=t._getPointerById(r)||t._changedPointerPositions[0]||n;DragAndDrop_1.DD._dragElements.set(this._id,{node:this,startPointerPos:a,offset:{x:a.x-n.x,y:a.y-n.y},dragStatus:"ready",pointerId:r})}}startDrag(e,r=!0){DragAndDrop_1.DD._dragElements.has(this._id)||this._createDragElement(e);const t=DragAndDrop_1.DD._dragElements.get(this._id);t.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:e&&e.evt},r)}_setDragPosition(e,r){const t=this.getStage()._getPointerById(r.pointerId);if(t){var n={x:t.x-r.offset.x,y:t.y-r.offset.y},a=this.dragBoundFunc();if(a!==void 0){const u=a.call(this,n,e);u?n=u:Util_1$c.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}(!this._lastPos||this._lastPos.x!==n.x||this._lastPos.y!==n.y)&&(this.setAbsolutePosition(n),this._requestDraw()),this._lastPos=n}}stopDrag(e){const r=DragAndDrop_1.DD._dragElements.get(this._id);r&&(r.dragStatus="stopped"),DragAndDrop_1.DD._endDragBefore(e),DragAndDrop_1.DD._endDragAfter(e)}setDraggable(e){this._setAttr("draggable",e),this._dragChange()}isDragging(){const e=DragAndDrop_1.DD._dragElements.get(this._id);return e?e.dragStatus==="dragging":!1}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(e){var r=e.evt.button!==void 0,t=!r||Global_1$m.Konva.dragButtons.indexOf(e.evt.button)>=0;if(t&&!this.isDragging()){var n=!1;DragAndDrop_1.DD._dragElements.forEach(a=>{this.isAncestorOf(a.node)&&(n=!0)}),n||this._createDragElement(e)}})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();var e=this.getStage();if(!e)return;const r=DragAndDrop_1.DD._dragElements.get(this._id),t=r&&r.dragStatus==="dragging",n=r&&r.dragStatus==="ready";t?this.stopDrag():n&&DragAndDrop_1.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const r=this.getStage();if(!r)return!1;const t={x:-e.x,y:-e.y,width:r.width()+2*e.x,height:r.height()+2*e.y};return Util_1$c.Util.haveIntersection(t,this.getClientRect())}static create(e,r){return Util_1$c.Util._isString(e)&&(e=JSON.parse(e)),this._createNode(e,r)}static _createNode(e,r){var t=Node.prototype.getClassName.call(e),n=e.children,a,u,l;r&&(e.attrs.container=r),Global_1$m.Konva[t]||(Util_1$c.Util.warn('Can not find a node with class name "'+t+'". Fallback to "Shape".'),t="Shape");const f=Global_1$m.Konva[t];if(a=new f(e.attrs),n)for(u=n.length,l=0;l<u;l++)a.add(Node._createNode(n[l]));return a}}Node$1.Node=Node;Node.prototype.nodeType="Node";Node.prototype._attrsAffectingSize=[];Node.prototype.eventListeners={};Node.prototype.on.call(Node.prototype,TRANSFORM_CHANGE_STR$1,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM)});Node.prototype.on.call(Node.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(VISIBLE)});Node.prototype.on.call(Node.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(LISTENING)});Node.prototype.on.call(Node.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY)});const addGetterSetter=Factory_1$y.Factory.addGetterSetter;addGetterSetter(Node,"zIndex");addGetterSetter(Node,"absolutePosition");addGetterSetter(Node,"position");addGetterSetter(Node,"x",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"y",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"globalCompositeOperation","source-over",(0,Validators_1$x.getStringValidator)());addGetterSetter(Node,"opacity",1,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"name","",(0,Validators_1$x.getStringValidator)());addGetterSetter(Node,"id","",(0,Validators_1$x.getStringValidator)());addGetterSetter(Node,"rotation",0,(0,Validators_1$x.getNumberValidator)());Factory_1$y.Factory.addComponentsGetterSetter(Node,"scale",["x","y"]);addGetterSetter(Node,"scaleX",1,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"scaleY",1,(0,Validators_1$x.getNumberValidator)());Factory_1$y.Factory.addComponentsGetterSetter(Node,"skew",["x","y"]);addGetterSetter(Node,"skewX",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"skewY",0,(0,Validators_1$x.getNumberValidator)());Factory_1$y.Factory.addComponentsGetterSetter(Node,"offset",["x","y"]);addGetterSetter(Node,"offsetX",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"offsetY",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"dragDistance",null,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"width",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"height",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"listening",!0,(0,Validators_1$x.getBooleanValidator)());addGetterSetter(Node,"preventDefault",!0,(0,Validators_1$x.getBooleanValidator)());addGetterSetter(Node,"filters",null,function(o){return this._filterUpToDate=!1,o});addGetterSetter(Node,"visible",!0,(0,Validators_1$x.getBooleanValidator)());addGetterSetter(Node,"transformsEnabled","all",(0,Validators_1$x.getStringValidator)());addGetterSetter(Node,"size");addGetterSetter(Node,"dragBoundFunc");addGetterSetter(Node,"draggable",!1,(0,Validators_1$x.getBooleanValidator)());Factory_1$y.Factory.backCompat(Node,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var Container$2={};Object.defineProperty(Container$2,"__esModule",{value:!0});Container$2.Container=void 0;const Factory_1$x=Factory,Node_1$h=Node$1,Validators_1$w=Validators;let Container$1=class extends Node_1$h.Node{constructor(){super(...arguments),this.children=[]}getChildren(e){if(!e)return this.children||[];const r=this.children||[];var t=[];return r.forEach(function(n){e(n)&&t.push(n)}),t}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._requestDraw(),this}add(...e){if(e.length===0)return this;if(e.length>1){for(var r=0;r<e.length;r++)this.add(e[r]);return this}const t=e[0];return t.getParent()?(t.moveTo(this),this):(this._validateAdd(t),t.index=this.getChildren().length,t.parent=this,t._clearCaches(),this.getChildren().push(t),this._fire("add",{child:t}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){var r=this._generalFind(e,!0);return r.length>0?r[0]:void 0}_generalFind(e,r){var t=[];return this._descendants(n=>{const a=n._isMatch(e);return a&&t.push(n),!!(a&&r)}),t}_descendants(e){let r=!1;const t=this.getChildren();for(const n of t){if(r=e(n),r)return!0;if(n.hasChildren()&&(r=n._descendants(e),r))return!0}return!1}toObject(){var e=Node_1$h.Node.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(r=>{e.children.push(r.toObject())}),e}isAncestorOf(e){for(var r=e.getParent();r;){if(r._id===this._id)return!0;r=r.getParent()}return!1}clone(e){var r=Node_1$h.Node.prototype.clone.call(this,e);return this.getChildren().forEach(function(t){r.add(t.clone())}),r}getAllIntersections(e){var r=[];return this.find("Shape").forEach(t=>{t.isVisible()&&t.intersects(e)&&r.push(t)}),r}_clearSelfAndDescendantCache(e){var r;super._clearSelfAndDescendantCache(e),!this.isCached()&&((r=this.children)===null||r===void 0||r.forEach(function(t){t._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(r,t){r.index=t}),this._requestDraw()}drawScene(e,r){var t=this.getLayer(),n=e||t&&t.getCanvas(),a=n&&n.getContext(),u=this._getCanvasCache(),l=u&&u.scene,f=n&&n.isCache;if(!this.isVisible()&&!f)return this;if(l){a.save();var c=this.getAbsoluteTransform(r).getMatrix();a.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedSceneCanvas(a),a.restore()}else this._drawChildren("drawScene",n,r);return this}drawHit(e,r){if(!this.shouldDrawHit(r))return this;var t=this.getLayer(),n=e||t&&t.hitCanvas,a=n&&n.getContext(),u=this._getCanvasCache(),l=u&&u.hit;if(l){a.save();var f=this.getAbsoluteTransform(r).getMatrix();a.transform(f[0],f[1],f[2],f[3],f[4],f[5]),this._drawCachedHitCanvas(a),a.restore()}else this._drawChildren("drawHit",n,r);return this}_drawChildren(e,r,t){var n,a=r&&r.getContext(),u=this.clipWidth(),l=this.clipHeight(),f=this.clipFunc(),c=u&&l||f;const h=t===this;if(c){a.save();var y=this.getAbsoluteTransform(t),E=y.getMatrix();a.transform(E[0],E[1],E[2],E[3],E[4],E[5]),a.beginPath();let x;if(f)x=f.call(this,a,this);else{var p=this.clipX(),_=this.clipY();a.rect(p,_,u,l)}a.clip.apply(a,x),E=y.copy().invert().getMatrix(),a.transform(E[0],E[1],E[2],E[3],E[4],E[5])}var g=!h&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";g&&(a.save(),a._applyGlobalCompositeOperation(this)),(n=this.children)===null||n===void 0||n.forEach(function(x){x[e](r,t)}),g&&a.restore(),c&&a.restore()}getClientRect(e={}){var r,t=e.skipTransform,n=e.relativeTo,a,u,l,f,c={x:1/0,y:1/0,width:0,height:0},h=this;(r=this.children)===null||r===void 0||r.forEach(function(g){if(g.visible()){var x=g.getClientRect({relativeTo:h,skipShadow:e.skipShadow,skipStroke:e.skipStroke});x.width===0&&x.height===0||(a===void 0?(a=x.x,u=x.y,l=x.x+x.width,f=x.y+x.height):(a=Math.min(a,x.x),u=Math.min(u,x.y),l=Math.max(l,x.x+x.width),f=Math.max(f,x.y+x.height)))}});for(var y=this.find("Shape"),E=!1,p=0;p<y.length;p++){var _=y[p];if(_._isVisible(this)){E=!0;break}}return E&&a!==void 0?c={x:a,y:u,width:l-a,height:f-u}:c={x:0,y:0,width:0,height:0},t?c:this._transformedRect(c,n)}};Container$2.Container=Container$1;Factory_1$x.Factory.addComponentsGetterSetter(Container$1,"clip",["x","y","width","height"]);Factory_1$x.Factory.addGetterSetter(Container$1,"clipX",void 0,(0,Validators_1$w.getNumberValidator)());Factory_1$x.Factory.addGetterSetter(Container$1,"clipY",void 0,(0,Validators_1$w.getNumberValidator)());Factory_1$x.Factory.addGetterSetter(Container$1,"clipWidth",void 0,(0,Validators_1$w.getNumberValidator)());Factory_1$x.Factory.addGetterSetter(Container$1,"clipHeight",void 0,(0,Validators_1$w.getNumberValidator)());Factory_1$x.Factory.addGetterSetter(Container$1,"clipFunc");var Stage$1={},PointerEvents={};Object.defineProperty(PointerEvents,"__esModule",{value:!0});PointerEvents.releaseCapture=PointerEvents.setPointerCapture=PointerEvents.hasPointerCapture=PointerEvents.createEvent=PointerEvents.getCapturedShape=void 0;const Global_1$l=Global,Captures=new Map,SUPPORT_POINTER_EVENTS=Global_1$l.Konva._global.PointerEvent!==void 0;function getCapturedShape(o){return Captures.get(o)}PointerEvents.getCapturedShape=getCapturedShape;function createEvent(o){return{evt:o,pointerId:o.pointerId}}PointerEvents.createEvent=createEvent;function hasPointerCapture(o,e){return Captures.get(o)===e}PointerEvents.hasPointerCapture=hasPointerCapture;function setPointerCapture(o,e){releaseCapture(o),e.getStage()&&(Captures.set(o,e),SUPPORT_POINTER_EVENTS&&e._fire("gotpointercapture",createEvent(new PointerEvent("gotpointercapture"))))}PointerEvents.setPointerCapture=setPointerCapture;function releaseCapture(o,e){const r=Captures.get(o);if(!r)return;const t=r.getStage();t&&t.content,Captures.delete(o),SUPPORT_POINTER_EVENTS&&r._fire("lostpointercapture",createEvent(new PointerEvent("lostpointercapture")))}PointerEvents.releaseCapture=releaseCapture;(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Stage=o.stages=void 0;const e=Util,r=Factory,t=Container$2,n=Global,a=Canvas$1,u=DragAndDrop,l=Global,f=PointerEvents;var c="Stage",h="string",y="px",E="mouseout",p="mouseleave",_="mouseover",g="mouseenter",x="mousemove",C="mousedown",R="mouseup",S="pointermove",A="pointerdown",T="pointerup",w="pointercancel",P="lostpointercapture",O="pointerout",k="pointerleave",D="pointerover",F="pointerenter",G="contextmenu",V="touchstart",W="touchend",Z="touchmove",q="touchcancel",z="wheel",U=5,I=[[g,"_pointerenter"],[C,"_pointerdown"],[x,"_pointermove"],[R,"_pointerup"],[p,"_pointerleave"],[V,"_pointerdown"],[Z,"_pointermove"],[W,"_pointerup"],[q,"_pointercancel"],[_,"_pointerover"],[z,"_wheel"],[G,"_contextmenu"],[A,"_pointerdown"],[S,"_pointermove"],[T,"_pointerup"],[w,"_pointercancel"],[P,"_lostpointercapture"]];const $={mouse:{[O]:E,[k]:p,[D]:_,[F]:g,[S]:x,[A]:C,[T]:R,[w]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[O]:"touchout",[k]:"touchleave",[D]:"touchover",[F]:"touchenter",[S]:Z,[A]:V,[T]:W,[w]:q,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[O]:O,[k]:k,[D]:D,[F]:F,[S]:S,[A]:A,[T]:T,[w]:w,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},B=se=>se.indexOf("pointer")>=0?"pointer":se.indexOf("touch")>=0?"touch":"mouse",X=se=>{const ee=B(se);if(ee==="pointer")return n.Konva.pointerEventsEnabled&&$.pointer;if(ee==="touch")return $.touch;if(ee==="mouse")return $.mouse};function Q(se={}){return(se.clipFunc||se.clipWidth||se.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),se}const J="Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);";o.stages=[];class ne extends t.Container{constructor(ee){super(Q(ee)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),o.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{Q(this.attrs)}),this._checkVisibility()}_validateAdd(ee){const ie=ee.getType()==="Layer",oe=ee.getType()==="FastLayer";ie||oe||e.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const ee=this.visible()?"":"none";this.content.style.display=ee}setContainer(ee){if(typeof ee===h){if(ee.charAt(0)==="."){var ie=ee.slice(1);ee=document.getElementsByClassName(ie)[0]}else{var oe;ee.charAt(0)!=="#"?oe=ee:oe=ee.slice(1),ee=document.getElementById(oe)}if(!ee)throw"Can not find container in document with id "+oe}return this._setAttr("container",ee),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),ee.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){var ee=this.children,ie=ee.length,oe;for(oe=0;oe<ie;oe++)ee[oe].clear();return this}clone(ee){return ee||(ee={}),ee.container=typeof document<"u"&&document.createElement("div"),t.Container.prototype.clone.call(this,ee)}destroy(){super.destroy();var ee=this.content;ee&&e.Util._isInDocument(ee)&&this.container().removeChild(ee);var ie=o.stages.indexOf(this);return ie>-1&&o.stages.splice(ie,1),e.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const ee=this._pointerPositions[0]||this._changedPointerPositions[0];return ee?{x:ee.x,y:ee.y}:(e.Util.warn(J),null)}_getPointerById(ee){return this._pointerPositions.find(ie=>ie.id===ee)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(ee){ee=ee||{},ee.x=ee.x||0,ee.y=ee.y||0,ee.width=ee.width||this.width(),ee.height=ee.height||this.height();var ie=new a.SceneCanvas({width:ee.width,height:ee.height,pixelRatio:ee.pixelRatio||1}),oe=ie.getContext()._context,fe=this.children;return(ee.x||ee.y)&&oe.translate(-1*ee.x,-1*ee.y),fe.forEach(function(de){if(de.isVisible()){var ce=de._toKonvaCanvas(ee);oe.drawImage(ce._canvas,ee.x,ee.y,ce.getWidth()/ce.getPixelRatio(),ce.getHeight()/ce.getPixelRatio())}}),ie}getIntersection(ee){if(!ee)return null;var ie=this.children,oe=ie.length,fe=oe-1,de;for(de=fe;de>=0;de--){const ce=ie[de].getIntersection(ee);if(ce)return ce}return null}_resizeDOM(){var ee=this.width(),ie=this.height();this.content&&(this.content.style.width=ee+y,this.content.style.height=ie+y),this.bufferCanvas.setSize(ee,ie),this.bufferHitCanvas.setSize(ee,ie),this.children.forEach(oe=>{oe.setSize({width:ee,height:ie}),oe.draw()})}add(ee,...ie){if(arguments.length>1){for(var oe=0;oe<arguments.length;oe++)this.add(arguments[oe]);return this}super.add(ee);var fe=this.children.length;return fe>U&&e.Util.warn("The stage has "+fe+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),ee.setSize({width:this.width(),height:this.height()}),ee.draw(),n.Konva.isBrowser&&this.content.appendChild(ee.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(ee){return f.hasPointerCapture(ee,this)}setPointerCapture(ee){f.setPointerCapture(ee,this)}releaseCapture(ee){f.releaseCapture(ee,this)}getLayers(){return this.children}_bindContentEvents(){n.Konva.isBrowser&&I.forEach(([ee,ie])=>{this.content.addEventListener(ee,oe=>{this[ie](oe)},{passive:!1})})}_pointerenter(ee){this.setPointersPositions(ee);const ie=X(ee.type);ie&&this._fire(ie.pointerenter,{evt:ee,target:this,currentTarget:this})}_pointerover(ee){this.setPointersPositions(ee);const ie=X(ee.type);ie&&this._fire(ie.pointerover,{evt:ee,target:this,currentTarget:this})}_getTargetShape(ee){let ie=this[ee+"targetShape"];return ie&&!ie.getStage()&&(ie=null),ie}_pointerleave(ee){const ie=X(ee.type),oe=B(ee.type);if(ie){this.setPointersPositions(ee);var fe=this._getTargetShape(oe),de=!u.DD.isDragging||n.Konva.hitOnDragEnabled;fe&&de?(fe._fireAndBubble(ie.pointerout,{evt:ee}),fe._fireAndBubble(ie.pointerleave,{evt:ee}),this._fire(ie.pointerleave,{evt:ee,target:this,currentTarget:this}),this[oe+"targetShape"]=null):de&&(this._fire(ie.pointerleave,{evt:ee,target:this,currentTarget:this}),this._fire(ie.pointerout,{evt:ee,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}}_pointerdown(ee){const ie=X(ee.type),oe=B(ee.type);if(ie){this.setPointersPositions(ee);var fe=!1;this._changedPointerPositions.forEach(de=>{var ce=this.getIntersection(de);if(u.DD.justDragged=!1,n.Konva["_"+oe+"ListenClick"]=!0,!ce||!ce.isListening())return;n.Konva.capturePointerEventsEnabled&&ce.setPointerCapture(de.id),this[oe+"ClickStartShape"]=ce,ce._fireAndBubble(ie.pointerdown,{evt:ee,pointerId:de.id}),fe=!0;const Se=ee.type.indexOf("touch")>=0;ce.preventDefault()&&ee.cancelable&&Se&&ee.preventDefault()}),fe||this._fire(ie.pointerdown,{evt:ee,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(ee){const ie=X(ee.type),oe=B(ee.type);if(!ie)return;u.DD.isDragging&&u.DD.node.preventDefault()&&ee.cancelable&&ee.preventDefault(),this.setPointersPositions(ee);var fe=!u.DD.isDragging||n.Konva.hitOnDragEnabled;if(!fe)return;var de={};let ce=!1;var Se=this._getTargetShape(oe);this._changedPointerPositions.forEach(ke=>{const Ne=f.getCapturedShape(ke.id)||this.getIntersection(ke),We=ke.id,Ke={evt:ee,pointerId:We};var Qe=Se!==Ne;if(Qe&&Se&&(Se._fireAndBubble(ie.pointerout,{...Ke},Ne),Se._fireAndBubble(ie.pointerleave,{...Ke},Ne)),Ne){if(de[Ne._id])return;de[Ne._id]=!0}Ne&&Ne.isListening()?(ce=!0,Qe&&(Ne._fireAndBubble(ie.pointerover,{...Ke},Se),Ne._fireAndBubble(ie.pointerenter,{...Ke},Se),this[oe+"targetShape"]=Ne),Ne._fireAndBubble(ie.pointermove,{...Ke})):Se&&(this._fire(ie.pointerover,{evt:ee,target:this,currentTarget:this,pointerId:We}),this[oe+"targetShape"]=null)}),ce||this._fire(ie.pointermove,{evt:ee,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(ee){const ie=X(ee.type),oe=B(ee.type);if(!ie)return;this.setPointersPositions(ee);const fe=this[oe+"ClickStartShape"],de=this[oe+"ClickEndShape"];var ce={};let Se=!1;this._changedPointerPositions.forEach(ke=>{const Ne=f.getCapturedShape(ke.id)||this.getIntersection(ke);if(Ne){if(Ne.releaseCapture(ke.id),ce[Ne._id])return;ce[Ne._id]=!0}const We=ke.id,Ke={evt:ee,pointerId:We};let Qe=!1;n.Konva["_"+oe+"InDblClickWindow"]?(Qe=!0,clearTimeout(this[oe+"DblTimeout"])):u.DD.justDragged||(n.Konva["_"+oe+"InDblClickWindow"]=!0,clearTimeout(this[oe+"DblTimeout"])),this[oe+"DblTimeout"]=setTimeout(function(){n.Konva["_"+oe+"InDblClickWindow"]=!1},n.Konva.dblClickWindow),Ne&&Ne.isListening()?(Se=!0,this[oe+"ClickEndShape"]=Ne,Ne._fireAndBubble(ie.pointerup,{...Ke}),n.Konva["_"+oe+"ListenClick"]&&fe&&fe===Ne&&(Ne._fireAndBubble(ie.pointerclick,{...Ke}),Qe&&de&&de===Ne&&Ne._fireAndBubble(ie.pointerdblclick,{...Ke}))):(this[oe+"ClickEndShape"]=null,n.Konva["_"+oe+"ListenClick"]&&this._fire(ie.pointerclick,{evt:ee,target:this,currentTarget:this,pointerId:We}),Qe&&this._fire(ie.pointerdblclick,{evt:ee,target:this,currentTarget:this,pointerId:We}))}),Se||this._fire(ie.pointerup,{evt:ee,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),n.Konva["_"+oe+"ListenClick"]=!1,ee.cancelable&&oe!=="touch"&&ee.preventDefault()}_contextmenu(ee){this.setPointersPositions(ee);var ie=this.getIntersection(this.getPointerPosition());ie&&ie.isListening()?ie._fireAndBubble(G,{evt:ee}):this._fire(G,{evt:ee,target:this,currentTarget:this})}_wheel(ee){this.setPointersPositions(ee);var ie=this.getIntersection(this.getPointerPosition());ie&&ie.isListening()?ie._fireAndBubble(z,{evt:ee}):this._fire(z,{evt:ee,target:this,currentTarget:this})}_pointercancel(ee){this.setPointersPositions(ee);const ie=f.getCapturedShape(ee.pointerId)||this.getIntersection(this.getPointerPosition());ie&&ie._fireAndBubble(T,f.createEvent(ee)),f.releaseCapture(ee.pointerId)}_lostpointercapture(ee){f.releaseCapture(ee.pointerId)}setPointersPositions(ee){var ie=this._getContentPosition(),oe=null,fe=null;ee=ee||window.event,ee.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(ee.touches,de=>{this._pointerPositions.push({id:de.identifier,x:(de.clientX-ie.left)/ie.scaleX,y:(de.clientY-ie.top)/ie.scaleY})}),Array.prototype.forEach.call(ee.changedTouches||ee.touches,de=>{this._changedPointerPositions.push({id:de.identifier,x:(de.clientX-ie.left)/ie.scaleX,y:(de.clientY-ie.top)/ie.scaleY})})):(oe=(ee.clientX-ie.left)/ie.scaleX,fe=(ee.clientY-ie.top)/ie.scaleY,this.pointerPos={x:oe,y:fe},this._pointerPositions=[{x:oe,y:fe,id:e.Util._getFirstPointerId(ee)}],this._changedPointerPositions=[{x:oe,y:fe,id:e.Util._getFirstPointerId(ee)}])}_setPointerPosition(ee){e.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(ee)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};var ee=this.content.getBoundingClientRect();return{top:ee.top,left:ee.left,scaleX:ee.width/this.content.clientWidth||1,scaleY:ee.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new a.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new a.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!!n.Konva.isBrowser){var ee=this.container();if(!ee)throw"Stage has no container. A container is required.";ee.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),ee.appendChild(this.content),this._resizeDOM()}}cache(){return e.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(ee){ee.batchDraw()}),this}}o.Stage=ne,ne.prototype.nodeType=c,(0,l._registerNode)(ne),r.Factory.addGetterSetter(ne,"container")})(Stage$1);var Layer$2={},Shape={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Shape=o.shapes=void 0;const e=Global,r=Util,t=Factory,n=Node$1,a=Validators,u=Global,l=PointerEvents;var f="hasShadow",c="shadowRGBA",h="patternImage",y="linearGradient",E="radialGradient";let p;function _(){return p||(p=r.Util.createCanvasElement().getContext("2d"),p)}o.shapes={};function g(k){const D=this.attrs.fillRule;D?k.fill(D):k.fill()}function x(k){k.stroke()}function C(k){k.fill()}function R(k){k.stroke()}function S(){this._clearCache(f)}function A(){this._clearCache(c)}function T(){this._clearCache(h)}function w(){this._clearCache(y)}function P(){this._clearCache(E)}class O extends n.Node{constructor(D){super(D);let F;for(;F=r.Util.getRandomColor(),!(F&&!(F in o.shapes)););this.colorKey=F,o.shapes[F]=this}getContext(){return r.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return r.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(f,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(h,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){var D=_();const F=D.createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(F&&F.setTransform){const G=new r.Transform;G.translate(this.fillPatternX(),this.fillPatternY()),G.rotate(e.Konva.getAngle(this.fillPatternRotation())),G.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),G.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const V=G.getMatrix(),W=typeof DOMMatrix>"u"?{a:V[0],b:V[1],c:V[2],d:V[3],e:V[4],f:V[5]}:new DOMMatrix(V);F.setTransform(W)}return F}}_getLinearGradient(){return this._getCache(y,this.__getLinearGradient)}__getLinearGradient(){var D=this.fillLinearGradientColorStops();if(D){for(var F=_(),G=this.fillLinearGradientStartPoint(),V=this.fillLinearGradientEndPoint(),W=F.createLinearGradient(G.x,G.y,V.x,V.y),Z=0;Z<D.length;Z+=2)W.addColorStop(D[Z],D[Z+1]);return W}}_getRadialGradient(){return this._getCache(E,this.__getRadialGradient)}__getRadialGradient(){var D=this.fillRadialGradientColorStops();if(D){for(var F=_(),G=this.fillRadialGradientStartPoint(),V=this.fillRadialGradientEndPoint(),W=F.createRadialGradient(G.x,G.y,this.fillRadialGradientStartRadius(),V.x,V.y,this.fillRadialGradientEndRadius()),Z=0;Z<D.length;Z+=2)W.addColorStop(D[Z],D[Z+1]);return W}}getShadowRGBA(){return this._getCache(c,this._getShadowRGBA)}_getShadowRGBA(){if(this.hasShadow()){var D=r.Util.colorToRGBA(this.shadowColor());if(D)return"rgba("+D.r+","+D.g+","+D.b+","+D.a*(this.shadowOpacity()||1)+")"}}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){const D=this.hitStrokeWidth();return D==="auto"?this.hasStroke():this.strokeEnabled()&&!!D}intersects(D){var F=this.getStage();if(!F)return!1;const G=F.bufferHitCanvas;return G.getContext().clear(),this.drawHit(G,void 0,!0),G.context.getImageData(Math.round(D.x),Math.round(D.y),1,1).data[3]>0}destroy(){return n.Node.prototype.destroy.call(this),delete o.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(D){var F;if(!this.getStage()||!((F=this.attrs.perfectDrawEnabled)!==null&&F!==void 0?F:!0))return!1;const V=D||this.hasFill(),W=this.hasStroke(),Z=this.getAbsoluteOpacity()!==1;if(V&&W&&Z)return!0;const q=this.hasShadow(),z=this.shadowForStrokeEnabled();return!!(V&&W&&q&&z)}setStrokeHitEnabled(D){r.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),D?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){var D=this.size();return{x:this._centroid?-D.width/2:0,y:this._centroid?-D.height/2:0,width:D.width,height:D.height}}getClientRect(D={}){const F=D.skipTransform,G=D.relativeTo,V=this.getSelfRect(),Z=!D.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,q=V.width+Z,z=V.height+Z,U=!D.skipShadow&&this.hasShadow(),I=U?this.shadowOffsetX():0,$=U?this.shadowOffsetY():0,B=q+Math.abs(I),X=z+Math.abs($),Q=U&&this.shadowBlur()||0,J=B+Q*2,ne=X+Q*2,se={width:J,height:ne,x:-(Z/2+Q)+Math.min(I,0)+V.x,y:-(Z/2+Q)+Math.min($,0)+V.y};return F?se:this._transformedRect(se,G)}drawScene(D,F){var G=this.getLayer(),V=D||G.getCanvas(),W=V.getContext(),Z=this._getCanvasCache(),q=this.getSceneFunc(),z=this.hasShadow(),U,I,$,B=V.isCache,X=F===this;if(!this.isVisible()&&!X)return this;if(Z){W.save();var Q=this.getAbsoluteTransform(F).getMatrix();return W.transform(Q[0],Q[1],Q[2],Q[3],Q[4],Q[5]),this._drawCachedSceneCanvas(W),W.restore(),this}if(!q)return this;if(W.save(),this._useBufferCanvas()&&!B){U=this.getStage(),I=U.bufferCanvas,$=I.getContext(),$.clear(),$.save(),$._applyLineJoin(this);var J=this.getAbsoluteTransform(F).getMatrix();$.transform(J[0],J[1],J[2],J[3],J[4],J[5]),q.call(this,$,this),$.restore();var ne=I.pixelRatio;z&&W._applyShadow(this),W._applyOpacity(this),W._applyGlobalCompositeOperation(this),W.drawImage(I._canvas,0,0,I.width/ne,I.height/ne)}else{if(W._applyLineJoin(this),!X){var J=this.getAbsoluteTransform(F).getMatrix();W.transform(J[0],J[1],J[2],J[3],J[4],J[5]),W._applyOpacity(this),W._applyGlobalCompositeOperation(this)}z&&W._applyShadow(this),q.call(this,W,this)}return W.restore(),this}drawHit(D,F,G=!1){if(!this.shouldDrawHit(F,G))return this;var V=this.getLayer(),W=D||V.hitCanvas,Z=W&&W.getContext(),q=this.hitFunc()||this.sceneFunc(),z=this._getCanvasCache(),U=z&&z.hit;if(this.colorKey||r.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),U){Z.save();var I=this.getAbsoluteTransform(F).getMatrix();return Z.transform(I[0],I[1],I[2],I[3],I[4],I[5]),this._drawCachedHitCanvas(Z),Z.restore(),this}if(!q)return this;if(Z.save(),Z._applyLineJoin(this),!(this===F)){var B=this.getAbsoluteTransform(F).getMatrix();Z.transform(B[0],B[1],B[2],B[3],B[4],B[5])}return q.call(this,Z,this),Z.restore(),this}drawHitFromCache(D=0){var F=this._getCanvasCache(),G=this._getCachedSceneCanvas(),V=F.hit,W=V.getContext(),Z=V.getWidth(),q=V.getHeight(),z,U,I,$,B,X;W.clear(),W.drawImage(G._canvas,0,0,Z,q);try{for(z=W.getImageData(0,0,Z,q),U=z.data,I=U.length,$=r.Util._hexToRgb(this.colorKey),B=0;B<I;B+=4)X=U[B+3],X>D?(U[B]=$.r,U[B+1]=$.g,U[B+2]=$.b,U[B+3]=255):U[B+3]=0;W.putImageData(z,0,0)}catch(Q){r.Util.error("Unable to draw hit graph from cached scene canvas. "+Q.message)}return this}hasPointerCapture(D){return l.hasPointerCapture(D,this)}setPointerCapture(D){l.setPointerCapture(D,this)}releaseCapture(D){l.releaseCapture(D,this)}}o.Shape=O,O.prototype._fillFunc=g,O.prototype._strokeFunc=x,O.prototype._fillFuncHit=C,O.prototype._strokeFuncHit=R,O.prototype._centroid=!1,O.prototype.nodeType="Shape",(0,u._registerNode)(O),O.prototype.eventListeners={},O.prototype.on.call(O.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",S),O.prototype.on.call(O.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",A),O.prototype.on.call(O.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",T),O.prototype.on.call(O.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",w),O.prototype.on.call(O.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",P),t.Factory.addGetterSetter(O,"stroke",void 0,(0,a.getStringOrGradientValidator)()),t.Factory.addGetterSetter(O,"strokeWidth",2,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillAfterStrokeEnabled",!1),t.Factory.addGetterSetter(O,"hitStrokeWidth","auto",(0,a.getNumberOrAutoValidator)()),t.Factory.addGetterSetter(O,"strokeHitEnabled",!0,(0,a.getBooleanValidator)()),t.Factory.addGetterSetter(O,"perfectDrawEnabled",!0,(0,a.getBooleanValidator)()),t.Factory.addGetterSetter(O,"shadowForStrokeEnabled",!0,(0,a.getBooleanValidator)()),t.Factory.addGetterSetter(O,"lineJoin"),t.Factory.addGetterSetter(O,"lineCap"),t.Factory.addGetterSetter(O,"sceneFunc"),t.Factory.addGetterSetter(O,"hitFunc"),t.Factory.addGetterSetter(O,"dash"),t.Factory.addGetterSetter(O,"dashOffset",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"shadowColor",void 0,(0,a.getStringValidator)()),t.Factory.addGetterSetter(O,"shadowBlur",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"shadowOpacity",1,(0,a.getNumberValidator)()),t.Factory.addComponentsGetterSetter(O,"shadowOffset",["x","y"]),t.Factory.addGetterSetter(O,"shadowOffsetX",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"shadowOffsetY",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillPatternImage"),t.Factory.addGetterSetter(O,"fill",void 0,(0,a.getStringOrGradientValidator)()),t.Factory.addGetterSetter(O,"fillPatternX",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillPatternY",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillLinearGradientColorStops"),t.Factory.addGetterSetter(O,"strokeLinearGradientColorStops"),t.Factory.addGetterSetter(O,"fillRadialGradientStartRadius",0),t.Factory.addGetterSetter(O,"fillRadialGradientEndRadius",0),t.Factory.addGetterSetter(O,"fillRadialGradientColorStops"),t.Factory.addGetterSetter(O,"fillPatternRepeat","repeat"),t.Factory.addGetterSetter(O,"fillEnabled",!0),t.Factory.addGetterSetter(O,"strokeEnabled",!0),t.Factory.addGetterSetter(O,"shadowEnabled",!0),t.Factory.addGetterSetter(O,"dashEnabled",!0),t.Factory.addGetterSetter(O,"strokeScaleEnabled",!0),t.Factory.addGetterSetter(O,"fillPriority","color"),t.Factory.addComponentsGetterSetter(O,"fillPatternOffset",["x","y"]),t.Factory.addGetterSetter(O,"fillPatternOffsetX",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillPatternOffsetY",0,(0,a.getNumberValidator)()),t.Factory.addComponentsGetterSetter(O,"fillPatternScale",["x","y"]),t.Factory.addGetterSetter(O,"fillPatternScaleX",1,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillPatternScaleY",1,(0,a.getNumberValidator)()),t.Factory.addComponentsGetterSetter(O,"fillLinearGradientStartPoint",["x","y"]),t.Factory.addComponentsGetterSetter(O,"strokeLinearGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(O,"fillLinearGradientStartPointX",0),t.Factory.addGetterSetter(O,"strokeLinearGradientStartPointX",0),t.Factory.addGetterSetter(O,"fillLinearGradientStartPointY",0),t.Factory.addGetterSetter(O,"strokeLinearGradientStartPointY",0),t.Factory.addComponentsGetterSetter(O,"fillLinearGradientEndPoint",["x","y"]),t.Factory.addComponentsGetterSetter(O,"strokeLinearGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(O,"fillLinearGradientEndPointX",0),t.Factory.addGetterSetter(O,"strokeLinearGradientEndPointX",0),t.Factory.addGetterSetter(O,"fillLinearGradientEndPointY",0),t.Factory.addGetterSetter(O,"strokeLinearGradientEndPointY",0),t.Factory.addComponentsGetterSetter(O,"fillRadialGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(O,"fillRadialGradientStartPointX",0),t.Factory.addGetterSetter(O,"fillRadialGradientStartPointY",0),t.Factory.addComponentsGetterSetter(O,"fillRadialGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(O,"fillRadialGradientEndPointX",0),t.Factory.addGetterSetter(O,"fillRadialGradientEndPointY",0),t.Factory.addGetterSetter(O,"fillPatternRotation",0),t.Factory.addGetterSetter(O,"fillRule",void 0,(0,a.getStringValidator)()),t.Factory.backCompat(O,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})})(Shape);Object.defineProperty(Layer$2,"__esModule",{value:!0});Layer$2.Layer=void 0;const Util_1$b=Util,Container_1$1=Container$2,Node_1$g=Node$1,Factory_1$w=Factory,Canvas_1=Canvas$1,Validators_1$v=Validators,Shape_1$g=Shape,Global_1$k=Global;var HASH="#",BEFORE_DRAW="beforeDraw",DRAW="draw",INTERSECTION_OFFSETS=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],INTERSECTION_OFFSETS_LEN=INTERSECTION_OFFSETS.length;let Layer$1=class extends Container_1$1.Container{constructor(e){super(e),this.canvas=new Canvas_1.SceneCanvas,this.hitCanvas=new Canvas_1.HitCanvas({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);var r=this.getStage();return r&&r.content&&(r.content.removeChild(this.getNativeCanvasElement()),e<r.children.length-1?r.content.insertBefore(this.getNativeCanvasElement(),r.children[e+1].getCanvas()._canvas):r.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){Node_1$g.Node.prototype.moveToTop.call(this);var e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){var e=Node_1$g.Node.prototype.moveUp.call(this);if(!e)return!1;var r=this.getStage();return!r||!r.content?!1:(r.content.removeChild(this.getNativeCanvasElement()),this.index<r.children.length-1?r.content.insertBefore(this.getNativeCanvasElement(),r.children[this.index+1].getCanvas()._canvas):r.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(Node_1$g.Node.prototype.moveDown.call(this)){var e=this.getStage();if(e){var r=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),r[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(Node_1$g.Node.prototype.moveToBottom.call(this)){var e=this.getStage();if(e){var r=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),r[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){var e=this.getNativeCanvasElement();return Node_1$g.Node.prototype.remove.call(this),e&&e.parentNode&&Util_1$b.Util._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:r}){return this.canvas.setSize(e,r),this.hitCanvas.setSize(e,r),this._setSmoothEnabled(),this}_validateAdd(e){var r=e.getType();r!=="Group"&&r!=="Shape"&&Util_1$b.Util.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(e){return e=e||{},e.width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=e.x!==void 0?e.x:this.x(),e.y=e.y!==void 0?e.y:this.y(),Node_1$g.Node.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){this.visible()?this.canvas._canvas.style.display="block":this.canvas._canvas.style.display="none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){Util_1$b.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){Util_1$b.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,Util_1$b.Util.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;for(var r=1,t=!1;;){for(let n=0;n<INTERSECTION_OFFSETS_LEN;n++){const a=INTERSECTION_OFFSETS[n],u=this._getIntersection({x:e.x+a.x*r,y:e.y+a.y*r}),l=u.shape;if(l)return l;if(t=!!u.antialiased,!u.antialiased)break}if(t)r+=1;else return null}}_getIntersection(e){const r=this.hitCanvas.pixelRatio,t=this.hitCanvas.context.getImageData(Math.round(e.x*r),Math.round(e.y*r),1,1).data,n=t[3];if(n===255){const a=Util_1$b.Util._rgbToHex(t[0],t[1],t[2]),u=Shape_1$g.shapes[HASH+a];return u?{shape:u}:{antialiased:!0}}else if(n>0)return{antialiased:!0};return{}}drawScene(e,r){var t=this.getLayer(),n=e||t&&t.getCanvas();return this._fire(BEFORE_DRAW,{node:this}),this.clearBeforeDraw()&&n.getContext().clear(),Container_1$1.Container.prototype.drawScene.call(this,n,r),this._fire(DRAW,{node:this}),this}drawHit(e,r){var t=this.getLayer(),n=e||t&&t.hitCanvas;return t&&t.clearBeforeDraw()&&t.getHitCanvas().getContext().clear(),Container_1$1.Container.prototype.drawHit.call(this,n,r),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){Util_1$b.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return Util_1$b.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!(!this.parent||!this.parent.content)){var e=this.parent,r=!!this.hitCanvas._canvas.parentNode;r?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}}destroy(){return Util_1$b.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};Layer$2.Layer=Layer$1;Layer$1.prototype.nodeType="Layer";(0,Global_1$k._registerNode)(Layer$1);Factory_1$w.Factory.addGetterSetter(Layer$1,"imageSmoothingEnabled",!0);Factory_1$w.Factory.addGetterSetter(Layer$1,"clearBeforeDraw",!0);Factory_1$w.Factory.addGetterSetter(Layer$1,"hitGraphEnabled",!0,(0,Validators_1$v.getBooleanValidator)());var FastLayer$1={};Object.defineProperty(FastLayer$1,"__esModule",{value:!0});FastLayer$1.FastLayer=void 0;const Util_1$a=Util,Layer_1=Layer$2,Global_1$j=Global;class FastLayer extends Layer_1.Layer{constructor(e){super(e),this.listening(!1),Util_1$a.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}FastLayer$1.FastLayer=FastLayer;FastLayer.prototype.nodeType="FastLayer";(0,Global_1$j._registerNode)(FastLayer);var Group$2={};Object.defineProperty(Group$2,"__esModule",{value:!0});Group$2.Group=void 0;const Util_1$9=Util,Container_1=Container$2,Global_1$i=Global;let Group$1=class extends Container_1.Container{_validateAdd(e){var r=e.getType();r!=="Group"&&r!=="Shape"&&Util_1$9.Util.throw("You may only add groups and shapes to groups.")}};Group$2.Group=Group$1;Group$1.prototype.nodeType="Group";(0,Global_1$i._registerNode)(Group$1);var Animation$2={};Object.defineProperty(Animation$2,"__esModule",{value:!0});Animation$2.Animation=void 0;const Global_1$h=Global,Util_1$8=Util,now=function(){return Global_1$h.glob.performance&&Global_1$h.glob.performance.now?function(){return Global_1$h.glob.performance.now()}:function(){return new Date().getTime()}}();let Animation$1=class Hl{constructor(e,r){this.id=Hl.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:now(),frameRate:0},this.func=e,this.setLayers(r)}setLayers(e){let r=[];return e&&(r=Array.isArray(e)?e:[e]),this.layers=r,this}getLayers(){return this.layers}addLayer(e){const r=this.layers,t=r.length;for(let n=0;n<t;n++)if(r[n]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){const r=Hl.animations,t=r.length;for(let n=0;n<t;n++)if(r[n].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=now(),Hl._addAnimation(this),this}stop(){return Hl._removeAnimation(this),this}_updateFrameObject(e){this.frame.timeDiff=e-this.frame.lastTime,this.frame.lastTime=e,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(e){this.animations.push(e),this._handleAnimation()}static _removeAnimation(e){const r=e.id,t=this.animations,n=t.length;for(let a=0;a<n;a++)if(t[a].id===r){this.animations.splice(a,1);break}}static _runFrames(){const e={},r=this.animations;for(let t=0;t<r.length;t++){const n=r[t],a=n.layers,u=n.func;n._updateFrameObject(now());const l=a.length;let f;if(u?f=u.call(n,n.frame)!==!1:f=!0,!!f)for(let c=0;c<l;c++){const h=a[c];h._id!==void 0&&(e[h._id]=h)}}for(let t in e)e.hasOwnProperty(t)&&e[t].batchDraw()}static _animationLoop(){const e=Hl;e.animations.length?(e._runFrames(),Util_1$8.Util.requestAnimFrame(e._animationLoop)):e.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Util_1$8.Util.requestAnimFrame(this._animationLoop))}};Animation$2.Animation=Animation$1;Animation$1.animations=[];Animation$1.animIdCounter=0;Animation$1.animRunning=!1;var Tween$1={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Easings=o.Tween=void 0;const e=Util,r=Animation$2,t=Node$1,n=Global;var a={node:1,duration:1,easing:1,onFinish:1,yoyo:1},u=1,l=2,f=3,c=0,h=["fill","stroke","shadowColor"];class y{constructor(_,g,x,C,R,S,A){this.prop=_,this.propFunc=g,this.begin=C,this._pos=C,this.duration=S,this._change=0,this.prevPos=0,this.yoyo=A,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=x,this._change=R-this.begin,this.pause()}fire(_){var g=this[_];g&&g()}setTime(_){_>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():_<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=_,this.update())}getTime(){return this._time}setPosition(_){this.prevPos=this._pos,this.propFunc(_),this._pos=_}getPosition(_){return _===void 0&&(_=this._time),this.func(_,this.begin,this._change,this.duration)}play(){this.state=l,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=f,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(_){this.pause(),this._time=_,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){var _=this.getTimer()-this._startTime;this.state===l?this.setTime(_):this.state===f&&this.setTime(this.duration-_)}pause(){this.state=u,this.fire("onPause")}getTimer(){return new Date().getTime()}}class E{constructor(_){var g=this,x=_.node,C=x._id,R,S=_.easing||o.Easings.Linear,A=!!_.yoyo,T;typeof _.duration>"u"?R=.3:_.duration===0?R=.001:R=_.duration,this.node=x,this._id=c++;var w=x.getLayer()||(x instanceof n.Konva.Stage?x.getLayers():null);w||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new r.Animation(function(){g.tween.onEnterFrame()},w),this.tween=new y(T,function(P){g._tweenFunc(P)},S,0,1,R*1e3,A),this._addListeners(),E.attrs[C]||(E.attrs[C]={}),E.attrs[C][this._id]||(E.attrs[C][this._id]={}),E.tweens[C]||(E.tweens[C]={});for(T in _)a[T]===void 0&&this._addAttr(T,_[T]);this.reset(),this.onFinish=_.onFinish,this.onReset=_.onReset,this.onUpdate=_.onUpdate}_addAttr(_,g){var x=this.node,C=x._id,R,S,A,T,w,P,O,k;if(A=E.tweens[C][_],A&&delete E.attrs[C][A][_],R=x.getAttr(_),e.Util._isArray(g))if(S=[],w=Math.max(g.length,R.length),_==="points"&&g.length!==R.length&&(g.length>R.length?(O=R,R=e.Util._prepareArrayForTween(R,g,x.closed())):(P=g,g=e.Util._prepareArrayForTween(g,R,x.closed()))),_.indexOf("fill")===0)for(T=0;T<w;T++)if(T%2===0)S.push(g[T]-R[T]);else{var D=e.Util.colorToRGBA(R[T]);k=e.Util.colorToRGBA(g[T]),R[T]=D,S.push({r:k.r-D.r,g:k.g-D.g,b:k.b-D.b,a:k.a-D.a})}else for(T=0;T<w;T++)S.push(g[T]-R[T]);else h.indexOf(_)!==-1?(R=e.Util.colorToRGBA(R),k=e.Util.colorToRGBA(g),S={r:k.r-R.r,g:k.g-R.g,b:k.b-R.b,a:k.a-R.a}):S=g-R;E.attrs[C][this._id][_]={start:R,diff:S,end:g,trueEnd:P,trueStart:O},E.tweens[C][_]=this._id}_tweenFunc(_){var g=this.node,x=E.attrs[g._id][this._id],C,R,S,A,T,w,P,O;for(C in x){if(R=x[C],S=R.start,A=R.diff,O=R.end,e.Util._isArray(S))if(T=[],P=Math.max(S.length,O.length),C.indexOf("fill")===0)for(w=0;w<P;w++)w%2===0?T.push((S[w]||0)+A[w]*_):T.push("rgba("+Math.round(S[w].r+A[w].r*_)+","+Math.round(S[w].g+A[w].g*_)+","+Math.round(S[w].b+A[w].b*_)+","+(S[w].a+A[w].a*_)+")");else for(w=0;w<P;w++)T.push((S[w]||0)+A[w]*_);else h.indexOf(C)!==-1?T="rgba("+Math.round(S.r+A.r*_)+","+Math.round(S.g+A.g*_)+","+Math.round(S.b+A.b*_)+","+(S.a+A.a*_)+")":T=S+A*_;g.setAttr(C,T)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var _=this.node,g=E.attrs[_._id][this._id];g.points&&g.points.trueEnd&&_.setAttr("points",g.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var _=this.node,g=E.attrs[_._id][this._id];g.points&&g.points.trueStart&&_.points(g.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(_){return this.tween.seek(_*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var _=this.node._id,g=this._id,x=E.tweens[_],C;this.pause();for(C in x)delete E.tweens[_][C];delete E.attrs[_][g]}}o.Tween=E,E.attrs={},E.tweens={},t.Node.prototype.to=function(p){var _=p.onFinish;p.node=this,p.onFinish=function(){this.destroy(),_&&_()};var g=new E(p);g.play()},o.Easings={BackEaseIn(p,_,g,x){var C=1.70158;return g*(p/=x)*p*((C+1)*p-C)+_},BackEaseOut(p,_,g,x){var C=1.70158;return g*((p=p/x-1)*p*((C+1)*p+C)+1)+_},BackEaseInOut(p,_,g,x){var C=1.70158;return(p/=x/2)<1?g/2*(p*p*(((C*=1.525)+1)*p-C))+_:g/2*((p-=2)*p*(((C*=1.525)+1)*p+C)+2)+_},ElasticEaseIn(p,_,g,x,C,R){var S=0;return p===0?_:(p/=x)===1?_+g:(R||(R=x*.3),!C||C<Math.abs(g)?(C=g,S=R/4):S=R/(2*Math.PI)*Math.asin(g/C),-(C*Math.pow(2,10*(p-=1))*Math.sin((p*x-S)*(2*Math.PI)/R))+_)},ElasticEaseOut(p,_,g,x,C,R){var S=0;return p===0?_:(p/=x)===1?_+g:(R||(R=x*.3),!C||C<Math.abs(g)?(C=g,S=R/4):S=R/(2*Math.PI)*Math.asin(g/C),C*Math.pow(2,-10*p)*Math.sin((p*x-S)*(2*Math.PI)/R)+g+_)},ElasticEaseInOut(p,_,g,x,C,R){var S=0;return p===0?_:(p/=x/2)===2?_+g:(R||(R=x*(.3*1.5)),!C||C<Math.abs(g)?(C=g,S=R/4):S=R/(2*Math.PI)*Math.asin(g/C),p<1?-.5*(C*Math.pow(2,10*(p-=1))*Math.sin((p*x-S)*(2*Math.PI)/R))+_:C*Math.pow(2,-10*(p-=1))*Math.sin((p*x-S)*(2*Math.PI)/R)*.5+g+_)},BounceEaseOut(p,_,g,x){return(p/=x)<1/2.75?g*(7.5625*p*p)+_:p<2/2.75?g*(7.5625*(p-=1.5/2.75)*p+.75)+_:p<2.5/2.75?g*(7.5625*(p-=2.25/2.75)*p+.9375)+_:g*(7.5625*(p-=2.625/2.75)*p+.984375)+_},BounceEaseIn(p,_,g,x){return g-o.Easings.BounceEaseOut(x-p,0,g,x)+_},BounceEaseInOut(p,_,g,x){return p<x/2?o.Easings.BounceEaseIn(p*2,0,g,x)*.5+_:o.Easings.BounceEaseOut(p*2-x,0,g,x)*.5+g*.5+_},EaseIn(p,_,g,x){return g*(p/=x)*p+_},EaseOut(p,_,g,x){return-g*(p/=x)*(p-2)+_},EaseInOut(p,_,g,x){return(p/=x/2)<1?g/2*p*p+_:-g/2*(--p*(p-2)-1)+_},StrongEaseIn(p,_,g,x){return g*(p/=x)*p*p*p*p+_},StrongEaseOut(p,_,g,x){return g*((p=p/x-1)*p*p*p*p+1)+_},StrongEaseInOut(p,_,g,x){return(p/=x/2)<1?g/2*p*p*p*p*p+_:g/2*((p-=2)*p*p*p*p+2)+_},Linear(p,_,g,x){return g*p/x+_}}})(Tween$1);(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Konva=void 0;const e=Global,r=Util,t=Node$1,n=Container$2,a=Stage$1,u=Layer$2,l=FastLayer$1,f=Group$2,c=DragAndDrop,h=Shape,y=Animation$2,E=Tween$1,p=Context$2,_=Canvas$1;o.Konva=r.Util._assign(e.Konva,{Util:r.Util,Transform:r.Transform,Node:t.Node,Container:n.Container,Stage:a.Stage,stages:a.stages,Layer:u.Layer,FastLayer:l.FastLayer,Group:f.Group,DD:c.DD,Shape:h.Shape,shapes:h.shapes,Animation:y.Animation,Tween:E.Tween,Easings:E.Easings,Context:p.Context,Canvas:_.Canvas}),o.default=o.Konva})(_CoreInternals);var Arc$1={};Object.defineProperty(Arc$1,"__esModule",{value:!0});Arc$1.Arc=void 0;const Factory_1$v=Factory,Shape_1$f=Shape,Global_1$g=Global,Validators_1$u=Validators,Global_2$2=Global;class Arc extends Shape_1$f.Shape{_sceneFunc(e){var r=Global_1$g.Konva.getAngle(this.angle()),t=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,r,t),e.arc(0,0,this.innerRadius(),r,0,!t),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){const e=this.innerRadius(),r=this.outerRadius(),t=this.clockwise(),n=Global_1$g.Konva.getAngle(t?360-this.angle():this.angle()),a=Math.cos(Math.min(n,Math.PI)),u=1,l=Math.sin(Math.min(Math.max(Math.PI,n),3*Math.PI/2)),f=Math.sin(Math.min(n,Math.PI/2)),c=a*(a>0?e:r),h=u*r,y=l*(l>0?e:r),E=f*(f>0?r:e);return{x:c,y:t?-1*E:y,width:h-c,height:E-y}}}Arc$1.Arc=Arc;Arc.prototype._centroid=!0;Arc.prototype.className="Arc";Arc.prototype._attrsAffectingSize=["innerRadius","outerRadius"];(0,Global_2$2._registerNode)(Arc);Factory_1$v.Factory.addGetterSetter(Arc,"innerRadius",0,(0,Validators_1$u.getNumberValidator)());Factory_1$v.Factory.addGetterSetter(Arc,"outerRadius",0,(0,Validators_1$u.getNumberValidator)());Factory_1$v.Factory.addGetterSetter(Arc,"angle",0,(0,Validators_1$u.getNumberValidator)());Factory_1$v.Factory.addGetterSetter(Arc,"clockwise",!1,(0,Validators_1$u.getBooleanValidator)());var Arrow$1={},Line$2={};Object.defineProperty(Line$2,"__esModule",{value:!0});Line$2.Line=void 0;const Factory_1$u=Factory,Shape_1$e=Shape,Validators_1$t=Validators,Global_1$f=Global;function getControlPoints(o,e,r,t,n,a,u){var l=Math.sqrt(Math.pow(r-o,2)+Math.pow(t-e,2)),f=Math.sqrt(Math.pow(n-r,2)+Math.pow(a-t,2)),c=u*l/(l+f),h=u*f/(l+f),y=r-c*(n-o),E=t-c*(a-e),p=r+h*(n-o),_=t+h*(a-e);return[y,E,p,_]}function expandPoints(o,e){var r=o.length,t=[],n,a;for(n=2;n<r-2;n+=2)a=getControlPoints(o[n-2],o[n-1],o[n],o[n+1],o[n+2],o[n+3],e),!isNaN(a[0])&&(t.push(a[0]),t.push(a[1]),t.push(o[n]),t.push(o[n+1]),t.push(a[2]),t.push(a[3]));return t}let Line$1=class extends Shape_1$e.Shape{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(e){var r=this.points(),t=r.length,n=this.tension(),a=this.closed(),u=this.bezier(),l,f,c;if(t){if(e.beginPath(),e.moveTo(r[0],r[1]),n!==0&&t>4){for(l=this.getTensionPoints(),f=l.length,c=a?0:4,a||e.quadraticCurveTo(l[0],l[1],l[2],l[3]);c<f-2;)e.bezierCurveTo(l[c++],l[c++],l[c++],l[c++],l[c++],l[c++]);a||e.quadraticCurveTo(l[f-2],l[f-1],r[t-2],r[t-1])}else if(u)for(c=2;c<t;)e.bezierCurveTo(r[c++],r[c++],r[c++],r[c++],r[c++],r[c++]);else for(c=2;c<t;c+=2)e.lineTo(r[c],r[c+1]);a?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():expandPoints(this.points(),this.tension())}_getTensionPointsClosed(){var e=this.points(),r=e.length,t=this.tension(),n=getControlPoints(e[r-2],e[r-1],e[0],e[1],e[2],e[3],t),a=getControlPoints(e[r-4],e[r-3],e[r-2],e[r-1],e[0],e[1],t),u=expandPoints(e,t),l=[n[2],n[3]].concat(u).concat([a[0],a[1],e[r-2],e[r-1],a[2],a[3],n[0],n[1],e[0],e[1]]);return l}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){var e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};this.tension()!==0?e=[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]]:e=this.points();for(var r=e[0],t=e[0],n=e[1],a=e[1],u,l,f=0;f<e.length/2;f++)u=e[f*2],l=e[f*2+1],r=Math.min(r,u),t=Math.max(t,u),n=Math.min(n,l),a=Math.max(a,l);return{x:r,y:n,width:t-r,height:a-n}}};Line$2.Line=Line$1;Line$1.prototype.className="Line";Line$1.prototype._attrsAffectingSize=["points","bezier","tension"];(0,Global_1$f._registerNode)(Line$1);Factory_1$u.Factory.addGetterSetter(Line$1,"closed",!1);Factory_1$u.Factory.addGetterSetter(Line$1,"bezier",!1);Factory_1$u.Factory.addGetterSetter(Line$1,"tension",0,(0,Validators_1$t.getNumberValidator)());Factory_1$u.Factory.addGetterSetter(Line$1,"points",[],(0,Validators_1$t.getNumberArrayValidator)());var Path$1={},BezierFunctions={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.t2length=o.getQuadraticArcLength=o.getCubicArcLength=o.binomialCoefficients=o.cValues=o.tValues=void 0,o.tValues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],o.cValues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],o.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]];const e=(u,l,f)=>{let c,h,y;c=f/2,h=0;for(let p=0;p<20;p++)y=c*o.tValues[20][p]+c,h+=o.cValues[20][p]*t(u,l,y);return c*h};o.getCubicArcLength=e;const r=(u,l,f)=>{f===void 0&&(f=1);const c=u[0]-2*u[1]+u[2],h=l[0]-2*l[1]+l[2],y=2*u[1]-2*u[0],E=2*l[1]-2*l[0],p=4*(c*c+h*h),_=4*(c*y+h*E),g=y*y+E*E;if(p===0)return f*Math.sqrt(Math.pow(u[2]-u[0],2)+Math.pow(l[2]-l[0],2));const x=_/(2*p),C=g/p,R=f+x,S=C-x*x,A=R*R+S>0?Math.sqrt(R*R+S):0,T=x*x+S>0?Math.sqrt(x*x+S):0,w=x+Math.sqrt(x*x+S)!==0?S*Math.log(Math.abs((R+A)/(x+T))):0;return Math.sqrt(p)/2*(R*A-x*T+w)};o.getQuadraticArcLength=r;function t(u,l,f){const c=n(1,f,u),h=n(1,f,l),y=c*c+h*h;return Math.sqrt(y)}const n=(u,l,f)=>{const c=f.length-1;let h,y;if(c===0)return 0;if(u===0){y=0;for(let E=0;E<=c;E++)y+=o.binomialCoefficients[c][E]*Math.pow(1-l,c-E)*Math.pow(l,E)*f[E];return y}else{h=new Array(c);for(let E=0;E<c;E++)h[E]=c*(f[E+1]-f[E]);return n(u-1,l,h)}},a=(u,l,f)=>{let c=1,h=u/l,y=(u-f(h))/l,E=0;for(;c>.001;){const p=f(h+y),_=Math.abs(u-p)/l;if(_<c)c=_,h+=y;else{const g=f(h-y),x=Math.abs(u-g)/l;x<c?(c=x,h-=y):y/=2}if(E++,E>500)break}return h};o.t2length=a})(BezierFunctions);Object.defineProperty(Path$1,"__esModule",{value:!0});Path$1.Path=void 0;const Factory_1$t=Factory,Shape_1$d=Shape,Global_1$e=Global,BezierFunctions_1=BezierFunctions;class Path extends Shape_1$d.Shape{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=Path.parsePathData(this.data()),this.pathLength=Path.getPathLength(this.dataArray)}_sceneFunc(e){var r=this.dataArray;e.beginPath();for(var t=!1,n=0;n<r.length;n++){var a=r[n].command,u=r[n].points;switch(a){case"L":e.lineTo(u[0],u[1]);break;case"M":e.moveTo(u[0],u[1]);break;case"C":e.bezierCurveTo(u[0],u[1],u[2],u[3],u[4],u[5]);break;case"Q":e.quadraticCurveTo(u[0],u[1],u[2],u[3]);break;case"A":var l=u[0],f=u[1],c=u[2],h=u[3],y=u[4],E=u[5],p=u[6],_=u[7],g=c>h?c:h,x=c>h?1:c/h,C=c>h?h/c:1;e.translate(l,f),e.rotate(p),e.scale(x,C),e.arc(0,0,g,y,y+E,1-_),e.scale(1/x,1/C),e.rotate(-p),e.translate(-l,-f);break;case"z":t=!0,e.closePath();break}}!t&&!this.hasFill()?e.strokeShape(this):e.fillStrokeShape(this)}getSelfRect(){var e=[];this.dataArray.forEach(function(c){if(c.command==="A"){var h=c.points[4],y=c.points[5],E=c.points[4]+y,p=Math.PI/180;if(Math.abs(h-E)<p&&(p=Math.abs(h-E)),y<0)for(let _=h-p;_>E;_-=p){const g=Path.getPointOnEllipticalArc(c.points[0],c.points[1],c.points[2],c.points[3],_,0);e.push(g.x,g.y)}else for(let _=h+p;_<E;_+=p){const g=Path.getPointOnEllipticalArc(c.points[0],c.points[1],c.points[2],c.points[3],_,0);e.push(g.x,g.y)}}else if(c.command==="C")for(let _=0;_<=1;_+=.01){const g=Path.getPointOnCubicBezier(_,c.start.x,c.start.y,c.points[0],c.points[1],c.points[2],c.points[3],c.points[4],c.points[5]);e.push(g.x,g.y)}else e=e.concat(c.points)});for(var r=e[0],t=e[0],n=e[1],a=e[1],u,l,f=0;f<e.length/2;f++)u=e[f*2],l=e[f*2+1],isNaN(u)||(r=Math.min(r,u),t=Math.max(t,u)),isNaN(l)||(n=Math.min(n,l),a=Math.max(a,l));return{x:r,y:n,width:t-r,height:a-n}}getLength(){return this.pathLength}getPointAtLength(e){return Path.getPointAtLengthOfDataArray(e,this.dataArray)}static getLineLength(e,r,t,n){return Math.sqrt((t-e)*(t-e)+(n-r)*(n-r))}static getPathLength(e){let r=0;for(var t=0;t<e.length;++t)r+=e[t].pathLength;return r}static getPointAtLengthOfDataArray(e,r){var t,n=0,a=r.length;if(!a)return null;for(;n<a&&e>r[n].pathLength;)e-=r[n].pathLength,++n;if(n===a)return t=r[n-1].points.slice(-2),{x:t[0],y:t[1]};if(e<.01)return t=r[n].points.slice(0,2),{x:t[0],y:t[1]};var u=r[n],l=u.points;switch(u.command){case"L":return Path.getPointOnLine(e,u.start.x,u.start.y,l[0],l[1]);case"C":return Path.getPointOnCubicBezier((0,BezierFunctions_1.t2length)(e,Path.getPathLength(r),g=>(0,BezierFunctions_1.getCubicArcLength)([u.start.x,l[0],l[2],l[4]],[u.start.y,l[1],l[3],l[5]],g)),u.start.x,u.start.y,l[0],l[1],l[2],l[3],l[4],l[5]);case"Q":return Path.getPointOnQuadraticBezier((0,BezierFunctions_1.t2length)(e,Path.getPathLength(r),g=>(0,BezierFunctions_1.getQuadraticArcLength)([u.start.x,l[0],l[2]],[u.start.y,l[1],l[3]],g)),u.start.x,u.start.y,l[0],l[1],l[2],l[3]);case"A":var f=l[0],c=l[1],h=l[2],y=l[3],E=l[4],p=l[5],_=l[6];return E+=p*e/u.pathLength,Path.getPointOnEllipticalArc(f,c,h,y,E,_)}return null}static getPointOnLine(e,r,t,n,a,u,l){u===void 0&&(u=r),l===void 0&&(l=t);var f=(a-t)/(n-r+1e-8),c=Math.sqrt(e*e/(1+f*f));n<r&&(c*=-1);var h=f*c,y;if(n===r)y={x:u,y:l+h};else if((l-t)/(u-r+1e-8)===f)y={x:u+c,y:l+h};else{var E,p,_=this.getLineLength(r,t,n,a),g=(u-r)*(n-r)+(l-t)*(a-t);g=g/(_*_),E=r+g*(n-r),p=t+g*(a-t);var x=this.getLineLength(u,l,E,p),C=Math.sqrt(e*e-x*x);c=Math.sqrt(C*C/(1+f*f)),n<r&&(c*=-1),h=f*c,y={x:E+c,y:p+h}}return y}static getPointOnCubicBezier(e,r,t,n,a,u,l,f,c){function h(x){return x*x*x}function y(x){return 3*x*x*(1-x)}function E(x){return 3*x*(1-x)*(1-x)}function p(x){return(1-x)*(1-x)*(1-x)}var _=f*h(e)+u*y(e)+n*E(e)+r*p(e),g=c*h(e)+l*y(e)+a*E(e)+t*p(e);return{x:_,y:g}}static getPointOnQuadraticBezier(e,r,t,n,a,u,l){function f(p){return p*p}function c(p){return 2*p*(1-p)}function h(p){return(1-p)*(1-p)}var y=u*f(e)+n*c(e)+r*h(e),E=l*f(e)+a*c(e)+t*h(e);return{x:y,y:E}}static getPointOnEllipticalArc(e,r,t,n,a,u){var l=Math.cos(u),f=Math.sin(u),c={x:t*Math.cos(a),y:n*Math.sin(a)};return{x:e+(c.x*l-c.y*f),y:r+(c.x*f+c.y*l)}}static parsePathData(e){if(!e)return[];var r=e,t=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];r=r.replace(new RegExp(" ","g"),",");for(var n=0;n<t.length;n++)r=r.replace(new RegExp(t[n],"g"),"|"+t[n]);var a=r.split("|"),u=[],l=[],f=0,c=0,h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,y;for(n=1;n<a.length;n++){var E=a[n],p=E.charAt(0);for(E=E.slice(1),l.length=0;y=h.exec(E);)l.push(y[0]);for(var _=[],g=0,x=l.length;g<x;g++){if(l[g]==="00"){_.push(0,0);continue}var C=parseFloat(l[g]);isNaN(C)?_.push(0):_.push(C)}for(;_.length>0&&!isNaN(_[0]);){var R="",S=[],A=f,T=c,w,P,O,k,D,F,G,V,W,Z;switch(p){case"l":f+=_.shift(),c+=_.shift(),R="L",S.push(f,c);break;case"L":f=_.shift(),c=_.shift(),S.push(f,c);break;case"m":var q=_.shift(),z=_.shift();if(f+=q,c+=z,R="M",u.length>2&&u[u.length-1].command==="z"){for(var U=u.length-2;U>=0;U--)if(u[U].command==="M"){f=u[U].points[0]+q,c=u[U].points[1]+z;break}}S.push(f,c),p="l";break;case"M":f=_.shift(),c=_.shift(),R="M",S.push(f,c),p="L";break;case"h":f+=_.shift(),R="L",S.push(f,c);break;case"H":f=_.shift(),R="L",S.push(f,c);break;case"v":c+=_.shift(),R="L",S.push(f,c);break;case"V":c=_.shift(),R="L",S.push(f,c);break;case"C":S.push(_.shift(),_.shift(),_.shift(),_.shift()),f=_.shift(),c=_.shift(),S.push(f,c);break;case"c":S.push(f+_.shift(),c+_.shift(),f+_.shift(),c+_.shift()),f+=_.shift(),c+=_.shift(),R="C",S.push(f,c);break;case"S":P=f,O=c,w=u[u.length-1],w.command==="C"&&(P=f+(f-w.points[2]),O=c+(c-w.points[3])),S.push(P,O,_.shift(),_.shift()),f=_.shift(),c=_.shift(),R="C",S.push(f,c);break;case"s":P=f,O=c,w=u[u.length-1],w.command==="C"&&(P=f+(f-w.points[2]),O=c+(c-w.points[3])),S.push(P,O,f+_.shift(),c+_.shift()),f+=_.shift(),c+=_.shift(),R="C",S.push(f,c);break;case"Q":S.push(_.shift(),_.shift()),f=_.shift(),c=_.shift(),S.push(f,c);break;case"q":S.push(f+_.shift(),c+_.shift()),f+=_.shift(),c+=_.shift(),R="Q",S.push(f,c);break;case"T":P=f,O=c,w=u[u.length-1],w.command==="Q"&&(P=f+(f-w.points[0]),O=c+(c-w.points[1])),f=_.shift(),c=_.shift(),R="Q",S.push(P,O,f,c);break;case"t":P=f,O=c,w=u[u.length-1],w.command==="Q"&&(P=f+(f-w.points[0]),O=c+(c-w.points[1])),f+=_.shift(),c+=_.shift(),R="Q",S.push(P,O,f,c);break;case"A":k=_.shift(),D=_.shift(),F=_.shift(),G=_.shift(),V=_.shift(),W=f,Z=c,f=_.shift(),c=_.shift(),R="A",S=this.convertEndpointToCenterParameterization(W,Z,f,c,G,V,k,D,F);break;case"a":k=_.shift(),D=_.shift(),F=_.shift(),G=_.shift(),V=_.shift(),W=f,Z=c,f+=_.shift(),c+=_.shift(),R="A",S=this.convertEndpointToCenterParameterization(W,Z,f,c,G,V,k,D,F);break}u.push({command:R||p,points:S,start:{x:A,y:T},pathLength:this.calcLength(A,T,R||p,S)})}(p==="z"||p==="Z")&&u.push({command:"z",points:[],start:void 0,pathLength:0})}return u}static calcLength(e,r,t,n){var a,u,l,f,c=Path;switch(t){case"L":return c.getLineLength(e,r,n[0],n[1]);case"C":return(0,BezierFunctions_1.getCubicArcLength)([e,n[0],n[2],n[4]],[r,n[1],n[3],n[5]],1);case"Q":return(0,BezierFunctions_1.getQuadraticArcLength)([e,n[0],n[2]],[r,n[1],n[3]],1);case"A":a=0;var h=n[4],y=n[5],E=n[4]+y,p=Math.PI/180;if(Math.abs(h-E)<p&&(p=Math.abs(h-E)),u=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],h,0),y<0)for(f=h-p;f>E;f-=p)l=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],f,0),a+=c.getLineLength(u.x,u.y,l.x,l.y),u=l;else for(f=h+p;f<E;f+=p)l=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],f,0),a+=c.getLineLength(u.x,u.y,l.x,l.y),u=l;return l=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],E,0),a+=c.getLineLength(u.x,u.y,l.x,l.y),a}return 0}static convertEndpointToCenterParameterization(e,r,t,n,a,u,l,f,c){var h=c*(Math.PI/180),y=Math.cos(h)*(e-t)/2+Math.sin(h)*(r-n)/2,E=-1*Math.sin(h)*(e-t)/2+Math.cos(h)*(r-n)/2,p=y*y/(l*l)+E*E/(f*f);p>1&&(l*=Math.sqrt(p),f*=Math.sqrt(p));var _=Math.sqrt((l*l*(f*f)-l*l*(E*E)-f*f*(y*y))/(l*l*(E*E)+f*f*(y*y)));a===u&&(_*=-1),isNaN(_)&&(_=0);var g=_*l*E/f,x=_*-f*y/l,C=(e+t)/2+Math.cos(h)*g-Math.sin(h)*x,R=(r+n)/2+Math.sin(h)*g+Math.cos(h)*x,S=function(D){return Math.sqrt(D[0]*D[0]+D[1]*D[1])},A=function(D,F){return(D[0]*F[0]+D[1]*F[1])/(S(D)*S(F))},T=function(D,F){return(D[0]*F[1]<D[1]*F[0]?-1:1)*Math.acos(A(D,F))},w=T([1,0],[(y-g)/l,(E-x)/f]),P=[(y-g)/l,(E-x)/f],O=[(-1*y-g)/l,(-1*E-x)/f],k=T(P,O);return A(P,O)<=-1&&(k=Math.PI),A(P,O)>=1&&(k=0),u===0&&k>0&&(k=k-2*Math.PI),u===1&&k<0&&(k=k+2*Math.PI),[C,R,l,f,w,k,h,u]}}Path$1.Path=Path;Path.prototype.className="Path";Path.prototype._attrsAffectingSize=["data"];(0,Global_1$e._registerNode)(Path);Factory_1$t.Factory.addGetterSetter(Path,"data");Object.defineProperty(Arrow$1,"__esModule",{value:!0});Arrow$1.Arrow=void 0;const Factory_1$s=Factory,Line_1$1=Line$2,Validators_1$s=Validators,Global_1$d=Global,Path_1$2=Path$1;class Arrow extends Line_1$1.Line{_sceneFunc(e){super._sceneFunc(e);var r=Math.PI*2,t=this.points(),n=t,a=this.tension()!==0&&t.length>4;a&&(n=this.getTensionPoints());var u=this.pointerLength(),l=t.length,f,c;if(a){const E=[n[n.length-4],n[n.length-3],n[n.length-2],n[n.length-1],t[l-2],t[l-1]],p=Path_1$2.Path.calcLength(n[n.length-4],n[n.length-3],"C",E),_=Path_1$2.Path.getPointOnQuadraticBezier(Math.min(1,1-u/p),E[0],E[1],E[2],E[3],E[4],E[5]);f=t[l-2]-_.x,c=t[l-1]-_.y}else f=t[l-2]-t[l-4],c=t[l-1]-t[l-3];var h=(Math.atan2(c,f)+r)%r,y=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(t[l-2],t[l-1]),e.rotate(h),e.moveTo(0,0),e.lineTo(-u,y/2),e.lineTo(-u,-y/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(t[0],t[1]),a?(f=(n[0]+n[2])/2-t[0],c=(n[1]+n[3])/2-t[1]):(f=t[2]-t[0],c=t[3]-t[1]),e.rotate((Math.atan2(-c,-f)+r)%r),e.moveTo(0,0),e.lineTo(-u,y/2),e.lineTo(-u,-y/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){var r=this.dashEnabled();r&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),r&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),r=this.pointerWidth()/2;return{x:e.x-r,y:e.y-r,width:e.width+r*2,height:e.height+r*2}}}Arrow$1.Arrow=Arrow;Arrow.prototype.className="Arrow";(0,Global_1$d._registerNode)(Arrow);Factory_1$s.Factory.addGetterSetter(Arrow,"pointerLength",10,(0,Validators_1$s.getNumberValidator)());Factory_1$s.Factory.addGetterSetter(Arrow,"pointerWidth",10,(0,Validators_1$s.getNumberValidator)());Factory_1$s.Factory.addGetterSetter(Arrow,"pointerAtBeginning",!1);Factory_1$s.Factory.addGetterSetter(Arrow,"pointerAtEnding",!0);var Circle$1={};Object.defineProperty(Circle$1,"__esModule",{value:!0});Circle$1.Circle=void 0;const Factory_1$r=Factory,Shape_1$c=Shape,Validators_1$r=Validators,Global_1$c=Global;class Circle extends Shape_1$c.Shape{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}}Circle$1.Circle=Circle;Circle.prototype._centroid=!0;Circle.prototype.className="Circle";Circle.prototype._attrsAffectingSize=["radius"];(0,Global_1$c._registerNode)(Circle);Factory_1$r.Factory.addGetterSetter(Circle,"radius",0,(0,Validators_1$r.getNumberValidator)());var Ellipse$1={};Object.defineProperty(Ellipse$1,"__esModule",{value:!0});Ellipse$1.Ellipse=void 0;const Factory_1$q=Factory,Shape_1$b=Shape,Validators_1$q=Validators,Global_1$b=Global;class Ellipse extends Shape_1$b.Shape{_sceneFunc(e){var r=this.radiusX(),t=this.radiusY();e.beginPath(),e.save(),r!==t&&e.scale(1,t/r),e.arc(0,0,r,0,Math.PI*2,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}}Ellipse$1.Ellipse=Ellipse;Ellipse.prototype.className="Ellipse";Ellipse.prototype._centroid=!0;Ellipse.prototype._attrsAffectingSize=["radiusX","radiusY"];(0,Global_1$b._registerNode)(Ellipse);Factory_1$q.Factory.addComponentsGetterSetter(Ellipse,"radius",["x","y"]);Factory_1$q.Factory.addGetterSetter(Ellipse,"radiusX",0,(0,Validators_1$q.getNumberValidator)());Factory_1$q.Factory.addGetterSetter(Ellipse,"radiusY",0,(0,Validators_1$q.getNumberValidator)());var Image$4={};Object.defineProperty(Image$4,"__esModule",{value:!0});Image$4.Image=void 0;const Util_1$7=Util,Factory_1$p=Factory,Shape_1$a=Shape,Global_1$a=Global,Validators_1$p=Validators;let Image$3=class wv extends Shape_1$a.Shape{constructor(e){super(e),this.on("imageChange.konva",()=>{this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const e=this.image();e&&e.complete||e&&e.readyState===4||e&&e.addEventListener&&e.addEventListener("load",()=>{this._requestDraw()})}_useBufferCanvas(){return super._useBufferCanvas(!0)}_sceneFunc(e){const r=this.getWidth(),t=this.getHeight(),n=this.cornerRadius(),a=this.attrs.image;let u;if(a){const l=this.attrs.cropWidth,f=this.attrs.cropHeight;l&&f?u=[a,this.cropX(),this.cropY(),l,f,0,0,r,t]:u=[a,0,0,r,t]}(this.hasFill()||this.hasStroke()||n)&&(e.beginPath(),n?Util_1$7.Util.drawRoundedRectPath(e,r,t,n):e.rect(0,0,r,t),e.closePath(),e.fillStrokeShape(this)),a&&(n&&e.clip(),e.drawImage.apply(e,u))}_hitFunc(e){var r=this.width(),t=this.height(),n=this.cornerRadius();e.beginPath(),n?Util_1$7.Util.drawRoundedRectPath(e,r,t,n):e.rect(0,0,r,t),e.closePath(),e.fillStrokeShape(this)}getWidth(){var e,r;return(e=this.attrs.width)!==null&&e!==void 0?e:(r=this.image())===null||r===void 0?void 0:r.width}getHeight(){var e,r;return(e=this.attrs.height)!==null&&e!==void 0?e:(r=this.image())===null||r===void 0?void 0:r.height}static fromURL(e,r,t=null){var n=Util_1$7.Util.createImageElement();n.onload=function(){var a=new wv({image:n});r(a)},n.onerror=t,n.crossOrigin="Anonymous",n.src=e}};Image$4.Image=Image$3;Image$3.prototype.className="Image";(0,Global_1$a._registerNode)(Image$3);Factory_1$p.Factory.addGetterSetter(Image$3,"cornerRadius",0,(0,Validators_1$p.getNumberOrArrayOfNumbersValidator)(4));Factory_1$p.Factory.addGetterSetter(Image$3,"image");Factory_1$p.Factory.addComponentsGetterSetter(Image$3,"crop",["x","y","width","height"]);Factory_1$p.Factory.addGetterSetter(Image$3,"cropX",0,(0,Validators_1$p.getNumberValidator)());Factory_1$p.Factory.addGetterSetter(Image$3,"cropY",0,(0,Validators_1$p.getNumberValidator)());Factory_1$p.Factory.addGetterSetter(Image$3,"cropWidth",0,(0,Validators_1$p.getNumberValidator)());Factory_1$p.Factory.addGetterSetter(Image$3,"cropHeight",0,(0,Validators_1$p.getNumberValidator)());var Label$1={};Object.defineProperty(Label$1,"__esModule",{value:!0});Label$1.Tag=Label$1.Label=void 0;const Factory_1$o=Factory,Shape_1$9=Shape,Group_1$1=Group$2,Validators_1$o=Validators,Global_1$9=Global;var ATTR_CHANGE_LIST$2=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],CHANGE_KONVA$1="Change.konva",NONE$1="none",UP="up",RIGHT$1="right",DOWN="down",LEFT$1="left",attrChangeListLen$1=ATTR_CHANGE_LIST$2.length;class Label extends Group_1$1.Group{constructor(e){super(e),this.on("add.konva",function(r){this._addListeners(r.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){var r=this,t,n=function(){r._sync()};for(t=0;t<attrChangeListLen$1;t++)e.on(ATTR_CHANGE_LIST$2[t]+CHANGE_KONVA$1,n)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var e=this.getText(),r=this.getTag(),t,n,a,u,l,f,c;if(e&&r){switch(t=e.width(),n=e.height(),a=r.pointerDirection(),u=r.pointerWidth(),c=r.pointerHeight(),l=0,f=0,a){case UP:l=t/2,f=-1*c;break;case RIGHT$1:l=t+u,f=n/2;break;case DOWN:l=t/2,f=n+c;break;case LEFT$1:l=-1*u,f=n/2;break}r.setAttrs({x:-1*l,y:-1*f,width:t,height:n}),e.setAttrs({x:-1*l,y:-1*f})}}}Label$1.Label=Label;Label.prototype.className="Label";(0,Global_1$9._registerNode)(Label);class Tag extends Shape_1$9.Shape{_sceneFunc(e){var r=this.width(),t=this.height(),n=this.pointerDirection(),a=this.pointerWidth(),u=this.pointerHeight(),l=this.cornerRadius();let f=0,c=0,h=0,y=0;typeof l=="number"?f=c=h=y=Math.min(l,r/2,t/2):(f=Math.min(l[0]||0,r/2,t/2),c=Math.min(l[1]||0,r/2,t/2),y=Math.min(l[2]||0,r/2,t/2),h=Math.min(l[3]||0,r/2,t/2)),e.beginPath(),e.moveTo(f,0),n===UP&&(e.lineTo((r-a)/2,0),e.lineTo(r/2,-1*u),e.lineTo((r+a)/2,0)),e.lineTo(r-c,0),e.arc(r-c,c,c,Math.PI*3/2,0,!1),n===RIGHT$1&&(e.lineTo(r,(t-u)/2),e.lineTo(r+a,t/2),e.lineTo(r,(t+u)/2)),e.lineTo(r,t-y),e.arc(r-y,t-y,y,0,Math.PI/2,!1),n===DOWN&&(e.lineTo((r+a)/2,t),e.lineTo(r/2,t+u),e.lineTo((r-a)/2,t)),e.lineTo(h,t),e.arc(h,t-h,h,Math.PI/2,Math.PI,!1),n===LEFT$1&&(e.lineTo(0,(t+u)/2),e.lineTo(-1*a,t/2),e.lineTo(0,(t-u)/2)),e.lineTo(0,f),e.arc(f,f,f,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){var e=0,r=0,t=this.pointerWidth(),n=this.pointerHeight(),a=this.pointerDirection(),u=this.width(),l=this.height();return a===UP?(r-=n,l+=n):a===DOWN?l+=n:a===LEFT$1?(e-=t*1.5,u+=t):a===RIGHT$1&&(u+=t*1.5),{x:e,y:r,width:u,height:l}}}Label$1.Tag=Tag;Tag.prototype.className="Tag";(0,Global_1$9._registerNode)(Tag);Factory_1$o.Factory.addGetterSetter(Tag,"pointerDirection",NONE$1);Factory_1$o.Factory.addGetterSetter(Tag,"pointerWidth",0,(0,Validators_1$o.getNumberValidator)());Factory_1$o.Factory.addGetterSetter(Tag,"pointerHeight",0,(0,Validators_1$o.getNumberValidator)());Factory_1$o.Factory.addGetterSetter(Tag,"cornerRadius",0,(0,Validators_1$o.getNumberOrArrayOfNumbersValidator)(4));var Rect$2={};Object.defineProperty(Rect$2,"__esModule",{value:!0});Rect$2.Rect=void 0;const Factory_1$n=Factory,Shape_1$8=Shape,Global_1$8=Global,Util_1$6=Util,Validators_1$n=Validators;let Rect$1=class extends Shape_1$8.Shape{_sceneFunc(e){var r=this.cornerRadius(),t=this.width(),n=this.height();e.beginPath(),r?Util_1$6.Util.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}};Rect$2.Rect=Rect$1;Rect$1.prototype.className="Rect";(0,Global_1$8._registerNode)(Rect$1);Factory_1$n.Factory.addGetterSetter(Rect$1,"cornerRadius",0,(0,Validators_1$n.getNumberOrArrayOfNumbersValidator)(4));var RegularPolygon$1={};Object.defineProperty(RegularPolygon$1,"__esModule",{value:!0});RegularPolygon$1.RegularPolygon=void 0;const Factory_1$m=Factory,Shape_1$7=Shape,Validators_1$m=Validators,Global_1$7=Global;class RegularPolygon extends Shape_1$7.Shape{_sceneFunc(e){const r=this._getPoints();e.beginPath(),e.moveTo(r[0].x,r[0].y);for(var t=1;t<r.length;t++)e.lineTo(r[t].x,r[t].y);e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,r=this.attrs.radius||0,t=[];for(var n=0;n<e;n++)t.push({x:r*Math.sin(n*2*Math.PI/e),y:-1*r*Math.cos(n*2*Math.PI/e)});return t}getSelfRect(){const e=this._getPoints();var r=e[0].x,t=e[0].y,n=e[0].x,a=e[0].y;return e.forEach(u=>{r=Math.min(r,u.x),t=Math.max(t,u.x),n=Math.min(n,u.y),a=Math.max(a,u.y)}),{x:r,y:n,width:t-r,height:a-n}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}RegularPolygon$1.RegularPolygon=RegularPolygon;RegularPolygon.prototype.className="RegularPolygon";RegularPolygon.prototype._centroid=!0;RegularPolygon.prototype._attrsAffectingSize=["radius"];(0,Global_1$7._registerNode)(RegularPolygon);Factory_1$m.Factory.addGetterSetter(RegularPolygon,"radius",0,(0,Validators_1$m.getNumberValidator)());Factory_1$m.Factory.addGetterSetter(RegularPolygon,"sides",0,(0,Validators_1$m.getNumberValidator)());var Ring$1={};Object.defineProperty(Ring$1,"__esModule",{value:!0});Ring$1.Ring=void 0;const Factory_1$l=Factory,Shape_1$6=Shape,Validators_1$l=Validators,Global_1$6=Global;var PIx2=Math.PI*2;class Ring extends Shape_1$6.Shape{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,PIx2,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),PIx2,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}Ring$1.Ring=Ring;Ring.prototype.className="Ring";Ring.prototype._centroid=!0;Ring.prototype._attrsAffectingSize=["innerRadius","outerRadius"];(0,Global_1$6._registerNode)(Ring);Factory_1$l.Factory.addGetterSetter(Ring,"innerRadius",0,(0,Validators_1$l.getNumberValidator)());Factory_1$l.Factory.addGetterSetter(Ring,"outerRadius",0,(0,Validators_1$l.getNumberValidator)());var Sprite$1={};Object.defineProperty(Sprite$1,"__esModule",{value:!0});Sprite$1.Sprite=void 0;const Factory_1$k=Factory,Shape_1$5=Shape,Animation_1=Animation$2,Validators_1$k=Validators,Global_1$5=Global;class Sprite extends Shape_1$5.Shape{constructor(e){super(e),this._updated=!0,this.anim=new Animation_1.Animation(()=>{var r=this._updated;return this._updated=!1,r}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(e){var r=this.animation(),t=this.frameIndex(),n=t*4,a=this.animations()[r],u=this.frameOffsets(),l=a[n+0],f=a[n+1],c=a[n+2],h=a[n+3],y=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,c,h),e.closePath(),e.fillStrokeShape(this)),y)if(u){var E=u[r],p=t*2;e.drawImage(y,l,f,c,h,E[p+0],E[p+1],c,h)}else e.drawImage(y,l,f,c,h,0,0,c,h)}_hitFunc(e){var r=this.animation(),t=this.frameIndex(),n=t*4,a=this.animations()[r],u=this.frameOffsets(),l=a[n+2],f=a[n+3];if(e.beginPath(),u){var c=u[r],h=t*2;e.rect(c[h+0],c[h+1],l,f)}else e.rect(0,0,l,f);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){var e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(!this.isRunning()){var e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){var e=this.frameIndex(),r=this.animation(),t=this.animations(),n=t[r],a=n.length/4;e<a-1?this.frameIndex(e+1):this.frameIndex(0)}}Sprite$1.Sprite=Sprite;Sprite.prototype.className="Sprite";(0,Global_1$5._registerNode)(Sprite);Factory_1$k.Factory.addGetterSetter(Sprite,"animation");Factory_1$k.Factory.addGetterSetter(Sprite,"animations");Factory_1$k.Factory.addGetterSetter(Sprite,"frameOffsets");Factory_1$k.Factory.addGetterSetter(Sprite,"image");Factory_1$k.Factory.addGetterSetter(Sprite,"frameIndex",0,(0,Validators_1$k.getNumberValidator)());Factory_1$k.Factory.addGetterSetter(Sprite,"frameRate",17,(0,Validators_1$k.getNumberValidator)());Factory_1$k.Factory.backCompat(Sprite,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var Star$1={};Object.defineProperty(Star$1,"__esModule",{value:!0});Star$1.Star=void 0;const Factory_1$j=Factory,Shape_1$4=Shape,Validators_1$j=Validators,Global_1$4=Global;class Star extends Shape_1$4.Shape{_sceneFunc(e){var r=this.innerRadius(),t=this.outerRadius(),n=this.numPoints();e.beginPath(),e.moveTo(0,0-t);for(var a=1;a<n*2;a++){var u=a%2===0?t:r,l=u*Math.sin(a*Math.PI/n),f=-1*u*Math.cos(a*Math.PI/n);e.lineTo(l,f)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}Star$1.Star=Star;Star.prototype.className="Star";Star.prototype._centroid=!0;Star.prototype._attrsAffectingSize=["innerRadius","outerRadius"];(0,Global_1$4._registerNode)(Star);Factory_1$j.Factory.addGetterSetter(Star,"numPoints",5,(0,Validators_1$j.getNumberValidator)());Factory_1$j.Factory.addGetterSetter(Star,"innerRadius",0,(0,Validators_1$j.getNumberValidator)());Factory_1$j.Factory.addGetterSetter(Star,"outerRadius",0,(0,Validators_1$j.getNumberValidator)());var Text$2={};Object.defineProperty(Text$2,"__esModule",{value:!0});Text$2.Text=Text$2.stringToArray=void 0;const Util_1$5=Util,Factory_1$i=Factory,Shape_1$3=Shape,Validators_1$i=Validators,Global_1$3=Global;function stringToArray(o){return Array.from(o)}Text$2.stringToArray=stringToArray;var AUTO="auto",CENTER="center",INHERIT="inherit",JUSTIFY="justify",CHANGE_KONVA="Change.konva",CONTEXT_2D="2d",DASH="-",LEFT="left",TEXT="text",TEXT_UPPER="Text",TOP="top",BOTTOM="bottom",MIDDLE="middle",NORMAL$1="normal",PX_SPACE="px ",SPACE=" ",RIGHT="right",RTL="rtl",WORD="word",CHAR="char",NONE="none",ELLIPSIS="…",ATTR_CHANGE_LIST$1=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],attrChangeListLen=ATTR_CHANGE_LIST$1.length;function normalizeFontFamily(o){return o.split(",").map(e=>{e=e.trim();const r=e.indexOf(" ")>=0,t=e.indexOf('"')>=0||e.indexOf("'")>=0;return r&&!t&&(e=`"${e}"`),e}).join(", ")}var dummyContext;function getDummyContext(){return dummyContext||(dummyContext=Util_1$5.Util.createCanvasElement().getContext(CONTEXT_2D),dummyContext)}function _fillFunc$1(o){o.fillText(this._partialText,this._partialTextX,this._partialTextY)}function _strokeFunc$1(o){o.setAttr("miterLimit",2),o.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function checkDefaultFill(o){return o=o||{},!o.fillLinearGradientColorStops&&!o.fillRadialGradientColorStops&&!o.fillPatternImage&&(o.fill=o.fill||"black"),o}let Text$1=class extends Shape_1$3.Shape{constructor(e){super(checkDefaultFill(e)),this._partialTextX=0,this._partialTextY=0;for(var r=0;r<attrChangeListLen;r++)this.on(ATTR_CHANGE_LIST$1[r]+CHANGE_KONVA,this._setTextData);this._setTextData()}_sceneFunc(e){var r=this.textArr,t=r.length;if(this.text()){var n=this.padding(),a=this.fontSize(),u=this.lineHeight()*a,l=this.verticalAlign(),f=this.direction(),c=0,h=this.align(),y=this.getWidth(),E=this.letterSpacing(),p=this.fill(),_=this.textDecoration(),g=_.indexOf("underline")!==-1,x=_.indexOf("line-through")!==-1,C;f=f===INHERIT?e.direction:f;var R=0,R=u/2,S=0,A=0;for(f===RTL&&e.setAttr("direction",f),e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",MIDDLE),e.setAttr("textAlign",LEFT),l===MIDDLE?c=(this.getHeight()-t*u-n*2)/2:l===BOTTOM&&(c=this.getHeight()-t*u-n*2),e.translate(n,c+n),C=0;C<t;C++){var S=0,A=0,T=r[C],w=T.text,P=T.width,O=T.lastInParagraph,k,D,F;if(e.save(),h===RIGHT?S+=y-P-n*2:h===CENTER&&(S+=(y-P-n*2)/2),g){e.save(),e.beginPath(),e.moveTo(S,R+A+Math.round(a/2)),k=w.split(" ").length-1,D=k===0,F=h===JUSTIFY&&!O?y-n*2:P,e.lineTo(S+Math.round(F),R+A+Math.round(a/2)),e.lineWidth=a/15;const z=this._getLinearGradient();e.strokeStyle=z||p,e.stroke(),e.restore()}if(x){e.save(),e.beginPath(),e.moveTo(S,R+A),k=w.split(" ").length-1,D=k===0,F=h===JUSTIFY&&O&&!D?y-n*2:P,e.lineTo(S+Math.round(F),R+A),e.lineWidth=a/15;const z=this._getLinearGradient();e.strokeStyle=z||p,e.stroke(),e.restore()}if(f!==RTL&&(E!==0||h===JUSTIFY)){k=w.split(" ").length-1;for(var G=stringToArray(w),V=0;V<G.length;V++){var W=G[V];W===" "&&!O&&h===JUSTIFY&&(S+=(y-n*2-P)/k),this._partialTextX=S,this._partialTextY=R+A,this._partialText=W,e.fillStrokeShape(this),S+=this.measureSize(W).width+E}}else E!==0&&e.setAttr("letterSpacing",`${E}px`),this._partialTextX=S,this._partialTextY=R+A,this._partialText=w,e.fillStrokeShape(this);e.restore(),t>1&&(R+=u)}}}_hitFunc(e){var r=this.getWidth(),t=this.getHeight();e.beginPath(),e.rect(0,0,r,t),e.closePath(),e.fillStrokeShape(this)}setText(e){var r=Util_1$5.Util._isString(e)?e:e==null?"":e+"";return this._setAttr(TEXT,r),this}getWidth(){var e=this.attrs.width===AUTO||this.attrs.width===void 0;return e?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){var e=this.attrs.height===AUTO||this.attrs.height===void 0;return e?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Util_1$5.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var r=getDummyContext(),t=this.fontSize(),n;return r.save(),r.font=this._getContextFont(),n=r.measureText(e),r.restore(),{width:n.width,height:t}}_getContextFont(){return this.fontStyle()+SPACE+this.fontVariant()+SPACE+(this.fontSize()+PX_SPACE)+normalizeFontFamily(this.fontFamily())}_addTextLine(e){this.align()===JUSTIFY&&(e=e.trim());var t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){var r=this.letterSpacing(),t=e.length;return getDummyContext().measureText(e).width+(t?r*(t-1):0)}_setTextData(){var e=this.text().split(`
71
+ ${E&&R+1>=o.length?"glowing-animation":""}`,"data-testid":"btn-nxt",onClick:()=>{R+1<o.length?F():(w("click-ui"),O())},"aria-label":LangIsRtl()?c("comic.previous"):c("comic.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})}):null}function CartelComponent({img:o,text:e,audio:r,audioType:t,voice:n,emitEvent:a,soundActions:u,audioVolume:l,pause:f,keyboardControl:c}){const h=R=>a({type:"translate",payload:R}),y=(o==null?void 0:o.url)||"https://min.gamelearn.io/css-resources/gamelearn/resources/conversation.jpg",E=React$2.useRef(),p=React$2.useRef(),[_]=u;useEkho({audioType:t,voice:n,text:e,audio:r,soundActions:u,emitEvent:a,volume:l,pauseTTS:f});const g=()=>{_("click-ui"),a({type:"success"})};c(null,g,g);const x=(R,S)=>window.matchMedia("(min-width: 1280px)").matches?S:R,C=React$2.useCallback(()=>{if(e&&p.current){const R=p.current.naturalWidth/p.current.naturalHeight;let S=p.current.height*R,A=p.current.height;if(S>p.current.width&&(S=p.current.width,A=p.current.width/R),E.current.style.width=`${S}px`,window.innerHeight<p.current.width)E.current.style.bottom=`${x(24,48)+x(36,100)}px`;else{const T=(window.innerHeight-A)/2+x(36,100);E.current.style.bottom=`${T}px`}}},[e]);return React$2.useEffect(()=>{p.current&&new ResizeObserver(()=>x(24,48)&&C()).observe(p.current)}),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"cartel",children:jsxRuntimeExports.jsxs("div",{className:"cartel__imagewrap",children:[jsxRuntimeExports.jsx("img",{ref:p,onLoad:C,className:"cartel__image",src:y,alt:"cartel pic"}),e?jsxRuntimeExports.jsx("div",{ref:E,className:"cartel__textwrap",children:jsxRuntimeExports.jsx("div",{className:"cartel__text",children:jsxRuntimeExports.jsx("span",{children:e})})}):null]})}),jsxRuntimeExports.jsx("div",{className:"position--absolute center right",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__round",onClick:()=>g(),"aria-label":h("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})})]})}var Typist$1={exports:{}};(function(o){o.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var a=r[n]={exports:{},id:n,loaded:!1};return e[n].call(a.exports,a,a.exports,t),a.loaded=!0,a.exports}return t.m=e,t.c=r,t.p="",t(0)}([function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0});var n=Object.assign||function(k){for(var D=1;D<arguments.length;D++){var F=arguments[D];for(var G in F)Object.prototype.hasOwnProperty.call(F,G)&&(k[G]=F[G])}return k},a=function(){function k(D,F){for(var G=0;G<F.length;G++){var V=F[G];V.enumerable=V.enumerable||!1,V.configurable=!0,"value"in V&&(V.writable=!0),Object.defineProperty(D,V.key,V)}}return function(D,F,G){return F&&k(D.prototype,F),G&&k(D,G),D}}(),u=t(1),l=S(u),f=t(2),c=S(f),h=t(10),y=S(h),E=t(12),p=S(E),_=t(13),g=S(_),x=t(14),C=R(x);function R(k){if(k&&k.__esModule)return k;var D={};if(k!=null)for(var F in k)Object.prototype.hasOwnProperty.call(k,F)&&(D[F]=k[F]);return D.default=k,D}function S(k){return k&&k.__esModule?k:{default:k}}function A(k,D){if(!(k instanceof D))throw new TypeError("Cannot call a class as a function")}function T(k,D){if(!k)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return D&&(typeof D=="object"||typeof D=="function")?D:k}function w(k,D){if(typeof D!="function"&&D!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof D);k.prototype=Object.create(D&&D.prototype,{constructor:{value:k,enumerable:!1,writable:!0,configurable:!0}}),D&&(Object.setPrototypeOf?Object.setPrototypeOf(k,D):k.__proto__=D)}var P=["🔙","⏰"],O=function(k){w(D,k);function D(F){A(this,D);var G=T(this,(D.__proto__||Object.getPrototypeOf(D)).call(this,F));return G.state={textLines:[],isDone:!1},G.onTypingDone=function(){G.mounted&&(G.setState({isDone:!0}),G.props.onTypingDone())},G.delayGenerator=function(V,W,Z,q){var z=G.props.avgTypingDelay,U=G.props.stdTypingDelay;return G.props.delayGenerator(z,U,{line:V,lineIdx:W,character:Z,charIdx:q,defDelayGenerator:function(){var $=arguments.length>0&&arguments[0]!==void 0?arguments[0]:z,B=arguments.length>1&&arguments[1]!==void 0?arguments[1]:U;return C.gaussianRnd($,B)}})},G.typeLine=function(V,W){if(!G.mounted)return Promise.resolve();var Z=V,q=G.props.onLineTyped;return C.isBackspaceElement(V)?(V.props.delay>0&&(G.introducedDelay=V.props.delay),Z="🔙".repeat(V.props.count)):C.isDelayElement(V)&&(G.introducedDelay=V.props.ms,Z="⏰"),new Promise(function(z,U){G.setState({textLines:G.state.textLines.concat([""])},function(){C.eachPromise(Z,G.typeCharacter,Z,W).then(function(){return q(Z,W)}).then(z).catch(U)})})},G.typeCharacter=function(V,W,Z,q){if(!G.mounted)return Promise.resolve();var z=G.props.onCharacterTyped;return new Promise(function(U){var I=G.state.textLines.slice();C.sleep(G.introducedDelay).then(function(){G.introducedDelay=null;var $=V==="🔙",B=V==="⏰";if(B){U();return}if($&&q>0){for(var X=q-1,Q=I[X],J=X;J>=0&&!(Q.length>0&&!P.includes(Q[0]));J--)X=J,Q=I[X];I[X]=Q.substr(0,Q.length-1)}else I[q]+=V;G.setState({textLines:I},function(){var ne=G.delayGenerator(Z,q,V,W);z(V,W),setTimeout(U,ne)})})})},G.mounted=!1,G.linesToType=[],G.introducedDelay=null,F.children&&(G.linesToType=C.extractTextFromElement(F.children)),G}return a(D,[{key:"componentDidMount",value:function(){this.mounted=!0;var G=this.props,V=G.children,W=G.startDelay;V?W>0&&typeof window<"u"?setTimeout(this.typeAllLines.bind(this),W):this.typeAllLines():this.onTypingDone()}},{key:"shouldComponentUpdate",value:function(G,V){if(V.textLines.length!==this.state.textLines.length)return!0;for(var W=0;W<V.textLines.length;W++){var Z=this.state.textLines[W],q=V.textLines[W];if(Z!==q)return!0}return this.state.isDone!==V.isDone}},{key:"componentWillUnmount",value:function(){this.mounted=!1}},{key:"typeAllLines",value:function(){var G=this,V=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.linesToType;return C.eachPromise(V,this.typeLine).then(function(){return G.onTypingDone()})}},{key:"render",value:function(){var G=this.props,V=G.className,W=G.cursor,Z=this.state.isDone,q=C.cloneElementWithSpecifiedText({element:this.props.children,textLines:this.state.textLines});return l.default.createElement("div",{className:"Typist "+V},q,l.default.createElement(y.default,n({isDone:Z},W)))}}]),D}(u.Component);O.propTypes={children:c.default.node,className:c.default.string,avgTypingDelay:c.default.number,stdTypingDelay:c.default.number,startDelay:c.default.number,cursor:c.default.object,onCharacterTyped:c.default.func,onLineTyped:c.default.func,onTypingDone:c.default.func,delayGenerator:c.default.func},O.defaultProps={className:"",avgTypingDelay:70,stdTypingDelay:25,startDelay:0,cursor:{},onCharacterTyped:function(){},onLineTyped:function(){},onTypingDone:function(){},delayGenerator:C.gaussianRnd},r.default=O,O.Backspace=p.default,O.Delay=g.default},function(e,r){e.exports=React$2},function(e,r,t){if(process.env.NODE_ENV!=="production"){var n=typeof Symbol=="function"&&Symbol.for&&Symbol.for("react.element")||60103,a=function(l){return typeof l=="object"&&l!==null&&l.$$typeof===n},u=!0;e.exports=t(3)(a,u)}else e.exports=t(9)()},function(e,r,t){var n=t(4),a=t(5),u=t(6),l=t(7),f=t(8);e.exports=function(c,h){var y=typeof Symbol=="function"&&Symbol.iterator,E="@@iterator";function p(I){var $=I&&(y&&I[y]||I[E]);if(typeof $=="function")return $}var _="<<anonymous>>",g={array:S("array"),bool:S("boolean"),func:S("function"),number:S("number"),object:S("object"),string:S("string"),symbol:S("symbol"),any:A(),arrayOf:T,element:w(),instanceOf:P,node:F(),objectOf:k,oneOf:O,oneOfType:D,shape:G};function x(I,$){return I===$?I!==0||1/I===1/$:I!==I&&$!==$}function C(I){this.message=I,this.stack=""}C.prototype=Error.prototype;function R(I){if(process.env.NODE_ENV!=="production")var $={},B=0;function X(J,ne,se,ee,ie,oe,fe){if(ee=ee||_,oe=oe||se,fe!==l){if(h)a(!1,"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");else if(process.env.NODE_ENV!=="production"&&typeof console<"u"){var de=ee+":"+se;!$[de]&&B<3&&(u(!1,"You are manually calling a React.PropTypes validation function for the `%s` prop on `%s`. 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.",oe,ee),$[de]=!0,B++)}}return ne[se]==null?J?ne[se]===null?new C("The "+ie+" `"+oe+"` is marked as required "+("in `"+ee+"`, but its value is `null`.")):new C("The "+ie+" `"+oe+"` is marked as required in "+("`"+ee+"`, but its value is `undefined`.")):null:I(ne,se,ee,ie,oe)}var Q=X.bind(null,!1);return Q.isRequired=X.bind(null,!0),Q}function S(I){function $(B,X,Q,J,ne,se){var ee=B[X],ie=Z(ee);if(ie!==I){var oe=q(ee);return new C("Invalid "+J+" `"+ne+"` of type "+("`"+oe+"` supplied to `"+Q+"`, expected ")+("`"+I+"`."))}return null}return R($)}function A(){return R(n.thatReturnsNull)}function T(I){function $(B,X,Q,J,ne){if(typeof I!="function")return new C("Property `"+ne+"` of component `"+Q+"` has invalid PropType notation inside arrayOf.");var se=B[X];if(!Array.isArray(se)){var ee=Z(se);return new C("Invalid "+J+" `"+ne+"` of type "+("`"+ee+"` supplied to `"+Q+"`, expected an array."))}for(var ie=0;ie<se.length;ie++){var oe=I(se,ie,Q,J,ne+"["+ie+"]",l);if(oe instanceof Error)return oe}return null}return R($)}function w(){function I($,B,X,Q,J){var ne=$[B];if(!c(ne)){var se=Z(ne);return new C("Invalid "+Q+" `"+J+"` of type "+("`"+se+"` supplied to `"+X+"`, expected a single ReactElement."))}return null}return R(I)}function P(I){function $(B,X,Q,J,ne){if(!(B[X]instanceof I)){var se=I.name||_,ee=U(B[X]);return new C("Invalid "+J+" `"+ne+"` of type "+("`"+ee+"` supplied to `"+Q+"`, expected ")+("instance of `"+se+"`."))}return null}return R($)}function O(I){if(!Array.isArray(I))return process.env.NODE_ENV!=="production"&&u(!1,"Invalid argument supplied to oneOf, expected an instance of array."),n.thatReturnsNull;function $(B,X,Q,J,ne){for(var se=B[X],ee=0;ee<I.length;ee++)if(x(se,I[ee]))return null;var ie=JSON.stringify(I);return new C("Invalid "+J+" `"+ne+"` of value `"+se+"` "+("supplied to `"+Q+"`, expected one of "+ie+"."))}return R($)}function k(I){function $(B,X,Q,J,ne){if(typeof I!="function")return new C("Property `"+ne+"` of component `"+Q+"` has invalid PropType notation inside objectOf.");var se=B[X],ee=Z(se);if(ee!=="object")return new C("Invalid "+J+" `"+ne+"` of type "+("`"+ee+"` supplied to `"+Q+"`, expected an object."));for(var ie in se)if(se.hasOwnProperty(ie)){var oe=I(se,ie,Q,J,ne+"."+ie,l);if(oe instanceof Error)return oe}return null}return R($)}function D(I){if(!Array.isArray(I))return process.env.NODE_ENV!=="production"&&u(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),n.thatReturnsNull;for(var $=0;$<I.length;$++){var B=I[$];if(typeof B!="function")return u(!1,"Invalid argument supplid to oneOfType. Expected an array of check functions, but received %s at index %s.",z(B),$),n.thatReturnsNull}function X(Q,J,ne,se,ee){for(var ie=0;ie<I.length;ie++){var oe=I[ie];if(oe(Q,J,ne,se,ee,l)==null)return null}return new C("Invalid "+se+" `"+ee+"` supplied to "+("`"+ne+"`."))}return R(X)}function F(){function I($,B,X,Q,J){return V($[B])?null:new C("Invalid "+Q+" `"+J+"` supplied to "+("`"+X+"`, expected a ReactNode."))}return R(I)}function G(I){function $(B,X,Q,J,ne){var se=B[X],ee=Z(se);if(ee!=="object")return new C("Invalid "+J+" `"+ne+"` of type `"+ee+"` "+("supplied to `"+Q+"`, expected `object`."));for(var ie in I){var oe=I[ie];if(oe){var fe=oe(se,ie,Q,J,ne+"."+ie,l);if(fe)return fe}}return null}return R($)}function V(I){switch(typeof I){case"number":case"string":case"undefined":return!0;case"boolean":return!I;case"object":if(Array.isArray(I))return I.every(V);if(I===null||c(I))return!0;var $=p(I);if($){var B=$.call(I),X;if($!==I.entries){for(;!(X=B.next()).done;)if(!V(X.value))return!1}else for(;!(X=B.next()).done;){var Q=X.value;if(Q&&!V(Q[1]))return!1}}else return!1;return!0;default:return!1}}function W(I,$){return I==="symbol"||$["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&$ instanceof Symbol}function Z(I){var $=typeof I;return Array.isArray(I)?"array":I instanceof RegExp?"object":W($,I)?"symbol":$}function q(I){if(typeof I>"u"||I===null)return""+I;var $=Z(I);if($==="object"){if(I instanceof Date)return"date";if(I instanceof RegExp)return"regexp"}return $}function z(I){var $=q(I);switch($){case"array":case"object":return"an "+$;case"boolean":case"date":case"regexp":return"a "+$;default:return $}}function U(I){return!I.constructor||!I.constructor.name?_:I.constructor.name}return g.checkPropTypes=f,g.PropTypes=g,g}},function(e,r){function t(a){return function(){return a}}var n=function(){};n.thatReturns=t,n.thatReturnsFalse=t(!1),n.thatReturnsTrue=t(!0),n.thatReturnsNull=t(null),n.thatReturnsThis=function(){return this},n.thatReturnsArgument=function(a){return a},e.exports=n},function(e,r){var t=function(u){};process.env.NODE_ENV!=="production"&&(t=function(u){if(u===void 0)throw new Error("invariant requires an error message argument")});function n(a,u,l,f,c,h,y,E){if(t(u),!a){var p;if(u===void 0)p=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var _=[l,f,c,h,y,E],g=0;p=new Error(u.replace(/%s/g,function(){return _[g++]})),p.name="Invariant Violation"}throw p.framesToPop=1,p}}e.exports=n},function(e,r,t){var n=t(4),a=n;process.env.NODE_ENV!=="production"&&function(){var u=function(f){for(var c=arguments.length,h=Array(c>1?c-1:0),y=1;y<c;y++)h[y-1]=arguments[y];var E=0,p="Warning: "+f.replace(/%s/g,function(){return h[E++]});typeof console<"u"&&console.error(p);try{throw new Error(p)}catch{}};a=function(f,c){if(c===void 0)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(c.indexOf("Failed Composite propType: ")!==0&&!f){for(var h=arguments.length,y=Array(h>2?h-2:0),E=2;E<h;E++)y[E-2]=arguments[E];u.apply(void 0,[c].concat(y))}}}(),e.exports=a},function(e,r){var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=t},function(e,r,t){if(process.env.NODE_ENV!=="production")var n=t(5),a=t(6),u=t(7),l={};function f(c,h,y,E,p){if(process.env.NODE_ENV!=="production"){for(var _ in c)if(c.hasOwnProperty(_)){var g;try{n(typeof c[_]=="function","%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",E||"React class",y,_),g=c[_](h,_,E,y,null,u)}catch(C){g=C}if(a(!g||g instanceof Error,"%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. 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||"React class",y,_,typeof g),g instanceof Error&&!(g.message in l)){l[g.message]=!0;var x=p?p():"";a(!1,"Failed %s type: %s%s",y,g.message,x??"")}}}}e.exports=f},function(e,r,t){var n=t(4),a=t(5),u=t(7);e.exports=function(){function l(h,y,E,p,_,g){g!==u&&a(!1,"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")}l.isRequired=l;function f(){return l}var c={array:l,bool:l,func:l,number:l,object:l,string:l,symbol:l,any:l,arrayOf:f,element:l,instanceOf:f,node:l,objectOf:f,oneOf:f,oneOfType:f,shape:f};return c.checkPropTypes=n,c.PropTypes=c,c}},function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0});var n=function(){function _(g,x){for(var C=0;C<x.length;C++){var R=x[C];R.enumerable=R.enumerable||!1,R.configurable=!0,"value"in R&&(R.writable=!0),Object.defineProperty(g,R.key,R)}}return function(g,x,C){return x&&_(g.prototype,x),C&&_(g,C),g}}(),a=t(1),u=c(a),l=t(2),f=c(l);t(11);function c(_){return _&&_.__esModule?_:{default:_}}function h(_,g){if(!(_ instanceof g))throw new TypeError("Cannot call a class as a function")}function y(_,g){if(!_)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:_}function E(_,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);_.prototype=Object.create(g&&g.prototype,{constructor:{value:_,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(_,g):_.__proto__=g)}var p=function(_){E(g,_);function g(x){h(this,g);var C=y(this,(g.__proto__||Object.getPrototypeOf(g)).call(this,x));return C._isReRenderingCursor=!1,C.state={shouldRender:C.props.show},C}return n(g,[{key:"componentWillReceiveProps",value:function(C){var R=this,S=!this.props.isDone&&C.isDone&&this.props.hideWhenDone;S&&setTimeout(function(){return R.setState({shouldRender:!1})},this.props.hideWhenDoneDelay)}},{key:"componentDidUpdate",value:function(){var C=this.props,R=C.show,S=C.isDone;R&&(S||this._isReRenderingCursor||this._reRenderCursor())}},{key:"_reRenderCursor",value:function(){var C=this;this._isReRenderingCursor=!0,this.setState({shouldRender:!1},function(){C.setState({shouldRender:!0},function(){C._isReRenderingCursor=!1})})}},{key:"render",value:function(){if(this.state.shouldRender){var C=this.props.blink?" Cursor--blinking":"";return u.default.createElement("span",{className:"Cursor"+C},this.props.element)}return null}}]),g}(a.Component);p.propTypes={blink:f.default.bool,show:f.default.bool,element:f.default.node,hideWhenDone:f.default.bool,hideWhenDoneDelay:f.default.number,isDone:f.default.bool},p.defaultProps={blink:!0,show:!0,element:"|",hideWhenDone:!1,hideWhenDoneDelay:1e3,isDone:!1},r.default=p},function(e,r){},function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0});var n=t(1),a=f(n),u=t(2),l=f(u);function f(h){return h&&h.__esModule?h:{default:h}}var c=function(){return a.default.createElement("noscript",null)};c.componentName="Backspace",c.propTypes={count:l.default.number,delay:l.default.number},c.defaultProps={count:1,delay:0},r.default=c},function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0});var n=t(1),a=f(n),u=t(2),l=f(u);function f(h){return h&&h.__esModule?h:{default:h}}var c=function(){return a.default.createElement("noscript",null)};c.componentName="Delay",c.propTypes={ms:l.default.number.isRequired},r.default=c},function(e,r,t){Object.defineProperty(r,"__esModule",{value:!0}),r.sleep=void 0;var n=function(){function R(S,A){var T=[],w=!0,P=!1,O=void 0;try{for(var k=S[Symbol.iterator](),D;!(w=(D=k.next()).done)&&(T.push(D.value),!(A&&T.length===A));w=!0);}catch(F){P=!0,O=F}finally{try{!w&&k.return&&k.return()}finally{if(P)throw O}}return T}return function(S,A){if(Array.isArray(S))return S;if(Symbol.iterator in Object(S))return R(S,A);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();r.gaussianRnd=c,r.eachPromise=h,r.exclude=y,r.isBackspaceElement=E,r.isDelayElement=p,r.extractTextFromElement=_,r.cloneElement=g,r.cloneElementWithSpecifiedText=C;var a=t(1),u=l(a);function l(R){return R&&R.__esModule?R:{default:R}}function f(R){if(Array.isArray(R)){for(var S=0,A=Array(R.length);S<R.length;S++)A[S]=R[S];return A}else return Array.from(R)}r.sleep=function(S){return new Promise(function(A){return S!=null?setTimeout(A,S):A()})};function c(R,S){for(var A=12,T=0,w=0;w<A;w++)T+=Math.random();return T-=A/2,Math.round(T*S)+R}function h(R,S){for(var A=arguments.length,T=Array(A>2?A-2:0),w=2;w<A;w++)T[w-2]=arguments[w];var P=function(k,D,F){return k.then(function(){return S.apply(void 0,[D,F].concat(T))})};return Array.from(R).reduce(P,Promise.resolve())}function y(R,S){var A={};for(var T in R)S.indexOf(T)===-1&&(A[T]=R[T]);return A}function E(R){return R&&R.type&&R.type.componentName==="Backspace"}function p(R){return R&&R.type&&R.type.componentName==="Delay"}function _(R){for(var S=R?[R]:[],A=[];S.length>0;){var T=S.pop();if(u.default.isValidElement(T))E(T)||p(T)?A.unshift(T):u.default.Children.forEach(T.props.children,function(G){S.push(G)});else if(Array.isArray(T)){var w=!0,P=!1,O=void 0;try{for(var k=T[Symbol.iterator](),D;!(w=(D=k.next()).done);w=!0){var F=D.value;S.push(F)}}catch(G){P=!0,O=G}finally{try{!w&&k.return&&k.return()}finally{if(P)throw O}}}else A.unshift(T)}return A}function g(R,S){var A=R.type,T=y(R.props,["children"]),w=new Date().getUTCMilliseconds(),P=w+Math.random()+Math.random();return T.key="Typist-element-"+A+"-"+P,u.default.createElement.apply(u.default,[A,T].concat(f(S)))}function x(R,S,A){if(A>=S.length)return[null,A];var T=A,w=function(F){var G=x(F,S,T),V=n(G,2),W=V[0],Z=V[1];return T=Z,W},P=u.default.isValidElement(R)&&!(E(R)||p(R));if(P){var O=u.default.Children.map(R.props.children,w)||[];return[g(R,O),T]}if(Array.isArray(R)){var k=R.map(w);return[k,T]}return[S[T],T+1]}function C(R){var S=R.element,A=R.textLines;if(S)return x(S,A,0)[0]}}])})(Typist$1);var TypistExports=Typist$1.exports;const Typist=getDefaultExportFromCjs(TypistExports),languages={js:["var rows = prompt('How many rows for your multiplication table?');","var cols = prompt('How many columns for your multiplication table?');"," ","if(rows == '' || rows == null)"," rows = 10;"," ","if(cols== '' || cols== null)"," cols = 10;"," ","createTable(rows, cols);"," ","function createTable(rows, cols)","{"," var j=1;"," var output = '<table border='1' width='500' cellspacing='0'cellpadding='5'>';"," "," for(i=1;i<=rows;i++)"," {"," output = output + '<tr>';"," while(j<=cols)"," {"," output = output + '<td>' + i*j + '</td>';"," j = j+1;"," }"," output = output + '</tr>';"," j = 1;"," }"," "," output = output + '</table>';"," document.write(output);","}"],lua:["-- Ensure that that the element at i is in the right position,","-- and return a closure which can be used for continuing the sort."," ","function quicksorter(i, vec, low, high)"," if low >= high then"," return quicksorter"," else -- low < high"," -- partition the vector and initialize the child closures"," local middle = partition(vec, low, high)"," local left, right = quicksorter"," ","-- Create the promise"," local function self(i, vec, low, high)"," if i < middle then"," left = left(i, vec, low, middle-1)"," return self"," elseif i > middle then"," right = right(i, vec, middle+1, high)"," return self"," end"," end"," ","-- Force the promise until i is in the right position"," return self(i, vec, low, high)"," end","end"," ","function lazysort(vec, low, high)"," local sorter = quicksorter"," return function(i)"," sorter = sorter(i, vec, low, high)"," return vec[i]"," end","end"],python:["#ask the user to enter four pieces of information"," ","firstname = input('Enter your first name: ')","surname = input('Enter your surname: ')","email = input('Enter your email: ')","yearsteaching = input('Enter the number of years teaching: ')"," ","file = open('staff.csv','r') #opens the file in read mode","found=False #sets whether the user is found to False"," ","for line in file: #reads each line in the file"," staff = line.split(',') #splits the line into the list called staff"," if staff[2] == email: #checks if the email entered is in the list"," found=True #if it is changes found to True"," ","file.close() #closes the file"," ","if found==True: #after the loop checks if the user is found"," print('Staff member already exists in the file') #displays on screen","else:"," #if the email was not in the file"," writefile=open('staff.csv','a') #open the file in append mode"," writefile.write(firstname + ',' + surname + ',' + email + ',' + yearsteaching) #write the new information to the file"," writefile.close() #close the file"," print('Staff member added to file')"]},themes={theme1:{bg:1,color:1,typo:2},theme2:{bg:3,color:2,typo:3},theme3:{bg:5,color:4,typo:1},theme4:{bg:1,color:3,typo:2},theme5:{bg:2,color:5,typo:1},theme6:{bg:5,color:6,typo:2},theme7:{bg:1,color:7,typo:3}};function ProgressBar({progress:o,type:e}){const r=languages[e];if(r){const t=r.reduce((u,l)=>(u.length?u.length:u)+l.length),n=Math.floor(o*100/t),a=n===100?"puzzle--hacker__percentage percentage--label":"puzzle--hacker__percentage";return jsxRuntimeExports.jsx("div",{className:"puzzle--hacker__progress",children:jsxRuntimeExports.jsx("span",{className:"puzzle--hacker__progress--item",style:{width:`${Math.floor(o*100/t)}%`},children:jsxRuntimeExports.jsxs("span",{className:a,children:[n,"%"]})})})}return null}function Code({codeContainer:o}){const e=o,r=e.split("<br>");return r.length>0?r.map((t,n)=>{const a=t.replace(/ /g," ");return jsxRuntimeExports.jsx("p",{children:a},`line_${0+n}`)}):jsxRuntimeExports.jsx("p",{children:e})}function HackerPuzzleComponent({emitEvent:o,soundActions:e,info:r,themeNumber:t,type:n,writingSpeed:a,disableExit:u,setResolveAction:l}){const f=W=>o({type:"translate",payload:W}),[c]=e,{solution:h}=r,E=themes[`theme${t||1}`],[p,_]=React$2.useState(""),[g,x]=React$2.useState(0),[C,R]=React$2.useState(0),[S,A]=React$2.useState(!1),[T,w]=React$2.useState({start:0,end:0}),P=React$2.useRef(),O=React$2.useRef(),k=f("puzzle.hacker.congratulations"),D=(W,Z)=>W>Z.length?Z.length:W,F=()=>{c("click-ui");const{rewards:W}=h.right;o({type:"addPoints",complex:!0,finish:!0,payload:W}),o({type:"passPuzzle"})};React$2.useEffect(()=>{P.current.focus(),S&&u(!0)},[S]),React$2.useEffect(()=>{l(W=>{c("score"),A(!0),o({type:"hidePuzzleButtons",payload:!1}),W()})},[l]);const G=()=>{if(languages[n]&&!S){O.current&&(O.current.scrollTop=P.current.scrollHeight);const W=languages[n],Z=W[g],q=W.reduce((U,I)=>(U.length?U.length:U)+I.length),z=a>0?a:Math.floor(q/50)+g;if(Z){const U=Z.split(""),I=D(T.end,U),$=U.slice(T.start,I),B=p+$.join("");R(C+$.join("").length),_(B),I===U.length?g+1>=W.length?(c("score"),A(!0)):(x(g+1),_(`${p+$.join("")}<br>`),w({start:0,end:D(z,U)})):w({start:I,end:D(I+z,U)})}}},V=W=>{W.preventDefault(),G()};return jsxRuntimeExports.jsxs("div",{role:"button",tabIndex:0,"data-testid":"hacker",ref:P,onKeyDown:V,onTouchStart:V,className:`puzzle--hacker__container background-hacker-${E.bg}`,children:[jsxRuntimeExports.jsx("div",{className:"puzzle--hacker__header",children:jsxRuntimeExports.jsx("span",{className:"title",children:"Console"})}),jsxRuntimeExports.jsxs("div",{className:`puzzle--hacker__body color-hacker-${E.color} typography-hacker-${E.typo}`,children:[jsxRuntimeExports.jsxs("div",{className:"puzzle--hacker__code",ref:O,children:[jsxRuntimeExports.jsx(Code,{codeContainer:p}),S?jsxRuntimeExports.jsxs(Typist,{avgTypingDelay:110,onCharacterTyped:()=>{O.current&&(O.current.scrollTop=P.current.scrollHeight)},cursor:{hideWhenDone:!0},className:"puzzle--hacker__result",children:[jsxRuntimeExports.jsx(Typist.Delay,{ms:300}),h.right.desc?`// ${h.right.desc}`:`${k}`]}):null]}),jsxRuntimeExports.jsx(ProgressBar,{type:n,progress:C})]}),S?jsxRuntimeExports.jsx("div",{className:"position--absolute bottom center",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary gat--btn__cracker",onClick:F,children:f("screens.continue")})}):null]})}HackerPuzzleComponent.defaultProps={type:"",writingSpeed:0,context:{},info:{},themeNumber:1};const imagenPorDefecto="https://min.gamelearn.io/css-resources/gamelearn/resources/puzzle-login-low.png";function LoginPuzzleComponent({emitEvent:o,soundActions:e,info:r,user:t,login:n,password:a,image:u,setResolveAction:l,nodeId:f}){var I;const c=$=>o({type:"translate",payload:$}),h=`login-puzzle_${f}`,y=LangIsRtl(),[E,p]=React$2.useState(""),[_,g]=React$2.useState(""),[x,C]=React$2.useState(!1),[R,S]=React$2.useState(""),[A,T]=React$2.useState(""),[w,P]=React$2.useState(!1),[O,k]=React$2.useState(!1),[D,F]=React$2.useState(!1),[G]=e,[V,W]=React$2.useState([]),Z=((I=u.img)==null?void 0:I.url)||imagenPorDefecto,q=()=>{const{rewards:$}=r.solution.right,B=[...V,...$];o({type:"addPoints",complex:!0,finish:!0,payload:B}),o({type:"passPuzzle"})},z=()=>{G("click-ui");const $={login:!0,password:!1};n&&($.login=t===E),$.password=a===_,$.login&&$.password?(T("success"),P(!0),k(!1),G("score"),setTimeout(()=>{q()},2e3)):(W([...V,...r.solution.wrong.rewards]),G("fail"),T("failed"),k(!0),o({type:"failPuzzle"}))},U=$=>{let B="";if($.length>=0){for(let X=0;X<$.length;X+=1)B+="•";S(B)}};return React$2.useEffect(()=>{l(()=>{const $=[...V,...r.resolve.rewards];F(!0),setTimeout(()=>{o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:h,rewards:$,finish:!0}})},2e3)})},[V,r.resolve.rewards,o,l,h]),jsxRuntimeExports.jsx("div",{className:"puzzle--layer",style:{backgroundImage:`url("${Z}")`},children:jsxRuntimeExports.jsxs("div",{className:`puzzle--login ${t?"puzzle--login--withuser":""}`,children:[jsxRuntimeExports.jsx("span",{className:"icon-login-puzzle",children:" "}),jsxRuntimeExports.jsx("span",{className:"puzzle--login__title",children:c("puzzle.initSession")}),jsxRuntimeExports.jsxs("div",{children:[n&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--login__label",children:c("puzzle.user")}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:"puzzle--login__group",children:[D?jsxRuntimeExports.jsx("input",{dir:y?"rtl":"auto",disabled:w,"data-testid":"username",className:"puzzle--login__input success",type:"text",placeholder:t,value:t}):jsxRuntimeExports.jsx("input",{dir:y?"rtl":"auto",disabled:w,"data-testid":"username",className:`puzzle--login__input ${A}`,type:"text",placeholder:c("puzzle.user"),onChange:$=>{p($.target.value),T(""),k(!1)}}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check",children:" "})]})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--login__label",children:jsxRuntimeExports.jsx("span",{children:c("puzzle.password")})}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:"puzzle--login__group",children:[D?jsxRuntimeExports.jsx("input",{dir:y?"rtl":"auto",disabled:!0,"data-testid":"password",className:"puzzle--login__input puzzle--login__input--fakepassword success",type:"text",placeholder:a,value:a,style:{opacity:1}}):jsxRuntimeExports.jsx("input",{dir:y?"rtl":"auto",disabled:w,"data-testid":"password",className:`puzzle--login__input puzzle--login__input--fakepassword ${A}`,type:"text",placeholder:c("puzzle.password"),onFocus:()=>{C(!0)},onBlur:()=>{C(!1)},onChange:$=>{g($.target.value),U($.target.value),T(""),k(!1)}}),D?null:jsxRuntimeExports.jsx("div",{dir:y?"rtl":"auto",className:`login-fakepassword${x?" login-fakepassword--focus":""}${R.length?" login-fakepassword--fill":""} ${A||""}`,children:_?R:c("puzzle.password")}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check",children:" "})]})]})]}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${_.length!==0&&!w?"":"disabled"}`,onClick:z,children:c("puzzle.loginIn")}),!D&&O&&r.solution.wrong.desc!==""&&jsxRuntimeExports.jsx("div",{className:"puzzle--login__label--error",children:r.solution.wrong.desc})]})})}function FeedbackComponent$1({text:o,success:e,playSound:r,additionalStyle:t,functionOnClose:n,secondText:a,translate:u,shortText:l,hasTimeout:f,delay:c,timeExpired:h,keyboardControl:y}){const[E,p]=React$2.useState();React$2.useEffect(()=>{let x;return r&&r(e?"score":"fail"),o&&!l&&(x=setTimeout(()=>{p(!0)},1e3)),()=>{x&&clearTimeout(x)}},[r,e,l,o]),React$2.useEffect(()=>{let x;return f&&n&&(x=setTimeout(n,c)),()=>{x&&clearTimeout(x)}},[c,n,f]);const _=()=>e?"success":"failed",g=()=>e?"icon-correct-thumb":h?"icon-times-up":"icon-incorrect-thumb";return y(null,o&&n&&E?n:null,o&&n&&E||n&&l?n:null),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:`feedback-layer ${E?"feedback-layer--withexplain":""}`,children:[jsxRuntimeExports.jsxs("div",{className:`feedback-layer__header ${l?"feedback-layer__header--in-shortText":""} ${t||""} ${_()}`,children:[a&&jsxRuntimeExports.jsxs("span",{className:"puzzle--terminal__visor--file",children:[jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__icon ${t||""}`}),jsxRuntimeExports.jsx("span",{children:a})]}),jsxRuntimeExports.jsx("span",{className:"feedback-layer__maintitle",children:!o||!l?jsxRuntimeExports.jsx("div",{title:u(`tooltip.${e?"correct":"incorrect"}`),className:`${g()}`}):o}),l&&jsxRuntimeExports.jsx("button",{type:"button",className:"feedback-layer__closeX",onClick:()=>n(),"aria-label":u("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})]}),!l&&o!==""&&jsxRuntimeExports.jsx("div",{className:"feedback-layer__explainwrap",children:jsxRuntimeExports.jsxs("div",{className:"feedback-layer__explain",children:[jsxRuntimeExports.jsx("div",{dir:"auto",children:o}),o&&n&&E&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__navigation",onClick:()=>n(),"aria-label":u("storylines.misc.closePiece"),style:{display:"flex",margin:"auto",marginTop:"24px"},children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})})]})})}FeedbackComponent$1.defaultProps={text:"",hasTimeout:!1,delay:3e3,success:!1};const KeyboardPuzzleComponent=({emitEvent:o,image:e,password:r,keyboard:t,info:n,disableExit:a,soundActions:u,setResolveAction:l,nodeId:f,keyboardControl:c,styles:h="default-theme"})=>{var z,U;const[y,E]=React$2.useState(""),[p,_]=React$2.useState(""),[g,x]=React$2.useState(!1),[C,R]=React$2.useState(""),[S,A]=React$2.useState(!1),[T,w]=React$2.useState([]),P=I=>o({type:"translate",payload:I}),O=`keyboard-puzzle_${f}`,[k]=u,D=React$2.useCallback(I=>{x(!1),A(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"addPoints",complex:!0,finish:!0,payload:I})},[o]),F=()=>{if(g){const{rewards:I}=n.solution.right,$=[...T,...I];k("score"),D($)}else o({type:"hidePuzzleButtons",payload:!1}),x(!1),a(!1),A(!1);R("")},G=I=>{I===r?(a(!1),E("success"),k("score"),o({type:"passPuzzle"}),x(!0),A(!0),n.solution.right.desc?R(n.solution.right.desc):setTimeout(()=>{const{rewards:$}=n.solution.right,B=[...T,...$];D(B)},3e3)):(A(!0),E("failed"),k("fail"),o({type:"failPuzzle"}),x(!1),w([...T,...n.solution.wrong.rewards]),o({type:"hidePuzzleButtons",payload:!1}),E(""),_(""),A(!0),n.solution.wrong.desc?R(n.solution.wrong.desc):setTimeout(()=>{F()},3e3))};React$2.useEffect(()=>{l(()=>{a(!1),k("score"),E("success"),x(!0),R(n.solution.right.desc),_(r);const I=[...T,...n.resolve.rewards];setTimeout(()=>{x(!1),A(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:O,rewards:I,finish:!0}})},2e3)})},[l,a,n.solution.right.desc,k,n.resolve.rewards,T,r,o,O]);const V=(I,$)=>{const B=t[I][$];k("click-ui"),p.length<r.length+1&&(_(p+B),p.length+1===r.length&&G(p+B))},W=()=>{k("click-ui"),_(p.substring(0,p.length-1))},q={backgroundImage:`url("${((z=e.img)==null?void 0:z.url)||""}")`,backgroudPosition:"center center"};return jsxRuntimeExports.jsxs("div",{className:`puzzle-keyboard puzzle-keyboard--${h}`,style:(U=e.img)!=null&&U.url?q:null,children:[jsxRuntimeExports.jsx("div",{className:"puzzle-keyboard__header",children:jsxRuntimeExports.jsxs("div",{className:"puzzle-keyboard__digits",children:[r.split("").map((I,$)=>jsxRuntimeExports.jsx("div",{className:`puzzle-keyboard__digit ${y}`,children:p.split("")[$]?p.split("")[$]:""},`${I+$}`)),y!==""?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:y==="success"?jsxRuntimeExports.jsx("span",{className:"puzzle-keyboard__positionatedToDigits icon-mini-check-circle"}):jsxRuntimeExports.jsx("span",{className:"puzzle-keyboard__positionatedToDigits icon-mini-error-circle"})}):jsxRuntimeExports.jsx("button",{type:"button",onClick:W,className:"puzzle-keyboard__positionatedToDigits puzzle-keyboard__delete","aria-label":P("puzzles.keyboard-puzzle.deleteButton"),children:jsxRuntimeExports.jsx("span",{className:"icon-delete-key-2023"})})]})}),jsxRuntimeExports.jsxs("div",{className:"puzzle-keyboard__keypad",children:[h==="scifi-theme"&&jsxRuntimeExports.jsx("div",{"aria-hidden":!0,className:"puzzle-keyboard__scifi-notch",children:jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",children:jsxRuntimeExports.jsxs("g",{fill:"none",fillRule:"evenodd",children:[jsxRuntimeExports.jsxs("g",{transform:"translate(3 3)",children:[jsxRuntimeExports.jsx("circle",{fill:"#1E282F",cx:"5",cy:"5",r:"5"}),jsxRuntimeExports.jsx("path",{d:"M1.48 8.55a5 5 0 1 0 7.008-7.133",fillOpacity:".096",fill:"#1DDDD8"}),jsxRuntimeExports.jsx("circle",{fill:"#1DDDD8",opacity:".359",cx:"3",cy:"3",r:"2"})]}),jsxRuntimeExports.jsx("circle",{stroke:"#1E282F",cx:"8",cy:"8",r:"7.5"})]})})})}),jsxRuntimeExports.jsx("div",{className:`keyboard-keys keyboard-keys--${h}`,children:t.map((I,$)=>(Array.isArray(I)?I:Object.values(I)).map((B,X)=>jsxRuntimeExports.jsx("button",{className:`keyboard-key keyboard-key--${h} ${B==="*"?"keyboard-key--star":""}`,type:"button",onClick:()=>V($,X),children:jsxRuntimeExports.jsx("div",{children:B})},B)))}),h==="scifi-theme"&&jsxRuntimeExports.jsx("hr",{"aria-hidden":!0,className:"puzzle-keyboard__scifi-line"})]}),S&&jsxRuntimeExports.jsx(FeedbackComponent$1,{translate:P,text:C,success:g,functionOnClose:F,keyboardControl:c})]})};var lib$1={exports:{}},_FullInternals={},_CoreInternals={},Global={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o._registerNode=o.Konva=o.glob=void 0;const e=Math.PI/180;function r(){return typeof window<"u"&&({}.toString.call(window)==="[object Window]"||{}.toString.call(window)==="[object global]")}o.glob=typeof commonjsGlobal<"u"?commonjsGlobal:typeof window<"u"?window:typeof WorkerGlobalScope<"u"?self:{},o.Konva={_global:o.glob,version:"9.3.0",isBrowser:r(),isUnminified:/param/.test((function(n){}).toString()),dblClickWindow:400,getAngle(n){return o.Konva.angleDeg?n*e:n},enableTrace:!1,pointerEventsEnabled:!0,autoDrawEnabled:!0,hitOnDragEnabled:!1,capturePointerEventsEnabled:!1,_mouseListenClick:!1,_touchListenClick:!1,_pointerListenClick:!1,_mouseInDblClickWindow:!1,_touchInDblClickWindow:!1,_pointerInDblClickWindow:!1,_mouseDblClickPointerId:null,_touchDblClickPointerId:null,_pointerDblClickPointerId:null,pixelRatio:typeof window<"u"&&window.devicePixelRatio||1,dragDistance:3,angleDeg:!0,showWarnings:!0,dragButtons:[0,1],isDragging(){return o.Konva.DD.isDragging},isDragReady(){return!!o.Konva.DD.node},releaseCanvasOnDestroy:!0,document:o.glob.document,_injectGlobal(n){o.glob.Konva=n}};const t=n=>{o.Konva[n.prototype.getClassName()]=n};o._registerNode=t,o.Konva._injectGlobal(o.Konva)})(Global);var Util={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Util=o.Transform=void 0;const e=Global;class r{constructor(A=[1,0,0,1,0,0]){this.dirty=!1,this.m=A&&A.slice()||[1,0,0,1,0,0]}reset(){this.m[0]=1,this.m[1]=0,this.m[2]=0,this.m[3]=1,this.m[4]=0,this.m[5]=0}copy(){return new r(this.m)}copyInto(A){A.m[0]=this.m[0],A.m[1]=this.m[1],A.m[2]=this.m[2],A.m[3]=this.m[3],A.m[4]=this.m[4],A.m[5]=this.m[5]}point(A){var T=this.m;return{x:T[0]*A.x+T[2]*A.y+T[4],y:T[1]*A.x+T[3]*A.y+T[5]}}translate(A,T){return this.m[4]+=this.m[0]*A+this.m[2]*T,this.m[5]+=this.m[1]*A+this.m[3]*T,this}scale(A,T){return this.m[0]*=A,this.m[1]*=A,this.m[2]*=T,this.m[3]*=T,this}rotate(A){var T=Math.cos(A),w=Math.sin(A),P=this.m[0]*T+this.m[2]*w,O=this.m[1]*T+this.m[3]*w,k=this.m[0]*-w+this.m[2]*T,D=this.m[1]*-w+this.m[3]*T;return this.m[0]=P,this.m[1]=O,this.m[2]=k,this.m[3]=D,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(A,T){var w=this.m[0]+this.m[2]*T,P=this.m[1]+this.m[3]*T,O=this.m[2]+this.m[0]*A,k=this.m[3]+this.m[1]*A;return this.m[0]=w,this.m[1]=P,this.m[2]=O,this.m[3]=k,this}multiply(A){var T=this.m[0]*A.m[0]+this.m[2]*A.m[1],w=this.m[1]*A.m[0]+this.m[3]*A.m[1],P=this.m[0]*A.m[2]+this.m[2]*A.m[3],O=this.m[1]*A.m[2]+this.m[3]*A.m[3],k=this.m[0]*A.m[4]+this.m[2]*A.m[5]+this.m[4],D=this.m[1]*A.m[4]+this.m[3]*A.m[5]+this.m[5];return this.m[0]=T,this.m[1]=w,this.m[2]=P,this.m[3]=O,this.m[4]=k,this.m[5]=D,this}invert(){var A=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),T=this.m[3]*A,w=-this.m[1]*A,P=-this.m[2]*A,O=this.m[0]*A,k=A*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),D=A*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=T,this.m[1]=w,this.m[2]=P,this.m[3]=O,this.m[4]=k,this.m[5]=D,this}getMatrix(){return this.m}decompose(){var A=this.m[0],T=this.m[1],w=this.m[2],P=this.m[3],O=this.m[4],k=this.m[5],D=A*P-T*w;let F={x:O,y:k,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(A!=0||T!=0){var G=Math.sqrt(A*A+T*T);F.rotation=T>0?Math.acos(A/G):-Math.acos(A/G),F.scaleX=G,F.scaleY=D/G,F.skewX=(A*w+T*P)/D,F.skewY=0}else if(w!=0||P!=0){var V=Math.sqrt(w*w+P*P);F.rotation=Math.PI/2-(P>0?Math.acos(-w/V):-Math.acos(w/V)),F.scaleX=D/V,F.scaleY=V,F.skewX=0,F.skewY=(A*w+T*P)/D}return F.rotation=o.Util._getRotation(F.rotation),F}}o.Transform=r;var t="[object Array]",n="[object Number]",a="[object String]",u="[object Boolean]",l=Math.PI/180,f=180/Math.PI,c="#",h="",y="0",E="Konva warning: ",p="Konva error: ",_="rgb(",g={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,132,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,255,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,203],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[119,128,144],slategrey:[119,128,144],snow:[255,255,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],transparent:[255,255,255,0],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,5]},x=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,C=[];const R=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(S){setTimeout(S,60)};o.Util={_isElement(S){return!!(S&&S.nodeType==1)},_isFunction(S){return!!(S&&S.constructor&&S.call&&S.apply)},_isPlainObject(S){return!!S&&S.constructor===Object},_isArray(S){return Object.prototype.toString.call(S)===t},_isNumber(S){return Object.prototype.toString.call(S)===n&&!isNaN(S)&&isFinite(S)},_isString(S){return Object.prototype.toString.call(S)===a},_isBoolean(S){return Object.prototype.toString.call(S)===u},isObject(S){return S instanceof Object},isValidSelector(S){if(typeof S!="string")return!1;var A=S[0];return A==="#"||A==="."||A===A.toUpperCase()},_sign(S){return S===0||S>0?1:-1},requestAnimFrame(S){C.push(S),C.length===1&&R(function(){const A=C;C=[],A.forEach(function(T){T()})})},createCanvasElement(){var S=document.createElement("canvas");try{S.style=S.style||{}}catch{}return S},createImageElement(){return document.createElement("img")},_isInDocument(S){for(;S=S.parentNode;)if(S==document)return!0;return!1},_urlToImage(S,A){var T=o.Util.createImageElement();T.onload=function(){A(T)},T.src=S},_rgbToHex(S,A,T){return((1<<24)+(S<<16)+(A<<8)+T).toString(16).slice(1)},_hexToRgb(S){S=S.replace(c,h);var A=parseInt(S,16);return{r:A>>16&255,g:A>>8&255,b:A&255}},getRandomColor(){for(var S=(Math.random()*16777215<<0).toString(16);S.length<6;)S=y+S;return c+S},getRGB(S){var A;return S in g?(A=g[S],{r:A[0],g:A[1],b:A[2]}):S[0]===c?this._hexToRgb(S.substring(1)):S.substr(0,4)===_?(A=x.exec(S.replace(/ /g,"")),{r:parseInt(A[1],10),g:parseInt(A[2],10),b:parseInt(A[3],10)}):{r:0,g:0,b:0}},colorToRGBA(S){return S=S||"black",o.Util._namedColorToRBA(S)||o.Util._hex3ColorToRGBA(S)||o.Util._hex4ColorToRGBA(S)||o.Util._hex6ColorToRGBA(S)||o.Util._hex8ColorToRGBA(S)||o.Util._rgbColorToRGBA(S)||o.Util._rgbaColorToRGBA(S)||o.Util._hslColorToRGBA(S)},_namedColorToRBA(S){var A=g[S.toLowerCase()];return A?{r:A[0],g:A[1],b:A[2],a:1}:null},_rgbColorToRGBA(S){if(S.indexOf("rgb(")===0){S=S.match(/rgb\(([^)]+)\)/)[1];var A=S.split(/ *, */).map(Number);return{r:A[0],g:A[1],b:A[2],a:1}}},_rgbaColorToRGBA(S){if(S.indexOf("rgba(")===0){S=S.match(/rgba\(([^)]+)\)/)[1];var A=S.split(/ *, */).map((T,w)=>T.slice(-1)==="%"?w===3?parseInt(T)/100:parseInt(T)/100*255:Number(T));return{r:A[0],g:A[1],b:A[2],a:A[3]}}},_hex8ColorToRGBA(S){if(S[0]==="#"&&S.length===9)return{r:parseInt(S.slice(1,3),16),g:parseInt(S.slice(3,5),16),b:parseInt(S.slice(5,7),16),a:parseInt(S.slice(7,9),16)/255}},_hex6ColorToRGBA(S){if(S[0]==="#"&&S.length===7)return{r:parseInt(S.slice(1,3),16),g:parseInt(S.slice(3,5),16),b:parseInt(S.slice(5,7),16),a:1}},_hex4ColorToRGBA(S){if(S[0]==="#"&&S.length===5)return{r:parseInt(S[1]+S[1],16),g:parseInt(S[2]+S[2],16),b:parseInt(S[3]+S[3],16),a:parseInt(S[4]+S[4],16)/255}},_hex3ColorToRGBA(S){if(S[0]==="#"&&S.length===4)return{r:parseInt(S[1]+S[1],16),g:parseInt(S[2]+S[2],16),b:parseInt(S[3]+S[3],16),a:1}},_hslColorToRGBA(S){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(S)){const[A,...T]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(S),w=Number(T[0])/360,P=Number(T[1])/100,O=Number(T[2])/100;let k,D,F;if(P===0)return F=O*255,{r:Math.round(F),g:Math.round(F),b:Math.round(F),a:1};O<.5?k=O*(1+P):k=O+P-O*P;const G=2*O-k,V=[0,0,0];for(let W=0;W<3;W++)D=w+1/3*-(W-1),D<0&&D++,D>1&&D--,6*D<1?F=G+(k-G)*6*D:2*D<1?F=k:3*D<2?F=G+(k-G)*(2/3-D)*6:F=G,V[W]=F*255;return{r:Math.round(V[0]),g:Math.round(V[1]),b:Math.round(V[2]),a:1}}},haveIntersection(S,A){return!(A.x>S.x+S.width||A.x+A.width<S.x||A.y>S.y+S.height||A.y+A.height<S.y)},cloneObject(S){var A={};for(var T in S)this._isPlainObject(S[T])?A[T]=this.cloneObject(S[T]):this._isArray(S[T])?A[T]=this.cloneArray(S[T]):A[T]=S[T];return A},cloneArray(S){return S.slice(0)},degToRad(S){return S*l},radToDeg(S){return S*f},_degToRad(S){return o.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),o.Util.degToRad(S)},_radToDeg(S){return o.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),o.Util.radToDeg(S)},_getRotation(S){return e.Konva.angleDeg?o.Util.radToDeg(S):S},_capitalize(S){return S.charAt(0).toUpperCase()+S.slice(1)},throw(S){throw new Error(p+S)},error(S){console.error(p+S)},warn(S){e.Konva.showWarnings&&console.warn(E+S)},each(S,A){for(var T in S)A(T,S[T])},_inRange(S,A,T){return A<=S&&S<T},_getProjectionToSegment(S,A,T,w,P,O){var k,D,F,G=(S-T)*(S-T)+(A-w)*(A-w);if(G==0)k=S,D=A,F=(P-T)*(P-T)+(O-w)*(O-w);else{var V=((P-S)*(T-S)+(O-A)*(w-A))/G;V<0?(k=S,D=A,F=(S-P)*(S-P)+(A-O)*(A-O)):V>1?(k=T,D=w,F=(T-P)*(T-P)+(w-O)*(w-O)):(k=S+V*(T-S),D=A+V*(w-A),F=(k-P)*(k-P)+(D-O)*(D-O))}return[k,D,F]},_getProjectionToLine(S,A,T){var w=o.Util.cloneObject(S),P=Number.MAX_VALUE;return A.forEach(function(O,k){if(!(!T&&k===A.length-1)){var D=A[(k+1)%A.length],F=o.Util._getProjectionToSegment(O.x,O.y,D.x,D.y,S.x,S.y),G=F[0],V=F[1],W=F[2];W<P&&(w.x=G,w.y=V,P=W)}}),w},_prepareArrayForTween(S,A,T){var w,P=[],O=[];if(S.length>A.length){var k=A;A=S,S=k}for(w=0;w<S.length;w+=2)P.push({x:S[w],y:S[w+1]});for(w=0;w<A.length;w+=2)O.push({x:A[w],y:A[w+1]});var D=[];return O.forEach(function(F){var G=o.Util._getProjectionToLine(F,P,T);D.push(G.x),D.push(G.y)}),D},_prepareToStringify(S){var A;S.visitedByCircularReferenceRemoval=!0;for(var T in S)if(S.hasOwnProperty(T)&&S[T]&&typeof S[T]=="object"){if(A=Object.getOwnPropertyDescriptor(S,T),S[T].visitedByCircularReferenceRemoval||o.Util._isElement(S[T]))if(A.configurable)delete S[T];else return null;else if(o.Util._prepareToStringify(S[T])===null)if(A.configurable)delete S[T];else return null}return delete S.visitedByCircularReferenceRemoval,S},_assign(S,A){for(var T in A)S[T]=A[T];return S},_getFirstPointerId(S){return S.touches?S.changedTouches[0].identifier:S.pointerId||999},releaseCanvas(...S){e.Konva.releaseCanvasOnDestroy&&S.forEach(A=>{A.width=0,A.height=0})},drawRoundedRectPath(S,A,T,w){let P=0,O=0,k=0,D=0;typeof w=="number"?P=O=k=D=Math.min(w,A/2,T/2):(P=Math.min(w[0]||0,A/2,T/2),O=Math.min(w[1]||0,A/2,T/2),D=Math.min(w[2]||0,A/2,T/2),k=Math.min(w[3]||0,A/2,T/2)),S.moveTo(P,0),S.lineTo(A-O,0),S.arc(A-O,O,O,Math.PI*3/2,0,!1),S.lineTo(A,T-D),S.arc(A-D,T-D,D,0,Math.PI/2,!1),S.lineTo(k,T),S.arc(k,T-k,k,Math.PI/2,Math.PI,!1),S.lineTo(0,P),S.arc(P,P,P,Math.PI,Math.PI*3/2,!1)}}})(Util);var Node$1={},Factory={},Validators={};Object.defineProperty(Validators,"__esModule",{value:!0});Validators.getComponentValidator=Validators.getBooleanValidator=Validators.getNumberArrayValidator=Validators.getFunctionValidator=Validators.getStringOrGradientValidator=Validators.getStringValidator=Validators.getNumberOrAutoValidator=Validators.getNumberOrArrayOfNumbersValidator=Validators.getNumberValidator=Validators.alphaComponent=Validators.RGBComponent=void 0;const Global_1$p=Global,Util_1$f=Util;function _formatValue(o){return Util_1$f.Util._isString(o)?'"'+o+'"':Object.prototype.toString.call(o)==="[object Number]"||Util_1$f.Util._isBoolean(o)?o:Object.prototype.toString.call(o)}function RGBComponent(o){return o>255?255:o<0?0:Math.round(o)}Validators.RGBComponent=RGBComponent;function alphaComponent(o){return o>1?1:o<1e-4?1e-4:o}Validators.alphaComponent=alphaComponent;function getNumberValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){return Util_1$f.Util._isNumber(o)||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),o}}Validators.getNumberValidator=getNumberValidator;function getNumberOrArrayOfNumbersValidator(o){if(Global_1$p.Konva.isUnminified)return function(e,r){let t=Util_1$f.Util._isNumber(e),n=Util_1$f.Util._isArray(e)&&e.length==o;return!t&&!n&&Util_1$f.Util.warn(_formatValue(e)+' is a not valid value for "'+r+'" attribute. The value should be a number or Array<number>('+o+")"),e}}Validators.getNumberOrArrayOfNumbersValidator=getNumberOrArrayOfNumbersValidator;function getNumberOrAutoValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){var r=Util_1$f.Util._isNumber(o),t=o==="auto";return r||t||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),o}}Validators.getNumberOrAutoValidator=getNumberOrAutoValidator;function getStringValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){return Util_1$f.Util._isString(o)||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),o}}Validators.getStringValidator=getStringValidator;function getStringOrGradientValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){const r=Util_1$f.Util._isString(o),t=Object.prototype.toString.call(o)==="[object CanvasGradient]"||o&&o.addColorStop;return r||t||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),o}}Validators.getStringOrGradientValidator=getStringOrGradientValidator;function getFunctionValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){return Util_1$f.Util._isFunction(o)||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a function.'),o}}Validators.getFunctionValidator=getFunctionValidator;function getNumberArrayValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){const r=Int8Array?Object.getPrototypeOf(Int8Array):null;return r&&o instanceof r||(Util_1$f.Util._isArray(o)?o.forEach(function(t){Util_1$f.Util._isNumber(t)||Util_1$f.Util.warn('"'+e+'" attribute has non numeric element '+t+". Make sure that all elements are numbers.")}):Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),o}}Validators.getNumberArrayValidator=getNumberArrayValidator;function getBooleanValidator(){if(Global_1$p.Konva.isUnminified)return function(o,e){var r=o===!0||o===!1;return r||Util_1$f.Util.warn(_formatValue(o)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),o}}Validators.getBooleanValidator=getBooleanValidator;function getComponentValidator(o){if(Global_1$p.Konva.isUnminified)return function(e,r){return e==null||Util_1$f.Util.isObject(e)||Util_1$f.Util.warn(_formatValue(e)+' is a not valid value for "'+r+'" attribute. The value should be an object with properties '+o),e}}Validators.getComponentValidator=getComponentValidator;(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Factory=void 0;const e=Util,r=Validators;var t="get",n="set";o.Factory={addGetterSetter(a,u,l,f,c){o.Factory.addGetter(a,u,l),o.Factory.addSetter(a,u,f,c),o.Factory.addOverloadedGetterSetter(a,u)},addGetter(a,u,l){var f=t+e.Util._capitalize(u);a.prototype[f]=a.prototype[f]||function(){var c=this.attrs[u];return c===void 0?l:c}},addSetter(a,u,l,f){var c=n+e.Util._capitalize(u);a.prototype[c]||o.Factory.overWriteSetter(a,u,l,f)},overWriteSetter(a,u,l,f){var c=n+e.Util._capitalize(u);a.prototype[c]=function(h){return l&&h!==void 0&&h!==null&&(h=l.call(this,h,u)),this._setAttr(u,h),f&&f.call(this),this}},addComponentsGetterSetter(a,u,l,f,c){var h=l.length,y=e.Util._capitalize,E=t+y(u),p=n+y(u),_,g;a.prototype[E]=function(){var C={};for(_=0;_<h;_++)g=l[_],C[g]=this.getAttr(u+y(g));return C};var x=(0,r.getComponentValidator)(l);a.prototype[p]=function(C){var R=this.attrs[u],S;f&&(C=f.call(this,C)),x&&x.call(this,C,u);for(S in C)C.hasOwnProperty(S)&&this._setAttr(u+y(S),C[S]);return C||l.forEach(A=>{this._setAttr(u+y(A),void 0)}),this._fireChangeEvent(u,R,C),c&&c.call(this),this},o.Factory.addOverloadedGetterSetter(a,u)},addOverloadedGetterSetter(a,u){var l=e.Util._capitalize(u),f=n+l,c=t+l;a.prototype[u]=function(){return arguments.length?(this[f](arguments[0]),this):this[c]()}},addDeprecatedGetterSetter(a,u,l,f){e.Util.error("Adding deprecated "+u);var c=t+e.Util._capitalize(u),h=u+" property is deprecated and will be removed soon. Look at Konva change log for more information.";a.prototype[c]=function(){e.Util.error(h);var y=this.attrs[u];return y===void 0?l:y},o.Factory.addSetter(a,u,f,function(){e.Util.error(h)}),o.Factory.addOverloadedGetterSetter(a,u)},backCompat(a,u){e.Util.each(u,function(l,f){var c=a.prototype[f],h=t+e.Util._capitalize(l),y=n+e.Util._capitalize(l);function E(){c.apply(this,arguments),e.Util.error('"'+l+'" method is deprecated and will be removed soon. Use ""'+f+'" instead.')}a.prototype[l]=E,a.prototype[h]=E,a.prototype[y]=E})},afterSetFilter(){this._filterUpToDate=!1}}})(Factory);var Canvas$1={},Context$2={};Object.defineProperty(Context$2,"__esModule",{value:!0});Context$2.HitContext=Context$2.SceneContext=Context$2.Context=void 0;const Util_1$e=Util,Global_1$o=Global;function simplifyArray(o){var e=[],r=o.length,t=Util_1$e.Util,n,a;for(n=0;n<r;n++)a=o[n],t._isNumber(a)?a=Math.round(a*1e3)/1e3:t._isString(a)||(a=a+""),e.push(a);return e}var COMMA=",",OPEN_PAREN="(",CLOSE_PAREN=")",OPEN_PAREN_BRACKET="([",CLOSE_BRACKET_PAREN="])",SEMICOLON=";",DOUBLE_PAREN="()",EQUALS="=",CONTEXT_METHODS=["arc","arcTo","beginPath","bezierCurveTo","clearRect","clip","closePath","createLinearGradient","createPattern","createRadialGradient","drawImage","ellipse","fill","fillText","getImageData","createImageData","lineTo","moveTo","putImageData","quadraticCurveTo","rect","restore","rotate","save","scale","setLineDash","setTransform","stroke","strokeText","transform","translate"],CONTEXT_PROPERTIES=["fillStyle","strokeStyle","shadowColor","shadowBlur","shadowOffsetX","shadowOffsetY","letterSpacing","lineCap","lineDashOffset","lineJoin","lineWidth","miterLimit","direction","font","textAlign","textBaseline","globalAlpha","globalCompositeOperation","imageSmoothingEnabled"];const traceArrMax=100;let Context$1=class{constructor(e){this.canvas=e,Global_1$o.Konva.enableTrace&&(this.traceArr=[],this._enableTrace())}fillShape(e){e.fillEnabled()&&this._fill(e)}_fill(e){}strokeShape(e){e.hasStroke()&&this._stroke(e)}_stroke(e){}fillStrokeShape(e){e.attrs.fillAfterStrokeEnabled?(this.strokeShape(e),this.fillShape(e)):(this.fillShape(e),this.strokeShape(e))}getTrace(e,r){var t=this.traceArr,n=t.length,a="",u,l,f,c;for(u=0;u<n;u++)l=t[u],f=l.method,f?(c=l.args,a+=f,e?a+=DOUBLE_PAREN:Util_1$e.Util._isArray(c[0])?a+=OPEN_PAREN_BRACKET+c.join(COMMA)+CLOSE_BRACKET_PAREN:(r&&(c=c.map(h=>typeof h=="number"?Math.floor(h):h)),a+=OPEN_PAREN+c.join(COMMA)+CLOSE_PAREN)):(a+=l.property,e||(a+=EQUALS+l.val)),a+=SEMICOLON;return a}clearTrace(){this.traceArr=[]}_trace(e){var r=this.traceArr,t;r.push(e),t=r.length,t>=traceArrMax&&r.shift()}reset(){var e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){var r=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,r.getWidth()/r.pixelRatio,r.getHeight()/r.pixelRatio)}_applyLineCap(e){const r=e.attrs.lineCap;r&&this.setAttr("lineCap",r)}_applyOpacity(e){var r=e.getAbsoluteOpacity();r!==1&&this.setAttr("globalAlpha",r)}_applyLineJoin(e){const r=e.attrs.lineJoin;r&&this.setAttr("lineJoin",r)}setAttr(e,r){this._context[e]=r}arc(e,r,t,n,a,u){this._context.arc(e,r,t,n,a,u)}arcTo(e,r,t,n,a){this._context.arcTo(e,r,t,n,a)}beginPath(){this._context.beginPath()}bezierCurveTo(e,r,t,n,a,u){this._context.bezierCurveTo(e,r,t,n,a,u)}clearRect(e,r,t,n){this._context.clearRect(e,r,t,n)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,r){var t=arguments;if(t.length===2)return this._context.createImageData(e,r);if(t.length===1)return this._context.createImageData(e)}createLinearGradient(e,r,t,n){return this._context.createLinearGradient(e,r,t,n)}createPattern(e,r){return this._context.createPattern(e,r)}createRadialGradient(e,r,t,n,a,u){return this._context.createRadialGradient(e,r,t,n,a,u)}drawImage(e,r,t,n,a,u,l,f,c){var h=arguments,y=this._context;h.length===3?y.drawImage(e,r,t):h.length===5?y.drawImage(e,r,t,n,a):h.length===9&&y.drawImage(e,r,t,n,a,u,l,f,c)}ellipse(e,r,t,n,a,u,l,f){this._context.ellipse(e,r,t,n,a,u,l,f)}isPointInPath(e,r,t,n){return t?this._context.isPointInPath(t,e,r,n):this._context.isPointInPath(e,r,n)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,r,t,n){this._context.fillRect(e,r,t,n)}strokeRect(e,r,t,n){this._context.strokeRect(e,r,t,n)}fillText(e,r,t,n){n?this._context.fillText(e,r,t,n):this._context.fillText(e,r,t)}measureText(e){return this._context.measureText(e)}getImageData(e,r,t,n){return this._context.getImageData(e,r,t,n)}lineTo(e,r){this._context.lineTo(e,r)}moveTo(e,r){this._context.moveTo(e,r)}rect(e,r,t,n){this._context.rect(e,r,t,n)}putImageData(e,r,t){this._context.putImageData(e,r,t)}quadraticCurveTo(e,r,t,n){this._context.quadraticCurveTo(e,r,t,n)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,r){this._context.scale(e,r)}setLineDash(e){this._context.setLineDash?this._context.setLineDash(e):"mozDash"in this._context?this._context.mozDash=e:"webkitLineDash"in this._context&&(this._context.webkitLineDash=e)}getLineDash(){return this._context.getLineDash()}setTransform(e,r,t,n,a,u){this._context.setTransform(e,r,t,n,a,u)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,r,t,n){this._context.strokeText(e,r,t,n)}transform(e,r,t,n,a,u){this._context.transform(e,r,t,n,a,u)}translate(e,r){this._context.translate(e,r)}_enableTrace(){var e=this,r=CONTEXT_METHODS.length,t=this.setAttr,n,a,u=function(l){var f=e[l],c;e[l]=function(){return a=simplifyArray(Array.prototype.slice.call(arguments,0)),c=f.apply(e,arguments),e._trace({method:l,args:a}),c}};for(n=0;n<r;n++)u(CONTEXT_METHODS[n]);e.setAttr=function(){t.apply(e,arguments);var l=arguments[0],f=arguments[1];(l==="shadowOffsetX"||l==="shadowOffsetY"||l==="shadowBlur")&&(f=f/this.canvas.getPixelRatio()),e._trace({property:l,val:f})}}_applyGlobalCompositeOperation(e){const r=e.attrs.globalCompositeOperation;var t=!r||r==="source-over";t||this.setAttr("globalCompositeOperation",r)}};Context$2.Context=Context$1;CONTEXT_PROPERTIES.forEach(function(o){Object.defineProperty(Context$1.prototype,o,{get(){return this._context[o]},set(e){this._context[o]=e}})});class SceneContext extends Context$1{constructor(e,{willReadFrequently:r=!1}={}){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:r})}_fillColor(e){var r=e.fill();this.setAttr("fillStyle",r),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){var r=e._getLinearGradient();r&&(this.setAttr("fillStyle",r),e._fillFunc(this))}_fillRadialGradient(e){const r=e._getRadialGradient();r&&(this.setAttr("fillStyle",r),e._fillFunc(this))}_fill(e){const r=e.fill(),t=e.getFillPriority();if(r&&t==="color"){this._fillColor(e);return}const n=e.getFillPatternImage();if(n&&t==="pattern"){this._fillPattern(e);return}const a=e.getFillLinearGradientColorStops();if(a&&t==="linear-gradient"){this._fillLinearGradient(e);return}const u=e.getFillRadialGradientColorStops();if(u&&t==="radial-gradient"){this._fillRadialGradient(e);return}r?this._fillColor(e):n?this._fillPattern(e):a?this._fillLinearGradient(e):u&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const r=e.getStrokeLinearGradientStartPoint(),t=e.getStrokeLinearGradientEndPoint(),n=e.getStrokeLinearGradientColorStops(),a=this.createLinearGradient(r.x,r.y,t.x,t.y);if(n){for(var u=0;u<n.length;u+=2)a.addColorStop(n[u],n[u+1]);this.setAttr("strokeStyle",a)}}_stroke(e){var r=e.dash(),t=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!t){this.save();var n=this.getCanvas().getPixelRatio();this.setTransform(n,0,0,n,0,0)}this._applyLineCap(e),r&&e.dashEnabled()&&(this.setLineDash(r),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");var a=e.getStrokeLinearGradientColorStops();a?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),t||this.restore()}}_applyShadow(e){var r,t,n,a=(r=e.getShadowRGBA())!==null&&r!==void 0?r:"black",u=(t=e.getShadowBlur())!==null&&t!==void 0?t:5,l=(n=e.getShadowOffset())!==null&&n!==void 0?n:{x:0,y:0},f=e.getAbsoluteScale(),c=this.canvas.getPixelRatio(),h=f.x*c,y=f.y*c;this.setAttr("shadowColor",a),this.setAttr("shadowBlur",u*Math.min(Math.abs(h),Math.abs(y))),this.setAttr("shadowOffsetX",l.x*h),this.setAttr("shadowOffsetY",l.y*y)}}Context$2.SceneContext=SceneContext;class HitContext extends Context$1{constructor(e){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:!0})}_fill(e){this.save(),this.setAttr("fillStyle",e.colorKey),e._fillFuncHit(this),this.restore()}strokeShape(e){e.hasHitStroke()&&this._stroke(e)}_stroke(e){if(e.hasHitStroke()){const a=e.getStrokeScaleEnabled();if(!a){this.save();var r=this.getCanvas().getPixelRatio();this.setTransform(r,0,0,r,0,0)}this._applyLineCap(e);var t=e.hitStrokeWidth(),n=t==="auto"?e.strokeWidth():t;this.setAttr("lineWidth",n),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),a||this.restore()}}}Context$2.HitContext=HitContext;Object.defineProperty(Canvas$1,"__esModule",{value:!0});Canvas$1.HitCanvas=Canvas$1.SceneCanvas=Canvas$1.Canvas=void 0;const Util_1$d=Util,Context_1=Context$2,Global_1$n=Global,Factory_1$z=Factory,Validators_1$y=Validators;var _pixelRatio;function getDevicePixelRatio(){if(_pixelRatio)return _pixelRatio;var o=Util_1$d.Util.createCanvasElement(),e=o.getContext("2d");return _pixelRatio=function(){var r=Global_1$n.Konva._global.devicePixelRatio||1,t=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return r/t}(),Util_1$d.Util.releaseCanvas(o),_pixelRatio}class Canvas{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var r=e||{},t=r.pixelRatio||Global_1$n.Konva.pixelRatio||getDevicePixelRatio();this.pixelRatio=t,this._canvas=Util_1$d.Util.createCanvasElement(),this._canvas.style.padding="0",this._canvas.style.margin="0",this._canvas.style.border="0",this._canvas.style.background="transparent",this._canvas.style.position="absolute",this._canvas.style.top="0",this._canvas.style.left="0"}getContext(){return this.context}getPixelRatio(){return this.pixelRatio}setPixelRatio(e){var r=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/r,this.getHeight()/r)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";var r=this.pixelRatio,t=this.getContext()._context;t.scale(r,r)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";var r=this.pixelRatio,t=this.getContext()._context;t.scale(r,r)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,r){this.setWidth(e||0),this.setHeight(r||0)}toDataURL(e,r){try{return this._canvas.toDataURL(e,r)}catch{try{return this._canvas.toDataURL()}catch(n){return Util_1$d.Util.error("Unable to get data URL. "+n.message+" For more info read https://konvajs.org/docs/posts/Tainted_Canvas.html."),""}}}}Canvas$1.Canvas=Canvas;Factory_1$z.Factory.addGetterSetter(Canvas,"pixelRatio",void 0,(0,Validators_1$y.getNumberValidator)());class SceneCanvas extends Canvas{constructor(e={width:0,height:0,willReadFrequently:!1}){super(e),this.context=new Context_1.SceneContext(this,{willReadFrequently:e.willReadFrequently}),this.setSize(e.width,e.height)}}Canvas$1.SceneCanvas=SceneCanvas;class HitCanvas extends Canvas{constructor(e={width:0,height:0}){super(e),this.hitCanvas=!0,this.context=new Context_1.HitContext(this),this.setSize(e.width,e.height)}}Canvas$1.HitCanvas=HitCanvas;var DragAndDrop={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.DD=void 0;const e=Global,r=Util;o.DD={get isDragging(){var t=!1;return o.DD._dragElements.forEach(n=>{n.dragStatus==="dragging"&&(t=!0)}),t},justDragged:!1,get node(){var t;return o.DD._dragElements.forEach(n=>{t=n.node}),t},_dragElements:new Map,_drag(t){const n=[];o.DD._dragElements.forEach((a,u)=>{const{node:l}=a,f=l.getStage();f.setPointersPositions(t),a.pointerId===void 0&&(a.pointerId=r.Util._getFirstPointerId(t));const c=f._changedPointerPositions.find(E=>E.id===a.pointerId);if(c){if(a.dragStatus!=="dragging"){var h=l.dragDistance(),y=Math.max(Math.abs(c.x-a.startPointerPos.x),Math.abs(c.y-a.startPointerPos.y));if(y<h||(l.startDrag({evt:t}),!l.isDragging()))return}l._setDragPosition(t,a),n.push(l)}}),n.forEach(a=>{a.fire("dragmove",{type:"dragmove",target:a,evt:t},!0)})},_endDragBefore(t){const n=[];o.DD._dragElements.forEach(a=>{const{node:u}=a,l=u.getStage();if(t&&l.setPointersPositions(t),!l._changedPointerPositions.find(h=>h.id===a.pointerId))return;(a.dragStatus==="dragging"||a.dragStatus==="stopped")&&(o.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,a.dragStatus="stopped");const c=a.node.getLayer()||a.node instanceof e.Konva.Stage&&a.node;c&&n.indexOf(c)===-1&&n.push(c)}),n.forEach(a=>{a.draw()})},_endDragAfter(t){o.DD._dragElements.forEach((n,a)=>{n.dragStatus==="stopped"&&n.node.fire("dragend",{type:"dragend",target:n.node,evt:t},!0),n.dragStatus!=="dragging"&&o.DD._dragElements.delete(a)})}},e.Konva.isBrowser&&(window.addEventListener("mouseup",o.DD._endDragBefore,!0),window.addEventListener("touchend",o.DD._endDragBefore,!0),window.addEventListener("mousemove",o.DD._drag),window.addEventListener("touchmove",o.DD._drag),window.addEventListener("mouseup",o.DD._endDragAfter,!1),window.addEventListener("touchend",o.DD._endDragAfter,!1))})(DragAndDrop);Object.defineProperty(Node$1,"__esModule",{value:!0});Node$1.Node=void 0;const Util_1$c=Util,Factory_1$y=Factory,Canvas_1$1=Canvas$1,Global_1$m=Global,DragAndDrop_1=DragAndDrop,Validators_1$x=Validators;var ABSOLUTE_OPACITY="absoluteOpacity",ALL_LISTENERS="allEventListeners",ABSOLUTE_TRANSFORM="absoluteTransform",ABSOLUTE_SCALE="absoluteScale",CANVAS="canvas",CHANGE="Change",CHILDREN="children",KONVA="konva",LISTENING="listening",MOUSEENTER="mouseenter",MOUSELEAVE="mouseleave",SET="set",SHAPE="Shape",SPACE$1=" ",STAGE="stage",TRANSFORM="transform",UPPER_STAGE="Stage",VISIBLE="visible",TRANSFORM_CHANGE_STR$1=["xChange.konva","yChange.konva","scaleXChange.konva","scaleYChange.konva","skewXChange.konva","skewYChange.konva","rotationChange.konva","offsetXChange.konva","offsetYChange.konva","transformsEnabledChange.konva"].join(SPACE$1);let idCounter=1;class Node{constructor(e){this._id=idCounter++,this.eventListeners={},this.attrs={},this.index=0,this._allEventListeners=null,this.parent=null,this._cache=new Map,this._attachedDepsListeners=new Map,this._lastPos=null,this._batchingTransformChange=!1,this._needClearTransformCache=!1,this._filterUpToDate=!1,this._isUnderCache=!1,this._dragEventId=null,this._shouldFireChangeEvents=!1,this.setAttrs(e),this._shouldFireChangeEvents=!0}hasChildren(){return!1}_clearCache(e){(e===TRANSFORM||e===ABSOLUTE_TRANSFORM)&&this._cache.get(e)?this._cache.get(e).dirty=!0:e?this._cache.delete(e):this._cache.clear()}_getCache(e,r){var t=this._cache.get(e),n=e===TRANSFORM||e===ABSOLUTE_TRANSFORM,a=t===void 0||n&&t.dirty===!0;return a&&(t=r.call(this),this._cache.set(e,t)),t}_calculate(e,r,t){if(!this._attachedDepsListeners.get(e)){const n=r.map(a=>a+"Change.konva").join(SPACE$1);this.on(n,()=>{this._clearCache(e)}),this._attachedDepsListeners.set(e,!0)}return this._getCache(e,t)}_getCanvasCache(){return this._cache.get(CANVAS)}_clearSelfAndDescendantCache(e){this._clearCache(e),e===ABSOLUTE_TRANSFORM&&this.fire("absoluteTransformChange")}clearCache(){if(this._cache.has(CANVAS)){const{scene:e,filter:r,hit:t}=this._cache.get(CANVAS);Util_1$c.Util.releaseCanvas(e,r,t),this._cache.delete(CANVAS)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){var r=e||{},t={};(r.x===void 0||r.y===void 0||r.width===void 0||r.height===void 0)&&(t=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));var n=Math.ceil(r.width||t.width),a=Math.ceil(r.height||t.height),u=r.pixelRatio,l=r.x===void 0?Math.floor(t.x):r.x,f=r.y===void 0?Math.floor(t.y):r.y,c=r.offset||0,h=r.drawBorder||!1,y=r.hitCanvasPixelRatio||1;if(!n||!a){Util_1$c.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}n+=c*2+1,a+=c*2+1,l-=c,f-=c;var E=new Canvas_1$1.SceneCanvas({pixelRatio:u,width:n,height:a}),p=new Canvas_1$1.SceneCanvas({pixelRatio:u,width:0,height:0,willReadFrequently:!0}),_=new Canvas_1$1.HitCanvas({pixelRatio:y,width:n,height:a}),g=E.getContext(),x=_.getContext();return _.isCache=!0,E.isCache=!0,this._cache.delete(CANVAS),this._filterUpToDate=!1,r.imageSmoothingEnabled===!1&&(E.getContext()._context.imageSmoothingEnabled=!1,p.getContext()._context.imageSmoothingEnabled=!1),g.save(),x.save(),g.translate(-l,-f),x.translate(-l,-f),this._isUnderCache=!0,this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY),this._clearSelfAndDescendantCache(ABSOLUTE_SCALE),this.drawScene(E,this),this.drawHit(_,this),this._isUnderCache=!1,g.restore(),x.restore(),h&&(g.save(),g.beginPath(),g.rect(0,0,n,a),g.closePath(),g.setAttr("strokeStyle","red"),g.setAttr("lineWidth",5),g.stroke(),g.restore()),this._cache.set(CANVAS,{scene:E,filter:p,hit:_,x:l,y:f}),this._requestDraw(),this}isCached(){return this._cache.has(CANVAS)}getClientRect(e){throw new Error('abstract "getClientRect" method call')}_transformedRect(e,r){var t=[{x:e.x,y:e.y},{x:e.x+e.width,y:e.y},{x:e.x+e.width,y:e.y+e.height},{x:e.x,y:e.y+e.height}],n=1/0,a=1/0,u=-1/0,l=-1/0,f=this.getAbsoluteTransform(r);return t.forEach(function(c){var h=f.point(c);n===void 0&&(n=u=h.x,a=l=h.y),n=Math.min(n,h.x),a=Math.min(a,h.y),u=Math.max(u,h.x),l=Math.max(l,h.y)}),{x:n,y:a,width:u-n,height:l-a}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);const r=this._getCanvasCache();e.translate(r.x,r.y);var t=this._getCachedSceneCanvas(),n=t.pixelRatio;e.drawImage(t._canvas,0,0,t.width/n,t.height/n),e.restore()}_drawCachedHitCanvas(e){var r=this._getCanvasCache(),t=r.hit;e.save(),e.translate(r.x,r.y),e.drawImage(t._canvas,0,0,t.width/t.pixelRatio,t.height/t.pixelRatio),e.restore()}_getCachedSceneCanvas(){var e=this.filters(),r=this._getCanvasCache(),t=r.scene,n=r.filter,a=n.getContext(),u,l,f,c;if(e){if(!this._filterUpToDate){var h=t.pixelRatio;n.setSize(t.width/t.pixelRatio,t.height/t.pixelRatio);try{for(u=e.length,a.clear(),a.drawImage(t._canvas,0,0,t.getWidth()/h,t.getHeight()/h),l=a.getImageData(0,0,n.getWidth(),n.getHeight()),f=0;f<u;f++){if(c=e[f],typeof c!="function"){Util_1$c.Util.error("Filter should be type of function, but got "+typeof c+" instead. Please check correct filters");continue}c.call(this,l),a.putImageData(l,0,0)}}catch(y){Util_1$c.Util.error("Unable to apply filter. "+y.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return n}return t}on(e,r){if(this._cache&&this._cache.delete(ALL_LISTENERS),arguments.length===3)return this._delegate.apply(this,arguments);var t=e.split(SPACE$1),n=t.length,a,u,l,f,c;for(a=0;a<n;a++)u=t[a],l=u.split("."),f=l[0],c=l[1]||"",this.eventListeners[f]||(this.eventListeners[f]=[]),this.eventListeners[f].push({name:c,handler:r});return this}off(e,r){var t=(e||"").split(SPACE$1),n=t.length,a,u,l,f,c,h;if(this._cache&&this._cache.delete(ALL_LISTENERS),!e)for(u in this.eventListeners)this._off(u);for(a=0;a<n;a++)if(l=t[a],f=l.split("."),c=f[0],h=f[1],c)this.eventListeners[c]&&this._off(c,h,r);else for(u in this.eventListeners)this._off(u,h,r);return this}dispatchEvent(e){var r={target:this,type:e.type,evt:e};return this.fire(e.type,r),this}addEventListener(e,r){return this.on(e,function(t){r.call(this,t.evt)}),this}removeEventListener(e){return this.off(e),this}_delegate(e,r,t){var n=this;this.on(e,function(a){for(var u=a.target.findAncestors(r,!0,n),l=0;l<u.length;l++)a=Util_1$c.Util.cloneObject(a),a.currentTarget=u[l],t.call(u[l],a)})}remove(){return this.isDragging()&&this.stopDrag(),DragAndDrop_1.DD._dragElements.delete(this._id),this._remove(),this}_clearCaches(){this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY),this._clearSelfAndDescendantCache(ABSOLUTE_SCALE),this._clearSelfAndDescendantCache(STAGE),this._clearSelfAndDescendantCache(VISIBLE),this._clearSelfAndDescendantCache(LISTENING)}_remove(){this._clearCaches();var e=this.getParent();e&&e.children&&(e.children.splice(this.index,1),e._setChildrenIndices(),this.parent=null)}destroy(){return this.remove(),this.clearCache(),this}getAttr(e){var r="get"+Util_1$c.Util._capitalize(e);return Util_1$c.Util._isFunction(this[r])?this[r]():this.attrs[e]}getAncestors(){for(var e=this.getParent(),r=[];e;)r.push(e),e=e.getParent();return r}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{var r,t;if(!e)return this;for(r in e)r!==CHILDREN&&(t=SET+Util_1$c.Util._capitalize(r),Util_1$c.Util._isFunction(this[t])?this[t](e[r]):this._setAttr(r,e[r]))}),this}isListening(){return this._getCache(LISTENING,this._isListening)}_isListening(e){if(!this.listening())return!1;const t=this.getParent();return t&&t!==e&&this!==e?t._isListening(e):!0}isVisible(){return this._getCache(VISIBLE,this._isVisible)}_isVisible(e){if(!this.visible())return!1;const t=this.getParent();return t&&t!==e&&this!==e?t._isVisible(e):!0}shouldDrawHit(e,r=!1){if(e)return this._isVisible(e)&&this._isListening(e);var t=this.getLayer(),n=!1;DragAndDrop_1.DD._dragElements.forEach(u=>{u.dragStatus==="dragging"&&(u.node.nodeType==="Stage"||u.node.getLayer()===t)&&(n=!0)});var a=!r&&!Global_1$m.Konva.hitOnDragEnabled&&n;return this.isListening()&&this.isVisible()&&!a}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){var e=this.getDepth(),r=this,t=0,n,a,u,l;function f(h){for(n=[],a=h.length,u=0;u<a;u++)l=h[u],t++,l.nodeType!==SHAPE&&(n=n.concat(l.getChildren().slice())),l._id===r._id&&(u=a);n.length>0&&n[0].getDepth()<=e&&f(n)}const c=this.getStage();return r.nodeType!==UPPER_STAGE&&c&&f(c.getChildren()),t}getDepth(){for(var e=0,r=this.parent;r;)e++,r=r.parent;return e}_batchTransformChanges(e){this._batchingTransformChange=!0,e(),this._batchingTransformChange=!1,this._needClearTransformCache&&(this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM)),this._needClearTransformCache=!1}setPosition(e){return this._batchTransformChanges(()=>{this.x(e.x),this.y(e.y)}),this}getPosition(){return{x:this.x(),y:this.y()}}getRelativePointerPosition(){const e=this.getStage();if(!e)return null;var r=e.getPointerPosition();if(!r)return null;var t=this.getAbsoluteTransform().copy();return t.invert(),t.point(r)}getAbsolutePosition(e){let r=!1,t=this.parent;for(;t;){if(t.isCached()){r=!0;break}t=t.parent}r&&!e&&(e=!0);var n=this.getAbsoluteTransform(e).getMatrix(),a=new Util_1$c.Transform,u=this.offset();return a.m=n.slice(),a.translate(u.x,u.y),a.getTranslation()}setAbsolutePosition(e){const{x:r,y:t,...n}=this._clearTransform();this.attrs.x=r,this.attrs.y=t,this._clearCache(TRANSFORM);var a=this._getAbsoluteTransform().copy();return a.invert(),a.translate(e.x,e.y),e={x:this.attrs.x+a.getTranslation().x,y:this.attrs.y+a.getTranslation().y},this._setTransform(n),this.setPosition({x:e.x,y:e.y}),this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM),this}_setTransform(e){var r;for(r in e)this.attrs[r]=e[r]}_clearTransform(){var e={x:this.x(),y:this.y(),rotation:this.rotation(),scaleX:this.scaleX(),scaleY:this.scaleY(),offsetX:this.offsetX(),offsetY:this.offsetY(),skewX:this.skewX(),skewY:this.skewY()};return this.attrs.x=0,this.attrs.y=0,this.attrs.rotation=0,this.attrs.scaleX=1,this.attrs.scaleY=1,this.attrs.offsetX=0,this.attrs.offsetY=0,this.attrs.skewX=0,this.attrs.skewY=0,e}move(e){var r=e.x,t=e.y,n=this.x(),a=this.y();return r!==void 0&&(n+=r),t!==void 0&&(a+=t),this.setPosition({x:n,y:a}),this}_eachAncestorReverse(e,r){var t=[],n=this.getParent(),a,u;if(!(r&&r._id===this._id)){for(t.unshift(this);n&&(!r||n._id!==r._id);)t.unshift(n),n=n.parent;for(a=t.length,u=0;u<a;u++)e(t[u])}}rotate(e){return this.rotation(this.rotation()+e),this}moveToTop(){if(!this.parent)return Util_1$c.Util.warn("Node has no parent. moveToTop function is ignored."),!1;var e=this.index,r=this.parent.getChildren().length;return e<r-1?(this.parent.children.splice(e,1),this.parent.children.push(this),this.parent._setChildrenIndices(),!0):!1}moveUp(){if(!this.parent)return Util_1$c.Util.warn("Node has no parent. moveUp function is ignored."),!1;var e=this.index,r=this.parent.getChildren().length;return e<r-1?(this.parent.children.splice(e,1),this.parent.children.splice(e+1,0,this),this.parent._setChildrenIndices(),!0):!1}moveDown(){if(!this.parent)return Util_1$c.Util.warn("Node has no parent. moveDown function is ignored."),!1;var e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.splice(e-1,0,this),this.parent._setChildrenIndices(),!0):!1}moveToBottom(){if(!this.parent)return Util_1$c.Util.warn("Node has no parent. moveToBottom function is ignored."),!1;var e=this.index;return e>0?(this.parent.children.splice(e,1),this.parent.children.unshift(this),this.parent._setChildrenIndices(),!0):!1}setZIndex(e){if(!this.parent)return Util_1$c.Util.warn("Node has no parent. zIndex parameter is ignored."),this;(e<0||e>=this.parent.children.length)&&Util_1$c.Util.warn("Unexpected value "+e+" for zIndex property. zIndex is just index of a node in children of its parent. Expected value is from 0 to "+(this.parent.children.length-1)+".");var r=this.index;return this.parent.children.splice(r,1),this.parent.children.splice(e,0,this),this.parent._setChildrenIndices(),this}getAbsoluteOpacity(){return this._getCache(ABSOLUTE_OPACITY,this._getAbsoluteOpacity)}_getAbsoluteOpacity(){var e=this.opacity(),r=this.getParent();return r&&!r._isUnderCache&&(e*=r.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){var e={},r=this.getAttrs(),t,n,a,u,l;e.attrs={};for(t in r)n=r[t],l=Util_1$c.Util.isObject(n)&&!Util_1$c.Util._isPlainObject(n)&&!Util_1$c.Util._isArray(n),!l&&(a=typeof this[t]=="function"&&this[t],delete r[t],u=a?a.call(this):null,r[t]=n,u!==n&&(e.attrs[t]=n));return e.className=this.getClassName(),Util_1$c.Util._prepareToStringify(e)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,r,t){var n=[];r&&this._isMatch(e)&&n.push(this);for(var a=this.parent;a;){if(a===t)return n;a._isMatch(e)&&n.push(a),a=a.parent}return n}isAncestorOf(e){return!1}findAncestor(e,r,t){return this.findAncestors(e,r,t)[0]}_isMatch(e){if(!e)return!1;if(typeof e=="function")return e(this);var r=e.replace(/ /g,"").split(","),t=r.length,n,a;for(n=0;n<t;n++)if(a=r[n],Util_1$c.Util.isValidSelector(a)||(Util_1$c.Util.warn('Selector "'+a+'" is invalid. Allowed selectors examples are "#foo", ".bar" or "Group".'),Util_1$c.Util.warn('If you have a custom shape with such className, please change it to start with upper letter like "Triangle".'),Util_1$c.Util.warn("Konva is awesome, right?")),a.charAt(0)==="#"){if(this.id()===a.slice(1))return!0}else if(a.charAt(0)==="."){if(this.hasName(a.slice(1)))return!0}else if(this.className===a||this.nodeType===a)return!0;return!1}getLayer(){var e=this.getParent();return e?e.getLayer():null}getStage(){return this._getCache(STAGE,this._getStage)}_getStage(){var e=this.getParent();return e?e.getStage():null}fire(e,r={},t){return r.target=r.target||this,t?this._fireAndBubble(e,r):this._fire(e,r),this}getAbsoluteTransform(e){return e?this._getAbsoluteTransform(e):this._getCache(ABSOLUTE_TRANSFORM,this._getAbsoluteTransform)}_getAbsoluteTransform(e){var r;if(e)return r=new Util_1$c.Transform,this._eachAncestorReverse(function(n){var a=n.transformsEnabled();a==="all"?r.multiply(n.getTransform()):a==="position"&&r.translate(n.x()-n.offsetX(),n.y()-n.offsetY())},e),r;r=this._cache.get(ABSOLUTE_TRANSFORM)||new Util_1$c.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(r):r.reset();var t=this.transformsEnabled();if(t==="all")r.multiply(this.getTransform());else if(t==="position"){const n=this.attrs.x||0,a=this.attrs.y||0,u=this.attrs.offsetX||0,l=this.attrs.offsetY||0;r.translate(n-u,a-l)}return r.dirty=!1,r}getAbsoluteScale(e){for(var r=this;r;)r._isUnderCache&&(e=r),r=r.getParent();const n=this.getAbsoluteTransform(e).decompose();return{x:n.scaleX,y:n.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(TRANSFORM,this._getTransform)}_getTransform(){var e,r,t=this._cache.get(TRANSFORM)||new Util_1$c.Transform;t.reset();var n=this.x(),a=this.y(),u=Global_1$m.Konva.getAngle(this.rotation()),l=(e=this.attrs.scaleX)!==null&&e!==void 0?e:1,f=(r=this.attrs.scaleY)!==null&&r!==void 0?r:1,c=this.attrs.skewX||0,h=this.attrs.skewY||0,y=this.attrs.offsetX||0,E=this.attrs.offsetY||0;return(n!==0||a!==0)&&t.translate(n,a),u!==0&&t.rotate(u),(c!==0||h!==0)&&t.skew(c,h),(l!==1||f!==1)&&t.scale(l,f),(y!==0||E!==0)&&t.translate(-1*y,-1*E),t.dirty=!1,t}clone(e){var r=Util_1$c.Util.cloneObject(this.attrs),t,n,a,u,l;for(t in e)r[t]=e[t];var f=new this.constructor(r);for(t in this.eventListeners)for(n=this.eventListeners[t],a=n.length,u=0;u<a;u++)l=n[u],l.name.indexOf(KONVA)<0&&(f.eventListeners[t]||(f.eventListeners[t]=[]),f.eventListeners[t].push(l));return f}_toKonvaCanvas(e){e=e||{};var r=this.getClientRect(),t=this.getStage(),n=e.x!==void 0?e.x:Math.floor(r.x),a=e.y!==void 0?e.y:Math.floor(r.y),u=e.pixelRatio||1,l=new Canvas_1$1.SceneCanvas({width:e.width||Math.ceil(r.width)||(t?t.width():0),height:e.height||Math.ceil(r.height)||(t?t.height():0),pixelRatio:u}),f=l.getContext();return e.imageSmoothingEnabled===!1&&(f._context.imageSmoothingEnabled=!1),f.save(),(n||a)&&f.translate(-1*n,-1*a),this.drawScene(l),f.restore(),l}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){e=e||{};var r=e.mimeType||null,t=e.quality||null,n=this._toKonvaCanvas(e).toDataURL(r,t);return e.callback&&e.callback(n),n}toImage(e){return new Promise((r,t)=>{try{const n=e==null?void 0:e.callback;n&&delete e.callback,Util_1$c.Util._urlToImage(this.toDataURL(e),function(a){r(a),n==null||n(a)})}catch(n){t(n)}})}toBlob(e){return new Promise((r,t)=>{try{const n=e==null?void 0:e.callback;n&&delete e.callback,this.toCanvas(e).toBlob(a=>{r(a),n==null||n(a)},e==null?void 0:e.mimeType,e==null?void 0:e.quality)}catch(n){t(n)}})}setSize(e){return this.width(e.width),this.height(e.height),this}getSize(){return{width:this.width(),height:this.height()}}getClassName(){return this.className||this.nodeType}getType(){return this.nodeType}getDragDistance(){return this.attrs.dragDistance!==void 0?this.attrs.dragDistance:this.parent?this.parent.getDragDistance():Global_1$m.Konva.dragDistance}_off(e,r,t){var n=this.eventListeners[e],a,u,l;for(a=0;a<n.length;a++)if(u=n[a].name,l=n[a].handler,(u!=="konva"||r==="konva")&&(!r||u===r)&&(!t||t===l)){if(n.splice(a,1),n.length===0){delete this.eventListeners[e];break}a--}}_fireChangeEvent(e,r,t){this._fire(e+CHANGE,{oldVal:r,newVal:t})}addName(e){if(!this.hasName(e)){var r=this.name(),t=r?r+" "+e:e;this.name(t)}return this}hasName(e){if(!e)return!1;const r=this.name();if(!r)return!1;var t=(r||"").split(/\s/g);return t.indexOf(e)!==-1}removeName(e){var r=(this.name()||"").split(/\s/g),t=r.indexOf(e);return t!==-1&&(r.splice(t,1),this.name(r.join(" "))),this}setAttr(e,r){var t=this[SET+Util_1$c.Util._capitalize(e)];return Util_1$c.Util._isFunction(t)?t.call(this,r):this._setAttr(e,r),this}_requestDraw(){if(Global_1$m.Konva.autoDrawEnabled){const e=this.getLayer()||this.getStage();e==null||e.batchDraw()}}_setAttr(e,r){var t=this.attrs[e];t===r&&!Util_1$c.Util.isObject(r)||(r==null?delete this.attrs[e]:this.attrs[e]=r,this._shouldFireChangeEvents&&this._fireChangeEvent(e,t,r),this._requestDraw())}_setComponentAttr(e,r,t){var n;t!==void 0&&(n=this.attrs[e],n||(this.attrs[e]=this.getAttr(e)),this.attrs[e][r]=t,this._fireChangeEvent(e,n,t))}_fireAndBubble(e,r,t){r&&this.nodeType===SHAPE&&(r.target=this);var n=(e===MOUSEENTER||e===MOUSELEAVE)&&(t&&(this===t||this.isAncestorOf&&this.isAncestorOf(t))||this.nodeType==="Stage"&&!t);if(!n){this._fire(e,r);var a=(e===MOUSEENTER||e===MOUSELEAVE)&&t&&t.isAncestorOf&&t.isAncestorOf(this)&&!t.isAncestorOf(this.parent);(r&&!r.cancelBubble||!r)&&this.parent&&this.parent.isListening()&&!a&&(t&&t.parent?this._fireAndBubble.call(this.parent,e,r,t):this._fireAndBubble.call(this.parent,e,r))}}_getProtoListeners(e){var r,t,n;const a=(r=this._cache.get(ALL_LISTENERS))!==null&&r!==void 0?r:{};let u=a==null?void 0:a[e];if(u===void 0){u=[];let l=Object.getPrototypeOf(this);for(;l;){const f=(n=(t=l.eventListeners)===null||t===void 0?void 0:t[e])!==null&&n!==void 0?n:[];u.push(...f),l=Object.getPrototypeOf(l)}a[e]=u,this._cache.set(ALL_LISTENERS,a)}return u}_fire(e,r){r=r||{},r.currentTarget=this,r.type=e;const t=this._getProtoListeners(e);if(t)for(var n=0;n<t.length;n++)t[n].handler.call(this,r);const a=this.eventListeners[e];if(a)for(var n=0;n<a.length;n++)a[n].handler.call(this,r)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){var r=e?e.pointerId:void 0,t=this.getStage(),n=this.getAbsolutePosition();if(t){var a=t._getPointerById(r)||t._changedPointerPositions[0]||n;DragAndDrop_1.DD._dragElements.set(this._id,{node:this,startPointerPos:a,offset:{x:a.x-n.x,y:a.y-n.y},dragStatus:"ready",pointerId:r})}}startDrag(e,r=!0){DragAndDrop_1.DD._dragElements.has(this._id)||this._createDragElement(e);const t=DragAndDrop_1.DD._dragElements.get(this._id);t.dragStatus="dragging",this.fire("dragstart",{type:"dragstart",target:this,evt:e&&e.evt},r)}_setDragPosition(e,r){const t=this.getStage()._getPointerById(r.pointerId);if(t){var n={x:t.x-r.offset.x,y:t.y-r.offset.y},a=this.dragBoundFunc();if(a!==void 0){const u=a.call(this,n,e);u?n=u:Util_1$c.Util.warn("dragBoundFunc did not return any value. That is unexpected behavior. You must return new absolute position from dragBoundFunc.")}(!this._lastPos||this._lastPos.x!==n.x||this._lastPos.y!==n.y)&&(this.setAbsolutePosition(n),this._requestDraw()),this._lastPos=n}}stopDrag(e){const r=DragAndDrop_1.DD._dragElements.get(this._id);r&&(r.dragStatus="stopped"),DragAndDrop_1.DD._endDragBefore(e),DragAndDrop_1.DD._endDragAfter(e)}setDraggable(e){this._setAttr("draggable",e),this._dragChange()}isDragging(){const e=DragAndDrop_1.DD._dragElements.get(this._id);return e?e.dragStatus==="dragging":!1}_listenDrag(){this._dragCleanup(),this.on("mousedown.konva touchstart.konva",function(e){var r=e.evt.button!==void 0,t=!r||Global_1$m.Konva.dragButtons.indexOf(e.evt.button)>=0;if(t&&!this.isDragging()){var n=!1;DragAndDrop_1.DD._dragElements.forEach(a=>{this.isAncestorOf(a.node)&&(n=!0)}),n||this._createDragElement(e)}})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();var e=this.getStage();if(!e)return;const r=DragAndDrop_1.DD._dragElements.get(this._id),t=r&&r.dragStatus==="dragging",n=r&&r.dragStatus==="ready";t?this.stopDrag():n&&DragAndDrop_1.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const r=this.getStage();if(!r)return!1;const t={x:-e.x,y:-e.y,width:r.width()+2*e.x,height:r.height()+2*e.y};return Util_1$c.Util.haveIntersection(t,this.getClientRect())}static create(e,r){return Util_1$c.Util._isString(e)&&(e=JSON.parse(e)),this._createNode(e,r)}static _createNode(e,r){var t=Node.prototype.getClassName.call(e),n=e.children,a,u,l;r&&(e.attrs.container=r),Global_1$m.Konva[t]||(Util_1$c.Util.warn('Can not find a node with class name "'+t+'". Fallback to "Shape".'),t="Shape");const f=Global_1$m.Konva[t];if(a=new f(e.attrs),n)for(u=n.length,l=0;l<u;l++)a.add(Node._createNode(n[l]));return a}}Node$1.Node=Node;Node.prototype.nodeType="Node";Node.prototype._attrsAffectingSize=[];Node.prototype.eventListeners={};Node.prototype.on.call(Node.prototype,TRANSFORM_CHANGE_STR$1,function(){if(this._batchingTransformChange){this._needClearTransformCache=!0;return}this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM)});Node.prototype.on.call(Node.prototype,"visibleChange.konva",function(){this._clearSelfAndDescendantCache(VISIBLE)});Node.prototype.on.call(Node.prototype,"listeningChange.konva",function(){this._clearSelfAndDescendantCache(LISTENING)});Node.prototype.on.call(Node.prototype,"opacityChange.konva",function(){this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY)});const addGetterSetter=Factory_1$y.Factory.addGetterSetter;addGetterSetter(Node,"zIndex");addGetterSetter(Node,"absolutePosition");addGetterSetter(Node,"position");addGetterSetter(Node,"x",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"y",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"globalCompositeOperation","source-over",(0,Validators_1$x.getStringValidator)());addGetterSetter(Node,"opacity",1,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"name","",(0,Validators_1$x.getStringValidator)());addGetterSetter(Node,"id","",(0,Validators_1$x.getStringValidator)());addGetterSetter(Node,"rotation",0,(0,Validators_1$x.getNumberValidator)());Factory_1$y.Factory.addComponentsGetterSetter(Node,"scale",["x","y"]);addGetterSetter(Node,"scaleX",1,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"scaleY",1,(0,Validators_1$x.getNumberValidator)());Factory_1$y.Factory.addComponentsGetterSetter(Node,"skew",["x","y"]);addGetterSetter(Node,"skewX",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"skewY",0,(0,Validators_1$x.getNumberValidator)());Factory_1$y.Factory.addComponentsGetterSetter(Node,"offset",["x","y"]);addGetterSetter(Node,"offsetX",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"offsetY",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"dragDistance",null,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"width",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"height",0,(0,Validators_1$x.getNumberValidator)());addGetterSetter(Node,"listening",!0,(0,Validators_1$x.getBooleanValidator)());addGetterSetter(Node,"preventDefault",!0,(0,Validators_1$x.getBooleanValidator)());addGetterSetter(Node,"filters",null,function(o){return this._filterUpToDate=!1,o});addGetterSetter(Node,"visible",!0,(0,Validators_1$x.getBooleanValidator)());addGetterSetter(Node,"transformsEnabled","all",(0,Validators_1$x.getStringValidator)());addGetterSetter(Node,"size");addGetterSetter(Node,"dragBoundFunc");addGetterSetter(Node,"draggable",!1,(0,Validators_1$x.getBooleanValidator)());Factory_1$y.Factory.backCompat(Node,{rotateDeg:"rotate",setRotationDeg:"setRotation",getRotationDeg:"getRotation"});var Container$2={};Object.defineProperty(Container$2,"__esModule",{value:!0});Container$2.Container=void 0;const Factory_1$x=Factory,Node_1$h=Node$1,Validators_1$w=Validators;let Container$1=class extends Node_1$h.Node{constructor(){super(...arguments),this.children=[]}getChildren(e){if(!e)return this.children||[];const r=this.children||[];var t=[];return r.forEach(function(n){e(n)&&t.push(n)}),t}hasChildren(){return this.getChildren().length>0}removeChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.remove()}),this.children=[],this._requestDraw(),this}destroyChildren(){return this.getChildren().forEach(e=>{e.parent=null,e.index=0,e.destroy()}),this.children=[],this._requestDraw(),this}add(...e){if(e.length===0)return this;if(e.length>1){for(var r=0;r<e.length;r++)this.add(e[r]);return this}const t=e[0];return t.getParent()?(t.moveTo(this),this):(this._validateAdd(t),t.index=this.getChildren().length,t.parent=this,t._clearCaches(),this.getChildren().push(t),this._fire("add",{child:t}),this._requestDraw(),this)}destroy(){return this.hasChildren()&&this.destroyChildren(),super.destroy(),this}find(e){return this._generalFind(e,!1)}findOne(e){var r=this._generalFind(e,!0);return r.length>0?r[0]:void 0}_generalFind(e,r){var t=[];return this._descendants(n=>{const a=n._isMatch(e);return a&&t.push(n),!!(a&&r)}),t}_descendants(e){let r=!1;const t=this.getChildren();for(const n of t){if(r=e(n),r)return!0;if(n.hasChildren()&&(r=n._descendants(e),r))return!0}return!1}toObject(){var e=Node_1$h.Node.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(r=>{e.children.push(r.toObject())}),e}isAncestorOf(e){for(var r=e.getParent();r;){if(r._id===this._id)return!0;r=r.getParent()}return!1}clone(e){var r=Node_1$h.Node.prototype.clone.call(this,e);return this.getChildren().forEach(function(t){r.add(t.clone())}),r}getAllIntersections(e){var r=[];return this.find("Shape").forEach(t=>{t.isVisible()&&t.intersects(e)&&r.push(t)}),r}_clearSelfAndDescendantCache(e){var r;super._clearSelfAndDescendantCache(e),!this.isCached()&&((r=this.children)===null||r===void 0||r.forEach(function(t){t._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(r,t){r.index=t}),this._requestDraw()}drawScene(e,r){var t=this.getLayer(),n=e||t&&t.getCanvas(),a=n&&n.getContext(),u=this._getCanvasCache(),l=u&&u.scene,f=n&&n.isCache;if(!this.isVisible()&&!f)return this;if(l){a.save();var c=this.getAbsoluteTransform(r).getMatrix();a.transform(c[0],c[1],c[2],c[3],c[4],c[5]),this._drawCachedSceneCanvas(a),a.restore()}else this._drawChildren("drawScene",n,r);return this}drawHit(e,r){if(!this.shouldDrawHit(r))return this;var t=this.getLayer(),n=e||t&&t.hitCanvas,a=n&&n.getContext(),u=this._getCanvasCache(),l=u&&u.hit;if(l){a.save();var f=this.getAbsoluteTransform(r).getMatrix();a.transform(f[0],f[1],f[2],f[3],f[4],f[5]),this._drawCachedHitCanvas(a),a.restore()}else this._drawChildren("drawHit",n,r);return this}_drawChildren(e,r,t){var n,a=r&&r.getContext(),u=this.clipWidth(),l=this.clipHeight(),f=this.clipFunc(),c=u&&l||f;const h=t===this;if(c){a.save();var y=this.getAbsoluteTransform(t),E=y.getMatrix();a.transform(E[0],E[1],E[2],E[3],E[4],E[5]),a.beginPath();let x;if(f)x=f.call(this,a,this);else{var p=this.clipX(),_=this.clipY();a.rect(p,_,u,l)}a.clip.apply(a,x),E=y.copy().invert().getMatrix(),a.transform(E[0],E[1],E[2],E[3],E[4],E[5])}var g=!h&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";g&&(a.save(),a._applyGlobalCompositeOperation(this)),(n=this.children)===null||n===void 0||n.forEach(function(x){x[e](r,t)}),g&&a.restore(),c&&a.restore()}getClientRect(e={}){var r,t=e.skipTransform,n=e.relativeTo,a,u,l,f,c={x:1/0,y:1/0,width:0,height:0},h=this;(r=this.children)===null||r===void 0||r.forEach(function(g){if(g.visible()){var x=g.getClientRect({relativeTo:h,skipShadow:e.skipShadow,skipStroke:e.skipStroke});x.width===0&&x.height===0||(a===void 0?(a=x.x,u=x.y,l=x.x+x.width,f=x.y+x.height):(a=Math.min(a,x.x),u=Math.min(u,x.y),l=Math.max(l,x.x+x.width),f=Math.max(f,x.y+x.height)))}});for(var y=this.find("Shape"),E=!1,p=0;p<y.length;p++){var _=y[p];if(_._isVisible(this)){E=!0;break}}return E&&a!==void 0?c={x:a,y:u,width:l-a,height:f-u}:c={x:0,y:0,width:0,height:0},t?c:this._transformedRect(c,n)}};Container$2.Container=Container$1;Factory_1$x.Factory.addComponentsGetterSetter(Container$1,"clip",["x","y","width","height"]);Factory_1$x.Factory.addGetterSetter(Container$1,"clipX",void 0,(0,Validators_1$w.getNumberValidator)());Factory_1$x.Factory.addGetterSetter(Container$1,"clipY",void 0,(0,Validators_1$w.getNumberValidator)());Factory_1$x.Factory.addGetterSetter(Container$1,"clipWidth",void 0,(0,Validators_1$w.getNumberValidator)());Factory_1$x.Factory.addGetterSetter(Container$1,"clipHeight",void 0,(0,Validators_1$w.getNumberValidator)());Factory_1$x.Factory.addGetterSetter(Container$1,"clipFunc");var Stage$1={},PointerEvents={};Object.defineProperty(PointerEvents,"__esModule",{value:!0});PointerEvents.releaseCapture=PointerEvents.setPointerCapture=PointerEvents.hasPointerCapture=PointerEvents.createEvent=PointerEvents.getCapturedShape=void 0;const Global_1$l=Global,Captures=new Map,SUPPORT_POINTER_EVENTS=Global_1$l.Konva._global.PointerEvent!==void 0;function getCapturedShape(o){return Captures.get(o)}PointerEvents.getCapturedShape=getCapturedShape;function createEvent(o){return{evt:o,pointerId:o.pointerId}}PointerEvents.createEvent=createEvent;function hasPointerCapture(o,e){return Captures.get(o)===e}PointerEvents.hasPointerCapture=hasPointerCapture;function setPointerCapture(o,e){releaseCapture(o),e.getStage()&&(Captures.set(o,e),SUPPORT_POINTER_EVENTS&&e._fire("gotpointercapture",createEvent(new PointerEvent("gotpointercapture"))))}PointerEvents.setPointerCapture=setPointerCapture;function releaseCapture(o,e){const r=Captures.get(o);if(!r)return;const t=r.getStage();t&&t.content,Captures.delete(o),SUPPORT_POINTER_EVENTS&&r._fire("lostpointercapture",createEvent(new PointerEvent("lostpointercapture")))}PointerEvents.releaseCapture=releaseCapture;(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Stage=o.stages=void 0;const e=Util,r=Factory,t=Container$2,n=Global,a=Canvas$1,u=DragAndDrop,l=Global,f=PointerEvents;var c="Stage",h="string",y="px",E="mouseout",p="mouseleave",_="mouseover",g="mouseenter",x="mousemove",C="mousedown",R="mouseup",S="pointermove",A="pointerdown",T="pointerup",w="pointercancel",P="lostpointercapture",O="pointerout",k="pointerleave",D="pointerover",F="pointerenter",G="contextmenu",V="touchstart",W="touchend",Z="touchmove",q="touchcancel",z="wheel",U=5,I=[[g,"_pointerenter"],[C,"_pointerdown"],[x,"_pointermove"],[R,"_pointerup"],[p,"_pointerleave"],[V,"_pointerdown"],[Z,"_pointermove"],[W,"_pointerup"],[q,"_pointercancel"],[_,"_pointerover"],[z,"_wheel"],[G,"_contextmenu"],[A,"_pointerdown"],[S,"_pointermove"],[T,"_pointerup"],[w,"_pointercancel"],[P,"_lostpointercapture"]];const $={mouse:{[O]:E,[k]:p,[D]:_,[F]:g,[S]:x,[A]:C,[T]:R,[w]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[O]:"touchout",[k]:"touchleave",[D]:"touchover",[F]:"touchenter",[S]:Z,[A]:V,[T]:W,[w]:q,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[O]:O,[k]:k,[D]:D,[F]:F,[S]:S,[A]:A,[T]:T,[w]:w,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},B=se=>se.indexOf("pointer")>=0?"pointer":se.indexOf("touch")>=0?"touch":"mouse",X=se=>{const ee=B(se);if(ee==="pointer")return n.Konva.pointerEventsEnabled&&$.pointer;if(ee==="touch")return $.touch;if(ee==="mouse")return $.mouse};function Q(se={}){return(se.clipFunc||se.clipWidth||se.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),se}const J="Pointer position is missing and not registered by the stage. Looks like it is outside of the stage container. You can set it manually from event: stage.setPointersPositions(event);";o.stages=[];class ne extends t.Container{constructor(ee){super(Q(ee)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),o.stages.push(this),this.on("widthChange.konva heightChange.konva",this._resizeDOM),this.on("visibleChange.konva",this._checkVisibility),this.on("clipWidthChange.konva clipHeightChange.konva clipFuncChange.konva",()=>{Q(this.attrs)}),this._checkVisibility()}_validateAdd(ee){const ie=ee.getType()==="Layer",oe=ee.getType()==="FastLayer";ie||oe||e.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const ee=this.visible()?"":"none";this.content.style.display=ee}setContainer(ee){if(typeof ee===h){if(ee.charAt(0)==="."){var ie=ee.slice(1);ee=document.getElementsByClassName(ie)[0]}else{var oe;ee.charAt(0)!=="#"?oe=ee:oe=ee.slice(1),ee=document.getElementById(oe)}if(!ee)throw"Can not find container in document with id "+oe}return this._setAttr("container",ee),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),ee.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){var ee=this.children,ie=ee.length,oe;for(oe=0;oe<ie;oe++)ee[oe].clear();return this}clone(ee){return ee||(ee={}),ee.container=typeof document<"u"&&document.createElement("div"),t.Container.prototype.clone.call(this,ee)}destroy(){super.destroy();var ee=this.content;ee&&e.Util._isInDocument(ee)&&this.container().removeChild(ee);var ie=o.stages.indexOf(this);return ie>-1&&o.stages.splice(ie,1),e.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const ee=this._pointerPositions[0]||this._changedPointerPositions[0];return ee?{x:ee.x,y:ee.y}:(e.Util.warn(J),null)}_getPointerById(ee){return this._pointerPositions.find(ie=>ie.id===ee)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(ee){ee=ee||{},ee.x=ee.x||0,ee.y=ee.y||0,ee.width=ee.width||this.width(),ee.height=ee.height||this.height();var ie=new a.SceneCanvas({width:ee.width,height:ee.height,pixelRatio:ee.pixelRatio||1}),oe=ie.getContext()._context,fe=this.children;return(ee.x||ee.y)&&oe.translate(-1*ee.x,-1*ee.y),fe.forEach(function(de){if(de.isVisible()){var ce=de._toKonvaCanvas(ee);oe.drawImage(ce._canvas,ee.x,ee.y,ce.getWidth()/ce.getPixelRatio(),ce.getHeight()/ce.getPixelRatio())}}),ie}getIntersection(ee){if(!ee)return null;var ie=this.children,oe=ie.length,fe=oe-1,de;for(de=fe;de>=0;de--){const ce=ie[de].getIntersection(ee);if(ce)return ce}return null}_resizeDOM(){var ee=this.width(),ie=this.height();this.content&&(this.content.style.width=ee+y,this.content.style.height=ie+y),this.bufferCanvas.setSize(ee,ie),this.bufferHitCanvas.setSize(ee,ie),this.children.forEach(oe=>{oe.setSize({width:ee,height:ie}),oe.draw()})}add(ee,...ie){if(arguments.length>1){for(var oe=0;oe<arguments.length;oe++)this.add(arguments[oe]);return this}super.add(ee);var fe=this.children.length;return fe>U&&e.Util.warn("The stage has "+fe+" layers. Recommended maximum number of layers is 3-5. Adding more layers into the stage may drop the performance. Rethink your tree structure, you can use Konva.Group."),ee.setSize({width:this.width(),height:this.height()}),ee.draw(),n.Konva.isBrowser&&this.content.appendChild(ee.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(ee){return f.hasPointerCapture(ee,this)}setPointerCapture(ee){f.setPointerCapture(ee,this)}releaseCapture(ee){f.releaseCapture(ee,this)}getLayers(){return this.children}_bindContentEvents(){n.Konva.isBrowser&&I.forEach(([ee,ie])=>{this.content.addEventListener(ee,oe=>{this[ie](oe)},{passive:!1})})}_pointerenter(ee){this.setPointersPositions(ee);const ie=X(ee.type);ie&&this._fire(ie.pointerenter,{evt:ee,target:this,currentTarget:this})}_pointerover(ee){this.setPointersPositions(ee);const ie=X(ee.type);ie&&this._fire(ie.pointerover,{evt:ee,target:this,currentTarget:this})}_getTargetShape(ee){let ie=this[ee+"targetShape"];return ie&&!ie.getStage()&&(ie=null),ie}_pointerleave(ee){const ie=X(ee.type),oe=B(ee.type);if(ie){this.setPointersPositions(ee);var fe=this._getTargetShape(oe),de=!u.DD.isDragging||n.Konva.hitOnDragEnabled;fe&&de?(fe._fireAndBubble(ie.pointerout,{evt:ee}),fe._fireAndBubble(ie.pointerleave,{evt:ee}),this._fire(ie.pointerleave,{evt:ee,target:this,currentTarget:this}),this[oe+"targetShape"]=null):de&&(this._fire(ie.pointerleave,{evt:ee,target:this,currentTarget:this}),this._fire(ie.pointerout,{evt:ee,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}}_pointerdown(ee){const ie=X(ee.type),oe=B(ee.type);if(ie){this.setPointersPositions(ee);var fe=!1;this._changedPointerPositions.forEach(de=>{var ce=this.getIntersection(de);if(u.DD.justDragged=!1,n.Konva["_"+oe+"ListenClick"]=!0,!ce||!ce.isListening())return;n.Konva.capturePointerEventsEnabled&&ce.setPointerCapture(de.id),this[oe+"ClickStartShape"]=ce,ce._fireAndBubble(ie.pointerdown,{evt:ee,pointerId:de.id}),fe=!0;const Se=ee.type.indexOf("touch")>=0;ce.preventDefault()&&ee.cancelable&&Se&&ee.preventDefault()}),fe||this._fire(ie.pointerdown,{evt:ee,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(ee){const ie=X(ee.type),oe=B(ee.type);if(!ie)return;u.DD.isDragging&&u.DD.node.preventDefault()&&ee.cancelable&&ee.preventDefault(),this.setPointersPositions(ee);var fe=!u.DD.isDragging||n.Konva.hitOnDragEnabled;if(!fe)return;var de={};let ce=!1;var Se=this._getTargetShape(oe);this._changedPointerPositions.forEach(ke=>{const Ne=f.getCapturedShape(ke.id)||this.getIntersection(ke),We=ke.id,Ke={evt:ee,pointerId:We};var Qe=Se!==Ne;if(Qe&&Se&&(Se._fireAndBubble(ie.pointerout,{...Ke},Ne),Se._fireAndBubble(ie.pointerleave,{...Ke},Ne)),Ne){if(de[Ne._id])return;de[Ne._id]=!0}Ne&&Ne.isListening()?(ce=!0,Qe&&(Ne._fireAndBubble(ie.pointerover,{...Ke},Se),Ne._fireAndBubble(ie.pointerenter,{...Ke},Se),this[oe+"targetShape"]=Ne),Ne._fireAndBubble(ie.pointermove,{...Ke})):Se&&(this._fire(ie.pointerover,{evt:ee,target:this,currentTarget:this,pointerId:We}),this[oe+"targetShape"]=null)}),ce||this._fire(ie.pointermove,{evt:ee,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(ee){const ie=X(ee.type),oe=B(ee.type);if(!ie)return;this.setPointersPositions(ee);const fe=this[oe+"ClickStartShape"],de=this[oe+"ClickEndShape"];var ce={};let Se=!1;this._changedPointerPositions.forEach(ke=>{const Ne=f.getCapturedShape(ke.id)||this.getIntersection(ke);if(Ne){if(Ne.releaseCapture(ke.id),ce[Ne._id])return;ce[Ne._id]=!0}const We=ke.id,Ke={evt:ee,pointerId:We};let Qe=!1;n.Konva["_"+oe+"InDblClickWindow"]?(Qe=!0,clearTimeout(this[oe+"DblTimeout"])):u.DD.justDragged||(n.Konva["_"+oe+"InDblClickWindow"]=!0,clearTimeout(this[oe+"DblTimeout"])),this[oe+"DblTimeout"]=setTimeout(function(){n.Konva["_"+oe+"InDblClickWindow"]=!1},n.Konva.dblClickWindow),Ne&&Ne.isListening()?(Se=!0,this[oe+"ClickEndShape"]=Ne,Ne._fireAndBubble(ie.pointerup,{...Ke}),n.Konva["_"+oe+"ListenClick"]&&fe&&fe===Ne&&(Ne._fireAndBubble(ie.pointerclick,{...Ke}),Qe&&de&&de===Ne&&Ne._fireAndBubble(ie.pointerdblclick,{...Ke}))):(this[oe+"ClickEndShape"]=null,n.Konva["_"+oe+"ListenClick"]&&this._fire(ie.pointerclick,{evt:ee,target:this,currentTarget:this,pointerId:We}),Qe&&this._fire(ie.pointerdblclick,{evt:ee,target:this,currentTarget:this,pointerId:We}))}),Se||this._fire(ie.pointerup,{evt:ee,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),n.Konva["_"+oe+"ListenClick"]=!1,ee.cancelable&&oe!=="touch"&&ee.preventDefault()}_contextmenu(ee){this.setPointersPositions(ee);var ie=this.getIntersection(this.getPointerPosition());ie&&ie.isListening()?ie._fireAndBubble(G,{evt:ee}):this._fire(G,{evt:ee,target:this,currentTarget:this})}_wheel(ee){this.setPointersPositions(ee);var ie=this.getIntersection(this.getPointerPosition());ie&&ie.isListening()?ie._fireAndBubble(z,{evt:ee}):this._fire(z,{evt:ee,target:this,currentTarget:this})}_pointercancel(ee){this.setPointersPositions(ee);const ie=f.getCapturedShape(ee.pointerId)||this.getIntersection(this.getPointerPosition());ie&&ie._fireAndBubble(T,f.createEvent(ee)),f.releaseCapture(ee.pointerId)}_lostpointercapture(ee){f.releaseCapture(ee.pointerId)}setPointersPositions(ee){var ie=this._getContentPosition(),oe=null,fe=null;ee=ee||window.event,ee.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(ee.touches,de=>{this._pointerPositions.push({id:de.identifier,x:(de.clientX-ie.left)/ie.scaleX,y:(de.clientY-ie.top)/ie.scaleY})}),Array.prototype.forEach.call(ee.changedTouches||ee.touches,de=>{this._changedPointerPositions.push({id:de.identifier,x:(de.clientX-ie.left)/ie.scaleX,y:(de.clientY-ie.top)/ie.scaleY})})):(oe=(ee.clientX-ie.left)/ie.scaleX,fe=(ee.clientY-ie.top)/ie.scaleY,this.pointerPos={x:oe,y:fe},this._pointerPositions=[{x:oe,y:fe,id:e.Util._getFirstPointerId(ee)}],this._changedPointerPositions=[{x:oe,y:fe,id:e.Util._getFirstPointerId(ee)}])}_setPointerPosition(ee){e.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(ee)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};var ee=this.content.getBoundingClientRect();return{top:ee.top,left:ee.left,scaleX:ee.width/this.content.clientWidth||1,scaleY:ee.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new a.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new a.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!!n.Konva.isBrowser){var ee=this.container();if(!ee)throw"Stage has no container. A container is required.";ee.innerHTML="",this.content=document.createElement("div"),this.content.style.position="relative",this.content.style.userSelect="none",this.content.className="konvajs-content",this.content.setAttribute("role","presentation"),ee.appendChild(this.content),this._resizeDOM()}}cache(){return e.Util.warn("Cache function is not allowed for stage. You may use cache only for layers, groups and shapes."),this}clearCache(){return this}batchDraw(){return this.getChildren().forEach(function(ee){ee.batchDraw()}),this}}o.Stage=ne,ne.prototype.nodeType=c,(0,l._registerNode)(ne),r.Factory.addGetterSetter(ne,"container")})(Stage$1);var Layer$2={},Shape={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Shape=o.shapes=void 0;const e=Global,r=Util,t=Factory,n=Node$1,a=Validators,u=Global,l=PointerEvents;var f="hasShadow",c="shadowRGBA",h="patternImage",y="linearGradient",E="radialGradient";let p;function _(){return p||(p=r.Util.createCanvasElement().getContext("2d"),p)}o.shapes={};function g(k){const D=this.attrs.fillRule;D?k.fill(D):k.fill()}function x(k){k.stroke()}function C(k){k.fill()}function R(k){k.stroke()}function S(){this._clearCache(f)}function A(){this._clearCache(c)}function T(){this._clearCache(h)}function w(){this._clearCache(y)}function P(){this._clearCache(E)}class O extends n.Node{constructor(D){super(D);let F;for(;F=r.Util.getRandomColor(),!(F&&!(F in o.shapes)););this.colorKey=F,o.shapes[F]=this}getContext(){return r.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return r.Util.warn("shape.getCanvas() method is deprecated. Please do not use it."),this.getLayer().getCanvas()}getSceneFunc(){return this.attrs.sceneFunc||this._sceneFunc}getHitFunc(){return this.attrs.hitFunc||this._hitFunc}hasShadow(){return this._getCache(f,this._hasShadow)}_hasShadow(){return this.shadowEnabled()&&this.shadowOpacity()!==0&&!!(this.shadowColor()||this.shadowBlur()||this.shadowOffsetX()||this.shadowOffsetY())}_getFillPattern(){return this._getCache(h,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){var D=_();const F=D.createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(F&&F.setTransform){const G=new r.Transform;G.translate(this.fillPatternX(),this.fillPatternY()),G.rotate(e.Konva.getAngle(this.fillPatternRotation())),G.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),G.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const V=G.getMatrix(),W=typeof DOMMatrix>"u"?{a:V[0],b:V[1],c:V[2],d:V[3],e:V[4],f:V[5]}:new DOMMatrix(V);F.setTransform(W)}return F}}_getLinearGradient(){return this._getCache(y,this.__getLinearGradient)}__getLinearGradient(){var D=this.fillLinearGradientColorStops();if(D){for(var F=_(),G=this.fillLinearGradientStartPoint(),V=this.fillLinearGradientEndPoint(),W=F.createLinearGradient(G.x,G.y,V.x,V.y),Z=0;Z<D.length;Z+=2)W.addColorStop(D[Z],D[Z+1]);return W}}_getRadialGradient(){return this._getCache(E,this.__getRadialGradient)}__getRadialGradient(){var D=this.fillRadialGradientColorStops();if(D){for(var F=_(),G=this.fillRadialGradientStartPoint(),V=this.fillRadialGradientEndPoint(),W=F.createRadialGradient(G.x,G.y,this.fillRadialGradientStartRadius(),V.x,V.y,this.fillRadialGradientEndRadius()),Z=0;Z<D.length;Z+=2)W.addColorStop(D[Z],D[Z+1]);return W}}getShadowRGBA(){return this._getCache(c,this._getShadowRGBA)}_getShadowRGBA(){if(this.hasShadow()){var D=r.Util.colorToRGBA(this.shadowColor());if(D)return"rgba("+D.r+","+D.g+","+D.b+","+D.a*(this.shadowOpacity()||1)+")"}}hasFill(){return this._calculate("hasFill",["fillEnabled","fill","fillPatternImage","fillLinearGradientColorStops","fillRadialGradientColorStops"],()=>this.fillEnabled()&&!!(this.fill()||this.fillPatternImage()||this.fillLinearGradientColorStops()||this.fillRadialGradientColorStops()))}hasStroke(){return this._calculate("hasStroke",["strokeEnabled","strokeWidth","stroke","strokeLinearGradientColorStops"],()=>this.strokeEnabled()&&this.strokeWidth()&&!!(this.stroke()||this.strokeLinearGradientColorStops()))}hasHitStroke(){const D=this.hitStrokeWidth();return D==="auto"?this.hasStroke():this.strokeEnabled()&&!!D}intersects(D){var F=this.getStage();if(!F)return!1;const G=F.bufferHitCanvas;return G.getContext().clear(),this.drawHit(G,void 0,!0),G.context.getImageData(Math.round(D.x),Math.round(D.y),1,1).data[3]>0}destroy(){return n.Node.prototype.destroy.call(this),delete o.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(D){var F;if(!this.getStage()||!((F=this.attrs.perfectDrawEnabled)!==null&&F!==void 0?F:!0))return!1;const V=D||this.hasFill(),W=this.hasStroke(),Z=this.getAbsoluteOpacity()!==1;if(V&&W&&Z)return!0;const q=this.hasShadow(),z=this.shadowForStrokeEnabled();return!!(V&&W&&q&&z)}setStrokeHitEnabled(D){r.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),D?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){var D=this.size();return{x:this._centroid?-D.width/2:0,y:this._centroid?-D.height/2:0,width:D.width,height:D.height}}getClientRect(D={}){const F=D.skipTransform,G=D.relativeTo,V=this.getSelfRect(),Z=!D.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,q=V.width+Z,z=V.height+Z,U=!D.skipShadow&&this.hasShadow(),I=U?this.shadowOffsetX():0,$=U?this.shadowOffsetY():0,B=q+Math.abs(I),X=z+Math.abs($),Q=U&&this.shadowBlur()||0,J=B+Q*2,ne=X+Q*2,se={width:J,height:ne,x:-(Z/2+Q)+Math.min(I,0)+V.x,y:-(Z/2+Q)+Math.min($,0)+V.y};return F?se:this._transformedRect(se,G)}drawScene(D,F){var G=this.getLayer(),V=D||G.getCanvas(),W=V.getContext(),Z=this._getCanvasCache(),q=this.getSceneFunc(),z=this.hasShadow(),U,I,$,B=V.isCache,X=F===this;if(!this.isVisible()&&!X)return this;if(Z){W.save();var Q=this.getAbsoluteTransform(F).getMatrix();return W.transform(Q[0],Q[1],Q[2],Q[3],Q[4],Q[5]),this._drawCachedSceneCanvas(W),W.restore(),this}if(!q)return this;if(W.save(),this._useBufferCanvas()&&!B){U=this.getStage(),I=U.bufferCanvas,$=I.getContext(),$.clear(),$.save(),$._applyLineJoin(this);var J=this.getAbsoluteTransform(F).getMatrix();$.transform(J[0],J[1],J[2],J[3],J[4],J[5]),q.call(this,$,this),$.restore();var ne=I.pixelRatio;z&&W._applyShadow(this),W._applyOpacity(this),W._applyGlobalCompositeOperation(this),W.drawImage(I._canvas,0,0,I.width/ne,I.height/ne)}else{if(W._applyLineJoin(this),!X){var J=this.getAbsoluteTransform(F).getMatrix();W.transform(J[0],J[1],J[2],J[3],J[4],J[5]),W._applyOpacity(this),W._applyGlobalCompositeOperation(this)}z&&W._applyShadow(this),q.call(this,W,this)}return W.restore(),this}drawHit(D,F,G=!1){if(!this.shouldDrawHit(F,G))return this;var V=this.getLayer(),W=D||V.hitCanvas,Z=W&&W.getContext(),q=this.hitFunc()||this.sceneFunc(),z=this._getCanvasCache(),U=z&&z.hit;if(this.colorKey||r.Util.warn("Looks like your canvas has a destroyed shape in it. Do not reuse shape after you destroyed it. If you want to reuse shape you should call remove() instead of destroy()"),U){Z.save();var I=this.getAbsoluteTransform(F).getMatrix();return Z.transform(I[0],I[1],I[2],I[3],I[4],I[5]),this._drawCachedHitCanvas(Z),Z.restore(),this}if(!q)return this;if(Z.save(),Z._applyLineJoin(this),!(this===F)){var B=this.getAbsoluteTransform(F).getMatrix();Z.transform(B[0],B[1],B[2],B[3],B[4],B[5])}return q.call(this,Z,this),Z.restore(),this}drawHitFromCache(D=0){var F=this._getCanvasCache(),G=this._getCachedSceneCanvas(),V=F.hit,W=V.getContext(),Z=V.getWidth(),q=V.getHeight(),z,U,I,$,B,X;W.clear(),W.drawImage(G._canvas,0,0,Z,q);try{for(z=W.getImageData(0,0,Z,q),U=z.data,I=U.length,$=r.Util._hexToRgb(this.colorKey),B=0;B<I;B+=4)X=U[B+3],X>D?(U[B]=$.r,U[B+1]=$.g,U[B+2]=$.b,U[B+3]=255):U[B+3]=0;W.putImageData(z,0,0)}catch(Q){r.Util.error("Unable to draw hit graph from cached scene canvas. "+Q.message)}return this}hasPointerCapture(D){return l.hasPointerCapture(D,this)}setPointerCapture(D){l.setPointerCapture(D,this)}releaseCapture(D){l.releaseCapture(D,this)}}o.Shape=O,O.prototype._fillFunc=g,O.prototype._strokeFunc=x,O.prototype._fillFuncHit=C,O.prototype._strokeFuncHit=R,O.prototype._centroid=!1,O.prototype.nodeType="Shape",(0,u._registerNode)(O),O.prototype.eventListeners={},O.prototype.on.call(O.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",S),O.prototype.on.call(O.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",A),O.prototype.on.call(O.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",T),O.prototype.on.call(O.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",w),O.prototype.on.call(O.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",P),t.Factory.addGetterSetter(O,"stroke",void 0,(0,a.getStringOrGradientValidator)()),t.Factory.addGetterSetter(O,"strokeWidth",2,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillAfterStrokeEnabled",!1),t.Factory.addGetterSetter(O,"hitStrokeWidth","auto",(0,a.getNumberOrAutoValidator)()),t.Factory.addGetterSetter(O,"strokeHitEnabled",!0,(0,a.getBooleanValidator)()),t.Factory.addGetterSetter(O,"perfectDrawEnabled",!0,(0,a.getBooleanValidator)()),t.Factory.addGetterSetter(O,"shadowForStrokeEnabled",!0,(0,a.getBooleanValidator)()),t.Factory.addGetterSetter(O,"lineJoin"),t.Factory.addGetterSetter(O,"lineCap"),t.Factory.addGetterSetter(O,"sceneFunc"),t.Factory.addGetterSetter(O,"hitFunc"),t.Factory.addGetterSetter(O,"dash"),t.Factory.addGetterSetter(O,"dashOffset",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"shadowColor",void 0,(0,a.getStringValidator)()),t.Factory.addGetterSetter(O,"shadowBlur",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"shadowOpacity",1,(0,a.getNumberValidator)()),t.Factory.addComponentsGetterSetter(O,"shadowOffset",["x","y"]),t.Factory.addGetterSetter(O,"shadowOffsetX",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"shadowOffsetY",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillPatternImage"),t.Factory.addGetterSetter(O,"fill",void 0,(0,a.getStringOrGradientValidator)()),t.Factory.addGetterSetter(O,"fillPatternX",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillPatternY",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillLinearGradientColorStops"),t.Factory.addGetterSetter(O,"strokeLinearGradientColorStops"),t.Factory.addGetterSetter(O,"fillRadialGradientStartRadius",0),t.Factory.addGetterSetter(O,"fillRadialGradientEndRadius",0),t.Factory.addGetterSetter(O,"fillRadialGradientColorStops"),t.Factory.addGetterSetter(O,"fillPatternRepeat","repeat"),t.Factory.addGetterSetter(O,"fillEnabled",!0),t.Factory.addGetterSetter(O,"strokeEnabled",!0),t.Factory.addGetterSetter(O,"shadowEnabled",!0),t.Factory.addGetterSetter(O,"dashEnabled",!0),t.Factory.addGetterSetter(O,"strokeScaleEnabled",!0),t.Factory.addGetterSetter(O,"fillPriority","color"),t.Factory.addComponentsGetterSetter(O,"fillPatternOffset",["x","y"]),t.Factory.addGetterSetter(O,"fillPatternOffsetX",0,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillPatternOffsetY",0,(0,a.getNumberValidator)()),t.Factory.addComponentsGetterSetter(O,"fillPatternScale",["x","y"]),t.Factory.addGetterSetter(O,"fillPatternScaleX",1,(0,a.getNumberValidator)()),t.Factory.addGetterSetter(O,"fillPatternScaleY",1,(0,a.getNumberValidator)()),t.Factory.addComponentsGetterSetter(O,"fillLinearGradientStartPoint",["x","y"]),t.Factory.addComponentsGetterSetter(O,"strokeLinearGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(O,"fillLinearGradientStartPointX",0),t.Factory.addGetterSetter(O,"strokeLinearGradientStartPointX",0),t.Factory.addGetterSetter(O,"fillLinearGradientStartPointY",0),t.Factory.addGetterSetter(O,"strokeLinearGradientStartPointY",0),t.Factory.addComponentsGetterSetter(O,"fillLinearGradientEndPoint",["x","y"]),t.Factory.addComponentsGetterSetter(O,"strokeLinearGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(O,"fillLinearGradientEndPointX",0),t.Factory.addGetterSetter(O,"strokeLinearGradientEndPointX",0),t.Factory.addGetterSetter(O,"fillLinearGradientEndPointY",0),t.Factory.addGetterSetter(O,"strokeLinearGradientEndPointY",0),t.Factory.addComponentsGetterSetter(O,"fillRadialGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(O,"fillRadialGradientStartPointX",0),t.Factory.addGetterSetter(O,"fillRadialGradientStartPointY",0),t.Factory.addComponentsGetterSetter(O,"fillRadialGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(O,"fillRadialGradientEndPointX",0),t.Factory.addGetterSetter(O,"fillRadialGradientEndPointY",0),t.Factory.addGetterSetter(O,"fillPatternRotation",0),t.Factory.addGetterSetter(O,"fillRule",void 0,(0,a.getStringValidator)()),t.Factory.backCompat(O,{dashArray:"dash",getDashArray:"getDash",setDashArray:"getDash",drawFunc:"sceneFunc",getDrawFunc:"getSceneFunc",setDrawFunc:"setSceneFunc",drawHitFunc:"hitFunc",getDrawHitFunc:"getHitFunc",setDrawHitFunc:"setHitFunc"})})(Shape);Object.defineProperty(Layer$2,"__esModule",{value:!0});Layer$2.Layer=void 0;const Util_1$b=Util,Container_1$1=Container$2,Node_1$g=Node$1,Factory_1$w=Factory,Canvas_1=Canvas$1,Validators_1$v=Validators,Shape_1$g=Shape,Global_1$k=Global;var HASH="#",BEFORE_DRAW="beforeDraw",DRAW="draw",INTERSECTION_OFFSETS=[{x:0,y:0},{x:-1,y:-1},{x:1,y:-1},{x:1,y:1},{x:-1,y:1}],INTERSECTION_OFFSETS_LEN=INTERSECTION_OFFSETS.length;let Layer$1=class extends Container_1$1.Container{constructor(e){super(e),this.canvas=new Canvas_1.SceneCanvas,this.hitCanvas=new Canvas_1.HitCanvas({pixelRatio:1}),this._waitingForDraw=!1,this.on("visibleChange.konva",this._checkVisibility),this._checkVisibility(),this.on("imageSmoothingEnabledChange.konva",this._setSmoothEnabled),this._setSmoothEnabled()}createPNGStream(){return this.canvas._canvas.createPNGStream()}getCanvas(){return this.canvas}getNativeCanvasElement(){return this.canvas._canvas}getHitCanvas(){return this.hitCanvas}getContext(){return this.getCanvas().getContext()}clear(e){return this.getContext().clear(e),this.getHitCanvas().getContext().clear(e),this}setZIndex(e){super.setZIndex(e);var r=this.getStage();return r&&r.content&&(r.content.removeChild(this.getNativeCanvasElement()),e<r.children.length-1?r.content.insertBefore(this.getNativeCanvasElement(),r.children[e+1].getCanvas()._canvas):r.content.appendChild(this.getNativeCanvasElement())),this}moveToTop(){Node_1$g.Node.prototype.moveToTop.call(this);var e=this.getStage();return e&&e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.appendChild(this.getNativeCanvasElement())),!0}moveUp(){var e=Node_1$g.Node.prototype.moveUp.call(this);if(!e)return!1;var r=this.getStage();return!r||!r.content?!1:(r.content.removeChild(this.getNativeCanvasElement()),this.index<r.children.length-1?r.content.insertBefore(this.getNativeCanvasElement(),r.children[this.index+1].getCanvas()._canvas):r.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(Node_1$g.Node.prototype.moveDown.call(this)){var e=this.getStage();if(e){var r=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),r[this.index+1].getCanvas()._canvas))}return!0}return!1}moveToBottom(){if(Node_1$g.Node.prototype.moveToBottom.call(this)){var e=this.getStage();if(e){var r=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),r[1].getCanvas()._canvas))}return!0}return!1}getLayer(){return this}remove(){var e=this.getNativeCanvasElement();return Node_1$g.Node.prototype.remove.call(this),e&&e.parentNode&&Util_1$b.Util._isInDocument(e)&&e.parentNode.removeChild(e),this}getStage(){return this.parent}setSize({width:e,height:r}){return this.canvas.setSize(e,r),this.hitCanvas.setSize(e,r),this._setSmoothEnabled(),this}_validateAdd(e){var r=e.getType();r!=="Group"&&r!=="Shape"&&Util_1$b.Util.throw("You may only add groups and shapes to a layer.")}_toKonvaCanvas(e){return e=e||{},e.width=e.width||this.getWidth(),e.height=e.height||this.getHeight(),e.x=e.x!==void 0?e.x:this.x(),e.y=e.y!==void 0?e.y:this.y(),Node_1$g.Node.prototype._toKonvaCanvas.call(this,e)}_checkVisibility(){this.visible()?this.canvas._canvas.style.display="block":this.canvas._canvas.style.display="none"}_setSmoothEnabled(){this.getContext()._context.imageSmoothingEnabled=this.imageSmoothingEnabled()}getWidth(){if(this.parent)return this.parent.width()}setWidth(){Util_1$b.Util.warn('Can not change width of layer. Use "stage.width(value)" function instead.')}getHeight(){if(this.parent)return this.parent.height()}setHeight(){Util_1$b.Util.warn('Can not change height of layer. Use "stage.height(value)" function instead.')}batchDraw(){return this._waitingForDraw||(this._waitingForDraw=!0,Util_1$b.Util.requestAnimFrame(()=>{this.draw(),this._waitingForDraw=!1})),this}getIntersection(e){if(!this.isListening()||!this.isVisible())return null;for(var r=1,t=!1;;){for(let n=0;n<INTERSECTION_OFFSETS_LEN;n++){const a=INTERSECTION_OFFSETS[n],u=this._getIntersection({x:e.x+a.x*r,y:e.y+a.y*r}),l=u.shape;if(l)return l;if(t=!!u.antialiased,!u.antialiased)break}if(t)r+=1;else return null}}_getIntersection(e){const r=this.hitCanvas.pixelRatio,t=this.hitCanvas.context.getImageData(Math.round(e.x*r),Math.round(e.y*r),1,1).data,n=t[3];if(n===255){const a=Util_1$b.Util._rgbToHex(t[0],t[1],t[2]),u=Shape_1$g.shapes[HASH+a];return u?{shape:u}:{antialiased:!0}}else if(n>0)return{antialiased:!0};return{}}drawScene(e,r){var t=this.getLayer(),n=e||t&&t.getCanvas();return this._fire(BEFORE_DRAW,{node:this}),this.clearBeforeDraw()&&n.getContext().clear(),Container_1$1.Container.prototype.drawScene.call(this,n,r),this._fire(DRAW,{node:this}),this}drawHit(e,r){var t=this.getLayer(),n=e||t&&t.hitCanvas;return t&&t.clearBeforeDraw()&&t.getHitCanvas().getContext().clear(),Container_1$1.Container.prototype.drawHit.call(this,n,r),this}enableHitGraph(){return this.hitGraphEnabled(!0),this}disableHitGraph(){return this.hitGraphEnabled(!1),this}setHitGraphEnabled(e){Util_1$b.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening(e)}getHitGraphEnabled(e){return Util_1$b.Util.warn("hitGraphEnabled method is deprecated. Please use layer.listening() instead."),this.listening()}toggleHitCanvas(){if(!(!this.parent||!this.parent.content)){var e=this.parent,r=!!this.hitCanvas._canvas.parentNode;r?e.content.removeChild(this.hitCanvas._canvas):e.content.appendChild(this.hitCanvas._canvas)}}destroy(){return Util_1$b.Util.releaseCanvas(this.getNativeCanvasElement(),this.getHitCanvas()._canvas),super.destroy()}};Layer$2.Layer=Layer$1;Layer$1.prototype.nodeType="Layer";(0,Global_1$k._registerNode)(Layer$1);Factory_1$w.Factory.addGetterSetter(Layer$1,"imageSmoothingEnabled",!0);Factory_1$w.Factory.addGetterSetter(Layer$1,"clearBeforeDraw",!0);Factory_1$w.Factory.addGetterSetter(Layer$1,"hitGraphEnabled",!0,(0,Validators_1$v.getBooleanValidator)());var FastLayer$1={};Object.defineProperty(FastLayer$1,"__esModule",{value:!0});FastLayer$1.FastLayer=void 0;const Util_1$a=Util,Layer_1=Layer$2,Global_1$j=Global;class FastLayer extends Layer_1.Layer{constructor(e){super(e),this.listening(!1),Util_1$a.Util.warn('Konva.Fast layer is deprecated. Please use "new Konva.Layer({ listening: false })" instead.')}}FastLayer$1.FastLayer=FastLayer;FastLayer.prototype.nodeType="FastLayer";(0,Global_1$j._registerNode)(FastLayer);var Group$2={};Object.defineProperty(Group$2,"__esModule",{value:!0});Group$2.Group=void 0;const Util_1$9=Util,Container_1=Container$2,Global_1$i=Global;let Group$1=class extends Container_1.Container{_validateAdd(e){var r=e.getType();r!=="Group"&&r!=="Shape"&&Util_1$9.Util.throw("You may only add groups and shapes to groups.")}};Group$2.Group=Group$1;Group$1.prototype.nodeType="Group";(0,Global_1$i._registerNode)(Group$1);var Animation$2={};Object.defineProperty(Animation$2,"__esModule",{value:!0});Animation$2.Animation=void 0;const Global_1$h=Global,Util_1$8=Util,now=function(){return Global_1$h.glob.performance&&Global_1$h.glob.performance.now?function(){return Global_1$h.glob.performance.now()}:function(){return new Date().getTime()}}();let Animation$1=class Hl{constructor(e,r){this.id=Hl.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:now(),frameRate:0},this.func=e,this.setLayers(r)}setLayers(e){let r=[];return e&&(r=Array.isArray(e)?e:[e]),this.layers=r,this}getLayers(){return this.layers}addLayer(e){const r=this.layers,t=r.length;for(let n=0;n<t;n++)if(r[n]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){const r=Hl.animations,t=r.length;for(let n=0;n<t;n++)if(r[n].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=now(),Hl._addAnimation(this),this}stop(){return Hl._removeAnimation(this),this}_updateFrameObject(e){this.frame.timeDiff=e-this.frame.lastTime,this.frame.lastTime=e,this.frame.time+=this.frame.timeDiff,this.frame.frameRate=1e3/this.frame.timeDiff}static _addAnimation(e){this.animations.push(e),this._handleAnimation()}static _removeAnimation(e){const r=e.id,t=this.animations,n=t.length;for(let a=0;a<n;a++)if(t[a].id===r){this.animations.splice(a,1);break}}static _runFrames(){const e={},r=this.animations;for(let t=0;t<r.length;t++){const n=r[t],a=n.layers,u=n.func;n._updateFrameObject(now());const l=a.length;let f;if(u?f=u.call(n,n.frame)!==!1:f=!0,!!f)for(let c=0;c<l;c++){const h=a[c];h._id!==void 0&&(e[h._id]=h)}}for(let t in e)e.hasOwnProperty(t)&&e[t].batchDraw()}static _animationLoop(){const e=Hl;e.animations.length?(e._runFrames(),Util_1$8.Util.requestAnimFrame(e._animationLoop)):e.animRunning=!1}static _handleAnimation(){this.animRunning||(this.animRunning=!0,Util_1$8.Util.requestAnimFrame(this._animationLoop))}};Animation$2.Animation=Animation$1;Animation$1.animations=[];Animation$1.animIdCounter=0;Animation$1.animRunning=!1;var Tween$1={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Easings=o.Tween=void 0;const e=Util,r=Animation$2,t=Node$1,n=Global;var a={node:1,duration:1,easing:1,onFinish:1,yoyo:1},u=1,l=2,f=3,c=0,h=["fill","stroke","shadowColor"];class y{constructor(_,g,x,C,R,S,A){this.prop=_,this.propFunc=g,this.begin=C,this._pos=C,this.duration=S,this._change=0,this.prevPos=0,this.yoyo=A,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=x,this._change=R-this.begin,this.pause()}fire(_){var g=this[_];g&&g()}setTime(_){_>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():_<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=_,this.update())}getTime(){return this._time}setPosition(_){this.prevPos=this._pos,this.propFunc(_),this._pos=_}getPosition(_){return _===void 0&&(_=this._time),this.func(_,this.begin,this._change,this.duration)}play(){this.state=l,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onPlay")}reverse(){this.state=f,this._time=this.duration-this._time,this._startTime=this.getTimer()-this._time,this.onEnterFrame(),this.fire("onReverse")}seek(_){this.pause(),this._time=_,this.update(),this.fire("onSeek")}reset(){this.pause(),this._time=0,this.update(),this.fire("onReset")}finish(){this.pause(),this._time=this.duration,this.update(),this.fire("onFinish")}update(){this.setPosition(this.getPosition(this._time)),this.fire("onUpdate")}onEnterFrame(){var _=this.getTimer()-this._startTime;this.state===l?this.setTime(_):this.state===f&&this.setTime(this.duration-_)}pause(){this.state=u,this.fire("onPause")}getTimer(){return new Date().getTime()}}class E{constructor(_){var g=this,x=_.node,C=x._id,R,S=_.easing||o.Easings.Linear,A=!!_.yoyo,T;typeof _.duration>"u"?R=.3:_.duration===0?R=.001:R=_.duration,this.node=x,this._id=c++;var w=x.getLayer()||(x instanceof n.Konva.Stage?x.getLayers():null);w||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new r.Animation(function(){g.tween.onEnterFrame()},w),this.tween=new y(T,function(P){g._tweenFunc(P)},S,0,1,R*1e3,A),this._addListeners(),E.attrs[C]||(E.attrs[C]={}),E.attrs[C][this._id]||(E.attrs[C][this._id]={}),E.tweens[C]||(E.tweens[C]={});for(T in _)a[T]===void 0&&this._addAttr(T,_[T]);this.reset(),this.onFinish=_.onFinish,this.onReset=_.onReset,this.onUpdate=_.onUpdate}_addAttr(_,g){var x=this.node,C=x._id,R,S,A,T,w,P,O,k;if(A=E.tweens[C][_],A&&delete E.attrs[C][A][_],R=x.getAttr(_),e.Util._isArray(g))if(S=[],w=Math.max(g.length,R.length),_==="points"&&g.length!==R.length&&(g.length>R.length?(O=R,R=e.Util._prepareArrayForTween(R,g,x.closed())):(P=g,g=e.Util._prepareArrayForTween(g,R,x.closed()))),_.indexOf("fill")===0)for(T=0;T<w;T++)if(T%2===0)S.push(g[T]-R[T]);else{var D=e.Util.colorToRGBA(R[T]);k=e.Util.colorToRGBA(g[T]),R[T]=D,S.push({r:k.r-D.r,g:k.g-D.g,b:k.b-D.b,a:k.a-D.a})}else for(T=0;T<w;T++)S.push(g[T]-R[T]);else h.indexOf(_)!==-1?(R=e.Util.colorToRGBA(R),k=e.Util.colorToRGBA(g),S={r:k.r-R.r,g:k.g-R.g,b:k.b-R.b,a:k.a-R.a}):S=g-R;E.attrs[C][this._id][_]={start:R,diff:S,end:g,trueEnd:P,trueStart:O},E.tweens[C][_]=this._id}_tweenFunc(_){var g=this.node,x=E.attrs[g._id][this._id],C,R,S,A,T,w,P,O;for(C in x){if(R=x[C],S=R.start,A=R.diff,O=R.end,e.Util._isArray(S))if(T=[],P=Math.max(S.length,O.length),C.indexOf("fill")===0)for(w=0;w<P;w++)w%2===0?T.push((S[w]||0)+A[w]*_):T.push("rgba("+Math.round(S[w].r+A[w].r*_)+","+Math.round(S[w].g+A[w].g*_)+","+Math.round(S[w].b+A[w].b*_)+","+(S[w].a+A[w].a*_)+")");else for(w=0;w<P;w++)T.push((S[w]||0)+A[w]*_);else h.indexOf(C)!==-1?T="rgba("+Math.round(S.r+A.r*_)+","+Math.round(S.g+A.g*_)+","+Math.round(S.b+A.b*_)+","+(S.a+A.a*_)+")":T=S+A*_;g.setAttr(C,T)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var _=this.node,g=E.attrs[_._id][this._id];g.points&&g.points.trueEnd&&_.setAttr("points",g.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var _=this.node,g=E.attrs[_._id][this._id];g.points&&g.points.trueStart&&_.points(g.points.trueStart),this.onReset&&this.onReset()},this.tween.onUpdate=()=>{this.onUpdate&&this.onUpdate.call(this)}}play(){return this.tween.play(),this}reverse(){return this.tween.reverse(),this}reset(){return this.tween.reset(),this}seek(_){return this.tween.seek(_*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var _=this.node._id,g=this._id,x=E.tweens[_],C;this.pause();for(C in x)delete E.tweens[_][C];delete E.attrs[_][g]}}o.Tween=E,E.attrs={},E.tweens={},t.Node.prototype.to=function(p){var _=p.onFinish;p.node=this,p.onFinish=function(){this.destroy(),_&&_()};var g=new E(p);g.play()},o.Easings={BackEaseIn(p,_,g,x){var C=1.70158;return g*(p/=x)*p*((C+1)*p-C)+_},BackEaseOut(p,_,g,x){var C=1.70158;return g*((p=p/x-1)*p*((C+1)*p+C)+1)+_},BackEaseInOut(p,_,g,x){var C=1.70158;return(p/=x/2)<1?g/2*(p*p*(((C*=1.525)+1)*p-C))+_:g/2*((p-=2)*p*(((C*=1.525)+1)*p+C)+2)+_},ElasticEaseIn(p,_,g,x,C,R){var S=0;return p===0?_:(p/=x)===1?_+g:(R||(R=x*.3),!C||C<Math.abs(g)?(C=g,S=R/4):S=R/(2*Math.PI)*Math.asin(g/C),-(C*Math.pow(2,10*(p-=1))*Math.sin((p*x-S)*(2*Math.PI)/R))+_)},ElasticEaseOut(p,_,g,x,C,R){var S=0;return p===0?_:(p/=x)===1?_+g:(R||(R=x*.3),!C||C<Math.abs(g)?(C=g,S=R/4):S=R/(2*Math.PI)*Math.asin(g/C),C*Math.pow(2,-10*p)*Math.sin((p*x-S)*(2*Math.PI)/R)+g+_)},ElasticEaseInOut(p,_,g,x,C,R){var S=0;return p===0?_:(p/=x/2)===2?_+g:(R||(R=x*(.3*1.5)),!C||C<Math.abs(g)?(C=g,S=R/4):S=R/(2*Math.PI)*Math.asin(g/C),p<1?-.5*(C*Math.pow(2,10*(p-=1))*Math.sin((p*x-S)*(2*Math.PI)/R))+_:C*Math.pow(2,-10*(p-=1))*Math.sin((p*x-S)*(2*Math.PI)/R)*.5+g+_)},BounceEaseOut(p,_,g,x){return(p/=x)<1/2.75?g*(7.5625*p*p)+_:p<2/2.75?g*(7.5625*(p-=1.5/2.75)*p+.75)+_:p<2.5/2.75?g*(7.5625*(p-=2.25/2.75)*p+.9375)+_:g*(7.5625*(p-=2.625/2.75)*p+.984375)+_},BounceEaseIn(p,_,g,x){return g-o.Easings.BounceEaseOut(x-p,0,g,x)+_},BounceEaseInOut(p,_,g,x){return p<x/2?o.Easings.BounceEaseIn(p*2,0,g,x)*.5+_:o.Easings.BounceEaseOut(p*2-x,0,g,x)*.5+g*.5+_},EaseIn(p,_,g,x){return g*(p/=x)*p+_},EaseOut(p,_,g,x){return-g*(p/=x)*(p-2)+_},EaseInOut(p,_,g,x){return(p/=x/2)<1?g/2*p*p+_:-g/2*(--p*(p-2)-1)+_},StrongEaseIn(p,_,g,x){return g*(p/=x)*p*p*p*p+_},StrongEaseOut(p,_,g,x){return g*((p=p/x-1)*p*p*p*p+1)+_},StrongEaseInOut(p,_,g,x){return(p/=x/2)<1?g/2*p*p*p*p*p+_:g/2*((p-=2)*p*p*p*p+2)+_},Linear(p,_,g,x){return g*p/x+_}}})(Tween$1);(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.Konva=void 0;const e=Global,r=Util,t=Node$1,n=Container$2,a=Stage$1,u=Layer$2,l=FastLayer$1,f=Group$2,c=DragAndDrop,h=Shape,y=Animation$2,E=Tween$1,p=Context$2,_=Canvas$1;o.Konva=r.Util._assign(e.Konva,{Util:r.Util,Transform:r.Transform,Node:t.Node,Container:n.Container,Stage:a.Stage,stages:a.stages,Layer:u.Layer,FastLayer:l.FastLayer,Group:f.Group,DD:c.DD,Shape:h.Shape,shapes:h.shapes,Animation:y.Animation,Tween:E.Tween,Easings:E.Easings,Context:p.Context,Canvas:_.Canvas}),o.default=o.Konva})(_CoreInternals);var Arc$1={};Object.defineProperty(Arc$1,"__esModule",{value:!0});Arc$1.Arc=void 0;const Factory_1$v=Factory,Shape_1$f=Shape,Global_1$g=Global,Validators_1$u=Validators,Global_2$2=Global;class Arc extends Shape_1$f.Shape{_sceneFunc(e){var r=Global_1$g.Konva.getAngle(this.angle()),t=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,r,t),e.arc(0,0,this.innerRadius(),r,0,!t),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}getSelfRect(){const e=this.innerRadius(),r=this.outerRadius(),t=this.clockwise(),n=Global_1$g.Konva.getAngle(t?360-this.angle():this.angle()),a=Math.cos(Math.min(n,Math.PI)),u=1,l=Math.sin(Math.min(Math.max(Math.PI,n),3*Math.PI/2)),f=Math.sin(Math.min(n,Math.PI/2)),c=a*(a>0?e:r),h=u*r,y=l*(l>0?e:r),E=f*(f>0?r:e);return{x:c,y:t?-1*E:y,width:h-c,height:E-y}}}Arc$1.Arc=Arc;Arc.prototype._centroid=!0;Arc.prototype.className="Arc";Arc.prototype._attrsAffectingSize=["innerRadius","outerRadius"];(0,Global_2$2._registerNode)(Arc);Factory_1$v.Factory.addGetterSetter(Arc,"innerRadius",0,(0,Validators_1$u.getNumberValidator)());Factory_1$v.Factory.addGetterSetter(Arc,"outerRadius",0,(0,Validators_1$u.getNumberValidator)());Factory_1$v.Factory.addGetterSetter(Arc,"angle",0,(0,Validators_1$u.getNumberValidator)());Factory_1$v.Factory.addGetterSetter(Arc,"clockwise",!1,(0,Validators_1$u.getBooleanValidator)());var Arrow$1={},Line$2={};Object.defineProperty(Line$2,"__esModule",{value:!0});Line$2.Line=void 0;const Factory_1$u=Factory,Shape_1$e=Shape,Validators_1$t=Validators,Global_1$f=Global;function getControlPoints(o,e,r,t,n,a,u){var l=Math.sqrt(Math.pow(r-o,2)+Math.pow(t-e,2)),f=Math.sqrt(Math.pow(n-r,2)+Math.pow(a-t,2)),c=u*l/(l+f),h=u*f/(l+f),y=r-c*(n-o),E=t-c*(a-e),p=r+h*(n-o),_=t+h*(a-e);return[y,E,p,_]}function expandPoints(o,e){var r=o.length,t=[],n,a;for(n=2;n<r-2;n+=2)a=getControlPoints(o[n-2],o[n-1],o[n],o[n+1],o[n+2],o[n+3],e),!isNaN(a[0])&&(t.push(a[0]),t.push(a[1]),t.push(o[n]),t.push(o[n+1]),t.push(a[2]),t.push(a[3]));return t}let Line$1=class extends Shape_1$e.Shape{constructor(e){super(e),this.on("pointsChange.konva tensionChange.konva closedChange.konva bezierChange.konva",function(){this._clearCache("tensionPoints")})}_sceneFunc(e){var r=this.points(),t=r.length,n=this.tension(),a=this.closed(),u=this.bezier(),l,f,c;if(t){if(e.beginPath(),e.moveTo(r[0],r[1]),n!==0&&t>4){for(l=this.getTensionPoints(),f=l.length,c=a?0:4,a||e.quadraticCurveTo(l[0],l[1],l[2],l[3]);c<f-2;)e.bezierCurveTo(l[c++],l[c++],l[c++],l[c++],l[c++],l[c++]);a||e.quadraticCurveTo(l[f-2],l[f-1],r[t-2],r[t-1])}else if(u)for(c=2;c<t;)e.bezierCurveTo(r[c++],r[c++],r[c++],r[c++],r[c++],r[c++]);else for(c=2;c<t;c+=2)e.lineTo(r[c],r[c+1]);a?(e.closePath(),e.fillStrokeShape(this)):e.strokeShape(this)}}getTensionPoints(){return this._getCache("tensionPoints",this._getTensionPoints)}_getTensionPoints(){return this.closed()?this._getTensionPointsClosed():expandPoints(this.points(),this.tension())}_getTensionPointsClosed(){var e=this.points(),r=e.length,t=this.tension(),n=getControlPoints(e[r-2],e[r-1],e[0],e[1],e[2],e[3],t),a=getControlPoints(e[r-4],e[r-3],e[r-2],e[r-1],e[0],e[1],t),u=expandPoints(e,t),l=[n[2],n[3]].concat(u).concat([a[0],a[1],e[r-2],e[r-1],a[2],a[3],n[0],n[1],e[0],e[1]]);return l}getWidth(){return this.getSelfRect().width}getHeight(){return this.getSelfRect().height}getSelfRect(){var e=this.points();if(e.length<4)return{x:e[0]||0,y:e[1]||0,width:0,height:0};this.tension()!==0?e=[e[0],e[1],...this._getTensionPoints(),e[e.length-2],e[e.length-1]]:e=this.points();for(var r=e[0],t=e[0],n=e[1],a=e[1],u,l,f=0;f<e.length/2;f++)u=e[f*2],l=e[f*2+1],r=Math.min(r,u),t=Math.max(t,u),n=Math.min(n,l),a=Math.max(a,l);return{x:r,y:n,width:t-r,height:a-n}}};Line$2.Line=Line$1;Line$1.prototype.className="Line";Line$1.prototype._attrsAffectingSize=["points","bezier","tension"];(0,Global_1$f._registerNode)(Line$1);Factory_1$u.Factory.addGetterSetter(Line$1,"closed",!1);Factory_1$u.Factory.addGetterSetter(Line$1,"bezier",!1);Factory_1$u.Factory.addGetterSetter(Line$1,"tension",0,(0,Validators_1$t.getNumberValidator)());Factory_1$u.Factory.addGetterSetter(Line$1,"points",[],(0,Validators_1$t.getNumberArrayValidator)());var Path$1={},BezierFunctions={};(function(o){Object.defineProperty(o,"__esModule",{value:!0}),o.t2length=o.getQuadraticArcLength=o.getCubicArcLength=o.binomialCoefficients=o.cValues=o.tValues=void 0,o.tValues=[[],[],[-.5773502691896257,.5773502691896257],[0,-.7745966692414834,.7745966692414834],[-.33998104358485626,.33998104358485626,-.8611363115940526,.8611363115940526],[0,-.5384693101056831,.5384693101056831,-.906179845938664,.906179845938664],[.6612093864662645,-.6612093864662645,-.2386191860831969,.2386191860831969,-.932469514203152,.932469514203152],[0,.4058451513773972,-.4058451513773972,-.7415311855993945,.7415311855993945,-.9491079123427585,.9491079123427585],[-.1834346424956498,.1834346424956498,-.525532409916329,.525532409916329,-.7966664774136267,.7966664774136267,-.9602898564975363,.9602898564975363],[0,-.8360311073266358,.8360311073266358,-.9681602395076261,.9681602395076261,-.3242534234038089,.3242534234038089,-.6133714327005904,.6133714327005904],[-.14887433898163122,.14887433898163122,-.4333953941292472,.4333953941292472,-.6794095682990244,.6794095682990244,-.8650633666889845,.8650633666889845,-.9739065285171717,.9739065285171717],[0,-.26954315595234496,.26954315595234496,-.5190961292068118,.5190961292068118,-.7301520055740494,.7301520055740494,-.8870625997680953,.8870625997680953,-.978228658146057,.978228658146057],[-.1252334085114689,.1252334085114689,-.3678314989981802,.3678314989981802,-.5873179542866175,.5873179542866175,-.7699026741943047,.7699026741943047,-.9041172563704749,.9041172563704749,-.9815606342467192,.9815606342467192],[0,-.2304583159551348,.2304583159551348,-.44849275103644687,.44849275103644687,-.6423493394403402,.6423493394403402,-.8015780907333099,.8015780907333099,-.9175983992229779,.9175983992229779,-.9841830547185881,.9841830547185881],[-.10805494870734367,.10805494870734367,-.31911236892788974,.31911236892788974,-.5152486363581541,.5152486363581541,-.6872929048116855,.6872929048116855,-.827201315069765,.827201315069765,-.9284348836635735,.9284348836635735,-.9862838086968123,.9862838086968123],[0,-.20119409399743451,.20119409399743451,-.3941513470775634,.3941513470775634,-.5709721726085388,.5709721726085388,-.7244177313601701,.7244177313601701,-.8482065834104272,.8482065834104272,-.937273392400706,.937273392400706,-.9879925180204854,.9879925180204854],[-.09501250983763744,.09501250983763744,-.2816035507792589,.2816035507792589,-.45801677765722737,.45801677765722737,-.6178762444026438,.6178762444026438,-.755404408355003,.755404408355003,-.8656312023878318,.8656312023878318,-.9445750230732326,.9445750230732326,-.9894009349916499,.9894009349916499],[0,-.17848418149584785,.17848418149584785,-.3512317634538763,.3512317634538763,-.5126905370864769,.5126905370864769,-.6576711592166907,.6576711592166907,-.7815140038968014,.7815140038968014,-.8802391537269859,.8802391537269859,-.9506755217687678,.9506755217687678,-.9905754753144174,.9905754753144174],[-.0847750130417353,.0847750130417353,-.2518862256915055,.2518862256915055,-.41175116146284263,.41175116146284263,-.5597708310739475,.5597708310739475,-.6916870430603532,.6916870430603532,-.8037049589725231,.8037049589725231,-.8926024664975557,.8926024664975557,-.9558239495713977,.9558239495713977,-.9915651684209309,.9915651684209309],[0,-.16035864564022537,.16035864564022537,-.31656409996362983,.31656409996362983,-.46457074137596094,.46457074137596094,-.600545304661681,.600545304661681,-.7209661773352294,.7209661773352294,-.8227146565371428,.8227146565371428,-.9031559036148179,.9031559036148179,-.96020815213483,.96020815213483,-.9924068438435844,.9924068438435844],[-.07652652113349734,.07652652113349734,-.22778585114164507,.22778585114164507,-.37370608871541955,.37370608871541955,-.5108670019508271,.5108670019508271,-.636053680726515,.636053680726515,-.7463319064601508,.7463319064601508,-.8391169718222188,.8391169718222188,-.912234428251326,.912234428251326,-.9639719272779138,.9639719272779138,-.9931285991850949,.9931285991850949],[0,-.1455618541608951,.1455618541608951,-.2880213168024011,.2880213168024011,-.4243421202074388,.4243421202074388,-.5516188358872198,.5516188358872198,-.6671388041974123,.6671388041974123,-.7684399634756779,.7684399634756779,-.8533633645833173,.8533633645833173,-.9200993341504008,.9200993341504008,-.9672268385663063,.9672268385663063,-.9937521706203895,.9937521706203895],[-.06973927331972223,.06973927331972223,-.20786042668822127,.20786042668822127,-.34193582089208424,.34193582089208424,-.469355837986757,.469355837986757,-.5876404035069116,.5876404035069116,-.6944872631866827,.6944872631866827,-.7878168059792081,.7878168059792081,-.8658125777203002,.8658125777203002,-.926956772187174,.926956772187174,-.9700604978354287,.9700604978354287,-.9942945854823992,.9942945854823992],[0,-.1332568242984661,.1332568242984661,-.26413568097034495,.26413568097034495,-.3903010380302908,.3903010380302908,-.5095014778460075,.5095014778460075,-.6196098757636461,.6196098757636461,-.7186613631319502,.7186613631319502,-.8048884016188399,.8048884016188399,-.8767523582704416,.8767523582704416,-.9329710868260161,.9329710868260161,-.9725424712181152,.9725424712181152,-.9947693349975522,.9947693349975522],[-.06405689286260563,.06405689286260563,-.1911188674736163,.1911188674736163,-.3150426796961634,.3150426796961634,-.4337935076260451,.4337935076260451,-.5454214713888396,.5454214713888396,-.6480936519369755,.6480936519369755,-.7401241915785544,.7401241915785544,-.820001985973903,.820001985973903,-.8864155270044011,.8864155270044011,-.9382745520027328,.9382745520027328,-.9747285559713095,.9747285559713095,-.9951872199970213,.9951872199970213]],o.cValues=[[],[],[1,1],[.8888888888888888,.5555555555555556,.5555555555555556],[.6521451548625461,.6521451548625461,.34785484513745385,.34785484513745385],[.5688888888888889,.47862867049936647,.47862867049936647,.23692688505618908,.23692688505618908],[.3607615730481386,.3607615730481386,.46791393457269104,.46791393457269104,.17132449237917036,.17132449237917036],[.4179591836734694,.3818300505051189,.3818300505051189,.27970539148927664,.27970539148927664,.1294849661688697,.1294849661688697],[.362683783378362,.362683783378362,.31370664587788727,.31370664587788727,.22238103445337448,.22238103445337448,.10122853629037626,.10122853629037626],[.3302393550012598,.1806481606948574,.1806481606948574,.08127438836157441,.08127438836157441,.31234707704000286,.31234707704000286,.26061069640293544,.26061069640293544],[.29552422471475287,.29552422471475287,.26926671930999635,.26926671930999635,.21908636251598204,.21908636251598204,.1494513491505806,.1494513491505806,.06667134430868814,.06667134430868814],[.2729250867779006,.26280454451024665,.26280454451024665,.23319376459199048,.23319376459199048,.18629021092773426,.18629021092773426,.1255803694649046,.1255803694649046,.05566856711617366,.05566856711617366],[.24914704581340277,.24914704581340277,.2334925365383548,.2334925365383548,.20316742672306592,.20316742672306592,.16007832854334622,.16007832854334622,.10693932599531843,.10693932599531843,.04717533638651183,.04717533638651183],[.2325515532308739,.22628318026289723,.22628318026289723,.2078160475368885,.2078160475368885,.17814598076194574,.17814598076194574,.13887351021978725,.13887351021978725,.09212149983772845,.09212149983772845,.04048400476531588,.04048400476531588],[.2152638534631578,.2152638534631578,.2051984637212956,.2051984637212956,.18553839747793782,.18553839747793782,.15720316715819355,.15720316715819355,.12151857068790319,.12151857068790319,.08015808715976021,.08015808715976021,.03511946033175186,.03511946033175186],[.2025782419255613,.19843148532711158,.19843148532711158,.1861610000155622,.1861610000155622,.16626920581699392,.16626920581699392,.13957067792615432,.13957067792615432,.10715922046717194,.10715922046717194,.07036604748810812,.07036604748810812,.03075324199611727,.03075324199611727],[.1894506104550685,.1894506104550685,.18260341504492358,.18260341504492358,.16915651939500254,.16915651939500254,.14959598881657674,.14959598881657674,.12462897125553388,.12462897125553388,.09515851168249279,.09515851168249279,.062253523938647894,.062253523938647894,.027152459411754096,.027152459411754096],[.17944647035620653,.17656270536699264,.17656270536699264,.16800410215645004,.16800410215645004,.15404576107681028,.15404576107681028,.13513636846852548,.13513636846852548,.11188384719340397,.11188384719340397,.08503614831717918,.08503614831717918,.0554595293739872,.0554595293739872,.02414830286854793,.02414830286854793],[.1691423829631436,.1691423829631436,.16427648374583273,.16427648374583273,.15468467512626524,.15468467512626524,.14064291467065065,.14064291467065065,.12255520671147846,.12255520671147846,.10094204410628717,.10094204410628717,.07642573025488905,.07642573025488905,.0497145488949698,.0497145488949698,.02161601352648331,.02161601352648331],[.1610544498487837,.15896884339395434,.15896884339395434,.15276604206585967,.15276604206585967,.1426067021736066,.1426067021736066,.12875396253933621,.12875396253933621,.11156664554733399,.11156664554733399,.09149002162245,.09149002162245,.06904454273764123,.06904454273764123,.0448142267656996,.0448142267656996,.019461788229726478,.019461788229726478],[.15275338713072584,.15275338713072584,.14917298647260374,.14917298647260374,.14209610931838204,.14209610931838204,.13168863844917664,.13168863844917664,.11819453196151841,.11819453196151841,.10193011981724044,.10193011981724044,.08327674157670475,.08327674157670475,.06267204833410907,.06267204833410907,.04060142980038694,.04060142980038694,.017614007139152118,.017614007139152118],[.14608113364969041,.14452440398997005,.14452440398997005,.13988739479107315,.13988739479107315,.13226893863333747,.13226893863333747,.12183141605372853,.12183141605372853,.10879729916714838,.10879729916714838,.09344442345603386,.09344442345603386,.0761001136283793,.0761001136283793,.057134425426857205,.057134425426857205,.036953789770852494,.036953789770852494,.016017228257774335,.016017228257774335],[.13925187285563198,.13925187285563198,.13654149834601517,.13654149834601517,.13117350478706238,.13117350478706238,.12325237681051242,.12325237681051242,.11293229608053922,.11293229608053922,.10041414444288096,.10041414444288096,.08594160621706773,.08594160621706773,.06979646842452049,.06979646842452049,.052293335152683286,.052293335152683286,.03377490158481415,.03377490158481415,.0146279952982722,.0146279952982722],[.13365457218610619,.1324620394046966,.1324620394046966,.12890572218808216,.12890572218808216,.12304908430672953,.12304908430672953,.11499664022241136,.11499664022241136,.10489209146454141,.10489209146454141,.09291576606003515,.09291576606003515,.07928141177671895,.07928141177671895,.06423242140852585,.06423242140852585,.04803767173108467,.04803767173108467,.030988005856979445,.030988005856979445,.013411859487141771,.013411859487141771],[.12793819534675216,.12793819534675216,.1258374563468283,.1258374563468283,.12167047292780339,.12167047292780339,.1155056680537256,.1155056680537256,.10744427011596563,.10744427011596563,.09761865210411388,.09761865210411388,.08619016153195327,.08619016153195327,.0733464814110803,.0733464814110803,.05929858491543678,.05929858491543678,.04427743881741981,.04427743881741981,.028531388628933663,.028531388628933663,.0123412297999872,.0123412297999872]],o.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]];const e=(u,l,f)=>{let c,h,y;c=f/2,h=0;for(let p=0;p<20;p++)y=c*o.tValues[20][p]+c,h+=o.cValues[20][p]*t(u,l,y);return c*h};o.getCubicArcLength=e;const r=(u,l,f)=>{f===void 0&&(f=1);const c=u[0]-2*u[1]+u[2],h=l[0]-2*l[1]+l[2],y=2*u[1]-2*u[0],E=2*l[1]-2*l[0],p=4*(c*c+h*h),_=4*(c*y+h*E),g=y*y+E*E;if(p===0)return f*Math.sqrt(Math.pow(u[2]-u[0],2)+Math.pow(l[2]-l[0],2));const x=_/(2*p),C=g/p,R=f+x,S=C-x*x,A=R*R+S>0?Math.sqrt(R*R+S):0,T=x*x+S>0?Math.sqrt(x*x+S):0,w=x+Math.sqrt(x*x+S)!==0?S*Math.log(Math.abs((R+A)/(x+T))):0;return Math.sqrt(p)/2*(R*A-x*T+w)};o.getQuadraticArcLength=r;function t(u,l,f){const c=n(1,f,u),h=n(1,f,l),y=c*c+h*h;return Math.sqrt(y)}const n=(u,l,f)=>{const c=f.length-1;let h,y;if(c===0)return 0;if(u===0){y=0;for(let E=0;E<=c;E++)y+=o.binomialCoefficients[c][E]*Math.pow(1-l,c-E)*Math.pow(l,E)*f[E];return y}else{h=new Array(c);for(let E=0;E<c;E++)h[E]=c*(f[E+1]-f[E]);return n(u-1,l,h)}},a=(u,l,f)=>{let c=1,h=u/l,y=(u-f(h))/l,E=0;for(;c>.001;){const p=f(h+y),_=Math.abs(u-p)/l;if(_<c)c=_,h+=y;else{const g=f(h-y),x=Math.abs(u-g)/l;x<c?(c=x,h-=y):y/=2}if(E++,E>500)break}return h};o.t2length=a})(BezierFunctions);Object.defineProperty(Path$1,"__esModule",{value:!0});Path$1.Path=void 0;const Factory_1$t=Factory,Shape_1$d=Shape,Global_1$e=Global,BezierFunctions_1=BezierFunctions;class Path extends Shape_1$d.Shape{constructor(e){super(e),this.dataArray=[],this.pathLength=0,this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute()})}_readDataAttribute(){this.dataArray=Path.parsePathData(this.data()),this.pathLength=Path.getPathLength(this.dataArray)}_sceneFunc(e){var r=this.dataArray;e.beginPath();for(var t=!1,n=0;n<r.length;n++){var a=r[n].command,u=r[n].points;switch(a){case"L":e.lineTo(u[0],u[1]);break;case"M":e.moveTo(u[0],u[1]);break;case"C":e.bezierCurveTo(u[0],u[1],u[2],u[3],u[4],u[5]);break;case"Q":e.quadraticCurveTo(u[0],u[1],u[2],u[3]);break;case"A":var l=u[0],f=u[1],c=u[2],h=u[3],y=u[4],E=u[5],p=u[6],_=u[7],g=c>h?c:h,x=c>h?1:c/h,C=c>h?h/c:1;e.translate(l,f),e.rotate(p),e.scale(x,C),e.arc(0,0,g,y,y+E,1-_),e.scale(1/x,1/C),e.rotate(-p),e.translate(-l,-f);break;case"z":t=!0,e.closePath();break}}!t&&!this.hasFill()?e.strokeShape(this):e.fillStrokeShape(this)}getSelfRect(){var e=[];this.dataArray.forEach(function(c){if(c.command==="A"){var h=c.points[4],y=c.points[5],E=c.points[4]+y,p=Math.PI/180;if(Math.abs(h-E)<p&&(p=Math.abs(h-E)),y<0)for(let _=h-p;_>E;_-=p){const g=Path.getPointOnEllipticalArc(c.points[0],c.points[1],c.points[2],c.points[3],_,0);e.push(g.x,g.y)}else for(let _=h+p;_<E;_+=p){const g=Path.getPointOnEllipticalArc(c.points[0],c.points[1],c.points[2],c.points[3],_,0);e.push(g.x,g.y)}}else if(c.command==="C")for(let _=0;_<=1;_+=.01){const g=Path.getPointOnCubicBezier(_,c.start.x,c.start.y,c.points[0],c.points[1],c.points[2],c.points[3],c.points[4],c.points[5]);e.push(g.x,g.y)}else e=e.concat(c.points)});for(var r=e[0],t=e[0],n=e[1],a=e[1],u,l,f=0;f<e.length/2;f++)u=e[f*2],l=e[f*2+1],isNaN(u)||(r=Math.min(r,u),t=Math.max(t,u)),isNaN(l)||(n=Math.min(n,l),a=Math.max(a,l));return{x:r,y:n,width:t-r,height:a-n}}getLength(){return this.pathLength}getPointAtLength(e){return Path.getPointAtLengthOfDataArray(e,this.dataArray)}static getLineLength(e,r,t,n){return Math.sqrt((t-e)*(t-e)+(n-r)*(n-r))}static getPathLength(e){let r=0;for(var t=0;t<e.length;++t)r+=e[t].pathLength;return r}static getPointAtLengthOfDataArray(e,r){var t,n=0,a=r.length;if(!a)return null;for(;n<a&&e>r[n].pathLength;)e-=r[n].pathLength,++n;if(n===a)return t=r[n-1].points.slice(-2),{x:t[0],y:t[1]};if(e<.01)return t=r[n].points.slice(0,2),{x:t[0],y:t[1]};var u=r[n],l=u.points;switch(u.command){case"L":return Path.getPointOnLine(e,u.start.x,u.start.y,l[0],l[1]);case"C":return Path.getPointOnCubicBezier((0,BezierFunctions_1.t2length)(e,Path.getPathLength(r),g=>(0,BezierFunctions_1.getCubicArcLength)([u.start.x,l[0],l[2],l[4]],[u.start.y,l[1],l[3],l[5]],g)),u.start.x,u.start.y,l[0],l[1],l[2],l[3],l[4],l[5]);case"Q":return Path.getPointOnQuadraticBezier((0,BezierFunctions_1.t2length)(e,Path.getPathLength(r),g=>(0,BezierFunctions_1.getQuadraticArcLength)([u.start.x,l[0],l[2]],[u.start.y,l[1],l[3]],g)),u.start.x,u.start.y,l[0],l[1],l[2],l[3]);case"A":var f=l[0],c=l[1],h=l[2],y=l[3],E=l[4],p=l[5],_=l[6];return E+=p*e/u.pathLength,Path.getPointOnEllipticalArc(f,c,h,y,E,_)}return null}static getPointOnLine(e,r,t,n,a,u,l){u===void 0&&(u=r),l===void 0&&(l=t);var f=(a-t)/(n-r+1e-8),c=Math.sqrt(e*e/(1+f*f));n<r&&(c*=-1);var h=f*c,y;if(n===r)y={x:u,y:l+h};else if((l-t)/(u-r+1e-8)===f)y={x:u+c,y:l+h};else{var E,p,_=this.getLineLength(r,t,n,a),g=(u-r)*(n-r)+(l-t)*(a-t);g=g/(_*_),E=r+g*(n-r),p=t+g*(a-t);var x=this.getLineLength(u,l,E,p),C=Math.sqrt(e*e-x*x);c=Math.sqrt(C*C/(1+f*f)),n<r&&(c*=-1),h=f*c,y={x:E+c,y:p+h}}return y}static getPointOnCubicBezier(e,r,t,n,a,u,l,f,c){function h(x){return x*x*x}function y(x){return 3*x*x*(1-x)}function E(x){return 3*x*(1-x)*(1-x)}function p(x){return(1-x)*(1-x)*(1-x)}var _=f*h(e)+u*y(e)+n*E(e)+r*p(e),g=c*h(e)+l*y(e)+a*E(e)+t*p(e);return{x:_,y:g}}static getPointOnQuadraticBezier(e,r,t,n,a,u,l){function f(p){return p*p}function c(p){return 2*p*(1-p)}function h(p){return(1-p)*(1-p)}var y=u*f(e)+n*c(e)+r*h(e),E=l*f(e)+a*c(e)+t*h(e);return{x:y,y:E}}static getPointOnEllipticalArc(e,r,t,n,a,u){var l=Math.cos(u),f=Math.sin(u),c={x:t*Math.cos(a),y:n*Math.sin(a)};return{x:e+(c.x*l-c.y*f),y:r+(c.x*f+c.y*l)}}static parsePathData(e){if(!e)return[];var r=e,t=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];r=r.replace(new RegExp(" ","g"),",");for(var n=0;n<t.length;n++)r=r.replace(new RegExp(t[n],"g"),"|"+t[n]);var a=r.split("|"),u=[],l=[],f=0,c=0,h=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,y;for(n=1;n<a.length;n++){var E=a[n],p=E.charAt(0);for(E=E.slice(1),l.length=0;y=h.exec(E);)l.push(y[0]);for(var _=[],g=0,x=l.length;g<x;g++){if(l[g]==="00"){_.push(0,0);continue}var C=parseFloat(l[g]);isNaN(C)?_.push(0):_.push(C)}for(;_.length>0&&!isNaN(_[0]);){var R="",S=[],A=f,T=c,w,P,O,k,D,F,G,V,W,Z;switch(p){case"l":f+=_.shift(),c+=_.shift(),R="L",S.push(f,c);break;case"L":f=_.shift(),c=_.shift(),S.push(f,c);break;case"m":var q=_.shift(),z=_.shift();if(f+=q,c+=z,R="M",u.length>2&&u[u.length-1].command==="z"){for(var U=u.length-2;U>=0;U--)if(u[U].command==="M"){f=u[U].points[0]+q,c=u[U].points[1]+z;break}}S.push(f,c),p="l";break;case"M":f=_.shift(),c=_.shift(),R="M",S.push(f,c),p="L";break;case"h":f+=_.shift(),R="L",S.push(f,c);break;case"H":f=_.shift(),R="L",S.push(f,c);break;case"v":c+=_.shift(),R="L",S.push(f,c);break;case"V":c=_.shift(),R="L",S.push(f,c);break;case"C":S.push(_.shift(),_.shift(),_.shift(),_.shift()),f=_.shift(),c=_.shift(),S.push(f,c);break;case"c":S.push(f+_.shift(),c+_.shift(),f+_.shift(),c+_.shift()),f+=_.shift(),c+=_.shift(),R="C",S.push(f,c);break;case"S":P=f,O=c,w=u[u.length-1],w.command==="C"&&(P=f+(f-w.points[2]),O=c+(c-w.points[3])),S.push(P,O,_.shift(),_.shift()),f=_.shift(),c=_.shift(),R="C",S.push(f,c);break;case"s":P=f,O=c,w=u[u.length-1],w.command==="C"&&(P=f+(f-w.points[2]),O=c+(c-w.points[3])),S.push(P,O,f+_.shift(),c+_.shift()),f+=_.shift(),c+=_.shift(),R="C",S.push(f,c);break;case"Q":S.push(_.shift(),_.shift()),f=_.shift(),c=_.shift(),S.push(f,c);break;case"q":S.push(f+_.shift(),c+_.shift()),f+=_.shift(),c+=_.shift(),R="Q",S.push(f,c);break;case"T":P=f,O=c,w=u[u.length-1],w.command==="Q"&&(P=f+(f-w.points[0]),O=c+(c-w.points[1])),f=_.shift(),c=_.shift(),R="Q",S.push(P,O,f,c);break;case"t":P=f,O=c,w=u[u.length-1],w.command==="Q"&&(P=f+(f-w.points[0]),O=c+(c-w.points[1])),f+=_.shift(),c+=_.shift(),R="Q",S.push(P,O,f,c);break;case"A":k=_.shift(),D=_.shift(),F=_.shift(),G=_.shift(),V=_.shift(),W=f,Z=c,f=_.shift(),c=_.shift(),R="A",S=this.convertEndpointToCenterParameterization(W,Z,f,c,G,V,k,D,F);break;case"a":k=_.shift(),D=_.shift(),F=_.shift(),G=_.shift(),V=_.shift(),W=f,Z=c,f+=_.shift(),c+=_.shift(),R="A",S=this.convertEndpointToCenterParameterization(W,Z,f,c,G,V,k,D,F);break}u.push({command:R||p,points:S,start:{x:A,y:T},pathLength:this.calcLength(A,T,R||p,S)})}(p==="z"||p==="Z")&&u.push({command:"z",points:[],start:void 0,pathLength:0})}return u}static calcLength(e,r,t,n){var a,u,l,f,c=Path;switch(t){case"L":return c.getLineLength(e,r,n[0],n[1]);case"C":return(0,BezierFunctions_1.getCubicArcLength)([e,n[0],n[2],n[4]],[r,n[1],n[3],n[5]],1);case"Q":return(0,BezierFunctions_1.getQuadraticArcLength)([e,n[0],n[2]],[r,n[1],n[3]],1);case"A":a=0;var h=n[4],y=n[5],E=n[4]+y,p=Math.PI/180;if(Math.abs(h-E)<p&&(p=Math.abs(h-E)),u=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],h,0),y<0)for(f=h-p;f>E;f-=p)l=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],f,0),a+=c.getLineLength(u.x,u.y,l.x,l.y),u=l;else for(f=h+p;f<E;f+=p)l=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],f,0),a+=c.getLineLength(u.x,u.y,l.x,l.y),u=l;return l=c.getPointOnEllipticalArc(n[0],n[1],n[2],n[3],E,0),a+=c.getLineLength(u.x,u.y,l.x,l.y),a}return 0}static convertEndpointToCenterParameterization(e,r,t,n,a,u,l,f,c){var h=c*(Math.PI/180),y=Math.cos(h)*(e-t)/2+Math.sin(h)*(r-n)/2,E=-1*Math.sin(h)*(e-t)/2+Math.cos(h)*(r-n)/2,p=y*y/(l*l)+E*E/(f*f);p>1&&(l*=Math.sqrt(p),f*=Math.sqrt(p));var _=Math.sqrt((l*l*(f*f)-l*l*(E*E)-f*f*(y*y))/(l*l*(E*E)+f*f*(y*y)));a===u&&(_*=-1),isNaN(_)&&(_=0);var g=_*l*E/f,x=_*-f*y/l,C=(e+t)/2+Math.cos(h)*g-Math.sin(h)*x,R=(r+n)/2+Math.sin(h)*g+Math.cos(h)*x,S=function(D){return Math.sqrt(D[0]*D[0]+D[1]*D[1])},A=function(D,F){return(D[0]*F[0]+D[1]*F[1])/(S(D)*S(F))},T=function(D,F){return(D[0]*F[1]<D[1]*F[0]?-1:1)*Math.acos(A(D,F))},w=T([1,0],[(y-g)/l,(E-x)/f]),P=[(y-g)/l,(E-x)/f],O=[(-1*y-g)/l,(-1*E-x)/f],k=T(P,O);return A(P,O)<=-1&&(k=Math.PI),A(P,O)>=1&&(k=0),u===0&&k>0&&(k=k-2*Math.PI),u===1&&k<0&&(k=k+2*Math.PI),[C,R,l,f,w,k,h,u]}}Path$1.Path=Path;Path.prototype.className="Path";Path.prototype._attrsAffectingSize=["data"];(0,Global_1$e._registerNode)(Path);Factory_1$t.Factory.addGetterSetter(Path,"data");Object.defineProperty(Arrow$1,"__esModule",{value:!0});Arrow$1.Arrow=void 0;const Factory_1$s=Factory,Line_1$1=Line$2,Validators_1$s=Validators,Global_1$d=Global,Path_1$2=Path$1;class Arrow extends Line_1$1.Line{_sceneFunc(e){super._sceneFunc(e);var r=Math.PI*2,t=this.points(),n=t,a=this.tension()!==0&&t.length>4;a&&(n=this.getTensionPoints());var u=this.pointerLength(),l=t.length,f,c;if(a){const E=[n[n.length-4],n[n.length-3],n[n.length-2],n[n.length-1],t[l-2],t[l-1]],p=Path_1$2.Path.calcLength(n[n.length-4],n[n.length-3],"C",E),_=Path_1$2.Path.getPointOnQuadraticBezier(Math.min(1,1-u/p),E[0],E[1],E[2],E[3],E[4],E[5]);f=t[l-2]-_.x,c=t[l-1]-_.y}else f=t[l-2]-t[l-4],c=t[l-1]-t[l-3];var h=(Math.atan2(c,f)+r)%r,y=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(t[l-2],t[l-1]),e.rotate(h),e.moveTo(0,0),e.lineTo(-u,y/2),e.lineTo(-u,-y/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(t[0],t[1]),a?(f=(n[0]+n[2])/2-t[0],c=(n[1]+n[3])/2-t[1]):(f=t[2]-t[0],c=t[3]-t[1]),e.rotate((Math.atan2(-c,-f)+r)%r),e.moveTo(0,0),e.lineTo(-u,y/2),e.lineTo(-u,-y/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){var r=this.dashEnabled();r&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),r&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),r=this.pointerWidth()/2;return{x:e.x-r,y:e.y-r,width:e.width+r*2,height:e.height+r*2}}}Arrow$1.Arrow=Arrow;Arrow.prototype.className="Arrow";(0,Global_1$d._registerNode)(Arrow);Factory_1$s.Factory.addGetterSetter(Arrow,"pointerLength",10,(0,Validators_1$s.getNumberValidator)());Factory_1$s.Factory.addGetterSetter(Arrow,"pointerWidth",10,(0,Validators_1$s.getNumberValidator)());Factory_1$s.Factory.addGetterSetter(Arrow,"pointerAtBeginning",!1);Factory_1$s.Factory.addGetterSetter(Arrow,"pointerAtEnding",!0);var Circle$1={};Object.defineProperty(Circle$1,"__esModule",{value:!0});Circle$1.Circle=void 0;const Factory_1$r=Factory,Shape_1$c=Shape,Validators_1$r=Validators,Global_1$c=Global;class Circle extends Shape_1$c.Shape{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.attrs.radius||0,0,Math.PI*2,!1),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius()!==e/2&&this.radius(e/2)}setHeight(e){this.radius()!==e/2&&this.radius(e/2)}}Circle$1.Circle=Circle;Circle.prototype._centroid=!0;Circle.prototype.className="Circle";Circle.prototype._attrsAffectingSize=["radius"];(0,Global_1$c._registerNode)(Circle);Factory_1$r.Factory.addGetterSetter(Circle,"radius",0,(0,Validators_1$r.getNumberValidator)());var Ellipse$1={};Object.defineProperty(Ellipse$1,"__esModule",{value:!0});Ellipse$1.Ellipse=void 0;const Factory_1$q=Factory,Shape_1$b=Shape,Validators_1$q=Validators,Global_1$b=Global;class Ellipse extends Shape_1$b.Shape{_sceneFunc(e){var r=this.radiusX(),t=this.radiusY();e.beginPath(),e.save(),r!==t&&e.scale(1,t/r),e.arc(0,0,r,0,Math.PI*2,!1),e.restore(),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radiusX()*2}getHeight(){return this.radiusY()*2}setWidth(e){this.radiusX(e/2)}setHeight(e){this.radiusY(e/2)}}Ellipse$1.Ellipse=Ellipse;Ellipse.prototype.className="Ellipse";Ellipse.prototype._centroid=!0;Ellipse.prototype._attrsAffectingSize=["radiusX","radiusY"];(0,Global_1$b._registerNode)(Ellipse);Factory_1$q.Factory.addComponentsGetterSetter(Ellipse,"radius",["x","y"]);Factory_1$q.Factory.addGetterSetter(Ellipse,"radiusX",0,(0,Validators_1$q.getNumberValidator)());Factory_1$q.Factory.addGetterSetter(Ellipse,"radiusY",0,(0,Validators_1$q.getNumberValidator)());var Image$4={};Object.defineProperty(Image$4,"__esModule",{value:!0});Image$4.Image=void 0;const Util_1$7=Util,Factory_1$p=Factory,Shape_1$a=Shape,Global_1$a=Global,Validators_1$p=Validators;let Image$3=class wv extends Shape_1$a.Shape{constructor(e){super(e),this.on("imageChange.konva",()=>{this._setImageLoad()}),this._setImageLoad()}_setImageLoad(){const e=this.image();e&&e.complete||e&&e.readyState===4||e&&e.addEventListener&&e.addEventListener("load",()=>{this._requestDraw()})}_useBufferCanvas(){return super._useBufferCanvas(!0)}_sceneFunc(e){const r=this.getWidth(),t=this.getHeight(),n=this.cornerRadius(),a=this.attrs.image;let u;if(a){const l=this.attrs.cropWidth,f=this.attrs.cropHeight;l&&f?u=[a,this.cropX(),this.cropY(),l,f,0,0,r,t]:u=[a,0,0,r,t]}(this.hasFill()||this.hasStroke()||n)&&(e.beginPath(),n?Util_1$7.Util.drawRoundedRectPath(e,r,t,n):e.rect(0,0,r,t),e.closePath(),e.fillStrokeShape(this)),a&&(n&&e.clip(),e.drawImage.apply(e,u))}_hitFunc(e){var r=this.width(),t=this.height(),n=this.cornerRadius();e.beginPath(),n?Util_1$7.Util.drawRoundedRectPath(e,r,t,n):e.rect(0,0,r,t),e.closePath(),e.fillStrokeShape(this)}getWidth(){var e,r;return(e=this.attrs.width)!==null&&e!==void 0?e:(r=this.image())===null||r===void 0?void 0:r.width}getHeight(){var e,r;return(e=this.attrs.height)!==null&&e!==void 0?e:(r=this.image())===null||r===void 0?void 0:r.height}static fromURL(e,r,t=null){var n=Util_1$7.Util.createImageElement();n.onload=function(){var a=new wv({image:n});r(a)},n.onerror=t,n.crossOrigin="Anonymous",n.src=e}};Image$4.Image=Image$3;Image$3.prototype.className="Image";(0,Global_1$a._registerNode)(Image$3);Factory_1$p.Factory.addGetterSetter(Image$3,"cornerRadius",0,(0,Validators_1$p.getNumberOrArrayOfNumbersValidator)(4));Factory_1$p.Factory.addGetterSetter(Image$3,"image");Factory_1$p.Factory.addComponentsGetterSetter(Image$3,"crop",["x","y","width","height"]);Factory_1$p.Factory.addGetterSetter(Image$3,"cropX",0,(0,Validators_1$p.getNumberValidator)());Factory_1$p.Factory.addGetterSetter(Image$3,"cropY",0,(0,Validators_1$p.getNumberValidator)());Factory_1$p.Factory.addGetterSetter(Image$3,"cropWidth",0,(0,Validators_1$p.getNumberValidator)());Factory_1$p.Factory.addGetterSetter(Image$3,"cropHeight",0,(0,Validators_1$p.getNumberValidator)());var Label$1={};Object.defineProperty(Label$1,"__esModule",{value:!0});Label$1.Tag=Label$1.Label=void 0;const Factory_1$o=Factory,Shape_1$9=Shape,Group_1$1=Group$2,Validators_1$o=Validators,Global_1$9=Global;var ATTR_CHANGE_LIST$2=["fontFamily","fontSize","fontStyle","padding","lineHeight","text","width","height","pointerDirection","pointerWidth","pointerHeight"],CHANGE_KONVA$1="Change.konva",NONE$1="none",UP="up",RIGHT$1="right",DOWN="down",LEFT$1="left",attrChangeListLen$1=ATTR_CHANGE_LIST$2.length;class Label extends Group_1$1.Group{constructor(e){super(e),this.on("add.konva",function(r){this._addListeners(r.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){var r=this,t,n=function(){r._sync()};for(t=0;t<attrChangeListLen$1;t++)e.on(ATTR_CHANGE_LIST$2[t]+CHANGE_KONVA$1,n)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var e=this.getText(),r=this.getTag(),t,n,a,u,l,f,c;if(e&&r){switch(t=e.width(),n=e.height(),a=r.pointerDirection(),u=r.pointerWidth(),c=r.pointerHeight(),l=0,f=0,a){case UP:l=t/2,f=-1*c;break;case RIGHT$1:l=t+u,f=n/2;break;case DOWN:l=t/2,f=n+c;break;case LEFT$1:l=-1*u,f=n/2;break}r.setAttrs({x:-1*l,y:-1*f,width:t,height:n}),e.setAttrs({x:-1*l,y:-1*f})}}}Label$1.Label=Label;Label.prototype.className="Label";(0,Global_1$9._registerNode)(Label);class Tag extends Shape_1$9.Shape{_sceneFunc(e){var r=this.width(),t=this.height(),n=this.pointerDirection(),a=this.pointerWidth(),u=this.pointerHeight(),l=this.cornerRadius();let f=0,c=0,h=0,y=0;typeof l=="number"?f=c=h=y=Math.min(l,r/2,t/2):(f=Math.min(l[0]||0,r/2,t/2),c=Math.min(l[1]||0,r/2,t/2),y=Math.min(l[2]||0,r/2,t/2),h=Math.min(l[3]||0,r/2,t/2)),e.beginPath(),e.moveTo(f,0),n===UP&&(e.lineTo((r-a)/2,0),e.lineTo(r/2,-1*u),e.lineTo((r+a)/2,0)),e.lineTo(r-c,0),e.arc(r-c,c,c,Math.PI*3/2,0,!1),n===RIGHT$1&&(e.lineTo(r,(t-u)/2),e.lineTo(r+a,t/2),e.lineTo(r,(t+u)/2)),e.lineTo(r,t-y),e.arc(r-y,t-y,y,0,Math.PI/2,!1),n===DOWN&&(e.lineTo((r+a)/2,t),e.lineTo(r/2,t+u),e.lineTo((r-a)/2,t)),e.lineTo(h,t),e.arc(h,t-h,h,Math.PI/2,Math.PI,!1),n===LEFT$1&&(e.lineTo(0,(t+u)/2),e.lineTo(-1*a,t/2),e.lineTo(0,(t-u)/2)),e.lineTo(0,f),e.arc(f,f,f,Math.PI,Math.PI*3/2,!1),e.closePath(),e.fillStrokeShape(this)}getSelfRect(){var e=0,r=0,t=this.pointerWidth(),n=this.pointerHeight(),a=this.pointerDirection(),u=this.width(),l=this.height();return a===UP?(r-=n,l+=n):a===DOWN?l+=n:a===LEFT$1?(e-=t*1.5,u+=t):a===RIGHT$1&&(u+=t*1.5),{x:e,y:r,width:u,height:l}}}Label$1.Tag=Tag;Tag.prototype.className="Tag";(0,Global_1$9._registerNode)(Tag);Factory_1$o.Factory.addGetterSetter(Tag,"pointerDirection",NONE$1);Factory_1$o.Factory.addGetterSetter(Tag,"pointerWidth",0,(0,Validators_1$o.getNumberValidator)());Factory_1$o.Factory.addGetterSetter(Tag,"pointerHeight",0,(0,Validators_1$o.getNumberValidator)());Factory_1$o.Factory.addGetterSetter(Tag,"cornerRadius",0,(0,Validators_1$o.getNumberOrArrayOfNumbersValidator)(4));var Rect$2={};Object.defineProperty(Rect$2,"__esModule",{value:!0});Rect$2.Rect=void 0;const Factory_1$n=Factory,Shape_1$8=Shape,Global_1$8=Global,Util_1$6=Util,Validators_1$n=Validators;let Rect$1=class extends Shape_1$8.Shape{_sceneFunc(e){var r=this.cornerRadius(),t=this.width(),n=this.height();e.beginPath(),r?Util_1$6.Util.drawRoundedRectPath(e,t,n,r):e.rect(0,0,t,n),e.closePath(),e.fillStrokeShape(this)}};Rect$2.Rect=Rect$1;Rect$1.prototype.className="Rect";(0,Global_1$8._registerNode)(Rect$1);Factory_1$n.Factory.addGetterSetter(Rect$1,"cornerRadius",0,(0,Validators_1$n.getNumberOrArrayOfNumbersValidator)(4));var RegularPolygon$1={};Object.defineProperty(RegularPolygon$1,"__esModule",{value:!0});RegularPolygon$1.RegularPolygon=void 0;const Factory_1$m=Factory,Shape_1$7=Shape,Validators_1$m=Validators,Global_1$7=Global;class RegularPolygon extends Shape_1$7.Shape{_sceneFunc(e){const r=this._getPoints();e.beginPath(),e.moveTo(r[0].x,r[0].y);for(var t=1;t<r.length;t++)e.lineTo(r[t].x,r[t].y);e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,r=this.attrs.radius||0,t=[];for(var n=0;n<e;n++)t.push({x:r*Math.sin(n*2*Math.PI/e),y:-1*r*Math.cos(n*2*Math.PI/e)});return t}getSelfRect(){const e=this._getPoints();var r=e[0].x,t=e[0].y,n=e[0].x,a=e[0].y;return e.forEach(u=>{r=Math.min(r,u.x),t=Math.max(t,u.x),n=Math.min(n,u.y),a=Math.max(a,u.y)}),{x:r,y:n,width:t-r,height:a-n}}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}RegularPolygon$1.RegularPolygon=RegularPolygon;RegularPolygon.prototype.className="RegularPolygon";RegularPolygon.prototype._centroid=!0;RegularPolygon.prototype._attrsAffectingSize=["radius"];(0,Global_1$7._registerNode)(RegularPolygon);Factory_1$m.Factory.addGetterSetter(RegularPolygon,"radius",0,(0,Validators_1$m.getNumberValidator)());Factory_1$m.Factory.addGetterSetter(RegularPolygon,"sides",0,(0,Validators_1$m.getNumberValidator)());var Ring$1={};Object.defineProperty(Ring$1,"__esModule",{value:!0});Ring$1.Ring=void 0;const Factory_1$l=Factory,Shape_1$6=Shape,Validators_1$l=Validators,Global_1$6=Global;var PIx2=Math.PI*2;class Ring extends Shape_1$6.Shape{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.innerRadius(),0,PIx2,!1),e.moveTo(this.outerRadius(),0),e.arc(0,0,this.outerRadius(),PIx2,0,!0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}Ring$1.Ring=Ring;Ring.prototype.className="Ring";Ring.prototype._centroid=!0;Ring.prototype._attrsAffectingSize=["innerRadius","outerRadius"];(0,Global_1$6._registerNode)(Ring);Factory_1$l.Factory.addGetterSetter(Ring,"innerRadius",0,(0,Validators_1$l.getNumberValidator)());Factory_1$l.Factory.addGetterSetter(Ring,"outerRadius",0,(0,Validators_1$l.getNumberValidator)());var Sprite$1={};Object.defineProperty(Sprite$1,"__esModule",{value:!0});Sprite$1.Sprite=void 0;const Factory_1$k=Factory,Shape_1$5=Shape,Animation_1=Animation$2,Validators_1$k=Validators,Global_1$5=Global;class Sprite extends Shape_1$5.Shape{constructor(e){super(e),this._updated=!0,this.anim=new Animation_1.Animation(()=>{var r=this._updated;return this._updated=!1,r}),this.on("animationChange.konva",function(){this.frameIndex(0)}),this.on("frameIndexChange.konva",function(){this._updated=!0}),this.on("frameRateChange.konva",function(){this.anim.isRunning()&&(clearInterval(this.interval),this._setInterval())})}_sceneFunc(e){var r=this.animation(),t=this.frameIndex(),n=t*4,a=this.animations()[r],u=this.frameOffsets(),l=a[n+0],f=a[n+1],c=a[n+2],h=a[n+3],y=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,c,h),e.closePath(),e.fillStrokeShape(this)),y)if(u){var E=u[r],p=t*2;e.drawImage(y,l,f,c,h,E[p+0],E[p+1],c,h)}else e.drawImage(y,l,f,c,h,0,0,c,h)}_hitFunc(e){var r=this.animation(),t=this.frameIndex(),n=t*4,a=this.animations()[r],u=this.frameOffsets(),l=a[n+2],f=a[n+3];if(e.beginPath(),u){var c=u[r],h=t*2;e.rect(c[h+0],c[h+1],l,f)}else e.rect(0,0,l,f);e.closePath(),e.fillShape(this)}_useBufferCanvas(){return super._useBufferCanvas(!0)}_setInterval(){var e=this;this.interval=setInterval(function(){e._updateIndex()},1e3/this.frameRate())}start(){if(!this.isRunning()){var e=this.getLayer();this.anim.setLayers(e),this._setInterval(),this.anim.start()}}stop(){this.anim.stop(),clearInterval(this.interval)}isRunning(){return this.anim.isRunning()}_updateIndex(){var e=this.frameIndex(),r=this.animation(),t=this.animations(),n=t[r],a=n.length/4;e<a-1?this.frameIndex(e+1):this.frameIndex(0)}}Sprite$1.Sprite=Sprite;Sprite.prototype.className="Sprite";(0,Global_1$5._registerNode)(Sprite);Factory_1$k.Factory.addGetterSetter(Sprite,"animation");Factory_1$k.Factory.addGetterSetter(Sprite,"animations");Factory_1$k.Factory.addGetterSetter(Sprite,"frameOffsets");Factory_1$k.Factory.addGetterSetter(Sprite,"image");Factory_1$k.Factory.addGetterSetter(Sprite,"frameIndex",0,(0,Validators_1$k.getNumberValidator)());Factory_1$k.Factory.addGetterSetter(Sprite,"frameRate",17,(0,Validators_1$k.getNumberValidator)());Factory_1$k.Factory.backCompat(Sprite,{index:"frameIndex",getIndex:"getFrameIndex",setIndex:"setFrameIndex"});var Star$1={};Object.defineProperty(Star$1,"__esModule",{value:!0});Star$1.Star=void 0;const Factory_1$j=Factory,Shape_1$4=Shape,Validators_1$j=Validators,Global_1$4=Global;class Star extends Shape_1$4.Shape{_sceneFunc(e){var r=this.innerRadius(),t=this.outerRadius(),n=this.numPoints();e.beginPath(),e.moveTo(0,0-t);for(var a=1;a<n*2;a++){var u=a%2===0?t:r,l=u*Math.sin(a*Math.PI/n),f=-1*u*Math.cos(a*Math.PI/n);e.lineTo(l,f)}e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.outerRadius()*2}getHeight(){return this.outerRadius()*2}setWidth(e){this.outerRadius(e/2)}setHeight(e){this.outerRadius(e/2)}}Star$1.Star=Star;Star.prototype.className="Star";Star.prototype._centroid=!0;Star.prototype._attrsAffectingSize=["innerRadius","outerRadius"];(0,Global_1$4._registerNode)(Star);Factory_1$j.Factory.addGetterSetter(Star,"numPoints",5,(0,Validators_1$j.getNumberValidator)());Factory_1$j.Factory.addGetterSetter(Star,"innerRadius",0,(0,Validators_1$j.getNumberValidator)());Factory_1$j.Factory.addGetterSetter(Star,"outerRadius",0,(0,Validators_1$j.getNumberValidator)());var Text$2={};Object.defineProperty(Text$2,"__esModule",{value:!0});Text$2.Text=Text$2.stringToArray=void 0;const Util_1$5=Util,Factory_1$i=Factory,Shape_1$3=Shape,Validators_1$i=Validators,Global_1$3=Global;function stringToArray(o){return Array.from(o)}Text$2.stringToArray=stringToArray;var AUTO="auto",CENTER="center",INHERIT="inherit",JUSTIFY="justify",CHANGE_KONVA="Change.konva",CONTEXT_2D="2d",DASH="-",LEFT="left",TEXT="text",TEXT_UPPER="Text",TOP="top",BOTTOM="bottom",MIDDLE="middle",NORMAL$1="normal",PX_SPACE="px ",SPACE=" ",RIGHT="right",RTL="rtl",WORD="word",CHAR="char",NONE="none",ELLIPSIS="…",ATTR_CHANGE_LIST$1=["direction","fontFamily","fontSize","fontStyle","fontVariant","padding","align","verticalAlign","lineHeight","text","width","height","wrap","ellipsis","letterSpacing"],attrChangeListLen=ATTR_CHANGE_LIST$1.length;function normalizeFontFamily(o){return o.split(",").map(e=>{e=e.trim();const r=e.indexOf(" ")>=0,t=e.indexOf('"')>=0||e.indexOf("'")>=0;return r&&!t&&(e=`"${e}"`),e}).join(", ")}var dummyContext;function getDummyContext(){return dummyContext||(dummyContext=Util_1$5.Util.createCanvasElement().getContext(CONTEXT_2D),dummyContext)}function _fillFunc$1(o){o.fillText(this._partialText,this._partialTextX,this._partialTextY)}function _strokeFunc$1(o){o.setAttr("miterLimit",2),o.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function checkDefaultFill(o){return o=o||{},!o.fillLinearGradientColorStops&&!o.fillRadialGradientColorStops&&!o.fillPatternImage&&(o.fill=o.fill||"black"),o}let Text$1=class extends Shape_1$3.Shape{constructor(e){super(checkDefaultFill(e)),this._partialTextX=0,this._partialTextY=0;for(var r=0;r<attrChangeListLen;r++)this.on(ATTR_CHANGE_LIST$1[r]+CHANGE_KONVA,this._setTextData);this._setTextData()}_sceneFunc(e){var r=this.textArr,t=r.length;if(this.text()){var n=this.padding(),a=this.fontSize(),u=this.lineHeight()*a,l=this.verticalAlign(),f=this.direction(),c=0,h=this.align(),y=this.getWidth(),E=this.letterSpacing(),p=this.fill(),_=this.textDecoration(),g=_.indexOf("underline")!==-1,x=_.indexOf("line-through")!==-1,C;f=f===INHERIT?e.direction:f;var R=0,R=u/2,S=0,A=0;for(f===RTL&&e.setAttr("direction",f),e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",MIDDLE),e.setAttr("textAlign",LEFT),l===MIDDLE?c=(this.getHeight()-t*u-n*2)/2:l===BOTTOM&&(c=this.getHeight()-t*u-n*2),e.translate(n,c+n),C=0;C<t;C++){var S=0,A=0,T=r[C],w=T.text,P=T.width,O=T.lastInParagraph,k,D,F;if(e.save(),h===RIGHT?S+=y-P-n*2:h===CENTER&&(S+=(y-P-n*2)/2),g){e.save(),e.beginPath(),e.moveTo(S,R+A+Math.round(a/2)),k=w.split(" ").length-1,D=k===0,F=h===JUSTIFY&&!O?y-n*2:P,e.lineTo(S+Math.round(F),R+A+Math.round(a/2)),e.lineWidth=a/15;const z=this._getLinearGradient();e.strokeStyle=z||p,e.stroke(),e.restore()}if(x){e.save(),e.beginPath(),e.moveTo(S,R+A),k=w.split(" ").length-1,D=k===0,F=h===JUSTIFY&&O&&!D?y-n*2:P,e.lineTo(S+Math.round(F),R+A),e.lineWidth=a/15;const z=this._getLinearGradient();e.strokeStyle=z||p,e.stroke(),e.restore()}if(f!==RTL&&(E!==0||h===JUSTIFY)){k=w.split(" ").length-1;for(var G=stringToArray(w),V=0;V<G.length;V++){var W=G[V];W===" "&&!O&&h===JUSTIFY&&(S+=(y-n*2-P)/k),this._partialTextX=S,this._partialTextY=R+A,this._partialText=W,e.fillStrokeShape(this),S+=this.measureSize(W).width+E}}else E!==0&&e.setAttr("letterSpacing",`${E}px`),this._partialTextX=S,this._partialTextY=R+A,this._partialText=w,e.fillStrokeShape(this);e.restore(),t>1&&(R+=u)}}}_hitFunc(e){var r=this.getWidth(),t=this.getHeight();e.beginPath(),e.rect(0,0,r,t),e.closePath(),e.fillStrokeShape(this)}setText(e){var r=Util_1$5.Util._isString(e)?e:e==null?"":e+"";return this._setAttr(TEXT,r),this}getWidth(){var e=this.attrs.width===AUTO||this.attrs.width===void 0;return e?this.getTextWidth()+this.padding()*2:this.attrs.width}getHeight(){var e=this.attrs.height===AUTO||this.attrs.height===void 0;return e?this.fontSize()*this.textArr.length*this.lineHeight()+this.padding()*2:this.attrs.height}getTextWidth(){return this.textWidth}getTextHeight(){return Util_1$5.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}measureSize(e){var r=getDummyContext(),t=this.fontSize(),n;return r.save(),r.font=this._getContextFont(),n=r.measureText(e),r.restore(),{width:n.width,height:t}}_getContextFont(){return this.fontStyle()+SPACE+this.fontVariant()+SPACE+(this.fontSize()+PX_SPACE)+normalizeFontFamily(this.fontFamily())}_addTextLine(e){this.align()===JUSTIFY&&(e=e.trim());var t=this._getTextWidth(e);return this.textArr.push({text:e,width:t,lastInParagraph:!1})}_getTextWidth(e){var r=this.letterSpacing(),t=e.length;return getDummyContext().measureText(e).width+(t?r*(t-1):0)}_setTextData(){var e=this.text().split(`
72
72
  `),r=+this.fontSize(),t=0,n=this.lineHeight()*r,a=this.attrs.width,u=this.attrs.height,l=a!==AUTO&&a!==void 0,f=u!==AUTO&&u!==void 0,c=this.padding(),h=a-c*2,y=u-c*2,E=0,p=this.wrap(),_=p!==NONE,g=p!==CHAR&&_,x=this.ellipsis();this.textArr=[],getDummyContext().font=this._getContextFont();for(var C=x?this._getTextWidth(ELLIPSIS):0,R=0,S=e.length;R<S;++R){var A=e[R],T=this._getTextWidth(A);if(l&&T>h)for(;A.length>0;){for(var w=0,P=A.length,O="",k=0;w<P;){var D=w+P>>>1,F=A.slice(0,D+1),G=this._getTextWidth(F)+C;G<=h?(w=D+1,O=F,k=G):P=D}if(O){if(g){var V,W=A[O.length],Z=W===SPACE||W===DASH;Z&&k<=h?V=O.length:V=Math.max(O.lastIndexOf(SPACE),O.lastIndexOf(DASH))+1,V>0&&(w=V,O=O.slice(0,w),k=this._getTextWidth(O))}O=O.trimRight(),this._addTextLine(O),t=Math.max(t,k),E+=n;var q=this._shouldHandleEllipsis(E);if(q){this._tryToAddEllipsisToLastLine();break}if(A=A.slice(w),A=A.trimLeft(),A.length>0&&(T=this._getTextWidth(A),T<=h)){this._addTextLine(A),E+=n,t=Math.max(t,T);break}}else break}else this._addTextLine(A),E+=n,t=Math.max(t,T),this._shouldHandleEllipsis(E)&&R<S-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),f&&E+n>y)break}this.textHeight=r,this.textWidth=t}_shouldHandleEllipsis(e){var r=+this.fontSize(),t=this.lineHeight()*r,n=this.attrs.height,a=n!==AUTO&&n!==void 0,u=this.padding(),l=n-u*2,f=this.wrap(),c=f!==NONE;return!c||a&&e+t>l}_tryToAddEllipsisToLastLine(){var e=this.attrs.width,r=e!==AUTO&&e!==void 0,t=this.padding(),n=e-t*2,a=this.ellipsis(),u=this.textArr[this.textArr.length-1];if(!(!u||!a)){if(r){var l=this._getTextWidth(u.text+ELLIPSIS)<n;l||(u.text=u.text.slice(0,u.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(u.text+ELLIPSIS)}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const e=this.textDecoration().indexOf("underline")!==-1||this.textDecoration().indexOf("line-through")!==-1,r=this.hasShadow();return e&&r?!0:super._useBufferCanvas()}};Text$2.Text=Text$1;Text$1.prototype._fillFunc=_fillFunc$1;Text$1.prototype._strokeFunc=_strokeFunc$1;Text$1.prototype.className=TEXT_UPPER;Text$1.prototype._attrsAffectingSize=["text","fontSize","padding","wrap","lineHeight","letterSpacing"];(0,Global_1$3._registerNode)(Text$1);Factory_1$i.Factory.overWriteSetter(Text$1,"width",(0,Validators_1$i.getNumberOrAutoValidator)());Factory_1$i.Factory.overWriteSetter(Text$1,"height",(0,Validators_1$i.getNumberOrAutoValidator)());Factory_1$i.Factory.addGetterSetter(Text$1,"direction",INHERIT);Factory_1$i.Factory.addGetterSetter(Text$1,"fontFamily","Arial");Factory_1$i.Factory.addGetterSetter(Text$1,"fontSize",12,(0,Validators_1$i.getNumberValidator)());Factory_1$i.Factory.addGetterSetter(Text$1,"fontStyle",NORMAL$1);Factory_1$i.Factory.addGetterSetter(Text$1,"fontVariant",NORMAL$1);Factory_1$i.Factory.addGetterSetter(Text$1,"padding",0,(0,Validators_1$i.getNumberValidator)());Factory_1$i.Factory.addGetterSetter(Text$1,"align",LEFT);Factory_1$i.Factory.addGetterSetter(Text$1,"verticalAlign",TOP);Factory_1$i.Factory.addGetterSetter(Text$1,"lineHeight",1,(0,Validators_1$i.getNumberValidator)());Factory_1$i.Factory.addGetterSetter(Text$1,"wrap",WORD);Factory_1$i.Factory.addGetterSetter(Text$1,"ellipsis",!1,(0,Validators_1$i.getBooleanValidator)());Factory_1$i.Factory.addGetterSetter(Text$1,"letterSpacing",0,(0,Validators_1$i.getNumberValidator)());Factory_1$i.Factory.addGetterSetter(Text$1,"text","",(0,Validators_1$i.getStringValidator)());Factory_1$i.Factory.addGetterSetter(Text$1,"textDecoration","");var TextPath$1={};Object.defineProperty(TextPath$1,"__esModule",{value:!0});TextPath$1.TextPath=void 0;const Util_1$4=Util,Factory_1$h=Factory,Shape_1$2=Shape,Path_1$1=Path$1,Text_1$1=Text$2,Validators_1$h=Validators,Global_1$2=Global;var EMPTY_STRING="",NORMAL="normal";function _fillFunc(o){o.fillText(this.partialText,0,0)}function _strokeFunc(o){o.strokeText(this.partialText,0,0)}class TextPath extends Shape_1$2.Shape{constructor(e){super(e),this.dummyCanvas=Util_1$4.Util.createCanvasElement(),this.dataArray=[],this._readDataAttribute(),this.on("dataChange.konva",function(){this._readDataAttribute(),this._setTextData()}),this.on("textChange.konva alignChange.konva letterSpacingChange.konva kerningFuncChange.konva fontSizeChange.konva fontFamilyChange.konva",this._setTextData),this._setTextData()}_getTextPathLength(){return Path_1$1.Path.getPathLength(this.dataArray)}_getPointAtLength(e){if(!this.attrs.data)return null;const r=this.pathLength;return e-1>r?null:Path_1$1.Path.getPointAtLengthOfDataArray(e,this.dataArray)}_readDataAttribute(){this.dataArray=Path_1$1.Path.parsePathData(this.attrs.data),this.pathLength=this._getTextPathLength()}_sceneFunc(e){e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",this.textBaseline()),e.setAttr("textAlign","left"),e.save();var r=this.textDecoration(),t=this.fill(),n=this.fontSize(),a=this.glyphInfo;r==="underline"&&e.beginPath();for(var u=0;u<a.length;u++){e.save();var l=a[u].p0;e.translate(l.x,l.y),e.rotate(a[u].rotation),this.partialText=a[u].text,e.fillStrokeShape(this),r==="underline"&&(u===0&&e.moveTo(0,n/2+1),e.lineTo(n,n/2+1)),e.restore()}r==="underline"&&(e.strokeStyle=t,e.lineWidth=n/20,e.stroke()),e.restore()}_hitFunc(e){e.beginPath();var r=this.glyphInfo;if(r.length>=1){var t=r[0].p0;e.moveTo(t.x,t.y)}for(var n=0;n<r.length;n++){var a=r[n].p1;e.lineTo(a.x,a.y)}e.setAttr("lineWidth",this.fontSize()),e.setAttr("strokeStyle",this.colorKey),e.stroke()}getTextWidth(){return this.textWidth}getTextHeight(){return Util_1$4.Util.warn("text.getTextHeight() method is deprecated. Use text.height() - for full height and text.fontSize() - for one line height."),this.textHeight}setText(e){return Text_1$1.Text.prototype.setText.call(this,e)}_getContextFont(){return Text_1$1.Text.prototype._getContextFont.call(this)}_getTextSize(e){var r=this.dummyCanvas,t=r.getContext("2d");t.save(),t.font=this._getContextFont();var n=t.measureText(e);return t.restore(),{width:n.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const{width:e,height:r}=this._getTextSize(this.attrs.text);if(this.textWidth=e,this.textHeight=r,this.glyphInfo=[],!this.attrs.data)return null;const t=this.letterSpacing(),n=this.align(),a=this.kerningFunc(),u=Math.max(this.textWidth+((this.attrs.text||"").length-1)*t,0);let l=0;n==="center"&&(l=Math.max(0,this.pathLength/2-u/2)),n==="right"&&(l=Math.max(0,this.pathLength-u));const f=(0,Text_1$1.stringToArray)(this.text());let c=l;for(var h=0;h<f.length;h++){const y=this._getPointAtLength(c);if(!y)return;let E=this._getTextSize(f[h]).width+t;if(f[h]===" "&&n==="justify"){const R=this.text().split(" ").length-1;E+=(this.pathLength-u)/R}const p=this._getPointAtLength(c+E);if(!p)return;const _=Path_1$1.Path.getLineLength(y.x,y.y,p.x,p.y);let g=0;if(a)try{g=a(f[h-1],f[h])*this.fontSize()}catch{g=0}y.x+=g,p.x+=g,this.textWidth+=g;const x=Path_1$1.Path.getPointOnLine(g+_/2,y.x,y.y,p.x,p.y),C=Math.atan2(p.y-y.y,p.x-y.x);this.glyphInfo.push({transposeX:x.x,transposeY:x.y,text:f[h],rotation:C,p0:y,p1:p}),c+=E}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};var e=[];this.glyphInfo.forEach(function(h){e.push(h.p0.x),e.push(h.p0.y),e.push(h.p1.x),e.push(h.p1.y)});for(var r=e[0]||0,t=e[0]||0,n=e[1]||0,a=e[1]||0,u,l,f=0;f<e.length/2;f++)u=e[f*2],l=e[f*2+1],r=Math.min(r,u),t=Math.max(t,u),n=Math.min(n,l),a=Math.max(a,l);var c=this.fontSize();return{x:r-c/2,y:n-c/2,width:t-r+c,height:a-n+c}}destroy(){return Util_1$4.Util.releaseCanvas(this.dummyCanvas),super.destroy()}}TextPath$1.TextPath=TextPath;TextPath.prototype._fillFunc=_fillFunc;TextPath.prototype._strokeFunc=_strokeFunc;TextPath.prototype._fillFuncHit=_fillFunc;TextPath.prototype._strokeFuncHit=_strokeFunc;TextPath.prototype.className="TextPath";TextPath.prototype._attrsAffectingSize=["text","fontSize","data"];(0,Global_1$2._registerNode)(TextPath);Factory_1$h.Factory.addGetterSetter(TextPath,"data");Factory_1$h.Factory.addGetterSetter(TextPath,"fontFamily","Arial");Factory_1$h.Factory.addGetterSetter(TextPath,"fontSize",12,(0,Validators_1$h.getNumberValidator)());Factory_1$h.Factory.addGetterSetter(TextPath,"fontStyle",NORMAL);Factory_1$h.Factory.addGetterSetter(TextPath,"align","left");Factory_1$h.Factory.addGetterSetter(TextPath,"letterSpacing",0,(0,Validators_1$h.getNumberValidator)());Factory_1$h.Factory.addGetterSetter(TextPath,"textBaseline","middle");Factory_1$h.Factory.addGetterSetter(TextPath,"fontVariant",NORMAL);Factory_1$h.Factory.addGetterSetter(TextPath,"text",EMPTY_STRING);Factory_1$h.Factory.addGetterSetter(TextPath,"textDecoration",null);Factory_1$h.Factory.addGetterSetter(TextPath,"kerningFunc",null);var Transformer$1={};Object.defineProperty(Transformer$1,"__esModule",{value:!0});Transformer$1.Transformer=void 0;const Util_1$3=Util,Factory_1$g=Factory,Node_1$f=Node$1,Shape_1$1=Shape,Rect_1$1=Rect$2,Group_1=Group$2,Global_1$1=Global,Validators_1$g=Validators,Global_2$1=Global;var EVENTS_NAME="tr-konva",ATTR_CHANGE_LIST=["resizeEnabledChange","rotateAnchorOffsetChange","rotateEnabledChange","enabledAnchorsChange","anchorSizeChange","borderEnabledChange","borderStrokeChange","borderStrokeWidthChange","borderDashChange","anchorStrokeChange","anchorStrokeWidthChange","anchorFillChange","anchorCornerRadiusChange","ignoreStrokeChange","anchorStyleFuncChange"].map(o=>o+`.${EVENTS_NAME}`).join(" "),NODES_RECT="nodesRect",TRANSFORM_CHANGE_STR=["widthChange","heightChange","scaleXChange","scaleYChange","skewXChange","skewYChange","rotationChange","offsetXChange","offsetYChange","transformsEnabledChange","strokeWidthChange"],ANGLES={"top-left":-45,"top-center":0,"top-right":45,"middle-right":-90,"middle-left":90,"bottom-left":-135,"bottom-center":180,"bottom-right":135};const TOUCH_DEVICE="ontouchstart"in Global_1$1.Konva._global;function getCursor(o,e,r){if(o==="rotater")return r;e+=Util_1$3.Util.degToRad(ANGLES[o]||0);var t=(Util_1$3.Util.radToDeg(e)%360+360)%360;return Util_1$3.Util._inRange(t,315+22.5,360)||Util_1$3.Util._inRange(t,0,22.5)?"ns-resize":Util_1$3.Util._inRange(t,45-22.5,45+22.5)?"nesw-resize":Util_1$3.Util._inRange(t,90-22.5,90+22.5)?"ew-resize":Util_1$3.Util._inRange(t,135-22.5,135+22.5)?"nwse-resize":Util_1$3.Util._inRange(t,180-22.5,180+22.5)?"ns-resize":Util_1$3.Util._inRange(t,225-22.5,225+22.5)?"nesw-resize":Util_1$3.Util._inRange(t,270-22.5,270+22.5)?"ew-resize":Util_1$3.Util._inRange(t,315-22.5,315+22.5)?"nwse-resize":(Util_1$3.Util.error("Transformer has unknown angle for cursor detection: "+t),"pointer")}var ANCHORS_NAMES=["top-left","top-center","top-right","middle-right","middle-left","bottom-left","bottom-center","bottom-right"],MAX_SAFE_INTEGER=1e8;function getCenter(o){return{x:o.x+o.width/2*Math.cos(o.rotation)+o.height/2*Math.sin(-o.rotation),y:o.y+o.height/2*Math.cos(o.rotation)+o.width/2*Math.sin(o.rotation)}}function rotateAroundPoint(o,e,r){const t=r.x+(o.x-r.x)*Math.cos(e)-(o.y-r.y)*Math.sin(e),n=r.y+(o.x-r.x)*Math.sin(e)+(o.y-r.y)*Math.cos(e);return{...o,rotation:o.rotation+e,x:t,y:n}}function rotateAroundCenter(o,e){const r=getCenter(o);return rotateAroundPoint(o,e,r)}function getSnap(o,e,r){let t=e;for(let n=0;n<o.length;n++){const a=Global_1$1.Konva.getAngle(o[n]),u=Math.abs(a-e)%(Math.PI*2);Math.min(u,Math.PI*2-u)<r&&(t=a)}return t}class Transformer extends Group_1.Group{constructor(e){super(e),this._movingAnchorName=null,this._transforming=!1,this._createElements(),this._handleMouseMove=this._handleMouseMove.bind(this),this._handleMouseUp=this._handleMouseUp.bind(this),this.update=this.update.bind(this),this.on(ATTR_CHANGE_LIST,this.update),this.getNode()&&this.update()}attachTo(e){return this.setNode(e),this}setNode(e){return Util_1$3.Util.warn("tr.setNode(shape), tr.node(shape) and tr.attachTo(shape) methods are deprecated. Please use tr.nodes(nodesArray) instead."),this.setNodes([e])}getNode(){return this._nodes&&this._nodes[0]}_getEventNamespace(){return EVENTS_NAME+this._id}setNodes(e=[]){this._nodes&&this._nodes.length&&this.detach();const r=e.filter(n=>n.isAncestorOf(this)?(Util_1$3.Util.error("Konva.Transformer cannot be an a child of the node you are trying to attach"),!1):!0);this._nodes=e=r,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(n=>{const a=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()},u=n._attrsAffectingSize.map(l=>l+"Change."+this._getEventNamespace()).join(" ");n.on(u,a),n.on(TRANSFORM_CHANGE_STR.map(l=>l+`.${this._getEventNamespace()}`).join(" "),a),n.on(`absoluteTransformChange.${this._getEventNamespace()}`,a),this._proxyDrag(n)}),this._resetTransformCache();var t=!!this.findOne(".top-left");return t&&this.update(),this}_proxyDrag(e){let r;e.on(`dragstart.${this._getEventNamespace()}`,t=>{r=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(t,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,t=>{if(!r)return;const n=e.getAbsolutePosition(),a=n.x-r.x,u=n.y-r.y;this.nodes().forEach(l=>{if(l===e||l.isDragging())return;const f=l.getAbsolutePosition();l.setAbsolutePosition({x:f.x+a,y:f.y+u}),l.startDrag(t)}),r=null})}getNodes(){return this._nodes||[]}getActiveAnchor(){return this._movingAnchorName}detach(){this._nodes&&this._nodes.forEach(e=>{e.off("."+this._getEventNamespace())}),this._nodes=[],this._resetTransformCache()}_resetTransformCache(){this._clearCache(NODES_RECT),this._clearCache("transform"),this._clearSelfAndDescendantCache("absoluteTransform")}_getNodeRect(){return this._getCache(NODES_RECT,this.__getNodeRect)}__getNodeShape(e,r=this.rotation(),t){var n=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),a=e.getAbsoluteScale(t),u=e.getAbsolutePosition(t),l=n.x*a.x-e.offsetX()*a.x,f=n.y*a.y-e.offsetY()*a.y;const c=(Global_1$1.Konva.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2),h={x:u.x+l*Math.cos(c)+f*Math.sin(-c),y:u.y+f*Math.cos(c)+l*Math.sin(c),width:n.width*a.x,height:n.height*a.y,rotation:c};return rotateAroundPoint(h,-Global_1$1.Konva.getAngle(r),{x:0,y:0})}__getNodeRect(){var e=this.getNode();if(!e)return{x:-MAX_SAFE_INTEGER,y:-MAX_SAFE_INTEGER,width:0,height:0,rotation:0};const r=[];this.nodes().map(c=>{const h=c.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()});var y=[{x:h.x,y:h.y},{x:h.x+h.width,y:h.y},{x:h.x+h.width,y:h.y+h.height},{x:h.x,y:h.y+h.height}],E=c.getAbsoluteTransform();y.forEach(function(p){var _=E.point(p);r.push(_)})});const t=new Util_1$3.Transform;t.rotate(-Global_1$1.Konva.getAngle(this.rotation()));var n=1/0,a=1/0,u=-1/0,l=-1/0;r.forEach(function(c){var h=t.point(c);n===void 0&&(n=u=h.x,a=l=h.y),n=Math.min(n,h.x),a=Math.min(a,h.y),u=Math.max(u,h.x),l=Math.max(l,h.y)}),t.invert();const f=t.point({x:n,y:a});return{x:f.x,y:f.y,width:u-n,height:l-a,rotation:Global_1$1.Konva.getAngle(this.rotation())}}getX(){return this._getNodeRect().x}getY(){return this._getNodeRect().y}getWidth(){return this._getNodeRect().width}getHeight(){return this._getNodeRect().height}_createElements(){this._createBack(),ANCHORS_NAMES.forEach(e=>{this._createAnchor(e)}),this._createAnchor("rotater")}_createAnchor(e){var r=new Rect_1$1.Rect({stroke:"rgb(0, 161, 255)",fill:"white",strokeWidth:1,name:e+" _anchor",dragDistance:0,draggable:!0,hitStrokeWidth:TOUCH_DEVICE?10:"auto"}),t=this;r.on("mousedown touchstart",function(n){t._handleMouseDown(n)}),r.on("dragstart",n=>{r.stopDrag(),n.cancelBubble=!0}),r.on("dragend",n=>{n.cancelBubble=!0}),r.on("mouseenter",()=>{var n=Global_1$1.Konva.getAngle(this.rotation()),a=this.rotateAnchorCursor(),u=getCursor(e,n,a);r.getStage().content&&(r.getStage().content.style.cursor=u),this._cursorChange=!0}),r.on("mouseout",()=>{r.getStage().content&&(r.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(r)}_createBack(){var e=new Shape_1$1.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(r,t){var n=t.getParent(),a=n.padding();r.beginPath(),r.rect(-a,-a,t.width()+a*2,t.height()+a*2),r.moveTo(t.width()/2,-a),n.rotateEnabled()&&n.rotateLineVisible()&&r.lineTo(t.width()/2,-n.rotateAnchorOffset()*Util_1$3.Util._sign(t.height())-a),r.fillStrokeShape(t)},hitFunc:(r,t)=>{if(this.shouldOverdrawWholeArea()){var n=this.padding();r.beginPath(),r.rect(-n,-n,t.width()+n*2,t.height()+n*2),r.fillStrokeShape(t)}}});this.add(e),this._proxyDrag(e),e.on("dragstart",r=>{r.cancelBubble=!0}),e.on("dragmove",r=>{r.cancelBubble=!0}),e.on("dragend",r=>{r.cancelBubble=!0}),this.on("dragmove",r=>{this.update()})}_handleMouseDown(e){this._movingAnchorName=e.target.name().split(" ")[0];var r=this._getNodeRect(),t=r.width,n=r.height,a=Math.sqrt(Math.pow(t,2)+Math.pow(n,2));this.sin=Math.abs(n/a),this.cos=Math.abs(t/a),typeof window<"u"&&(window.addEventListener("mousemove",this._handleMouseMove),window.addEventListener("touchmove",this._handleMouseMove),window.addEventListener("mouseup",this._handleMouseUp,!0),window.addEventListener("touchend",this._handleMouseUp,!0)),this._transforming=!0;var u=e.target.getAbsolutePosition(),l=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:l.x-u.x,y:l.y-u.y},this._fire("transformstart",{evt:e.evt,target:this.getNode()}),this._nodes.forEach(f=>{f._fire("transformstart",{evt:e.evt,target:f})})}_handleMouseMove(e){var r,t,n,a=this.findOne("."+this._movingAnchorName),u=a.getStage();u.setPointersPositions(e);const l=u.getPointerPosition();let f={x:l.x-this._anchorDragOffset.x,y:l.y-this._anchorDragOffset.y};const c=a.getAbsolutePosition();this.anchorDragBoundFunc()&&(f=this.anchorDragBoundFunc()(c,f,e)),a.setAbsolutePosition(f);const h=a.getAbsolutePosition();if(!(c.x===h.x&&c.y===h.y)){if(this._movingAnchorName==="rotater"){var y=this._getNodeRect();r=a.x()-y.width/2,t=-a.y()+y.height/2;let V=Math.atan2(-t,r)+Math.PI/2;y.height<0&&(V-=Math.PI);var E=Global_1$1.Konva.getAngle(this.rotation());const W=E+V,Z=Global_1$1.Konva.getAngle(this.rotationSnapTolerance()),z=getSnap(this.rotationSnaps(),W,Z)-y.rotation,U=rotateAroundCenter(y,z);this._fitNodesInto(U,e);return}var p=this.shiftBehavior(),_;p==="inverted"?_=this.keepRatio()&&!e.shiftKey:p==="none"?_=this.keepRatio():_=this.keepRatio()||e.shiftKey;var S=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(_){var g=S?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};n=Math.sqrt(Math.pow(g.x-a.x(),2)+Math.pow(g.y-a.y(),2));var x=this.findOne(".top-left").x()>g.x?-1:1,C=this.findOne(".top-left").y()>g.y?-1:1;r=n*this.cos*x,t=n*this.sin*C,this.findOne(".top-left").x(g.x-r),this.findOne(".top-left").y(g.y-t)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(a.y());else if(this._movingAnchorName==="top-right"){if(_){var g=S?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};n=Math.sqrt(Math.pow(a.x()-g.x,2)+Math.pow(g.y-a.y(),2));var x=this.findOne(".top-right").x()<g.x?-1:1,C=this.findOne(".top-right").y()>g.y?-1:1;r=n*this.cos*x,t=n*this.sin*C,this.findOne(".top-right").x(g.x+r),this.findOne(".top-right").y(g.y-t)}var R=a.position();this.findOne(".top-left").y(R.y),this.findOne(".bottom-right").x(R.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(a.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(a.x());else if(this._movingAnchorName==="bottom-left"){if(_){var g=S?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};n=Math.sqrt(Math.pow(g.x-a.x(),2)+Math.pow(a.y()-g.y,2));var x=g.x<a.x()?-1:1,C=a.y()<g.y?-1:1;r=n*this.cos*x,t=n*this.sin*C,a.x(g.x-r),a.y(g.y+t)}R=a.position(),this.findOne(".top-left").x(R.x),this.findOne(".bottom-right").y(R.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(a.y());else if(this._movingAnchorName==="bottom-right"){if(_){var g=S?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};n=Math.sqrt(Math.pow(a.x()-g.x,2)+Math.pow(a.y()-g.y,2));var x=this.findOne(".bottom-right").x()<g.x?-1:1,C=this.findOne(".bottom-right").y()<g.y?-1:1;r=n*this.cos*x,t=n*this.sin*C,this.findOne(".bottom-right").x(g.x+r),this.findOne(".bottom-right").y(g.y+t)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));var S=this.centeredScaling()||e.altKey;if(S){var A=this.findOne(".top-left"),T=this.findOne(".bottom-right"),w=A.x(),P=A.y(),O=this.getWidth()-T.x(),k=this.getHeight()-T.y();T.move({x:-w,y:-P}),A.move({x:O,y:k})}var D=this.findOne(".top-left").getAbsolutePosition();r=D.x,t=D.y;var F=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),G=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:r,y:t,width:F,height:G,rotation:Global_1$1.Konva.getAngle(this.rotation())},e)}}_handleMouseUp(e){this._removeEvents(e)}getAbsoluteTransform(){return this.getTransform()}_removeEvents(e){if(this._transforming){this._transforming=!1,typeof window<"u"&&(window.removeEventListener("mousemove",this._handleMouseMove),window.removeEventListener("touchmove",this._handleMouseMove),window.removeEventListener("mouseup",this._handleMouseUp,!0),window.removeEventListener("touchend",this._handleMouseUp,!0));var r=this.getNode();this._fire("transformend",{evt:e,target:r}),r&&this._nodes.forEach(t=>{t._fire("transformend",{evt:e,target:t})}),this._movingAnchorName=null}}_fitNodesInto(e,r){var t=this._getNodeRect();const n=1;if(Util_1$3.Util._inRange(e.width,-this.padding()*2-n,n)){this.update();return}if(Util_1$3.Util._inRange(e.height,-this.padding()*2-n,n)){this.update();return}var a=new Util_1$3.Transform;if(a.rotate(Global_1$1.Konva.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const E=a.point({x:-this.padding()*2,y:0});e.x+=E.x,e.y+=E.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=E.x,this._anchorDragOffset.y-=E.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const E=a.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=E.x,this._anchorDragOffset.y-=E.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const E=a.point({x:0,y:-this.padding()*2});e.x+=E.x,e.y+=E.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=E.x,this._anchorDragOffset.y-=E.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const E=a.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=E.x,this._anchorDragOffset.y-=E.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){const E=this.boundBoxFunc()(t,e);E?e=E:Util_1$3.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const u=1e7,l=new Util_1$3.Transform;l.translate(t.x,t.y),l.rotate(t.rotation),l.scale(t.width/u,t.height/u);const f=new Util_1$3.Transform,c=e.width/u,h=e.height/u;this.flipEnabled()===!1?(f.translate(e.x,e.y),f.rotate(e.rotation),f.translate(e.width<0?e.width:0,e.height<0?e.height:0),f.scale(Math.abs(c),Math.abs(h))):(f.translate(e.x,e.y),f.rotate(e.rotation),f.scale(c,h));const y=f.multiply(l.invert());this._nodes.forEach(E=>{var p;const _=E.getParent().getAbsoluteTransform(),g=E.getTransform().copy();g.translate(E.offsetX(),E.offsetY());const x=new Util_1$3.Transform;x.multiply(_.copy().invert()).multiply(y).multiply(_).multiply(g);const C=x.decompose();E.setAttrs(C),this._fire("transform",{evt:r,target:E}),E._fire("transform",{evt:r,target:E}),(p=E.getLayer())===null||p===void 0||p.batchDraw()}),this.rotation(Util_1$3.Util._getRotation(e.rotation)),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,r){this.findOne(e).setAttrs(r)}update(){var e,r=this._getNodeRect();this.rotation(Util_1$3.Util._getRotation(r.rotation));var t=r.width,n=r.height,a=this.enabledAnchors(),u=this.resizeEnabled(),l=this.padding(),f=this.anchorSize();const c=this.find("._anchor");c.forEach(y=>{y.setAttrs({width:f,height:f,offsetX:f/2,offsetY:f/2,stroke:this.anchorStroke(),strokeWidth:this.anchorStrokeWidth(),fill:this.anchorFill(),cornerRadius:this.anchorCornerRadius()})}),this._batchChangeChild(".top-left",{x:0,y:0,offsetX:f/2+l,offsetY:f/2+l,visible:u&&a.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:t/2,y:0,offsetY:f/2+l,visible:u&&a.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:t,y:0,offsetX:f/2-l,offsetY:f/2+l,visible:u&&a.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:n/2,offsetX:f/2+l,visible:u&&a.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:t,y:n/2,offsetX:f/2-l,visible:u&&a.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:n,offsetX:f/2+l,offsetY:f/2-l,visible:u&&a.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:t/2,y:n,offsetY:f/2-l,visible:u&&a.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:t,y:n,offsetX:f/2-l,offsetY:f/2-l,visible:u&&a.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:t/2,y:-this.rotateAnchorOffset()*Util_1$3.Util._sign(n)-l,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:t,height:n,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const h=this.anchorStyleFunc();h&&c.forEach(y=>{h(y)}),(e=this.getLayer())===null||e===void 0||e.batchDraw()}isTransforming(){return this._transforming}stopTransform(){if(this._transforming){this._removeEvents();var e=this.findOne("."+this._movingAnchorName);e&&e.stopDrag()}}destroy(){return this.getStage()&&this._cursorChange&&this.getStage().content&&(this.getStage().content.style.cursor=""),Group_1.Group.prototype.destroy.call(this),this.detach(),this._removeEvents(),this}toObject(){return Node_1$f.Node.prototype.toObject.call(this)}clone(e){var r=Node_1$f.Node.prototype.clone.call(this,e);return r}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}Transformer$1.Transformer=Transformer;function validateAnchors(o){return o instanceof Array||Util_1$3.Util.warn("enabledAnchors value should be an array"),o instanceof Array&&o.forEach(function(e){ANCHORS_NAMES.indexOf(e)===-1&&Util_1$3.Util.warn("Unknown anchor name: "+e+". Available names are: "+ANCHORS_NAMES.join(", "))}),o||[]}Transformer.prototype.className="Transformer";(0,Global_2$1._registerNode)(Transformer);Factory_1$g.Factory.addGetterSetter(Transformer,"enabledAnchors",ANCHORS_NAMES,validateAnchors);Factory_1$g.Factory.addGetterSetter(Transformer,"flipEnabled",!0,(0,Validators_1$g.getBooleanValidator)());Factory_1$g.Factory.addGetterSetter(Transformer,"resizeEnabled",!0);Factory_1$g.Factory.addGetterSetter(Transformer,"anchorSize",10,(0,Validators_1$g.getNumberValidator)());Factory_1$g.Factory.addGetterSetter(Transformer,"rotateEnabled",!0);Factory_1$g.Factory.addGetterSetter(Transformer,"rotateLineVisible",!0);Factory_1$g.Factory.addGetterSetter(Transformer,"rotationSnaps",[]);Factory_1$g.Factory.addGetterSetter(Transformer,"rotateAnchorOffset",50,(0,Validators_1$g.getNumberValidator)());Factory_1$g.Factory.addGetterSetter(Transformer,"rotateAnchorCursor","crosshair");Factory_1$g.Factory.addGetterSetter(Transformer,"rotationSnapTolerance",5,(0,Validators_1$g.getNumberValidator)());Factory_1$g.Factory.addGetterSetter(Transformer,"borderEnabled",!0);Factory_1$g.Factory.addGetterSetter(Transformer,"anchorStroke","rgb(0, 161, 255)");Factory_1$g.Factory.addGetterSetter(Transformer,"anchorStrokeWidth",1,(0,Validators_1$g.getNumberValidator)());Factory_1$g.Factory.addGetterSetter(Transformer,"anchorFill","white");Factory_1$g.Factory.addGetterSetter(Transformer,"anchorCornerRadius",0,(0,Validators_1$g.getNumberValidator)());Factory_1$g.Factory.addGetterSetter(Transformer,"borderStroke","rgb(0, 161, 255)");Factory_1$g.Factory.addGetterSetter(Transformer,"borderStrokeWidth",1,(0,Validators_1$g.getNumberValidator)());Factory_1$g.Factory.addGetterSetter(Transformer,"borderDash");Factory_1$g.Factory.addGetterSetter(Transformer,"keepRatio",!0);Factory_1$g.Factory.addGetterSetter(Transformer,"shiftBehavior","default");Factory_1$g.Factory.addGetterSetter(Transformer,"centeredScaling",!1);Factory_1$g.Factory.addGetterSetter(Transformer,"ignoreStroke",!1);Factory_1$g.Factory.addGetterSetter(Transformer,"padding",0,(0,Validators_1$g.getNumberValidator)());Factory_1$g.Factory.addGetterSetter(Transformer,"node");Factory_1$g.Factory.addGetterSetter(Transformer,"nodes");Factory_1$g.Factory.addGetterSetter(Transformer,"boundBoxFunc");Factory_1$g.Factory.addGetterSetter(Transformer,"anchorDragBoundFunc");Factory_1$g.Factory.addGetterSetter(Transformer,"anchorStyleFunc");Factory_1$g.Factory.addGetterSetter(Transformer,"shouldOverdrawWholeArea",!1);Factory_1$g.Factory.addGetterSetter(Transformer,"useSingleNodeRotation",!0);Factory_1$g.Factory.backCompat(Transformer,{lineEnabled:"borderEnabled",rotateHandlerOffset:"rotateAnchorOffset",enabledHandlers:"enabledAnchors"});var Wedge$1={};Object.defineProperty(Wedge$1,"__esModule",{value:!0});Wedge$1.Wedge=void 0;const Factory_1$f=Factory,Shape_1=Shape,Global_1=Global,Validators_1$f=Validators,Global_2=Global;class Wedge extends Shape_1.Shape{_sceneFunc(e){e.beginPath(),e.arc(0,0,this.radius(),0,Global_1.Konva.getAngle(this.angle()),this.clockwise()),e.lineTo(0,0),e.closePath(),e.fillStrokeShape(this)}getWidth(){return this.radius()*2}getHeight(){return this.radius()*2}setWidth(e){this.radius(e/2)}setHeight(e){this.radius(e/2)}}Wedge$1.Wedge=Wedge;Wedge.prototype.className="Wedge";Wedge.prototype._centroid=!0;Wedge.prototype._attrsAffectingSize=["radius"];(0,Global_2._registerNode)(Wedge);Factory_1$f.Factory.addGetterSetter(Wedge,"radius",0,(0,Validators_1$f.getNumberValidator)());Factory_1$f.Factory.addGetterSetter(Wedge,"angle",0,(0,Validators_1$f.getNumberValidator)());Factory_1$f.Factory.addGetterSetter(Wedge,"clockwise",!1);Factory_1$f.Factory.backCompat(Wedge,{angleDeg:"angle",getAngleDeg:"getAngle",setAngleDeg:"setAngle"});var Blur$1={};Object.defineProperty(Blur$1,"__esModule",{value:!0});Blur$1.Blur=void 0;const Factory_1$e=Factory,Node_1$e=Node$1,Validators_1$e=Validators;function BlurStack(){this.r=0,this.g=0,this.b=0,this.a=0,this.next=null}var mul_table=[512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,289,287,285,282,280,278,275,273,271,269,267,265,263,261,259],shg_table=[9,11,12,13,13,14,14,15,15,15,15,16,16,16,16,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24];function filterGaussBlurRGBA(o,e){var r=o.data,t=o.width,n=o.height,a,u,l,f,c,h,y,E,p,_,g,x,C,R,S,A,T,w,P,O,k,D,F,G,V=e+e+1,W=t-1,Z=n-1,q=e+1,z=q*(q+1)/2,U=new BlurStack,I=null,$=U,B=null,X=null,Q=mul_table[e],J=shg_table[e];for(l=1;l<V;l++)$=$.next=new BlurStack,l===q&&(I=$);for($.next=U,y=h=0,u=0;u<n;u++){for(A=T=w=P=E=p=_=g=0,x=q*(O=r[h]),C=q*(k=r[h+1]),R=q*(D=r[h+2]),S=q*(F=r[h+3]),E+=z*O,p+=z*k,_+=z*D,g+=z*F,$=U,l=0;l<q;l++)$.r=O,$.g=k,$.b=D,$.a=F,$=$.next;for(l=1;l<q;l++)f=h+((W<l?W:l)<<2),E+=($.r=O=r[f])*(G=q-l),p+=($.g=k=r[f+1])*G,_+=($.b=D=r[f+2])*G,g+=($.a=F=r[f+3])*G,A+=O,T+=k,w+=D,P+=F,$=$.next;for(B=U,X=I,a=0;a<t;a++)r[h+3]=F=g*Q>>J,F!==0?(F=255/F,r[h]=(E*Q>>J)*F,r[h+1]=(p*Q>>J)*F,r[h+2]=(_*Q>>J)*F):r[h]=r[h+1]=r[h+2]=0,E-=x,p-=C,_-=R,g-=S,x-=B.r,C-=B.g,R-=B.b,S-=B.a,f=y+((f=a+e+1)<W?f:W)<<2,A+=B.r=r[f],T+=B.g=r[f+1],w+=B.b=r[f+2],P+=B.a=r[f+3],E+=A,p+=T,_+=w,g+=P,B=B.next,x+=O=X.r,C+=k=X.g,R+=D=X.b,S+=F=X.a,A-=O,T-=k,w-=D,P-=F,X=X.next,h+=4;y+=t}for(a=0;a<t;a++){for(T=w=P=A=p=_=g=E=0,h=a<<2,x=q*(O=r[h]),C=q*(k=r[h+1]),R=q*(D=r[h+2]),S=q*(F=r[h+3]),E+=z*O,p+=z*k,_+=z*D,g+=z*F,$=U,l=0;l<q;l++)$.r=O,$.g=k,$.b=D,$.a=F,$=$.next;for(c=t,l=1;l<=e;l++)h=c+a<<2,E+=($.r=O=r[h])*(G=q-l),p+=($.g=k=r[h+1])*G,_+=($.b=D=r[h+2])*G,g+=($.a=F=r[h+3])*G,A+=O,T+=k,w+=D,P+=F,$=$.next,l<Z&&(c+=t);for(h=a,B=U,X=I,u=0;u<n;u++)f=h<<2,r[f+3]=F=g*Q>>J,F>0?(F=255/F,r[f]=(E*Q>>J)*F,r[f+1]=(p*Q>>J)*F,r[f+2]=(_*Q>>J)*F):r[f]=r[f+1]=r[f+2]=0,E-=x,p-=C,_-=R,g-=S,x-=B.r,C-=B.g,R-=B.b,S-=B.a,f=a+((f=u+q)<Z?f:Z)*t<<2,E+=A+=B.r=r[f],p+=T+=B.g=r[f+1],_+=w+=B.b=r[f+2],g+=P+=B.a=r[f+3],B=B.next,x+=O=X.r,C+=k=X.g,R+=D=X.b,S+=F=X.a,A-=O,T-=k,w-=D,P-=F,X=X.next,h+=t}}const Blur=function o(e){var r=Math.round(this.blurRadius());r>0&&filterGaussBlurRGBA(e,r)};Blur$1.Blur=Blur;Factory_1$e.Factory.addGetterSetter(Node_1$e.Node,"blurRadius",0,(0,Validators_1$e.getNumberValidator)(),Factory_1$e.Factory.afterSetFilter);var Brighten$1={};Object.defineProperty(Brighten$1,"__esModule",{value:!0});Brighten$1.Brighten=void 0;const Factory_1$d=Factory,Node_1$d=Node$1,Validators_1$d=Validators,Brighten=function(o){var e=this.brightness()*255,r=o.data,t=r.length,n;for(n=0;n<t;n+=4)r[n]+=e,r[n+1]+=e,r[n+2]+=e};Brighten$1.Brighten=Brighten;Factory_1$d.Factory.addGetterSetter(Node_1$d.Node,"brightness",0,(0,Validators_1$d.getNumberValidator)(),Factory_1$d.Factory.afterSetFilter);var Contrast$1={};Object.defineProperty(Contrast$1,"__esModule",{value:!0});Contrast$1.Contrast=void 0;const Factory_1$c=Factory,Node_1$c=Node$1,Validators_1$c=Validators,Contrast=function(o){var e=Math.pow((this.contrast()+100)/100,2),r=o.data,t=r.length,n=150,a=150,u=150,l;for(l=0;l<t;l+=4)n=r[l],a=r[l+1],u=r[l+2],n/=255,n-=.5,n*=e,n+=.5,n*=255,a/=255,a-=.5,a*=e,a+=.5,a*=255,u/=255,u-=.5,u*=e,u+=.5,u*=255,n=n<0?0:n>255?255:n,a=a<0?0:a>255?255:a,u=u<0?0:u>255?255:u,r[l]=n,r[l+1]=a,r[l+2]=u};Contrast$1.Contrast=Contrast;Factory_1$c.Factory.addGetterSetter(Node_1$c.Node,"contrast",0,(0,Validators_1$c.getNumberValidator)(),Factory_1$c.Factory.afterSetFilter);var Emboss$1={};Object.defineProperty(Emboss$1,"__esModule",{value:!0});Emboss$1.Emboss=void 0;const Factory_1$b=Factory,Node_1$b=Node$1,Util_1$2=Util,Validators_1$b=Validators,Emboss=function(o){var e=this.embossStrength()*10,r=this.embossWhiteLevel()*255,t=this.embossDirection(),n=this.embossBlend(),a=0,u=0,l=o.data,f=o.width,c=o.height,h=f*4,y=c;switch(t){case"top-left":a=-1,u=-1;break;case"top":a=-1,u=0;break;case"top-right":a=-1,u=1;break;case"right":a=0,u=1;break;case"bottom-right":a=1,u=1;break;case"bottom":a=1,u=0;break;case"bottom-left":a=1,u=-1;break;case"left":a=0,u=-1;break;default:Util_1$2.Util.error("Unknown emboss direction: "+t)}do{var E=(y-1)*h,p=a;y+p<1&&(p=0),y+p>c&&(p=0);var _=(y-1+p)*f*4,g=f;do{var x=E+(g-1)*4,C=u;g+C<1&&(C=0),g+C>f&&(C=0);var R=_+(g-1+C)*4,S=l[x]-l[R],A=l[x+1]-l[R+1],T=l[x+2]-l[R+2],w=S,P=w>0?w:-w,O=A>0?A:-A,k=T>0?T:-T;if(O>P&&(w=A),k>P&&(w=T),w*=e,n){var D=l[x]+w,F=l[x+1]+w,G=l[x+2]+w;l[x]=D>255?255:D<0?0:D,l[x+1]=F>255?255:F<0?0:F,l[x+2]=G>255?255:G<0?0:G}else{var V=r-w;V<0?V=0:V>255&&(V=255),l[x]=l[x+1]=l[x+2]=V}}while(--g)}while(--y)};Emboss$1.Emboss=Emboss;Factory_1$b.Factory.addGetterSetter(Node_1$b.Node,"embossStrength",.5,(0,Validators_1$b.getNumberValidator)(),Factory_1$b.Factory.afterSetFilter);Factory_1$b.Factory.addGetterSetter(Node_1$b.Node,"embossWhiteLevel",.5,(0,Validators_1$b.getNumberValidator)(),Factory_1$b.Factory.afterSetFilter);Factory_1$b.Factory.addGetterSetter(Node_1$b.Node,"embossDirection","top-left",null,Factory_1$b.Factory.afterSetFilter);Factory_1$b.Factory.addGetterSetter(Node_1$b.Node,"embossBlend",!1,null,Factory_1$b.Factory.afterSetFilter);var Enhance$1={};Object.defineProperty(Enhance$1,"__esModule",{value:!0});Enhance$1.Enhance=void 0;const Factory_1$a=Factory,Node_1$a=Node$1,Validators_1$a=Validators;function remap(o,e,r,t,n){var a=r-e,u=n-t,l;return a===0?t+u/2:u===0?t:(l=(o-e)/a,l=u*l+t,l)}const Enhance=function(o){var e=o.data,r=e.length,t=e[0],n=t,a,u=e[1],l=u,f,c=e[2],h=c,y,E,p=this.enhance();if(p!==0){for(E=0;E<r;E+=4)a=e[E+0],a<t?t=a:a>n&&(n=a),f=e[E+1],f<u?u=f:f>l&&(l=f),y=e[E+2],y<c?c=y:y>h&&(h=y);n===t&&(n=255,t=0),l===u&&(l=255,u=0),h===c&&(h=255,c=0);var _,g,x,C,R,S,A,T,w;for(p>0?(g=n+p*(255-n),x=t-p*(t-0),R=l+p*(255-l),S=u-p*(u-0),T=h+p*(255-h),w=c-p*(c-0)):(_=(n+t)*.5,g=n+p*(n-_),x=t+p*(t-_),C=(l+u)*.5,R=l+p*(l-C),S=u+p*(u-C),A=(h+c)*.5,T=h+p*(h-A),w=c+p*(c-A)),E=0;E<r;E+=4)e[E+0]=remap(e[E+0],t,n,x,g),e[E+1]=remap(e[E+1],u,l,S,R),e[E+2]=remap(e[E+2],c,h,w,T)}};Enhance$1.Enhance=Enhance;Factory_1$a.Factory.addGetterSetter(Node_1$a.Node,"enhance",0,(0,Validators_1$a.getNumberValidator)(),Factory_1$a.Factory.afterSetFilter);var Grayscale$1={};Object.defineProperty(Grayscale$1,"__esModule",{value:!0});Grayscale$1.Grayscale=void 0;const Grayscale=function(o){var e=o.data,r=e.length,t,n;for(t=0;t<r;t+=4)n=.34*e[t]+.5*e[t+1]+.16*e[t+2],e[t]=n,e[t+1]=n,e[t+2]=n};Grayscale$1.Grayscale=Grayscale;var HSL$1={};Object.defineProperty(HSL$1,"__esModule",{value:!0});HSL$1.HSL=void 0;const Factory_1$9=Factory,Node_1$9=Node$1,Validators_1$9=Validators;Factory_1$9.Factory.addGetterSetter(Node_1$9.Node,"hue",0,(0,Validators_1$9.getNumberValidator)(),Factory_1$9.Factory.afterSetFilter);Factory_1$9.Factory.addGetterSetter(Node_1$9.Node,"saturation",0,(0,Validators_1$9.getNumberValidator)(),Factory_1$9.Factory.afterSetFilter);Factory_1$9.Factory.addGetterSetter(Node_1$9.Node,"luminance",0,(0,Validators_1$9.getNumberValidator)(),Factory_1$9.Factory.afterSetFilter);const HSL=function(o){var e=o.data,r=e.length,t=1,n=Math.pow(2,this.saturation()),a=Math.abs(this.hue()+360)%360,u=this.luminance()*127,l,f=t*n*Math.cos(a*Math.PI/180),c=t*n*Math.sin(a*Math.PI/180),h=.299*t+.701*f+.167*c,y=.587*t-.587*f+.33*c,E=.114*t-.114*f-.497*c,p=.299*t-.299*f-.328*c,_=.587*t+.413*f+.035*c,g=.114*t-.114*f+.293*c,x=.299*t-.3*f+1.25*c,C=.587*t-.586*f-1.05*c,R=.114*t+.886*f-.2*c,S,A,T,w;for(l=0;l<r;l+=4)S=e[l+0],A=e[l+1],T=e[l+2],w=e[l+3],e[l+0]=h*S+y*A+E*T+u,e[l+1]=p*S+_*A+g*T+u,e[l+2]=x*S+C*A+R*T+u,e[l+3]=w};HSL$1.HSL=HSL;var HSV$1={};Object.defineProperty(HSV$1,"__esModule",{value:!0});HSV$1.HSV=void 0;const Factory_1$8=Factory,Node_1$8=Node$1,Validators_1$8=Validators,HSV=function(o){var e=o.data,r=e.length,t=Math.pow(2,this.value()),n=Math.pow(2,this.saturation()),a=Math.abs(this.hue()+360)%360,u,l=t*n*Math.cos(a*Math.PI/180),f=t*n*Math.sin(a*Math.PI/180),c=.299*t+.701*l+.167*f,h=.587*t-.587*l+.33*f,y=.114*t-.114*l-.497*f,E=.299*t-.299*l-.328*f,p=.587*t+.413*l+.035*f,_=.114*t-.114*l+.293*f,g=.299*t-.3*l+1.25*f,x=.587*t-.586*l-1.05*f,C=.114*t+.886*l-.2*f,R,S,A,T;for(u=0;u<r;u+=4)R=e[u+0],S=e[u+1],A=e[u+2],T=e[u+3],e[u+0]=c*R+h*S+y*A,e[u+1]=E*R+p*S+_*A,e[u+2]=g*R+x*S+C*A,e[u+3]=T};HSV$1.HSV=HSV;Factory_1$8.Factory.addGetterSetter(Node_1$8.Node,"hue",0,(0,Validators_1$8.getNumberValidator)(),Factory_1$8.Factory.afterSetFilter);Factory_1$8.Factory.addGetterSetter(Node_1$8.Node,"saturation",0,(0,Validators_1$8.getNumberValidator)(),Factory_1$8.Factory.afterSetFilter);Factory_1$8.Factory.addGetterSetter(Node_1$8.Node,"value",0,(0,Validators_1$8.getNumberValidator)(),Factory_1$8.Factory.afterSetFilter);var Invert$1={};Object.defineProperty(Invert$1,"__esModule",{value:!0});Invert$1.Invert=void 0;const Invert=function(o){var e=o.data,r=e.length,t;for(t=0;t<r;t+=4)e[t]=255-e[t],e[t+1]=255-e[t+1],e[t+2]=255-e[t+2]};Invert$1.Invert=Invert;var Kaleidoscope$1={};Object.defineProperty(Kaleidoscope$1,"__esModule",{value:!0});Kaleidoscope$1.Kaleidoscope=void 0;const Factory_1$7=Factory,Node_1$7=Node$1,Util_1$1=Util,Validators_1$7=Validators;var ToPolar=function(o,e,r){var t=o.data,n=e.data,a=o.width,u=o.height,l=r.polarCenterX||a/2,f=r.polarCenterY||u/2,c,h,y,E=0,p=0,_=0,g=0,x,C=Math.sqrt(l*l+f*f);h=a-l,y=u-f,x=Math.sqrt(h*h+y*y),C=x>C?x:C;var R=u,S=a,A,T,w=360/S*Math.PI/180,P,O;for(T=0;T<S;T+=1)for(P=Math.sin(T*w),O=Math.cos(T*w),A=0;A<R;A+=1)h=Math.floor(l+C*A/R*O),y=Math.floor(f+C*A/R*P),c=(y*a+h)*4,E=t[c+0],p=t[c+1],_=t[c+2],g=t[c+3],c=(T+A*a)*4,n[c+0]=E,n[c+1]=p,n[c+2]=_,n[c+3]=g},FromPolar=function(o,e,r){var t=o.data,n=e.data,a=o.width,u=o.height,l=r.polarCenterX||a/2,f=r.polarCenterY||u/2,c,h,y,E,p,_=0,g=0,x=0,C=0,R,S=Math.sqrt(l*l+f*f);h=a-l,y=u-f,R=Math.sqrt(h*h+y*y),S=R>S?R:S;var A=u,T=a,w,P,O=r.polarRotation||0,k,D;for(h=0;h<a;h+=1)for(y=0;y<u;y+=1)E=h-l,p=y-f,w=Math.sqrt(E*E+p*p)*A/S,P=(Math.atan2(p,E)*180/Math.PI+360+O)%360,P=P*T/360,k=Math.floor(P),D=Math.floor(w),c=(D*a+k)*4,_=t[c+0],g=t[c+1],x=t[c+2],C=t[c+3],c=(y*a+h)*4,n[c+0]=_,n[c+1]=g,n[c+2]=x,n[c+3]=C};const Kaleidoscope=function(o){var e=o.width,r=o.height,t,n,a,u,l,f,c,h,y,E,p=Math.round(this.kaleidoscopePower()),_=Math.round(this.kaleidoscopeAngle()),g=Math.floor(e*(_%360)/360);if(!(p<1)){var x=Util_1$1.Util.createCanvasElement();x.width=e,x.height=r;var C=x.getContext("2d").getImageData(0,0,e,r);Util_1$1.Util.releaseCanvas(x),ToPolar(o,C,{polarCenterX:e/2,polarCenterY:r/2});for(var R=e/Math.pow(2,p);R<=8;)R=R*2,p-=1;R=Math.ceil(R);var S=R,A=0,T=S,w=1;for(g+R>e&&(A=S,T=0,w=-1),n=0;n<r;n+=1)for(t=A;t!==T;t+=w)a=Math.round(t+g)%e,y=(e*n+a)*4,l=C.data[y+0],f=C.data[y+1],c=C.data[y+2],h=C.data[y+3],E=(e*n+t)*4,C.data[E+0]=l,C.data[E+1]=f,C.data[E+2]=c,C.data[E+3]=h;for(n=0;n<r;n+=1)for(S=Math.floor(R),u=0;u<p;u+=1){for(t=0;t<S+1;t+=1)y=(e*n+t)*4,l=C.data[y+0],f=C.data[y+1],c=C.data[y+2],h=C.data[y+3],E=(e*n+S*2-t-1)*4,C.data[E+0]=l,C.data[E+1]=f,C.data[E+2]=c,C.data[E+3]=h;S*=2}FromPolar(C,o,{polarRotation:0})}};Kaleidoscope$1.Kaleidoscope=Kaleidoscope;Factory_1$7.Factory.addGetterSetter(Node_1$7.Node,"kaleidoscopePower",2,(0,Validators_1$7.getNumberValidator)(),Factory_1$7.Factory.afterSetFilter);Factory_1$7.Factory.addGetterSetter(Node_1$7.Node,"kaleidoscopeAngle",0,(0,Validators_1$7.getNumberValidator)(),Factory_1$7.Factory.afterSetFilter);var Mask$1={};Object.defineProperty(Mask$1,"__esModule",{value:!0});Mask$1.Mask=void 0;const Factory_1$6=Factory,Node_1$6=Node$1,Validators_1$6=Validators;function pixelAt(o,e,r){var t=(r*o.width+e)*4,n=[];return n.push(o.data[t++],o.data[t++],o.data[t++],o.data[t++]),n}function rgbDistance(o,e){return Math.sqrt(Math.pow(o[0]-e[0],2)+Math.pow(o[1]-e[1],2)+Math.pow(o[2]-e[2],2))}function rgbMean(o){for(var e=[0,0,0],r=0;r<o.length;r++)e[0]+=o[r][0],e[1]+=o[r][1],e[2]+=o[r][2];return e[0]/=o.length,e[1]/=o.length,e[2]/=o.length,e}function backgroundMask(o,e){var r=pixelAt(o,0,0),t=pixelAt(o,o.width-1,0),n=pixelAt(o,0,o.height-1),a=pixelAt(o,o.width-1,o.height-1),u=e||10;if(rgbDistance(r,t)<u&&rgbDistance(t,a)<u&&rgbDistance(a,n)<u&&rgbDistance(n,r)<u){for(var l=rgbMean([t,r,a,n]),f=[],c=0;c<o.width*o.height;c++){var h=rgbDistance(l,[o.data[c*4],o.data[c*4+1],o.data[c*4+2]]);f[c]=h<u?0:255}return f}}function applyMask(o,e){for(var r=0;r<o.width*o.height;r++)o.data[4*r+3]=e[r]}function erodeMask(o,e,r){for(var t=[1,1,1,1,0,1,1,1,1],n=Math.round(Math.sqrt(t.length)),a=Math.floor(n/2),u=[],l=0;l<r;l++)for(var f=0;f<e;f++){for(var c=l*e+f,h=0,y=0;y<n;y++)for(var E=0;E<n;E++){var p=l+y-a,_=f+E-a;if(p>=0&&p<r&&_>=0&&_<e){var g=p*e+_,x=t[y*n+E];h+=o[g]*x}}u[c]=h===255*8?255:0}return u}function dilateMask(o,e,r){for(var t=[1,1,1,1,1,1,1,1,1],n=Math.round(Math.sqrt(t.length)),a=Math.floor(n/2),u=[],l=0;l<r;l++)for(var f=0;f<e;f++){for(var c=l*e+f,h=0,y=0;y<n;y++)for(var E=0;E<n;E++){var p=l+y-a,_=f+E-a;if(p>=0&&p<r&&_>=0&&_<e){var g=p*e+_,x=t[y*n+E];h+=o[g]*x}}u[c]=h>=255*4?255:0}return u}function smoothEdgeMask(o,e,r){for(var t=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],n=Math.round(Math.sqrt(t.length)),a=Math.floor(n/2),u=[],l=0;l<r;l++)for(var f=0;f<e;f++){for(var c=l*e+f,h=0,y=0;y<n;y++)for(var E=0;E<n;E++){var p=l+y-a,_=f+E-a;if(p>=0&&p<r&&_>=0&&_<e){var g=p*e+_,x=t[y*n+E];h+=o[g]*x}}u[c]=h}return u}const Mask=function(o){var e=this.threshold(),r=backgroundMask(o,e);return r&&(r=erodeMask(r,o.width,o.height),r=dilateMask(r,o.width,o.height),r=smoothEdgeMask(r,o.width,o.height),applyMask(o,r)),o};Mask$1.Mask=Mask;Factory_1$6.Factory.addGetterSetter(Node_1$6.Node,"threshold",0,(0,Validators_1$6.getNumberValidator)(),Factory_1$6.Factory.afterSetFilter);var Noise$1={};Object.defineProperty(Noise$1,"__esModule",{value:!0});Noise$1.Noise=void 0;const Factory_1$5=Factory,Node_1$5=Node$1,Validators_1$5=Validators,Noise=function(o){var e=this.noise()*255,r=o.data,t=r.length,n=e/2,a;for(a=0;a<t;a+=4)r[a+0]+=n-2*n*Math.random(),r[a+1]+=n-2*n*Math.random(),r[a+2]+=n-2*n*Math.random()};Noise$1.Noise=Noise;Factory_1$5.Factory.addGetterSetter(Node_1$5.Node,"noise",.2,(0,Validators_1$5.getNumberValidator)(),Factory_1$5.Factory.afterSetFilter);var Pixelate$1={};Object.defineProperty(Pixelate$1,"__esModule",{value:!0});Pixelate$1.Pixelate=void 0;const Factory_1$4=Factory,Util_1=Util,Node_1$4=Node$1,Validators_1$4=Validators,Pixelate=function(o){var e=Math.ceil(this.pixelSize()),r=o.width,t=o.height,n,a,u,l,f,c,h,y=Math.ceil(r/e),E=Math.ceil(t/e),p,_,g,x,C,R,S,A=o.data;if(e<=0){Util_1.Util.error("pixelSize value can not be <= 0");return}for(C=0;C<y;C+=1)for(R=0;R<E;R+=1){for(l=0,f=0,c=0,h=0,p=C*e,_=p+e,g=R*e,x=g+e,S=0,n=p;n<_;n+=1)if(!(n>=r))for(a=g;a<x;a+=1)a>=t||(u=(r*a+n)*4,l+=A[u+0],f+=A[u+1],c+=A[u+2],h+=A[u+3],S+=1);for(l=l/S,f=f/S,c=c/S,h=h/S,n=p;n<_;n+=1)if(!(n>=r))for(a=g;a<x;a+=1)a>=t||(u=(r*a+n)*4,A[u+0]=l,A[u+1]=f,A[u+2]=c,A[u+3]=h)}};Pixelate$1.Pixelate=Pixelate;Factory_1$4.Factory.addGetterSetter(Node_1$4.Node,"pixelSize",8,(0,Validators_1$4.getNumberValidator)(),Factory_1$4.Factory.afterSetFilter);var Posterize$1={};Object.defineProperty(Posterize$1,"__esModule",{value:!0});Posterize$1.Posterize=void 0;const Factory_1$3=Factory,Node_1$3=Node$1,Validators_1$3=Validators,Posterize=function(o){var e=Math.round(this.levels()*254)+1,r=o.data,t=r.length,n=255/e,a;for(a=0;a<t;a+=1)r[a]=Math.floor(r[a]/n)*n};Posterize$1.Posterize=Posterize;Factory_1$3.Factory.addGetterSetter(Node_1$3.Node,"levels",.5,(0,Validators_1$3.getNumberValidator)(),Factory_1$3.Factory.afterSetFilter);var RGB$1={};Object.defineProperty(RGB$1,"__esModule",{value:!0});RGB$1.RGB=void 0;const Factory_1$2=Factory,Node_1$2=Node$1,Validators_1$2=Validators,RGB=function(o){var e=o.data,r=e.length,t=this.red(),n=this.green(),a=this.blue(),u,l;for(u=0;u<r;u+=4)l=(.34*e[u]+.5*e[u+1]+.16*e[u+2])/255,e[u]=l*t,e[u+1]=l*n,e[u+2]=l*a,e[u+3]=e[u+3]};RGB$1.RGB=RGB;Factory_1$2.Factory.addGetterSetter(Node_1$2.Node,"red",0,function(o){return this._filterUpToDate=!1,o>255?255:o<0?0:Math.round(o)});Factory_1$2.Factory.addGetterSetter(Node_1$2.Node,"green",0,function(o){return this._filterUpToDate=!1,o>255?255:o<0?0:Math.round(o)});Factory_1$2.Factory.addGetterSetter(Node_1$2.Node,"blue",0,Validators_1$2.RGBComponent,Factory_1$2.Factory.afterSetFilter);var RGBA$1={};Object.defineProperty(RGBA$1,"__esModule",{value:!0});RGBA$1.RGBA=void 0;const Factory_1$1=Factory,Node_1$1=Node$1,Validators_1$1=Validators,RGBA=function(o){var e=o.data,r=e.length,t=this.red(),n=this.green(),a=this.blue(),u=this.alpha(),l,f;for(l=0;l<r;l+=4)f=1-u,e[l]=t*u+e[l]*f,e[l+1]=n*u+e[l+1]*f,e[l+2]=a*u+e[l+2]*f};RGBA$1.RGBA=RGBA;Factory_1$1.Factory.addGetterSetter(Node_1$1.Node,"red",0,function(o){return this._filterUpToDate=!1,o>255?255:o<0?0:Math.round(o)});Factory_1$1.Factory.addGetterSetter(Node_1$1.Node,"green",0,function(o){return this._filterUpToDate=!1,o>255?255:o<0?0:Math.round(o)});Factory_1$1.Factory.addGetterSetter(Node_1$1.Node,"blue",0,Validators_1$1.RGBComponent,Factory_1$1.Factory.afterSetFilter);Factory_1$1.Factory.addGetterSetter(Node_1$1.Node,"alpha",1,function(o){return this._filterUpToDate=!1,o>1?1:o<0?0:o});var Sepia$1={};Object.defineProperty(Sepia$1,"__esModule",{value:!0});Sepia$1.Sepia=void 0;const Sepia=function(o){var e=o.data,r=e.length,t,n,a,u;for(t=0;t<r;t+=4)n=e[t+0],a=e[t+1],u=e[t+2],e[t+0]=Math.min(255,n*.393+a*.769+u*.189),e[t+1]=Math.min(255,n*.349+a*.686+u*.168),e[t+2]=Math.min(255,n*.272+a*.534+u*.131)};Sepia$1.Sepia=Sepia;var Solarize$1={};Object.defineProperty(Solarize$1,"__esModule",{value:!0});Solarize$1.Solarize=void 0;const Solarize=function(o){var e=o.data,r=o.width,t=o.height,n=r*4,a=t;do{var u=(a-1)*n,l=r;do{var f=u+(l-1)*4,c=e[f],h=e[f+1],y=e[f+2];c>127&&(c=255-c),h>127&&(h=255-h),y>127&&(y=255-y),e[f]=c,e[f+1]=h,e[f+2]=y}while(--l)}while(--a)};Solarize$1.Solarize=Solarize;var Threshold$1={};Object.defineProperty(Threshold$1,"__esModule",{value:!0});Threshold$1.Threshold=void 0;const Factory_1=Factory,Node_1=Node$1,Validators_1=Validators,Threshold=function(o){var e=this.threshold()*255,r=o.data,t=r.length,n;for(n=0;n<t;n+=1)r[n]=r[n]<e?0:255};Threshold$1.Threshold=Threshold;Factory_1.Factory.addGetterSetter(Node_1.Node,"threshold",.5,(0,Validators_1.getNumberValidator)(),Factory_1.Factory.afterSetFilter);Object.defineProperty(_FullInternals,"__esModule",{value:!0});_FullInternals.Konva=void 0;const _CoreInternals_1=_CoreInternals,Arc_1=Arc$1,Arrow_1=Arrow$1,Circle_1=Circle$1,Ellipse_1=Ellipse$1,Image_1=Image$4,Label_1=Label$1,Line_1=Line$2,Path_1=Path$1,Rect_1=Rect$2,RegularPolygon_1=RegularPolygon$1,Ring_1=Ring$1,Sprite_1=Sprite$1,Star_1=Star$1,Text_1=Text$2,TextPath_1=TextPath$1,Transformer_1=Transformer$1,Wedge_1=Wedge$1,Blur_1=Blur$1,Brighten_1=Brighten$1,Contrast_1=Contrast$1,Emboss_1=Emboss$1,Enhance_1=Enhance$1,Grayscale_1=Grayscale$1,HSL_1=HSL$1,HSV_1=HSV$1,Invert_1=Invert$1,Kaleidoscope_1=Kaleidoscope$1,Mask_1=Mask$1,Noise_1=Noise$1,Pixelate_1=Pixelate$1,Posterize_1=Posterize$1,RGB_1=RGB$1,RGBA_1=RGBA$1,Sepia_1=Sepia$1,Solarize_1=Solarize$1,Threshold_1=Threshold$1;_FullInternals.Konva=_CoreInternals_1.Konva.Util._assign(_CoreInternals_1.Konva,{Arc:Arc_1.Arc,Arrow:Arrow_1.Arrow,Circle:Circle_1.Circle,Ellipse:Ellipse_1.Ellipse,Image:Image_1.Image,Label:Label_1.Label,Tag:Label_1.Tag,Line:Line_1.Line,Path:Path_1.Path,Rect:Rect_1.Rect,RegularPolygon:RegularPolygon_1.RegularPolygon,Ring:Ring_1.Ring,Sprite:Sprite_1.Sprite,Star:Star_1.Star,Text:Text_1.Text,TextPath:TextPath_1.TextPath,Transformer:Transformer_1.Transformer,Wedge:Wedge_1.Wedge,Filters:{Blur:Blur_1.Blur,Brighten:Brighten_1.Brighten,Contrast:Contrast_1.Contrast,Emboss:Emboss_1.Emboss,Enhance:Enhance_1.Enhance,Grayscale:Grayscale_1.Grayscale,HSL:HSL_1.HSL,HSV:HSV_1.HSV,Invert:Invert_1.Invert,Kaleidoscope:Kaleidoscope_1.Kaleidoscope,Mask:Mask_1.Mask,Noise:Noise_1.Noise,Pixelate:Pixelate_1.Pixelate,Posterize:Posterize_1.Posterize,RGB:RGB_1.RGB,RGBA:RGBA_1.RGBA,Sepia:Sepia_1.Sepia,Solarize:Solarize_1.Solarize,Threshold:Threshold_1.Threshold}});var lib=lib$1.exports;Object.defineProperty(lib,"__esModule",{value:!0});const _FullInternals_1=_FullInternals;lib$1.exports=_FullInternals_1.Konva;var Core={exports:{}};(function(o,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Konva=void 0;var r=_CoreInternals;Object.defineProperty(e,"Konva",{enumerable:!0,get:function(){return r.Konva}});const t=_CoreInternals;o.exports=t.Konva})(Core,Core.exports);var CoreExports=Core.exports;const Konva=getDefaultExportFromCjs(CoreExports);var reactReconciler={exports:{}},scheduler={exports:{}},scheduler_production_min={};/**
73
73
  * @license React
74
74
  * scheduler.production.min.js
@@ -249,7 +249,7 @@ For more info see: https://github.com/konvajs/react-konva/issues/256
249
249
  `,Z_INDEX_WARNING=`ReactKonva: You are using "zIndex" attribute for a Konva node.
250
250
  react-konva may get confused with ordering. Just define correct order of elements in your render function of a component.
251
251
  For more info see: https://github.com/konvajs/react-konva/issues/194
252
- `,EMPTY_PROPS={};function applyNodeProps(o,e,r=EMPTY_PROPS){if(!zIndexWarningShowed&&"zIndex"in e&&(console.warn(Z_INDEX_WARNING),zIndexWarningShowed=!0),!dragWarningShowed&&e.draggable){var t=e.x!==void 0||e.y!==void 0,n=e.onDragEnd||e.onDragMove;t&&!n&&(console.warn(DRAGGABLE_WARNING),dragWarningShowed=!0)}for(var a in r)if(!propsToSkip[a]){var u=a.slice(0,2)==="on",l=r[a]!==e[a];if(u&&l){var f=a.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),o.off(f,r[a])}var c=!e.hasOwnProperty(a);c&&o.setAttr(a,void 0)}var h=e._useStrictMode,y={},E=!1;const p={};for(var a in e)if(!propsToSkip[a]){var u=a.slice(0,2)==="on",_=r[a]!==e[a];if(u&&_){var f=a.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),e[a]&&(p[f]=e[a])}!u&&(e[a]!==r[a]||h&&e[a]!==o.getAttr(a))&&(E=!0,y[a]=e[a])}E&&(o.setAttrs(y),updatePicture(o));for(var f in p)o.on(f+EVENTS_NAMESPACE,p[f])}function updatePicture(o){if(!Global.Konva.autoDrawEnabled){var e=o.getLayer()||o.getStage();e&&e.batchDraw()}}var schedulerExports=requireScheduler();const NO_CONTEXT={},UPDATE_SIGNAL={};Konva.Node.prototype._applyProps=applyNodeProps;function appendInitialChild(o,e){if(typeof e=="string"){console.error(`Do not use plain text as child of Konva.Node. You are using text: ${e}`);return}o.add(e),updatePicture(o)}function createInstance(o,e,r){let t=Konva[o];t||(console.error(`Konva has no node with the type ${o}. Group will be used instead. If you use minimal version of react-konva, just import required nodes into Konva: "import "konva/lib/shapes/${o}" If you want to render DOM elements as part of canvas tree take a look into this demo: https://konvajs.github.io/docs/react/DOM_Portal.html`),t=Konva.Group);const n={},a={};for(var u in e){var l=u.slice(0,2)==="on";l?a[u]=e[u]:n[u]=e[u]}const f=new t(n);return applyNodeProps(f,a),f}function createTextInstance(o,e,r){console.error(`Text components are not supported for now in ReactKonva. Your text is: "${o}"`)}function finalizeInitialChildren(o,e,r){return!1}function getPublicInstance(o){return o}function prepareForCommit(){return null}function preparePortalMount(){return null}function prepareUpdate(o,e,r,t){return UPDATE_SIGNAL}function resetAfterCommit(){}function resetTextContent(o){}function shouldDeprioritizeSubtree(o,e){return!1}function getRootHostContext(){return NO_CONTEXT}function getChildHostContext(){return NO_CONTEXT}const scheduleTimeout=setTimeout,cancelTimeout=clearTimeout,noTimeout=-1;function shouldSetTextContent(o,e){return!1}const isPrimaryRenderer=!1,warnsIfNotActing=!0,supportsMutation=!0;function appendChild(o,e){e.parent===o?e.moveToTop():o.add(e),updatePicture(o)}function appendChildToContainer(o,e){e.parent===o?e.moveToTop():o.add(e),updatePicture(o)}function insertBefore(o,e,r){e._remove(),o.add(e),e.setZIndex(r.getZIndex()),updatePicture(o)}function insertInContainerBefore(o,e,r){insertBefore(o,e,r)}function removeChild(o,e){e.destroy(),e.off(EVENTS_NAMESPACE),updatePicture(o)}function removeChildFromContainer(o,e){e.destroy(),e.off(EVENTS_NAMESPACE),updatePicture(o)}function commitTextUpdate(o,e,r){console.error(`Text components are not yet supported in ReactKonva. You text is: "${r}"`)}function commitMount(o,e,r){}function commitUpdate(o,e,r,t,n){applyNodeProps(o,n,t)}function hideInstance(o){o.hide(),updatePicture(o)}function hideTextInstance(o){}function unhideInstance(o,e){(e.visible==null||e.visible)&&o.show()}function unhideTextInstance(o,e){}function clearContainer(o){}function detachDeletedInstance(){}const getCurrentEventPriority=()=>constantsExports.DefaultEventPriority,HostConfig=Object.freeze(Object.defineProperty({__proto__:null,appendChild,appendChildToContainer,appendInitialChild,cancelTimeout,clearContainer,commitMount,commitTextUpdate,commitUpdate,createInstance,createTextInstance,detachDeletedInstance,finalizeInitialChildren,getChildHostContext,getCurrentEventPriority,getPublicInstance,getRootHostContext,hideInstance,hideTextInstance,idlePriority:schedulerExports.unstable_IdlePriority,insertBefore,insertInContainerBefore,isPrimaryRenderer,noTimeout,now:schedulerExports.unstable_now,prepareForCommit,preparePortalMount,prepareUpdate,removeChild,removeChildFromContainer,resetAfterCommit,resetTextContent,run:schedulerExports.unstable_runWithPriority,scheduleTimeout,shouldDeprioritizeSubtree,shouldSetTextContent,supportsMutation,unhideInstance,unhideTextInstance,warnsIfNotActing},Symbol.toStringTag,{value:"Module"}));var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,e,r)=>e in o?__defProp(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r,__spreadValues=(o,e)=>{for(var r in e||(e={}))__hasOwnProp.call(e,r)&&__defNormalProp(o,r,e[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(e))__propIsEnum.call(e,r)&&__defNormalProp(o,r,e[r]);return o},__spreadProps=(o,e)=>__defProps(o,__getOwnPropDescs(e));function traverseFiber(o,e,r){if(!o)return;if(r(o)===!0)return o;let t=e?o.return:o.child;for(;t;){const n=traverseFiber(t,e,r);if(n)return n;t=e?null:t.sibling}}function wrapContext(o){try{return Object.defineProperties(o,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return o}}const FiberContext=wrapContext(React__namespace.createContext(null));class FiberProvider extends React__namespace.Component{render(){return React__namespace.createElement(FiberContext.Provider,{value:this._reactInternals},this.props.children)}}const{ReactCurrentOwner,ReactCurrentDispatcher}=React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function useFiber(){const o=React__namespace.useContext(FiberContext);if(o===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const e=React__namespace.useId();return React__namespace.useMemo(()=>{for(const t of[ReactCurrentOwner==null?void 0:ReactCurrentOwner.current,o,o==null?void 0:o.alternate]){if(!t)continue;const n=traverseFiber(t,!1,a=>{let u=a.memoizedState;for(;u;){if(u.memoizedState===e)return!0;u=u.next}});if(n)return n}},[o,e])}function useContextMap(){var o,e;const r=useFiber(),[t]=React__namespace.useState(()=>new Map);t.clear();let n=r;for(;n;){const a=(o=n.type)==null?void 0:o._context;a&&a!==FiberContext&&!t.has(a)&&t.set(a,(e=ReactCurrentDispatcher==null?void 0:ReactCurrentDispatcher.current)==null?void 0:e.readContext(wrapContext(a))),n=n.return}return t}function useContextBridge(){const o=useContextMap();return React__namespace.useMemo(()=>Array.from(o.keys()).reduce((e,r)=>t=>React__namespace.createElement(e,null,React__namespace.createElement(r.Provider,__spreadProps(__spreadValues({},t),{value:o.get(r)}))),e=>React__namespace.createElement(FiberProvider,__spreadValues({},e))),[o])}function usePrevious(o){const e=React$2.useRef({});return React$2.useLayoutEffect(()=>{e.current=o}),React$2.useLayoutEffect(()=>()=>{e.current={}},[]),e.current}const StageWrap=o=>{const e=React$2.useRef(),r=React$2.useRef(),t=React$2.useRef(),n=usePrevious(o),a=useContextBridge(),u=l=>{const{forwardedRef:f}=o;f&&(typeof f=="function"?f(l):f.current=l)};return React$2.useLayoutEffect(()=>(r.current=new Konva.Stage({width:o.width,height:o.height,container:e.current}),u(r.current),t.current=KonvaRenderer.createContainer(r.current,constantsExports.LegacyRoot,!1,null),KonvaRenderer.updateContainer(React$2.createElement(a,{},o.children),t.current),()=>{Konva.isBrowser&&(u(null),KonvaRenderer.updateContainer(null,t.current,null),r.current.destroy())}),[]),React$2.useLayoutEffect(()=>{u(r.current),applyNodeProps(r.current,o,n),KonvaRenderer.updateContainer(React$2.createElement(a,{},o.children),t.current,null)}),React$2.createElement("div",{ref:e,id:o.id,accessKey:o.accessKey,className:o.className,role:o.role,style:o.style,tabIndex:o.tabIndex,title:o.title})},Layer="Layer",Group="Group",Rect="Rect",Line="Line",Image$2="Image",Text="Text",KonvaRenderer=ReactFiberReconciler(HostConfig);KonvaRenderer.injectIntoDevTools({findHostInstanceByFiber:()=>null,bundleType:process.env.NODE_ENV!=="production"?1:0,version:React$2.version,rendererPackageName:"react-konva"});const Stage=React$2.forwardRef((o,e)=>React$2.createElement(FiberProvider,{},React$2.createElement(StageWrap,{...o,forwardedRef:e})));var client={},m=require$$0;if(process.env.NODE_ENV==="production")client.createRoot=m.createRoot,client.hydrateRoot=m.hydrateRoot;else{var i=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;client.createRoot=function(o,e){i.usingClientEntryPoint=!0;try{return m.createRoot(o,e)}finally{i.usingClientEntryPoint=!1}},client.hydrateRoot=function(o,e,r){i.usingClientEntryPoint=!0;try{return m.hydrateRoot(o,e,r)}finally{i.usingClientEntryPoint=!1}}}var __rest=globalThis&&globalThis.__rest||function(o,e){var r={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(r[t]=o[t]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,t=Object.getOwnPropertySymbols(o);n<t.length;n++)e.indexOf(t[n])<0&&Object.prototype.propertyIsEnumerable.call(o,t[n])&&(r[t[n]]=o[t[n]]);return r};const needForceStyle=o=>{const e=window.getComputedStyle(o).position;return!(e==="absolute"||e==="relative")};function useEvent(o=()=>{}){const e=React$2.useRef(o);return e.current=o,React$2.useCallback((...r)=>e.current.apply(null,r),[])}const Html=({children:o,groupProps:e,divProps:r,transform:t,transformFunc:n})=>{const a=React$2.useRef(null);React$2.useRef();const[u]=React$2.useState(()=>document.createElement("div")),l=React$2.useMemo(()=>client.createRoot(u),[u]),f=t??!0,c=useEvent(()=>{if(f&&a.current){let _=a.current.getAbsoluteTransform().decompose();n&&(_=n(_)),u.style.position="absolute",u.style.zIndex="10",u.style.top="0px",u.style.left="0px",u.style.transform=`translate(${_.x}px, ${_.y}px) rotate(${_.rotation}deg) scaleX(${_.scaleX}) scaleY(${_.scaleY})`,u.style.transformOrigin="top left"}else u.style.position="",u.style.zIndex="",u.style.top="",u.style.left="",u.style.transform="",u.style.transformOrigin="";const h=r||{},{style:y}=h,E=__rest(h,["style"]);Object.assign(u.style,y),Object.assign(u,E)});return React$2.useLayoutEffect(()=>{var h;const y=a.current;if(!y)return;const E=(h=y.getStage())===null||h===void 0?void 0:h.container();if(E)return E.appendChild(u),f&&needForceStyle(E)&&(E.style.position="relative"),y.on("absoluteTransformChange",c),c(),()=>{var p;y.off("absoluteTransformChange",c),(p=u.parentNode)===null||p===void 0||p.removeChild(u)}},[f]),React$2.useLayoutEffect(()=>{c()},[r,n]),React$2.useLayoutEffect(()=>{l.render(o)}),React$2.useLayoutEffect(()=>()=>{setTimeout(()=>{l.unmount()})},[]),React$2.createElement(Group,Object.assign({ref:a},e))};function Area({area:o,finished:e,isClicked:r,isBad:t,hasHighlights:n,completed:a,onClick:u,onClickOutside:l}){const f=React$2.useRef(),[c,h]=React$2.useState(),y=t?"rgba(255, 99, 77, 0.32)":"rgba(75, 215, 169, 0.32)",E=t?"#ff634d":"#4bd7a9",p=DeviceDetection(),_=()=>{var S,A,T;n&&!a&&!r&&((S=f.current)==null||S.setAttr("fill","rgba(130, 134, 142, 0.4)"),(A=f.current)==null||A.setAttr("stroke","rgba(255, 255, 255, 0.3)"),(T=f.current)==null||T.to({duration:.25,opacity:1}))},g=()=>{var S;n&&!a&&!r&&((S=f.current)==null||S.to({duration:.25,opacity:0}))};React$2.useEffect(()=>{var S,A,T;a&&!e&&(t?(T=f.current)==null||T.to({duration:.25,opacity:0}):((S=f.current)==null||S.to({duration:.25,opacity:1}),(A=f.current)==null||A.globalCompositeOperation("destination-out")))},[a,e,t]);const x=()=>{var S,A;a||(t?l(o):u(o),(S=f.current)==null||S.setAttr("fill",y),(A=f.current)==null||A.setAttr("stroke",E))},C=o.scaleX?o.scaleX:1,R=o.scaleY?o.scaleY:1;return React$2.useLayoutEffect(()=>{const S=f.current.getStage();S.on("stage-loaded",()=>{const A=f.current.getClientRect({relativeTo:f.current.getParent()});h({x:A.x+A.width/2,y:A.y+A.height/2}),S.batchDraw()})},[o]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[c?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...c},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:o.id})}):null,jsxRuntimeExports.jsx(Line,{name:o.id,ref:f,onFocus:()=>_(),onMouseOver:()=>_(),onMouseLeave:g,onClick:()=>x(),onTap:()=>x(),x:o.x,y:o.y,scale:{x:C,y:R},skew:{x:o.skewX,y:o.skewY},rotation:o.rotation,points:o.points,shape:"poly",fill:e?"":y,stroke:e||r?E:"",strokeWidth:p?10:4,opacity:e||r?1:0,closed:!0})]})}Area.defaultProps={finished:!1,isBad:!1,isClicked:!1,hasHighlights:!1,completed:!1,onClick:()=>{},onClickOutside:()=>{}};const useWindowSize=()=>{const[o,e]=React$2.useState([0,0]);return React$2.useLayoutEffect(()=>{function r(){e([window.innerWidth,window.innerHeight])}return window.addEventListener("resize",r),r(),()=>window.removeEventListener("resize",r)},[]),o};function KonvaMapper({areas:o,badAreas:e,imageUrl:r,completed:t,onClick:n,onClickOutside:a,hasHighlights:u,clickedZones:l}){const f=React$2.useRef(),c=React$2.useRef(),h=React$2.useRef(),y=React$2.useRef(),E=React$2.useRef(),p=React$2.useRef(),_=React$2.useRef(),[g,x]=React$2.useState(new window.Image),[C,R]=useWindowSize(),S=e.find(w=>w.id==="AllArea")||!1,A=e.filter(w=>w.id!=="AllArea");React$2.useEffect(()=>{_.current&&c.current&&t&&(_.current.to({duration:.25,opacity:.5}),c.current.setAttr("visible",!0))},[t]);const T=w=>{S&&!w.target.attrs.shape&&a(S)};return React$2.useEffect(()=>{g.src=r,g.addEventListener("load",()=>{if(f.current){const w={x:C/2,y:R/2,width:g.width,height:g.height,offsetX:g.width/2,offsetY:g.height/2,scale:{x:Math.min(C/g.width,R/g.height),y:Math.min(C/g.width,R/g.height)}};y.current&&y.current.setAttrs(w),E.current&&E.current.setAttrs(w),c.current&&c.current.setAttrs(w),h.current&&h.current.setAttrs(w),p.current&&p.current.setAttrs(w),f.current.batchDraw(),x(g),f.current.fire("stage-loaded")}})},[g,R,r,C]),jsxRuntimeExports.jsxs(Stage,{ref:f,width:C,height:R,onClick:T,onTouchEnd:T,children:[jsxRuntimeExports.jsx(Layer,{children:jsxRuntimeExports.jsx(Image$2,{ref:p,image:g})}),jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Rect,{ref:_,width:C,height:R,fill:"black",opacity:0}),jsxRuntimeExports.jsx(Group,{ref:E,children:A.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:u,completed:t,onClick:n,onClickOutside:a,area:w,isBad:!0},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:y,children:o.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:u,completed:t,onClick:n,onClickOutside:a,area:w,isClicked:l.some(O=>O.index===w.index)},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:h,visible:!1,children:A.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:u,completed:t,onClick:n,onClickOutside:a,area:w,isBad:!0,finished:!0},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:c,visible:!1,children:o.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:u,completed:t,onClick:n,onClickOutside:a,area:w,finished:!0},w.name+"_"+P))})]})]})}KonvaMapper.defaultProps={hasHighlights:!1,onClick:()=>{},completed:!1,onClickOutside:()=>{}};function TimerDialog({retry:o,translate:e,onInit:r}){return jsxRuntimeExports.jsx("div",{className:"timer-dialog",children:jsxRuntimeExports.jsxs("div",{className:"timer-dialog__container",children:[jsxRuntimeExports.jsx("div",{className:"timer-dialog__title",children:e("storylines.misc.ready")}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:r,children:jsxRuntimeExports.jsx("span",{children:e(o?"storylines.misc.start":"storylines.misc.retry")})})]})})}function CountDown({time:o}){const e=Math.floor(o/60),r=o%60;return jsxRuntimeExports.jsx("div",{className:`count-down count-down--in-puzzle-frame ${o<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{children:[e<10?`0${e}`:e," : ",r<10?`0${Math.floor(r)}`:Math.floor(r)]})})}const defaultImg="https://min.gamelearn.io/css-resources/gamelearn/resources/puzzle-login-low.png";function ImageReview(){return jsxRuntimeExports.jsx("div",{className:"puzzle--image__preview",children:jsxRuntimeExports.jsx("img",{alt:"img",src:"https://min.gamelearn.io/css-resources/gamelearn/resources/image-click.jpg"})})}function ImageClickWrapperComponent(o){var ye,Oe;const{soundActions:e,emitEvent:r,handleClick:t,disableExit:n,setResolveAction:a,info:u,image:l,areas:f,badAreas:c,hasClickOrder:h,timer:y,hasClickOnce:E,hasHighlights:p,hasImageReview:_,defaultCompleted:g,className:x,emitFinish:C,emitResolve:R,translateFromParent:S,specificFeedbacks:A,slideNumber:T,emitResetPuzzle:w,firstTryForFrame:P,puzzlesAutoCompleted:O,emitOpenPopupCounterInfo:k,pause:D,keyboardControl:F}=o,[G,V]=React$2.useState([]),[W,Z]=React$2.useState(!1),[q,z]=React$2.useState(!1),[U,I]=React$2.useState({show:!1,success:!1,text:"",rewards:[]}),$=React$2.useRef(!1),[B,X]=React$2.useState(!0),[Q,J]=React$2.useState(!1),ne=React$2.useRef(null),se=React$2.useRef(null),ee=React$2.useRef(null),ie=React$2.useRef(null),oe=React$2.useRef(null),fe=React$2.useRef(null),de=React$2.useRef(null),ce=React$2.useRef(null),Se=React$2.useRef(null),[ke,Ne]=React$2.useState(y),We=Ge=>S?S(Ge):r({type:"translate",payload:Ge}),[Ke]=e,{solution:Qe}=u,pt=l.img.url||defaultImg,vt=f.map((Ge,nt)=>({index:nt,shape:"poly",...Ge})),ct=c.map((Ge,nt)=>({index:nt,shape:"poly",...Ge})),mt=React$2.useCallback(()=>{if(!B){const Ge=setInterval(()=>{Ne(nt=>nt>1?nt-1:0)},1e3);Se.current=Ge}},[B]),Vt=React$2.useCallback((Ge,nt)=>{C?C(Ge,nt):r({type:"addPoints",payload:Ge})},[r,C]);React$2.useEffect(()=>{W&&n(!0)},[W,n]),React$2.useEffect(()=>{Z(g)},[g]);const kt=React$2.useCallback(()=>{clearInterval(ee.current)},[]),Ie=React$2.useCallback(()=>{clearInterval(Se.current)},[]),et=React$2.useCallback(Ge=>{oe.current=Date.now(),ie.current?(de.current=ie.current-oe.current,kt()):(de.current=oe.current-(oe.current-Ge*1e3),kt())},[kt]),at=React$2.useCallback(()=>{I(()=>{var Ge,nt;return{show:!0,success:!1,text:(Ge=u==null?void 0:u.timerFeedback)!=null&&Ge.desc?u.timerFeedback.desc:"",rewards:(nt=u==null?void 0:u.timerFeedback)==null?void 0:nt.rewards}}),J(!0),Ie(),kt()},[Ie,kt,(ye=u.timerFeedback)==null?void 0:ye.desc,(Oe=u.timerFeedback)==null?void 0:Oe.rewards]),Kt=React$2.useCallback(()=>{clearInterval(ee.current),ee.current=setInterval(()=>{se.current=Date.now(),se.current>ie.current&&at()},250)},[at]);React$2.useEffect(()=>{var Ge;if((f.length===G.length||E&&G.length>0)&&!W){Z(!0);const nt=G[G.length-1],je=A==null?void 0:A.correctFeedbacks.find(Ee=>Ee.id===nt.id);(!((Ge=A==null?void 0:A.correctFeedbacks)!=null&&Ge.length)||A!=null&&A.correctFeedbacks.some(Ee=>!Ee.desc)||E)&&(I(Ee=>({...Ee,show:!0,success:!0,text:je?je.desc:u.solution.right.desc,rewards:je?je.rewards:u.solution.right.rewards})),y&&(Ie(),et()))}},[G,f.length,A,E,W,u.solution.right,et,y,Ie]),React$2.useEffect(()=>{a(Ge=>{y&&(Ie(),X(!1),U.show?I(nt=>({...nt,show:!1,success:!1,text:"",rewards:[]})):kt()),Z(!0),z(!0),setTimeout(()=>{R?R(Ge):Ge()},4e3)})},[a,R,Ke,y,U.show,kt,Ie]),React$2.useEffect(()=>{q&&n(!0)},[q,n]);const Xe=(Ge,nt=!1)=>{var je,Ee;if(!W){const{rewards:Be,desc:qe}=Qe.wrong;let He=qe,ht=Be;const $t=(je=A==null?void 0:A.wrongFeedbacks)==null?void 0:je.find(Lt=>Lt.id===Ge.id);$t&&(He=$t.desc,ht=$t.rewards),h&&(V([]),nt&&(Ee=u==null?void 0:u.orderFeedback)!=null&&Ee.desc&&(He=u.orderFeedback.desc,ht=u.orderFeedback.rewards)),y&&(Ie(),et()),I(Lt=>({...Lt,show:!0,success:!1,text:He,rewards:ht})),Ke("fail")}},it=React$2.useCallback(()=>{fe.current=Date.now();const Ge=fe.current+de.current;se.current=null,ie.current=Ge,(y||Q)&&(U.success?f.length===G.length||E&&G.length>0?Ie():(Ne(de.current*.001),mt(),Kt()):(V([]),X(!0),w())),Vt(U.rewards,U.success),Ke("click-ui"),I(nt=>({...nt,show:!1,success:!1,text:"",rewards:[]}))},[y,Q,Vt,U.rewards,U.success,Ke,f.length,G.length,E,w,Ie,mt,Kt]),pe=Ge=>{var nt,je;if(!G.some(Ee=>Ee.index===Ge.index)&&!U.show&&!W){Ke("click-ui");let Ee=Qe.right.desc,{rewards:Be}=Qe.right;const qe=[...G,Ge];if(h&&Ge.index===G.length||!h){if(y&&et(ke),t(),(nt=A==null?void 0:A.correctFeedbacks)!=null&&nt.length){const He=(je=A.correctFeedbacks)==null?void 0:je.find(ht=>ht.id===Ge.id);He&&(Ee=He.desc,Be=He.rewards),!Ee&&f.length>qe.length&&!E?Vt(Be,!0):Ee&&!E&&(I(ht=>({...ht,show:!0,success:!0,text:Ee,rewards:Be})),y&&Ie())}V(qe)}else Xe(Ge,!0)}},ge=React$2.useCallback(()=>{Ie(),Ne(y),mt(),!$.current&&P&&k(),X(!1),ne.current=Date.now(),ie.current=ne.current+y*1e3,Kt()},[Ie,y,mt,P,Kt,k]);return React$2.useEffect(()=>{y&&T>0&&!ce.current&&(P&&Object.keys(O).length&&O[T-1]?(X(!0),ce.current=!0):X(!1))},[g,P,O,T,y]),React$2.useEffect(()=>{y&&ke===0&&at()},[ke,at,y]),React$2.useEffect(()=>{y&&(D?(Ie(),et()):mt())},[Ie,Kt,D,et,mt,y]),jsxRuntimeExports.jsxs("div",{className:x,children:[U.show?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:Ke,text:U.text,success:U.success,translate:We,hasTimeout:!U.text,delay:y?1e3:2e3,functionOnClose:it,timeExpired:Q,keyboardControl:F}):null,jsxRuntimeExports.jsx(KonvaMapper,{completed:W,imageUrl:pt,areas:E&&G.length?[G[0]]:vt,badAreas:ct,clickedZones:G,onClick:pe,onClickOutside:Xe,hasHighlights:p,emitEvent:r}),_?jsxRuntimeExports.jsx(ImageReview,{}):null,y&&B?jsxRuntimeExports.jsx(TimerDialog,{retry:P||O[T-1],translate:We,onInit:ge}):null,y?jsxRuntimeExports.jsx(CountDown,{time:ke}):null]})}ImageClickWrapperComponent.defaultProps={info:{instructions:"",resolve:{},solution:{},hint:{},title:""},badAreas:[],className:"puzzle--image__click",hasClickOrder:!1,hasClickOnce:!1,hasHighlights:!1,hasImageReview:!1,defaultCompleted:!1,hideContinue:!1,emitAreaClick:()=>{},handleClick:()=>{}};function ImageClickPuzzleComponent(o){const e=(r,t)=>{t?(o.emitEvent({type:"addPoints",complex:!0,finish:!0,payload:r}),o.emitEvent({type:"passPuzzle"})):(o.emitEvent({type:"addPoints",payload:r,finish:!1}),o.emitEvent({type:"failPuzzle"}))};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...o,emitFinish:e,name:"image-click-puzzle"})}const GREEN="#44d7ab",ORANGE="#FFB34B",RED="#FF634D",getDistance=(o,e)=>Math.max(Math.abs(o[0]-e[0]),Math.abs(o[1]-e[1])),generatePasswordPositions=(o,e,r,t)=>{const n=[],a=o;for(const u of e.toLowerCase()){const l=Math.floor(Math.random()*r),f=Math.floor(Math.random()*t);a[l][f].value=u,n.push({char:u,position:[l,f]})}return[a,n]},paintedGridPassword=(o,e,r,t)=>{const n=o;for(let a=0;a<e;a+=1)for(let u=0;u<r;u+=1)switch(t.reduce((f,c)=>{const h=[a,u],y=getDistance(c.position,h);return y<f?y:f},9999)){case 0:n[a][u].hiddenColor=GREEN;break;case 1:n[a][u].hiddenColor=ORANGE;break;case 2:n[a][u].hiddenColor=RED;break}return n},resetColors=(o,e,r)=>{const t=r;for(let n=0;n<o;n+=1)for(let a=0;a<e;a+=1)t[n][a].color="",t[n][a].hiddenColor=RED;return t},repaintGridPassword=(o,e,r,t)=>{const n=resetColors(r,t,o),[a,u]=generatePasswordPositions(n,e,r,t);return paintedGridPassword(a,r,t,u)},prepareAcceptedChars=(o,e)=>e.split("").filter(r=>!o.includes(r)).join(""),generateBasicGrid=(o,e,r)=>{const t=[];for(let n=0;n<o;n+=1){const a=[];for(let u=0;u<e;u+=1){const l={color:"",hiddenColor:RED,value:r[Math.floor(Math.random()*r.length)]};a.push(l)}t.push(a)}return t},makeSomeNoise=({numberOfColumns:o,numberOfRows:e,password:r})=>{const t=LangIsRtl()?"٠١٢٣٤٥٦٧٨٩شزذيثبلاهتنمورخحضقسفعدصطغظ":"0123456789abcdefghijklmnopqrstuvwxyz",n=prepareAcceptedChars(r,t),a=generateBasicGrid(e,o,n),[u,l]=generatePasswordPositions(a,r,e,o);return paintedGridPassword(u,e,o,l)};function DrawItem({item:o,rowIndex:e,columnIndex:r,setCursorPosition:t,cursorPosition:n}){const a=Math.abs(e-n[0])<3&&Math.abs(r-n[1])<3;return jsxRuntimeExports.jsx("span",{className:"puzzle--cracker__item",style:{backgroundColor:`${a?o.hiddenColor:o.color}`,flexGrow:1,textAlign:"center"},onMouseOver:()=>{t([e,r])},onFocus:()=>{t([e,r])},children:o.value})}DrawItem.defaultProps={setCursorPosition:()=>{}};DrawItem.propTypes={item:PropTypes.shape({color:PropTypes.string,hiddenColor:PropTypes.string,value:PropTypes.string}).isRequired,rowIndex:PropTypes.number.isRequired,columnIndex:PropTypes.number.isRequired,cursorPosition:PropTypes.arrayOf(PropTypes.number).isRequired,setCursorPosition:PropTypes.func};function DrawRow({row:o,rowIndex:e,setCursorPosition:r,cursorPosition:t}){return o.length?jsxRuntimeExports.jsx("div",{className:"puzzle--cracker",children:o.map((n,a)=>jsxRuntimeExports.jsx(DrawItem,{item:n,rowIndex:e,columnIndex:a,setCursorPosition:r,cursorPosition:t},a))}):null}DrawRow.defaultProps={row:[]};DrawRow.propTypes={row:PropTypes.arrayOf(PropTypes.shape({})),rowIndex:PropTypes.number.isRequired,setCursorPosition:PropTypes.func.isRequired,cursorPosition:PropTypes.arrayOf(PropTypes.number).isRequired};function DrawGrid({grid:o,cursorPosition:e,setCursorPosition:r}){return jsxRuntimeExports.jsx("div",{className:"puzzle--cracker__canvas",children:o.map((t,n)=>jsxRuntimeExports.jsx(DrawRow,{row:t,rowIndex:n,cursorPosition:e,setCursorPosition:r},n))})}DrawGrid.defaultProps={setCursorPosition:()=>{}};const VELOCITY_MAP={slow:2,fast:5,fastest:10},DIFFICULTY_MAP={easy:{visibleRows:"auto",visibleColumns:40,totalRows:25},medium:{visibleRows:"auto",visibleColumns:40,totalRows:40},hard:{visibleRows:"auto",visibleColumns:40,totalRows:80}};function CrackerPuzzleComponent({emitEvent:o,soundActions:e,info:r,velocity:t,password:n,disableExit:a,difficulty:u,setResolveAction:l}){const[f]=e,c=X=>o({type:"translate",payload:X}),h=React$2.useRef(),y=React$2.useRef(),{solution:E}=r,[p,_]=React$2.useState(n.toLowerCase()),[g,x]=React$2.useState(),[C,R]=React$2.useState(Array(n.toLowerCase().length).fill("")),[S,A]=React$2.useState(!1),[T,w]=React$2.useState([0,0]),P=c("puzzle.cracker.crackedPassword"),O=r.solution.right.desc&&r.solution.right.desc!==""?r.solution.right.desc:"",k=c("puzzle.cracker.congratulations"),[D,F]=React$2.useState([[]]),{visibleRows:G,visibleColumns:V}=DIFFICULTY_MAP[u];let W=G==="auto"?Math.ceil(window.innerHeight*.025):G;W=W>=20?W:20,React$2.useEffect(()=>{S&&a(!0)},[S,a]),React$2.useEffect(()=>{l(X=>{f("score"),A(!0),setTimeout(()=>{o({type:"hidePuzzleButtons",payload:!1}),X()},0)})},[l,f]);const Z=()=>{f("click-ui");const{rewards:X}=E.right;o({type:"addPoints",complex:!0,finish:!0,payload:X}),o({type:"passPuzzle"})},q=()=>n.toLowerCase().split("").map((Q,J)=>({char:Q,index:J,used:!1})),z=X=>X.filter(Q=>Q.used===!1).map(Q=>Q.char).join(""),U=X=>{if(X[0].length>0&&!S){const Q=[...X];return Q.push(Q.shift()),Q}return X};let I=0;const $=X=>{if(y.current!==void 0){const Q=X-y.current;I+=Q,I>1e3/VELOCITY_MAP[t]&&(F(U),I=0)}y.current=X,h.current=requestAnimationFrame($)};React$2.useEffect(()=>{_(n.toLowerCase());const X=makeSomeNoise({numberOfColumns:V,numberOfRows:W,password:n.toLowerCase()});return F(X),x(q()),h.current=requestAnimationFrame($),()=>cancelAnimationFrame(h.current)},[]);const B=()=>{if(D.length<=1)return;const[X,Q]=T,J=D[X][Q];if(J.hiddenColor===GREEN){const ne=g.filter(se=>se.char===J.value.toLowerCase()&&se.used===!1)[0];if(ne){const{index:se}=ne;f("score");const ee=g;ee[se].used=!0,x(ee);const ie=[...C];ie[se]=J.value;const oe=z(ee);_(oe);const fe=repaintGridPassword(D,oe,W,V);F(fe),R(ie)}}p<=0&&(f("score"),A(!0))};return React$2.useEffect(()=>{S||B()},[T]),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:C.map((X,Q)=>jsxRuntimeExports.jsx("span",{className:"puzzle--pieces__item",children:X&&jsxRuntimeExports.jsx("span",{className:"character success-transition-animation","data-testid":`solution${Q}`,children:X})},`${X+Q}`))})]}),jsxRuntimeExports.jsx(DrawGrid,{grid:S?[[]]:D,cursorPosition:T,setCursorPosition:w}),S&&P&&k&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs(Typist,{avgTypingDelay:110,cursor:{hideWhenDone:!0},className:"puzzle--cracker__result",children:[jsxRuntimeExports.jsx(Typist.Delay,{ms:300}),jsxRuntimeExports.jsxs("span",{children:[`${P} ${n.toLowerCase()}`," "]}),jsxRuntimeExports.jsxs("span",{children:[k," "]}),O!==""&&jsxRuntimeExports.jsx("span",{children:O})]}),jsxRuntimeExports.jsx("div",{className:"position--absolute bottom center",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary gat--btn__cracker",onClick:Z,children:c("screens.continue")})})]})]})}CrackerPuzzleComponent.defaultProps={velocity:"slow",difficulty:"easy",context:{},info:{}};const ARABIC=/[\u0600-\u06FF]/,restrictCharacters=(o,e)=>{let r=!1;return e==="or"&&(r=o===""||o===" "||o===","||o==="."||o==="/"),e==="and"&&(r=o&&o!==" "&&o!==","&&o!=="."&&o!==""&&o!=="/"),r},sortChar=(o,e)=>o.char>e.char?1:o.char<e.char?-1:0,analyzeChars=o=>{const e={anyArabic:!1,anyNumber:!1,anyWestern:!1};for(let r=0;r<o.length;r+=1){const t=o[r].charCodeAt(0);t>=65&&t<=90?e.anyWestern=!0:t>=48&&t<=57?e.anyNumber=!0:ARABIC.test(o[r])&&(e.anyArabic=!0)}return e},makeChar=o=>{const e="شزذيثبلاهتنمورخحضثقسفعدصطغظ",r="ABCDEFGHIJKLMNOPQRSTUVWXYZ",t="0123456789";let n="";return o.anyWestern&&(n+=r),o.anyNumber&&(n+=t),o.anyArabic&&(n+=e),n.charAt(Math.floor(Math.random()*n.length))},MAX_POOL_LETTERS=26,MAX_EXTRA_LETTERS=8,AnswerPanel=({answer:o,flickerPosition:e,show:r=!1,showCorrectSolution:t})=>{const n=[];let a=0;return o.forEach(u=>{n[a]||(n[a]=[]),n[a]=[...n[a],u],u.char===" "&&(a+=1),t||(u.positionInitial=u.index)}),n.map((u,l)=>jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__word","data-testid":`result-${l}`,children:r?u.map((f,c)=>jsxRuntimeExports.jsx("span",{className:"puzzle--hanged__letter active",children:f},`${f+c}`)):u.filter(({char:f})=>f!==" ").map(({char:f,fixed:c},h)=>jsxRuntimeExports.jsx("span",{className:`puzzle--hanged__letter ${c?"":"active"} ${u[h].positionInitial===e?"fakeFocus":""}`,children:f},`${f+h}`))},`${u+l}`))},defaultImage="https://min.gamelearn.io/css-resources/gamelearn/resources/partenon.jpg";function HangedPuzzleComponent({soundActions:o,emitEvent:e,disableExit:r,question:t,image:n,info:a,answer:u,hintUsed:l,setResolveAction:f,setHintAction:c,keyboardControl:h}){var fe;const[y]=o,E=((fe=n.img)==null?void 0:fe.url)||defaultImage,[p,_]=React$2.useState(0),[g,x]=React$2.useState(!1),[C,R]=React$2.useState([]),[S,A]=React$2.useState(!1),[T,w]=React$2.useState([]),[P,O]=React$2.useState(""),[k,D]=React$2.useState(!1),[F,G]=React$2.useState([]),[V,W]=React$2.useState(!1),Z=u.toUpperCase().split(""),q=Z.filter(de=>restrictCharacters(de,"and")),z=de=>e({type:"translate",payload:de}),U=React$2.useCallback(()=>{const de=q.map(ke=>({char:ke}));let ce=[];const Se=analyzeChars(q);for(;ce.length<MAX_EXTRA_LETTERS;){const ke=makeChar(Se);ce=[...ce,{char:ke}]}return[...de,...ce]},[q]),I=u.toUpperCase().split("").map((de,ce)=>restrictCharacters(de,"or")?{index:ce,letter:de,char:de,fixed:!0}:{index:ce,letter:de,char:""}),$=React$2.useCallback(()=>{let de=U();for(;de.length>MAX_POOL_LETTERS;){const ce=Math.trunc(Math.random()*(de.length-1))+1,Se=de[ce],ke=I.find((Ne,We)=>Se.char===Ne.letter&&!I[We].fixed);ke&&(de.splice(ce,1),I[ke.index]={...ke,char:ke.letter,fixed:!0})}l&&(de=[],I.forEach(({letter:ce})=>{ce!==" "&&de.push({char:ce})})),w(I),R(de)},[I,l,U]),B=(de,ce)=>C.map((ke,Ne)=>Ne===ce?{...ke,deleted:!0}:{...ke}),X=(de,ce,Se)=>{const ke=ce.map((We,Ke)=>Se.find(pt=>pt.poolIndex===Ke)?{char:We.char}:We);R(ke),w(de);const Ne=de.find(We=>We.char==="");_(Ne.index)},Q=(de,ce)=>{y("click-ui");let Se=!1;const ke=T.map(Ke=>!Ke.char&&!Se?(Se=!0,{...Ke,char:de,poolIndex:ce}):Ke),Ne=B(de,ce),We=ke.filter(Ke=>Ke.char).length;R(Ne),w(ke),J(),We===T.length&&ie(ke,Ne)},J=()=>{var de;if(g){const ce=T.find(Se=>Se.index!==p&&Se.letter!==" "&&Se.char===""&&Se.poolIndex===!1);ce&&_(ce.index)}else{const ce=T.find(Se=>Se.char==="");_(ce.index+1),((de=T[ce.index+1])==null?void 0:de.letter)===" "&&_(ce.index+2)}},ne=()=>{y("click-ui");const de=T.map((ce,Se)=>T[T.length-1-Se]).find(ce=>ce.char&&!ce.fixed);if(de){const ce=T.map(Ne=>Ne.index===de.index?{...de,char:""}:Ne);let Se=!1;const ke=C.map((Ne,We)=>We===de.poolIndex&&(Ne.deleted||!Se)?(Se=!0,{char:Ne.char}):Ne);R(ke),w(ce),_(de.index)}},se=()=>{r(!0),O("");const de=[...F,...a.solution.right.rewards];y("score"),e({type:"hidePuzzleButtons",payload:!1}),e({type:"addPoints",complex:!0,finish:!0,payload:de}),e({type:"passPuzzle"})},ee=()=>{y("fail"),e({type:"hidePuzzleButtons",payload:!1}),G([...F,...a.solution.wrong.rewards]),O(""),D(!1),e({type:"failPuzzle"}),x(!0)},ie=(de,ce)=>{let Se=[];D(!0);const ke=de.map((We,Ke)=>Z[Ke]===We.char?{...We,fixed:!0}:(Se=[...Se,We],{...We,poolIndex:!1,char:""})),Ne=ke.filter(We=>We.fixed).length;e({type:"hidePuzzleButtons",payload:!0}),Ne===Z.length?(O("success"),a.solution.right.desc===""&&setTimeout(()=>{se()},2e3)):(O("failed"),X(ke,ce,Se),a.solution.wrong.desc===""&&setTimeout(()=>{ee()},2e3))},oe=()=>{if(P==="success")se();else{ee();const de=T.find(ce=>ce.char==="");_(de.index)}};return React$2.useEffect(()=>{S||(A(!0),$()),f(de=>{W(!0),setTimeout(()=>{e({type:"hidePuzzleButtons",payload:!1}),de()},2e3)}),c(de=>{const ce=[];I.forEach(({letter:Se})=>{Se!==" "&&ce.push({char:Se})}),R(ce),de()})},[$,S,u,f,e,F,a.resolve.rewards,I,c]),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged",style:{backgroundImage:`url("${E}")`},children:[P?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:y,text:a.solution[P==="success"?"right":"wrong"].desc,success:P==="success",translate:z,functionOnClose:oe,keyboardControl:h}):null,jsxRuntimeExports.jsx("div",{className:"puzzle--hanged__content",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__controls",children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__header",children:t}),jsxRuntimeExports.jsx("div",{dir:"auto",className:`puzzle--hanged__solution ${P}`,"data-testid":`${P}`,children:V?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:V,answer:u.split(""),show:!0})}):jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:V,flickerPosition:p,answer:T})}),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__keyboard",children:[C.sort((de,ce)=>sortChar(de,ce)).map((de,ce)=>jsxRuntimeExports.jsx("button",{"data-testid":`key-${de.char}`,type:"button",onClick:()=>{!de.deleted&&!P&&!k&&(Q(de.char,ce),y("click-ui"))},className:`puzzle--hanged__keyboard--item ${de.deleted||k?"disabled":""}`,children:de.char},`${de+ce}`)),jsxRuntimeExports.jsx("button",{onClick:k?null:()=>ne(),type:"button",disabled:k?"disabled":null,"aria-label":z("puzzles.hanged-puzzle.deleteButton"),className:`puzzle--hanged__keyboard--item delete ${k?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:"icon-delete-keyboard"})})]})]})})]})}HangedPuzzleComponent.defaultProps={question:"",answer:"",image:{},hintBought:!1,info:{description:"",instructions:"",resolve:{},solution:{},hintBought:{}}};function CurrentImageClickPuzzle({list:o,description:e,nodeId:r,setInfo:t,emitEvent:n,disableExit:a,setResolveAction:u,soundActions:l,setSelected:f,selected:c,pause:h,loadPuzzleStatus:y,index:E,setIndex:p,slidesCompleted:_,setSlidesCompleted:g,keyboardControl:x,totalCorrects:C}){const R=React$2.useRef([]),S=React$2.useRef(0),A=React$2.useRef(0),T=`chained-image-click-puzzle_${E}_${r}`,[w]=l,P=Z=>{R.current=[...R.current,...Z]},O=React$2.useCallback(Z=>{w("score"),n({type:"hidePuzzleButtons",payload:!1}),n({type:"addPoints",complex:!0,finish:!0,payload:[...R.current,...Z]}),n({type:"passPuzzle"})},[w,n]),k=o[E],{info:D,specificFeedbacks:F}=k;D.description=e,React$2.useEffect(()=>{S.current=0,A.current=0},[E]);const G=React$2.useCallback((Z,q=!1)=>{var U;let z={..._};if(q){if((U=F==null?void 0:F.correctFeedbacks)!=null&&U.length&&!k.hasClickOnce)S.current+=1;else{let I=c;A.current&&(I-=A.current),S.current=k.areas.length,f(I+S.current)}S.current===k.areas.length&&(E+1>=o.length?O(Z):p(E+1),z={...z,[E]:!0},g(z)),P(Z)}else n({type:"addPoints",payload:Z,finish:!1}),n({type:"failPuzzle"}),k.hasClickOrder&&(f(c-S.current),S.current===0&&Object.entries(_).length===0?f(0):S.current=0),Object.entries(_).length===0&&k.hasClickOrder&&!c&&f(0)},[_,F,k.hasClickOnce,k.areas.length,k.hasClickOrder,c,f,E,o.length,g,O,p,n]),V=()=>{E>=o.length-1&&f(C),w("score"),n({type:"puzzleAction",action:"resolve",payload:{element:T,rewards:D.resolve.rewards,finish:E+1>=o.length}})};React$2.useEffect(()=>{t({...D,hintId:T})},[D,T,t]),React$2.useEffect(()=>{y&&E!==o.length-1&&G([],!0)},[E,o.length,y,G]);const W=()=>{const Z=k.hasClickOnce?k.areas.length:1;A.current+=Z,f(c+Z)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...k,puzzle:{name:T,component:"chained-image-click-puzzle"},specificFeedbacks:F,emitFinish:G,emitError:P,emitResolve:V,isLast:E+1===o.length,defaultCompleted:_[E]||!!y,hideContinue:E+1!==o.length,handleClick:W,emitEvent:n,disableExit:a,soundActions:l,setResolveAction:u,pause:h,keyboardControl:x},E)}function ChainedImageClickPuzzleComponent(o){const{setInfo:e,emitEvent:r,nodeId:t,list:n,description:a,soundActions:u,showFrames:l,disableExit:f,setResolveAction:c,keyboardControl:h}=o,[y,E]=React$2.useState(0),[p,_]=React$2.useState(0),[g,x]=React$2.useState({}),C=`chained-image-click-puzzle_${p}_${t}`,R=React$2.useMemo(()=>r({type:"loadObjectStatus",payload:C}),[r,C]),S=n.reduce((T,w)=>T+w.areas.length,0),A={list:n,description:a,nodeId:t,disableExit:f,setResolveAction:c,emitEvent:r,soundActions:u,setInfo:e,setSelected:E,selected:y,index:p,setIndex:_,slidesCompleted:g,setSlidesCompleted:x,loadPuzzleStatus:R,keyboardControl:h,totalCorrects:S};return jsxRuntimeExports.jsxs("div",{className:"puzzle--image__click",children:[l?jsxRuntimeExports.jsxs("div",{className:"puzzle-image__info",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[y," / ",S]})]}):null,jsxRuntimeExports.jsx(CurrentImageClickPuzzle,{...A})]})}function CurrentFramePuzzle({list:o,index:e,puzzlesCompiledRef:r,framesCompleted:t,handleFinish:n,setRewards:a,setIndex:u,setFramesCompleted:l,loadPuzzleStatus:f,soundActions:c,setResolveAction:h,disableExit:y,description:E,translateFromParent:p,setInfo:_,emitEvent:g,nodeId:x,setSelected:C,selected:R,emitResetPuzzle:S,firstTryForFrame:A,setPuzzlesAutoCompleted:T,puzzlesAutoCompleted:w,emitOpenPopupCounterInfo:P,resetValues:O,setResetValues:k,pause:D,keyboardControl:F,totalCorrects:G}){var J;const[V]=c,W=o[e],{info:Z,specificFeedbacks:q}=W;Z.description=E;const z=React$2.useRef(0),U=React$2.useRef(0),I=`frame-image-click-puzzle_${e}_${x}`;React$2.useEffect(()=>{r.current+=1},[r]),React$2.useEffect(()=>{_({...Z,hintId:I})},[_,Z,I]),React$2.useEffect(()=>{O&&(U.current=0,z.current=0,C(0),k(!1))},[O,k,C]),React$2.useEffect(()=>{U.current=0,z.current=0},[e]);const $=React$2.useCallback((ne,se=!1)=>{var ie;let ee={...t};if(se){if((ie=q==null?void 0:q.correctFeedbacks)!=null&&ie.length&&!W.hasClickOnce)U.current+=1;else{let oe=R;z.current&&(oe-=z.current),U.current=W.areas.length,w[0]&&Object.entries(t).length===0?C(U.current):C(oe+U.current)}U.current===W.areas.length&&(e+1>=o.length&&n(ne),ee={...ee,[e]:!0},l(ee),u(e+1>o.length-1?0:e+1)),a(ne)}else g({type:"addPoints",payload:ne,finish:!1}),g({type:"failPuzzle"}),W.hasClickOrder&&(C(R-U.current),U.current=0)},[t,(J=q==null?void 0:q.correctFeedbacks)==null?void 0:J.length,W.hasClickOnce,W.areas.length,W.hasClickOrder,a,R,w,C,e,o.length,l,u,n,g]),B=React$2.useCallback(()=>{e>=o.length-1&&C(G),V("score"),g({type:"hidePuzzleButtons",payload:!1}),T(ne=>({...ne,[e]:!0})),g({type:"puzzleAction",action:"resolve",payload:{element:I,rewards:Z.resolve.rewards,finish:e+1>=o.length}})},[e,o.length,V,g,T,I,Z.resolve.rewards,C,G]),X=React$2.useCallback(()=>{l({}),U.current=0,z.current=0,S()},[S,l]);React$2.useEffect(()=>{f&&e!==o.length-1&&$([],!0)},[t,e,o.length,f,$]);const Q=()=>{const ne=W.hasClickOnce?W.areas.length:1;z.current+=ne,C(R+ne)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...W,className:"puzzle-frame__canvas",puzzle:{name:"",component:"frame-click-puzzle"},specificFeedbacks:q,emitFinish:$,emitResolve:B,hideContinue:!0,disableInfo:r.current>1,defaultCompleted:t[e]||!!f,soundActions:c,setResolveAction:h,disableExit:y,translateFromParent:p,emitEvent:g,slideNumber:e,handleClick:Q,emitResetPuzzle:X,firstTryForFrame:A,puzzlesAutoCompleted:w,emitOpenPopupCounterInfo:P,pause:D,keyboardControl:F},e)}function Tooltip({emitEvent:o}){const e=r=>o({type:"translate",payload:r});return jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle-frame__info--tooltip",children:e("puzzles.counterTooltip")})}function Counter({current:o,total:e,tooltip:r,emitEvent:t}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[r?jsxRuntimeExports.jsx(Tooltip,{emitEvent:t}):null,jsxRuntimeExports.jsxs("div",{className:"puzzle-frame__info--frames",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[o," / ",e]})]})]})}function FrameImageClickComponent({emitEvent:o,nodeId:e,list:r,description:t,showFrames:n,soundActions:a,disableExit:u,setResolveAction:l,setInfo:f,pause:c,keyboardControl:h}){const[y,E]=React$2.useState({}),p=React$2.useRef([]),[_,g]=React$2.useState(0),[x,C]=React$2.useState({}),[R,S]=React$2.useState(0),A=React$2.useRef(0),[T,w]=React$2.useState(!0),[P,O]=React$2.useState(!0),[k,D]=React$2.useState(!1),F=r.reduce((B,X)=>B+X.areas.length,0),G=B=>{p.current=[...p.current,...B]},V=`frame-image-click-puzzle_${_}_${e}`,W=React$2.useMemo(()=>o({type:"loadObjectStatus",payload:V}),[o,V]),Z=React$2.useCallback(B=>{o({type:"addPoints",complex:!0,finish:!0,payload:[...p.current,...B]}),o({type:"passPuzzle"})},[o]),q=React$2.useCallback(()=>{O(!1),p.current=[],S(0),g(0),C({}),w(!0),D(!0)},[]),z=B=>o({type:"translate",payload:B}),U=()=>{w(!0)},$={firstTryForFrame:P,list:r,description:t,index:_,puzzlesCompiledRef:A,framesCompleted:x,handleFinish:Z,setRewards:G,accRewards:p,setSelected:S,selected:R,setIndex:g,setFramesCompleted:C,loadPuzzleStatus:W,soundActions:a,setResolveAction:l,disableExit:u,translateFromParent:z,setInfo:f,emitEvent:o,nodeId:e,emitResetPuzzle:q,resetValues:k,setResetValues:D,setPuzzlesAutoCompleted:E,puzzlesAutoCompleted:y,emitOpenPopupCounterInfo:()=>{_===0&&w(!1)},pause:c,keyboardControl:h,totalCorrects:F};return jsxRuntimeExports.jsxs("div",{className:"puzzle-frame",children:[jsxRuntimeExports.jsx(CurrentFramePuzzle,{...$}),jsxRuntimeExports.jsxs("div",{className:"puzzle-frame__content",children:[jsxRuntimeExports.jsx("div",{className:"puzzle-frame__controls",children:jsxRuntimeExports.jsx("div",{className:"puzzle-frame__progress",children:jsxRuntimeExports.jsx("div",{style:{width:`${R/F*100}%`},className:"puzzle-frame__progress--handle"})})}),n?jsxRuntimeExports.jsx("button",{disabled:T,"aria-hidden":T,type:"button",className:"puzzle-frame__info",onClick:U,children:jsxRuntimeExports.jsx(Counter,{current:R,total:F,tooltip:!T,emitEvent:o})}):null]})]})}FrameImageClickComponent.defaultProps={description:"",context:{},nodeId:0,showFrames:!1};function EditButton({action:o,className:e}){return jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,"aria-label":`${o} edit button`,onKeyUp:()=>{},className:`puzzle--webBuilder__edit ${e}`,onClick:o,children:jsxRuntimeExports.jsx("span",{className:"icon-fb-edit"})})}EditButton.defaultProps={action:()=>{},className:""};const path="https://min.gamelearn.io/css-resources/gamelearn/resources/",imagesOptions=[{name:"webbuilder.imageOptions.image1",src:"Amor.jpg"},{name:"webbuilder.imageOptions.image2",src:"Bancorp.svg"},{name:"webbuilder.imageOptions.image3",src:"Amanda.jpg"},{name:"webbuilder.imageOptions.image4",src:"keyboard.jpg"},{name:"webbuilder.imageOptions.image5",src:"Melanie.jpg"},{name:"webbuilder.imageOptions.image6",src:"Sharon.jpg"},{name:"webbuilder.imageOptions.image7",src:"Bankex.svg"},{name:"webbuilder.imageOptions.image8",src:"Futbol.jpg"},{name:"webbuilder.imageOptions.image9",src:"GBL.svg"},{name:"webbuilder.imageOptions.image10",src:"Fooder.jpg"},{name:"webbuilder.imageOptions.image11",src:"Corporate.jpg"},{name:"webbuilder.imageOptions.image12",src:"Bank of Zamunda.svg"},{name:"webbuilder.imageOptions.image13",src:"mindfullness.jpg"},{name:"webbuilder.imageOptions.image14",src:"Nature.jpg"},{name:"webbuilder.imageOptions.image15",src:"Shopper.jpg"},{name:"webbuilder.imageOptions.image16",src:"Lab.jpg"}],colorOptions=["#c66a46","#3c9dc0","#6236ff","#21254f"],colorOptions2=["#39b7b9","#25a1d4","#f5a623","#080269"],titleOptions=[{title:"webbuilder.bank.titleOptions.title1.text",desc:"webbuilder.bank.titleOptions.title1.description"},{title:"webbuilder.bank.titleOptions.title2.text",desc:"webbuilder.bank.titleOptions.title2.description"},{title:"webbuilder.bank.titleOptions.title3.text",desc:"webbuilder.bank.titleOptions.title3.description"},{title:"webbuilder.bank.titleOptions.title4.text",desc:"webbuilder.bank.titleOptions.title4.description"},{title:"webbuilder.bank.titleOptions.title5.text",desc:"webbuilder.bank.titleOptions.title5.description"}],bankProps={backgroundImage:imagesOptions[10].src,backgroundLogo:imagesOptions[11].src,backgroundColor:"#21254f",btnColor:"#25a1d4"},BankTemplate={header:{color:bankProps.backgroundColor,logo:bankProps.backgroundLogo},body:{bankTitle:titleOptions[0].title,bankDesc:titleOptions[0].desc,bgImage:bankProps.backgroundImage,btnColor:bankProps.btnColor}};function BankHeader({showingReference:o,usingTemplate:e,openPopup:r,onSave:t,header:n,translate:a}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[o?jsxRuntimeExports.jsx("div",{className:"bank--edit__logo",children:jsxRuntimeExports.jsx("img",{src:path+e.header.logo,alt:"",title:""})}):jsxRuntimeExports.jsxs("div",{className:"bank--edit__logo",children:[n.logo?jsxRuntimeExports.jsx("img",{src:path+n.logo,alt:"",title:""}):jsxRuntimeExports.jsxs("span",{children:[jsxRuntimeExports.jsx("b",{children:a("webbuilder.bank.header.title")}),jsxRuntimeExports.jsx("b",{children:a("webbuilder.bank.header.logo")})]}),jsxRuntimeExports.jsx(EditButton,{action:()=>r("PopupImageComponent",{text:"Documents",images:imagesOptions,onSave:u=>t({logo:u})})})]}),jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsxs("ul",{className:"bank--navigation",children:[jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.account")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.invest")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.loans")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.mortgage")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>r("PopupColorComponent",{colors:colorOptions,onSave:u=>t({color:u})})})]})]})}BankHeader.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},header:{}};BankHeader.propTypes={showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),openPopup:PropTypes.func,onSave:PropTypes.func,header:PropTypes.shape({})};function FacebookHeader({showingReference:o,usingTemplate:e,header:r,translate:t}){const n=o?e.header.userImage:r.userImage,a=o?e.header.username:r.username;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{className:"facebook--header__logo",children:jsxRuntimeExports.jsx("span",{className:"icon-fb-logo"})}),jsxRuntimeExports.jsxs("span",{className:"facebook--header__user",children:[jsxRuntimeExports.jsx("span",{className:"facebook--header__user--circle",style:{backgroundImage:`url(${path+n})`}}),jsxRuntimeExports.jsx("span",{className:"facebook--header__user--text",children:t(a||"webbuilder.facebook.header.userName")})]})]})}FacebookHeader.defaultProps={showingReference:!1,usingTemplate:{},header:{}};function WebBuilderHeader(o){const{isFacebook:e,header:r,showingReference:t,usingTemplate:n}=o,a=t?n.header.color:r.color;return jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__header ${e?"":"bank"}`,style:e?{}:{backgroundColor:`${a}`},children:jsxRuntimeExports.jsx("div",{className:`${e?"facebook":"bank"}--header`,children:e?jsxRuntimeExports.jsx(FacebookHeader,{...o}):jsxRuntimeExports.jsx(BankHeader,{...o})})})}WebBuilderHeader.defaultProps={isFacebook:!1,showingReference:!1,usingTemplate:{},header:{}};WebBuilderHeader.propTypes={isFacebook:PropTypes.bool,showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),header:PropTypes.shape({})};const facebookProps={backgroundImage:imagesOptions[12].src,backgroundUser:imagesOptions[5].src},userOptions=["webbuilder.userOptions.user1","webbuilder.userOptions.user2","webbuilder.userOptions.user3"],workOptions=["webbuilder.workOptions.work1","webbuilder.workOptions.work2","webbuilder.workOptions.work3"],studiesOptions=["webbuilder.studiesOptions.study1","webbuilder.studiesOptions.study2","webbuilder.studiesOptions.study3"],mailOptions=["webbuilder.mailOptions.mail1","webbuilder.mailOptions.mail2","webbuilder.mailOptions.mail3"],homeOptions=["webbuilder.homeOptions.home1","webbuilder.homeOptions.home2","webbuilder.homeOptions.home3"],FacebookTemplate={header:{username:userOptions[1],userImage:facebookProps.backgroundUser,bgImage:facebookProps.backgroundImage},body:{work:workOptions[2],home:homeOptions[1],studies:studiesOptions[0],mail:mailOptions[0]}};function WebBuilderFront({showingReference:o,usingTemplate:e,header:r,onSave:t,translate:n,openPopup:a}){const u=o?e.header.userImage:r.userImage,l=o?e.header.username:r.username,f=o?e.header.bgImage:r.bgImage;return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__front",style:{backgroundImage:`url(${path+f})`},children:[jsxRuntimeExports.jsxs("div",{className:"facebook--user",children:[jsxRuntimeExports.jsx("span",{className:"facebook--user__circle",style:{backgroundImage:`url(${path+u})`},children:o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupImageComponent",{images:imagesOptions,onSave:c=>t({userImage:c})})}})}),jsxRuntimeExports.jsx("span",{className:"facebook--user__text",children:n(l||"webbuilder.facebook.header.userName")}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupTextComponent",{options:userOptions,onSave:c=>t({username:c})})}})]}),o?null:jsxRuntimeExports.jsx(EditButton,{className:"position--absolute right top",action:()=>{a("PopupImageComponent",{images:imagesOptions,onSave:c=>t({bgImage:c})})}})]})}WebBuilderFront.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},header:{}};WebBuilderFront.propTypes={showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),openPopup:PropTypes.func,onSave:PropTypes.func,header:PropTypes.shape({})};function FacebookBody({showingReference:o,usingTemplate:e,body:r,onSave:t,openPopup:n,translate:a}){const u=o?e.body.work:r.work,l=o?e.body.studies:r.studies,f=o?e.body.home:r.home,c=o?e.body.mail:r.mail;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("ul",{className:"facebook--sidebar",dir:"auto",children:[jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${u||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-work"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(u||"webbuilder.facebook.body.work")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:workOptions,onSave:h=>t({work:h})})}})]}),jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${l||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-education"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(l||"webbuilder.facebook.body.studies")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:studiesOptions,onSave:h=>t({studies:h})})}})]}),jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${f||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-home"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(f||"webbuilder.facebook.body.home")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:homeOptions,onSave:h=>t({home:h})})}})]})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--board",children:[jsxRuntimeExports.jsx("div",{className:"facebook--mail__label",children:"E-mail"}),jsxRuntimeExports.jsxs("div",{className:`facebook--mail__box ${c||o?"active":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-mail"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(c||"webbuilder.facebook.body.email")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:mailOptions,onSave:h=>t({mail:h})})}})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs",children:[jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-edit"}),a("webbuilder.facebook.body.editPost")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-photo"}),a("webbuilder.facebook.body.editPhoto")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-video"}),a("webbuilder.facebook.body.liveVideo")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-events"}),a("webbuilder.facebook.body.facebookEvent")]})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--thinking",children:[jsxRuntimeExports.jsxs("div",{className:"facebook--textarea",children:[jsxRuntimeExports.jsx("div",{className:"facebook--textarea__circle"}),jsxRuntimeExports.jsx("div",{className:"facebook--textarea__placeholder",children:a("webbuilder.facebook.body.think")})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--chips",children:[jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.photo")}),jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.label")}),jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.feeling")})]})]})]})]})}FacebookBody.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},body:{}};function BankBody({showingReference:o,usingTemplate:e,body:r,onSave:t,openPopup:n,translate:a}){const u=o?e.body.bgImage:r.bgImage,l=o?e.body.btnColor:r.btnColor,f=a(o?e.body.bankTitle:"webbuilder.bank.body.image.title"),c=a(o?e.body.bankDesc:"webbuilder.bank.body.image.description");return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"bank--image__front",style:{backgroundImage:`url(${path+u})`},children:jsxRuntimeExports.jsxs("div",{className:"bank--image__text",children:[jsxRuntimeExports.jsx("span",{className:"title",children:r.bankTitle&&!o?a(r.bankTitle):f}),jsxRuntimeExports.jsx("span",{children:r.bankDesc&&!o?a(r.bankDesc):c}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:titleOptions,onSave:h=>t({bankTitle:h.title,bankDesc:h.desc})})}}),o?null:jsxRuntimeExports.jsx(EditButton,{className:"position--absolute top right",action:()=>{n("PopupImageComponent",{images:imagesOptions,onSave:h=>t({bgImage:h})})}})]})}),jsxRuntimeExports.jsx("div",{dir:"auto",className:"bank--sidebar",children:jsxRuntimeExports.jsxs("div",{className:"bank--form",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__title",children:a("webbuilder.bank.body.password.title")}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.current")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.new")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.confirm")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"bank--form__btn",style:{backgroundColor:`${l}`},children:a("webbuilder.save")}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupColorComponent",{colors:colorOptions2,onSave:h=>t({btnColor:h})})}})]})]})})]})}function WebBuilderBody(o){const{isFacebook:e}=o;return jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__body ${e?"":"bank"}`,children:e?jsxRuntimeExports.jsx(FacebookBody,{...o}):jsxRuntimeExports.jsx(BankBody,{...o})})}WebBuilderBody.defaultProps={isFacebook:!1};WebBuilderBody.propTypes={isFacebook:PropTypes.bool};function CurrentButton({translate:o,backActive:e,action:r}){return jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__topbar--buttons",children:jsxRuntimeExports.jsx("button",{type:"button",className:"puzzle--webBuilder__topbar--buttons__item",onClick:r,children:o(`webbuilder.${e?"return":"showReference"}`)})})}function WebBuilderTopBar({backActive:o,displayButton:e,clickAction:r,translate:t}){return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__topbar",children:[e?jsxRuntimeExports.jsx(CurrentButton,{backActive:o,action:r,translate:t}):null,jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__title",children:"web builder 3.0"})]})}function FeedbackResult({onNext:o,success:e,showButton:r,translate:t}){const n=t(e?"webbuilder.feedback.successTitle":"webbuilder.feedback.failTitle"),a=t(e?"webbuilder.feedback.success":"webbuilder.feedback.fail");return jsxRuntimeExports.jsxs("div",{dir:"auto",className:`puzzle--webBuilder__feedback bottom ${e?"success":"failed"}`,style:e?{zIndex:"11"}:{},children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"title",children:n}),jsxRuntimeExports.jsx("div",{className:"description",children:a})]}),r?jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__secondary ${e?"green":"red"}`,onClick:o,style:{marginRight:"64px"},children:t("webbuilder.continue")}):null]})}FeedbackResult.defaultProps={onNext:()=>{},success:!1,showButton:!0};function PublishButton({onPublish:o,translate:e}){return jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,onKeyUp:()=>{},"aria-label":"publish",className:"position--absolute bottom center",onClick:o,children:jsxRuntimeExports.jsxs("div",{className:"gat--btn gat--btn__primary",children:[jsxRuntimeExports.jsx("span",{className:"icon-download-cloud"}),e("webbuilder.publish")]})})}PublishButton.defaultProps={onPublish:()=>{}};function PopupColorComponent({colors:o,onSave:e,closingAction:r,translate:t,soundActions:n}){const[a]=n,[u,l]=React$2.useState(),f=u===null;return jsxRuntimeExports.jsx("div",{className:"popup--layer",children:jsxRuntimeExports.jsxs("div",{className:"popup",children:[jsxRuntimeExports.jsx("div",{className:"popup--info",children:jsxRuntimeExports.jsx("span",{className:"popup--info__item",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__colors",children:[jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__colors--title",children:jsxRuntimeExports.jsx("span",{children:t("webbuilder.colorSelect.title")})}),jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__colors--items",children:o.map(c=>jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__color--select ${u===c?"selected":""}`,style:{borderColor:`${c}`},onClick:()=>l(c),children:jsxRuntimeExports.jsx("span",{style:{backgroundColor:`${c}`}})},c+Date.now()))})]})})}),jsxRuntimeExports.jsxs("div",{className:"popup--buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:r,children:jsxRuntimeExports.jsx("span",{children:t("webbuilder.cancel")})}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,onClick:f?null:()=>{a("click-ui"),e(u)},children:t("webbuilder.save")})]})]})})}PopupColorComponent.defaultProps={closingAction:()=>{},onSave:()=>{},colors:{}};PopupColorComponent.propTypes={closingAction:PropTypes.func,onSave:PropTypes.func,colors:PropTypes.arrayOf(PropTypes.string)};function PopupImageComponent({images:o,onSave:e,closingAction:r,translate:t,soundActions:n}){const[a]=n,[u,l]=React$2.useState(),f=!u;return jsxRuntimeExports.jsx("div",{className:"folder-popup",children:jsxRuntimeExports.jsxs("div",{className:"folder-popup__content",children:[jsxRuntimeExports.jsxs("div",{className:"folder-popup__header",children:[jsxRuntimeExports.jsx("div",{}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__title",children:[jsxRuntimeExports.jsx("span",{className:"folder-popup__icon-header icon-fb-search"}),jsxRuntimeExports.jsx("span",{children:t("webbuilder.imageSelect.title")})]}),jsxRuntimeExports.jsx("button",{onClick:r,className:"folder-popup__close",type:"button",children:jsxRuntimeExports.jsx("span",{className:"icon-close-fit"})})]}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__body",children:[jsxRuntimeExports.jsx("div",{className:"folder-popup__scroll",children:jsxRuntimeExports.jsx("ul",{className:"folder-popup__list",children:o.map(c=>jsxRuntimeExports.jsxs("li",{className:"folder-item-file",children:[jsxRuntimeExports.jsx("div",{className:"folder-item-file__imagewrap",onClick:()=>l(c),onKeyUp:()=>{},role:"button",tabIndex:0,children:jsxRuntimeExports.jsx("img",{alt:c.src,src:path+c.src})}),jsxRuntimeExports.jsx("div",{className:"folder-item-file__title",title:c.src,children:c.src})]},c.src+Date.now()))})}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:r,children:t("webbuilder.cancel")}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,onClick:f?null:()=>{a("click-ui"),e(u.src)},children:t("webbuilder.open")})]})]})]})})}PopupImageComponent.defaultProps={closingAction:()=>{},onSave:()=>{},images:[]};function Selected({item:o,translate:e}){return o instanceof Object?e(o.title.toString()):jsxRuntimeExports.jsx("span",{children:e(o||"webbuilder.textSelect.title")})}function PopupTextComponent({closingAction:o,onSave:e,options:r,translate:t,soundActions:n}){const[a]=n,[u,l]=React$2.useState(""),f=u==="",[c,h]=React$2.useState(!1),y=c?"puzzle--webBuilder__select--item open":"puzzle--webBuilder__select--item",E=()=>{h(!c)};return jsxRuntimeExports.jsx("div",{className:"popup--layer",children:jsxRuntimeExports.jsxs("div",{className:"popup",children:[jsxRuntimeExports.jsx("div",{className:"popup--info",children:jsxRuntimeExports.jsx("span",{className:"popup--info__item",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__select",children:[jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__select--label",children:jsxRuntimeExports.jsx("div",{dir:"auto",children:t("webbuilder.textSelect.title")})}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:y,onClick:()=>E(),role:"presentation",children:[jsxRuntimeExports.jsx(Selected,{item:u,translate:t}),jsxRuntimeExports.jsx("span",{className:"icon-down-arrow"}),jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__dropdown",children:r.map(p=>p instanceof Object?jsxRuntimeExports.jsxs("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{l(p)},children:[jsxRuntimeExports.jsx("span",{children:t(p.title)}),jsxRuntimeExports.jsx("span",{className:"subtitle",children:t(p.desc)})]},p.title):jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{l(p)},children:t(p)},p))})]})]})})}),jsxRuntimeExports.jsxs("div",{className:"popup--buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:o,children:t("webbuilder.cancel")}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,disabled:f,onClick:()=>{a("click-ui"),e(u)},children:t("webbuilder.save")})]})]})})}const POPUPS=Object.freeze(Object.defineProperty({__proto__:null,PopupColorComponent,PopupImageComponent,PopupTextComponent},Symbol.toStringTag,{value:"Module"})),defaultHeader={username:null,logo:null,userImage:null,bgImage:null,color:""},defaultBody={bankTitle:null,color:"",btnColor:"",work:null,home:null,mail:null,studies:null,bgImage:null};function PopupComponent({type:o,close:e,translate:r,soundActions:t,...n}){const a=POPUPS[o];return a?jsxRuntimeExports.jsx(a,{type:o,...n,closingAction:e,translate:r,soundActions:t}):null}function DisplayingFeedback({feed:o,resolved:e,translate:r,onNext:t}){return o==="success"?jsxRuntimeExports.jsx(FeedbackResult,{success:!0,showButton:!e,onNext:t,translate:r}):o==="failed"?jsxRuntimeExports.jsx(FeedbackResult,{onNext:t,translate:r}):null}function WebBuilderPuzzleComponent({type:o,info:e,emitEvent:r,setResolveAction:t,soundActions:n,disableExit:a,keyboardControl:u}){const[l,f]=React$2.useState(!1),[c,h]=React$2.useState(!1),[y,E]=React$2.useState(!1),[p,_]=React$2.useState(!1),[g,x]=React$2.useState(!1),[C,R]=React$2.useState(null),S=o==="facebook",A=S?FacebookTemplate:BankTemplate,[T,w]=React$2.useState({type:"",props:{}}),[P,O]=React$2.useState(defaultHeader),[k,D]=React$2.useState(defaultBody),[F]=n,G=Q=>r({type:"translate",payload:Q}),V=()=>{w({type:"",props:{}})},W=(Q,J={})=>{w({type:Q,props:J})},Z=()=>{if(e.solution){const{rewards:Q}=e.solution.right,{rewards:J}=e.solution.wrong;F(y?"fail":"score"),r({type:"addPoints",complex:!0,finish:!0,payload:y?J:Q}),r({type:"passPuzzle"})}};u(null,C==="success"?Z:null,C==="success"?Z:null);const q=(Q,J)=>{const ne=Object.keys(Q),se={existing:0,equal:0};return ne.forEach(ee=>{J[ee]!==null&&J[ee]!==""&&(se.existing+=1),Q[ee]===J[ee]&&(se.equal+=1)}),se},z=(Q,J)=>{const ne=Object.keys(A.header).length,se=Object.keys(A.body).length,ee=q(A.header,Q),ie=q(A.body,J),oe=ie.existing+ee.existing===ne+se,fe=ie.equal+ee.equal===ne+se;return{exist:oe,equal:fe}},U=()=>{F("click-ui");const{exist:Q,equal:J}=z(P,k);r({type:"hidePuzzleButtons",payload:!0}),Q&&!J?(g&&x(!1),R("failed"),E(!0),r({type:"failPuzzle"})):Q&&J&&(g&&(a(!1),x(!1)),_(!0),R("success"))},I=Q=>{if(Object.keys(Q).length>0){const J={...P,...Q};O(J),V();const{exist:ne}=z(J,k);x(!!ne)}},$=Q=>{if(Object.keys(Q).length>0){const J={...k,...Q};D(J),V();const{exist:ne}=z(P,J);x(!!ne)}};React$2.useEffect(()=>{t(Q=>{h(!0),R("success"),f(!1),setTimeout(()=>{R(""),Q()},4e3)}),a(!0)},[t,a,e.resolve.rewards,r]);const B={showingReference:l||c,isFacebook:S,openPopup:W,usingTemplate:A,translate:G},X=()=>{C==="failed"?(R(null),r({type:"hidePuzzleButtons",payload:!1})):C==="success"&&Z()};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(PopupComponent,{type:T.type,...T,close:V,soundActions:n,translate:G}),jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder",children:[jsxRuntimeExports.jsx(WebBuilderTopBar,{backActive:l,displayButton:!c&&!p,translate:G,clickAction:()=>{F("click-ui"),f(!l)}}),jsxRuntimeExports.jsx(WebBuilderHeader,{...B,header:P,onSave:I}),S?jsxRuntimeExports.jsx(WebBuilderFront,{...B,header:P,onSave:I}):null,jsxRuntimeExports.jsx(WebBuilderBody,{...B,body:k,onSave:$})]}),!g&&!l?jsxRuntimeExports.jsx(DisplayingFeedback,{feed:C,onNext:X,resolved:c,translate:G}):null,g&&!l?jsxRuntimeExports.jsx(PublishButton,{onPublish:U,translate:G}):null]})}function Card({card:o,handleClick:e,flipped:r,cardIndex:t,wrongOrder:n}){const a=()=>!(o.img||o.text),u=()=>{const _=(o.img||{}).url;return jsxRuntimeExports.jsx("img",{src:_,alt:""})},l=()=>o.text?jsxRuntimeExports.jsx("div",{className:`card-selector-item__textbox ${o.img?"":"card-selector-item__textbox--noimage"}`,children:jsxRuntimeExports.jsx("div",{className:"card-selector-item__text",children:jsxRuntimeExports.jsx("span",{children:o.text||"_"})})}):null,f=()=>!!(r&&!o.correct||!r),c=()=>jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedback card-selector-item__feedback--error",children:jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedbackicon",children:jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black"})})}),h=()=>o.order?jsxRuntimeExports.jsx("div",{className:"card-selector-item__order",children:jsxRuntimeExports.jsx("div",{children:o.order})}):null,y=()=>jsxRuntimeExports.jsxs("div",{className:"card-selector-item__feedback card-selector-item__feedback--success ",children:[h(),jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedbackicon",children:jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black"})})]}),E=()=>!a()&&r&&o.correct&&!n?y():!a()&&r?c():null;return jsxRuntimeExports.jsxs("button",{type:"button",order:o.order,onClick:()=>{!a()&&f()&&e(t)},className:`unset-button card-selector-item ${a()?"card-selector-item--empty":""}`,"aria-label":o.text?o.text:null,children:[u(),l(),E()]})}Card.defaultProps={handleClick:()=>{},documentsDict:{},card:{},flipped:!1,wrongOrder:!1,cardIndex:0};Card.propTypes={wrongOrder:PropTypes.bool,handleClick:PropTypes.func,cardIndex:PropTypes.number,flipped:PropTypes.bool,documentsDict:PropTypes.shape({}),card:PropTypes.shape({correct:PropTypes.bool,order:PropTypes.number,text:PropTypes.string,imgId:PropTypes.string,status:PropTypes.string})};function Board({cards:o,currentOrder:e,setCurrentOrder:r,handleError:t,feedbackIsShown:n,resolvePuzzle:a,soundActions:u,onFinish:l,handleSuccess:f,resolveWithAnyCard:c}){const[h,y]=React$2.useState(Array(o.length).fill(!1)),[E,p]=React$2.useState(Array(o.length).fill(!1)),[_,g]=React$2.useState(0),[x,C]=React$2.useState(!1),[R]=u,S=o.filter(F=>F.correct===!0).length,A=o.filter(F=>F.order).length>0,T=React$2.useCallback(()=>{y(Array(o.length).fill(!1)),p(Array(o.length).fill(!1)),g(0),r(1)},[o.length,r]),w=()=>{setTimeout(()=>{T()},1e3)};function P(F){const G=Array.from(h);G[F]=F,y(G)}const O=React$2.useCallback(()=>{const F=[];o.forEach((G,V)=>{G.correct===!0&&F.push(V)}),y(F)},[o]);React$2.useEffect(()=>{a&&O()},[O,a]),React$2.useEffect(()=>{(c&&_||_===S&&S>0)&&(l(),C(!0),g(0))},[_,l,S,c]);const k=F=>{P(F),f(o[F].id||null),g(_+1)},D=F=>{var G,V;if(!x&&!n)if(R("click-ui"),o[F].correct&&!A)k(F);else if(A)if(o[F].order===e)r(e+1),k(F);else{if(o[F].order!==e){const W=Array.from(E);W[F]=F,p(W),t(((G=o[F])==null?void 0:G.id)||null,o[F].correct),w()}P(F)}else t(((V=o[F])==null?void 0:V.id)||null),w(),P(F)};return jsxRuntimeExports.jsx("div",{className:`cards-selector__content cards-selector__content-${o.length}`,children:o&&o.map((F,G)=>jsxRuntimeExports.jsx(Card,{setCurrentOrder:r,card:F,handleClick:()=>D(G),flipped:h.includes(G),wrongOrder:E.includes(G),cardIndex:G},`cardPuzzle ${o.indexOf(F)}`))})}Board.defaultProps={setCurrentOrder:()=>{},handleError:()=>{},onFinish:()=>{},handleSuccess:()=>{},documentsDict:{},cards:[],currentOrder:1,resolvePuzzle:!1,feedbackIsShown:!1,resolveWithAnyCard:!1};function CardsSelectorPuzzleComponent({emitEvent:o,info:e,cards:r,resolveWithAnyCard:t,specificFeedbacks:n,disableExit:a,setResolveAction:u,soundActions:l,backgroundImage:f,nodeId:c,keyboardControl:h}){var $,B;const[y,E]=React$2.useState(!1),[p,_]=React$2.useState(1),[g,x]=React$2.useState(!1),[C,R]=React$2.useState(!1),[S,A]=React$2.useState(!1),[T,w]=React$2.useState([]),[P,O]=React$2.useState(!1),[k,D]=React$2.useState(""),[F]=l,G=X=>o({type:"translate",payload:X}),V=`cards-selector-puzzle_${c}`,W=React$2.useCallback(X=>{x(!1),A(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"addPoints",complex:!0,finish:!0,payload:X}),o({type:"passPuzzle"})},[o]),Z=React$2.useCallback(()=>{var ne,se;o({type:"hidePuzzleButtons",payload:!0}),x(!0);const{rewards:X}=((ne=e==null?void 0:e.solution)==null?void 0:ne.right)||{},Q=((se=n==null?void 0:n.correctFeedbacks)==null?void 0:se.map(ee=>ee.rewards).flat())||[],J=[...T,...X,...Q];F("score"),W(J)},[T,W,o,($=e==null?void 0:e.solution)==null?void 0:$.right,F,n==null?void 0:n.correctFeedbacks]),q=()=>{E(!0),e.solution.right.desc&&!(n!=null&&n.specificCorrectFeedbacks)&&D(e.solution.right.desc),A(!0)},z=()=>{g||y?Z():(x(!1),a(!1),A(!1),o({type:"hidePuzzleButtons",payload:!1})),D("")},U=X=>{if(R(!0),n!=null&&n.specificCorrectFeedbacks){const Q=n.correctFeedbacks.find(J=>J.id===X);Q!=null&&Q.desc&&(D(Q.desc),A(!0))}F("score"),o({type:"hidePuzzleButtons",payload:!0})},I=(X,Q=!1)=>{var J,ne;if(R(!1),Q)D((J=e.orderFeedback)==null?void 0:J.desc),A(!0),w([...T,...((ne=e.orderFeedback)==null?void 0:ne.rewards)||[]]);else if(n!=null&&n.specificWrongFeedbacks){const se=n.wrongFeedbacks.find(ee=>ee.id===X);se!=null&&se.desc?(D(se.desc),A(!0)):(A(!0),setTimeout(()=>{z(),o({type:"hidePuzzleButtons",payload:!1})},2e3)),w([...T,...(se==null?void 0:se.rewards)||[]])}else e.solution.wrong.desc?(D(e.solution.wrong.desc),A(!0)):(A(!0),setTimeout(()=>{z(),o({type:"hidePuzzleButtons",payload:!1})},3e3));a(!0),!(n!=null&&n.specificWrongFeedbacks)&&!Q&&w([...T,...e.solution.wrong.rewards]),F("fail"),o({type:"hidePuzzleButtons",payload:!0}),o({type:"failPuzzle"})};return React$2.useEffect(()=>{y&&a(!0)},[a,y]),React$2.useEffect(()=>{u(()=>{var Q;o({type:"hidePuzzleButtons",payload:!0}),O(!0);const X=[...T,...((Q=e==null?void 0:e.resolve)==null?void 0:Q.rewards)||{}];setTimeout(()=>{x(!1),A(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:V,rewards:X,finish:!0}})},2e3)})},[u,a,T,(B=e==null?void 0:e.resolve)==null?void 0:B.rewards,o,V]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:`cards-selector ${f!=null&&f.url?"cards-selector--with-custom-bg":""}`,style:f!=null&&f.url?{backgroundImage:`url("${f.url}")`}:{},children:jsxRuntimeExports.jsx(Board,{setCurrentOrder:_,currentOrder:p,cards:r,onFinish:q,resolveWithAnyCard:t,handleError:I,feedbackIsShown:S,resolvePuzzle:P,soundActions:l,handleSuccess:U})}),S&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:g||C,text:k,hasTimeout:!k,translate:G,functionOnClose:z,keyboardControl:h})]})}CardsSelectorPuzzleComponent.defaultProps={cards:[],info:{},resolveWithAnyCard:!1,backgroundImage:{url:""}};function Fakecursor(){return jsxRuntimeExports.jsx("span",{className:"fakecursor",children:"|"})}function FixedComponent({delay:o,index:e,length:r,textToPrint:t,setDoneTyping:n,nextParagraphType:a,isWriting:u}){const[l,f]=React$2.useState(!0),[c,h]=React$2.useState(""),[y,E]=React$2.useState(!1);React$2.useEffect(()=>{E(e===r-1)},[e,r]);const p=C=>{if(!C||!C.length)return"";const R=C.replace(/<script.*?>.*?<\/script>/gim,""),S=document.createElement("DIV");return S.innerHTML=R,S.textContent||S.innerText||""};React$2.useEffect(()=>{const C=()=>{const S=t.trim().split(" ");return R(S,S.length-1).join(" ")},R=(S,A)=>{if(A<0)return[""];const T=[...S];if(p(S[A]).length!==0){const w=S[A];return T[A]=`<span class="lastWord" >${w}</span>`,T}return R(S,A-1)};a==="election"?h(C()):setTimeout(()=>{h(t)},200)},[a,t]);const _=()=>{n(!0),f(!1)},g=t.split("<p>");g.shift();const x=g.length>1;return l&&t!==""&&c!==""?jsxRuntimeExports.jsx("span",{className:`writer-inline ${x?"multiple":""} ${y?"Typist":""}`,"data-testid":`result-${e}`,children:jsxRuntimeExports.jsx(Typist,{startDelay:300,avgTypingDelay:o,stdTypingDelay:10,onCharacterTyped:u,onTypingDone:_,cursor:{hideWhenDone:!0,hideWhenDoneDelay:200},blink:!0,children:HTMLReactParser$1(t)})}):jsxRuntimeExports.jsxs("span",{className:`writer-inline ${x?"multiple":""} ${y?"Typist":""}`,"data-testid":`result-${e}`,children:[HTMLReactParser$1(c),a==="election"&&y&&jsxRuntimeExports.jsx(Fakecursor,{})]})}FixedComponent.defaultProps={delay:0,textToPrint:"",setDoneTyping:()=>{},nextParagraphType:"",isWriting:()=>{}};function SingleElection({option:o,decisionInspected:e,setCurrentDecisionSelected:r,index:t,setCurrentDecisionInspected:n,soundActions:a}){const[u]=a,l=E=>E.previewText!==""?HTMLReactParser$1(E.previewText):HTMLReactParser$1(E.fullText),f=E=>E.previewText!==""?e===t?"icon-eye inspected":"icon-eye":"",c=()=>{u("click-ui"),r(t)},h=E=>{E.keyCode===13&&y(E)},y=E=>{E.preventDefault(),E.stopPropagation(),e===t?(E.target.style.background="",n("")):n(t)};return jsxRuntimeExports.jsxs("div",{className:"single-election",children:[jsxRuntimeExports.jsxs("button",{className:"single-election__cta",type:"button",onClick:()=>c(),children:[jsxRuntimeExports.jsx("div",{className:"single-election__btn",children:jsxRuntimeExports.jsx("span",{children:l(o)})}),jsxRuntimeExports.jsx("div",{onClick:y,onKeyDown:h,className:f(o),"aria-label":"Inspect",role:"button",tabIndex:0})]}),e===t&&jsxRuntimeExports.jsx("div",{className:"single-election__complete",children:jsxRuntimeExports.jsx("div",{children:HTMLReactParser$1(o.fullText)})})]})}SingleElection.defaultProps={setCurrentDecisionSelected:()=>{},setCurrentDecisionInspected:()=>{},option:{},index:0};function SingleElectionRender({decisionInspected:o,opt:e,index:r,setCurrentDecisionSelected:t,setCurrentDecisionInspected:n,soundActions:a}){return e&&e.fullText&&e.fullText!==""?jsxRuntimeExports.jsx(SingleElection,{decisionInspected:o,setCurrentDecisionSelected:t,setCurrentDecisionInspected:n,option:e,soundActions:a,index:r}):null}function ElectionComponent({textWithOpts:o,setCurrentDecisionSelected:e,printed:r,soundActions:t}){const[n,a]=React$2.useState("");return React$2.useEffect(()=>{r()},[r]),jsxRuntimeExports.jsx("div",{className:`elections-box pos${n+1}-${o.filter(u=>!!u.fullText).length}`,children:o&&o.map((u,l)=>jsxRuntimeExports.jsx(SingleElectionRender,{opt:u,soundActions:t,index:l,setCurrentDecisionSelected:e,setCurrentDecisionInspected:a,decisionInspected:n},l))})}ElectionComponent.defaultProps={textWithOpts:[],setCurrentDecisionSelected:()=>{},printed:()=>{}};function FeedbackElement({decision:o}){const{title:e,body:r}=o.feedback;return jsxRuntimeExports.jsx("div",{children:r!==""&&jsxRuntimeExports.jsxs("div",{className:"writer-feedback-decision-item",children:[e&&jsxRuntimeExports.jsxs("div",{dir:"auto",className:"writer-feedback-decision-item__title",children:[e," "]}),r&&jsxRuntimeExports.jsxs("div",{dir:"auto",className:"writer-feedback-decision-item__message",children:[o.correct?jsxRuntimeExports.jsx("span",{className:"icon-check-circle-black color--success"}):jsxRuntimeExports.jsx("span",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("span",{children:r})]})]})})}FeedbackElement.defaultProps={decision:{}};function FeedbackComponent({emitEvent:o,closingAction:e,feedbackIsDone:r,decisionsList:t,texts:n,retryAction:a,retry:u,skip:l,checkCorrect:f,rewardsStack:c,setFailed:h,soundActions:y}){const[E]=y,p=g=>o({type:"translate",payload:g}),_=()=>{E("click-ui"),e(),h(),r()};return jsxRuntimeExports.jsxs("div",{className:`writer-feedback ${c.length?"":"start"}`,children:[jsxRuntimeExports.jsx("div",{className:"writer-feedback__title",children:p("puzzles.feedback")}),jsxRuntimeExports.jsx("div",{className:"writer-feedback__decisions",children:t.map(g=>n[g.currenTextParagraph].electionTexts[g.index].feedback.body?jsxRuntimeExports.jsx(FeedbackElement,{decision:n[g.currenTextParagraph].electionTexts[g.index]},g.index):null)}),jsxRuntimeExports.jsxs("div",{className:"writer-feedback__btns",children:[l&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary writer-feedback__btn-mobile",onClick:()=>{_()},children:p("puzzles.skip")}),u&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>{f()?_():(E("click-ui"),a())},children:p(f()?"puzzles.continue":"puzzles.retry")}),!u&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>_(),children:p("puzzles.continue")})]})]})}FeedbackComponent.defaultProps={emitEvent:()=>{},closingAction:()=>{},feedbackIsDone:()=>{},decisionsList:[],texts:[],retryAction:()=>{},retry:!1,skip:!1,checkCorrect:()=>{},nodeId:"0"};function FinishedTextComponent({textToPrint:o,correct:e}){const r=o.split("<p>");r.shift();const t=r.length>1;return jsxRuntimeExports.jsx("span",{className:`writer-inline ${t?"multiple":""} ${e}`,children:HTMLReactParser$1(o)})}FinishedTextComponent.defaultProps={correct:"",textToPrint:""};function WriterPuzzleComponent({emitEvent:o,styles:e,nodeId:r,retry:t,skip:n,type:a,info:u,setResolveAction:l,documentTitle:f,documentTitle_labelId:c,texts:h,soundActions:y,backgroundImage:E}){const p=Ie=>o({type:"translate",payload:Ie}),_=React$2.useRef(),[g,x]=React$2.useState(!1),[C,R]=React$2.useState(!1),[S,A]=React$2.useState(0),[T,w]=React$2.useState({[`text_${S}`]:{...h[S],id:`text_${S}`,correct:""}}),[P,O]=React$2.useState(!1),[k,D]=React$2.useState([]),[F,G]=React$2.useState(!1),[V,W]=React$2.useState(!1),[Z,q]=React$2.useState(!1),[z,U]=React$2.useState(!0),[I,$]=React$2.useState([]),[B,X]=React$2.useState(!0),[Q]=y,J=React$2.useRef({}),ne=Ie=>{let et;return Ie.electionTexts.forEach((at,Kt)=>{at.correct&&(et=Kt)}),et},se=React$2.useCallback(Ie=>k.filter(at=>at.currenTextParagraph===Ie)[0].fullText_labelId,[k]),ee=React$2.useCallback(()=>h.map((Ie,et)=>{if(Ie.type==="fixed")return Ie.fullText_labelId??Ie.fullText;if(Ie.type==="election"){const at=ne(Ie);return at>=0?Ie.electionTexts[at].fullText_labelId:se(et)}return""}),[se,h]),ie=12,oe=()=>{if(k){const Ie=k.length;let et=0;for(let at=0;at<Ie;at+=1)k[at].isCorrect==="none"&&(et+=1);return et===Ie}return!0},fe=React$2.useCallback(()=>{if(k){const Ie=k.length;let et=0;for(let at=0;at<Ie;at+=1)k[at].isCorrect==="green"&&(et+=1);return et===Ie}return!0},[k]),de=()=>!!(k&&k.length),ce=()=>k.find(Ie=>{const{feedback:et}=h[Ie.currenTextParagraph].electionTexts[Ie.index];return et.body!==""}),Se=React$2.useCallback(()=>{const Ie=ee();o({type:"finishMedia",payload:{name:c,text:Ie,documentType:a,type:"text"}})},[ee,c,o,a]),ke=React$2.useCallback(Ie=>{const et=fe();Q(C?"fail":et?"score":"fail"),o({type:"addPoints",complex:!0,finish:!0,payload:Ie||I,onFinish:a!=="view"?Se:null}),o({type:"passPuzzle"})},[fe,o,C,Se,Q,I,a]);React$2.useEffect(()=>{g&&X(!1),l(()=>{ke(u.resolve.rewards)})},[o,ke,g,Se,u.resolve.rewards,l,a]);const Ne=()=>{x(!1),A(0),D([]),$([]),R(!1),q(!1),O(!1),W(!1),G(!1),w({text_0:{...h[0],id:"text_0",correct:""}}),U(!0),o({type:"addPoints",complex:!0,finish:!1,payload:I}),o({type:"failPuzzle"})},We=()=>{de()?oe()&&(G(!0),ke()):(G(!0),q(!0),ke()),F?(U(!1),Z&&!V?W(!0):(V||!Z&&!V)&&(!Z&&!V&&t?fe()?ke():Ne():ke())):(G(!0),ce()&&q(!0))},Ke=()=>{const Ie=h[S].electionTexts.filter(at=>at.correct).length,et=h[S].electionTexts;return Ie===0||Ie===et},Qe=Ie=>{const et=h[S].electionTexts[Ie],at=et.feedback.rewards;at&&at[0]&&at[0].points&&(J.current[`t${S}_e${Ie}`]||(et.correct&&(J.current[`t${S}_e${Ie}`]=!0),$([...I,...at])));const Kt=()=>Ke()?"none":et.correct?"green":"red",Xe={currenTextParagraph:S,fullText:et.fullText,index:Ie,isCorrect:Kt()};w({...T,[`text_${S}`]:{type:"fixed",fullText:et.fullText,correct:Xe.isCorrect}}),D([...k,Xe])},pt=()=>{_.current.scrollTop=_.current.scrollHeight+100},vt=()=>{if(_.current.querySelector(".wrapfixed").offsetHeight>_.current.offsetHeight){const Ie=_.current.querySelector(".wrapfixed").offsetHeight;_.current.scrollTo({top:Ie,behavior:"smooth"})}},ct=(Ie,et,at)=>{const Kt=Ie.fullText,Xe=h[at+1]?h[at+1].type:"",it=T[`text_${at+1}`]&&T[`text_${at+1}`].type?T[`text_${at+1}`].type:Xe;return jsxRuntimeExports.jsx(FixedComponent,{length:et,doneTyping:P,index:at,delay:ie,setDoneTyping:O,nextParagraphType:it,isWriting:vt,textToPrint:Kt},at.toString())},mt=(Ie,et)=>{const at=Ie.fullText;return jsxRuntimeExports.jsx(FinishedTextComponent,{textToPrint:at,correct:Ie.correct},et)},Vt=Ie=>jsxRuntimeExports.jsx(ElectionComponent,{soundActions:y,textWithOpts:Ie.electionTexts,setCurrentDecisionSelected:Qe,printed:pt,disableExit:B},Ie.electionTexts),kt=(Ie,et,at)=>Ie.type==="fixed"?ct(Ie,et,at):Vt(Ie);return React$2.useEffect(()=>{P===!0&&(()=>{h[S+1]?(w({...T,[`text_${S+1}`]:{...h[S+1],id:`text_${S+1}`,correct:""}}),A(S+1),O(!1)):x(!0)})()},[P,S,T,h]),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:`writer-puzzle writer-puzzle--${e}`,style:E!=null&&E.url?{backgroundImage:`url("${E.url}")`}:{},children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__overlay",children:[V&&jsxRuntimeExports.jsx(FeedbackComponent,{emitEvent:o,texts:h,setFailed:()=>R(!0),decisionsList:k,closingAction:We,retry:t,skip:n,checkCorrect:fe,retryAction:Ne,rewardsStack:I,nodeId:r,soundActions:y}),!V&&jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__container",children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"writer-puzzle__title",children:f!==""&&f}),jsxRuntimeExports.jsx("div",{className:"writer-puzzle__body",dir:LangIsRtl()?"rtl":"auto",children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__scroll",tabIndex:0,style:{overflowX:"hidden",padding:"0 0 20px 0",height:"95%"},ref:_,children:[jsxRuntimeExports.jsx("div",{className:"wrapfixed",children:z&&!F&&Object.values(T).map((Ie,et)=>kt(Ie,Object.values(T).length-1,et))}),F&&Object.values(T).map((Ie,et)=>mt(Ie,et))]})}),g&&jsxRuntimeExports.jsx("div",{className:"writer-puzzle__footer",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:We,children:p("screens.continue")})})]})]})})})}WriterPuzzleComponent.defaultProps={emitEvent:()=>{},info:{},styles:"",nodeId:"0",retry:!1,skip:!1,type:"",documentTitle:"",texts:[]};function Image$1({document:o,name:e,isWallpaper:r}){const t=(o==null?void 0:o.url)||null;return jsxRuntimeExports.jsx("div",{className:`puzzle--terminal__image ${r?"puzzle--terminal__image--wallpaper":""}`,children:t?jsxRuntimeExports.jsx("img",{src:t,alt:e||""}):null})}const ICONS$1={image:"image-icon",video:"video-icon",embedded_video:"video-icon",pdf:"pdf-icon",terminal:"console-icon",cracker:"cracker-icon",folder:"folder-icon",world:"world-icon"};function Visor({file:o,solution:e,showContinue:r,info:t,resolvePuzzle:n,backFile:a,translate:u,soundActions:l,keyboardControl:f}){var R;const{fileId:c}=o,h=((R=o.document)==null?void 0:R.url)||"",[y]=l,E={image:{component:Image$1,props:{...o,url:h,soundActions:l}},video:{component:VideoVisor,props:{...o,url:h,endVideo:n,soundActions:l,translate:u}},embedded_video:{component:VideoVisor,props:{...o,url:h,soundActions:l}},pdf:{component:PdfVisor,props:{...o,url:h,translate:u,soundActions:l,emitNumberOfPages:()=>{},endPdf:()=>{},keyboardControl:f}},application:{component:PdfVisor,props:{...o,url:h,translate:u,soundActions:l,emitNumberOfPages:()=>{},keyboardControl:f,endPdf:()=>{}}}};if(!E[o.type])return null;const p=E[o.type].component,_=E[o.type].props,x=o.name.replace(/.jpg|.png|.pdf|.mp4/gi,""),C=e.fileId;return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__visor",children:[jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:y,shortText:!0,success:c===C,text:c===C?t.solution.right.desc:t.solution.wrong.desc,functionOnClose:c===C?n:a,additionalStyle:ICONS$1[o.type],secondText:x,translate:u,puzzleHeaderClass:"puzzle--terminal__visor--message",keyboardControl:f}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__visor--body",children:jsxRuntimeExports.jsx(p,{..._})}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__button",children:c===C&&r?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary green",type:"button",onClick:n,children:u("screens.continue")}):null})]})})}const ICONS={image:"image-icon",video:"video-icon",embedded_video:"video-icon",pdf:"pdf-icon",terminal:"console-icon",cracker:"cracker-icon",folder:"folder-icon",application:"pdf-icon",world:"world-icon"};function Item({item:o,selectItem:e}){const r=o.name;return jsxRuntimeExports.jsx("li",{className:"puzzle--terminal__folder__list--item",children:jsxRuntimeExports.jsxs("button",{type:"button",title:r,className:`unset-button puzzle--terminal__item id-${o.id}`,onClick:()=>o.fixed?null:e(o),children:[jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__icon ${ICONS[o.type]}`}),jsxRuntimeExports.jsx("span",{children:r})]})})}function FilesGroup({initFile:o,backFile:e,file:r,closeFolder:t,selectItem:n}){return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:r.id==="init"?jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:r.children.map((a,u)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${`${u}${a.id}`}`))}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:o.children.map((a,u)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${u+a.id}`))}),jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__folder",children:[jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__folder--head",children:[jsxRuntimeExports.jsx("span",{role:"button",onKeyUp:()=>{},"aria-label":"back file",tabIndex:0,onClick:()=>e(),className:"puzzle--terminal__folder--back",children:jsxRuntimeExports.jsx("span",{className:"icon-back"})}),jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__folder--head__icon ${ICONS[r.type]}`}),jsxRuntimeExports.jsx("span",{className:"text",children:r.name}),jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,"aria-label":"close folder",onKeyUp:()=>{},onClick:()=>t(),className:"puzzle--terminal__folder--close",children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})]}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__folder--body",children:jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list",children:r.children.map((a,u)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${u+a.id}`))})})]})]})})}const DEFAULT_IMG="https://min.gamelearn.io/css-resources/gamelearn/resources/cosmos-bg-min.jpg",FIXED_ITEMS=[{fileId:"ids1",type:"world",fixed:!0,name:"Web builder 3.0"},{fileId:"ids2",type:"cracker",fixed:!0,name:"Decoder.exe"},{fileId:"ids3",type:"terminal",fixed:!0,name:"terminal"}];function TerminalPuzzleComponent({emitEvent:o,items:e,backgroundImage:r,solution:t,info:n,disableExit:a,soundActions:u,setResolveAction:l,nodeId:f,keyboardControl:c}){const[h,y]=React$2.useState({}),[E]=React$2.useState(!1),[p,_]=React$2.useState([]),g=React$2.useRef([]),[x]=u,C=k=>o({type:"translate",payload:k}),R=`terminal-puzzle_${f}`,S=React$2.useMemo(()=>({name:"init",children:[...FIXED_ITEMS,...e],id:"init"}),[e]),A=React$2.useCallback(k=>{x("click-ui"),y(k),_([...p,k]),k.type!=="folder"&&(o({type:"hidePuzzleButtons",payload:!0}),a(!0))},[p,a,o,x]);React$2.useEffect(()=>{y(S),_([S])},[S]),React$2.useEffect(()=>{l(()=>{g.current=[...g.current,...n.resolve.rewards];const k=g.current.map(D=>{var q;const{name:F,points:G,type:V,id:W}=D,Z={name:F,points:G,type:V,id:W};return(q=D==null?void 0:D.document)!=null&&q.resourceId&&(Z.id=D.document.resourceId),Z});o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:R,rewards:k,finish:!0}})})},[l,n.resolve.rewards,o,R]);const T=()=>{g.current=[...g.current,...n.solution.wrong.rewards];const k=p.length-1,D=p.filter((F,G)=>k>G);y(p[k-1]),_(D),a(!1),o({type:"hidePuzzleButtons",payload:!1})},w=()=>{x("click-ui");const k=p[0];y(k),_([k])},P=()=>{g.current=[...g.current,...n.solution.right.rewards];const k=g.current.map(D=>{var q;const{name:F,points:G,type:V,id:W}=D,Z={name:F,points:G,type:V,id:W};return(q=D==null?void 0:D.document)!=null&&q.resourceId&&(Z.id=D.document.resourceId),Z});o({type:"hidePuzzleButtons",payload:!1}),x("score"),o({type:"addPoints",complex:!0,finish:!0,payload:k}),o({type:"passPuzzle"})},O=(r==null?void 0:r.url)||DEFAULT_IMG;return jsxRuntimeExports.jsx("div",{className:"puzzle--terminal",children:h.children?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Image$1,{isWallpaper:!0,document:{url:O}}),jsxRuntimeExports.jsx(FilesGroup,{backFile:T,initFile:S,selectItem:A,breadcrumb:p,closeFolder:w,file:h,translate:C})]}):jsxRuntimeExports.jsx(Visor,{soundActions:u,backFile:T,resolvePuzzle:P,info:n,showContinue:!E,solution:t,file:h,translate:C,keyboardControl:c})})}function DragItemPuzzleComponent({area:o,image:e,resolveObject:r,info:t,hasHighlights:n,consume:a,disableExit:u,emitEvent:l,soundActions:f,keyboardControl:c}){const{solution:h}=t,y=React$2.useRef(),E=React$2.useRef(),p=React$2.useRef(),_=React$2.useRef(),g=React$2.useRef({}),[x,C]=React$2.useState(""),[R,S]=React$2.useState(!1),[A,T]=React$2.useState(!1),[w,P]=React$2.useState(),[O]=React$2.useState(new window.Image),k=React$2.useRef([]),[D]=f,F=J=>l({type:"translate",payload:J});React$2.useEffect(()=>{u(x!=="")},[x,u]);const G=(J,ne)=>(J.x+J.width>ne.x&&J.x+J.width<=ne.x+ne.width||ne.x+ne.width>J.x&&ne.x+ne.width<=J.x+J.width)&&(J.y+J.height>ne.y&&J.y+J.height<=ne.y+ne.height||ne.y+ne.height>J.y&&ne.y+ne.height<=J.y+J.height),V=()=>{y&&n&&(y.current.to({duration:.25,opacity:.75}),E.current.to({duration:.25,opacity:.4}))},W=()=>{y&&n&&(y.current.to({duration:.25,opacity:0}),E.current.to({duration:.25,opacity:0}))},Z=React$2.useCallback(J=>{let ne=!1;if(J){const se=p.current;se.setPointersPositions(J);const ee=se.getPointerPosition(),ie=y.current.getClientRect({relativeTo:se});ne=G({...ee,width:1,height:1},ie)}return ne},[]),q=React$2.useCallback(J=>J&&r.uid===JSON.parse(J).uid,[r.uid]),z=React$2.useCallback(()=>{C(""),l({type:"hidePuzzleButtons",payload:!1}),l({type:"addPoints",complex:!0,finish:!0,payload:k.current}),l({type:"passPuzzle"}),a&&l({type:"consumeItem",payload:{uid:r.uid,targetId:r.uid,name:r.name}}),l({type:"closeUI",ui:"inventory"})},[a,l,r.name,r.uid]),U=React$2.useCallback(()=>{C("success"),l({type:"hidePuzzleButtons",payload:!0}),k.current=[...k.current,...h.right.rewards],setTimeout(()=>{z()},2e3)},[l,z,h.right.rewards]),I=React$2.useCallback(()=>{l({type:"openUI",ui:"inventory",onFinish:()=>{}}),C(""),l({type:"hidePuzzleButtons",payload:!1}),l({type:"failPuzzle"}),k.current=[...k.current,...h.wrong.rewards]},[l,h.wrong.rewards]),$=React$2.useCallback(J=>{const ne=J.dataTransfer.getData("item");p.current.setPointersPositions(J);const se=Z(J);l({type:"hidePuzzleButtons",payload:!0}),se&&q(ne)?(C("success"),l({type:"closeUI",ui:"inventory"}),t.solution.right.desc===""&&U()):(l({type:"closeUI",ui:"inventory"}),C("failed"),t.solution.wrong.desc===""&&setTimeout(()=>{I()},2e3))},[Z,q,l,U,I,t.solution.right.desc,t.solution.wrong.desc]),B=()=>{x==="success"?U():I()};React$2.useEffect(()=>{const J=e.img.url||"";O.src=J,O.onload=()=>{_.current&&(g.current={x:_.current.clientWidth/2,y:_.current.clientHeight/2,width:O.width,height:O.height,offsetX:O.width/2,offsetY:O.height/2,scale:{x:Math.min(_.current.clientWidth/O.width,_.current.clientHeight/O.height),y:Math.min(_.current.clientWidth/O.width,_.current.clientHeight/O.height)}},S(!0))}},[O,e.img.url]),React$2.useEffect(()=>{A||(l({type:"openUI",ui:"inventory",onFinish:()=>{}}),T(!0))},[A,l]);const X=J=>{J!==null&&(y.current=J)},Q=J=>{if(J!==null&&(E.current=J,y.current)){const{x:ne,y:se,width:ee,height:ie}=y.current.getClientRect();J.setAttr("x",ne),J.setAttr("y",se),J.setAttr("height",ie),J.setAttr("width",ee)}};return React$2.useLayoutEffect(()=>{if(y.current&&R){const J=y.current.getClientRect({relativeTo:y.current.getParent()});P({x:J.x+J.width/2,y:J.y+J.height/2})}},[R]),jsxRuntimeExports.jsxs("div",{className:"puzzle--drag__mask100",onDrop:$,onDragOver:J=>{J.preventDefault()},children:[jsxRuntimeExports.jsx("div",{className:"puzzle--drag__mask",children:jsxRuntimeExports.jsx("div",{ref:_,"data-testid":"mask_canvas",className:"puzzle--drag__mask--canvas",children:R?jsxRuntimeExports.jsx(Stage,{ref:p,width:_.current.clientWidth,height:_.current.clientHeight,children:jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Image$2,{image:O,...g.current}),jsxRuntimeExports.jsxs(Group,{...g.current,children:[w?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...w},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:"object-area-projection"})}):null,jsxRuntimeExports.jsx(Line,{onMouseEnter:V,onMouseLeave:W,ref:X,...o,shape:"poly",fill:"#262a31d9",stroke:"white",strokeWidth:1,opacity:0,dash:[3,2],closed:!0,draggable:!1})]}),jsxRuntimeExports.jsx(Text,{onMouseEnter:V,onMouseLeave:W,ref:Q,text:F("puzzle.drag.dropzone"),fontSize:12,align:"center",verticalAlign:"middle",fill:"#ffffff",opacity:0})]})}):null})}),x!==""?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:t.solution[x==="success"?"right":"wrong"].desc,success:x==="success",translate:F,playSound:D,functionOnClose:B,keyboardControl:c}):null]})}const LABELS_INDEX$1=["A","B","C","D","E","F","G","H","I","J"];function Questions({disabled:o,answered:e,question:r,updateForm:t,result:n,correctQuestions:a,translate:u}){const[l,f]=React$2.useState(!1),c=r.answers.filter(x=>x.text),h=x=>{let C=!1;return n[r.id].find(R=>R.id===x)&&(C=!0),C},y=x=>{let C="";return l?(e&&h(x.id)&&(C="selected"),o&&h(x.id)&&a.includes(x.id)&&(C="success"),o&&h(x.id)&&!a.includes(x.id)&&(C="failed")):(e&&x.id===n[r.id][0].id&&(C="selected"),o&&x.id===n[r.id][0].id&&(C=n[r.id][0].isCorrect?"success":"failed")),C},E=x=>{const C=y(x);return C==="selected"?"icon-check-circle-black color--selected":C==="success"?"icon-check-circle-black color--success":C==="failed"?"icon-error-circle-black color--error":""},p=x=>o&&x.feedback&&(l&&h(x.id)||x.id===n[r.id][0].id),_=(x,C)=>C===0?"tooltip--right__top":C===x.length-1?"tooltip--right__bottom":"tooltip--center__right",g=r.answers.filter(x=>x.isCorrect);return React$2.useEffect(()=>{g.length===1?f(!1):f(!0)},[g.length,l,r.answers]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:r.text})}),l&&!o?jsxRuntimeExports.jsx("div",{className:"test--questions__intertitle test--questions__intertitle--multiresponse",children:u("tests.chooseMoreOneAnswer")}):null,c.map((x,C)=>jsxRuntimeExports.jsxs("div",{className:"test--response__fakeinput",children:[l?jsxRuntimeExports.jsx("input",{checked:e&&h(x.id),disabled:o&&!h(x.id),readOnly:o,type:"checkbox",id:x.id,onChange:()=>o?null:t(x,r.id,C,"isCheckbox",x.id)}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("input",{checked:e&&x.id===n[r.id][0].id,disabled:o&&!y(x),type:"radio",name:"name",id:x.id,onChange:()=>o?null:t(x,r.id,C,"isRadio")})}),jsxRuntimeExports.jsxs("label",{htmlFor:x.id,className:`test--response__item ${y(x)}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX$1[C]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:x.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${E(x)}`})]}),o?jsxRuntimeExports.jsxs("div",{className:`test--feedback__info ${p(x)?"":"test--feedback__info--hidden"}`,children:[jsxRuntimeExports.jsx("span",{className:`icon-info2 ${y(x)==="success"?"color--success":"color--error"}`}),jsxRuntimeExports.jsxs("div",{id:`tooltipFeedback-${C}`,className:`tooltip ${_(c,C)}`,children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsx("span",{children:u("test.feedback")})})}),jsxRuntimeExports.jsx("span",{children:jsxRuntimeExports.jsx("span",{children:x.feedback})})]})]}):null]},x.text))]})}const LABELS_INDEX=["A","B","C","D","E","F","G","H","I","J"];function FeedbackItem({selectedAnswers:o,correctQuestions:e,question:r,translate:t}){const n=l=>e.includes(l),a=(l,f)=>l.index<f.index?-1:l.index>f.index?1:0,u=o.sort(a);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:r})}),u.map(l=>jsxRuntimeExports.jsxs("div",{className:"test--response__itemwrap",children:[jsxRuntimeExports.jsxs("div",{className:`test--response__item ${n(l.id)?"success":"failed"}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX[l.index]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:l.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${n(l.id)?"icon-check-circle-black color--success":"icon-error-circle-black color--error"}`})]}),jsxRuntimeExports.jsxs("div",{className:"test--feedback",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsxs("span",{children:[t("test.feedback")," ",o.length>1?LABELS_INDEX[l.index]:""]})})}),jsxRuntimeExports.jsx("span",{children:l.feedback})]})]},l.text))]})}function Container({questions:o,setTime:e,saveInterval:r,result:t,setTries:n,tries:a,time:u,showResults:l,answered:f,answerPage:c,updateForm:h,disabled:y,translate:E,soundActions:p,paused:_,view:g,correctQuestions:x,feedbacksOnlyWhenReview:C}){const R=document.querySelector(".test--container"),[S,A]=React$2.useState(0),[T,w]=React$2.useState(),P=o[S].id,[O]=p;React$2.useEffect(()=>{if(u>=0&&!y&&!_){const q=setInterval(()=>{T||e(z=>z-1)},1e3);return r(q),()=>{clearInterval(q)}}},[y,T,_,r,e,u]);const k=()=>{R.scrollTo(0,0),O("click-ui"),f&&(t[P][0].feedback&&!y&&!C?w(!0):(c(!1),A(S+1)))},D=()=>{O("click-ui"),A(S-1)},F=()=>{R.scrollTo(0,0),o[S+1]?(w(!1),c(!1),A(S+1)):l()},G=()=>{R.scrollTo(0,0),n(a+1),t[P][0].feedback&&!y&&!C?w(!0):l()},V=Math.floor(u/60),W=u%60;React$2.useEffect(()=>{if(g==="review"){const q=t[`q${S}`][0].id,z=document.querySelector(`#${q}`);R.scrollTo(0,z.offsetTop)}},[S,R,t,g]);const Z=()=>{if(f){const q=x[o[S].id.substring(1)].answers,z=t[P],U=z.find($=>$.isCorrect===!1);let I=0;return z.forEach($=>{q.includes($.id)&&(I+=1)}),!U&&I===q.length}return!1};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[g==="review"||T?jsxRuntimeExports.jsx("div",{className:`test-feedback-header ${Z()?"success":"failed"}`,children:jsxRuntimeExports.jsxs("h2",{children:[jsxRuntimeExports.jsx("span",{className:`${Z()?"icon-correct-thumb":"icon-incorrect-thumb"}`}),jsxRuntimeExports.jsx("span",{className:"test-feedback-header__title",children:Z()?E("tests.resolvedQuestion"):E("tests.notResolvedQuestion")})]})}):null,jsxRuntimeExports.jsxs("div",{className:"test--questions",children:[jsxRuntimeExports.jsx("div",{className:"test--questions__container",children:T?jsxRuntimeExports.jsx(FeedbackItem,{selectedAnswers:t[P],correctQuestions:x[o[S].id.substring(1)].answers,question:o[S].text,translate:E}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"test--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:LangIsRtl()?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[S+1,"/",o.length," ",jsxRuntimeExports.jsx("span",{children:E("tests.question")})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{children:E("tests.question")})," ",S+1,"/",o.length]})}),g!=="review"&&u>=0?jsxRuntimeExports.jsx("div",{dir:"ltr",className:`count-down ${u<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{id:"test-time",children:[V<10?`0${V}`:V," : ",W<10?`0${W}`:W]})}):null]}),jsxRuntimeExports.jsx(Questions,{result:t,disabled:y,answered:f,updateForm:h,question:o[S],correctQuestions:y?x[o[S].id.substring(1)].answers:[],translate:E},o[S].id)]})}),jsxRuntimeExports.jsxs("div",{className:`test--buttons ${g==="review"?"reviewmode":"next"}`,children:[g==="review"?jsxRuntimeExports.jsx("button",{disabled:S===0,id:"back-button",onClick:()=>D(),type:"button",className:`gat--btn__navigation ${S===0?"disabled":""}`,"aria-label":LangIsRtl()?E("survey.next"):E("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}):null,!T&&o[S+1]?jsxRuntimeExports.jsx("button",{disabled:!f,id:"next-button",onClick:()=>k(),type:"button",className:`gat--btn__navigation ${f?"":"disabled"}`,"aria-label":LangIsRtl()?E("survey.previous"):E("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null,T?jsxRuntimeExports.jsx("button",{id:"next-button",onClick:()=>F(),type:"button",className:"gat--btn__navigation",children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null,!T&&o[S].id.substring(1)===(o.length-1).toString()?jsxRuntimeExports.jsx("button",{disabled:!f,id:"finish-button",onClick:()=>{O("click-ui"),f&&G()},type:"button",className:`gat--btn__navigation ${f?"":"disabled"}`,"aria-label":LangIsRtl()?E("survey.previous"):E("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null]})]})]})}function ResultsComponent({result:o,time:e,mandatory:r,correctQuestions:t,isFirst:n,reviewTest:a,finishTest:u,restartTest:l,timeOver:f,timeOverText:c,emitEvent:h,minimumPercentage:y}){const[E,p]=React$2.useState(0),[_,g]=React$2.useState(),[x,C]=React$2.useState([]),[R,S]=React$2.useState([]),[A,T]=React$2.useState([]),w=React$2.useCallback(()=>{const z=[];return t.forEach(U=>z.push(U.answers)),z},[t]),P=React$2.useCallback(()=>{const z=[];return Object.values(o).forEach(U=>{if(U.length>1){const I=U.find(B=>B.isCorrect===!1),$=[];I?z.push([]):(U.forEach(B=>{B.isCorrect&&$.push(B.id)}),z.push($))}else U[0].isCorrect?z.push([U[0].id]):U[0].isCorrect===!1&&z.push("")}),z},[o]),O=React$2.useCallback(()=>{let z=0;return R.length>0&&x.forEach((U,I)=>{U.length>1?U.every($=>R[I].includes($))&&(z+=1):U.length===1&&R[I]&&U[0]===R[I][0]&&(z+=1)}),z},[x,R]);React$2.useEffect(()=>{C(w),S(P),T(O)},[w,P,O]);const k=t.length,D=O()===k,F=A<y,G=A>=y,V=!r||G,W=Math.trunc(E/k*100),Z=(z,U)=>h({type:"translate",payload:z,values:U}),q={"--chart-color":"var(--color-error)"};return React$2.useEffect(()=>{if(E<A){const z=setInterval(()=>{p(U=>U+1)},100);return g(z),()=>{clearInterval(z)}}},[A,E]),React$2.useEffect(()=>{E>=A&&clearInterval(_)},[A,_,E]),jsxRuntimeExports.jsxs("div",{className:`test--results ${F||f?"test--results--failed":""}`,children:[n&&D?jsxRuntimeExports.jsxs("div",{className:"fireworks",children:[jsxRuntimeExports.jsx("div",{className:"before"}),jsxRuntimeExports.jsx("div",{className:"after"})]}):null,!f&&F?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:Z("tests.NotFinishedSuccessfully")})}):null,!f&&G||D?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:Z("tests.finishedSuccessfully")})}):null,f?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:c})}),jsxRuntimeExports.jsx("div",{className:"test--results__time",id:"results-time",children:jsxRuntimeExports.jsx("span",{children:Z("tests.time",e)})})]}):null,jsxRuntimeExports.jsxs("div",{className:`chart center chart${W}`,children:[jsxRuntimeExports.jsxs("div",{className:"chart-slice",children:[jsxRuntimeExports.jsx("div",{className:"chart-bar",style:F||f?q:{}}),jsxRuntimeExports.jsx("div",{className:"chart-fill",style:F||f?q:{}})]}),jsxRuntimeExports.jsxs("span",{className:"chart-value",children:[jsxRuntimeExports.jsxs("div",{className:"test--results__chart",children:[jsxRuntimeExports.jsx("span",{children:E}),jsxRuntimeExports.jsxs("span",{children:["/",k]})]}),jsxRuntimeExports.jsx("div",{className:"test--results__chart--label",children:jsxRuntimeExports.jsx("span",{children:Z("tests.success")})})]})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__minimum",children:[jsxRuntimeExports.jsx("div",{className:"icon-bell"}),jsxRuntimeExports.jsx("div",{children:Z("tests.minimumQuestionsMessage",{minimumPercentage:y})})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__buttons",children:[f?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__secondary",id:"review-button",onClick:()=>a(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.review")})}),V?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",id:"restart-button",onClick:()=>l(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.restart")})}),V?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",id:"finish-button",onClick:()=>u(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.continue")})}):null]})]})}function TestComponent({test:o,countdown:e={},emitEvent:r,soundActions:t,audio:n,required:a,pause:u,minimumPercentage:l=100,feedbacksOnlyWhenReview:f}){const{questions:c}=o,[h,y]=React$2.useState({}),[E,p]=React$2.useState(),[_,g]=React$2.useState(0),[x,C]=React$2.useState([]),[R,S]=React$2.useState(e.time),[A,T]=React$2.useState(!1),[w,P]=React$2.useState("test"),[O,k]=React$2.useState(!0),[D,F]=React$2.useState({}),[G,V]=React$2.useState({}),[W,Z]=React$2.useState(!1),q=a||o.required||!1,z=React$2.useRef({}),[U,I]=React$2.useState(),[$,B]=t,X=(ie,oe,fe,de,ce)=>{const Se={...ie,index:fe};if(_>0&&(Se.rewards=Se.rewards.filter(Ne=>!G[ie.id]||Ne.points<0)),h[oe]){const Ne=h[oe].find(We=>We.id===ce);if(Ne){if(Ne.id===ie.id){const We=h[oe].find(Qe=>Qe.id===ce),Ke=h[oe].indexOf(We);if(h[oe].splice(Ke,1),h[oe].length===0){T(!1);return}}}else h[oe].push(Se)}else h[oe]=[Se];let ke;de==="isRadio"?ke={...h,[oe]:[Se]}:ke={...h},y(ke),F(ke),V({...G,[ie.id]:{...ie}}),T(!0)};React$2.useEffect(()=>{n!=null&&n.url&&$(n.url,"tts")},[$,n]);const Q=c.map(ie=>{const oe=ie.answers.filter(de=>de.isCorrect),fe=[];return oe.forEach(de=>{fe.push(de.id)}),{question:ie.id,answers:fe}});React$2.useEffect(()=>{C(Q)},[Q]),React$2.useEffect(()=>{if(l){const ie=Math.ceil(c.length*l/100);I(ie)}},[c.length,l]),React$2.useEffect(()=>{R===0&&(clearInterval(E),T(!1),Z(!0),P("results"),B("tts"))},[E,B,R]);const J=()=>{clearInterval(E),T(!1),P("results");const ie={...D};F(ie),B("tts")},ne=()=>{const ie={correctQuestions:x.length,result:h,status:"resolved"};Object.keys(h).forEach(fe=>{h[fe].forEach(de=>{z.current[de.id]&&(de.rewards=[])})}),r({type:"saveTest",payload:ie})},se=()=>{const ie=()=>{F({}),V({}),P("test"),y({}),S(e.time),Z(!1),n!=null&&n.url&&$(n.url,"tts")},oe=Object.values(h);oe.forEach(de=>{de.forEach(ce=>{ce.isCorrect&&(z.current[ce.id]?ce.rewards=[]:z.current[ce.id]=!0)})});let fe=oe.reduce((de,ce)=>{const Se=[];return ce.forEach(ke=>{Se.push(ke.rewards)}),[...de,...Se.flat()]},[]);W&&e.rewards&&(fe=[...fe,...e.rewards]),r({type:"addPoints",payload:fe,complex:!0,finish:!1,onFinish:ie}),r({type:"failTest"})},ee=(ie,oe)=>r({type:"translate",payload:ie,values:oe});return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--container__overlay"}),jsxRuntimeExports.jsx("div",{className:"test--container",dir:"auto",children:w!=="results"?jsxRuntimeExports.jsx(Container,{result:h,time:R,setTries:g,tries:_,answerPage:T,setTime:S,paused:u,saveInterval:p,disabled:w!=="test",answered:A||w!=="test",questions:c,updateForm:X,showResults:J,translate:ee,soundActions:t,view:w,correctQuestions:x,feedbacksOnlyWhenReview:f}):jsxRuntimeExports.jsx(ResultsComponent,{reviewTest:()=>{k(!1),P("review")},isFirst:O,finishTest:ne,time:R,mandatory:q,restartTest:se,result:h,correctQuestions:x,timeOver:W,timeOverText:e.text,emitEvent:r,soundActions:t,minimumPercentage:U})})]})}const OPTIONS=["yes","no"],LETTERS=["A","B"];function ApplicableBox({setSurveyData:o,survey:e,id:r,translate:t,changePage:n}){const a=u=>{o({...e,[r]:u}),n()};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:OPTIONS.map((u,l)=>jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>a(u),className:`unset-button survey--response__item ${e[r]===u?"selected":""}`,children:[jsxRuntimeExports.jsx("div",{className:"survey--response__index",children:LETTERS[l]}),jsxRuntimeExports.jsx("div",{className:"survey--response__text",children:t(`survey.${u}`)})]},u))})}const OPINION_OPTIONS=[0,1,2,3,4,5,6,7,8,9,10];function OpinionBox({setSurveyData:o,survey:e,id:r,translate:t,changePage:n}){const a=u=>{o({...e,[r]:u}),n()};return jsxRuntimeExports.jsxs("div",{className:"survey--page__item","aria-label":"opinion box",children:[jsxRuntimeExports.jsx("div",{className:"survey--points",children:OPINION_OPTIONS.map(u=>jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>a(u),className:`unset-button survey--points__item ${e[r]===u?"selected":""}`,children:u},u))}),jsxRuntimeExports.jsxs("div",{className:"survey--points__labels",children:[jsxRuntimeExports.jsx("span",{children:t("survey.bad")}),jsxRuntimeExports.jsx("span",{children:t("survey.excellent")})]})]})}function TextBox({setSurveyData:o,survey:e,id:r,literalLabel:t}){const n=a=>{o({...e,[r]:a})};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:jsxRuntimeExports.jsx("textarea",{ref:a=>{a&&a.focus()},className:"survey--textarea",id:t,value:e[r],onChange:a=>n(a.target.value)})})}const INIT_SURVEY={applicable:"",opinion:"",comments:"",suggestions:""},PAGES=[{component:ApplicableBox,id:"applicable"},{component:OpinionBox,id:"opinion"},{component:TextBox,id:"comments"},{component:TextBox,id:"suggestions"}];function SurveyComponent({emitEvent:o,soundActions:e}){const[r,t]=React$2.useState(INIT_SURVEY),[n,a]=React$2.useState(0),[u,l]=React$2.useState(!1),[f]=e,c=(E,p)=>o({type:"translate",payload:E,values:p}),h=(E=!1)=>{if(f("click-ui"),!E&&n+1>=PAGES.length)l(!0);else{E&&l(!1);const p=E?n-1:n+1;a(p)}},y=PAGES[n].component;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"survey--container__overlay"}),jsxRuntimeExports.jsx("div",{className:"survey--container",dir:"auto",children:jsxRuntimeExports.jsxs("div",{className:"survey--questions",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__container",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("span",{children:c("survey.numQuestion",{init:n+1,page:PAGES.length})})}),jsxRuntimeExports.jsx("div",{children:c("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsx("label",{className:"survey--questions__item",htmlFor:c(`survey.question${n+1}`,{ordinal:n+1}),children:c(`survey.question${n+1}`,{ordinal:n+1})}),jsxRuntimeExports.jsx(y,{setSurveyData:t,id:PAGES[n].id,survey:r,translate:c,changePage:E=>h(!1),literalLabel:c(`survey.question${n+1}`,{ordinal:n+1})})]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next",children:[jsxRuntimeExports.jsx("button",{id:"survey-button-back",type:"button",disabled:n===0,onClick:()=>h(!0),className:`gat--btn__navigation ${n===0?"disabled":""}`,"aria-label":LangIsRtl()?c("survey.next"):c("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),u&&n===PAGES.length-1?jsxRuntimeExports.jsx("button",{id:"survey-button",type:"button",disabled:!r[PAGES[n].id],onClick:()=>{f("click-ui"),o({type:"saveSurvey",payload:r})},className:`gat--btn gat--btn__primary ${r[PAGES[n].id]?"":"disabled"} not-transition`,children:c("survey.finish")}):null,!u&&n!==PAGES.length?jsxRuntimeExports.jsx("button",{id:"survey-button",type:"button",disabled:!r[PAGES[n].id],onClick:()=>h(!1),className:`gat--btn__navigation ${r[PAGES[n].id]?"":"disabled"}`,"aria-label":LangIsRtl()?c("survey.previous"):c("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null]})]})})]})}function EndScreen({onFinish:o,translate:e}){return React$2.useEffect(()=>{let r;return o&&(r=setTimeout(()=>{o()},2e3)),()=>{r&&clearTimeout(r)}},[o]),jsxRuntimeExports.jsx("div",{className:"auto-evaluation__endscreen","aria-label":"auto evaluation endscreen",children:jsxRuntimeExports.jsxs("div",{className:"auto-evaluation__finishband","aria-label":"auto evaluation finishband",children:[jsxRuntimeExports.jsx("span",{className:"icon-check-laptop auto-evaluation__iconendscreen","aria-label":"icon-check",role:"img"}),jsxRuntimeExports.jsx("span",{className:"auto-evaluation__thanks","aria-label":"auto evaluation thanks",role:"contentinfo",children:e("auto-evaluation.thanks")})]})})}function StartScreen({onNext:o,description:e,translate:r}){return jsxRuntimeExports.jsxs("div",{className:"auto-evaluation__startscreen",role:"alertdialog","aria-modal":"true","aria-label":"ae start screen",children:[jsxRuntimeExports.jsx("span",{className:"icon-happy-laptop auto-evaluation__starticon","aria-label":"icon laptop",role:"img"}),jsxRuntimeExports.jsx("div",{className:"auto-evaluation__starttext","aria-label":"desciption",children:jsxRuntimeExports.jsx("span",{children:e})}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary auto-evaluation__button auto-evaluation__button--start",onClick:o,children:jsxRuntimeExports.jsx("span",{children:r("auto-evaluation.start")})})]})}function AutoEvaluation({description:o,questions:e,type:r,emitEvent:t,soundActions:n}){var A,T,w;const[a,u]=React$2.useState(null),[l,f]=React$2.useState("start"),[c,h]=React$2.useState(!1),[y,E]=React$2.useState(0),[p,_]=React$2.useState({current:{questions:[],type:r}}),[g]=n,x=P=>t({type:"translate",payload:P}),C=P=>{P.keyCode===13&&P.target.blur()},R=()=>{g("click-ui"),t({type:"saveSurveyPrePos",payload:p.current})};React$2.useEffect(()=>{!e.length&&l==="questions"&&f("end")},[e,l]);const S=(P,O=!1)=>{var D;const k=P!==null?P:(D=p.current.questions.find(F=>F.id===e[y].id))==null?void 0:D.answer;if(g("click-ui"),O)E(y-1),h(!1);else{const F=p.current.questions.findIndex(V=>V.id===e[y].id),G=[...p.current.questions];F>-1?G.splice(F,1,{id:e[y].id,answer:k}):G.push({id:e[y].id,answer:k}),_({...p,current:{...p.current,questions:G}}),y===e.length-1?h(!0):(E(y+1),h(!1))}};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--container__overlay","aria-label":"test container overlay"}),jsxRuntimeExports.jsxs("div",{className:"test--container",dir:"auto","aria-label":"test container",children:[l==="start"&&jsxRuntimeExports.jsx(StartScreen,{description:o,onNext:()=>{f("questions"),g("click-ui")},translate:x}),l==="questions"&&jsxRuntimeExports.jsxs("div",{className:"survey--questions","aria-label":"survey questions",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__container","aria-label":"survey questions container",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsxs("span",{children:[x("auto-evaluation.question")," ",y+1," ",x("storylines.misc.of")," ",e.length]})}),jsxRuntimeExports.jsx("div",{children:x("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"survey--questions__item","aria-label":"survey questions item",children:(A=e[y])==null?void 0:A.text}),jsxRuntimeExports.jsx("div",{className:"survey--page__item","aria-label":"survey page item",children:jsxRuntimeExports.jsx("div",{className:"survey--points","aria-label":"survey points",children:Array(11).fill(0).map((P,O)=>{var k;return jsxRuntimeExports.jsx("button",{type:"button",onTouchStart:()=>{u(O)},onTouchEnd:()=>{u(null)},onKeyUp:D=>{C(D)},onClick:()=>{S(O,!1)},className:`survey--points__item ${((k=p.current.questions[y])==null?void 0:k.answer)===O||a===O?"selected":""}`,children:O},`${0+O}`)})})})]},`${e[y]}`)]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next","aria-label":"test buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",disabled:y===0,onClick:()=>S(null,!0),"aria-label":LangIsRtl()?x("survey.next"):x("survey.previous"),className:`gat--btn__navigation ${y===0?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back","aria-label":"icon button"})}),c?jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{f("end"),g("click-ui")},className:`gat--btn gat--btn__primary auto-evaluation__button not-transition
252
+ `,EMPTY_PROPS={};function applyNodeProps(o,e,r=EMPTY_PROPS){if(!zIndexWarningShowed&&"zIndex"in e&&(console.warn(Z_INDEX_WARNING),zIndexWarningShowed=!0),!dragWarningShowed&&e.draggable){var t=e.x!==void 0||e.y!==void 0,n=e.onDragEnd||e.onDragMove;t&&!n&&(console.warn(DRAGGABLE_WARNING),dragWarningShowed=!0)}for(var a in r)if(!propsToSkip[a]){var u=a.slice(0,2)==="on",l=r[a]!==e[a];if(u&&l){var f=a.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),o.off(f,r[a])}var c=!e.hasOwnProperty(a);c&&o.setAttr(a,void 0)}var h=e._useStrictMode,y={},E=!1;const p={};for(var a in e)if(!propsToSkip[a]){var u=a.slice(0,2)==="on",_=r[a]!==e[a];if(u&&_){var f=a.substr(2).toLowerCase();f.substr(0,7)==="content"&&(f="content"+f.substr(7,1).toUpperCase()+f.substr(8)),e[a]&&(p[f]=e[a])}!u&&(e[a]!==r[a]||h&&e[a]!==o.getAttr(a))&&(E=!0,y[a]=e[a])}E&&(o.setAttrs(y),updatePicture(o));for(var f in p)o.on(f+EVENTS_NAMESPACE,p[f])}function updatePicture(o){if(!Global.Konva.autoDrawEnabled){var e=o.getLayer()||o.getStage();e&&e.batchDraw()}}var schedulerExports=requireScheduler();const NO_CONTEXT={},UPDATE_SIGNAL={};Konva.Node.prototype._applyProps=applyNodeProps;function appendInitialChild(o,e){if(typeof e=="string"){console.error(`Do not use plain text as child of Konva.Node. You are using text: ${e}`);return}o.add(e),updatePicture(o)}function createInstance(o,e,r){let t=Konva[o];t||(console.error(`Konva has no node with the type ${o}. Group will be used instead. If you use minimal version of react-konva, just import required nodes into Konva: "import "konva/lib/shapes/${o}" If you want to render DOM elements as part of canvas tree take a look into this demo: https://konvajs.github.io/docs/react/DOM_Portal.html`),t=Konva.Group);const n={},a={};for(var u in e){var l=u.slice(0,2)==="on";l?a[u]=e[u]:n[u]=e[u]}const f=new t(n);return applyNodeProps(f,a),f}function createTextInstance(o,e,r){console.error(`Text components are not supported for now in ReactKonva. Your text is: "${o}"`)}function finalizeInitialChildren(o,e,r){return!1}function getPublicInstance(o){return o}function prepareForCommit(){return null}function preparePortalMount(){return null}function prepareUpdate(o,e,r,t){return UPDATE_SIGNAL}function resetAfterCommit(){}function resetTextContent(o){}function shouldDeprioritizeSubtree(o,e){return!1}function getRootHostContext(){return NO_CONTEXT}function getChildHostContext(){return NO_CONTEXT}const scheduleTimeout=setTimeout,cancelTimeout=clearTimeout,noTimeout=-1;function shouldSetTextContent(o,e){return!1}const isPrimaryRenderer=!1,warnsIfNotActing=!0,supportsMutation=!0;function appendChild(o,e){e.parent===o?e.moveToTop():o.add(e),updatePicture(o)}function appendChildToContainer(o,e){e.parent===o?e.moveToTop():o.add(e),updatePicture(o)}function insertBefore(o,e,r){e._remove(),o.add(e),e.setZIndex(r.getZIndex()),updatePicture(o)}function insertInContainerBefore(o,e,r){insertBefore(o,e,r)}function removeChild(o,e){e.destroy(),e.off(EVENTS_NAMESPACE),updatePicture(o)}function removeChildFromContainer(o,e){e.destroy(),e.off(EVENTS_NAMESPACE),updatePicture(o)}function commitTextUpdate(o,e,r){console.error(`Text components are not yet supported in ReactKonva. You text is: "${r}"`)}function commitMount(o,e,r){}function commitUpdate(o,e,r,t,n){applyNodeProps(o,n,t)}function hideInstance(o){o.hide(),updatePicture(o)}function hideTextInstance(o){}function unhideInstance(o,e){(e.visible==null||e.visible)&&o.show()}function unhideTextInstance(o,e){}function clearContainer(o){}function detachDeletedInstance(){}const getCurrentEventPriority=()=>constantsExports.DefaultEventPriority,HostConfig=Object.freeze(Object.defineProperty({__proto__:null,appendChild,appendChildToContainer,appendInitialChild,cancelTimeout,clearContainer,commitMount,commitTextUpdate,commitUpdate,createInstance,createTextInstance,detachDeletedInstance,finalizeInitialChildren,getChildHostContext,getCurrentEventPriority,getPublicInstance,getRootHostContext,hideInstance,hideTextInstance,idlePriority:schedulerExports.unstable_IdlePriority,insertBefore,insertInContainerBefore,isPrimaryRenderer,noTimeout,now:schedulerExports.unstable_now,prepareForCommit,preparePortalMount,prepareUpdate,removeChild,removeChildFromContainer,resetAfterCommit,resetTextContent,run:schedulerExports.unstable_runWithPriority,scheduleTimeout,shouldDeprioritizeSubtree,shouldSetTextContent,supportsMutation,unhideInstance,unhideTextInstance,warnsIfNotActing},Symbol.toStringTag,{value:"Module"}));var __defProp=Object.defineProperty,__defProps=Object.defineProperties,__getOwnPropDescs=Object.getOwnPropertyDescriptors,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(o,e,r)=>e in o?__defProp(o,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):o[e]=r,__spreadValues=(o,e)=>{for(var r in e||(e={}))__hasOwnProp.call(e,r)&&__defNormalProp(o,r,e[r]);if(__getOwnPropSymbols)for(var r of __getOwnPropSymbols(e))__propIsEnum.call(e,r)&&__defNormalProp(o,r,e[r]);return o},__spreadProps=(o,e)=>__defProps(o,__getOwnPropDescs(e));function traverseFiber(o,e,r){if(!o)return;if(r(o)===!0)return o;let t=e?o.return:o.child;for(;t;){const n=traverseFiber(t,e,r);if(n)return n;t=e?null:t.sibling}}function wrapContext(o){try{return Object.defineProperties(o,{_currentRenderer:{get(){return null},set(){}},_currentRenderer2:{get(){return null},set(){}}})}catch{return o}}const FiberContext=wrapContext(React__namespace.createContext(null));class FiberProvider extends React__namespace.Component{render(){return React__namespace.createElement(FiberContext.Provider,{value:this._reactInternals},this.props.children)}}const{ReactCurrentOwner,ReactCurrentDispatcher}=React__namespace.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function useFiber(){const o=React__namespace.useContext(FiberContext);if(o===null)throw new Error("its-fine: useFiber must be called within a <FiberProvider />!");const e=React__namespace.useId();return React__namespace.useMemo(()=>{for(const t of[ReactCurrentOwner==null?void 0:ReactCurrentOwner.current,o,o==null?void 0:o.alternate]){if(!t)continue;const n=traverseFiber(t,!1,a=>{let u=a.memoizedState;for(;u;){if(u.memoizedState===e)return!0;u=u.next}});if(n)return n}},[o,e])}function useContextMap(){var o,e;const r=useFiber(),[t]=React__namespace.useState(()=>new Map);t.clear();let n=r;for(;n;){const a=(o=n.type)==null?void 0:o._context;a&&a!==FiberContext&&!t.has(a)&&t.set(a,(e=ReactCurrentDispatcher==null?void 0:ReactCurrentDispatcher.current)==null?void 0:e.readContext(wrapContext(a))),n=n.return}return t}function useContextBridge(){const o=useContextMap();return React__namespace.useMemo(()=>Array.from(o.keys()).reduce((e,r)=>t=>React__namespace.createElement(e,null,React__namespace.createElement(r.Provider,__spreadProps(__spreadValues({},t),{value:o.get(r)}))),e=>React__namespace.createElement(FiberProvider,__spreadValues({},e))),[o])}function usePrevious(o){const e=React$2.useRef({});return React$2.useLayoutEffect(()=>{e.current=o}),React$2.useLayoutEffect(()=>()=>{e.current={}},[]),e.current}const StageWrap=o=>{const e=React$2.useRef(),r=React$2.useRef(),t=React$2.useRef(),n=usePrevious(o),a=useContextBridge(),u=l=>{const{forwardedRef:f}=o;f&&(typeof f=="function"?f(l):f.current=l)};return React$2.useLayoutEffect(()=>(r.current=new Konva.Stage({width:o.width,height:o.height,container:e.current}),u(r.current),t.current=KonvaRenderer.createContainer(r.current,constantsExports.LegacyRoot,!1,null),KonvaRenderer.updateContainer(React$2.createElement(a,{},o.children),t.current),()=>{Konva.isBrowser&&(u(null),KonvaRenderer.updateContainer(null,t.current,null),r.current.destroy())}),[]),React$2.useLayoutEffect(()=>{u(r.current),applyNodeProps(r.current,o,n),KonvaRenderer.updateContainer(React$2.createElement(a,{},o.children),t.current,null)}),React$2.createElement("div",{ref:e,id:o.id,accessKey:o.accessKey,className:o.className,role:o.role,style:o.style,tabIndex:o.tabIndex,title:o.title})},Layer="Layer",Group="Group",Rect="Rect",Line="Line",Image$2="Image",Text="Text",KonvaRenderer=ReactFiberReconciler(HostConfig);KonvaRenderer.injectIntoDevTools({findHostInstanceByFiber:()=>null,bundleType:process.env.NODE_ENV!=="production"?1:0,version:React$2.version,rendererPackageName:"react-konva"});const Stage=React$2.forwardRef((o,e)=>React$2.createElement(FiberProvider,{},React$2.createElement(StageWrap,{...o,forwardedRef:e})));var client={},m=require$$0;if(process.env.NODE_ENV==="production")client.createRoot=m.createRoot,client.hydrateRoot=m.hydrateRoot;else{var i=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;client.createRoot=function(o,e){i.usingClientEntryPoint=!0;try{return m.createRoot(o,e)}finally{i.usingClientEntryPoint=!1}},client.hydrateRoot=function(o,e,r){i.usingClientEntryPoint=!0;try{return m.hydrateRoot(o,e,r)}finally{i.usingClientEntryPoint=!1}}}var __rest=globalThis&&globalThis.__rest||function(o,e){var r={};for(var t in o)Object.prototype.hasOwnProperty.call(o,t)&&e.indexOf(t)<0&&(r[t]=o[t]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,t=Object.getOwnPropertySymbols(o);n<t.length;n++)e.indexOf(t[n])<0&&Object.prototype.propertyIsEnumerable.call(o,t[n])&&(r[t[n]]=o[t[n]]);return r};const needForceStyle=o=>{const e=window.getComputedStyle(o).position;return!(e==="absolute"||e==="relative")};function useEvent(o=()=>{}){const e=React$2.useRef(o);return e.current=o,React$2.useCallback((...r)=>e.current.apply(null,r),[])}const Html=({children:o,groupProps:e,divProps:r,transform:t,transformFunc:n})=>{const a=React$2.useRef(null);React$2.useRef();const[u]=React$2.useState(()=>document.createElement("div")),l=React$2.useMemo(()=>client.createRoot(u),[u]),f=t??!0,c=useEvent(()=>{if(f&&a.current){let _=a.current.getAbsoluteTransform().decompose();n&&(_=n(_)),u.style.position="absolute",u.style.zIndex="10",u.style.top="0px",u.style.left="0px",u.style.transform=`translate(${_.x}px, ${_.y}px) rotate(${_.rotation}deg) scaleX(${_.scaleX}) scaleY(${_.scaleY})`,u.style.transformOrigin="top left"}else u.style.position="",u.style.zIndex="",u.style.top="",u.style.left="",u.style.transform="",u.style.transformOrigin="";const h=r||{},{style:y}=h,E=__rest(h,["style"]);Object.assign(u.style,y),Object.assign(u,E)});return React$2.useLayoutEffect(()=>{var h;const y=a.current;if(!y)return;const E=(h=y.getStage())===null||h===void 0?void 0:h.container();if(E)return E.appendChild(u),f&&needForceStyle(E)&&(E.style.position="relative"),y.on("absoluteTransformChange",c),c(),()=>{var p;y.off("absoluteTransformChange",c),(p=u.parentNode)===null||p===void 0||p.removeChild(u)}},[f]),React$2.useLayoutEffect(()=>{c()},[r,n]),React$2.useLayoutEffect(()=>{l.render(o)}),React$2.useLayoutEffect(()=>()=>{setTimeout(()=>{l.unmount()})},[]),React$2.createElement(Group,Object.assign({ref:a},e))};function Area({area:o,finished:e,isClicked:r,isBad:t,hasHighlights:n,completed:a,onClick:u,onClickOutside:l}){const f=React$2.useRef(),[c,h]=React$2.useState(),y=t?"rgba(255, 99, 77, 0.32)":"rgba(75, 215, 169, 0.32)",E=t?"#ff634d":"#4bd7a9",p=DeviceDetection(),_=()=>{var S,A,T;n&&!a&&!r&&((S=f.current)==null||S.setAttr("fill","rgba(130, 134, 142, 0.4)"),(A=f.current)==null||A.setAttr("stroke","rgba(255, 255, 255, 0.3)"),(T=f.current)==null||T.to({duration:.25,opacity:1}))},g=()=>{var S;n&&!a&&!r&&((S=f.current)==null||S.to({duration:.25,opacity:0}))};React$2.useEffect(()=>{var S,A,T;a&&!e&&(t?(T=f.current)==null||T.to({duration:.25,opacity:0}):((S=f.current)==null||S.to({duration:.25,opacity:1}),(A=f.current)==null||A.globalCompositeOperation("destination-out")))},[a,e,t]);const x=()=>{var S,A;a||(t?l(o):u(o),(S=f.current)==null||S.setAttr("fill",y),(A=f.current)==null||A.setAttr("stroke",E))},C=o.scaleX?o.scaleX:1,R=o.scaleY?o.scaleY:1;return React$2.useLayoutEffect(()=>{const S=f.current.getStage();S.on("stage-loaded",()=>{const A=f.current.getClientRect({relativeTo:f.current.getParent()});h({x:A.x+A.width/2,y:A.y+A.height/2}),S.batchDraw()})},[o]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[c?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...c},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:o.id})}):null,jsxRuntimeExports.jsx(Line,{name:o.id,ref:f,onFocus:()=>_(),onMouseOver:()=>_(),onMouseLeave:g,onClick:()=>x(),onTap:()=>x(),x:o.x,y:o.y,scale:{x:C,y:R},skew:{x:o.skewX,y:o.skewY},rotation:o.rotation,points:o.points,shape:"poly",fill:e?"":y,stroke:e||r?E:"",strokeWidth:p?10:4,opacity:e||r?1:0,closed:!0})]})}Area.defaultProps={finished:!1,isBad:!1,isClicked:!1,hasHighlights:!1,completed:!1,onClick:()=>{},onClickOutside:()=>{}};const useWindowSize=()=>{const[o,e]=React$2.useState([0,0]);return React$2.useLayoutEffect(()=>{function r(){e([window.innerWidth,window.innerHeight])}return window.addEventListener("resize",r),r(),()=>window.removeEventListener("resize",r)},[]),o};function KonvaMapper({areas:o,badAreas:e,imageUrl:r,completed:t,onClick:n,onClickOutside:a,hasHighlights:u,clickedZones:l}){const f=React$2.useRef(),c=React$2.useRef(),h=React$2.useRef(),y=React$2.useRef(),E=React$2.useRef(),p=React$2.useRef(),_=React$2.useRef(),[g,x]=React$2.useState(new window.Image),[C,R]=useWindowSize(),S=e.find(w=>w.id==="AllArea")||!1,A=e.filter(w=>w.id!=="AllArea");React$2.useEffect(()=>{_.current&&c.current&&t&&(_.current.to({duration:.25,opacity:.5}),c.current.setAttr("visible",!0))},[t]);const T=w=>{S&&!w.target.attrs.shape&&a(S)};return React$2.useEffect(()=>{g.src=r,g.addEventListener("load",()=>{if(f.current){const w={x:C/2,y:R/2,width:g.width,height:g.height,offsetX:g.width/2,offsetY:g.height/2,scale:{x:Math.min(C/g.width,R/g.height),y:Math.min(C/g.width,R/g.height)}};y.current&&y.current.setAttrs(w),E.current&&E.current.setAttrs(w),c.current&&c.current.setAttrs(w),h.current&&h.current.setAttrs(w),p.current&&p.current.setAttrs(w),f.current.batchDraw(),x(g),f.current.fire("stage-loaded")}})},[g,R,r,C]),jsxRuntimeExports.jsxs(Stage,{ref:f,width:C,height:R,onClick:T,onTouchEnd:T,children:[jsxRuntimeExports.jsx(Layer,{children:jsxRuntimeExports.jsx(Image$2,{ref:p,image:g})}),jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Rect,{ref:_,width:C,height:R,fill:"black",opacity:0}),jsxRuntimeExports.jsx(Group,{ref:E,children:A.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:u,completed:t,onClick:n,onClickOutside:a,area:w,isBad:!0},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:y,children:o.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:u,completed:t,onClick:n,onClickOutside:a,area:w,isClicked:l.some(O=>O.index===w.index)},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:h,visible:!1,children:A.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:u,completed:t,onClick:n,onClickOutside:a,area:w,isBad:!0,finished:!0},w.name+"_"+P))}),jsxRuntimeExports.jsx(Group,{ref:c,visible:!1,children:o.map((w,P)=>jsxRuntimeExports.jsx(Area,{hasHighlights:u,completed:t,onClick:n,onClickOutside:a,area:w,finished:!0},w.name+"_"+P))})]})]})}KonvaMapper.defaultProps={hasHighlights:!1,onClick:()=>{},completed:!1,onClickOutside:()=>{}};function TimerDialog({retry:o,translate:e,onInit:r}){return jsxRuntimeExports.jsx("div",{className:"timer-dialog",children:jsxRuntimeExports.jsxs("div",{className:"timer-dialog__container",children:[jsxRuntimeExports.jsx("div",{className:"timer-dialog__title",children:e("storylines.misc.ready")}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:r,children:jsxRuntimeExports.jsx("span",{children:e(o?"storylines.misc.start":"storylines.misc.retry")})})]})})}function CountDown({time:o}){const e=Math.floor(o/60),r=o%60;return jsxRuntimeExports.jsx("div",{className:`count-down count-down--in-puzzle-frame ${o<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{children:[e<10?`0${e}`:e," : ",r<10?`0${Math.floor(r)}`:Math.floor(r)]})})}const defaultImg="https://min.gamelearn.io/css-resources/gamelearn/resources/puzzle-login-low.png";function ImageReview(){return jsxRuntimeExports.jsx("div",{className:"puzzle--image__preview",children:jsxRuntimeExports.jsx("img",{alt:"img",src:"https://min.gamelearn.io/css-resources/gamelearn/resources/image-click.jpg"})})}function ImageClickWrapperComponent(o){var ye,Oe;const{soundActions:e,emitEvent:r,handleClick:t,disableExit:n,setResolveAction:a,info:u,image:l,areas:f,badAreas:c,hasClickOrder:h,timer:y,hasClickOnce:E,hasHighlights:p,hasImageReview:_,defaultCompleted:g,className:x,emitFinish:C,emitResolve:R,translateFromParent:S,specificFeedbacks:A,slideNumber:T,emitResetPuzzle:w,firstTryForFrame:P,puzzlesAutoCompleted:O,emitOpenPopupCounterInfo:k,pause:D,keyboardControl:F}=o,[G,V]=React$2.useState([]),[W,Z]=React$2.useState(!1),[q,z]=React$2.useState(!1),[U,I]=React$2.useState({show:!1,success:!1,text:"",rewards:[]}),$=React$2.useRef(!1),[B,X]=React$2.useState(!0),[Q,J]=React$2.useState(!1),ne=React$2.useRef(null),se=React$2.useRef(null),ee=React$2.useRef(null),ie=React$2.useRef(null),oe=React$2.useRef(null),fe=React$2.useRef(null),de=React$2.useRef(null),ce=React$2.useRef(null),Se=React$2.useRef(null),[ke,Ne]=React$2.useState(y),We=Ge=>S?S(Ge):r({type:"translate",payload:Ge}),[Ke]=e,{solution:Qe}=u,pt=l.img.url||defaultImg,vt=f.map((Ge,nt)=>({index:nt,shape:"poly",...Ge})),ct=c.map((Ge,nt)=>({index:nt,shape:"poly",...Ge})),mt=React$2.useCallback(()=>{if(!B){const Ge=setInterval(()=>{Ne(nt=>nt>1?nt-1:0)},1e3);Se.current=Ge}},[B]),Vt=React$2.useCallback((Ge,nt)=>{C?C(Ge,nt):r({type:"addPoints",payload:Ge})},[r,C]);React$2.useEffect(()=>{W&&n(!0)},[W,n]),React$2.useEffect(()=>{Z(g)},[g]);const kt=React$2.useCallback(()=>{clearInterval(ee.current)},[]),Ie=React$2.useCallback(()=>{clearInterval(Se.current)},[]),et=React$2.useCallback(Ge=>{oe.current=Date.now(),ie.current?(de.current=ie.current-oe.current,kt()):(de.current=oe.current-(oe.current-Ge*1e3),kt())},[kt]),at=React$2.useCallback(()=>{I(()=>{var Ge,nt;return{show:!0,success:!1,text:(Ge=u==null?void 0:u.timerFeedback)!=null&&Ge.desc?u.timerFeedback.desc:"",rewards:(nt=u==null?void 0:u.timerFeedback)==null?void 0:nt.rewards}}),J(!0),Ie(),kt()},[Ie,kt,(ye=u.timerFeedback)==null?void 0:ye.desc,(Oe=u.timerFeedback)==null?void 0:Oe.rewards]),Kt=React$2.useCallback(()=>{clearInterval(ee.current),ee.current=setInterval(()=>{se.current=Date.now(),se.current>ie.current&&at()},250)},[at]);React$2.useEffect(()=>{var Ge;if((f.length===G.length||E&&G.length>0)&&!W){Z(!0);const nt=G[G.length-1],je=A==null?void 0:A.correctFeedbacks.find(Ee=>Ee.id===nt.id);(!((Ge=A==null?void 0:A.correctFeedbacks)!=null&&Ge.length)||A!=null&&A.correctFeedbacks.some(Ee=>!Ee.desc)||E)&&(I(Ee=>({...Ee,show:!0,success:!0,text:je?je.desc:u.solution.right.desc,rewards:je?je.rewards:u.solution.right.rewards})),y&&(Ie(),et()))}},[G,f.length,A,E,W,u.solution.right,et,y,Ie]),React$2.useEffect(()=>{a(Ge=>{y&&(Ie(),X(!1),U.show?I(nt=>({...nt,show:!1,success:!1,text:"",rewards:[]})):kt()),Z(!0),z(!0),setTimeout(()=>{R?R(Ge):Ge()},4e3)})},[a,R,Ke,y,U.show,kt,Ie]),React$2.useEffect(()=>{q&&n(!0)},[q,n]);const Xe=(Ge,nt=!1)=>{var je,Ee;if(!W){const{rewards:Be,desc:qe}=Qe.wrong;let He=qe,ht=Be;const $t=(je=A==null?void 0:A.wrongFeedbacks)==null?void 0:je.find(Lt=>Lt.id===Ge.id);$t&&(He=$t.desc,ht=$t.rewards),h&&(V([]),nt&&(Ee=u==null?void 0:u.orderFeedback)!=null&&Ee.desc&&(He=u.orderFeedback.desc,ht=u.orderFeedback.rewards)),y&&(Ie(),et()),I(Lt=>({...Lt,show:!0,success:!1,text:He,rewards:ht})),Ke("fail")}},it=React$2.useCallback(()=>{fe.current=Date.now();const Ge=fe.current+de.current;se.current=null,ie.current=Ge,(y||Q)&&(U.success?f.length===G.length||E&&G.length>0?Ie():(Ne(de.current*.001),mt(),Kt()):(V([]),X(!0),w())),Vt(U.rewards,U.success),Ke("click-ui"),I(nt=>({...nt,show:!1,success:!1,text:"",rewards:[]}))},[y,Q,Vt,U.rewards,U.success,Ke,f.length,G.length,E,w,Ie,mt,Kt]),pe=Ge=>{var nt,je;if(!G.some(Ee=>Ee.index===Ge.index)&&!U.show&&!W){Ke("click-ui");let Ee=Qe.right.desc,{rewards:Be}=Qe.right;const qe=[...G,Ge];if(h&&Ge.index===G.length||!h){if(y&&et(ke),t(),(nt=A==null?void 0:A.correctFeedbacks)!=null&&nt.length){const He=(je=A.correctFeedbacks)==null?void 0:je.find(ht=>ht.id===Ge.id);He&&(Ee=He.desc,Be=He.rewards),!Ee&&f.length>qe.length&&!E?Vt(Be,!0):Ee&&!E&&(I(ht=>({...ht,show:!0,success:!0,text:Ee,rewards:Be})),y&&Ie())}V(qe)}else Xe(Ge,!0)}},ge=React$2.useCallback(()=>{Ie(),Ne(y),mt(),!$.current&&P&&k(),X(!1),ne.current=Date.now(),ie.current=ne.current+y*1e3,Kt()},[Ie,y,mt,P,Kt,k]);return React$2.useEffect(()=>{y&&T>0&&!ce.current&&(P&&Object.keys(O).length&&O[T-1]?(X(!0),ce.current=!0):X(!1))},[g,P,O,T,y]),React$2.useEffect(()=>{y&&ke===0&&at()},[ke,at,y]),React$2.useEffect(()=>{y&&(D?(Ie(),et()):mt())},[Ie,Kt,D,et,mt,y]),jsxRuntimeExports.jsxs("div",{className:x,children:[U.show?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:Ke,text:U.text,success:U.success,translate:We,hasTimeout:!U.text,delay:y?1e3:2e3,functionOnClose:it,timeExpired:Q,keyboardControl:F}):null,jsxRuntimeExports.jsx(KonvaMapper,{completed:W,imageUrl:pt,areas:E&&G.length?[G[0]]:vt,badAreas:ct,clickedZones:G,onClick:pe,onClickOutside:Xe,hasHighlights:p,emitEvent:r}),_?jsxRuntimeExports.jsx(ImageReview,{}):null,y&&B?jsxRuntimeExports.jsx(TimerDialog,{retry:P||O[T-1],translate:We,onInit:ge}):null,y?jsxRuntimeExports.jsx(CountDown,{time:ke}):null]})}ImageClickWrapperComponent.defaultProps={info:{instructions:"",resolve:{},solution:{},hint:{},title:""},badAreas:[],className:"puzzle--image__click",hasClickOrder:!1,hasClickOnce:!1,hasHighlights:!1,hasImageReview:!1,defaultCompleted:!1,hideContinue:!1,emitAreaClick:()=>{},handleClick:()=>{}};function ImageClickPuzzleComponent(o){const e=(r,t)=>{t?(o.emitEvent({type:"addPoints",complex:!0,finish:!0,payload:r}),o.emitEvent({type:"passPuzzle"})):(o.emitEvent({type:"addPoints",payload:r,finish:!1}),o.emitEvent({type:"failPuzzle"}))};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...o,emitFinish:e,name:"image-click-puzzle"})}const GREEN="#44d7ab",ORANGE="#FFB34B",RED="#FF634D",getDistance=(o,e)=>Math.max(Math.abs(o[0]-e[0]),Math.abs(o[1]-e[1])),generatePasswordPositions=(o,e,r,t)=>{const n=[],a=o;for(const u of e.toLowerCase()){const l=Math.floor(Math.random()*r),f=Math.floor(Math.random()*t);a[l][f].value=u,n.push({char:u,position:[l,f]})}return[a,n]},paintedGridPassword=(o,e,r,t)=>{const n=o;for(let a=0;a<e;a+=1)for(let u=0;u<r;u+=1)switch(t.reduce((f,c)=>{const h=[a,u],y=getDistance(c.position,h);return y<f?y:f},9999)){case 0:n[a][u].hiddenColor=GREEN;break;case 1:n[a][u].hiddenColor=ORANGE;break;case 2:n[a][u].hiddenColor=RED;break}return n},resetColors=(o,e,r)=>{const t=r;for(let n=0;n<o;n+=1)for(let a=0;a<e;a+=1)t[n][a].color="",t[n][a].hiddenColor=RED;return t},repaintGridPassword=(o,e,r,t)=>{const n=resetColors(r,t,o),[a,u]=generatePasswordPositions(n,e,r,t);return paintedGridPassword(a,r,t,u)},prepareAcceptedChars=(o,e)=>e.split("").filter(r=>!o.includes(r)).join(""),generateBasicGrid=(o,e,r)=>{const t=[];for(let n=0;n<o;n+=1){const a=[];for(let u=0;u<e;u+=1){const l={color:"",hiddenColor:RED,value:r[Math.floor(Math.random()*r.length)]};a.push(l)}t.push(a)}return t},makeSomeNoise=({numberOfColumns:o,numberOfRows:e,password:r})=>{const t=LangIsRtl()?"٠١٢٣٤٥٦٧٨٩شزذيثبلاهتنمورخحضقسفعدصطغظ":"0123456789abcdefghijklmnopqrstuvwxyz",n=prepareAcceptedChars(r,t),a=generateBasicGrid(e,o,n),[u,l]=generatePasswordPositions(a,r,e,o);return paintedGridPassword(u,e,o,l)};function DrawItem({item:o,rowIndex:e,columnIndex:r,setCursorPosition:t,cursorPosition:n}){const a=Math.abs(e-n[0])<3&&Math.abs(r-n[1])<3;return jsxRuntimeExports.jsx("span",{className:"puzzle--cracker__item",style:{backgroundColor:`${a?o.hiddenColor:o.color}`,flexGrow:1,textAlign:"center"},onMouseOver:()=>{t([e,r])},onFocus:()=>{t([e,r])},children:o.value})}DrawItem.defaultProps={setCursorPosition:()=>{}};DrawItem.propTypes={item:PropTypes.shape({color:PropTypes.string,hiddenColor:PropTypes.string,value:PropTypes.string}).isRequired,rowIndex:PropTypes.number.isRequired,columnIndex:PropTypes.number.isRequired,cursorPosition:PropTypes.arrayOf(PropTypes.number).isRequired,setCursorPosition:PropTypes.func};function DrawRow({row:o,rowIndex:e,setCursorPosition:r,cursorPosition:t}){return o.length?jsxRuntimeExports.jsx("div",{className:"puzzle--cracker",children:o.map((n,a)=>jsxRuntimeExports.jsx(DrawItem,{item:n,rowIndex:e,columnIndex:a,setCursorPosition:r,cursorPosition:t},a))}):null}DrawRow.defaultProps={row:[]};DrawRow.propTypes={row:PropTypes.arrayOf(PropTypes.shape({})),rowIndex:PropTypes.number.isRequired,setCursorPosition:PropTypes.func.isRequired,cursorPosition:PropTypes.arrayOf(PropTypes.number).isRequired};function DrawGrid({grid:o,cursorPosition:e,setCursorPosition:r}){return jsxRuntimeExports.jsx("div",{className:"puzzle--cracker__canvas",children:o.map((t,n)=>jsxRuntimeExports.jsx(DrawRow,{row:t,rowIndex:n,cursorPosition:e,setCursorPosition:r},n))})}DrawGrid.defaultProps={setCursorPosition:()=>{}};const VELOCITY_MAP={slow:2,fast:5,fastest:10},DIFFICULTY_MAP={easy:{visibleRows:"auto",visibleColumns:40,totalRows:25},medium:{visibleRows:"auto",visibleColumns:40,totalRows:40},hard:{visibleRows:"auto",visibleColumns:40,totalRows:80}};function CrackerPuzzleComponent({emitEvent:o,soundActions:e,info:r,velocity:t,password:n,disableExit:a,difficulty:u,setResolveAction:l}){const[f]=e,c=X=>o({type:"translate",payload:X}),h=React$2.useRef(),y=React$2.useRef(),{solution:E}=r,[p,_]=React$2.useState(n.toLowerCase()),[g,x]=React$2.useState(),[C,R]=React$2.useState(Array(n.toLowerCase().length).fill("")),[S,A]=React$2.useState(!1),[T,w]=React$2.useState([0,0]),P=c("puzzle.cracker.crackedPassword"),O=r.solution.right.desc&&r.solution.right.desc!==""?r.solution.right.desc:"",k=c("puzzle.cracker.congratulations"),[D,F]=React$2.useState([[]]),{visibleRows:G,visibleColumns:V}=DIFFICULTY_MAP[u];let W=G==="auto"?Math.ceil(window.innerHeight*.025):G;W=W>=20?W:20,React$2.useEffect(()=>{S&&a(!0)},[S,a]),React$2.useEffect(()=>{l(X=>{f("score"),A(!0),setTimeout(()=>{o({type:"hidePuzzleButtons",payload:!1}),X()},0)})},[l,f]);const Z=()=>{f("click-ui");const{rewards:X}=E.right;o({type:"addPoints",complex:!0,finish:!0,payload:X}),o({type:"passPuzzle"})},q=()=>n.toLowerCase().split("").map((Q,J)=>({char:Q,index:J,used:!1})),z=X=>X.filter(Q=>Q.used===!1).map(Q=>Q.char).join(""),U=X=>{if(X[0].length>0&&!S){const Q=[...X];return Q.push(Q.shift()),Q}return X};let I=0;const $=X=>{if(y.current!==void 0){const Q=X-y.current;I+=Q,I>1e3/VELOCITY_MAP[t]&&(F(U),I=0)}y.current=X,h.current=requestAnimationFrame($)};React$2.useEffect(()=>{_(n.toLowerCase());const X=makeSomeNoise({numberOfColumns:V,numberOfRows:W,password:n.toLowerCase()});return F(X),x(q()),h.current=requestAnimationFrame($),()=>cancelAnimationFrame(h.current)},[]);const B=()=>{if(D.length<=1)return;const[X,Q]=T,J=D[X][Q];if(J.hiddenColor===GREEN){const ne=g.filter(se=>se.char===J.value.toLowerCase()&&se.used===!1)[0];if(ne){const{index:se}=ne;f("score");const ee=g;ee[se].used=!0,x(ee);const ie=[...C];ie[se]=J.value;const oe=z(ee);_(oe);const fe=repaintGridPassword(D,oe,W,V);F(fe),R(ie)}}p<=0&&(f("score"),A(!0))};return React$2.useEffect(()=>{S||B()},[T]),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:C.map((X,Q)=>jsxRuntimeExports.jsx("span",{className:"puzzle--pieces__item",children:X&&jsxRuntimeExports.jsx("span",{className:"character success-transition-animation","data-testid":`solution${Q}`,children:X})},`${X+Q}`))})]}),jsxRuntimeExports.jsx(DrawGrid,{grid:S?[[]]:D,cursorPosition:T,setCursorPosition:w}),S&&P&&k&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs(Typist,{avgTypingDelay:110,cursor:{hideWhenDone:!0},className:"puzzle--cracker__result",children:[jsxRuntimeExports.jsx(Typist.Delay,{ms:300}),jsxRuntimeExports.jsxs("span",{children:[`${P} ${n.toLowerCase()}`," "]}),jsxRuntimeExports.jsxs("span",{children:[k," "]}),O!==""&&jsxRuntimeExports.jsx("span",{children:O})]}),jsxRuntimeExports.jsx("div",{className:"position--absolute bottom center",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary gat--btn__cracker",onClick:Z,children:c("screens.continue")})})]})]})}CrackerPuzzleComponent.defaultProps={velocity:"slow",difficulty:"easy",context:{},info:{}};const ARABIC=/[\u0600-\u06FF]/,restrictCharacters=(o,e)=>{let r=!1;return e==="or"&&(r=o===""||o===" "||o===","||o==="."||o==="/"),e==="and"&&(r=o&&o!==" "&&o!==","&&o!=="."&&o!==""&&o!=="/"),r},sortChar=(o,e)=>o.char>e.char?1:o.char<e.char?-1:0,analyzeChars=o=>{const e={anyArabic:!1,anyNumber:!1,anyWestern:!1};for(let r=0;r<o.length;r+=1){const t=o[r].charCodeAt(0);t>=65&&t<=90?e.anyWestern=!0:t>=48&&t<=57?e.anyNumber=!0:ARABIC.test(o[r])&&(e.anyArabic=!0)}return e},makeChar=o=>{const e="شزذيثبلاهتنمورخحضثقسفعدصطغظ",r="ABCDEFGHIJKLMNOPQRSTUVWXYZ",t="0123456789";let n="";return o.anyWestern&&(n+=r),o.anyNumber&&(n+=t),o.anyArabic&&(n+=e),n.charAt(Math.floor(Math.random()*n.length))},MAX_POOL_LETTERS=26,MAX_EXTRA_LETTERS=8,AnswerPanel=({answer:o,flickerPosition:e,show:r=!1,showCorrectSolution:t})=>{const n=[];let a=0;return o.forEach(u=>{n[a]||(n[a]=[]),n[a]=[...n[a],u],u.char===" "&&(a+=1),t||(u.positionInitial=u.index)}),n.map((u,l)=>jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__word","data-testid":`result-${l}`,children:r?u.map((f,c)=>jsxRuntimeExports.jsx("span",{className:"puzzle--hanged__letter active",children:f},`${f+c}`)):u.filter(({char:f})=>f!==" ").map(({char:f,fixed:c},h)=>jsxRuntimeExports.jsx("span",{className:`puzzle--hanged__letter ${c?"":"active"} ${u[h].positionInitial===e?"fakeFocus":""}`,children:f},`${f+h}`))},`${u+l}`))},defaultImage="https://min.gamelearn.io/css-resources/gamelearn/resources/partenon.jpg";function HangedPuzzleComponent({soundActions:o,emitEvent:e,disableExit:r,question:t,image:n,info:a,answer:u,hintUsed:l,setResolveAction:f,setHintAction:c,keyboardControl:h}){var fe;const[y]=o,E=((fe=n.img)==null?void 0:fe.url)||defaultImage,[p,_]=React$2.useState(0),[g,x]=React$2.useState(!1),[C,R]=React$2.useState([]),[S,A]=React$2.useState(!1),[T,w]=React$2.useState([]),[P,O]=React$2.useState(""),[k,D]=React$2.useState(!1),[F,G]=React$2.useState([]),[V,W]=React$2.useState(!1),Z=u.toUpperCase().split(""),q=Z.filter(de=>restrictCharacters(de,"and")),z=de=>e({type:"translate",payload:de}),U=React$2.useCallback(()=>{const de=q.map(ke=>({char:ke}));let ce=[];const Se=analyzeChars(q);for(;ce.length<MAX_EXTRA_LETTERS;){const ke=makeChar(Se);ce=[...ce,{char:ke}]}return[...de,...ce]},[q]),I=u.toUpperCase().split("").map((de,ce)=>restrictCharacters(de,"or")?{index:ce,letter:de,char:de,fixed:!0}:{index:ce,letter:de,char:""}),$=React$2.useCallback(()=>{let de=U();for(;de.length>MAX_POOL_LETTERS;){const ce=Math.trunc(Math.random()*(de.length-1))+1,Se=de[ce],ke=I.find((Ne,We)=>Se.char===Ne.letter&&!I[We].fixed);ke&&(de.splice(ce,1),I[ke.index]={...ke,char:ke.letter,fixed:!0})}l&&(de=[],I.forEach(({letter:ce})=>{ce!==" "&&de.push({char:ce})})),w(I),R(de)},[I,l,U]),B=(de,ce)=>C.map((ke,Ne)=>Ne===ce?{...ke,deleted:!0}:{...ke}),X=(de,ce,Se)=>{const ke=ce.map((We,Ke)=>Se.find(pt=>pt.poolIndex===Ke)?{char:We.char}:We);R(ke),w(de);const Ne=de.find(We=>We.char==="");_(Ne.index)},Q=(de,ce)=>{y("click-ui");let Se=!1;const ke=T.map(Ke=>!Ke.char&&!Se?(Se=!0,{...Ke,char:de,poolIndex:ce}):Ke),Ne=B(de,ce),We=ke.filter(Ke=>Ke.char).length;R(Ne),w(ke),J(),We===T.length&&ie(ke,Ne)},J=()=>{var de;if(g){const ce=T.find(Se=>Se.index!==p&&Se.letter!==" "&&Se.char===""&&Se.poolIndex===!1);ce&&_(ce.index)}else{const ce=T.find(Se=>Se.char==="");_(ce.index+1),((de=T[ce.index+1])==null?void 0:de.letter)===" "&&_(ce.index+2)}},ne=()=>{y("click-ui");const de=T.map((ce,Se)=>T[T.length-1-Se]).find(ce=>ce.char&&!ce.fixed);if(de){const ce=T.map(Ne=>Ne.index===de.index?{...de,char:""}:Ne);let Se=!1;const ke=C.map((Ne,We)=>We===de.poolIndex&&(Ne.deleted||!Se)?(Se=!0,{char:Ne.char}):Ne);R(ke),w(ce),_(de.index)}},se=()=>{r(!0),O("");const de=[...F,...a.solution.right.rewards];y("score"),e({type:"hidePuzzleButtons",payload:!1}),e({type:"addPoints",complex:!0,finish:!0,payload:de}),e({type:"passPuzzle"})},ee=()=>{y("fail"),e({type:"hidePuzzleButtons",payload:!1}),G([...F,...a.solution.wrong.rewards]),O(""),D(!1),e({type:"failPuzzle"}),x(!0)},ie=(de,ce)=>{let Se=[];D(!0);const ke=de.map((We,Ke)=>Z[Ke]===We.char?{...We,fixed:!0}:(Se=[...Se,We],{...We,poolIndex:!1,char:""})),Ne=ke.filter(We=>We.fixed).length;e({type:"hidePuzzleButtons",payload:!0}),Ne===Z.length?(O("success"),a.solution.right.desc===""&&setTimeout(()=>{se()},2e3)):(O("failed"),X(ke,ce,Se),a.solution.wrong.desc===""&&setTimeout(()=>{ee()},2e3))},oe=()=>{if(P==="success")se();else{ee();const de=T.find(ce=>ce.char==="");_(de.index)}};return React$2.useEffect(()=>{S||(A(!0),$()),f(de=>{W(!0),setTimeout(()=>{e({type:"hidePuzzleButtons",payload:!1}),de()},2e3)}),c(de=>{const ce=[];I.forEach(({letter:Se})=>{Se!==" "&&ce.push({char:Se})}),R(ce),de()})},[$,S,u,f,e,F,a.resolve.rewards,I,c]),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged",style:{backgroundImage:`url("${E}")`},children:[P?jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:y,text:a.solution[P==="success"?"right":"wrong"].desc,success:P==="success",translate:z,functionOnClose:oe,keyboardControl:h}):null,jsxRuntimeExports.jsx("div",{className:"puzzle--hanged__content",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__controls",children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--hanged__header",children:t}),jsxRuntimeExports.jsx("div",{dir:"auto",className:`puzzle--hanged__solution ${P}`,"data-testid":`${P}`,children:V?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:V,answer:u.split(""),show:!0})}):jsxRuntimeExports.jsx(AnswerPanel,{showCorrectSolution:V,flickerPosition:p,answer:T})}),jsxRuntimeExports.jsxs("div",{className:"puzzle--hanged__keyboard",children:[C.sort((de,ce)=>sortChar(de,ce)).map((de,ce)=>jsxRuntimeExports.jsx("button",{"data-testid":`key-${de.char}`,type:"button",onClick:()=>{!de.deleted&&!P&&!k&&(Q(de.char,ce),y("click-ui"))},className:`puzzle--hanged__keyboard--item ${de.deleted||k?"disabled":""}`,children:de.char},`${de+ce}`)),jsxRuntimeExports.jsx("button",{onClick:k?null:()=>ne(),type:"button",disabled:k?"disabled":null,"aria-label":z("puzzles.hanged-puzzle.deleteButton"),className:`puzzle--hanged__keyboard--item delete ${k?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:"icon-delete-keyboard"})})]})]})})]})}HangedPuzzleComponent.defaultProps={question:"",answer:"",image:{},hintBought:!1,info:{description:"",instructions:"",resolve:{},solution:{},hintBought:{}}};function CurrentImageClickPuzzle({list:o,description:e,nodeId:r,setInfo:t,emitEvent:n,disableExit:a,setResolveAction:u,soundActions:l,setSelected:f,selected:c,pause:h,loadPuzzleStatus:y,index:E,setIndex:p,slidesCompleted:_,setSlidesCompleted:g,keyboardControl:x,totalCorrects:C}){const R=React$2.useRef([]),S=React$2.useRef(0),A=React$2.useRef(0),T=`chained-image-click-puzzle_${E}_${r}`,[w]=l,P=Z=>{R.current=[...R.current,...Z]},O=React$2.useCallback(Z=>{w("score"),n({type:"hidePuzzleButtons",payload:!1}),n({type:"addPoints",complex:!0,finish:!0,payload:[...R.current,...Z]}),n({type:"passPuzzle"})},[w,n]),k=o[E],{info:D,specificFeedbacks:F}=k;D.description=e,React$2.useEffect(()=>{S.current=0,A.current=0},[E]);const G=React$2.useCallback((Z,q=!1)=>{var U;let z={..._};if(q){if((U=F==null?void 0:F.correctFeedbacks)!=null&&U.length&&!k.hasClickOnce)S.current+=1;else{let I=c;A.current&&(I-=A.current),S.current=k.areas.length,f(I+S.current)}S.current===k.areas.length&&(E+1>=o.length?O(Z):p(E+1),z={...z,[E]:!0},g(z)),P(Z)}else n({type:"addPoints",payload:Z,finish:!1}),n({type:"failPuzzle"}),k.hasClickOrder&&(f(c-S.current),S.current===0&&Object.entries(_).length===0?f(0):S.current=0),Object.entries(_).length===0&&k.hasClickOrder&&!c&&f(0)},[_,F,k.hasClickOnce,k.areas.length,k.hasClickOrder,c,f,E,o.length,g,O,p,n]),V=()=>{E>=o.length-1&&f(C),w("score"),n({type:"puzzleAction",action:"resolve",payload:{element:T,rewards:D.resolve.rewards,finish:E+1>=o.length}})};React$2.useEffect(()=>{t({...D,hintId:T})},[D,T,t]),React$2.useEffect(()=>{y&&E!==o.length-1&&G([],!0)},[E,o.length,y,G]);const W=()=>{const Z=k.hasClickOnce?k.areas.length:1;A.current+=Z,f(c+Z)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...k,puzzle:{name:T,component:"chained-image-click-puzzle"},specificFeedbacks:F,emitFinish:G,emitError:P,emitResolve:V,isLast:E+1===o.length,defaultCompleted:_[E]||!!y,hideContinue:E+1!==o.length,handleClick:W,emitEvent:n,disableExit:a,soundActions:l,setResolveAction:u,pause:h,keyboardControl:x},E)}function ChainedImageClickPuzzleComponent(o){const{setInfo:e,emitEvent:r,nodeId:t,list:n,description:a,soundActions:u,showFrames:l,disableExit:f,setResolveAction:c,keyboardControl:h}=o,[y,E]=React$2.useState(0),[p,_]=React$2.useState(0),[g,x]=React$2.useState({}),C=`chained-image-click-puzzle_${p}_${t}`,R=React$2.useMemo(()=>r({type:"loadObjectStatus",payload:C}),[r,C]),S=n.reduce((T,w)=>T+w.areas.length,0),A={list:n,description:a,nodeId:t,disableExit:f,setResolveAction:c,emitEvent:r,soundActions:u,setInfo:e,setSelected:E,selected:y,index:p,setIndex:_,slidesCompleted:g,setSlidesCompleted:x,loadPuzzleStatus:R,keyboardControl:h,totalCorrects:S};return jsxRuntimeExports.jsxs("div",{className:"puzzle--image__click",children:[l?jsxRuntimeExports.jsxs("div",{className:"puzzle-image__info",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[y," / ",S]})]}):null,jsxRuntimeExports.jsx(CurrentImageClickPuzzle,{...A})]})}function CurrentFramePuzzle({list:o,index:e,puzzlesCompiledRef:r,framesCompleted:t,handleFinish:n,setRewards:a,setIndex:u,setFramesCompleted:l,loadPuzzleStatus:f,soundActions:c,setResolveAction:h,disableExit:y,description:E,translateFromParent:p,setInfo:_,emitEvent:g,nodeId:x,setSelected:C,selected:R,emitResetPuzzle:S,firstTryForFrame:A,setPuzzlesAutoCompleted:T,puzzlesAutoCompleted:w,emitOpenPopupCounterInfo:P,resetValues:O,setResetValues:k,pause:D,keyboardControl:F,totalCorrects:G}){var J;const[V]=c,W=o[e],{info:Z,specificFeedbacks:q}=W;Z.description=E;const z=React$2.useRef(0),U=React$2.useRef(0),I=`frame-image-click-puzzle_${e}_${x}`;React$2.useEffect(()=>{r.current+=1},[r]),React$2.useEffect(()=>{_({...Z,hintId:I})},[_,Z,I]),React$2.useEffect(()=>{O&&(U.current=0,z.current=0,C(0),k(!1))},[O,k,C]),React$2.useEffect(()=>{U.current=0,z.current=0},[e]);const $=React$2.useCallback((ne,se=!1)=>{var ie;let ee={...t};if(se){if((ie=q==null?void 0:q.correctFeedbacks)!=null&&ie.length&&!W.hasClickOnce)U.current+=1;else{let oe=R;z.current&&(oe-=z.current),U.current=W.areas.length,w[0]&&Object.entries(t).length===0?C(U.current):C(oe+U.current)}U.current===W.areas.length&&(e+1>=o.length&&n(ne),ee={...ee,[e]:!0},l(ee),u(e+1>o.length-1?0:e+1)),a(ne)}else g({type:"addPoints",payload:ne,finish:!1}),g({type:"failPuzzle"}),W.hasClickOrder&&(C(R-U.current),U.current=0)},[t,(J=q==null?void 0:q.correctFeedbacks)==null?void 0:J.length,W.hasClickOnce,W.areas.length,W.hasClickOrder,a,R,w,C,e,o.length,l,u,n,g]),B=React$2.useCallback(()=>{e>=o.length-1&&C(G),V("score"),g({type:"hidePuzzleButtons",payload:!1}),T(ne=>({...ne,[e]:!0})),g({type:"puzzleAction",action:"resolve",payload:{element:I,rewards:Z.resolve.rewards,finish:e+1>=o.length}})},[e,o.length,V,g,T,I,Z.resolve.rewards,C,G]),X=React$2.useCallback(()=>{l({}),U.current=0,z.current=0,S()},[S,l]);React$2.useEffect(()=>{f&&e!==o.length-1&&$([],!0)},[t,e,o.length,f,$]);const Q=()=>{const ne=W.hasClickOnce?W.areas.length:1;z.current+=ne,C(R+ne)};return jsxRuntimeExports.jsx(ImageClickWrapperComponent,{...W,className:"puzzle-frame__canvas",puzzle:{name:"",component:"frame-click-puzzle"},specificFeedbacks:q,emitFinish:$,emitResolve:B,hideContinue:!0,disableInfo:r.current>1,defaultCompleted:t[e]||!!f,soundActions:c,setResolveAction:h,disableExit:y,translateFromParent:p,emitEvent:g,slideNumber:e,handleClick:Q,emitResetPuzzle:X,firstTryForFrame:A,puzzlesAutoCompleted:w,emitOpenPopupCounterInfo:P,pause:D,keyboardControl:F},e)}function Tooltip({emitEvent:o}){const e=r=>o({type:"translate",payload:r});return jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle-frame__info--tooltip",children:e("puzzles.counterTooltip")})}function Counter({current:o,total:e,tooltip:r,emitEvent:t}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[r?jsxRuntimeExports.jsx(Tooltip,{emitEvent:t}):null,jsxRuntimeExports.jsxs("div",{className:"puzzle-frame__info--frames",children:[jsxRuntimeExports.jsx("span",{className:"info-circle"}),jsxRuntimeExports.jsxs("span",{children:[o," / ",e]})]})]})}function FrameImageClickComponent({emitEvent:o,nodeId:e,list:r,description:t,showFrames:n,soundActions:a,disableExit:u,setResolveAction:l,setInfo:f,pause:c,keyboardControl:h}){const[y,E]=React$2.useState({}),p=React$2.useRef([]),[_,g]=React$2.useState(0),[x,C]=React$2.useState({}),[R,S]=React$2.useState(0),A=React$2.useRef(0),[T,w]=React$2.useState(!0),[P,O]=React$2.useState(!0),[k,D]=React$2.useState(!1),F=r.reduce((B,X)=>B+X.areas.length,0),G=B=>{p.current=[...p.current,...B]},V=`frame-image-click-puzzle_${_}_${e}`,W=React$2.useMemo(()=>o({type:"loadObjectStatus",payload:V}),[o,V]),Z=React$2.useCallback(B=>{o({type:"addPoints",complex:!0,finish:!0,payload:[...p.current,...B]}),o({type:"passPuzzle"})},[o]),q=React$2.useCallback(()=>{O(!1),p.current=[],S(0),g(0),C({}),w(!0),D(!0)},[]),z=B=>o({type:"translate",payload:B}),U=()=>{w(!0)},$={firstTryForFrame:P,list:r,description:t,index:_,puzzlesCompiledRef:A,framesCompleted:x,handleFinish:Z,setRewards:G,accRewards:p,setSelected:S,selected:R,setIndex:g,setFramesCompleted:C,loadPuzzleStatus:W,soundActions:a,setResolveAction:l,disableExit:u,translateFromParent:z,setInfo:f,emitEvent:o,nodeId:e,emitResetPuzzle:q,resetValues:k,setResetValues:D,setPuzzlesAutoCompleted:E,puzzlesAutoCompleted:y,emitOpenPopupCounterInfo:()=>{_===0&&w(!1)},pause:c,keyboardControl:h,totalCorrects:F};return jsxRuntimeExports.jsxs("div",{className:"puzzle-frame",children:[jsxRuntimeExports.jsx(CurrentFramePuzzle,{...$}),jsxRuntimeExports.jsxs("div",{className:"puzzle-frame__content",children:[jsxRuntimeExports.jsx("div",{className:"puzzle-frame__controls",children:jsxRuntimeExports.jsx("div",{className:"puzzle-frame__progress",children:jsxRuntimeExports.jsx("div",{style:{width:`${R/F*100}%`},className:"puzzle-frame__progress--handle"})})}),n?jsxRuntimeExports.jsx("button",{disabled:T,"aria-hidden":T,type:"button",className:"puzzle-frame__info",onClick:U,children:jsxRuntimeExports.jsx(Counter,{current:R,total:F,tooltip:!T,emitEvent:o})}):null]})]})}FrameImageClickComponent.defaultProps={description:"",context:{},nodeId:0,showFrames:!1};function EditButton({action:o,className:e}){return jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,"aria-label":`${o} edit button`,onKeyUp:()=>{},className:`puzzle--webBuilder__edit ${e}`,onClick:o,children:jsxRuntimeExports.jsx("span",{className:"icon-fb-edit"})})}EditButton.defaultProps={action:()=>{},className:""};const path="https://min.gamelearn.io/css-resources/gamelearn/resources/",imagesOptions=[{name:"webbuilder.imageOptions.image1",src:"Amor.jpg"},{name:"webbuilder.imageOptions.image2",src:"Bancorp.svg"},{name:"webbuilder.imageOptions.image3",src:"Amanda.jpg"},{name:"webbuilder.imageOptions.image4",src:"keyboard.jpg"},{name:"webbuilder.imageOptions.image5",src:"Melanie.jpg"},{name:"webbuilder.imageOptions.image6",src:"Sharon.jpg"},{name:"webbuilder.imageOptions.image7",src:"Bankex.svg"},{name:"webbuilder.imageOptions.image8",src:"Futbol.jpg"},{name:"webbuilder.imageOptions.image9",src:"GBL.svg"},{name:"webbuilder.imageOptions.image10",src:"Fooder.jpg"},{name:"webbuilder.imageOptions.image11",src:"Corporate.jpg"},{name:"webbuilder.imageOptions.image12",src:"Bank of Zamunda.svg"},{name:"webbuilder.imageOptions.image13",src:"mindfullness.jpg"},{name:"webbuilder.imageOptions.image14",src:"Nature.jpg"},{name:"webbuilder.imageOptions.image15",src:"Shopper.jpg"},{name:"webbuilder.imageOptions.image16",src:"Lab.jpg"}],colorOptions=["#c66a46","#3c9dc0","#6236ff","#21254f"],colorOptions2=["#39b7b9","#25a1d4","#f5a623","#080269"],titleOptions=[{title:"webbuilder.bank.titleOptions.title1.text",desc:"webbuilder.bank.titleOptions.title1.description"},{title:"webbuilder.bank.titleOptions.title2.text",desc:"webbuilder.bank.titleOptions.title2.description"},{title:"webbuilder.bank.titleOptions.title3.text",desc:"webbuilder.bank.titleOptions.title3.description"},{title:"webbuilder.bank.titleOptions.title4.text",desc:"webbuilder.bank.titleOptions.title4.description"},{title:"webbuilder.bank.titleOptions.title5.text",desc:"webbuilder.bank.titleOptions.title5.description"}],bankProps={backgroundImage:imagesOptions[10].src,backgroundLogo:imagesOptions[11].src,backgroundColor:"#21254f",btnColor:"#25a1d4"},BankTemplate={header:{color:bankProps.backgroundColor,logo:bankProps.backgroundLogo},body:{bankTitle:titleOptions[0].title,bankDesc:titleOptions[0].desc,bgImage:bankProps.backgroundImage,btnColor:bankProps.btnColor}};function BankHeader({showingReference:o,usingTemplate:e,openPopup:r,onSave:t,header:n,translate:a}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[o?jsxRuntimeExports.jsx("div",{className:"bank--edit__logo",children:jsxRuntimeExports.jsx("img",{src:path+e.header.logo,alt:"",title:""})}):jsxRuntimeExports.jsxs("div",{className:"bank--edit__logo",children:[n.logo?jsxRuntimeExports.jsx("img",{src:path+n.logo,alt:"",title:""}):jsxRuntimeExports.jsxs("span",{children:[jsxRuntimeExports.jsx("b",{children:a("webbuilder.bank.header.title")}),jsxRuntimeExports.jsx("b",{children:a("webbuilder.bank.header.logo")})]}),jsxRuntimeExports.jsx(EditButton,{action:()=>r("PopupImageComponent",{text:"Documents",images:imagesOptions,onSave:u=>t({logo:u})})})]}),jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsxs("ul",{className:"bank--navigation",children:[jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.account")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.invest")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.loans")}),jsxRuntimeExports.jsx("li",{className:"bank-navigation__item",children:a("webbuilder.bank.header.mortgage")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>r("PopupColorComponent",{colors:colorOptions,onSave:u=>t({color:u})})})]})]})}BankHeader.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},header:{}};BankHeader.propTypes={showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),openPopup:PropTypes.func,onSave:PropTypes.func,header:PropTypes.shape({})};function FacebookHeader({showingReference:o,usingTemplate:e,header:r,translate:t}){const n=o?e.header.userImage:r.userImage,a=o?e.header.username:r.username;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{className:"facebook--header__logo",children:jsxRuntimeExports.jsx("span",{className:"icon-fb-logo"})}),jsxRuntimeExports.jsxs("span",{className:"facebook--header__user",children:[jsxRuntimeExports.jsx("span",{className:"facebook--header__user--circle",style:{backgroundImage:`url(${path+n})`}}),jsxRuntimeExports.jsx("span",{className:"facebook--header__user--text",children:t(a||"webbuilder.facebook.header.userName")})]})]})}FacebookHeader.defaultProps={showingReference:!1,usingTemplate:{},header:{}};function WebBuilderHeader(o){const{isFacebook:e,header:r,showingReference:t,usingTemplate:n}=o,a=t?n.header.color:r.color;return jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__header ${e?"":"bank"}`,style:e?{}:{backgroundColor:`${a}`},children:jsxRuntimeExports.jsx("div",{className:`${e?"facebook":"bank"}--header`,children:e?jsxRuntimeExports.jsx(FacebookHeader,{...o}):jsxRuntimeExports.jsx(BankHeader,{...o})})})}WebBuilderHeader.defaultProps={isFacebook:!1,showingReference:!1,usingTemplate:{},header:{}};WebBuilderHeader.propTypes={isFacebook:PropTypes.bool,showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),header:PropTypes.shape({})};const facebookProps={backgroundImage:imagesOptions[12].src,backgroundUser:imagesOptions[5].src},userOptions=["webbuilder.userOptions.user1","webbuilder.userOptions.user2","webbuilder.userOptions.user3"],workOptions=["webbuilder.workOptions.work1","webbuilder.workOptions.work2","webbuilder.workOptions.work3"],studiesOptions=["webbuilder.studiesOptions.study1","webbuilder.studiesOptions.study2","webbuilder.studiesOptions.study3"],mailOptions=["webbuilder.mailOptions.mail1","webbuilder.mailOptions.mail2","webbuilder.mailOptions.mail3"],homeOptions=["webbuilder.homeOptions.home1","webbuilder.homeOptions.home2","webbuilder.homeOptions.home3"],FacebookTemplate={header:{username:userOptions[1],userImage:facebookProps.backgroundUser,bgImage:facebookProps.backgroundImage},body:{work:workOptions[2],home:homeOptions[1],studies:studiesOptions[0],mail:mailOptions[0]}};function WebBuilderFront({showingReference:o,usingTemplate:e,header:r,onSave:t,translate:n,openPopup:a}){const u=o?e.header.userImage:r.userImage,l=o?e.header.username:r.username,f=o?e.header.bgImage:r.bgImage;return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__front",style:{backgroundImage:`url(${path+f})`},children:[jsxRuntimeExports.jsxs("div",{className:"facebook--user",children:[jsxRuntimeExports.jsx("span",{className:"facebook--user__circle",style:{backgroundImage:`url(${path+u})`},children:o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupImageComponent",{images:imagesOptions,onSave:c=>t({userImage:c})})}})}),jsxRuntimeExports.jsx("span",{className:"facebook--user__text",children:n(l||"webbuilder.facebook.header.userName")}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{a("PopupTextComponent",{options:userOptions,onSave:c=>t({username:c})})}})]}),o?null:jsxRuntimeExports.jsx(EditButton,{className:"position--absolute right top",action:()=>{a("PopupImageComponent",{images:imagesOptions,onSave:c=>t({bgImage:c})})}})]})}WebBuilderFront.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},header:{}};WebBuilderFront.propTypes={showingReference:PropTypes.bool,usingTemplate:PropTypes.shape({}),openPopup:PropTypes.func,onSave:PropTypes.func,header:PropTypes.shape({})};function FacebookBody({showingReference:o,usingTemplate:e,body:r,onSave:t,openPopup:n,translate:a}){const u=o?e.body.work:r.work,l=o?e.body.studies:r.studies,f=o?e.body.home:r.home,c=o?e.body.mail:r.mail;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("ul",{className:"facebook--sidebar",dir:"auto",children:[jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${u||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-work"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(u||"webbuilder.facebook.body.work")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:workOptions,onSave:h=>t({work:h})})}})]}),jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${l||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-education"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(l||"webbuilder.facebook.body.studies")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:studiesOptions,onSave:h=>t({studies:h})})}})]}),jsxRuntimeExports.jsxs("li",{className:`facebook--sidebar__item ${f||o?"selected":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-home"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(f||"webbuilder.facebook.body.home")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:homeOptions,onSave:h=>t({home:h})})}})]})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--board",children:[jsxRuntimeExports.jsx("div",{className:"facebook--mail__label",children:"E-mail"}),jsxRuntimeExports.jsxs("div",{className:`facebook--mail__box ${c||o?"active":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"flex align-center",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-mail"}),jsxRuntimeExports.jsx("span",{className:"text",children:a(c||"webbuilder.facebook.body.email")})]}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:mailOptions,onSave:h=>t({mail:h})})}})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs",children:[jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-edit"}),a("webbuilder.facebook.body.editPost")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-photo"}),a("webbuilder.facebook.body.editPhoto")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-video"}),a("webbuilder.facebook.body.liveVideo")]}),jsxRuntimeExports.jsxs("div",{className:"facebook--tabs__item",children:[jsxRuntimeExports.jsx("span",{className:"icon-fb-events"}),a("webbuilder.facebook.body.facebookEvent")]})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--thinking",children:[jsxRuntimeExports.jsxs("div",{className:"facebook--textarea",children:[jsxRuntimeExports.jsx("div",{className:"facebook--textarea__circle"}),jsxRuntimeExports.jsx("div",{className:"facebook--textarea__placeholder",children:a("webbuilder.facebook.body.think")})]}),jsxRuntimeExports.jsxs("div",{className:"facebook--chips",children:[jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.photo")}),jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.label")}),jsxRuntimeExports.jsx("span",{className:"facebook--chips__item",children:a("webbuilder.facebook.body.feeling")})]})]})]})]})}FacebookBody.defaultProps={showingReference:!1,usingTemplate:{},openPopup:()=>{},onSave:()=>{},body:{}};function BankBody({showingReference:o,usingTemplate:e,body:r,onSave:t,openPopup:n,translate:a}){const u=o?e.body.bgImage:r.bgImage,l=o?e.body.btnColor:r.btnColor,f=a(o?e.body.bankTitle:"webbuilder.bank.body.image.title"),c=a(o?e.body.bankDesc:"webbuilder.bank.body.image.description");return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"bank--image__front",style:{backgroundImage:`url(${path+u})`},children:jsxRuntimeExports.jsxs("div",{className:"bank--image__text",children:[jsxRuntimeExports.jsx("span",{className:"title",children:r.bankTitle&&!o?a(r.bankTitle):f}),jsxRuntimeExports.jsx("span",{children:r.bankDesc&&!o?a(r.bankDesc):c}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupTextComponent",{options:titleOptions,onSave:h=>t({bankTitle:h.title,bankDesc:h.desc})})}}),o?null:jsxRuntimeExports.jsx(EditButton,{className:"position--absolute top right",action:()=>{n("PopupImageComponent",{images:imagesOptions,onSave:h=>t({bgImage:h})})}})]})}),jsxRuntimeExports.jsx("div",{dir:"auto",className:"bank--sidebar",children:jsxRuntimeExports.jsxs("div",{className:"bank--form",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__title",children:a("webbuilder.bank.body.password.title")}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.current")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.new")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__group",children:[jsxRuntimeExports.jsx("div",{className:"bank--form__label",children:a("webbuilder.bank.body.password.confirm")}),jsxRuntimeExports.jsx("input",{disabled:!0,className:"bank--form__input",type:"password",placeholder:"********"}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check"})]}),jsxRuntimeExports.jsxs("div",{className:"bank--form__buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"bank--form__btn",style:{backgroundColor:`${l}`},children:a("webbuilder.save")}),o?null:jsxRuntimeExports.jsx(EditButton,{action:()=>{n("PopupColorComponent",{colors:colorOptions2,onSave:h=>t({btnColor:h})})}})]})]})})]})}function WebBuilderBody(o){const{isFacebook:e}=o;return jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__body ${e?"":"bank"}`,children:e?jsxRuntimeExports.jsx(FacebookBody,{...o}):jsxRuntimeExports.jsx(BankBody,{...o})})}WebBuilderBody.defaultProps={isFacebook:!1};WebBuilderBody.propTypes={isFacebook:PropTypes.bool};function CurrentButton({translate:o,backActive:e,action:r}){return jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__topbar--buttons",children:jsxRuntimeExports.jsx("button",{type:"button",className:"puzzle--webBuilder__topbar--buttons__item",onClick:r,children:o(`webbuilder.${e?"return":"showReference"}`)})})}function WebBuilderTopBar({backActive:o,displayButton:e,clickAction:r,translate:t}){return jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__topbar",children:[e?jsxRuntimeExports.jsx(CurrentButton,{backActive:o,action:r,translate:t}):null,jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__title",children:"web builder 3.0"})]})}function FeedbackResult({onNext:o,success:e,showButton:r,translate:t}){const n=t(e?"webbuilder.feedback.successTitle":"webbuilder.feedback.failTitle"),a=t(e?"webbuilder.feedback.success":"webbuilder.feedback.fail");return jsxRuntimeExports.jsxs("div",{dir:"auto",className:`puzzle--webBuilder__feedback bottom ${e?"success":"failed"}`,style:e?{zIndex:"11"}:{},children:[jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"title",children:n}),jsxRuntimeExports.jsx("div",{className:"description",children:a})]}),r?jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__secondary ${e?"green":"red"}`,onClick:o,style:{marginRight:"64px"},children:t("webbuilder.continue")}):null]})}FeedbackResult.defaultProps={onNext:()=>{},success:!1,showButton:!0};function PublishButton({onPublish:o,translate:e}){return jsxRuntimeExports.jsx("div",{role:"button",tabIndex:0,onKeyUp:()=>{},"aria-label":"publish",className:"position--absolute bottom center",onClick:o,children:jsxRuntimeExports.jsxs("div",{className:"gat--btn gat--btn__primary",children:[jsxRuntimeExports.jsx("span",{className:"icon-download-cloud"}),e("webbuilder.publish")]})})}PublishButton.defaultProps={onPublish:()=>{}};function PopupColorComponent({colors:o,onSave:e,closingAction:r,translate:t,soundActions:n}){const[a]=n,[u,l]=React$2.useState(),f=u===null;return jsxRuntimeExports.jsx("div",{className:"popup--layer",children:jsxRuntimeExports.jsxs("div",{className:"popup",children:[jsxRuntimeExports.jsx("div",{className:"popup--info",children:jsxRuntimeExports.jsx("span",{className:"popup--info__item",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__colors",children:[jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__colors--title",children:jsxRuntimeExports.jsx("span",{children:t("webbuilder.colorSelect.title")})}),jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__colors--items",children:o.map(c=>jsxRuntimeExports.jsx("div",{className:`puzzle--webBuilder__color--select ${u===c?"selected":""}`,style:{borderColor:`${c}`},onClick:()=>l(c),children:jsxRuntimeExports.jsx("span",{style:{backgroundColor:`${c}`}})},c+Date.now()))})]})})}),jsxRuntimeExports.jsxs("div",{className:"popup--buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:r,children:jsxRuntimeExports.jsx("span",{children:t("webbuilder.cancel")})}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,onClick:f?null:()=>{a("click-ui"),e(u)},children:t("webbuilder.save")})]})]})})}PopupColorComponent.defaultProps={closingAction:()=>{},onSave:()=>{},colors:{}};PopupColorComponent.propTypes={closingAction:PropTypes.func,onSave:PropTypes.func,colors:PropTypes.arrayOf(PropTypes.string)};function PopupImageComponent({images:o,onSave:e,closingAction:r,translate:t,soundActions:n}){const[a]=n,[u,l]=React$2.useState(),f=!u;return jsxRuntimeExports.jsx("div",{className:"folder-popup",children:jsxRuntimeExports.jsxs("div",{className:"folder-popup__content",children:[jsxRuntimeExports.jsxs("div",{className:"folder-popup__header",children:[jsxRuntimeExports.jsx("div",{}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__title",children:[jsxRuntimeExports.jsx("span",{className:"folder-popup__icon-header icon-fb-search"}),jsxRuntimeExports.jsx("span",{children:t("webbuilder.imageSelect.title")})]}),jsxRuntimeExports.jsx("button",{onClick:r,className:"folder-popup__close",type:"button",children:jsxRuntimeExports.jsx("span",{className:"icon-close-fit"})})]}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__body",children:[jsxRuntimeExports.jsx("div",{className:"folder-popup__scroll",children:jsxRuntimeExports.jsx("ul",{className:"folder-popup__list",children:o.map(c=>jsxRuntimeExports.jsxs("li",{className:"folder-item-file",children:[jsxRuntimeExports.jsx("div",{className:"folder-item-file__imagewrap",onClick:()=>l(c),onKeyUp:()=>{},role:"button",tabIndex:0,children:jsxRuntimeExports.jsx("img",{alt:c.src,src:path+c.src})}),jsxRuntimeExports.jsx("div",{className:"folder-item-file__title",title:c.src,children:c.src})]},c.src+Date.now()))})}),jsxRuntimeExports.jsxs("div",{className:"folder-popup__buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:r,children:t("webbuilder.cancel")}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,onClick:f?null:()=>{a("click-ui"),e(u.src)},children:t("webbuilder.open")})]})]})]})})}PopupImageComponent.defaultProps={closingAction:()=>{},onSave:()=>{},images:[]};function Selected({item:o,translate:e}){return o instanceof Object?e(o.title.toString()):jsxRuntimeExports.jsx("span",{children:e(o||"webbuilder.textSelect.title")})}function PopupTextComponent({closingAction:o,onSave:e,options:r,translate:t,soundActions:n}){const[a]=n,[u,l]=React$2.useState(""),f=u==="",[c,h]=React$2.useState(!1),y=c?"puzzle--webBuilder__select--item open":"puzzle--webBuilder__select--item",E=()=>{h(!c)};return jsxRuntimeExports.jsx("div",{className:"popup--layer",children:jsxRuntimeExports.jsxs("div",{className:"popup",children:[jsxRuntimeExports.jsx("div",{className:"popup--info",children:jsxRuntimeExports.jsx("span",{className:"popup--info__item",children:jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder__select",children:[jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__select--label",children:jsxRuntimeExports.jsx("div",{dir:"auto",children:t("webbuilder.textSelect.title")})}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:y,onClick:()=>E(),role:"presentation",children:[jsxRuntimeExports.jsx(Selected,{item:u,translate:t}),jsxRuntimeExports.jsx("span",{className:"icon-down-arrow"}),jsxRuntimeExports.jsx("div",{className:"puzzle--webBuilder__dropdown",children:r.map(p=>p instanceof Object?jsxRuntimeExports.jsxs("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{l(p)},children:[jsxRuntimeExports.jsx("span",{children:t(p.title)}),jsxRuntimeExports.jsx("span",{className:"subtitle",children:t(p.desc)})]},p.title):jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,onKeyUp:()=>{},className:"puzzle--webBuilder__dropdown--option",onClick:()=>{l(p)},children:t(p)},p))})]})]})})}),jsxRuntimeExports.jsxs("div",{className:"popup--buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary",onClick:o,children:t("webbuilder.cancel")}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${f?"disabled":""}`,disabled:f,onClick:()=>{a("click-ui"),e(u)},children:t("webbuilder.save")})]})]})})}const POPUPS=Object.freeze(Object.defineProperty({__proto__:null,PopupColorComponent,PopupImageComponent,PopupTextComponent},Symbol.toStringTag,{value:"Module"})),defaultHeader={username:null,logo:null,userImage:null,bgImage:null,color:""},defaultBody={bankTitle:null,color:"",btnColor:"",work:null,home:null,mail:null,studies:null,bgImage:null};function PopupComponent({type:o,close:e,translate:r,soundActions:t,...n}){const a=POPUPS[o];return a?jsxRuntimeExports.jsx(a,{type:o,...n.props,closingAction:e,translate:r,soundActions:t}):null}function DisplayingFeedback({feed:o,resolved:e,translate:r,onNext:t}){return o==="success"?jsxRuntimeExports.jsx(FeedbackResult,{success:!0,showButton:!e,onNext:t,translate:r}):o==="failed"?jsxRuntimeExports.jsx(FeedbackResult,{onNext:t,translate:r}):null}function WebBuilderPuzzleComponent({type:o,info:e,emitEvent:r,setResolveAction:t,soundActions:n,disableExit:a,keyboardControl:u}){const[l,f]=React$2.useState(!1),[c,h]=React$2.useState(!1),[y,E]=React$2.useState(!1),[p,_]=React$2.useState(!1),[g,x]=React$2.useState(!1),[C,R]=React$2.useState(null),S=o==="facebook",A=S?FacebookTemplate:BankTemplate,[T,w]=React$2.useState({type:"",props:{}}),[P,O]=React$2.useState(defaultHeader),[k,D]=React$2.useState(defaultBody),[F]=n,G=Q=>r({type:"translate",payload:Q}),V=()=>{w({type:"",props:{}})},W=(Q,J={})=>{w({type:Q,props:J})},Z=()=>{if(e.solution){const{rewards:Q}=e.solution.right,{rewards:J}=e.solution.wrong;F(y?"fail":"score"),r({type:"addPoints",complex:!0,finish:!0,payload:y?J:Q}),r({type:"passPuzzle"})}};u(null,C==="success"?Z:null,C==="success"?Z:null);const q=(Q,J)=>{const ne=Object.keys(Q),se={existing:0,equal:0};return ne.forEach(ee=>{J[ee]!==null&&J[ee]!==""&&(se.existing+=1),Q[ee]===J[ee]&&(se.equal+=1)}),se},z=(Q,J)=>{const ne=Object.keys(A.header).length,se=Object.keys(A.body).length,ee=q(A.header,Q),ie=q(A.body,J),oe=ie.existing+ee.existing===ne+se,fe=ie.equal+ee.equal===ne+se;return{exist:oe,equal:fe}},U=()=>{F("click-ui");const{exist:Q,equal:J}=z(P,k);r({type:"hidePuzzleButtons",payload:!0}),Q&&!J?(g&&x(!1),R("failed"),E(!0),r({type:"failPuzzle"})):Q&&J&&(g&&(a(!1),x(!1)),_(!0),R("success"))},I=Q=>{if(Object.keys(Q).length>0){const J={...P,...Q};O(J),V();const{exist:ne}=z(J,k);x(!!ne)}},$=Q=>{if(Object.keys(Q).length>0){const J={...k,...Q};D(J),V();const{exist:ne}=z(P,J);x(!!ne)}};React$2.useEffect(()=>{t(Q=>{h(!0),R("success"),f(!1),setTimeout(()=>{R(""),Q()},4e3)}),a(!0)},[t,a,e.resolve.rewards,r]);const B={showingReference:l||c,isFacebook:S,openPopup:W,usingTemplate:A,translate:G},X=()=>{C==="failed"?(R(null),r({type:"hidePuzzleButtons",payload:!1})):C==="success"&&Z()};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(PopupComponent,{type:T.type,...T,close:V,soundActions:n,translate:G}),jsxRuntimeExports.jsxs("div",{className:"puzzle--webBuilder",children:[jsxRuntimeExports.jsx(WebBuilderTopBar,{backActive:l,displayButton:!c&&!p,translate:G,clickAction:()=>{F("click-ui"),f(!l)}}),jsxRuntimeExports.jsx(WebBuilderHeader,{...B,header:P,onSave:I}),S?jsxRuntimeExports.jsx(WebBuilderFront,{...B,header:P,onSave:I}):null,jsxRuntimeExports.jsx(WebBuilderBody,{...B,body:k,onSave:$})]}),!g&&!l?jsxRuntimeExports.jsx(DisplayingFeedback,{feed:C,onNext:X,resolved:c,translate:G}):null,g&&!l?jsxRuntimeExports.jsx(PublishButton,{onPublish:U,translate:G}):null]})}function Card({card:o,handleClick:e,flipped:r,cardIndex:t,wrongOrder:n}){const a=()=>!(o.img||o.text),u=()=>{const _=(o.img||{}).url;return jsxRuntimeExports.jsx("img",{src:_,alt:""})},l=()=>o.text?jsxRuntimeExports.jsx("div",{className:`card-selector-item__textbox ${o.img?"":"card-selector-item__textbox--noimage"}`,children:jsxRuntimeExports.jsx("div",{className:"card-selector-item__text",children:jsxRuntimeExports.jsx("span",{children:o.text||"_"})})}):null,f=()=>!!(r&&!o.correct||!r),c=()=>jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedback card-selector-item__feedback--error",children:jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedbackicon",children:jsxRuntimeExports.jsx("div",{className:"icon-error-circle-black"})})}),h=()=>o.order?jsxRuntimeExports.jsx("div",{className:"card-selector-item__order",children:jsxRuntimeExports.jsx("div",{children:o.order})}):null,y=()=>jsxRuntimeExports.jsxs("div",{className:"card-selector-item__feedback card-selector-item__feedback--success ",children:[h(),jsxRuntimeExports.jsx("div",{className:"card-selector-item__feedbackicon",children:jsxRuntimeExports.jsx("div",{className:"icon-check-circle-black"})})]}),E=()=>!a()&&r&&o.correct&&!n?y():!a()&&r?c():null;return jsxRuntimeExports.jsxs("button",{type:"button",order:o.order,onClick:()=>{!a()&&f()&&e(t)},className:`unset-button card-selector-item ${a()?"card-selector-item--empty":""}`,"aria-label":o.text?o.text:null,children:[u(),l(),E()]})}Card.defaultProps={handleClick:()=>{},documentsDict:{},card:{},flipped:!1,wrongOrder:!1,cardIndex:0};Card.propTypes={wrongOrder:PropTypes.bool,handleClick:PropTypes.func,cardIndex:PropTypes.number,flipped:PropTypes.bool,documentsDict:PropTypes.shape({}),card:PropTypes.shape({correct:PropTypes.bool,order:PropTypes.number,text:PropTypes.string,imgId:PropTypes.string,status:PropTypes.string})};function Board({cards:o,currentOrder:e,setCurrentOrder:r,handleError:t,feedbackIsShown:n,resolvePuzzle:a,soundActions:u,onFinish:l,handleSuccess:f,resolveWithAnyCard:c}){const[h,y]=React$2.useState(Array(o.length).fill(!1)),[E,p]=React$2.useState(Array(o.length).fill(!1)),[_,g]=React$2.useState(0),[x,C]=React$2.useState(!1),[R]=u,S=o.filter(F=>F.correct===!0).length,A=o.filter(F=>F.order).length>0,T=React$2.useCallback(()=>{y(Array(o.length).fill(!1)),p(Array(o.length).fill(!1)),g(0),r(1)},[o.length,r]),w=()=>{setTimeout(()=>{T()},1e3)};function P(F){const G=Array.from(h);G[F]=F,y(G)}const O=React$2.useCallback(()=>{const F=[];o.forEach((G,V)=>{G.correct===!0&&F.push(V)}),y(F)},[o]);React$2.useEffect(()=>{a&&O()},[O,a]),React$2.useEffect(()=>{(c&&_||_===S&&S>0)&&(l(),C(!0),g(0))},[_,l,S,c]);const k=F=>{P(F),f(o[F].id||null),g(_+1)},D=F=>{var G,V;if(!x&&!n)if(R("click-ui"),o[F].correct&&!A)k(F);else if(A)if(o[F].order===e)r(e+1),k(F);else{if(o[F].order!==e){const W=Array.from(E);W[F]=F,p(W),t(((G=o[F])==null?void 0:G.id)||null,o[F].correct),w()}P(F)}else t(((V=o[F])==null?void 0:V.id)||null),w(),P(F)};return jsxRuntimeExports.jsx("div",{className:`cards-selector__content cards-selector__content-${o.length}`,children:o&&o.map((F,G)=>jsxRuntimeExports.jsx(Card,{setCurrentOrder:r,card:F,handleClick:()=>D(G),flipped:h.includes(G),wrongOrder:E.includes(G),cardIndex:G},`cardPuzzle ${o.indexOf(F)}`))})}Board.defaultProps={setCurrentOrder:()=>{},handleError:()=>{},onFinish:()=>{},handleSuccess:()=>{},documentsDict:{},cards:[],currentOrder:1,resolvePuzzle:!1,feedbackIsShown:!1,resolveWithAnyCard:!1};function CardsSelectorPuzzleComponent({emitEvent:o,info:e,cards:r,resolveWithAnyCard:t,specificFeedbacks:n,disableExit:a,setResolveAction:u,soundActions:l,backgroundImage:f,nodeId:c,keyboardControl:h}){var $,B;const[y,E]=React$2.useState(!1),[p,_]=React$2.useState(1),[g,x]=React$2.useState(!1),[C,R]=React$2.useState(!1),[S,A]=React$2.useState(!1),[T,w]=React$2.useState([]),[P,O]=React$2.useState(!1),[k,D]=React$2.useState(""),[F]=l,G=X=>o({type:"translate",payload:X}),V=`cards-selector-puzzle_${c}`,W=React$2.useCallback(X=>{x(!1),A(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"addPoints",complex:!0,finish:!0,payload:X}),o({type:"passPuzzle"})},[o]),Z=React$2.useCallback(()=>{var ne,se;o({type:"hidePuzzleButtons",payload:!0}),x(!0);const{rewards:X}=((ne=e==null?void 0:e.solution)==null?void 0:ne.right)||{},Q=((se=n==null?void 0:n.correctFeedbacks)==null?void 0:se.map(ee=>ee.rewards).flat())||[],J=[...T,...X,...Q];F("score"),W(J)},[T,W,o,($=e==null?void 0:e.solution)==null?void 0:$.right,F,n==null?void 0:n.correctFeedbacks]),q=()=>{E(!0),e.solution.right.desc&&!(n!=null&&n.specificCorrectFeedbacks)&&D(e.solution.right.desc),A(!0)},z=()=>{g||y?Z():(x(!1),a(!1),A(!1),o({type:"hidePuzzleButtons",payload:!1})),D("")},U=X=>{if(R(!0),n!=null&&n.specificCorrectFeedbacks){const Q=n.correctFeedbacks.find(J=>J.id===X);Q!=null&&Q.desc&&(D(Q.desc),A(!0))}F("score"),o({type:"hidePuzzleButtons",payload:!0})},I=(X,Q=!1)=>{var J,ne;if(R(!1),Q)D((J=e.orderFeedback)==null?void 0:J.desc),A(!0),w([...T,...((ne=e.orderFeedback)==null?void 0:ne.rewards)||[]]);else if(n!=null&&n.specificWrongFeedbacks){const se=n.wrongFeedbacks.find(ee=>ee.id===X);se!=null&&se.desc?(D(se.desc),A(!0)):(A(!0),setTimeout(()=>{z(),o({type:"hidePuzzleButtons",payload:!1})},2e3)),w([...T,...(se==null?void 0:se.rewards)||[]])}else e.solution.wrong.desc?(D(e.solution.wrong.desc),A(!0)):(A(!0),setTimeout(()=>{z(),o({type:"hidePuzzleButtons",payload:!1})},3e3));a(!0),!(n!=null&&n.specificWrongFeedbacks)&&!Q&&w([...T,...e.solution.wrong.rewards]),F("fail"),o({type:"hidePuzzleButtons",payload:!0}),o({type:"failPuzzle"})};return React$2.useEffect(()=>{y&&a(!0)},[a,y]),React$2.useEffect(()=>{u(()=>{var Q;o({type:"hidePuzzleButtons",payload:!0}),O(!0);const X=[...T,...((Q=e==null?void 0:e.resolve)==null?void 0:Q.rewards)||{}];setTimeout(()=>{x(!1),A(!1),o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:V,rewards:X,finish:!0}})},2e3)})},[u,a,T,(B=e==null?void 0:e.resolve)==null?void 0:B.rewards,o,V]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:`cards-selector ${f!=null&&f.url?"cards-selector--with-custom-bg":""}`,style:f!=null&&f.url?{backgroundImage:`url("${f.url}")`}:{},children:jsxRuntimeExports.jsx(Board,{setCurrentOrder:_,currentOrder:p,cards:r,onFinish:q,resolveWithAnyCard:t,handleError:I,feedbackIsShown:S,resolvePuzzle:P,soundActions:l,handleSuccess:U})}),S&&jsxRuntimeExports.jsx(FeedbackComponent$1,{success:g||C,text:k,hasTimeout:!k,translate:G,functionOnClose:z,keyboardControl:h})]})}CardsSelectorPuzzleComponent.defaultProps={cards:[],info:{},resolveWithAnyCard:!1,backgroundImage:{url:""}};function Fakecursor(){return jsxRuntimeExports.jsx("span",{className:"fakecursor",children:"|"})}function FixedComponent({delay:o,index:e,length:r,textToPrint:t,setDoneTyping:n,nextParagraphType:a,isWriting:u}){const[l,f]=React$2.useState(!0),[c,h]=React$2.useState(""),[y,E]=React$2.useState(!1);React$2.useEffect(()=>{E(e===r-1)},[e,r]);const p=C=>{if(!C||!C.length)return"";const R=C.replace(/<script.*?>.*?<\/script>/gim,""),S=document.createElement("DIV");return S.innerHTML=R,S.textContent||S.innerText||""};React$2.useEffect(()=>{const C=()=>{const S=t.trim().split(" ");return R(S,S.length-1).join(" ")},R=(S,A)=>{if(A<0)return[""];const T=[...S];if(p(S[A]).length!==0){const w=S[A];return T[A]=`<span class="lastWord" >${w}</span>`,T}return R(S,A-1)};a==="election"?h(C()):setTimeout(()=>{h(t)},200)},[a,t]);const _=()=>{n(!0),f(!1)},g=t.split("<p>");g.shift();const x=g.length>1;return l&&t!==""&&c!==""?jsxRuntimeExports.jsx("span",{className:`writer-inline ${x?"multiple":""} ${y?"Typist":""}`,"data-testid":`result-${e}`,children:jsxRuntimeExports.jsx(Typist,{startDelay:300,avgTypingDelay:o,stdTypingDelay:10,onCharacterTyped:u,onTypingDone:_,cursor:{hideWhenDone:!0,hideWhenDoneDelay:200},blink:!0,children:HTMLReactParser$1(t)})}):jsxRuntimeExports.jsxs("span",{className:`writer-inline ${x?"multiple":""} ${y?"Typist":""}`,"data-testid":`result-${e}`,children:[HTMLReactParser$1(c),a==="election"&&y&&jsxRuntimeExports.jsx(Fakecursor,{})]})}FixedComponent.defaultProps={delay:0,textToPrint:"",setDoneTyping:()=>{},nextParagraphType:"",isWriting:()=>{}};function SingleElection({option:o,decisionInspected:e,setCurrentDecisionSelected:r,index:t,setCurrentDecisionInspected:n,soundActions:a}){const[u]=a,l=E=>E.previewText!==""?HTMLReactParser$1(E.previewText):HTMLReactParser$1(E.fullText),f=E=>E.previewText!==""?e===t?"icon-eye inspected":"icon-eye":"",c=()=>{u("click-ui"),r(t)},h=E=>{E.keyCode===13&&y(E)},y=E=>{E.preventDefault(),E.stopPropagation(),e===t?(E.target.style.background="",n("")):n(t)};return jsxRuntimeExports.jsxs("div",{className:"single-election",children:[jsxRuntimeExports.jsxs("button",{className:"single-election__cta",type:"button",onClick:()=>c(),children:[jsxRuntimeExports.jsx("div",{className:"single-election__btn",children:jsxRuntimeExports.jsx("span",{children:l(o)})}),jsxRuntimeExports.jsx("div",{onClick:y,onKeyDown:h,className:f(o),"aria-label":"Inspect",role:"button",tabIndex:0})]}),e===t&&jsxRuntimeExports.jsx("div",{className:"single-election__complete",children:jsxRuntimeExports.jsx("div",{children:HTMLReactParser$1(o.fullText)})})]})}SingleElection.defaultProps={setCurrentDecisionSelected:()=>{},setCurrentDecisionInspected:()=>{},option:{},index:0};function SingleElectionRender({decisionInspected:o,opt:e,index:r,setCurrentDecisionSelected:t,setCurrentDecisionInspected:n,soundActions:a}){return e&&e.fullText&&e.fullText!==""?jsxRuntimeExports.jsx(SingleElection,{decisionInspected:o,setCurrentDecisionSelected:t,setCurrentDecisionInspected:n,option:e,soundActions:a,index:r}):null}function ElectionComponent({textWithOpts:o,setCurrentDecisionSelected:e,printed:r,soundActions:t}){const[n,a]=React$2.useState("");return React$2.useEffect(()=>{r()},[r]),jsxRuntimeExports.jsx("div",{className:`elections-box pos${n+1}-${o.filter(u=>!!u.fullText).length}`,children:o&&o.map((u,l)=>jsxRuntimeExports.jsx(SingleElectionRender,{opt:u,soundActions:t,index:l,setCurrentDecisionSelected:e,setCurrentDecisionInspected:a,decisionInspected:n},l))})}ElectionComponent.defaultProps={textWithOpts:[],setCurrentDecisionSelected:()=>{},printed:()=>{}};function FeedbackElement({decision:o}){const{title:e,body:r}=o.feedback;return jsxRuntimeExports.jsx("div",{children:r!==""&&jsxRuntimeExports.jsxs("div",{className:"writer-feedback-decision-item",children:[e&&jsxRuntimeExports.jsxs("div",{dir:"auto",className:"writer-feedback-decision-item__title",children:[e," "]}),r&&jsxRuntimeExports.jsxs("div",{dir:"auto",className:"writer-feedback-decision-item__message",children:[o.correct?jsxRuntimeExports.jsx("span",{className:"icon-check-circle-black color--success"}):jsxRuntimeExports.jsx("span",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("span",{children:r})]})]})})}FeedbackElement.defaultProps={decision:{}};function FeedbackComponent({emitEvent:o,closingAction:e,feedbackIsDone:r,decisionsList:t,texts:n,retryAction:a,retry:u,skip:l,checkCorrect:f,rewardsStack:c,setFailed:h,soundActions:y}){const[E]=y,p=g=>o({type:"translate",payload:g}),_=()=>{E("click-ui"),e(),h(),r()};return jsxRuntimeExports.jsxs("div",{className:`writer-feedback ${c.length?"":"start"}`,children:[jsxRuntimeExports.jsx("div",{className:"writer-feedback__title",children:p("puzzles.feedback")}),jsxRuntimeExports.jsx("div",{className:"writer-feedback__decisions",children:t.map(g=>n[g.currenTextParagraph].electionTexts[g.index].feedback.body?jsxRuntimeExports.jsx(FeedbackElement,{decision:n[g.currenTextParagraph].electionTexts[g.index]},g.index):null)}),jsxRuntimeExports.jsxs("div",{className:"writer-feedback__btns",children:[l&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__secondary writer-feedback__btn-mobile",onClick:()=>{_()},children:p("puzzles.skip")}),u&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>{f()?_():(E("click-ui"),a())},children:p(f()?"puzzles.continue":"puzzles.retry")}),!u&&jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary writer-feedback__btn-mobile",onClick:()=>_(),children:p("puzzles.continue")})]})]})}FeedbackComponent.defaultProps={emitEvent:()=>{},closingAction:()=>{},feedbackIsDone:()=>{},decisionsList:[],texts:[],retryAction:()=>{},retry:!1,skip:!1,checkCorrect:()=>{},nodeId:"0"};function FinishedTextComponent({textToPrint:o,correct:e}){const r=o.split("<p>");r.shift();const t=r.length>1;return jsxRuntimeExports.jsx("span",{className:`writer-inline ${t?"multiple":""} ${e}`,children:HTMLReactParser$1(o)})}FinishedTextComponent.defaultProps={correct:"",textToPrint:""};function WriterPuzzleComponent({emitEvent:o,styles:e,nodeId:r,retry:t,skip:n,type:a,info:u,setResolveAction:l,documentTitle:f,documentTitle_labelId:c,texts:h,soundActions:y,backgroundImage:E}){const p=Ie=>o({type:"translate",payload:Ie}),_=React$2.useRef(),[g,x]=React$2.useState(!1),[C,R]=React$2.useState(!1),[S,A]=React$2.useState(0),[T,w]=React$2.useState({[`text_${S}`]:{...h[S],id:`text_${S}`,correct:""}}),[P,O]=React$2.useState(!1),[k,D]=React$2.useState([]),[F,G]=React$2.useState(!1),[V,W]=React$2.useState(!1),[Z,q]=React$2.useState(!1),[z,U]=React$2.useState(!0),[I,$]=React$2.useState([]),[B,X]=React$2.useState(!0),[Q]=y,J=React$2.useRef({}),ne=Ie=>{let et;return Ie.electionTexts.forEach((at,Kt)=>{at.correct&&(et=Kt)}),et},se=React$2.useCallback(Ie=>k.filter(at=>at.currenTextParagraph===Ie)[0].fullText_labelId,[k]),ee=React$2.useCallback(()=>h.map((Ie,et)=>{if(Ie.type==="fixed")return Ie.fullText_labelId??Ie.fullText;if(Ie.type==="election"){const at=ne(Ie);return at>=0?Ie.electionTexts[at].fullText_labelId:se(et)}return""}),[se,h]),ie=12,oe=()=>{if(k){const Ie=k.length;let et=0;for(let at=0;at<Ie;at+=1)k[at].isCorrect==="none"&&(et+=1);return et===Ie}return!0},fe=React$2.useCallback(()=>{if(k){const Ie=k.length;let et=0;for(let at=0;at<Ie;at+=1)k[at].isCorrect==="green"&&(et+=1);return et===Ie}return!0},[k]),de=()=>!!(k&&k.length),ce=()=>k.find(Ie=>{const{feedback:et}=h[Ie.currenTextParagraph].electionTexts[Ie.index];return et.body!==""}),Se=React$2.useCallback(()=>{const Ie=ee();o({type:"finishMedia",payload:{name:c,text:Ie,documentType:a,type:"text"}})},[ee,c,o,a]),ke=React$2.useCallback(Ie=>{const et=fe();Q(C?"fail":et?"score":"fail"),o({type:"addPoints",complex:!0,finish:!0,payload:Ie||I,onFinish:a!=="view"?Se:null}),o({type:"passPuzzle"})},[fe,o,C,Se,Q,I,a]);React$2.useEffect(()=>{g&&X(!1),l(()=>{ke(u.resolve.rewards)})},[o,ke,g,Se,u.resolve.rewards,l,a]);const Ne=()=>{x(!1),A(0),D([]),$([]),R(!1),q(!1),O(!1),W(!1),G(!1),w({text_0:{...h[0],id:"text_0",correct:""}}),U(!0),o({type:"addPoints",complex:!0,finish:!1,payload:I}),o({type:"failPuzzle"})},We=()=>{de()?oe()&&(G(!0),ke()):(G(!0),q(!0),ke()),F?(U(!1),Z&&!V?W(!0):(V||!Z&&!V)&&(!Z&&!V&&t?fe()?ke():Ne():ke())):(G(!0),ce()&&q(!0))},Ke=()=>{const Ie=h[S].electionTexts.filter(at=>at.correct).length,et=h[S].electionTexts;return Ie===0||Ie===et},Qe=Ie=>{const et=h[S].electionTexts[Ie],at=et.feedback.rewards;at&&at[0]&&at[0].points&&(J.current[`t${S}_e${Ie}`]||(et.correct&&(J.current[`t${S}_e${Ie}`]=!0),$([...I,...at])));const Kt=()=>Ke()?"none":et.correct?"green":"red",Xe={currenTextParagraph:S,fullText:et.fullText,index:Ie,isCorrect:Kt()};w({...T,[`text_${S}`]:{type:"fixed",fullText:et.fullText,correct:Xe.isCorrect}}),D([...k,Xe])},pt=()=>{_.current.scrollTop=_.current.scrollHeight+100},vt=()=>{if(_.current.querySelector(".wrapfixed").offsetHeight>_.current.offsetHeight){const Ie=_.current.querySelector(".wrapfixed").offsetHeight;_.current.scrollTo({top:Ie,behavior:"smooth"})}},ct=(Ie,et,at)=>{const Kt=Ie.fullText,Xe=h[at+1]?h[at+1].type:"",it=T[`text_${at+1}`]&&T[`text_${at+1}`].type?T[`text_${at+1}`].type:Xe;return jsxRuntimeExports.jsx(FixedComponent,{length:et,doneTyping:P,index:at,delay:ie,setDoneTyping:O,nextParagraphType:it,isWriting:vt,textToPrint:Kt},at.toString())},mt=(Ie,et)=>{const at=Ie.fullText;return jsxRuntimeExports.jsx(FinishedTextComponent,{textToPrint:at,correct:Ie.correct},et)},Vt=Ie=>jsxRuntimeExports.jsx(ElectionComponent,{soundActions:y,textWithOpts:Ie.electionTexts,setCurrentDecisionSelected:Qe,printed:pt,disableExit:B},Ie.electionTexts),kt=(Ie,et,at)=>Ie.type==="fixed"?ct(Ie,et,at):Vt(Ie);return React$2.useEffect(()=>{P===!0&&(()=>{h[S+1]?(w({...T,[`text_${S+1}`]:{...h[S+1],id:`text_${S+1}`,correct:""}}),A(S+1),O(!1)):x(!0)})()},[P,S,T,h]),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("div",{className:`writer-puzzle writer-puzzle--${e}`,style:E!=null&&E.url?{backgroundImage:`url("${E.url}")`}:{},children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__overlay",children:[V&&jsxRuntimeExports.jsx(FeedbackComponent,{emitEvent:o,texts:h,setFailed:()=>R(!0),decisionsList:k,closingAction:We,retry:t,skip:n,checkCorrect:fe,retryAction:Ne,rewardsStack:I,nodeId:r,soundActions:y}),!V&&jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__container",children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"writer-puzzle__title",children:f!==""&&f}),jsxRuntimeExports.jsx("div",{className:"writer-puzzle__body",dir:LangIsRtl()?"rtl":"auto",children:jsxRuntimeExports.jsxs("div",{className:"writer-puzzle__scroll",tabIndex:0,style:{overflowX:"hidden",padding:"0 0 20px 0",height:"95%"},ref:_,children:[jsxRuntimeExports.jsx("div",{className:"wrapfixed",children:z&&!F&&Object.values(T).map((Ie,et)=>kt(Ie,Object.values(T).length-1,et))}),F&&Object.values(T).map((Ie,et)=>mt(Ie,et))]})}),g&&jsxRuntimeExports.jsx("div",{className:"writer-puzzle__footer",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary",onClick:We,children:p("screens.continue")})})]})]})})})}WriterPuzzleComponent.defaultProps={emitEvent:()=>{},info:{},styles:"",nodeId:"0",retry:!1,skip:!1,type:"",documentTitle:"",texts:[]};function Image$1({document:o,name:e,isWallpaper:r}){const t=(o==null?void 0:o.url)||null;return jsxRuntimeExports.jsx("div",{className:`puzzle--terminal__image ${r?"puzzle--terminal__image--wallpaper":""}`,children:t?jsxRuntimeExports.jsx("img",{src:t,alt:e||""}):null})}const ICONS$1={image:"image-icon",video:"video-icon",embedded_video:"video-icon",pdf:"pdf-icon",terminal:"console-icon",cracker:"cracker-icon",folder:"folder-icon",world:"world-icon"};function Visor({file:o,solution:e,showContinue:r,info:t,resolvePuzzle:n,backFile:a,translate:u,soundActions:l,keyboardControl:f}){var R;const{fileId:c}=o,h=((R=o.document)==null?void 0:R.url)||"",[y]=l,E={image:{component:Image$1,props:{...o,url:h,soundActions:l}},video:{component:VideoVisor,props:{...o,url:h,endVideo:n,soundActions:l,translate:u}},embedded_video:{component:VideoVisor,props:{...o,url:h,soundActions:l}},pdf:{component:PdfVisor,props:{...o,url:h,translate:u,soundActions:l,emitNumberOfPages:()=>{},endPdf:()=>{},keyboardControl:f}},application:{component:PdfVisor,props:{...o,url:h,translate:u,soundActions:l,emitNumberOfPages:()=>{},keyboardControl:f,endPdf:()=>{}}}};if(!E[o.type])return null;const p=E[o.type].component,_=E[o.type].props,x=o.name.replace(/.jpg|.png|.pdf|.mp4/gi,""),C=e.fileId;return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__visor",children:[jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:y,shortText:!0,success:c===C,text:c===C?t.solution.right.desc:t.solution.wrong.desc,functionOnClose:c===C?n:a,additionalStyle:ICONS$1[o.type],secondText:x,translate:u,puzzleHeaderClass:"puzzle--terminal__visor--message",keyboardControl:f}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__visor--body",children:jsxRuntimeExports.jsx(p,{..._})}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__button",children:c===C&&r?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary green",type:"button",onClick:n,children:u("screens.continue")}):null})]})})}const ICONS={image:"image-icon",video:"video-icon",embedded_video:"video-icon",pdf:"pdf-icon",terminal:"console-icon",cracker:"cracker-icon",folder:"folder-icon",application:"pdf-icon",world:"world-icon"};function Item({item:o,selectItem:e}){const r=o.name;return jsxRuntimeExports.jsx("li",{className:"puzzle--terminal__folder__list--item",children:jsxRuntimeExports.jsxs("button",{type:"button",title:r,className:`unset-button puzzle--terminal__item id-${o.id}`,onClick:()=>o.fixed?null:e(o),children:[jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__icon ${ICONS[o.type]}`}),jsxRuntimeExports.jsx("span",{children:r})]})})}function FilesGroup({initFile:o,backFile:e,file:r,closeFolder:t,selectItem:n}){return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:r.id==="init"?jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:r.children.map((a,u)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${`${u}${a.id}`}`))}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list desktop",children:o.children.map((a,u)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${u+a.id}`))}),jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__folder",children:[jsxRuntimeExports.jsxs("div",{className:"puzzle--terminal__folder--head",children:[jsxRuntimeExports.jsx("span",{role:"button",onKeyUp:()=>{},"aria-label":"back file",tabIndex:0,onClick:()=>e(),className:"puzzle--terminal__folder--back",children:jsxRuntimeExports.jsx("span",{className:"icon-back"})}),jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__folder--head__icon ${ICONS[r.type]}`}),jsxRuntimeExports.jsx("span",{className:"text",children:r.name}),jsxRuntimeExports.jsx("span",{role:"button",tabIndex:0,"aria-label":"close folder",onKeyUp:()=>{},onClick:()=>t(),className:"puzzle--terminal__folder--close",children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})]}),jsxRuntimeExports.jsx("div",{className:"puzzle--terminal__folder--body",children:jsxRuntimeExports.jsx("ul",{className:"puzzle--terminal__folder__list",children:r.children.map((a,u)=>jsxRuntimeExports.jsx(Item,{selectItem:n,item:a},`${u+a.id}`))})})]})]})})}const DEFAULT_IMG="https://min.gamelearn.io/css-resources/gamelearn/resources/cosmos-bg-min.jpg",FIXED_ITEMS=[{fileId:"ids1",type:"world",fixed:!0,name:"Web builder 3.0"},{fileId:"ids2",type:"cracker",fixed:!0,name:"Decoder.exe"},{fileId:"ids3",type:"terminal",fixed:!0,name:"terminal"}];function TerminalPuzzleComponent({emitEvent:o,items:e,backgroundImage:r,solution:t,info:n,disableExit:a,soundActions:u,setResolveAction:l,nodeId:f,keyboardControl:c}){const[h,y]=React$2.useState({}),[E]=React$2.useState(!1),[p,_]=React$2.useState([]),g=React$2.useRef([]),[x]=u,C=k=>o({type:"translate",payload:k}),R=`terminal-puzzle_${f}`,S=React$2.useMemo(()=>({name:"init",children:[...FIXED_ITEMS,...e],id:"init"}),[e]),A=React$2.useCallback(k=>{x("click-ui"),y(k),_([...p,k]),k.type!=="folder"&&(o({type:"hidePuzzleButtons",payload:!0}),a(!0))},[p,a,o,x]);React$2.useEffect(()=>{y(S),_([S])},[S]),React$2.useEffect(()=>{l(()=>{g.current=[...g.current,...n.resolve.rewards];const k=g.current.map(D=>{var q;const{name:F,points:G,type:V,id:W}=D,Z={name:F,points:G,type:V,id:W};return(q=D==null?void 0:D.document)!=null&&q.resourceId&&(Z.id=D.document.resourceId),Z});o({type:"hidePuzzleButtons",payload:!1}),o({type:"puzzleAction",action:"resolve",payload:{element:R,rewards:k,finish:!0}})})},[l,n.resolve.rewards,o,R]);const T=()=>{g.current=[...g.current,...n.solution.wrong.rewards];const k=p.length-1,D=p.filter((F,G)=>k>G);y(p[k-1]),_(D),a(!1),o({type:"hidePuzzleButtons",payload:!1})},w=()=>{x("click-ui");const k=p[0];y(k),_([k])},P=()=>{g.current=[...g.current,...n.solution.right.rewards];const k=g.current.map(D=>{var q;const{name:F,points:G,type:V,id:W}=D,Z={name:F,points:G,type:V,id:W};return(q=D==null?void 0:D.document)!=null&&q.resourceId&&(Z.id=D.document.resourceId),Z});o({type:"hidePuzzleButtons",payload:!1}),x("score"),o({type:"addPoints",complex:!0,finish:!0,payload:k}),o({type:"passPuzzle"})},O=(r==null?void 0:r.url)||DEFAULT_IMG;return jsxRuntimeExports.jsx("div",{className:"puzzle--terminal",children:h.children?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Image$1,{isWallpaper:!0,document:{url:O}}),jsxRuntimeExports.jsx(FilesGroup,{backFile:T,initFile:S,selectItem:A,breadcrumb:p,closeFolder:w,file:h,translate:C})]}):jsxRuntimeExports.jsx(Visor,{soundActions:u,backFile:T,resolvePuzzle:P,info:n,showContinue:!E,solution:t,file:h,translate:C,keyboardControl:c})})}function DragItemPuzzleComponent({area:o,image:e,resolveObject:r,info:t,hasHighlights:n,consume:a,disableExit:u,emitEvent:l,soundActions:f,keyboardControl:c}){const{solution:h}=t,y=React$2.useRef(),E=React$2.useRef(),p=React$2.useRef(),_=React$2.useRef(),g=React$2.useRef({}),[x,C]=React$2.useState(""),[R,S]=React$2.useState(!1),[A,T]=React$2.useState(!1),[w,P]=React$2.useState(),[O]=React$2.useState(new window.Image),k=React$2.useRef([]),[D]=f,F=J=>l({type:"translate",payload:J});React$2.useEffect(()=>{u(x!=="")},[x,u]);const G=(J,ne)=>(J.x+J.width>ne.x&&J.x+J.width<=ne.x+ne.width||ne.x+ne.width>J.x&&ne.x+ne.width<=J.x+J.width)&&(J.y+J.height>ne.y&&J.y+J.height<=ne.y+ne.height||ne.y+ne.height>J.y&&ne.y+ne.height<=J.y+J.height),V=()=>{y&&n&&(y.current.to({duration:.25,opacity:.75}),E.current.to({duration:.25,opacity:.4}))},W=()=>{y&&n&&(y.current.to({duration:.25,opacity:0}),E.current.to({duration:.25,opacity:0}))},Z=React$2.useCallback(J=>{let ne=!1;if(J){const se=p.current;se.setPointersPositions(J);const ee=se.getPointerPosition(),ie=y.current.getClientRect({relativeTo:se});ne=G({...ee,width:1,height:1},ie)}return ne},[]),q=React$2.useCallback(J=>J&&r.uid===JSON.parse(J).uid,[r.uid]),z=React$2.useCallback(()=>{C(""),l({type:"hidePuzzleButtons",payload:!1}),l({type:"addPoints",complex:!0,finish:!0,payload:k.current}),l({type:"passPuzzle"}),a&&l({type:"consumeItem",payload:{uid:r.uid,targetId:r.uid,name:r.name}}),l({type:"closeUI",ui:"inventory"})},[a,l,r.name,r.uid]),U=React$2.useCallback(()=>{C("success"),l({type:"hidePuzzleButtons",payload:!0}),k.current=[...k.current,...h.right.rewards],setTimeout(()=>{z()},2e3)},[l,z,h.right.rewards]),I=React$2.useCallback(()=>{l({type:"openUI",ui:"inventory",onFinish:()=>{}}),C(""),l({type:"hidePuzzleButtons",payload:!1}),l({type:"failPuzzle"}),k.current=[...k.current,...h.wrong.rewards]},[l,h.wrong.rewards]),$=React$2.useCallback(J=>{const ne=J.dataTransfer.getData("item");p.current.setPointersPositions(J);const se=Z(J);l({type:"hidePuzzleButtons",payload:!0}),se&&q(ne)?(C("success"),l({type:"closeUI",ui:"inventory"}),t.solution.right.desc===""&&U()):(l({type:"closeUI",ui:"inventory"}),C("failed"),t.solution.wrong.desc===""&&setTimeout(()=>{I()},2e3))},[Z,q,l,U,I,t.solution.right.desc,t.solution.wrong.desc]),B=()=>{x==="success"?U():I()};React$2.useEffect(()=>{const J=e.img.url||"";O.src=J,O.onload=()=>{_.current&&(g.current={x:_.current.clientWidth/2,y:_.current.clientHeight/2,width:O.width,height:O.height,offsetX:O.width/2,offsetY:O.height/2,scale:{x:Math.min(_.current.clientWidth/O.width,_.current.clientHeight/O.height),y:Math.min(_.current.clientWidth/O.width,_.current.clientHeight/O.height)}},S(!0))}},[O,e.img.url]),React$2.useEffect(()=>{A||(l({type:"openUI",ui:"inventory",onFinish:()=>{}}),T(!0))},[A,l]);const X=J=>{J!==null&&(y.current=J)},Q=J=>{if(J!==null&&(E.current=J,y.current)){const{x:ne,y:se,width:ee,height:ie}=y.current.getClientRect();J.setAttr("x",ne),J.setAttr("y",se),J.setAttr("height",ie),J.setAttr("width",ee)}};return React$2.useLayoutEffect(()=>{if(y.current&&R){const J=y.current.getClientRect({relativeTo:y.current.getParent()});P({x:J.x+J.width/2,y:J.y+J.height/2})}},[R]),jsxRuntimeExports.jsxs("div",{className:"puzzle--drag__mask100",onDrop:$,onDragOver:J=>{J.preventDefault()},children:[jsxRuntimeExports.jsx("div",{className:"puzzle--drag__mask",children:jsxRuntimeExports.jsx("div",{ref:_,"data-testid":"mask_canvas",className:"puzzle--drag__mask--canvas",children:R?jsxRuntimeExports.jsx(Stage,{ref:p,width:_.current.clientWidth,height:_.current.clientHeight,children:jsxRuntimeExports.jsxs(Layer,{children:[jsxRuntimeExports.jsx(Image$2,{image:O,...g.current}),jsxRuntimeExports.jsxs(Group,{...g.current,children:[w?jsxRuntimeExports.jsx(Html,{transform:!0,groupProps:{id:"projection",...w},divProps:{style:{pointerEvents:"none"}},children:jsxRuntimeExports.jsx("div",{style:{width:"50px",height:"50px",pointerEvents:"none"},id:"object-area-projection"})}):null,jsxRuntimeExports.jsx(Line,{onMouseEnter:V,onMouseLeave:W,ref:X,...o,shape:"poly",fill:"#262a31d9",stroke:"white",strokeWidth:1,opacity:0,dash:[3,2],closed:!0,draggable:!1})]}),jsxRuntimeExports.jsx(Text,{onMouseEnter:V,onMouseLeave:W,ref:Q,text:F("puzzle.drag.dropzone"),fontSize:12,align:"center",verticalAlign:"middle",fill:"#ffffff",opacity:0})]})}):null})}),x!==""?jsxRuntimeExports.jsx(FeedbackComponent$1,{text:t.solution[x==="success"?"right":"wrong"].desc,success:x==="success",translate:F,playSound:D,functionOnClose:B,keyboardControl:c}):null]})}const LABELS_INDEX$1=["A","B","C","D","E","F","G","H","I","J"];function Questions({disabled:o,answered:e,question:r,updateForm:t,result:n,correctQuestions:a,translate:u}){const[l,f]=React$2.useState(!1),c=r.answers.filter(x=>x.text),h=x=>{let C=!1;return n[r.id].find(R=>R.id===x)&&(C=!0),C},y=x=>{let C="";return l?(e&&h(x.id)&&(C="selected"),o&&h(x.id)&&a.includes(x.id)&&(C="success"),o&&h(x.id)&&!a.includes(x.id)&&(C="failed")):(e&&x.id===n[r.id][0].id&&(C="selected"),o&&x.id===n[r.id][0].id&&(C=n[r.id][0].isCorrect?"success":"failed")),C},E=x=>{const C=y(x);return C==="selected"?"icon-check-circle-black color--selected":C==="success"?"icon-check-circle-black color--success":C==="failed"?"icon-error-circle-black color--error":""},p=x=>o&&x.feedback&&(l&&h(x.id)||x.id===n[r.id][0].id),_=(x,C)=>C===0?"tooltip--right__top":C===x.length-1?"tooltip--right__bottom":"tooltip--center__right",g=r.answers.filter(x=>x.isCorrect);return React$2.useEffect(()=>{g.length===1?f(!1):f(!0)},[g.length,l,r.answers]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:r.text})}),l&&!o?jsxRuntimeExports.jsx("div",{className:"test--questions__intertitle test--questions__intertitle--multiresponse",children:u("tests.chooseMoreOneAnswer")}):null,c.map((x,C)=>jsxRuntimeExports.jsxs("div",{className:"test--response__fakeinput",children:[l?jsxRuntimeExports.jsx("input",{checked:e&&h(x.id),disabled:o&&!h(x.id),readOnly:o,type:"checkbox",id:x.id,onChange:()=>o?null:t(x,r.id,C,"isCheckbox",x.id)}):jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsx("input",{checked:e&&x.id===n[r.id][0].id,disabled:o&&!y(x),type:"radio",name:"name",id:x.id,onChange:()=>o?null:t(x,r.id,C,"isRadio")})}),jsxRuntimeExports.jsxs("label",{htmlFor:x.id,className:`test--response__item ${y(x)}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX$1[C]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:x.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${E(x)}`})]}),o?jsxRuntimeExports.jsxs("div",{className:`test--feedback__info ${p(x)?"":"test--feedback__info--hidden"}`,children:[jsxRuntimeExports.jsx("span",{className:`icon-info2 ${y(x)==="success"?"color--success":"color--error"}`}),jsxRuntimeExports.jsxs("div",{id:`tooltipFeedback-${C}`,className:`tooltip ${_(c,C)}`,children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsx("span",{children:u("test.feedback")})})}),jsxRuntimeExports.jsx("span",{children:jsxRuntimeExports.jsx("span",{children:x.feedback})})]})]}):null]},x.text))]})}const LABELS_INDEX=["A","B","C","D","E","F","G","H","I","J"];function FeedbackItem({selectedAnswers:o,correctQuestions:e,question:r,translate:t}){const n=l=>e.includes(l),a=(l,f)=>l.index<f.index?-1:l.index>f.index?1:0,u=o.sort(a);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--questions__item",children:jsxRuntimeExports.jsx("span",{children:r})}),u.map(l=>jsxRuntimeExports.jsxs("div",{className:"test--response__itemwrap",children:[jsxRuntimeExports.jsxs("div",{className:`test--response__item ${n(l.id)?"success":"failed"}`,children:[jsxRuntimeExports.jsx("div",{className:"test--response__index",children:LABELS_INDEX[l.index]}),jsxRuntimeExports.jsx("div",{className:"test--response__text",children:jsxRuntimeExports.jsx("span",{children:l.text})}),jsxRuntimeExports.jsx("div",{className:`test--response__icon ${n(l.id)?"icon-check-circle-black color--success":"icon-error-circle-black color--error"}`})]}),jsxRuntimeExports.jsxs("div",{className:"test--feedback",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("b",{children:jsxRuntimeExports.jsxs("span",{children:[t("test.feedback")," ",o.length>1?LABELS_INDEX[l.index]:""]})})}),jsxRuntimeExports.jsx("span",{children:l.feedback})]})]},l.text))]})}function Container({questions:o,setTime:e,saveInterval:r,result:t,setTries:n,tries:a,time:u,showResults:l,answered:f,answerPage:c,updateForm:h,disabled:y,translate:E,soundActions:p,paused:_,view:g,correctQuestions:x,feedbacksOnlyWhenReview:C}){const R=document.querySelector(".test--container"),[S,A]=React$2.useState(0),[T,w]=React$2.useState(),P=o[S].id,[O]=p;React$2.useEffect(()=>{if(u>=0&&!y&&!_){const q=setInterval(()=>{T||e(z=>z-1)},1e3);return r(q),()=>{clearInterval(q)}}},[y,T,_,r,e,u]);const k=()=>{R.scrollTo(0,0),O("click-ui"),f&&(t[P][0].feedback&&!y&&!C?w(!0):(c(!1),A(S+1)))},D=()=>{O("click-ui"),A(S-1)},F=()=>{R.scrollTo(0,0),o[S+1]?(w(!1),c(!1),A(S+1)):l()},G=()=>{R.scrollTo(0,0),n(a+1),t[P][0].feedback&&!y&&!C?w(!0):l()},V=Math.floor(u/60),W=u%60;React$2.useEffect(()=>{if(g==="review"){const q=t[`q${S}`][0].id,z=document.querySelector(`#${q}`);R.scrollTo(0,z.offsetTop)}},[S,R,t,g]);const Z=()=>{if(f){const q=x[o[S].id.substring(1)].answers,z=t[P],U=z.find($=>$.isCorrect===!1);let I=0;return z.forEach($=>{q.includes($.id)&&(I+=1)}),!U&&I===q.length}return!1};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[g==="review"||T?jsxRuntimeExports.jsx("div",{className:`test-feedback-header ${Z()?"success":"failed"}`,children:jsxRuntimeExports.jsxs("h2",{children:[jsxRuntimeExports.jsx("span",{className:`${Z()?"icon-correct-thumb":"icon-incorrect-thumb"}`}),jsxRuntimeExports.jsx("span",{className:"test-feedback-header__title",children:Z()?E("tests.resolvedQuestion"):E("tests.notResolvedQuestion")})]})}):null,jsxRuntimeExports.jsxs("div",{className:"test--questions",children:[jsxRuntimeExports.jsx("div",{className:"test--questions__container",children:T?jsxRuntimeExports.jsx(FeedbackItem,{selectedAnswers:t[P],correctQuestions:x[o[S].id.substring(1)].answers,question:o[S].text,translate:E}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:"test--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:LangIsRtl()?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[S+1,"/",o.length," ",jsxRuntimeExports.jsx("span",{children:E("tests.question")})]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("span",{children:E("tests.question")})," ",S+1,"/",o.length]})}),g!=="review"&&u>=0?jsxRuntimeExports.jsx("div",{dir:"ltr",className:`count-down ${u<10?"count-down--finalseconds":""}`,children:jsxRuntimeExports.jsxs("div",{id:"test-time",children:[V<10?`0${V}`:V," : ",W<10?`0${W}`:W]})}):null]}),jsxRuntimeExports.jsx(Questions,{result:t,disabled:y,answered:f,updateForm:h,question:o[S],correctQuestions:y?x[o[S].id.substring(1)].answers:[],translate:E},o[S].id)]})}),jsxRuntimeExports.jsxs("div",{className:`test--buttons ${g==="review"?"reviewmode":"next"}`,children:[g==="review"?jsxRuntimeExports.jsx("button",{disabled:S===0,id:"back-button",onClick:()=>D(),type:"button",className:`gat--btn__navigation ${S===0?"disabled":""}`,"aria-label":LangIsRtl()?E("survey.next"):E("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}):null,!T&&o[S+1]?jsxRuntimeExports.jsx("button",{disabled:!f,id:"next-button",onClick:()=>k(),type:"button",className:`gat--btn__navigation ${f?"":"disabled"}`,"aria-label":LangIsRtl()?E("survey.previous"):E("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null,T?jsxRuntimeExports.jsx("button",{id:"next-button",onClick:()=>F(),type:"button",className:"gat--btn__navigation",children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null,!T&&o[S].id.substring(1)===(o.length-1).toString()?jsxRuntimeExports.jsx("button",{disabled:!f,id:"finish-button",onClick:()=>{O("click-ui"),f&&G()},type:"button",className:`gat--btn__navigation ${f?"":"disabled"}`,"aria-label":LangIsRtl()?E("survey.previous"):E("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null]})]})]})}function ResultsComponent({result:o,time:e,mandatory:r,correctQuestions:t,isFirst:n,reviewTest:a,finishTest:u,restartTest:l,timeOver:f,timeOverText:c,emitEvent:h,minimumPercentage:y}){const[E,p]=React$2.useState(0),[_,g]=React$2.useState(),[x,C]=React$2.useState([]),[R,S]=React$2.useState([]),[A,T]=React$2.useState([]),w=React$2.useCallback(()=>{const z=[];return t.forEach(U=>z.push(U.answers)),z},[t]),P=React$2.useCallback(()=>{const z=[];return Object.values(o).forEach(U=>{if(U.length>1){const I=U.find(B=>B.isCorrect===!1),$=[];I?z.push([]):(U.forEach(B=>{B.isCorrect&&$.push(B.id)}),z.push($))}else U[0].isCorrect?z.push([U[0].id]):U[0].isCorrect===!1&&z.push("")}),z},[o]),O=React$2.useCallback(()=>{let z=0;return R.length>0&&x.forEach((U,I)=>{U.length>1?U.every($=>R[I].includes($))&&(z+=1):U.length===1&&R[I]&&U[0]===R[I][0]&&(z+=1)}),z},[x,R]);React$2.useEffect(()=>{C(w),S(P),T(O)},[w,P,O]);const k=t.length,D=O()===k,F=A<y,G=A>=y,V=!r||G,W=Math.trunc(E/k*100),Z=(z,U)=>h({type:"translate",payload:z,values:U}),q={"--chart-color":"var(--color-error)"};return React$2.useEffect(()=>{if(E<A){const z=setInterval(()=>{p(U=>U+1)},100);return g(z),()=>{clearInterval(z)}}},[A,E]),React$2.useEffect(()=>{E>=A&&clearInterval(_)},[A,_,E]),jsxRuntimeExports.jsxs("div",{className:`test--results ${F||f?"test--results--failed":""}`,children:[n&&D?jsxRuntimeExports.jsxs("div",{className:"fireworks",children:[jsxRuntimeExports.jsx("div",{className:"before"}),jsxRuntimeExports.jsx("div",{className:"after"})]}):null,!f&&F?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:Z("tests.NotFinishedSuccessfully")})}):null,!f&&G||D?jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:Z("tests.finishedSuccessfully")})}):null,f?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--results__title",children:jsxRuntimeExports.jsx("span",{children:c})}),jsxRuntimeExports.jsx("div",{className:"test--results__time",id:"results-time",children:jsxRuntimeExports.jsx("span",{children:Z("tests.time",e)})})]}):null,jsxRuntimeExports.jsxs("div",{className:`chart center chart${W}`,children:[jsxRuntimeExports.jsxs("div",{className:"chart-slice",children:[jsxRuntimeExports.jsx("div",{className:"chart-bar",style:F||f?q:{}}),jsxRuntimeExports.jsx("div",{className:"chart-fill",style:F||f?q:{}})]}),jsxRuntimeExports.jsxs("span",{className:"chart-value",children:[jsxRuntimeExports.jsxs("div",{className:"test--results__chart",children:[jsxRuntimeExports.jsx("span",{children:E}),jsxRuntimeExports.jsxs("span",{children:["/",k]})]}),jsxRuntimeExports.jsx("div",{className:"test--results__chart--label",children:jsxRuntimeExports.jsx("span",{children:Z("tests.success")})})]})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__minimum",children:[jsxRuntimeExports.jsx("div",{className:"icon-bell"}),jsxRuntimeExports.jsx("div",{children:Z("tests.minimumQuestionsMessage",{minimumPercentage:y})})]}),jsxRuntimeExports.jsxs("div",{className:"test--results__buttons",children:[f?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__secondary",id:"review-button",onClick:()=>a(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.review")})}),V?null:jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",id:"restart-button",onClick:()=>l(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.restart")})}),V?jsxRuntimeExports.jsx("button",{className:"gat--btn gat--btn__primary",id:"finish-button",onClick:()=>u(),type:"button",children:jsxRuntimeExports.jsx("span",{children:Z("tests.continue")})}):null]})]})}function TestComponent({test:o,countdown:e={},emitEvent:r,soundActions:t,audio:n,required:a,pause:u,minimumPercentage:l=100,feedbacksOnlyWhenReview:f}){const{questions:c}=o,[h,y]=React$2.useState({}),[E,p]=React$2.useState(),[_,g]=React$2.useState(0),[x,C]=React$2.useState([]),[R,S]=React$2.useState(e.time),[A,T]=React$2.useState(!1),[w,P]=React$2.useState("test"),[O,k]=React$2.useState(!0),[D,F]=React$2.useState({}),[G,V]=React$2.useState({}),[W,Z]=React$2.useState(!1),q=a||o.required||!1,z=React$2.useRef({}),[U,I]=React$2.useState(),[$,B]=t,X=(ie,oe,fe,de,ce)=>{const Se={...ie,index:fe};if(_>0&&(Se.rewards=Se.rewards.filter(Ne=>!G[ie.id]||Ne.points<0)),h[oe]){const Ne=h[oe].find(We=>We.id===ce);if(Ne){if(Ne.id===ie.id){const We=h[oe].find(Qe=>Qe.id===ce),Ke=h[oe].indexOf(We);if(h[oe].splice(Ke,1),h[oe].length===0){T(!1);return}}}else h[oe].push(Se)}else h[oe]=[Se];let ke;de==="isRadio"?ke={...h,[oe]:[Se]}:ke={...h},y(ke),F(ke),V({...G,[ie.id]:{...ie}}),T(!0)};React$2.useEffect(()=>{n!=null&&n.url&&$(n.url,"tts")},[$,n]);const Q=c.map(ie=>{const oe=ie.answers.filter(de=>de.isCorrect),fe=[];return oe.forEach(de=>{fe.push(de.id)}),{question:ie.id,answers:fe}});React$2.useEffect(()=>{C(Q)},[Q]),React$2.useEffect(()=>{if(l){const ie=Math.ceil(c.length*l/100);I(ie)}},[c.length,l]),React$2.useEffect(()=>{R===0&&(clearInterval(E),T(!1),Z(!0),P("results"),B("tts"))},[E,B,R]);const J=()=>{clearInterval(E),T(!1),P("results");const ie={...D};F(ie),B("tts")},ne=()=>{const ie={correctQuestions:x.length,result:h,status:"resolved"};Object.keys(h).forEach(fe=>{h[fe].forEach(de=>{z.current[de.id]&&(de.rewards=[])})}),r({type:"saveTest",payload:ie})},se=()=>{const ie=()=>{F({}),V({}),P("test"),y({}),S(e.time),Z(!1),n!=null&&n.url&&$(n.url,"tts")},oe=Object.values(h);oe.forEach(de=>{de.forEach(ce=>{ce.isCorrect&&(z.current[ce.id]?ce.rewards=[]:z.current[ce.id]=!0)})});let fe=oe.reduce((de,ce)=>{const Se=[];return ce.forEach(ke=>{Se.push(ke.rewards)}),[...de,...Se.flat()]},[]);W&&e.rewards&&(fe=[...fe,...e.rewards]),r({type:"addPoints",payload:fe,complex:!0,finish:!1,onFinish:ie}),r({type:"failTest"})},ee=(ie,oe)=>r({type:"translate",payload:ie,values:oe});return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--container__overlay"}),jsxRuntimeExports.jsx("div",{className:"test--container",dir:"auto",children:w!=="results"?jsxRuntimeExports.jsx(Container,{result:h,time:R,setTries:g,tries:_,answerPage:T,setTime:S,paused:u,saveInterval:p,disabled:w!=="test",answered:A||w!=="test",questions:c,updateForm:X,showResults:J,translate:ee,soundActions:t,view:w,correctQuestions:x,feedbacksOnlyWhenReview:f}):jsxRuntimeExports.jsx(ResultsComponent,{reviewTest:()=>{k(!1),P("review")},isFirst:O,finishTest:ne,time:R,mandatory:q,restartTest:se,result:h,correctQuestions:x,timeOver:W,timeOverText:e.text,emitEvent:r,soundActions:t,minimumPercentage:U})})]})}const OPTIONS=["yes","no"],LETTERS=["A","B"];function ApplicableBox({setSurveyData:o,survey:e,id:r,translate:t,changePage:n}){const a=u=>{o({...e,[r]:u}),n()};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:OPTIONS.map((u,l)=>jsxRuntimeExports.jsxs("button",{type:"button",onClick:()=>a(u),className:`unset-button survey--response__item ${e[r]===u?"selected":""}`,children:[jsxRuntimeExports.jsx("div",{className:"survey--response__index",children:LETTERS[l]}),jsxRuntimeExports.jsx("div",{className:"survey--response__text",children:t(`survey.${u}`)})]},u))})}const OPINION_OPTIONS=[0,1,2,3,4,5,6,7,8,9,10];function OpinionBox({setSurveyData:o,survey:e,id:r,translate:t,changePage:n}){const a=u=>{o({...e,[r]:u}),n()};return jsxRuntimeExports.jsxs("div",{className:"survey--page__item","aria-label":"opinion box",children:[jsxRuntimeExports.jsx("div",{className:"survey--points",children:OPINION_OPTIONS.map(u=>jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>a(u),className:`unset-button survey--points__item ${e[r]===u?"selected":""}`,children:u},u))}),jsxRuntimeExports.jsxs("div",{className:"survey--points__labels",children:[jsxRuntimeExports.jsx("span",{children:t("survey.bad")}),jsxRuntimeExports.jsx("span",{children:t("survey.excellent")})]})]})}function TextBox({setSurveyData:o,survey:e,id:r,literalLabel:t}){const n=a=>{o({...e,[r]:a})};return jsxRuntimeExports.jsx("div",{className:"survey--page__item",children:jsxRuntimeExports.jsx("textarea",{ref:a=>{a&&a.focus()},className:"survey--textarea",id:t,value:e[r],onChange:a=>n(a.target.value)})})}const INIT_SURVEY={applicable:"",opinion:"",comments:"",suggestions:""},PAGES=[{component:ApplicableBox,id:"applicable"},{component:OpinionBox,id:"opinion"},{component:TextBox,id:"comments"},{component:TextBox,id:"suggestions"}];function SurveyComponent({emitEvent:o,soundActions:e}){const[r,t]=React$2.useState(INIT_SURVEY),[n,a]=React$2.useState(0),[u,l]=React$2.useState(!1),[f]=e,c=(E,p)=>o({type:"translate",payload:E,values:p}),h=(E=!1)=>{if(f("click-ui"),!E&&n+1>=PAGES.length)l(!0);else{E&&l(!1);const p=E?n-1:n+1;a(p)}},y=PAGES[n].component;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"survey--container__overlay"}),jsxRuntimeExports.jsx("div",{className:"survey--container",dir:"auto",children:jsxRuntimeExports.jsxs("div",{className:"survey--questions",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__container",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsx("span",{children:c("survey.numQuestion",{init:n+1,page:PAGES.length})})}),jsxRuntimeExports.jsx("div",{children:c("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsx("label",{className:"survey--questions__item",htmlFor:c(`survey.question${n+1}`,{ordinal:n+1}),children:c(`survey.question${n+1}`,{ordinal:n+1})}),jsxRuntimeExports.jsx(y,{setSurveyData:t,id:PAGES[n].id,survey:r,translate:c,changePage:E=>h(!1),literalLabel:c(`survey.question${n+1}`,{ordinal:n+1})})]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next",children:[jsxRuntimeExports.jsx("button",{id:"survey-button-back",type:"button",disabled:n===0,onClick:()=>h(!0),className:`gat--btn__navigation ${n===0?"disabled":""}`,"aria-label":LangIsRtl()?c("survey.next"):c("survey.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),u&&n===PAGES.length-1?jsxRuntimeExports.jsx("button",{id:"survey-button",type:"button",disabled:!r[PAGES[n].id],onClick:()=>{f("click-ui"),o({type:"saveSurvey",payload:r})},className:`gat--btn gat--btn__primary ${r[PAGES[n].id]?"":"disabled"} not-transition`,children:c("survey.finish")}):null,!u&&n!==PAGES.length?jsxRuntimeExports.jsx("button",{id:"survey-button",type:"button",disabled:!r[PAGES[n].id],onClick:()=>h(!1),className:`gat--btn__navigation ${r[PAGES[n].id]?"":"disabled"}`,"aria-label":LangIsRtl()?c("survey.previous"):c("survey.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null]})]})})]})}function EndScreen({onFinish:o,translate:e}){return React$2.useEffect(()=>{let r;return o&&(r=setTimeout(()=>{o()},2e3)),()=>{r&&clearTimeout(r)}},[o]),jsxRuntimeExports.jsx("div",{className:"auto-evaluation__endscreen","aria-label":"auto evaluation endscreen",children:jsxRuntimeExports.jsxs("div",{className:"auto-evaluation__finishband","aria-label":"auto evaluation finishband",children:[jsxRuntimeExports.jsx("span",{className:"icon-check-laptop auto-evaluation__iconendscreen","aria-label":"icon-check",role:"img"}),jsxRuntimeExports.jsx("span",{className:"auto-evaluation__thanks","aria-label":"auto evaluation thanks",role:"contentinfo",children:e("auto-evaluation.thanks")})]})})}function StartScreen({onNext:o,description:e,translate:r}){return jsxRuntimeExports.jsxs("div",{className:"auto-evaluation__startscreen",role:"alertdialog","aria-modal":"true","aria-label":"ae start screen",children:[jsxRuntimeExports.jsx("span",{className:"icon-happy-laptop auto-evaluation__starticon","aria-label":"icon laptop",role:"img"}),jsxRuntimeExports.jsx("div",{className:"auto-evaluation__starttext","aria-label":"desciption",children:jsxRuntimeExports.jsx("span",{children:e})}),jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary auto-evaluation__button auto-evaluation__button--start",onClick:o,children:jsxRuntimeExports.jsx("span",{children:r("auto-evaluation.start")})})]})}function AutoEvaluation({description:o,questions:e,type:r,emitEvent:t,soundActions:n}){var A,T,w;const[a,u]=React$2.useState(null),[l,f]=React$2.useState("start"),[c,h]=React$2.useState(!1),[y,E]=React$2.useState(0),[p,_]=React$2.useState({current:{questions:[],type:r}}),[g]=n,x=P=>t({type:"translate",payload:P}),C=P=>{P.keyCode===13&&P.target.blur()},R=()=>{g("click-ui"),t({type:"saveSurveyPrePos",payload:p.current})};React$2.useEffect(()=>{!e.length&&l==="questions"&&f("end")},[e,l]);const S=(P,O=!1)=>{var D;const k=P!==null?P:(D=p.current.questions.find(F=>F.id===e[y].id))==null?void 0:D.answer;if(g("click-ui"),O)E(y-1),h(!1);else{const F=p.current.questions.findIndex(V=>V.id===e[y].id),G=[...p.current.questions];F>-1?G.splice(F,1,{id:e[y].id,answer:k}):G.push({id:e[y].id,answer:k}),_({...p,current:{...p.current,questions:G}}),y===e.length-1?h(!0):(E(y+1),h(!1))}};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"test--container__overlay","aria-label":"test container overlay"}),jsxRuntimeExports.jsxs("div",{className:"test--container",dir:"auto","aria-label":"test container",children:[l==="start"&&jsxRuntimeExports.jsx(StartScreen,{description:o,onNext:()=>{f("questions"),g("click-ui")},translate:x}),l==="questions"&&jsxRuntimeExports.jsxs("div",{className:"survey--questions","aria-label":"survey questions",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__container","aria-label":"survey questions container",children:[jsxRuntimeExports.jsxs("div",{className:"survey--questions__intertitle",children:[jsxRuntimeExports.jsx("div",{children:jsxRuntimeExports.jsxs("span",{children:[x("auto-evaluation.question")," ",y+1," ",x("storylines.misc.of")," ",e.length]})}),jsxRuntimeExports.jsx("div",{children:x("auto-evaluation.allQuestionsMandatory")})]}),jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{className:"survey--questions__item","aria-label":"survey questions item",children:(A=e[y])==null?void 0:A.text}),jsxRuntimeExports.jsx("div",{className:"survey--page__item","aria-label":"survey page item",children:jsxRuntimeExports.jsx("div",{className:"survey--points","aria-label":"survey points",children:Array(11).fill(0).map((P,O)=>{var k;return jsxRuntimeExports.jsx("button",{type:"button",onTouchStart:()=>{u(O)},onTouchEnd:()=>{u(null)},onKeyUp:D=>{C(D)},onClick:()=>{S(O,!1)},className:`survey--points__item ${((k=p.current.questions[y])==null?void 0:k.answer)===O||a===O?"selected":""}`,children:O},`${0+O}`)})})})]},`${e[y]}`)]}),jsxRuntimeExports.jsxs("div",{className:"test--buttons next","aria-label":"test buttons",children:[jsxRuntimeExports.jsx("button",{type:"button",disabled:y===0,onClick:()=>S(null,!0),"aria-label":LangIsRtl()?x("survey.next"):x("survey.previous"),className:`gat--btn__navigation ${y===0?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back","aria-label":"icon button"})}),c?jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>{f("end"),g("click-ui")},className:`gat--btn gat--btn__primary auto-evaluation__button not-transition
253
253
  `,children:jsxRuntimeExports.jsx("span",{children:x("auto-evaluation.end")})}):jsxRuntimeExports.jsx("button",{type:"button",onClick:()=>S(null,!1),disabled:((T=p.current.questions[y])==null?void 0:T.answer)===void 0,"aria-label":LangIsRtl()?x("survey.previous"):x("survey.next"),className:`gat--btn__navigation ${((w=p.current.questions[y])==null?void 0:w.answer)===void 0?"disabled":""}`,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]}),l==="end"&&jsxRuntimeExports.jsx(EndScreen,{onFinish:R,translate:x})]})]})}function PatternComponent({img:o,name:e,viewed:r,emitEvent:t,soundActions:n,keyboardControl:a}){const[u]=n,l=h=>t({type:"translate",payload:h});if(!o)return null;const f=o.url,c=()=>{u("click-ui"),t({type:"emitSavePattern",payload:{imgId:o.resourceId,name:e,viewed:!0,url:f,type:"pattern"}})};return a(null,r?null:c,r?null:c),jsxRuntimeExports.jsx("div",{className:r?"notes--results":"readings--container pattern-wrap--overlay",children:jsxRuntimeExports.jsx("div",{className:r?"notes--results__text":"pattern-wrap",children:r?jsxRuntimeExports.jsx("div",{children:f&&jsxRuntimeExports.jsx("img",{src:f,alt:"pattern"})}):jsxRuntimeExports.jsxs("div",{className:"pattern",children:[jsxRuntimeExports.jsxs("div",{className:"pattern__header",children:[jsxRuntimeExports.jsx("div",{className:"pattern__title",children:l("phone.pattern")}),jsxRuntimeExports.jsx("button",{type:"button","aria-label":l("storylines.misc.closePiece"),className:"pattern__close gat--btn__round gat--btn__close",onClick:()=>c(),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})]}),jsxRuntimeExports.jsx("figure",{className:"pattern__figure",children:f&&jsxRuntimeExports.jsx("img",{src:f,alt:"pattern"})})]})})})}const getRecursiveJSX=(o,e=0,r,t,n)=>{var a,u;if((a=o.props)!=null&&a.children){const l=o.type,{children:f,...c}=o.props;if(o.props["data-text-id"]){if(c.dir="auto",c.onClick=h=>t(h,c["data-text-id"]||-1),r!=null&&r.hasHighlights){const h=[...r.correctTexts,...r.wrongTexts];for(let y=0;y<h.length;y+=1)c["data-text-id"]===h[y].id&&(c.className="text-click__hover-correct")}}else r!=null&&r.allWrong&&!o.props["data-text-id"]&&(c.onClick=h=>t(h,"allWrong"));return Array.isArray(f)?jsxRuntimeExports.jsx(l,{...c,children:f.map((h,y)=>getRecursiveJSX(h,y,r,t))},`${o.type}_${e}`):jsxRuntimeExports.jsx(l,{...c,children:getRecursiveJSX(f,e,r,t)},`${o.type}_${e}`)}return((u=o.props)==null?void 0:u.children)!==null?o.split(" ").filter(l=>l!=="").map(l=>jsxRuntimeExports.jsx("span",{dir:"auto",children:l},l)):null};function TextClickPuzzleComponent({emitEvent:o,showFrames:e,styles:r,list:t,soundActions:n,description:a,setInfo:u,setResolveAction:l,keyboardControl:f,backgroundImage:c}){const[h,y]=React$2.useState({result:null,show:!1,text:"",timeout:!1}),[E]=n,[p,_]=React$2.useState(0),[g,x]=React$2.useState(0),[C,R]=React$2.useState(0),S=React$2.useRef(0),A=React$2.useRef([]),[T,w]=React$2.useState(0),[P,O]=React$2.useState(),k=React$2.useCallback($=>o({type:"translate",payload:$}),[o]),D=React$2.useRef(null),F=React$2.useCallback(()=>S.current===t[p].correctTexts.length||t[p].hasClickOnce&&S.current>=1,[p,t]),G=React$2.useCallback(($,B)=>{$&&o({type:"hidePuzzleButtons",payload:!0}),y(X=>({...X,show:$,...B}))},[o]),V=React$2.useCallback(()=>{if(F())if(y($=>({...$,result:!1})),S.current=0,C===g){const $=A.current.reduce((B,X)=>{const Q=B.findIndex(J=>J.id===X.id);return Q>=0?B[Q].points+=X.points:B.push({...X}),B},[]);o({type:"addPoints",complex:!0,finish:!0,payload:$}),o({type:"passPuzzle"})}else D.current=null,_(p+1),w(0),O(!0),setTimeout(()=>{O(!1)},1200)},[F,C,g,o,p]),W=React$2.useCallback(()=>{o({type:"hidePuzzleButtons",payload:!1}),V(),y(B=>({...B,show:!1,text:""}));const $=document.querySelectorAll(".text-click__failed");$.length>0&&$.forEach(B=>B.classList.remove("text-click__failed"))},[o,V]),Z=React$2.useCallback(($,B)=>{var X,Q;$.forEach(J=>J.classList.add("text-click__success")),R(C+1),S.current+=1,E("score"),(X=t[p].info.solution.right)!=null&&X.desc?F()&&(A.current=[...A.current,...t[p].info.solution.right.rewards],G(!0,{result:!0,text:t[p].info.solution.right.desc,timeout:!1})):t[p].info.solution.right.desc===""&&(B!=null&&B.desc)?(A.current=((Q=B==null?void 0:B.rewards)==null?void 0:Q.length)>0?[...A.current,...(B==null?void 0:B.rewards)||{}]:[...A.current],G(!0,{result:!0,text:B.desc,timeout:!1})):t[p].specificFeedbacks.specificCorrectFeedbacks?(A.current=[...A.current,...(B==null?void 0:B.rewards)||{}],F()&&G(!0,{result:!0,timeout:!0})):F()&&(A.current=[...A.current,...t[p].info.solution.right.rewards],G(!0,{result:!0,timeout:!0}))},[C,E,t,p,F,G]),q=React$2.useCallback(($,B)=>{var X;$.forEach(Q=>Q.classList.add("text-click__failed")),E("fail"),o({type:"failPuzzle"}),t[p].info.solution.wrong.desc!==""?(A.current=[...A.current,...t[p].info.solution.wrong.rewards],G(!0,{result:!1,text:t[p].info.solution.wrong.desc,timeout:!1})):t[p].info.solution.wrong.desc===""&&(B!=null&&B.desc)?(A.current=(X=B==null?void 0:B.rewards)!=null&&X.length?[...A.current,...(B==null?void 0:B.rewards)||{}]:[...A.current],G(!0,{result:!1,text:B.desc,timeout:!1})):t[p].specificFeedbacks.specificWrongFeedbacks?(A.current=[...A.current,...(B==null?void 0:B.rewards)||{}],G(!0,{result:!1,timeout:!0})):(A.current=[...A.current,...t[p].info.solution.wrong.rewards],G(!0,{result:!1,timeout:!0}))},[E,o,t,p,G]),z=React$2.useCallback(($,B)=>{var ie,oe,fe,de;$.stopPropagation();const X=document.querySelectorAll(`[data-text-id="${B}"]`),Q=document.querySelectorAll("[data-text-id]"),J=t[p].correctTexts.find(ce=>ce.id===B),ne=t[p].wrongTexts.find(ce=>ce.id===B),se=(oe=(ie=t[p])==null?void 0:ie.specificFeedbacks)==null?void 0:oe.correctFeedbacks.find(ce=>ce.id===B),ee=(de=(fe=t[p])==null?void 0:fe.specificFeedbacks)==null?void 0:de.wrongFeedbacks.find(ce=>ce.id===B);E("click-ui"),t[p].hasClickOrder?t[p].correctTexts[T].id===B?(w(T+1),Z(X,se)):t[p].correctTexts.find(ce=>ce.id===B)&&t[p].correctTexts[T].id!==B?(Q.forEach(ce=>ce.classList.remove("text-click__success")),w(0),R(0),S.current=0,G(!0,{result:!1,text:t[p].info.orderFeedback.desc||k("puzzles.incorrectOrder"),timeout:!1}),_(0)):q(X,ee):(J==null?void 0:J.id)===B?Z(X,se):((ne==null?void 0:ne.id)===B||B==="allWrong")&&q(X,ee)},[t,p,E,T,Z,G,k,q]),U=React$2.useCallback($=>getRecursiveJSX($,0,t[p],z),[p,t,z]),I=React$2.useCallback(()=>{let $=0;for(let B=0;B<t.length;B+=1)if(t[B].hasClickOnce)$+=1,x($);else for(let X=0;X<t[B].correctTexts.length;X+=1)$+=1,x($)},[t]);return React$2.useEffect(()=>{var $;if(t!=null&&t[p]&&u({...t[p].info,description:a}),($=t[p])!=null&&$.text){const B=HTMLReactParser$1(t[p].text);D.current=U(B),I()}else D.current=""},[p,a,I,t,U,u]),React$2.useEffect(()=>{l($=>{o({type:"hidePuzzleButtons",payload:!0}),setTimeout(()=>{o({type:"hidePuzzleButtons",payload:!1}),$()},2e3)})},[l,o,t,p]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{className:`text-click text-click--${r}`,style:(h.show,c!=null&&c.url?{backgroundImage:`url("${c.url}")`}:{}),children:[jsxRuntimeExports.jsx("div",{className:"text-click__overlay",children:jsxRuntimeExports.jsx("div",{className:`text-click__container ${P?"slideInLeft":""} `,children:jsxRuntimeExports.jsx("div",{className:"text-click__body",children:jsxRuntimeExports.jsx("div",{className:"text-click__scroll",dir:LangIsRtl()?"rtl":"auto",children:D.current})})})}),e&&jsxRuntimeExports.jsxs("div",{className:"text-click__paginator",children:[jsxRuntimeExports.jsx("div",{className:"text-click__icon-check-circle-black",children:jsxRuntimeExports.jsx("span",{className:"icon-check-circle-black"})}),jsxRuntimeExports.jsxs("span",{className:"text-click__slide",children:[C," / ",g]})]})]}),h.show&&jsxRuntimeExports.jsx(FeedbackComponent$1,{playSound:E,success:h.result,text:h.text,translate:k,functionOnClose:W,hasTimeout:h.timeout,keyboardControl:f})]})}function ZoomTest({targetId:o,emitEvent:e}){const[r,t]=React$2.useState(!1),n=fiber.useThree(c=>c.camera),a=React$2.useRef(!1),u=React$2.useRef(null),l=({scene:c,camera:h},y)=>{const E=c.getObjectByName(o);if(E){const p=E.getObjectByName("Head_M"),_=p.getWorldPosition(new three.Vector3);h.position.distanceTo(new three.Vector3)<=5?f({scene:c,camera:h}):(p.attach(h),h.position.lerp(new three.Vector3,y*.5),h.lookAt(_))}else a.current=!1},f=({camera:c})=>{a.current=!1,c.parent=null,c.copy(u.current),e({type:"success"})};return React$2.useEffect(()=>{r||(a.current=!0,u.current=n.clone(),t(!0))},[n,r]),fiber.useFrame((c,h)=>{a.current&&l(c,h)}),null}function _assertThisInitialized(o){if(o===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return o}function _inheritsLoose(o,e){o.prototype=Object.create(e.prototype),o.prototype.constructor=o,o.__proto__=e}/*!
254
254
  * GSAP 3.12.4
255
255
  * https://gsap.com