@gamelearn/arcade-components 3.32.0 → 3.32.1
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.
|
@@ -66,7 +66,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
66
66
|
`,FORWARD_SLASH="/",ASTERISK="*",EMPTY_STRING$1="",TYPE_COMMENT="comment",TYPE_DECLARATION="declaration",inlineStyleParser=function(l,e){if(typeof l!="string")throw new TypeError("First argument must be a string");if(!l)return[];e=e||{};var n=1,t=1;function a(S){var g=S.match(NEWLINE_REGEX);g&&(n+=g.length);var v=S.lastIndexOf(NEWLINE);t=~v?S.length-v:t+S.length}function o(){var S={line:n,column:t};return function(g){return g.position=new d(S),u(),g}}function d(S){this.start=S,this.end={line:n,column:t},this.source=e.source}d.prototype.content=l;function h(S){var g=new Error(e.source+":"+n+":"+t+": "+S);if(g.reason=S,g.filename=e.source,g.line=n,g.column=t,g.source=l,!e.silent)throw g}function f(S){var g=S.exec(l);if(g){var v=g[0];return a(v),l=l.slice(v.length),g}}function u(){f(WHITESPACE_REGEX)}function p(S){var g;for(S=S||[];g=_();)g!==!1&&S.push(g);return S}function _(){var S=o();if(!(FORWARD_SLASH!=l.charAt(0)||ASTERISK!=l.charAt(1))){for(var g=2;EMPTY_STRING$1!=l.charAt(g)&&(ASTERISK!=l.charAt(g)||FORWARD_SLASH!=l.charAt(g+1));)++g;if(g+=2,EMPTY_STRING$1===l.charAt(g-1))return h("End of comment missing");var v=l.slice(2,g-2);return t+=2,a(v),l=l.slice(g),t+=2,S({type:TYPE_COMMENT,comment:v})}}function R(){var S=o(),g=f(PROPERTY_REGEX);if(g){if(_(),!f(COLON_REGEX))return h("property missing ':'");var v=f(VALUE_REGEX),b=S({type:TYPE_DECLARATION,property:trim(g[0].replace(COMMENT_REGEX,EMPTY_STRING$1)),value:v?trim(v[0].replace(COMMENT_REGEX,EMPTY_STRING$1)):EMPTY_STRING$1});return f(SEMICOLON_REGEX),b}}function x(){var S=[];p(S);for(var g;g=R();)g!==!1&&(S.push(g),p(S));return S}return u(),x()};function trim(l){return l?l.replace(TRIM_REGEX,EMPTY_STRING$1):EMPTY_STRING$1}var parse=inlineStyleParser;function StyleToObject(l,e){var n=null;if(!l||typeof l!="string")return n;for(var t,a=parse(l),o=typeof e=="function",d,h,f=0,u=a.length;f<u;f++)t=a[f],d=t.property,h=t.value,o?e(d,h,t):h&&(n||(n={}),n[d]=h);return n}var styleToObject=StyleToObject,utilities$4={};utilities$4.__esModule=!0;utilities$4.camelCase=void 0;var CUSTOM_PROPERTY_REGEX=/^--[a-zA-Z0-9-]+$/,HYPHEN_REGEX=/-([a-z])/g,NO_HYPHEN_REGEX=/^[^-]+$/,VENDOR_PREFIX_REGEX=/^-(webkit|moz|ms|o|khtml)-/,MS_VENDOR_PREFIX_REGEX=/^-(ms)-/,skipCamelCase=function(l){return!l||NO_HYPHEN_REGEX.test(l)||CUSTOM_PROPERTY_REGEX.test(l)},capitalize=function(l,e){return e.toUpperCase()},trimHyphen=function(l,e){return"".concat(e,"-")},camelCase=function(l,e){return e===void 0&&(e={}),skipCamelCase(l)?l:(l=l.toLowerCase(),e.reactCompat?l=l.replace(MS_VENDOR_PREFIX_REGEX,trimHyphen):l=l.replace(VENDOR_PREFIX_REGEX,trimHyphen),l.replace(HYPHEN_REGEX,capitalize))};utilities$4.camelCase=camelCase;(function(l){var e=commonjsGlobal&&commonjsGlobal.__importDefault||function(o){return o&&o.__esModule?o:{default:o}};l.__esModule=!0;var n=e(styleToObject),t=utilities$4;function a(o,d){var h={};return!o||typeof o!="string"||(0,n.default)(o,function(f,u){f&&u&&(h[(0,t.camelCase)(f,d)]=u)}),h}l.default=a})(cjs);var React$1=React$2,styleToJS=cjs.default;function invertObject(l,e){if(!l||typeof l!="object")throw new TypeError("First argument must be an object");var n,t,a=typeof e=="function",o={},d={};for(n in l){if(t=l[n],a&&(o=e(n,t),o&&o.length===2)){d[o[0]]=o[1];continue}typeof t=="string"&&(d[t]=n)}return d}function isCustomComponent(l,e){if(l.indexOf("-")===-1)return e&&typeof e.is=="string";switch(l){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var styleToJSOptions={reactCompat:!0};function setStyleProp$1(l,e){if(l!=null)try{e.style=styleToJS(l,styleToJSOptions)}catch{e.style={}}}var PRESERVE_CUSTOM_ATTRIBUTES=React$1.version.split(".")[0]>=16,elementsWithNoTextChildren=new Set(["tr","tbody","thead","tfoot","colgroup","table","head","html","frameset"]);function canTextBeChildOfNode$1(l){return!elementsWithNoTextChildren.has(l.name)}var utilities$3={PRESERVE_CUSTOM_ATTRIBUTES,invertObject,isCustomComponent,setStyleProp:setStyleProp$1,canTextBeChildOfNode:canTextBeChildOfNode$1,elementsWithNoTextChildren},reactProperty=lib$4,utilities$2=utilities$3,attributesToProps$2=function l(e){e=e||{};var n={reset:!0,submit:!0},t,a,o,d,h,f={},u=e.type&&n[e.type];for(t in e){if(o=e[t],reactProperty.isCustomAttribute(t)){f[t]=o;continue}if(a=t.toLowerCase(),d=getPropName(a),d){switch(h=reactProperty.getPropertyInfo(d),(d==="checked"||d==="value")&&!u&&(d=getPropName("default"+a)),f[d]=o,h&&h.type){case reactProperty.BOOLEAN:f[d]=!0;break;case reactProperty.OVERLOADED_BOOLEAN:o===""&&(f[d]=!0);break}continue}utilities$2.PRESERVE_CUSTOM_ATTRIBUTES&&(f[t]=o)}return utilities$2.setStyleProp(e.style,f),f};function getPropName(l){return reactProperty.possibleStandardNames[l]}var React=React$2,attributesToProps$1=attributesToProps$2,utilities$1=utilities$3,setStyleProp=utilities$1.setStyleProp,canTextBeChildOfNode=utilities$1.canTextBeChildOfNode;function domToReact$1(l,e){e=e||{};for(var n=e.library||React,t=n.cloneElement,a=n.createElement,o=n.isValidElement,d=[],h,f,u=typeof e.replace=="function",p,_,R,x=e.trim,S=0,g=l.length;S<g;S++){if(h=l[S],u&&(p=e.replace(h),o(p))){g>1&&(p=t(p,{key:p.key||S})),d.push(p);continue}if(h.type==="text"){if(f=!h.data.trim().length,f&&h.parent&&!canTextBeChildOfNode(h.parent)||x&&f)continue;d.push(h.data);continue}switch(_=h.attribs,skipAttributesToProps(h)?setStyleProp(_.style,_):_&&(_=attributesToProps$1(_)),R=null,h.type){case"script":case"style":h.children[0]&&(_.dangerouslySetInnerHTML={__html:h.children[0].data});break;case"tag":h.name==="textarea"&&h.children[0]?_.defaultValue=h.children[0].data:h.children&&h.children.length&&(R=domToReact$1(h.children,e));break;default:continue}g>1&&(_.key=S),d.push(a(h.name,_,R))}return d.length===1?d[0]:d}function skipAttributesToProps(l){return utilities$1.PRESERVE_CUSTOM_ATTRIBUTES&&l.type==="tag"&&utilities$1.isCustomComponent(l.name,l.attribs)}var domToReact_1=domToReact$1,CASE_SENSITIVE_TAG_NAMES$1=["animateMotion","animateTransform","clipPath","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussainBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","foreignObject","linearGradient","radialGradient","textPath"],constants$2={CASE_SENSITIVE_TAG_NAMES:CASE_SENSITIVE_TAG_NAMES$1},node={},lib$3={},hasRequiredLib$1;function requireLib$1(){return hasRequiredLib$1||(hasRequiredLib$1=1,function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Doctype=l.CDATA=l.Tag=l.Style=l.Script=l.Comment=l.Directive=l.Text=l.Root=l.isTag=l.ElementType=void 0;var e;(function(t){t.Root="root",t.Text="text",t.Directive="directive",t.Comment="comment",t.Script="script",t.Style="style",t.Tag="tag",t.CDATA="cdata",t.Doctype="doctype"})(e=l.ElementType||(l.ElementType={}));function n(t){return t.type===e.Tag||t.type===e.Script||t.type===e.Style}l.isTag=n,l.Root=e.Root,l.Text=e.Text,l.Directive=e.Directive,l.Comment=e.Comment,l.Script=e.Script,l.Style=e.Style,l.Tag=e.Tag,l.CDATA=e.CDATA,l.Doctype=e.Doctype}(lib$3)),lib$3}var __extends=commonjsGlobal&&commonjsGlobal.__extends||function(){var l=function(e,n){return l=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,a){t.__proto__=a}||function(t,a){for(var o in a)Object.prototype.hasOwnProperty.call(a,o)&&(t[o]=a[o])},l(e,n)};return function(e,n){if(typeof n!="function"&&n!==null)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");l(e,n);function t(){this.constructor=e}e.prototype=n===null?Object.create(n):(t.prototype=n.prototype,new t)}}(),__assign=commonjsGlobal&&commonjsGlobal.__assign||function(){return __assign=Object.assign||function(l){for(var e,n=1,t=arguments.length;n<t;n++){e=arguments[n];for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&(l[a]=e[a])}return l},__assign.apply(this,arguments)};Object.defineProperty(node,"__esModule",{value:!0});node.cloneNode=node.hasChildren=node.isDocument=node.isDirective=node.isComment=node.isText=node.isCDATA=node.isTag=node.Element=node.Document=node.NodeWithChildren=node.ProcessingInstruction=node.Comment=node.Text=node.DataNode=node.Node=void 0;var domelementtype_1=requireLib$1(),nodeTypes=new Map([[domelementtype_1.ElementType.Tag,1],[domelementtype_1.ElementType.Script,1],[domelementtype_1.ElementType.Style,1],[domelementtype_1.ElementType.Directive,1],[domelementtype_1.ElementType.Text,3],[domelementtype_1.ElementType.CDATA,4],[domelementtype_1.ElementType.Comment,8],[domelementtype_1.ElementType.Root,9]]),Node$2=function(){function l(e){this.type=e,this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}return Object.defineProperty(l.prototype,"nodeType",{get:function(){var e;return(e=nodeTypes.get(this.type))!==null&&e!==void 0?e:1},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"parentNode",{get:function(){return this.parent},set:function(e){this.parent=e},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"previousSibling",{get:function(){return this.prev},set:function(e){this.prev=e},enumerable:!1,configurable:!0}),Object.defineProperty(l.prototype,"nextSibling",{get:function(){return this.next},set:function(e){this.next=e},enumerable:!1,configurable:!0}),l.prototype.cloneNode=function(e){return e===void 0&&(e=!1),cloneNode(this,e)},l}();node.Node=Node$2;var DataNode=function(l){__extends(e,l);function e(n,t){var a=l.call(this,n)||this;return a.data=t,a}return Object.defineProperty(e.prototype,"nodeValue",{get:function(){return this.data},set:function(n){this.data=n},enumerable:!1,configurable:!0}),e}(Node$2);node.DataNode=DataNode;var Text$4=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Text,n)||this}return e}(DataNode);node.Text=Text$4;var Comment$1=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Comment,n)||this}return e}(DataNode);node.Comment=Comment$1;var ProcessingInstruction$1=function(l){__extends(e,l);function e(n,t){var a=l.call(this,domelementtype_1.ElementType.Directive,t)||this;return a.name=n,a}return e}(DataNode);node.ProcessingInstruction=ProcessingInstruction$1;var NodeWithChildren=function(l){__extends(e,l);function e(n,t){var a=l.call(this,n)||this;return a.children=t,a}return Object.defineProperty(e.prototype,"firstChild",{get:function(){var n;return(n=this.children[0])!==null&&n!==void 0?n:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastChild",{get:function(){return this.children.length>0?this.children[this.children.length-1]:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"childNodes",{get:function(){return this.children},set:function(n){this.children=n},enumerable:!1,configurable:!0}),e}(Node$2);node.NodeWithChildren=NodeWithChildren;var Document=function(l){__extends(e,l);function e(n){return l.call(this,domelementtype_1.ElementType.Root,n)||this}return e}(NodeWithChildren);node.Document=Document;var Element$1=function(l){__extends(e,l);function e(n,t,a,o){a===void 0&&(a=[]),o===void 0&&(o=n==="script"?domelementtype_1.ElementType.Script:n==="style"?domelementtype_1.ElementType.Style:domelementtype_1.ElementType.Tag);var d=l.call(this,o,a)||this;return d.name=n,d.attribs=t,d}return Object.defineProperty(e.prototype,"tagName",{get:function(){return this.name},set:function(n){this.name=n},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"attributes",{get:function(){var n=this;return Object.keys(this.attribs).map(function(t){var a,o;return{name:t,value:n.attribs[t],namespace:(a=n["x-attribsNamespace"])===null||a===void 0?void 0:a[t],prefix:(o=n["x-attribsPrefix"])===null||o===void 0?void 0:o[t]}})},enumerable:!1,configurable:!0}),e}(NodeWithChildren);node.Element=Element$1;function isTag(l){return(0,domelementtype_1.isTag)(l)}node.isTag=isTag;function isCDATA(l){return l.type===domelementtype_1.ElementType.CDATA}node.isCDATA=isCDATA;function isText(l){return l.type===domelementtype_1.ElementType.Text}node.isText=isText;function isComment(l){return l.type===domelementtype_1.ElementType.Comment}node.isComment=isComment;function isDirective(l){return l.type===domelementtype_1.ElementType.Directive}node.isDirective=isDirective;function isDocument(l){return l.type===domelementtype_1.ElementType.Root}node.isDocument=isDocument;function hasChildren(l){return Object.prototype.hasOwnProperty.call(l,"children")}node.hasChildren=hasChildren;function cloneNode(l,e){e===void 0&&(e=!1);var n;if(isText(l))n=new Text$4(l.data);else if(isComment(l))n=new Comment$1(l.data);else if(isTag(l)){var t=e?cloneChildren(l.children):[],a=new Element$1(l.name,__assign({},l.attribs),t);t.forEach(function(f){return f.parent=a}),l.namespace!=null&&(a.namespace=l.namespace),l["x-attribsNamespace"]&&(a["x-attribsNamespace"]=__assign({},l["x-attribsNamespace"])),l["x-attribsPrefix"]&&(a["x-attribsPrefix"]=__assign({},l["x-attribsPrefix"])),n=a}else if(isCDATA(l)){var t=e?cloneChildren(l.children):[],o=new NodeWithChildren(domelementtype_1.ElementType.CDATA,t);t.forEach(function(u){return u.parent=o}),n=o}else if(isDocument(l)){var t=e?cloneChildren(l.children):[],d=new Document(t);t.forEach(function(u){return u.parent=d}),l["x-mode"]&&(d["x-mode"]=l["x-mode"]),n=d}else if(isDirective(l)){var h=new ProcessingInstruction$1(l.name,l.data);l["x-name"]!=null&&(h["x-name"]=l["x-name"],h["x-publicId"]=l["x-publicId"],h["x-systemId"]=l["x-systemId"]),n=h}else throw new Error("Not implemented yet: ".concat(l.type));return n.startIndex=l.startIndex,n.endIndex=l.endIndex,l.sourceCodeLocation!=null&&(n.sourceCodeLocation=l.sourceCodeLocation),n}node.cloneNode=cloneNode;function cloneChildren(l){for(var e=l.map(function(t){return cloneNode(t,!0)}),n=1;n<e.length;n++)e[n].prev=e[n-1],e[n-1].next=e[n];return e}var constants$1=constants$2,domhandler=node,CASE_SENSITIVE_TAG_NAMES=constants$1.CASE_SENSITIVE_TAG_NAMES,Comment=domhandler.Comment,Element=domhandler.Element,ProcessingInstruction=domhandler.ProcessingInstruction,Text$3=domhandler.Text,caseSensitiveTagNamesMap={},tagName;for(var i$1=0,len=CASE_SENSITIVE_TAG_NAMES.length;i$1<len;i$1++)tagName=CASE_SENSITIVE_TAG_NAMES[i$1],caseSensitiveTagNamesMap[tagName.toLowerCase()]=tagName;function getCaseSensitiveTagName(l){return caseSensitiveTagNamesMap[l]}function formatAttributes(l){for(var e={},n,t=0,a=l.length;t<a;t++)n=l[t],e[n.name]=n.value;return e}function formatTagName(l){l=l.toLowerCase();var e=getCaseSensitiveTagName(l);return e||l}function formatDOM$1(l,e,n){e=e||null;for(var t=[],a=0,o=l.length;a<o;a++){var d=l[a],h;switch(d.nodeType){case 1:h=new Element(formatTagName(d.nodeName),formatAttributes(d.attributes)),h.children=formatDOM$1(d.childNodes,h);break;case 3:h=new Text$3(d.nodeValue);break;case 8:h=new Comment(d.nodeValue);break;default:continue}var f=t[a-1]||null;f&&(f.next=h),h.parent=e,h.prev=f,h.next=null,t.push(h)}return n&&(h=new ProcessingInstruction(n.substring(0,n.indexOf(" ")).toLowerCase(),n),h.next=t[0]||null,h.parent=e,t.unshift(h),t[1]&&(t[1].prev=t[0])),t}function isIE$1(){return/(MSIE |Trident\/|Edge\/)/.test(navigator.userAgent)}var utilities={formatAttributes,formatDOM:formatDOM$1,isIE:isIE$1},HTML="html",HEAD="head",BODY="body",FIRST_TAG_REGEX=/<([a-zA-Z]+[0-9]?)/,HEAD_TAG_REGEX=/<head.*>/i,BODY_TAG_REGEX=/<body.*>/i,parseFromDocument=function(){throw new Error("This browser does not support `document.implementation.createHTMLDocument`")},parseFromString=function(){throw new Error("This browser does not support `DOMParser.prototype.parseFromString`")};if(typeof window.DOMParser=="function"){var domParser=new window.DOMParser,mimeType="text/html";parseFromString=function(l,e){return e&&(l="<"+e+">"+l+"</"+e+">"),domParser.parseFromString(l,mimeType)},parseFromDocument=parseFromString}if(document.implementation){var isIE=utilities.isIE,doc=document.implementation.createHTMLDocument(isIE()?"html-dom-parser":void 0);parseFromDocument=function(l,e){return e?(doc.documentElement.getElementsByTagName(e)[0].innerHTML=l,doc):(doc.documentElement.innerHTML=l,doc)}}var template=document.createElement("template"),parseFromTemplate;template.content&&(parseFromTemplate=function(l){return template.innerHTML=l,template.content.childNodes});function domparser$1(l){var e,n=l.match(FIRST_TAG_REGEX);n&&n[1]&&(e=n[1].toLowerCase());var t,a,o;switch(e){case HTML:return t=parseFromString(l),HEAD_TAG_REGEX.test(l)||(a=t.getElementsByTagName(HEAD)[0],a&&a.parentNode.removeChild(a)),BODY_TAG_REGEX.test(l)||(a=t.getElementsByTagName(BODY)[0],a&&a.parentNode.removeChild(a)),t.getElementsByTagName(HTML);case HEAD:case BODY:return o=parseFromDocument(l).getElementsByTagName(e),BODY_TAG_REGEX.test(l)&&HEAD_TAG_REGEX.test(l)?o[0].parentNode.childNodes:o;default:return parseFromTemplate?parseFromTemplate(l):parseFromDocument(l,BODY).getElementsByTagName(BODY)[0].childNodes}}var domparser_1=domparser$1,domparser=domparser_1,formatDOM=utilities.formatDOM,DIRECTIVE_REGEX=/<(![a-zA-Z\s]+)>/;function HTMLDOMParser(l){if(typeof l!="string")throw new TypeError("First argument must be a string");if(l==="")return[];var e=l.match(DIRECTIVE_REGEX),n;return e&&e[1]&&(n=e[1]),formatDOM(domparser(l),null,n)}var htmlToDom=HTMLDOMParser,lib$2={},hasRequiredLib;function requireLib(){return hasRequiredLib||(hasRequiredLib=1,function(l){var e=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(f,u,p,_){_===void 0&&(_=p);var R=Object.getOwnPropertyDescriptor(u,p);(!R||("get"in R?!u.__esModule:R.writable||R.configurable))&&(R={enumerable:!0,get:function(){return u[p]}}),Object.defineProperty(f,_,R)}:function(f,u,p,_){_===void 0&&(_=p),f[_]=u[p]}),n=commonjsGlobal&&commonjsGlobal.__exportStar||function(f,u){for(var p in f)p!=="default"&&!Object.prototype.hasOwnProperty.call(u,p)&&e(u,f,p)};Object.defineProperty(l,"__esModule",{value:!0}),l.DomHandler=void 0;var t=requireLib$1(),a=node;n(node,l);var o=/\s+/g,d={normalizeWhitespace:!1,withStartIndices:!1,withEndIndices:!1,xmlMode:!1},h=function(){function f(u,p,_){this.dom=[],this.root=new a.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof p=="function"&&(_=p,p=d),typeof u=="object"&&(p=u,u=void 0),this.callback=u??null,this.options=p??d,this.elementCB=_??null}return f.prototype.onparserinit=function(u){this.parser=u},f.prototype.onreset=function(){this.dom=[],this.root=new a.Document(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null},f.prototype.onend=function(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))},f.prototype.onerror=function(u){this.handleCallback(u)},f.prototype.onclosetag=function(){this.lastNode=null;var u=this.tagStack.pop();this.options.withEndIndices&&(u.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(u)},f.prototype.onopentag=function(u,p){var _=this.options.xmlMode?t.ElementType.Tag:void 0,R=new a.Element(u,p,void 0,_);this.addNode(R),this.tagStack.push(R)},f.prototype.ontext=function(u){var p=this.options.normalizeWhitespace,_=this.lastNode;if(_&&_.type===t.ElementType.Text)p?_.data=(_.data+u).replace(o," "):_.data+=u,this.options.withEndIndices&&(_.endIndex=this.parser.endIndex);else{p&&(u=u.replace(o," "));var R=new a.Text(u);this.addNode(R),this.lastNode=R}},f.prototype.oncomment=function(u){if(this.lastNode&&this.lastNode.type===t.ElementType.Comment){this.lastNode.data+=u;return}var p=new a.Comment(u);this.addNode(p),this.lastNode=p},f.prototype.oncommentend=function(){this.lastNode=null},f.prototype.oncdatastart=function(){var u=new a.Text(""),p=new a.NodeWithChildren(t.ElementType.CDATA,[u]);this.addNode(p),u.parent=p,this.lastNode=u},f.prototype.oncdataend=function(){this.lastNode=null},f.prototype.onprocessinginstruction=function(u,p){var _=new a.ProcessingInstruction(u,p);this.addNode(_)},f.prototype.handleCallback=function(u){if(typeof this.callback=="function")this.callback(u,this.dom);else if(u)throw u},f.prototype.addNode=function(u){var p=this.tagStack[this.tagStack.length-1],_=p.children[p.children.length-1];this.options.withStartIndices&&(u.startIndex=this.parser.startIndex),this.options.withEndIndices&&(u.endIndex=this.parser.endIndex),p.children.push(u),_&&(u.prev=_,_.next=u),u.parent=p,this.lastNode=null},f}();l.DomHandler=h,l.default=h}(lib$2)),lib$2}var domToReact=domToReact_1,attributesToProps=attributesToProps$2,htmlToDOM=htmlToDom;htmlToDOM=typeof htmlToDOM.default=="function"?htmlToDOM.default:htmlToDOM;var domParserOptions={lowerCaseAttributeNames:!1};function HTMLReactParser(l,e){if(typeof l!="string")throw new TypeError("First argument must be a string");return l===""?[]:(e=e||{},domToReact(htmlToDOM(l,e.htmlparser2||domParserOptions),e))}HTMLReactParser.domToReact=domToReact;HTMLReactParser.htmlToDOM=htmlToDOM;HTMLReactParser.attributesToProps=attributesToProps;HTMLReactParser.Element=requireLib().Element;htmlReactParser.exports=HTMLReactParser;htmlReactParser.exports.default=HTMLReactParser;var htmlReactParserExports=htmlReactParser.exports;const HTMLReactParser$1=getDefaultExportFromCjs(htmlReactParserExports);HTMLReactParser$1.domToReact;HTMLReactParser$1.htmlToDOM;HTMLReactParser$1.attributesToProps;HTMLReactParser$1.Element;function LectureButtons({goToLecture:l,close:e,minutes:n,seconds:t,btnText:a}){return jsxRuntimeExports.jsx("div",{className:"lectures--buttons",children:l?jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__navigation",onClick:()=>e(),"aria-label":a,children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__count","data-testid":"countdown",children:jsxRuntimeExports.jsxs("span",{children:[n<10?`0${n}`:n,":",t<10?`0${t}`:t]})})})}LectureButtons.defaultProps={goToLecture:!1,close:()=>{},minutes:0,seconds:0};const noop$1=()=>{},ttsCache={},useEkho=({voice:l,text:e,audioType:n,loop:t=!1,started:a=!0,audio:o,soundActions:d,getEvent:h,volume:f=.5,onFinish:u=noop$1,onMute:p=noop$1,onError:_=noop$1,onStart:R=noop$1,pauseTTS:x})=>{const[S,g,v,b]=d,T=!o&&!l,y=React$2.useRef(),[w,C]=React$2.useState(!1),N=React$2.useRef({url:"",cc:"tts"}),D=React$2.useCallback(j=>h({type:"translate",payload:j}),[h]),P=React$2.useCallback(({id:j,type:$="base"})=>{var re;const B=D("usedVoices"),X=D("gameCharacters");return $==="base"?B==null?void 0:B[j]:$==="character"?(re=X==null?void 0:X[j])==null?void 0:re.voiceId:null},[D]),k=React$2.useCallback((j,$="tts")=>{if(N.current.url!==j)return N.current={url:j,cc:$},S(j,$,t,f,u,R,p,_)},[S,t,f,u,R,p,_]),F=React$2.useCallback(async j=>{if(w&&j.voiceId&&j.text){let $=ttsCache[`${j.voiceId}_${j.text}`];try{$||($=await h({type:"getSpeech",payload:j}),$?ttsCache[`${j.voiceId}_${j.text}`]=$:_()),$&&(y.current=k($))}catch{_()}}else _()},[h,w,_,k]),M=React$2.useCallback(()=>{N.current.url&&g(N.current.cc)},[g]);return React$2.useEffect(()=>(C(!0),()=>{C(!1),M()}),[M]),React$2.useEffect(()=>{x?v():b()},[v,x,b]),React$2.useEffect(()=>{T&&M()},[T,M]),React$2.useEffect(()=>{if(w&&a)if(n==="voice"&&(l!=null&&l.id)){const j=P(l);F({voiceId:j,text:e})}else(n==="file"||!n)&&o?y.current=k(o==null?void 0:o.url):_()},[o,n,P,w,_,F,k,a,e,l]),[y,M]},cleanTextOfHtmlTags=l=>{const e=document.createElement("div");return e.innerHTML=l,e.textContent||e.innerText||""},READING_TIME=.2;function LecturesComponent({emitEvent:l,getEvent:e,name:n,name_labelId:t,required:a,text:o,text_labelId:d,visible:h,documentType:f,viewed:u,soundActions:p,backgroundImage:_,hideBackgroundImageTheme:R=!1,keyboardControl:x,audio:S,audioType:g,audioVolume:v,voice:b,pause:T,styles:y}){const[w,C]=React$2.useState(),[N,D]=React$2.useState(!1),[P,k]=React$2.useState(0),F=o,M=Math.trunc(F.split(" ").length*READING_TIME),j=!a||a&&P>=M||a&&!h,[$]=p,B=`${n}. ${cleanTextOfHtmlTags(o)}`;useEkho({audioType:g,voice:b,text:B,audio:S,soundActions:p,getEvent:e,volume:v,pauseTTS:T});const X=J=>e({type:"translate",payload:J}),re=React$2.useCallback(()=>{j&&($("click-ui"),l({type:"finishMedia",payload:{name:t,type:"text",text:d,documentType:f}}))},[f,l,j,t,d,$]),ae=x({disabled:u,forward:re,escape:re});React$2.useEffect(()=>ae(),[ae]),React$2.useEffect(()=>{if(!h&&!N&&(re(),D(!0)),a&&h){const J=setInterval(()=>{k(H=>H+1)},1e3);return C(J),()=>{clearInterval(J)}}},[re,a,N,h]),React$2.useEffect(()=>{P===M&&clearInterval(w)},[w,P,M]);const ee=M-P,K=Math.floor(ee/60),ne=ee%60,ue=React$2.useMemo(()=>{let J="";return u?J="notes--results":(J="lectures--container",y&&(J+=` lectures--container--${y}`),_!=null&&_.url&&(J+=" lectures--container--with-custom-bg"),y&&R&&(J+=" disable-background-image")),J},[_==null?void 0:_.url,R,y,u]),me={backgroundImage:_!=null&&_.url?`url('${_.url}')`:""};return h?jsxRuntimeExports.jsx("div",{className:ue,style:me,children:jsxRuntimeExports.jsx("div",{className:u?"":"lectures__overlay",children:jsxRuntimeExports.jsxs("div",{className:u?"notes--results__text":`lectures lectures--${y}`,children:[jsxRuntimeExports.jsx("div",{className:"lectures--title",children:n}),jsxRuntimeExports.jsxs("div",{className:"lectures--text",dir:"auto",children:[jsxRuntimeExports.jsx("div",{children:F?HTMLReactParser$1(F):null}),u?null:jsxRuntimeExports.jsx(LectureButtons,{goToLecture:j,close:re,minutes:K,seconds:ne,btnText:X("screens.continue")})]})]})})}):null}LecturesComponent.defaultProps={emitEvent:()=>{},name:"",text:"",visible:!1,documentType:"",viewed:!1,required:!1,context:{},styles:""};function Slot({character:l,active:e,slot:n,lowQuality:t}){var R;const a=l.type==="image",o=l.type==="character",d=l.type==="object",h=(R=l==null?void 0:l.resource)==null?void 0:R.url,f=()=>a?`url(${h})`:o&&t?`url(${h.replace("character.glb","face.png")})`:d&&t?`url(${h.replace("object.glb","thumbnail.png")})`:"",u=()=>a?"contain":o||d?"auto 95%":"",p=()=>a?"center":o||d?"center bottom":"",_=a||t?{backgroundImage:f(),backgroundRepeat:"no-repeat",backgroundPosition:p(),backgroundSize:u()}:{};return jsxRuntimeExports.jsx("div",{className:`conversation--character__item ${e?"active":""} ${n}`,style:_,children:e&&l.name?jsxRuntimeExports.jsx("span",{className:"conversation--character__name",children:l.name}):null},l.name)}Slot.propTypes={character:PropTypes.shape({name:PropTypes.string,url:PropTypes.string,type:PropTypes.string,emotion:PropTypes.string,uid:PropTypes.string,resource:PropTypes.shape({resourceId:PropTypes.string,url:PropTypes.string})}),active:PropTypes.bool,slot:PropTypes.number};Slot.defaultProps={character:{name:"",url:"",type:"",resource:{resourceId:""}},active:!1,slot:0};function toTrianglesDrawMode(l,e){if(e===three.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),l;if(e===three.TriangleFanDrawMode||e===three.TriangleStripDrawMode){let n=l.getIndex();if(n===null){const d=[],h=l.getAttribute("position");if(h!==void 0){for(let f=0;f<h.count;f++)d.push(f);l.setIndex(d),n=l.getIndex()}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),l}const t=n.count-2,a=[];if(e===three.TriangleFanDrawMode)for(let d=1;d<=t;d++)a.push(n.getX(0)),a.push(n.getX(d)),a.push(n.getX(d+1));else for(let d=0;d<t;d++)d%2===0?(a.push(n.getX(d)),a.push(n.getX(d+1)),a.push(n.getX(d+2))):(a.push(n.getX(d+2)),a.push(n.getX(d+1)),a.push(n.getX(d)));a.length/3!==t&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const o=l.clone();return o.setIndex(a),o.clearGroups(),o}else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",e),l}class GLTFLoader extends three.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(n){return new GLTFMaterialsClearcoatExtension(n)}),this.register(function(n){return new GLTFTextureBasisUExtension(n)}),this.register(function(n){return new GLTFTextureWebPExtension(n)}),this.register(function(n){return new GLTFTextureAVIFExtension(n)}),this.register(function(n){return new GLTFMaterialsSheenExtension(n)}),this.register(function(n){return new GLTFMaterialsTransmissionExtension(n)}),this.register(function(n){return new GLTFMaterialsVolumeExtension(n)}),this.register(function(n){return new GLTFMaterialsIorExtension(n)}),this.register(function(n){return new GLTFMaterialsEmissiveStrengthExtension(n)}),this.register(function(n){return new GLTFMaterialsSpecularExtension(n)}),this.register(function(n){return new GLTFMaterialsIridescenceExtension(n)}),this.register(function(n){return new GLTFMaterialsAnisotropyExtension(n)}),this.register(function(n){return new GLTFMaterialsBumpExtension(n)}),this.register(function(n){return new GLTFLightsExtension(n)}),this.register(function(n){return new GLTFMeshoptCompression(n)}),this.register(function(n){return new GLTFMeshGpuInstancing(n)})}load(e,n,t,a){const o=this;let d;if(this.resourcePath!=="")d=this.resourcePath;else if(this.path!==""){const u=three.LoaderUtils.extractUrlBase(e);d=three.LoaderUtils.resolveURL(u,this.path)}else d=three.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);const h=function(u){a?a(u):console.error(u),o.manager.itemError(e),o.manager.itemEnd(e)},f=new three.FileLoader(this.manager);f.setPath(this.path),f.setResponseType("arraybuffer"),f.setRequestHeader(this.requestHeader),f.setWithCredentials(this.withCredentials),f.load(e,function(u){try{o.parse(u,d,function(p){n(p),o.manager.itemEnd(e)},h)}catch(p){h(p)}},t,h)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,n,t,a){let o;const d={},h={},f=new TextDecoder;if(typeof e=="string")o=JSON.parse(e);else if(e instanceof ArrayBuffer)if(f.decode(new Uint8Array(e,0,4))===BINARY_EXTENSION_HEADER_MAGIC){try{d[EXTENSIONS.KHR_BINARY_GLTF]=new GLTFBinaryExtension(e)}catch(_){a&&a(_);return}o=JSON.parse(d[EXTENSIONS.KHR_BINARY_GLTF].content)}else o=JSON.parse(f.decode(e));else o=e;if(o.asset===void 0||o.asset.version[0]<2){a&&a(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}const u=new GLTFParser(o,{path:n||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});u.fileLoader.setRequestHeader(this.requestHeader);for(let p=0;p<this.pluginCallbacks.length;p++){const _=this.pluginCallbacks[p](u);_.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),h[_.name]=_,d[_.name]=!0}if(o.extensionsUsed)for(let p=0;p<o.extensionsUsed.length;++p){const _=o.extensionsUsed[p],R=o.extensionsRequired||[];switch(_){case EXTENSIONS.KHR_MATERIALS_UNLIT:d[_]=new GLTFMaterialsUnlitExtension;break;case EXTENSIONS.KHR_DRACO_MESH_COMPRESSION:d[_]=new GLTFDracoMeshCompressionExtension(o,this.dracoLoader);break;case EXTENSIONS.KHR_TEXTURE_TRANSFORM:d[_]=new GLTFTextureTransformExtension;break;case EXTENSIONS.KHR_MESH_QUANTIZATION:d[_]=new GLTFMeshQuantizationExtension;break;default:R.indexOf(_)>=0&&h[_]===void 0&&console.warn('THREE.GLTFLoader: Unknown extension "'+_+'".')}}u.setExtensions(d),u.setPlugins(h),u.parse(t,a)}parseAsync(e,n){const t=this;return new Promise(function(a,o){t.parse(e,n,a,o)})}}function GLTFRegistry(){let l={};return{get:function(e){return l[e]},add:function(e,n){l[e]=n},remove:function(e){delete l[e]},removeAll:function(){l={}}}}const EXTENSIONS={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class GLTFLightsExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,n=this.parser.json.nodes||[];for(let t=0,a=n.length;t<a;t++){const o=n[t];o.extensions&&o.extensions[this.name]&&o.extensions[this.name].light!==void 0&&e._addNodeRef(this.cache,o.extensions[this.name].light)}}_loadLight(e){const n=this.parser,t="light:"+e;let a=n.cache.get(t);if(a)return a;const o=n.json,f=((o.extensions&&o.extensions[this.name]||{}).lights||[])[e];let u;const p=new three.Color(16777215);f.color!==void 0&&p.setRGB(f.color[0],f.color[1],f.color[2],three.LinearSRGBColorSpace);const _=f.range!==void 0?f.range:0;switch(f.type){case"directional":u=new three.DirectionalLight(p),u.target.position.set(0,0,-1),u.add(u.target);break;case"point":u=new three.PointLight(p),u.distance=_;break;case"spot":u=new three.SpotLight(p),u.distance=_,f.spot=f.spot||{},f.spot.innerConeAngle=f.spot.innerConeAngle!==void 0?f.spot.innerConeAngle:0,f.spot.outerConeAngle=f.spot.outerConeAngle!==void 0?f.spot.outerConeAngle:Math.PI/4,u.angle=f.spot.outerConeAngle,u.penumbra=1-f.spot.innerConeAngle/f.spot.outerConeAngle,u.target.position.set(0,0,-1),u.add(u.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+f.type)}return u.position.set(0,0,0),u.decay=2,assignExtrasToUserData(u,f),f.intensity!==void 0&&(u.intensity=f.intensity),u.name=n.createUniqueName(f.name||"light_"+e),a=Promise.resolve(u),n.cache.add(t,a),a}getDependency(e,n){if(e==="light")return this._loadLight(n)}createNodeAttachment(e){const n=this,t=this.parser,o=t.json.nodes[e],h=(o.extensions&&o.extensions[this.name]||{}).light;return h===void 0?null:this._loadLight(h).then(function(f){return t._getNodeRef(n.cache,h,f)})}}class GLTFMaterialsUnlitExtension{constructor(){this.name=EXTENSIONS.KHR_MATERIALS_UNLIT}getMaterialType(){return three.MeshBasicMaterial}extendParams(e,n,t){const a=[];e.color=new three.Color(1,1,1),e.opacity=1;const o=n.pbrMetallicRoughness;if(o){if(Array.isArray(o.baseColorFactor)){const d=o.baseColorFactor;e.color.setRGB(d[0],d[1],d[2],three.LinearSRGBColorSpace),e.opacity=d[3]}o.baseColorTexture!==void 0&&a.push(t.assignTexture(e,"map",o.baseColorTexture,three.SRGBColorSpace))}return Promise.all(a)}}class GLTFMaterialsEmissiveStrengthExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=a.extensions[this.name].emissiveStrength;return o!==void 0&&(n.emissiveIntensity=o),Promise.resolve()}}class GLTFMaterialsClearcoatExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];if(d.clearcoatFactor!==void 0&&(n.clearcoat=d.clearcoatFactor),d.clearcoatTexture!==void 0&&o.push(t.assignTexture(n,"clearcoatMap",d.clearcoatTexture)),d.clearcoatRoughnessFactor!==void 0&&(n.clearcoatRoughness=d.clearcoatRoughnessFactor),d.clearcoatRoughnessTexture!==void 0&&o.push(t.assignTexture(n,"clearcoatRoughnessMap",d.clearcoatRoughnessTexture)),d.clearcoatNormalTexture!==void 0&&(o.push(t.assignTexture(n,"clearcoatNormalMap",d.clearcoatNormalTexture)),d.clearcoatNormalTexture.scale!==void 0)){const h=d.clearcoatNormalTexture.scale;n.clearcoatNormalScale=new three.Vector2(h,h)}return Promise.all(o)}}class GLTFMaterialsIridescenceExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.iridescenceFactor!==void 0&&(n.iridescence=d.iridescenceFactor),d.iridescenceTexture!==void 0&&o.push(t.assignTexture(n,"iridescenceMap",d.iridescenceTexture)),d.iridescenceIor!==void 0&&(n.iridescenceIOR=d.iridescenceIor),n.iridescenceThicknessRange===void 0&&(n.iridescenceThicknessRange=[100,400]),d.iridescenceThicknessMinimum!==void 0&&(n.iridescenceThicknessRange[0]=d.iridescenceThicknessMinimum),d.iridescenceThicknessMaximum!==void 0&&(n.iridescenceThicknessRange[1]=d.iridescenceThicknessMaximum),d.iridescenceThicknessTexture!==void 0&&o.push(t.assignTexture(n,"iridescenceThicknessMap",d.iridescenceThicknessTexture)),Promise.all(o)}}class GLTFMaterialsSheenExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[];n.sheenColor=new three.Color(0,0,0),n.sheenRoughness=0,n.sheen=1;const d=a.extensions[this.name];if(d.sheenColorFactor!==void 0){const h=d.sheenColorFactor;n.sheenColor.setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace)}return d.sheenRoughnessFactor!==void 0&&(n.sheenRoughness=d.sheenRoughnessFactor),d.sheenColorTexture!==void 0&&o.push(t.assignTexture(n,"sheenColorMap",d.sheenColorTexture,three.SRGBColorSpace)),d.sheenRoughnessTexture!==void 0&&o.push(t.assignTexture(n,"sheenRoughnessMap",d.sheenRoughnessTexture)),Promise.all(o)}}class GLTFMaterialsTransmissionExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.transmissionFactor!==void 0&&(n.transmission=d.transmissionFactor),d.transmissionTexture!==void 0&&o.push(t.assignTexture(n,"transmissionMap",d.transmissionTexture)),Promise.all(o)}}class GLTFMaterialsVolumeExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];n.thickness=d.thicknessFactor!==void 0?d.thicknessFactor:0,d.thicknessTexture!==void 0&&o.push(t.assignTexture(n,"thicknessMap",d.thicknessTexture)),n.attenuationDistance=d.attenuationDistance||1/0;const h=d.attenuationColor||[1,1,1];return n.attenuationColor=new three.Color().setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace),Promise.all(o)}}class GLTFMaterialsIorExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const a=this.parser.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=a.extensions[this.name];return n.ior=o.ior!==void 0?o.ior:1.5,Promise.resolve()}}class GLTFMaterialsSpecularExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];n.specularIntensity=d.specularFactor!==void 0?d.specularFactor:1,d.specularTexture!==void 0&&o.push(t.assignTexture(n,"specularIntensityMap",d.specularTexture));const h=d.specularColorFactor||[1,1,1];return n.specularColor=new three.Color().setRGB(h[0],h[1],h[2],three.LinearSRGBColorSpace),d.specularColorTexture!==void 0&&o.push(t.assignTexture(n,"specularColorMap",d.specularColorTexture,three.SRGBColorSpace)),Promise.all(o)}}class GLTFMaterialsBumpExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return n.bumpScale=d.bumpFactor!==void 0?d.bumpFactor:1,d.bumpTexture!==void 0&&o.push(t.assignTexture(n,"bumpMap",d.bumpTexture)),Promise.all(o)}}class GLTFMaterialsAnisotropyExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return!t.extensions||!t.extensions[this.name]?null:three.MeshPhysicalMaterial}extendMaterialParams(e,n){const t=this.parser,a=t.json.materials[e];if(!a.extensions||!a.extensions[this.name])return Promise.resolve();const o=[],d=a.extensions[this.name];return d.anisotropyStrength!==void 0&&(n.anisotropy=d.anisotropyStrength),d.anisotropyRotation!==void 0&&(n.anisotropyRotation=d.anisotropyRotation),d.anisotropyTexture!==void 0&&o.push(t.assignTexture(n,"anisotropyMap",d.anisotropyTexture)),Promise.all(o)}}class GLTFTextureBasisUExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.KHR_TEXTURE_BASISU}loadTexture(e){const n=this.parser,t=n.json,a=t.textures[e];if(!a.extensions||!a.extensions[this.name])return null;const o=a.extensions[this.name],d=n.options.ktx2Loader;if(!d){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return n.loadTextureImage(e,o.source,d)}}class GLTFTextureWebPExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const n=this.name,t=this.parser,a=t.json,o=a.textures[e];if(!o.extensions||!o.extensions[n])return null;const d=o.extensions[n],h=a.images[d.source];let f=t.textureLoader;if(h.uri){const u=t.options.manager.getHandler(h.uri);u!==null&&(f=u)}return this.detectSupport().then(function(u){if(u)return t.loadTextureImage(e,d.source,f);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return t.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class GLTFTextureAVIFExtension{constructor(e){this.parser=e,this.name=EXTENSIONS.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){const n=this.name,t=this.parser,a=t.json,o=a.textures[e];if(!o.extensions||!o.extensions[n])return null;const d=o.extensions[n],h=a.images[d.source];let f=t.textureLoader;if(h.uri){const u=t.options.manager.getHandler(h.uri);u!==null&&(f=u)}return this.detectSupport().then(function(u){if(u)return t.loadTextureImage(e,d.source,f);if(a.extensionsRequired&&a.extensionsRequired.indexOf(n)>=0)throw new Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return t.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){const n=new Image;n.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",n.onload=n.onerror=function(){e(n.height===1)}})),this.isSupported}}class GLTFMeshoptCompression{constructor(e){this.name=EXTENSIONS.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const n=this.parser.json,t=n.bufferViews[e];if(t.extensions&&t.extensions[this.name]){const a=t.extensions[this.name],o=this.parser.getDependency("buffer",a.buffer),d=this.parser.options.meshoptDecoder;if(!d||!d.supported){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return o.then(function(h){const f=a.byteOffset||0,u=a.byteLength||0,p=a.count,_=a.byteStride,R=new Uint8Array(h,f,u);return d.decodeGltfBufferAsync?d.decodeGltfBufferAsync(p,_,R,a.mode,a.filter).then(function(x){return x.buffer}):d.ready.then(function(){const x=new ArrayBuffer(p*_);return d.decodeGltfBuffer(new Uint8Array(x),p,_,R,a.mode,a.filter),x})})}else return null}}class GLTFMeshGpuInstancing{constructor(e){this.name=EXTENSIONS.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const n=this.parser.json,t=n.nodes[e];if(!t.extensions||!t.extensions[this.name]||t.mesh===void 0)return null;const a=n.meshes[t.mesh];for(const u of a.primitives)if(u.mode!==WEBGL_CONSTANTS.TRIANGLES&&u.mode!==WEBGL_CONSTANTS.TRIANGLE_STRIP&&u.mode!==WEBGL_CONSTANTS.TRIANGLE_FAN&&u.mode!==void 0)return null;const d=t.extensions[this.name].attributes,h=[],f={};for(const u in d)h.push(this.parser.getDependency("accessor",d[u]).then(p=>(f[u]=p,f[u])));return h.length<1?null:(h.push(this.parser.createNodeMesh(e)),Promise.all(h).then(u=>{const p=u.pop(),_=p.isGroup?p.children:[p],R=u[0].count,x=[];for(const S of _){const g=new three.Matrix4,v=new three.Vector3,b=new three.Quaternion,T=new three.Vector3(1,1,1),y=new three.InstancedMesh(S.geometry,S.material,R);for(let w=0;w<R;w++)f.TRANSLATION&&v.fromBufferAttribute(f.TRANSLATION,w),f.ROTATION&&b.fromBufferAttribute(f.ROTATION,w),f.SCALE&&T.fromBufferAttribute(f.SCALE,w),y.setMatrixAt(w,g.compose(v,b,T));for(const w in f)if(w==="_COLOR_0"){const C=f[w];y.instanceColor=new three.InstancedBufferAttribute(C.array,C.itemSize,C.normalized)}else w!=="TRANSLATION"&&w!=="ROTATION"&&w!=="SCALE"&&S.geometry.setAttribute(w,f[w]);three.Object3D.prototype.copy.call(y,S),this.parser.assignFinalMaterial(y),x.push(y)}return p.isGroup?(p.clear(),p.add(...x),p):x[0]}))}}const BINARY_EXTENSION_HEADER_MAGIC="glTF",BINARY_EXTENSION_HEADER_LENGTH=12,BINARY_EXTENSION_CHUNK_TYPES={JSON:1313821514,BIN:5130562};class GLTFBinaryExtension{constructor(e){this.name=EXTENSIONS.KHR_BINARY_GLTF,this.content=null,this.body=null;const n=new DataView(e,0,BINARY_EXTENSION_HEADER_LENGTH),t=new TextDecoder;if(this.header={magic:t.decode(new Uint8Array(e.slice(0,4))),version:n.getUint32(4,!0),length:n.getUint32(8,!0)},this.header.magic!==BINARY_EXTENSION_HEADER_MAGIC)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const a=this.header.length-BINARY_EXTENSION_HEADER_LENGTH,o=new DataView(e,BINARY_EXTENSION_HEADER_LENGTH);let d=0;for(;d<a;){const h=o.getUint32(d,!0);d+=4;const f=o.getUint32(d,!0);if(d+=4,f===BINARY_EXTENSION_CHUNK_TYPES.JSON){const u=new Uint8Array(e,BINARY_EXTENSION_HEADER_LENGTH+d,h);this.content=t.decode(u)}else if(f===BINARY_EXTENSION_CHUNK_TYPES.BIN){const u=BINARY_EXTENSION_HEADER_LENGTH+d;this.body=e.slice(u,u+h)}d+=h}if(this.content===null)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class GLTFDracoMeshCompressionExtension{constructor(e,n){if(!n)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=EXTENSIONS.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=n,this.dracoLoader.preload()}decodePrimitive(e,n){const t=this.json,a=this.dracoLoader,o=e.extensions[this.name].bufferView,d=e.extensions[this.name].attributes,h={},f={},u={};for(const p in d){const _=ATTRIBUTES[p]||p.toLowerCase();h[_]=d[p]}for(const p in e.attributes){const _=ATTRIBUTES[p]||p.toLowerCase();if(d[p]!==void 0){const R=t.accessors[e.attributes[p]],x=WEBGL_COMPONENT_TYPES[R.componentType];u[_]=x.name,f[_]=R.normalized===!0}}return n.getDependency("bufferView",o).then(function(p){return new Promise(function(_,R){a.decodeDracoFile(p,function(x){for(const S in x.attributes){const g=x.attributes[S],v=f[S];v!==void 0&&(g.normalized=v)}_(x)},h,u,three.LinearSRGBColorSpace,R)})})}}class GLTFTextureTransformExtension{constructor(){this.name=EXTENSIONS.KHR_TEXTURE_TRANSFORM}extendTexture(e,n){return(n.texCoord===void 0||n.texCoord===e.channel)&&n.offset===void 0&&n.rotation===void 0&&n.scale===void 0||(e=e.clone(),n.texCoord!==void 0&&(e.channel=n.texCoord),n.offset!==void 0&&e.offset.fromArray(n.offset),n.rotation!==void 0&&(e.rotation=n.rotation),n.scale!==void 0&&e.repeat.fromArray(n.scale),e.needsUpdate=!0),e}}class GLTFMeshQuantizationExtension{constructor(){this.name=EXTENSIONS.KHR_MESH_QUANTIZATION}}class GLTFCubicSplineInterpolant extends three.Interpolant{constructor(e,n,t,a){super(e,n,t,a)}copySampleValue_(e){const n=this.resultBuffer,t=this.sampleValues,a=this.valueSize,o=e*a*3+a;for(let d=0;d!==a;d++)n[d]=t[o+d];return n}interpolate_(e,n,t,a){const o=this.resultBuffer,d=this.sampleValues,h=this.valueSize,f=h*2,u=h*3,p=a-n,_=(t-n)/p,R=_*_,x=R*_,S=e*u,g=S-u,v=-2*x+3*R,b=x-R,T=1-v,y=b-R+_;for(let w=0;w!==h;w++){const C=d[g+w+h],N=d[g+w+f]*p,D=d[S+w+h],P=d[S+w]*p;o[w]=T*C+y*N+v*D+b*P}return o}}const _q=new three.Quaternion;class GLTFCubicSplineQuaternionInterpolant extends GLTFCubicSplineInterpolant{interpolate_(e,n,t,a){const o=super.interpolate_(e,n,t,a);return _q.fromArray(o).normalize().toArray(o),o}}const WEBGL_CONSTANTS={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},WEBGL_COMPONENT_TYPES={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},WEBGL_FILTERS={9728:three.NearestFilter,9729:three.LinearFilter,9984:three.NearestMipmapNearestFilter,9985:three.LinearMipmapNearestFilter,9986:three.NearestMipmapLinearFilter,9987:three.LinearMipmapLinearFilter},WEBGL_WRAPPINGS={33071:three.ClampToEdgeWrapping,33648:three.MirroredRepeatWrapping,10497:three.RepeatWrapping},WEBGL_TYPE_SIZES={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ATTRIBUTES={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},PATH_PROPERTIES={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},INTERPOLATION={CUBICSPLINE:void 0,LINEAR:three.InterpolateLinear,STEP:three.InterpolateDiscrete},ALPHA_MODES={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};function createDefaultMaterial(l){return l.DefaultMaterial===void 0&&(l.DefaultMaterial=new three.MeshStandardMaterial({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:three.FrontSide})),l.DefaultMaterial}function addUnknownExtensionsToUserData(l,e,n){for(const t in n.extensions)l[t]===void 0&&(e.userData.gltfExtensions=e.userData.gltfExtensions||{},e.userData.gltfExtensions[t]=n.extensions[t])}function assignExtrasToUserData(l,e){e.extras!==void 0&&(typeof e.extras=="object"?Object.assign(l.userData,e.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+e.extras))}function addMorphTargets(l,e,n){let t=!1,a=!1,o=!1;for(let u=0,p=e.length;u<p;u++){const _=e[u];if(_.POSITION!==void 0&&(t=!0),_.NORMAL!==void 0&&(a=!0),_.COLOR_0!==void 0&&(o=!0),t&&a&&o)break}if(!t&&!a&&!o)return Promise.resolve(l);const d=[],h=[],f=[];for(let u=0,p=e.length;u<p;u++){const _=e[u];if(t){const R=_.POSITION!==void 0?n.getDependency("accessor",_.POSITION):l.attributes.position;d.push(R)}if(a){const R=_.NORMAL!==void 0?n.getDependency("accessor",_.NORMAL):l.attributes.normal;h.push(R)}if(o){const R=_.COLOR_0!==void 0?n.getDependency("accessor",_.COLOR_0):l.attributes.color;f.push(R)}}return Promise.all([Promise.all(d),Promise.all(h),Promise.all(f)]).then(function(u){const p=u[0],_=u[1],R=u[2];return t&&(l.morphAttributes.position=p),a&&(l.morphAttributes.normal=_),o&&(l.morphAttributes.color=R),l.morphTargetsRelative=!0,l})}function updateMorphTargets(l,e){if(l.updateMorphTargets(),e.weights!==void 0)for(let n=0,t=e.weights.length;n<t;n++)l.morphTargetInfluences[n]=e.weights[n];if(e.extras&&Array.isArray(e.extras.targetNames)){const n=e.extras.targetNames;if(l.morphTargetInfluences.length===n.length){l.morphTargetDictionary={};for(let t=0,a=n.length;t<a;t++)l.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function createPrimitiveKey(l){let e;const n=l.extensions&&l.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION];if(n?e="draco:"+n.bufferView+":"+n.indices+":"+createAttributesKey(n.attributes):e=l.indices+":"+createAttributesKey(l.attributes)+":"+l.mode,l.targets!==void 0)for(let t=0,a=l.targets.length;t<a;t++)e+=":"+createAttributesKey(l.targets[t]);return e}function createAttributesKey(l){let e="";const n=Object.keys(l).sort();for(let t=0,a=n.length;t<a;t++)e+=n[t]+":"+l[n[t]]+";";return e}function getNormalizedComponentScale(l){switch(l){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}function getImageURIMimeType(l){return l.search(/\.jpe?g($|\?)/i)>0||l.search(/^data\:image\/jpeg/)===0?"image/jpeg":l.search(/\.webp($|\?)/i)>0||l.search(/^data\:image\/webp/)===0?"image/webp":"image/png"}const _identityMatrix=new three.Matrix4;class GLTFParser{constructor(e={},n={}){this.json=e,this.extensions={},this.plugins={},this.options=n,this.cache=new GLTFRegistry,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let t=!1,a=!1,o=-1;typeof navigator<"u"&&(t=/^((?!chrome|android).)*safari/i.test(navigator.userAgent)===!0,a=navigator.userAgent.indexOf("Firefox")>-1,o=a?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),typeof createImageBitmap>"u"||t||a&&o<98?this.textureLoader=new three.TextureLoader(this.options.manager):this.textureLoader=new three.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new three.FileLoader(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),this.options.crossOrigin==="use-credentials"&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,n){const t=this,a=this.json,o=this.extensions;this.cache.removeAll(),this.nodeCache={},this._invokeAll(function(d){return d._markDefs&&d._markDefs()}),Promise.all(this._invokeAll(function(d){return d.beforeRoot&&d.beforeRoot()})).then(function(){return Promise.all([t.getDependencies("scene"),t.getDependencies("animation"),t.getDependencies("camera")])}).then(function(d){const h={scene:d[0][a.scene||0],scenes:d[0],animations:d[1],cameras:d[2],asset:a.asset,parser:t,userData:{}};return addUnknownExtensionsToUserData(o,h,a),assignExtrasToUserData(h,a),Promise.all(t._invokeAll(function(f){return f.afterRoot&&f.afterRoot(h)})).then(function(){e(h)})}).catch(n)}_markDefs(){const e=this.json.nodes||[],n=this.json.skins||[],t=this.json.meshes||[];for(let a=0,o=n.length;a<o;a++){const d=n[a].joints;for(let h=0,f=d.length;h<f;h++)e[d[h]].isBone=!0}for(let a=0,o=e.length;a<o;a++){const d=e[a];d.mesh!==void 0&&(this._addNodeRef(this.meshCache,d.mesh),d.skin!==void 0&&(t[d.mesh].isSkinnedMesh=!0)),d.camera!==void 0&&this._addNodeRef(this.cameraCache,d.camera)}}_addNodeRef(e,n){n!==void 0&&(e.refs[n]===void 0&&(e.refs[n]=e.uses[n]=0),e.refs[n]++)}_getNodeRef(e,n,t){if(e.refs[n]<=1)return t;const a=t.clone(),o=(d,h)=>{const f=this.associations.get(d);f!=null&&this.associations.set(h,f);for(const[u,p]of d.children.entries())o(p,h.children[u])};return o(t,a),a.name+="_instance_"+e.uses[n]++,a}_invokeOne(e){const n=Object.values(this.plugins);n.push(this);for(let t=0;t<n.length;t++){const a=e(n[t]);if(a)return a}return null}_invokeAll(e){const n=Object.values(this.plugins);n.unshift(this);const t=[];for(let a=0;a<n.length;a++){const o=e(n[a]);o&&t.push(o)}return t}getDependency(e,n){const t=e+":"+n;let a=this.cache.get(t);if(!a){switch(e){case"scene":a=this.loadScene(n);break;case"node":a=this._invokeOne(function(o){return o.loadNode&&o.loadNode(n)});break;case"mesh":a=this._invokeOne(function(o){return o.loadMesh&&o.loadMesh(n)});break;case"accessor":a=this.loadAccessor(n);break;case"bufferView":a=this._invokeOne(function(o){return o.loadBufferView&&o.loadBufferView(n)});break;case"buffer":a=this.loadBuffer(n);break;case"material":a=this._invokeOne(function(o){return o.loadMaterial&&o.loadMaterial(n)});break;case"texture":a=this._invokeOne(function(o){return o.loadTexture&&o.loadTexture(n)});break;case"skin":a=this.loadSkin(n);break;case"animation":a=this._invokeOne(function(o){return o.loadAnimation&&o.loadAnimation(n)});break;case"camera":a=this.loadCamera(n);break;default:if(a=this._invokeOne(function(o){return o!=this&&o.getDependency&&o.getDependency(e,n)}),!a)throw new Error("Unknown type: "+e);break}this.cache.add(t,a)}return a}getDependencies(e){let n=this.cache.get(e);if(!n){const t=this,a=this.json[e+(e==="mesh"?"es":"s")]||[];n=Promise.all(a.map(function(o,d){return t.getDependency(e,d)})),this.cache.add(e,n)}return n}loadBuffer(e){const n=this.json.buffers[e],t=this.fileLoader;if(n.type&&n.type!=="arraybuffer")throw new Error("THREE.GLTFLoader: "+n.type+" buffer type is not supported.");if(n.uri===void 0&&e===0)return Promise.resolve(this.extensions[EXTENSIONS.KHR_BINARY_GLTF].body);const a=this.options;return new Promise(function(o,d){t.load(three.LoaderUtils.resolveURL(n.uri,a.path),o,void 0,function(){d(new Error('THREE.GLTFLoader: Failed to load buffer "'+n.uri+'".'))})})}loadBufferView(e){const n=this.json.bufferViews[e];return this.getDependency("buffer",n.buffer).then(function(t){const a=n.byteLength||0,o=n.byteOffset||0;return t.slice(o,o+a)})}loadAccessor(e){const n=this,t=this.json,a=this.json.accessors[e];if(a.bufferView===void 0&&a.sparse===void 0){const d=WEBGL_TYPE_SIZES[a.type],h=WEBGL_COMPONENT_TYPES[a.componentType],f=a.normalized===!0,u=new h(a.count*d);return Promise.resolve(new three.BufferAttribute(u,d,f))}const o=[];return a.bufferView!==void 0?o.push(this.getDependency("bufferView",a.bufferView)):o.push(null),a.sparse!==void 0&&(o.push(this.getDependency("bufferView",a.sparse.indices.bufferView)),o.push(this.getDependency("bufferView",a.sparse.values.bufferView))),Promise.all(o).then(function(d){const h=d[0],f=WEBGL_TYPE_SIZES[a.type],u=WEBGL_COMPONENT_TYPES[a.componentType],p=u.BYTES_PER_ELEMENT,_=p*f,R=a.byteOffset||0,x=a.bufferView!==void 0?t.bufferViews[a.bufferView].byteStride:void 0,S=a.normalized===!0;let g,v;if(x&&x!==_){const b=Math.floor(R/x),T="InterleavedBuffer:"+a.bufferView+":"+a.componentType+":"+b+":"+a.count;let y=n.cache.get(T);y||(g=new u(h,b*x,a.count*x/p),y=new three.InterleavedBuffer(g,x/p),n.cache.add(T,y)),v=new three.InterleavedBufferAttribute(y,f,R%x/p,S)}else h===null?g=new u(a.count*f):g=new u(h,R,a.count*f),v=new three.BufferAttribute(g,f,S);if(a.sparse!==void 0){const b=WEBGL_TYPE_SIZES.SCALAR,T=WEBGL_COMPONENT_TYPES[a.sparse.indices.componentType],y=a.sparse.indices.byteOffset||0,w=a.sparse.values.byteOffset||0,C=new T(d[1],y,a.sparse.count*b),N=new u(d[2],w,a.sparse.count*f);h!==null&&(v=new three.BufferAttribute(v.array.slice(),v.itemSize,v.normalized));for(let D=0,P=C.length;D<P;D++){const k=C[D];if(v.setX(k,N[D*f]),f>=2&&v.setY(k,N[D*f+1]),f>=3&&v.setZ(k,N[D*f+2]),f>=4&&v.setW(k,N[D*f+3]),f>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return v})}loadTexture(e){const n=this.json,t=this.options,o=n.textures[e].source,d=n.images[o];let h=this.textureLoader;if(d.uri){const f=t.manager.getHandler(d.uri);f!==null&&(h=f)}return this.loadTextureImage(e,o,h)}loadTextureImage(e,n,t){const a=this,o=this.json,d=o.textures[e],h=o.images[n],f=(h.uri||h.bufferView)+":"+d.sampler;if(this.textureCache[f])return this.textureCache[f];const u=this.loadImageSource(n,t).then(function(p){p.flipY=!1,p.name=d.name||h.name||"",p.name===""&&typeof h.uri=="string"&&h.uri.startsWith("data:image/")===!1&&(p.name=h.uri);const R=(o.samplers||{})[d.sampler]||{};return p.magFilter=WEBGL_FILTERS[R.magFilter]||three.LinearFilter,p.minFilter=WEBGL_FILTERS[R.minFilter]||three.LinearMipmapLinearFilter,p.wrapS=WEBGL_WRAPPINGS[R.wrapS]||three.RepeatWrapping,p.wrapT=WEBGL_WRAPPINGS[R.wrapT]||three.RepeatWrapping,a.associations.set(p,{textures:e}),p}).catch(function(){return null});return this.textureCache[f]=u,u}loadImageSource(e,n){const t=this,a=this.json,o=this.options;if(this.sourceCache[e]!==void 0)return this.sourceCache[e].then(_=>_.clone());const d=a.images[e],h=self.URL||self.webkitURL;let f=d.uri||"",u=!1;if(d.bufferView!==void 0)f=t.getDependency("bufferView",d.bufferView).then(function(_){u=!0;const R=new Blob([_],{type:d.mimeType});return f=h.createObjectURL(R),f});else if(d.uri===void 0)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const p=Promise.resolve(f).then(function(_){return new Promise(function(R,x){let S=R;n.isImageBitmapLoader===!0&&(S=function(g){const v=new three.Texture(g);v.needsUpdate=!0,R(v)}),n.load(three.LoaderUtils.resolveURL(_,o.path),S,void 0,x)})}).then(function(_){return u===!0&&h.revokeObjectURL(f),_.userData.mimeType=d.mimeType||getImageURIMimeType(d.uri),_}).catch(function(_){throw console.error("THREE.GLTFLoader: Couldn't load texture",f),_});return this.sourceCache[e]=p,p}assignTexture(e,n,t,a){const o=this;return this.getDependency("texture",t.index).then(function(d){if(!d)return null;if(t.texCoord!==void 0&&t.texCoord>0&&(d=d.clone(),d.channel=t.texCoord),o.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]){const h=t.extensions!==void 0?t.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM]:void 0;if(h){const f=o.associations.get(d);d=o.extensions[EXTENSIONS.KHR_TEXTURE_TRANSFORM].extendTexture(d,h),o.associations.set(d,f)}}return a!==void 0&&(d.colorSpace=a),e[n]=d,d})}assignFinalMaterial(e){const n=e.geometry;let t=e.material;const a=n.attributes.tangent===void 0,o=n.attributes.color!==void 0,d=n.attributes.normal===void 0;if(e.isPoints){const h="PointsMaterial:"+t.uuid;let f=this.cache.get(h);f||(f=new three.PointsMaterial,three.Material.prototype.copy.call(f,t),f.color.copy(t.color),f.map=t.map,f.sizeAttenuation=!1,this.cache.add(h,f)),t=f}else if(e.isLine){const h="LineBasicMaterial:"+t.uuid;let f=this.cache.get(h);f||(f=new three.LineBasicMaterial,three.Material.prototype.copy.call(f,t),f.color.copy(t.color),f.map=t.map,this.cache.add(h,f)),t=f}if(a||o||d){let h="ClonedMaterial:"+t.uuid+":";a&&(h+="derivative-tangents:"),o&&(h+="vertex-colors:"),d&&(h+="flat-shading:");let f=this.cache.get(h);f||(f=t.clone(),o&&(f.vertexColors=!0),d&&(f.flatShading=!0),a&&(f.normalScale&&(f.normalScale.y*=-1),f.clearcoatNormalScale&&(f.clearcoatNormalScale.y*=-1)),this.cache.add(h,f),this.associations.set(f,this.associations.get(t))),t=f}e.material=t}getMaterialType(){return three.MeshStandardMaterial}loadMaterial(e){const n=this,t=this.json,a=this.extensions,o=t.materials[e];let d;const h={},f=o.extensions||{},u=[];if(f[EXTENSIONS.KHR_MATERIALS_UNLIT]){const _=a[EXTENSIONS.KHR_MATERIALS_UNLIT];d=_.getMaterialType(),u.push(_.extendParams(h,o,n))}else{const _=o.pbrMetallicRoughness||{};if(h.color=new three.Color(1,1,1),h.opacity=1,Array.isArray(_.baseColorFactor)){const R=_.baseColorFactor;h.color.setRGB(R[0],R[1],R[2],three.LinearSRGBColorSpace),h.opacity=R[3]}_.baseColorTexture!==void 0&&u.push(n.assignTexture(h,"map",_.baseColorTexture,three.SRGBColorSpace)),h.metalness=_.metallicFactor!==void 0?_.metallicFactor:1,h.roughness=_.roughnessFactor!==void 0?_.roughnessFactor:1,_.metallicRoughnessTexture!==void 0&&(u.push(n.assignTexture(h,"metalnessMap",_.metallicRoughnessTexture)),u.push(n.assignTexture(h,"roughnessMap",_.metallicRoughnessTexture))),d=this._invokeOne(function(R){return R.getMaterialType&&R.getMaterialType(e)}),u.push(Promise.all(this._invokeAll(function(R){return R.extendMaterialParams&&R.extendMaterialParams(e,h)})))}o.doubleSided===!0&&(h.side=three.DoubleSide);const p=o.alphaMode||ALPHA_MODES.OPAQUE;if(p===ALPHA_MODES.BLEND?(h.transparent=!0,h.depthWrite=!1):(h.transparent=!1,p===ALPHA_MODES.MASK&&(h.alphaTest=o.alphaCutoff!==void 0?o.alphaCutoff:.5)),o.normalTexture!==void 0&&d!==three.MeshBasicMaterial&&(u.push(n.assignTexture(h,"normalMap",o.normalTexture)),h.normalScale=new three.Vector2(1,1),o.normalTexture.scale!==void 0)){const _=o.normalTexture.scale;h.normalScale.set(_,_)}if(o.occlusionTexture!==void 0&&d!==three.MeshBasicMaterial&&(u.push(n.assignTexture(h,"aoMap",o.occlusionTexture)),o.occlusionTexture.strength!==void 0&&(h.aoMapIntensity=o.occlusionTexture.strength)),o.emissiveFactor!==void 0&&d!==three.MeshBasicMaterial){const _=o.emissiveFactor;h.emissive=new three.Color().setRGB(_[0],_[1],_[2],three.LinearSRGBColorSpace)}return o.emissiveTexture!==void 0&&d!==three.MeshBasicMaterial&&u.push(n.assignTexture(h,"emissiveMap",o.emissiveTexture,three.SRGBColorSpace)),Promise.all(u).then(function(){const _=new d(h);return o.name&&(_.name=o.name),assignExtrasToUserData(_,o),n.associations.set(_,{materials:e}),o.extensions&&addUnknownExtensionsToUserData(a,_,o),_})}createUniqueName(e){const n=three.PropertyBinding.sanitizeNodeName(e||"");return n in this.nodeNamesUsed?n+"_"+ ++this.nodeNamesUsed[n]:(this.nodeNamesUsed[n]=0,n)}loadGeometries(e){const n=this,t=this.extensions,a=this.primitiveCache;function o(h){return t[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(h,n).then(function(f){return addPrimitiveAttributes(f,h,n)})}const d=[];for(let h=0,f=e.length;h<f;h++){const u=e[h],p=createPrimitiveKey(u),_=a[p];if(_)d.push(_.promise);else{let R;u.extensions&&u.extensions[EXTENSIONS.KHR_DRACO_MESH_COMPRESSION]?R=o(u):R=addPrimitiveAttributes(new three.BufferGeometry,u,n),a[p]={primitive:u,promise:R},d.push(R)}}return Promise.all(d)}loadMesh(e){const n=this,t=this.json,a=this.extensions,o=t.meshes[e],d=o.primitives,h=[];for(let f=0,u=d.length;f<u;f++){const p=d[f].material===void 0?createDefaultMaterial(this.cache):this.getDependency("material",d[f].material);h.push(p)}return h.push(n.loadGeometries(d)),Promise.all(h).then(function(f){const u=f.slice(0,f.length-1),p=f[f.length-1],_=[];for(let x=0,S=p.length;x<S;x++){const g=p[x],v=d[x];let b;const T=u[x];if(v.mode===WEBGL_CONSTANTS.TRIANGLES||v.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP||v.mode===WEBGL_CONSTANTS.TRIANGLE_FAN||v.mode===void 0)b=o.isSkinnedMesh===!0?new three.SkinnedMesh(g,T):new three.Mesh(g,T),b.isSkinnedMesh===!0&&b.normalizeSkinWeights(),v.mode===WEBGL_CONSTANTS.TRIANGLE_STRIP?b.geometry=toTrianglesDrawMode(b.geometry,three.TriangleStripDrawMode):v.mode===WEBGL_CONSTANTS.TRIANGLE_FAN&&(b.geometry=toTrianglesDrawMode(b.geometry,three.TriangleFanDrawMode));else if(v.mode===WEBGL_CONSTANTS.LINES)b=new three.LineSegments(g,T);else if(v.mode===WEBGL_CONSTANTS.LINE_STRIP)b=new three.Line(g,T);else if(v.mode===WEBGL_CONSTANTS.LINE_LOOP)b=new three.LineLoop(g,T);else if(v.mode===WEBGL_CONSTANTS.POINTS)b=new three.Points(g,T);else throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+v.mode);Object.keys(b.geometry.morphAttributes).length>0&&updateMorphTargets(b,o),b.name=n.createUniqueName(o.name||"mesh_"+e),assignExtrasToUserData(b,o),v.extensions&&addUnknownExtensionsToUserData(a,b,v),n.assignFinalMaterial(b),_.push(b)}for(let x=0,S=_.length;x<S;x++)n.associations.set(_[x],{meshes:e,primitives:x});if(_.length===1)return o.extensions&&addUnknownExtensionsToUserData(a,_[0],o),_[0];const R=new three.Group;o.extensions&&addUnknownExtensionsToUserData(a,R,o),n.associations.set(R,{meshes:e});for(let x=0,S=_.length;x<S;x++)R.add(_[x]);return R})}loadCamera(e){let n;const t=this.json.cameras[e],a=t[t.type];if(!a){console.warn("THREE.GLTFLoader: Missing camera parameters.");return}return t.type==="perspective"?n=new three.PerspectiveCamera(three.MathUtils.radToDeg(a.yfov),a.aspectRatio||1,a.znear||1,a.zfar||2e6):t.type==="orthographic"&&(n=new three.OrthographicCamera(-a.xmag,a.xmag,a.ymag,-a.ymag,a.znear,a.zfar)),t.name&&(n.name=this.createUniqueName(t.name)),assignExtrasToUserData(n,t),Promise.resolve(n)}loadSkin(e){const n=this.json.skins[e],t=[];for(let a=0,o=n.joints.length;a<o;a++)t.push(this._loadNodeShallow(n.joints[a]));return n.inverseBindMatrices!==void 0?t.push(this.getDependency("accessor",n.inverseBindMatrices)):t.push(null),Promise.all(t).then(function(a){const o=a.pop(),d=a,h=[],f=[];for(let u=0,p=d.length;u<p;u++){const _=d[u];if(_){h.push(_);const R=new three.Matrix4;o!==null&&R.fromArray(o.array,u*16),f.push(R)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',n.joints[u])}return new three.Skeleton(h,f)})}loadAnimation(e){const n=this.json,t=this,a=n.animations[e],o=a.name?a.name:"animation_"+e,d=[],h=[],f=[],u=[],p=[];for(let _=0,R=a.channels.length;_<R;_++){const x=a.channels[_],S=a.samplers[x.sampler],g=x.target,v=g.node,b=a.parameters!==void 0?a.parameters[S.input]:S.input,T=a.parameters!==void 0?a.parameters[S.output]:S.output;g.node!==void 0&&(d.push(this.getDependency("node",v)),h.push(this.getDependency("accessor",b)),f.push(this.getDependency("accessor",T)),u.push(S),p.push(g))}return Promise.all([Promise.all(d),Promise.all(h),Promise.all(f),Promise.all(u),Promise.all(p)]).then(function(_){const R=_[0],x=_[1],S=_[2],g=_[3],v=_[4],b=[];for(let T=0,y=R.length;T<y;T++){const w=R[T],C=x[T],N=S[T],D=g[T],P=v[T];if(w===void 0)continue;w.updateMatrix&&w.updateMatrix();const k=t._createAnimationTracks(w,C,N,D,P);if(k)for(let F=0;F<k.length;F++)b.push(k[F])}return new three.AnimationClip(o,void 0,b)})}createNodeMesh(e){const n=this.json,t=this,a=n.nodes[e];return a.mesh===void 0?null:t.getDependency("mesh",a.mesh).then(function(o){const d=t._getNodeRef(t.meshCache,a.mesh,o);return a.weights!==void 0&&d.traverse(function(h){if(h.isMesh)for(let f=0,u=a.weights.length;f<u;f++)h.morphTargetInfluences[f]=a.weights[f]}),d})}loadNode(e){const n=this.json,t=this,a=n.nodes[e],o=t._loadNodeShallow(e),d=[],h=a.children||[];for(let u=0,p=h.length;u<p;u++)d.push(t.getDependency("node",h[u]));const f=a.skin===void 0?Promise.resolve(null):t.getDependency("skin",a.skin);return Promise.all([o,Promise.all(d),f]).then(function(u){const p=u[0],_=u[1],R=u[2];R!==null&&p.traverse(function(x){x.isSkinnedMesh&&x.bind(R,_identityMatrix)});for(let x=0,S=_.length;x<S;x++)p.add(_[x]);return p})}_loadNodeShallow(e){const n=this.json,t=this.extensions,a=this;if(this.nodeCache[e]!==void 0)return this.nodeCache[e];const o=n.nodes[e],d=o.name?a.createUniqueName(o.name):"",h=[],f=a._invokeOne(function(u){return u.createNodeMesh&&u.createNodeMesh(e)});return f&&h.push(f),o.camera!==void 0&&h.push(a.getDependency("camera",o.camera).then(function(u){return a._getNodeRef(a.cameraCache,o.camera,u)})),a._invokeAll(function(u){return u.createNodeAttachment&&u.createNodeAttachment(e)}).forEach(function(u){h.push(u)}),this.nodeCache[e]=Promise.all(h).then(function(u){let p;if(o.isBone===!0?p=new three.Bone:u.length>1?p=new three.Group:u.length===1?p=u[0]:p=new three.Object3D,p!==u[0])for(let _=0,R=u.length;_<R;_++)p.add(u[_]);if(o.name&&(p.userData.name=o.name,p.name=d),assignExtrasToUserData(p,o),o.extensions&&addUnknownExtensionsToUserData(t,p,o),o.matrix!==void 0){const _=new three.Matrix4;_.fromArray(o.matrix),p.applyMatrix4(_)}else o.translation!==void 0&&p.position.fromArray(o.translation),o.rotation!==void 0&&p.quaternion.fromArray(o.rotation),o.scale!==void 0&&p.scale.fromArray(o.scale);return a.associations.has(p)||a.associations.set(p,{}),a.associations.get(p).nodes=e,p}),this.nodeCache[e]}loadScene(e){const n=this.extensions,t=this.json.scenes[e],a=this,o=new three.Group;t.name&&(o.name=a.createUniqueName(t.name)),assignExtrasToUserData(o,t),t.extensions&&addUnknownExtensionsToUserData(n,o,t);const d=t.nodes||[],h=[];for(let f=0,u=d.length;f<u;f++)h.push(a.getDependency("node",d[f]));return Promise.all(h).then(function(f){for(let p=0,_=f.length;p<_;p++)o.add(f[p]);const u=p=>{const _=new Map;for(const[R,x]of a.associations)(R instanceof three.Material||R instanceof three.Texture)&&_.set(R,x);return p.traverse(R=>{const x=a.associations.get(R);x!=null&&_.set(R,x)}),_};return a.associations=u(o),o})}_createAnimationTracks(e,n,t,a,o){const d=[],h=e.name?e.name:e.uuid,f=[];PATH_PROPERTIES[o.path]===PATH_PROPERTIES.weights?e.traverse(function(R){R.morphTargetInfluences&&f.push(R.name?R.name:R.uuid)}):f.push(h);let u;switch(PATH_PROPERTIES[o.path]){case PATH_PROPERTIES.weights:u=three.NumberKeyframeTrack;break;case PATH_PROPERTIES.rotation:u=three.QuaternionKeyframeTrack;break;case PATH_PROPERTIES.position:case PATH_PROPERTIES.scale:u=three.VectorKeyframeTrack;break;default:switch(t.itemSize){case 1:u=three.NumberKeyframeTrack;break;case 2:case 3:default:u=three.VectorKeyframeTrack;break}break}const p=a.interpolation!==void 0?INTERPOLATION[a.interpolation]:three.InterpolateLinear,_=this._getArrayFromAccessor(t);for(let R=0,x=f.length;R<x;R++){const S=new u(f[R]+"."+PATH_PROPERTIES[o.path],n.array,_,p);a.interpolation==="CUBICSPLINE"&&this._createCubicSplineTrackInterpolant(S),d.push(S)}return d}_getArrayFromAccessor(e){let n=e.array;if(e.normalized){const t=getNormalizedComponentScale(n.constructor),a=new Float32Array(n.length);for(let o=0,d=n.length;o<d;o++)a[o]=n[o]*t;n=a}return n}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(t){const a=this instanceof three.QuaternionKeyframeTrack?GLTFCubicSplineQuaternionInterpolant:GLTFCubicSplineInterpolant;return new a(this.times,this.values,this.getValueSize()/3,t)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function computeBounds(l,e,n){const t=e.attributes,a=new three.Box3;if(t.POSITION!==void 0){const h=n.json.accessors[t.POSITION],f=h.min,u=h.max;if(f!==void 0&&u!==void 0){if(a.set(new three.Vector3(f[0],f[1],f[2]),new three.Vector3(u[0],u[1],u[2])),h.normalized){const p=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[h.componentType]);a.min.multiplyScalar(p),a.max.multiplyScalar(p)}}else{console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");return}}else return;const o=e.targets;if(o!==void 0){const h=new three.Vector3,f=new three.Vector3;for(let u=0,p=o.length;u<p;u++){const _=o[u];if(_.POSITION!==void 0){const R=n.json.accessors[_.POSITION],x=R.min,S=R.max;if(x!==void 0&&S!==void 0){if(f.setX(Math.max(Math.abs(x[0]),Math.abs(S[0]))),f.setY(Math.max(Math.abs(x[1]),Math.abs(S[1]))),f.setZ(Math.max(Math.abs(x[2]),Math.abs(S[2]))),R.normalized){const g=getNormalizedComponentScale(WEBGL_COMPONENT_TYPES[R.componentType]);f.multiplyScalar(g)}h.max(f)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}a.expandByVector(h)}l.boundingBox=a;const d=new three.Sphere;a.getCenter(d.center),d.radius=a.min.distanceTo(a.max)/2,l.boundingSphere=d}function addPrimitiveAttributes(l,e,n){const t=e.attributes,a=[];function o(d,h){return n.getDependency("accessor",d).then(function(f){l.setAttribute(h,f)})}for(const d in t){const h=ATTRIBUTES[d]||d.toLowerCase();h in l.attributes||a.push(o(t[d],h))}if(e.indices!==void 0&&!l.index){const d=n.getDependency("accessor",e.indices).then(function(h){l.setIndex(h)});a.push(d)}return three.ColorManagement.workingColorSpace!==three.LinearSRGBColorSpace&&"COLOR_0"in t&&console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${three.ColorManagement.workingColorSpace}" not supported.`),assignExtrasToUserData(l,e),computeBounds(l,e,n),Promise.all(a).then(function(){return e.targets!==void 0?addMorphTargets(l,e.targets,n):l})}const defaultCamPos=[0,14.63,16],isMobile=DeviceDetection(),loader$1=new GLTFLoader,box=new three.Box3,worldPos=new three.Vector3,size=new three.Vector3;function Panel({character:l,ttsStarted:e,active:n,visible:t}){var x,S,g;const a=React$2.useRef(null),o=React$2.useRef(null),d=l.type==="character",[h,f]=React$2.useState(!1),u=React$2.useRef(),p=React$2.useMemo(()=>{var v,b,T,y,w,C,N,D;return d?l.animationId&&((v=l.animation)!=null&&v.url)?l.animation:(y=(T=(b=l==null?void 0:l.resource)==null?void 0:b.animations)==null?void 0:T[l.emotion])!=null&&y.url?(C=(w=l==null?void 0:l.resource)==null?void 0:w.animations)==null?void 0:C[l.emotion]:(D=(N=l==null?void 0:l.resource)==null?void 0:N.animations)==null?void 0:D.neutral:{}},[l.emotion,l==null?void 0:l.animationId,l==null?void 0:l.animation,(x=l==null?void 0:l.resource)==null?void 0:x.animations,d]),_=React$2.useCallback(()=>{if(u.current){const v=u.current.userData.animator;v.getAction("idle")&&v.mix("idle",.1)}},[]);React$2.useEffect(()=>{var v,b,T,y,w,C;if(t)if(n)if(e){const N=(T=(b=(v=l==null?void 0:l.resource)==null?void 0:v.animations)==null?void 0:b.talking)==null?void 0:T.url,P=((C=(w=(y=l==null?void 0:l.resource)==null?void 0:y.animations)==null?void 0:w["talking-short"])==null?void 0:C.url)||N;if(P&&u.current){const k=u.current.userData.animator,F=`${P}_talking`;k.getAction(F)?(k.mix(F,.1),f(!0)):loader$1.load(P,({animations:M})=>{if(!u.current)return;const j=k.getAction("idle").getClip();k.register(F,mixWithTalkingClip(M[0],j)),k.mix(F,.1),f(!0)})}}else _();else h&&_()},[e,n,_,h,t,(S=l==null?void 0:l.resource)==null?void 0:S.animations]);const R=React$2.useCallback(v=>{if(l.type==="character"){const b=v.getObjectByName("Head_M",!0);b?(b.updateMatrixWorld(!0),box.setFromObject(v),box.getSize(size),b.getWorldPosition(worldPos),a.current.lookAt(worldPos)):a.current.position.setY(size.y-1.5*1.3),a.current.zoom=1.5}else cameraFitAnyObject(v,a.current),a.current.zoom=1;a.current.updateProjectionMatrix()},[l]);return fiber.useFrame(({gl:v,scene:b})=>{if(a.current&&o.current){const T=document.querySelectorAll(".conversation--character__item")[l.slot];if(T){const y=T.getBoundingClientRect(),w=T.parentNode.getBoundingClientRect(),[C,N]=[y.right-y.left,y.bottom-y.top];if(a.current.aspect=C/N,a.current.updateProjectionMatrix(),d&&u.current){box.setFromObject(u.current),box.getSize(size);const k=u.current.getObjectByName("Head_M",!0);k?(k.getWorldPosition(worldPos),a.current.lookAt(worldPos)):a.current.position.setY(size.y-1.5*1.3),a.current.zoom=1.5}const D={top:y.top-w.top,right:y.right-w.right,left:y.left-w.left,bottom:y.bottom-w.bottom},P=isMobile?24:40;D.bottom+=n?-P:P,v.setViewport(D.left,D.bottom,C,N),v.setScissor(D.left,D.bottom,C,N),o.current.environment=b.environment,v.render(o.current,a.current)}}},1),l.type==="image"?null:jsxRuntimeExports.jsxs("scene",{ref:o,children:[(g=l.resource)!=null&&g.url?jsxRuntimeExports.jsx(arcadeThreeCore.SceneResource,{ref:u,name:`char_${l.uid}`,url:l.resource.url,animationUrl:p.url,type:l.type,onRender:R,texturable:!0,interactive:!0,merge:l.type!=="character",visible:t}):null,jsxRuntimeExports.jsx(drei.PerspectiveCamera,{ref:a,fov:35,position:defaultCamPos,rotation:[0,0,0],onUpdate:v=>{v.layers.enableAll()},manual:!0}),jsxRuntimeExports.jsx(LightSet,{})]})}function PanelsWrapper({characters:l,slots:e,ttsStarted:n,flex:t,currentMessage:a,lod:o}){const[d,h]=React$2.useState(!1);return fiber.useFrame(({gl:f})=>{f.setScissorTest(!1),f.clear(!0,!0),f.setScissorTest(!0)}),React$2.useEffect(()=>{const f=()=>{h(!0)};return arcadeThreeCore.ProgressManager.addEventListener("loaded",f),()=>{arcadeThreeCore.ProgressManager.removeEventListener("loaded",f)}},[]),jsxRuntimeExports.jsx(arcadeThreeCore.QualityManager,{lod:o,active:!0,children:e.map((f,u)=>{let p=null;const _=l.findIndex(R=>R&&R.uid===f.uid);if(_>=0){const R=t?_:u;return p={...l[_]},p.slot=R,jsxRuntimeExports.jsx(Panel,{character:p,active:a.position===R,ttsStarted:n,visible:d},`${`${p.uid}_${u}`}_${_}`)}return null})})}function Scene(l){return l.lowQuality?null:jsxRuntimeExports.jsxs(arcadeThreeCore.Renderer,{className:"conversation--canvas",style:{position:"absolute",width:"100%",height:"100%"},gl:{antialias:!0},fullscreen:!1,onCreated:({gl:e})=>{e.setClearColor("white",0)},children:[jsxRuntimeExports.jsx(arcadeThreeCore.SettingsController,{current:{animate:l.pause}}),jsxRuntimeExports.jsx(arcadeThreeCore.EnvironmentWrapper,{url:"https://min.gamelearn.io/statics/envs/envmap_1k.hdr"}),jsxRuntimeExports.jsx(PanelsWrapper,{...l})]})}function SlotList({characters:l,actors:e,lodSettings:n,ttsStarted:t,currentMessage:a,flex:o,slots:d,children:h,pause:f,getEvent:u}){const p=({character:b,active:T,slot:y})=>({character:b,active:T,emotion:T?a.emotion:"neutral",slot:y}),_=React$2.useMemo(()=>u({type:"currentLod"}),[u]),R=_==="divideby64",x=d.reduce((b,T)=>{var C,N;const y=e==null?void 0:e.find(D=>D.uid===T.uid),w={...T};if(T.character)w.name=T.alias||T.character.name,w.resource=w.character.resource,w.position=w.position>=0?w.position:-1,delete w.character,w.type="character",b.push(w);else if(y){const{resource:D}=y;w.name=T.alias||T.name,w.position=w.position>=0?w.position:-1,w.resource=D,w.type=y.type,b.push(w)}else T.type?(w.name=T.alias||((C=T.character)==null?void 0:C.name)||T.name,w.resource=((N=w.character)==null?void 0:N.resource)||T.resource,w.position=w.position>=0?w.position:-1,delete w.character,w.type=T.type,b.push(w)):o||b.push(null);return b},[]),S=x.length&&x.some(b=>b),g=l.filter(b=>d.find(T=>b.uid===T.uid));function v(){return S?x.map((b,T)=>b?jsxRuntimeExports.jsx(Slot,{lowQuality:R,...p({character:b,active:a.position===b.position,slot:T})},`${b.uid+T}`):jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${T}`},`void_${0+T}`)):o?g.map((b,T)=>{const y=a.position===T;return jsxRuntimeExports.jsx(Slot,{...p({character:b,active:y,slot:T})},`${b.uid+T}`)}):d.length>0?d.map((b,T)=>{const y=l.find(w=>w.uid===b.uid);if(y){const w=a.position===T;return y.name=b.alias||y.name,jsxRuntimeExports.jsx(Slot,{...p({character:y,active:w,slot:T})},`${y.uid+T}`)}return jsxRuntimeExports.jsx("div",{className:`conversation--character__item void ${T}`},`${0+T}`)}):null}return jsxRuntimeExports.jsxs("div",{className:"conversation--characters",children:[jsxRuntimeExports.jsx(Scene,{characters:S?x:g,slots:d,flex:o,currentMessage:a,lodSettings:n,ttsStarted:t,pause:f,lod:_,lowQuality:R}),h||jsxRuntimeExports.jsx(v,{})]})}SlotList.defaultProps={characters:[],currentMessage:{},flex:!0,slots:[]};function Options({inherited:l,options:e,selectedChoice:n,selectChoice:t,showingResults:a,simplifiedOptions:o,required:d}){const[h,f]=React$2.useState(null),u=_=>{o?(f(_),setTimeout(()=>{t(_),f(null)},1e3)):t(_)},p=_=>!!(a&&(n==null?void 0:n.id)===_.id||(n==null?void 0:n.right)===!0||a&&!d);return e==null?void 0:e.filter(_=>_.text).map(_=>jsxRuntimeExports.jsxs("div",{className:`${l?"conversation--question custom-radio":"custom-radio"}
|
|
67
67
|
${(h==null?void 0:h.id)===_.id?"radio-text-clicked":""}`,children:[jsxRuntimeExports.jsx("input",{onChange:()=>{u(_)},className:"radio",type:"radio",id:_.text_labelId,name:_.id,checked:(n==null?void 0:n.id)===_.id,disabled:p(_)}),jsxRuntimeExports.jsx("label",{className:`${_.right?"radio-text-success":"radio-text-fail"}`,htmlFor:_.text_labelId,children:HTMLReactParser$1(_.text)})]},`${_.id}_${_.text_labelId}`))}const noop=()=>{};function BasicDecision({children:l,question:e,showingResults:n,selected:t,required:a,failed:o,onNext:d,translate:h,hasRewards:f,options:u}){const[p,_]=React$2.useState(!1);function R(){(t==null?void 0:t.id)!==void 0&&!p&&(_(!0),d())}return jsxRuntimeExports.jsxs("div",{className:`popup popup__large popup__basicDecision ${n&&(t!=null&&t.feedback)?"popup__feedback":""}`,children:[jsxRuntimeExports.jsx("div",{className:"popup--info",children:n?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[l,!(t!=null&&t.feedback)&&f.length===0&&jsxRuntimeExports.jsx("span",{className:"popup--info__title",children:e!==""&&jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:e})}),!(t!=null&&t.feedback)&&f.length>0&&jsxRuntimeExports.jsx("span",{className:"popup--info__title",children:e})]}):jsxRuntimeExports.jsx("span",{className:"popup--info__title",children:e})}),jsxRuntimeExports.jsx("div",{className:"popup__questions",dir:"auto",children:u}),jsxRuntimeExports.jsx("div",{className:"popup--buttons",children:(a?!o:(t==null?void 0:t.id)!==void 0)?jsxRuntimeExports.jsx("button",{"data-testid":"continueButtonDecision",type:"button",className:`gat--btn__navigation ${p||(t==null?void 0:t.id)===void 0?"disabled":""}`,onClick:()=>R(),"aria-label":h("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})}):null})]})}function ComplexDecision({question:l,inScene:e,disabled:n,onNext:t,children:a,simplifiedOptions:o}){return jsxRuntimeExports.jsxs("div",{dir:"auto",className:`conversation--body ${e?"conversation--body--inScene":""}`,children:[jsxRuntimeExports.jsxs("div",{className:"conversation--message",children:[l!==""&&jsxRuntimeExports.jsx("div",{className:"conversation--main__text",children:HTMLReactParser$1(l)}),a]}),jsxRuntimeExports.jsxs("div",{style:{visibility:o?"hidden":"visible"},className:"conversation--controls conversation--controls--fixedbottom",children:[jsxRuntimeExports.jsx("div",{className:"gat--btn__round disabled",children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{"data-testid":"continueButtonComplexDecision",className:`gat--btn__round ${n?"disabled":""}`,type:"button",onClick:()=>!n&&t(),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})}function DecisionBody({options:l,question:e,inherited:n,branched:t,changeOption:a,onNext:o,failed:d,showingResults:h,currentSelectedChoice:f,children:u,translate:p,hasRewards:_,inScene:R,required:x,simplifiedOptions:S}){const g=T=>{h&&d&&a(T),o(T)},v=!h&&(f==null?void 0:f.id)!==void 0||!d,b={inherited:n,selectedChoice:f,selectChoice:(!x||t)&&(f==null?void 0:f.id)!==void 0||x&&!d?noop:g,options:l,showingResults:h,simplifiedOptions:S,required:x};return n?jsxRuntimeExports.jsx(ComplexDecision,{disabled:!v,question:e,inScene:R,onNext:()=>o(f),simplifiedOptions:S,children:jsxRuntimeExports.jsx(Options,{...b})}):jsxRuntimeExports.jsx(BasicDecision,{question:e,showingResults:h,selected:f,required:x,failed:d,onNext:()=>o(f),translate:p,hasRewards:_,options:jsxRuntimeExports.jsx(Options,{...b}),children:u})}function Wrapper({children:l,inherit:e}){return e?jsxRuntimeExports.jsx("div",{className:"conversation--feedback",children:l}):l}function FeedBack({choice:l,inherited:e,question:n}){return l.feedback?jsxRuntimeExports.jsx(Wrapper,{inherit:e,children:l.feedback&&jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"conversation--feedback__title",children:n}),jsxRuntimeExports.jsxs("div",{className:"conversation--feedback__text",dir:"auto",children:[l.right?jsxRuntimeExports.jsx("span",{className:"icon-check-circle-black color--success"}):jsxRuntimeExports.jsx("span",{className:"icon-error-circle-black color--error"}),jsxRuntimeExports.jsx("div",{className:"conversation--feedback__wysiwyg",children:HTMLReactParser$1(l.feedback)})]})]})}):null}function DecisionComponent({emitEvent:l,getEvent:e,soundActions:n,keyboardControl:t,inScene:a,...o}){var j,$;const{inheritProps:d={},decisionNumber:h,required:f,question:u,onAddPoints:p,onFinish:_,branched:R,simplifiedOptions:x}=o,S=Object.keys(d).length>0,[g,v]=React$2.useState("options"),[b,T]=React$2.useState({}),[y]=n,w=f&&!(b!=null&&b.right),C=React$2.useRef(),N=B=>{var X;(X=B.audio)!=null&&X.url&&y(B.audio.url,"audio_file",!1,B.audioVolume)},D={...d,slots:d.slots?d.slots:d.characters,currentMessage:{position:null,emotion:""},emitEvent:l,getEvent:e};d&&d.flex&&D.slots&&(D.characters=D.characters.filter(B=>D.slots.find(X=>X.uid===B.uid)));const P=B=>{l({type:"decisionJournal",payload:{choice:B,decisionNumber:h}})},k=B=>{if(!w&&g==="results")y("click-ui"),S?x?_&&(P(B),_(B,()=>{T({}),v("options")})):(p&&p(B),P(B),l({type:"addPoints",payload:B==null?void 0:B.rewards,finish:!1,complex:!0,onFinish:()=>{_?_(B,()=>{T({}),v("options")}):l({type:"success"}),T({}),v("options")}})):(P(B),l({type:"addPoints",payload:B==null?void 0:B.rewards,finish:!0,complex:!0}));else if(Object.keys(B).length>0)if(y("click-ui"),x)if(B!=null&&B.rewards.filter(X=>X.type==="var").length){P({...B,simplified:!0});const X=B==null?void 0:B.rewards.filter(re=>re.type==="var");l({type:"addPoints",payload:X,finish:!1,complex:!0,onFinish:()=>{_?_(B,()=>{T({}),v("options")}):l({type:"success"}),T({}),v("options")}})}else P({...B,simplified:!0}),_(B,()=>{T({}),v("options")});else B.right?y("score"):(y("fail"),R||(S||f?(P(B),l({type:"addPoints",payload:B==null?void 0:B.rewards,finish:!1,complex:!0})):f||(T({}),v("options")))),T(B),N(B),v("results")},F={...o,selectView:v,selectedView:g,emitEvent:l,inherited:S,branched:R,soundActions:n,showingResults:g==="results",currentSelectedChoice:b,hasRewards:(b==null?void 0:b.rewards)||[],failed:w,inScene:a,required:f,simplifiedOptions:x,changeOption:B=>{y("click-ui"),T(B),v("options")},onNext:k,translate:B=>e({type:"translate",payload:B})},M=t({disabled:g!=="results",repeat:!1,forward:()=>{if(C.current!==b)C.current=b;else return;k(b)}});return React$2.useEffect(()=>M(),[M]),S?jsxRuntimeExports.jsx("div",{className:`conversation--layer
|
|
68
68
|
${b!=null&&b.feedback?"":"conversation--layer__defaultFeedback"}
|
|
69
|
-
${g==="results"?"conversation--layer__feedback":""}`,children:jsxRuntimeExports.jsxs("div",{className:`conversation ${a?"conversation--inScene":""}`,style:(j=d.background)!=null&&j.img?{backgroundImage:`url("${($=d.background.img)==null?void 0:$.url}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...D,children:g==="results"&&(b!=null&&b.feedback)?jsxRuntimeExports.jsx(FeedBack,{question:u,soundActions:n,inherited:S,choice:b,rewards:(b==null?void 0:b.rewards)||[],emitEvent:l}):null}),jsxRuntimeExports.jsx(DecisionBody,{...F})]})}):jsxRuntimeExports.jsx("div",{className:"popup--layer popup--layer--transparent",children:jsxRuntimeExports.jsx(DecisionBody,{...F,children:jsxRuntimeExports.jsx(FeedBack,{question:u,soundActions:n,inherited:S,choice:b,rewards:(b==null?void 0:b.rewards)||[],emitEvent:l})})})}function ImageComponent({emitEvent:l,img:e,imgName:n,documentType:t,visible:a,viewed:o,imgId_labelId:d,soundActions:h,keyboardControl:f,getEvent:u}){const p=b=>u({type:"translate",payload:b}),[_,R]=React$2.useState(!1),x=e.url,[S]=h,g=React$2.useCallback(()=>{S("click-ui"),l({type:"finishMedia",payload:{imgId:d,name:n,imgName:n,documentType:t,type:"image"}})},[S,d,n,t,l]),v=f({disabled:o,forward:g,escape:g});return React$2.useEffect(()=>v(),[v]),React$2.useEffect(()=>{!a&&!_&&(R(!0),g())},[g,a,_]),a?jsxRuntimeExports.jsx("div",{className:o?"notes--results":"readings--container readings--container--darkopacity",children:jsxRuntimeExports.jsxs("div",{className:o?"notes--results__text":"readings readings--image",children:[x&&jsxRuntimeExports.jsx("img",{src:x,alt:n}),o?null:jsxRuntimeExports.jsx("div",{className:x?"readings--image--closeBtn":"position--absolute top right",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__round gat--btn__close",onClick:g,"aria-label":p("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})})]})}):null}function VoiceOver({name:l}){return jsxRuntimeExports.jsx("div",{className:"conversation--voice__over",children:jsxRuntimeExports.jsx("span",{children:l||"Voice-Over"})})}function ThinkFul({text:l}){return jsxRuntimeExports.jsxs("div",{className:"conversation--voice__over",children:[jsxRuntimeExports.jsx("span",{className:"icon-bubble-thinkful-black"}),jsxRuntimeExports.jsxs("span",{children:["[",l,"]"]})]})}function Message({current:l,translate:e}){var t,a;const n=l.text;return jsxRuntimeExports.jsxs("div",{className:`conversation--message ${l.voiceOver||(t=l==null?void 0:l.emotion)!=null&&t.includes("think")?"voice--over":""}`,children:[l.voiceOver?jsxRuntimeExports.jsx(VoiceOver,{name:l.name}):null,(a=l==null?void 0:l.emotion)!=null&&a.includes("think")?jsxRuntimeExports.jsx(ThinkFul,{text:e("emotion.thinking")}):null,jsxRuntimeExports.jsx("div",{className:"conversation--main__text",children:HTMLReactParser$1(n)})]})}Message.defaultProps={current:{},voiceOver:!1};const cleanStyle={width:"100%",height:"100%",position:"static"};function HtmlWrap(l){const e=document.querySelector(".screens--container");return React$2.useEffect(()=>(l.onMount&&l.onMount(),()=>{l.onUnMount&&l.onUnMount()}),[]),jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{zIndexRange:[6,6],style:cleanStyle,portal:e?{current:e}:void 0,onOcclude:()=>{},calculatePosition:()=>[0,0],wrapperClass:"htmlpro-wrap-100-h",children:l.children})}const characterMs$3=75,minMs$1=1400;function ConversationalProComponent({keyboardControl:l,emitEvent:e,getEvent:n,pause:t,lines:a,edges:o,characters:d,actors:h,background:f,soundActions:u,lodSettings:p,autoPlay:_,autoEnd:R,progress:x}){var $e,rt,ft;const S=a.length-1<=(x==null?void 0:x.line)?a.length-1:(x==null?void 0:x.line)||0,[g,v]=React$2.useState(!1),[b,T]=React$2.useState(!0),[y,w]=React$2.useState(!!_),[C,N]=React$2.useState(!1),[D,P]=React$2.useState(S),[k,F]=React$2.useState(!1),[M]=u,{start:j,stop:$}=useTimeout(),B=(($e=f==null?void 0:f.img)==null?void 0:$e.url)||null,X=a[D],{voiceOver:re,decision:ae}=X;let{flex:ee}=X,K=[];const ne=!!o,ue=re||X.type==="conversationalNarration",me=ae||X.type==="conversationalDecision",J=X.type==="conversationalCamera",[H,W]=React$2.useState([]),V=React$2.useMemo(()=>H[H.length-1],[H]),z=React$2.useCallback(()=>{if(ne){const Ge=a.filter(De=>!o.find(Re=>Re.toId===De.id));if(Ge.length){const De=Ge[0],Re=a.indexOf(De);if(Re>=0)return Re}}return-1},[ne,a,o]),Y=React$2.useCallback(()=>{const Ge=o.find(Re=>Re.fromId===V)||o.find(Re=>Re.toId===V),De=a.find(Re=>Re.id===(Ge==null?void 0:Ge.fromId));return!V&&(x==null?void 0:x.line)>=0?{decision:!0}:De},[o,a,V,x==null?void 0:x.line]),ie=React$2.useCallback(()=>{if(ne){const De=Y();return De==null?void 0:De.decision}const Ge=a[D-1]?a[D-1]:{};return D>0&&(Ge==null?void 0:Ge.decision)},[ne,Y,a,D]),le=React$2.useCallback(()=>{if(ne){const De=Y();return(De==null?void 0:De.type)==="conversationalCamera"}const Ge=a[D-1]?a[D-1]:{};return D>0&&(Ge==null?void 0:Ge.type)==="conversationalCamera"},[ne,a,D,Y]),fe=React$2.useCallback(Ge=>n({type:"translate",payload:Ge}),[n]),ce=React$2.useMemo(()=>{var De,Re;if(me)return{};if(ue)return X;const Ge=(De=X==null?void 0:X.slots)==null?void 0:De.find(ye=>ye.uid&&ye.talking);return Ge||((Re=X==null?void 0:X.slots)==null?void 0:Re.find(ye=>ye.uid&&ye.text))},[X,ue,me]),ge=a.slice(0,D+1).reverse().find(Ge=>Ge.slots),Se=!me&&((rt=X.slots)==null?void 0:rt.filter(Ge=>Ge.uid).length),Te=characterMs$3*(((ft=ce==null?void 0:ce.text)==null?void 0:ft.length)||0);let Fe=[];X.slots?Fe=X.slots:ge&&(Fe=ge.slots);const Ne=Fe.filter(Ge=>Ge.uid).map(Ge=>{const De=(d||h||[]).find(Re=>Re.uid===Ge.uid);return De&&(Ge.resource=De.resource,Ge.type=De.type),Ge.resource||(Ge.resource={}),Ge}),Qe={characters:Ne,lodSettings:p,actors:h,currentMessage:ce||{},slots:ue?K:X.slots,flex:ee,pause:t,getEvent:n};if(ue){const Ge=a.slice(D).find(Re=>Re.slots),De=ge||Ge;De&&(K=De.slots,ee=De.flex)}else if(!me&&Se&&(X.slots.forEach(Ge=>{const De=Ne.findIndex(Re=>Re.uid===Ge.uid);De>=0&&(Ne[De].emotion=Ge.emotion)}),ce&&ce.uid)){const Ge=X.slots.findIndex(Re=>Re.uid===ce.uid),De=Ne.findIndex(Re=>Re.uid===ce.uid);Ne.forEach(Re=>{Re.uid===ce.uid&&(Re.name=ce.alias)}),ce.position=ee?De:Ge}const st=React$2.useCallback(()=>{e({type:"success"})},[e]),Ze=React$2.useCallback((Ge,De)=>{const Re=[3,2,1][Ge.id],Pe=o.filter(Xe=>Xe.fromId===X.id).find(Xe=>parseInt(Xe.fromPointIndex)===Re);if(Pe){const Xe=a.findIndex(Ft=>Ft.id===Pe.toId);Pe.fromId===Pe.toId?De():Xe>=0?(P(Xe),e({type:"notifyProgress",payload:{line:Xe}})):st()}else st()},[X.id,o,e,st,a]),yt=React$2.useCallback((Ge=!0)=>{const De=Ge?["fromId","toId"]:["toId","fromId"],Re=o.filter(Xe=>Xe[De[0]]===X.id),ye=Re.length===1?Re[0]:Re.find(Xe=>Xe[De[1]]===V);if(!(ye!=null&&ye[De[0]])){st();return}Ge||W(H.slice(0,-1));const Pe=a.findIndex(Xe=>Xe.id===ye[De[1]]);Pe>=0?(P(Pe),e({type:"notifyProgress",payload:{line:Pe}})):st()},[X.id,o,H,e,st,V,a]),Ve=React$2.useCallback(Ge=>{if(ne){if(Ge){const De=[3,2,1][Ge.id],ye=o.filter(Pe=>Pe.fromId===X.id).find(Pe=>parseInt(Pe.fromPointIndex)===De);if(ye){const Pe=a.findIndex(Xe=>Xe.id===ye.toId);Pe>=0&&e({type:"notifyProgress",payload:{line:Pe}})}else e({type:"saveNode"})}}else if(D<a.length-1){const Re=D+1;e({type:"notifyProgress",payload:{line:Re}})}else e({type:"saveNode"})},[o,a,e,D,X.id,ne]),Me=React$2.useCallback((Ge,De)=>{let Re=!1;if(F(!1),T(!1),N(!1),ne)W([...H,X.id]),Ge?Ze(Ge,De):yt();else if(D<a.length-1){const Pe=D+1;P(Pe),e({type:"notifyProgress",payload:{line:Pe}}),De&&De()}else R||me||J?st():Re=!0;Re||T(!0)},[H,X.id,ne,D,a.length,R,me,J,Ze,yt,e,st]),Le=()=>{if(T(!1),F(!1),N(!1),ne)yt(!1);else if(!ie()){const Ge=D-1;P(Ge),e({type:"notifyProgress",payload:{line:Ge}})}T(!0)},Ke=React$2.useCallback(()=>ne?X&&X.type!=="conversationalDecision"&&!o.find(Ge=>Ge.fromId===X.id):D===a.length-1,[D,X,o,ne,a.length]),ke=()=>{M("click-ui"),Ke()?st():(w(!1),Me())},qe=()=>{M("click-ui"),w(!1),Le()},St=y&&!me&&!t&&!J,Ye=React$2.useMemo(()=>z()>=0&&H.length===0&&ne||D===0&&!ne||ie()||le(),[z,H.length,ne,D,ie,le]);useEkho({audioType:X==null?void 0:X.audioType,volume:X==null?void 0:X.audioVolume,voice:X==null?void 0:X.voice,started:b,slide:D,text:cleanTextOfHtmlTags(ce==null?void 0:ce.text),audio:X==null?void 0:X.audio,soundActions:u,getEvent:n,pauseTTS:t,onStart:()=>{var Ge;(Ge=ce==null?void 0:ce.emotion)!=null&&Ge.includes("think")||F(!0)},onError:()=>{N(!0)},onFinish:()=>{F(!1),St&&Me()}}),React$2.useEffect(()=>{var De;let Ge;return me?()=>{}:(((X==null?void 0:X.audioType)==="none"||C)&&!((De=ce==null?void 0:ce.emotion)!=null&&De.includes("think"))&&(F(!0),Ge=setTimeout(()=>{F(!1)},Te<minMs$1?minMs$1:Te)),()=>{Ge&&clearTimeout(Ge)})},[C,X,ce==null?void 0:ce.emotion,Te,me]),React$2.useEffect(()=>(St&&((X==null?void 0:X.audioType)==="none"||C)&&(!Ke()||Ke()&&R)&&j(Me,Te<minMs$1?minMs$1:Te),()=>{$()}),[ce,j,$,Me,X==null?void 0:X.audioType,St,C,R,a,Ke,Te]),React$2.useEffect(()=>{if(ne&&!g){const Ge=x==null?void 0:x.line;if(Ge>=0){v(!0),P(Ge);return}const De=z();De>=0&&(v(!0),P(De))}},[o,z,ne,a,g,x==null?void 0:x.line]);const ot=l({disabled:me,repeat:!1,forward:ke,rewind:Ye?null:qe});if(React$2.useEffect(()=>ot(),[ot]),J)return jsxRuntimeExports.jsx(ChangeCamera,{...X,transition:{type:"none"},emitEvent:e,success:!1,onFinish:Me},`change-camera-${D}`);if(me){const Ge=a[D].id?a.filter(Re=>Re.decision).findIndex(Re=>Re.id===a[D].id)+1:a.filter(Re=>Re.decision).findIndex(Re=>Re===a[D])+1,De={...X.payload,decisionNumber:Ge,required:!ne,branched:ne,onAddPoints:Ve,onFinish:Me,keyboardControl:l,emitEvent:e,getEvent:n,soundActions:u,inheritProps:{characters:Ne,background:f,flex:ge?ge.flex:!0,slots:ge?ge.slots:[]}};return jsxRuntimeExports.jsx(HtmlWrap,{children:jsxRuntimeExports.jsx(DecisionComponent,{...De})})}return jsxRuntimeExports.jsx(HtmlWrap,{children:jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{"data-testid":"conversational-pro-image",className:"conversation",style:B?{backgroundImage:`url("${B}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...Qe,ttsStarted:k}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",dir:"auto",children:[ce?jsxRuntimeExports.jsx(Message,{current:ce,translate:fe}):null,jsxRuntimeExports.jsxs("div",{className:"conversation--controls",children:[jsxRuntimeExports.jsx("button",{"data-testid":"conversational-pro-button-back",className:`gat--btn__round ${Ye?"disabled":""}`,disabled:Ye?!0:"",type:"button",onClick:qe,"aria-label":LangIsRtl()?fe("storylines.misc.forward"):fe("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{"data-testid":"conversational-pro-button-next",className:`gat--btn__round ${y&&Ke()?"glowing-animation":""}`,type:"button",onClick:ke,"aria-label":LangIsRtl()?fe("storylines.misc.rewind"):fe("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})]})})})}ConversationalProComponent.defaultProps={background:{},emitEvent:()=>{},soundActions:[()=>{},()=>{}]};function ConversationalComponent({emitEvent:l,getEvent:e,soundActions:n,messages:t,characters:a,alias:o,background:d,lodSettings:h}){var v;const[f,u]=React$2.useState(0),[p]=n,_=((v=d==null?void 0:d.img)==null?void 0:v.url)||null,R=t[f],x=a.map((b,T)=>({...b,name:o[T]?o[T]:b.name,uid:T})),S=()=>{const b=t.length-1;p("click-ui"),f+1<=b?u(f+1):l({type:"success"})},g=()=>{f>0&&(u(f-1),p("click-ui"))};return jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{"data-testid":"conversation-component",className:"conversation arcade-conversation",style:_?{backgroundImage:`url("${_}")`}:{},children:[jsxRuntimeExports.jsx(SlotList,{characters:x,lodSettings:h,currentMessage:R,slots:x,emitEvent:l,getEvent:e,flex:!0}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",children:[R?jsxRuntimeExports.jsx(Message,{current:R,voiceOver:R.emotion===null}):jsxRuntimeExports.jsx("div",{}),jsxRuntimeExports.jsxs("div",{className:"conversation--controls arcade-conversation--controls",children:[jsxRuntimeExports.jsx("button",{"data-testid":"conversational-back-button",className:`gat--btn__round ${f>0?"":"visibility--hidden"}`,type:"button",onClick:g,children:jsxRuntimeExports.jsx("span",{className:"icon-back"})}),jsxRuntimeExports.jsx("button",{"data-testid":"conversational-next-button",className:"gat--btn__round",type:"button",onClick:S,children:jsxRuntimeExports.jsx("span",{className:"icon-next"})})]})]})]})})}function Vignette({vignette:l,alias:e,translate:n,backgroundImageCover:t}){var u;const o=(l.img||{url:"https://min.gamelearn.io/css-resources/gamelearn/resources/conversation.jpg"}).url,[d,h]=React$2.useState(!0),f=p=>{document.querySelector(`#${p}`).focus(),h(!d)};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{"data-testid":"comic-image",className:`comic-image ${t?"comic-image--cover":""}`,children:o&&jsxRuntimeExports.jsx("img",{src:o,alt:"comic pic"})}),(u=l==null?void 0:l.textData)!=null&&u.text?jsxRuntimeExports.jsxs("div",{"data-testid":"comicCollapsable",className:`comic-collapsable ${d?"comic-collapsable--opened":""}`,children:[jsxRuntimeExports.jsx("button",{id:"buttonDown","data-testid":"buttonDown",onClick:()=>f("buttonUp"),type:"button",className:"un-btn comic-collapsable__headertoggle","aria-label":n("comic.toggleText"),children:jsxRuntimeExports.jsx("span",{className:"icon-down-arrow"})}),jsxRuntimeExports.jsxs("div",{className:"comic-collapsable__text",children:[e?jsxRuntimeExports.jsxs("b",{children:[e,": "]}):null,HTMLReactParser$1(l.textData.text)]})]}):null,jsxRuntimeExports.jsx("button",{id:"buttonUp","data-testid":"buttonUp",tabIndex:d?"-1":"0","aria-hidden":d,className:`unset-button comic-buttonup
|
|
69
|
+
${g==="results"?"conversation--layer__feedback":""}`,children:jsxRuntimeExports.jsxs("div",{className:`conversation ${a?"conversation--inScene":""}`,style:(j=d.background)!=null&&j.img?{backgroundImage:`url("${($=d.background.img)==null?void 0:$.url}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...D,children:g==="results"&&(b!=null&&b.feedback)?jsxRuntimeExports.jsx(FeedBack,{question:u,soundActions:n,inherited:S,choice:b,rewards:(b==null?void 0:b.rewards)||[],emitEvent:l}):null}),jsxRuntimeExports.jsx(DecisionBody,{...F})]})}):jsxRuntimeExports.jsx("div",{className:"popup--layer popup--layer--transparent",children:jsxRuntimeExports.jsx(DecisionBody,{...F,children:jsxRuntimeExports.jsx(FeedBack,{question:u,soundActions:n,inherited:S,choice:b,rewards:(b==null?void 0:b.rewards)||[],emitEvent:l})})})}function ImageComponent({emitEvent:l,img:e,imgName:n,documentType:t,visible:a,viewed:o,imgId_labelId:d,soundActions:h,keyboardControl:f,getEvent:u}){const p=b=>u({type:"translate",payload:b}),[_,R]=React$2.useState(!1),x=e.url,[S]=h,g=React$2.useCallback(()=>{S("click-ui"),l({type:"finishMedia",payload:{imgId:d,name:n,imgName:n,documentType:t,type:"image"}})},[S,d,n,t,l]),v=f({disabled:o,forward:g,escape:g});return React$2.useEffect(()=>v(),[v]),React$2.useEffect(()=>{!a&&!_&&(R(!0),g())},[g,a,_]),a?jsxRuntimeExports.jsx("div",{className:o?"notes--results":"readings--container readings--container--darkopacity",children:jsxRuntimeExports.jsxs("div",{className:o?"notes--results__text":"readings readings--image",children:[x&&jsxRuntimeExports.jsx("img",{src:x,alt:n}),o?null:jsxRuntimeExports.jsx("div",{className:x?"readings--image--closeBtn":"position--absolute top right",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn__round gat--btn__close",onClick:g,"aria-label":p("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})})]})}):null}function VoiceOver({name:l}){return jsxRuntimeExports.jsx("div",{className:"conversation--voice__over",children:jsxRuntimeExports.jsx("span",{children:l||"Voice-Over"})})}function ThinkFul({text:l}){return jsxRuntimeExports.jsxs("div",{className:"conversation--voice__over",children:[jsxRuntimeExports.jsx("span",{className:"icon-bubble-thinkful-black"}),jsxRuntimeExports.jsxs("span",{children:["[",l,"]"]})]})}function Message({current:l,translate:e}){var t,a;const n=l.text;return jsxRuntimeExports.jsxs("div",{className:`conversation--message ${l.voiceOver||(t=l==null?void 0:l.emotion)!=null&&t.includes("think")?"voice--over":""}`,children:[l.voiceOver?jsxRuntimeExports.jsx(VoiceOver,{name:l.name}):null,(a=l==null?void 0:l.emotion)!=null&&a.includes("think")?jsxRuntimeExports.jsx(ThinkFul,{text:e("emotion.thinking")}):null,jsxRuntimeExports.jsx("div",{className:"conversation--main__text",children:HTMLReactParser$1(n)})]})}Message.defaultProps={current:{},voiceOver:!1};const cleanStyle={width:"100%",height:"100%",position:"static"};function HtmlWrap(l){const e=document.querySelector(".screens--container");return React$2.useEffect(()=>(l.onMount&&l.onMount(),()=>{l.onUnMount&&l.onUnMount()}),[]),jsxRuntimeExports.jsx(arcadeThreeCore.HtmlPro,{zIndexRange:[6,6],style:cleanStyle,portal:e?{current:e}:void 0,onOcclude:()=>{},calculatePosition:()=>[0,0],wrapperClass:"htmlpro-wrap-100-h",children:l.children})}const characterMs$3=75,minMs$1=1400;function ConversationalProComponent({keyboardControl:l,emitEvent:e,getEvent:n,pause:t,lines:a,edges:o,characters:d,actors:h,background:f,soundActions:u,lodSettings:p,autoPlay:_,autoEnd:R,progress:x}){var $e,rt,ft;const S=a.length-1<=(x==null?void 0:x.line)?a.length-1:(x==null?void 0:x.line)||0,[g,v]=React$2.useState(!1),[b,T]=React$2.useState(!0),[y,w]=React$2.useState(!!_),[C,N]=React$2.useState(!1),[D,P]=React$2.useState(S),[k,F]=React$2.useState(!1),[M]=u,{start:j,stop:$}=useTimeout(),B=(($e=f==null?void 0:f.img)==null?void 0:$e.url)||null,X=a[D],{voiceOver:re,decision:ae}=X;let{flex:ee}=X,K=[];const ne=!!o,ue=re||X.type==="conversationalNarration",me=ae||X.type==="conversationalDecision",J=X.type==="conversationalCamera",[H,W]=React$2.useState([]),V=React$2.useMemo(()=>H[H.length-1],[H]),z=React$2.useCallback(()=>{if(ne){const Ge=a.filter(De=>!o.find(Re=>Re.toId===De.id));if(Ge.length){const De=Ge[0],Re=a.indexOf(De);if(Re>=0)return Re}}return-1},[ne,a,o]),Y=React$2.useCallback(()=>{const Ge=o.find(Re=>Re.fromId===V)||o.find(Re=>Re.toId===V),De=a.find(Re=>Re.id===(Ge==null?void 0:Ge.fromId));return!V&&(x==null?void 0:x.line)>=0?{decision:!0}:De},[o,a,V,x==null?void 0:x.line]),ie=React$2.useCallback(()=>{if(ne){const De=Y();return De==null?void 0:De.decision}const Ge=a[D-1]?a[D-1]:{};return D>0&&(Ge==null?void 0:Ge.decision)},[ne,Y,a,D]),le=React$2.useCallback(()=>{if(ne){const De=Y();return(De==null?void 0:De.type)==="conversationalCamera"}const Ge=a[D-1]?a[D-1]:{};return D>0&&(Ge==null?void 0:Ge.type)==="conversationalCamera"},[ne,a,D,Y]),fe=React$2.useCallback(Ge=>n({type:"translate",payload:Ge}),[n]),ce=React$2.useMemo(()=>{var De,Re;if(me)return{};if(ue)return X;const Ge=(De=X==null?void 0:X.slots)==null?void 0:De.find(ye=>ye.uid&&ye.talking);return Ge||((Re=X==null?void 0:X.slots)==null?void 0:Re.find(ye=>ye.uid&&ye.text))},[X,ue,me]),ge=a.slice(0,D+1).reverse().find(Ge=>Ge.slots),Se=!me&&((rt=X.slots)==null?void 0:rt.filter(Ge=>Ge.uid).length),Te=characterMs$3*(((ft=ce==null?void 0:ce.text)==null?void 0:ft.length)||0);let Fe=[];X.slots?Fe=X.slots:ge&&(Fe=ge.slots);const Ne=Fe.filter(Ge=>Ge.uid).map(Ge=>{const De=(d||h||[]).find(Re=>Re.uid===Ge.uid);return De&&(Ge.resource=De.resource,Ge.type=De.type),Ge.resource||(Ge.resource={}),Ge}),Qe={characters:Ne,lodSettings:p,actors:h,currentMessage:ce||{},slots:ue?K:X.slots,flex:ee,pause:t,getEvent:n};if(ue){const Ge=a.slice(D).find(Re=>Re.slots),De=ge||Ge;De&&(K=De.slots,ee=De.flex)}else if(!me&&Se&&(X.slots.forEach(Ge=>{const De=Ne.findIndex(Re=>Re.uid===Ge.uid);De>=0&&(Ne[De].emotion=Ge.emotion)}),ce&&ce.uid)){const Ge=X.slots.findIndex(Re=>Re.uid===ce.uid),De=Ne.findIndex(Re=>Re.uid===ce.uid);Ne.forEach(Re=>{Re.uid===ce.uid&&(Re.name=ce.alias)}),ce.position=ee?De:Ge}const st=React$2.useCallback(()=>{e({type:"success"})},[e]),Ze=React$2.useCallback((Ge,De)=>{const Re=[3,2,1][Ge.id],Pe=o.filter(Xe=>Xe.fromId===X.id).find(Xe=>parseInt(Xe.fromPointIndex)===Re);if(Pe){const Xe=a.findIndex(Ft=>Ft.id===Pe.toId);Pe.fromId===Pe.toId?De():Xe>=0?(P(Xe),e({type:"notifyProgress",payload:{line:Xe}})):st()}else st()},[X.id,o,e,st,a]),yt=React$2.useCallback((Ge=!0)=>{const De=Ge?["fromId","toId"]:["toId","fromId"],Re=o.filter(Xe=>Xe[De[0]]===X.id),ye=Re.length===1?Re[0]:Re.find(Xe=>Xe[De[1]]===V);if(!(ye!=null&&ye[De[0]])){st();return}Ge||W(H.slice(0,-1));const Pe=a.findIndex(Xe=>Xe.id===ye[De[1]]);Pe>=0?(P(Pe),e({type:"notifyProgress",payload:{line:Pe}})):st()},[X.id,o,H,e,st,V,a]),Ve=React$2.useCallback(Ge=>{if(ne){if(Ge){const De=[3,2,1][Ge.id],ye=o.filter(Pe=>Pe.fromId===X.id).find(Pe=>parseInt(Pe.fromPointIndex)===De);if(ye){const Pe=a.findIndex(Xe=>Xe.id===ye.toId);Pe>=0&&e({type:"notifyProgress",payload:{line:Pe}})}else e({type:"saveNode"})}}else if(D<a.length-1){const Re=D+1;e({type:"notifyProgress",payload:{line:Re}})}else e({type:"saveNode"})},[o,a,e,D,X.id,ne]),Me=React$2.useCallback((Ge,De)=>{let Re=!1;if(F(!1),T(!1),N(!1),ne)W([...H,X.id]),Ge?Ze(Ge,De):yt();else if(D<a.length-1){const Pe=D+1;P(Pe),e({type:"notifyProgress",payload:{line:Pe}}),De&&De()}else R||me||J?st():Re=!0;Re||T(!0)},[H,X.id,ne,D,a.length,R,me,J,Ze,yt,e,st]),Le=()=>{if(T(!1),F(!1),N(!1),ne)yt(!1);else if(!ie()){const Ge=D-1;P(Ge),e({type:"notifyProgress",payload:{line:Ge}})}T(!0)},Ke=React$2.useCallback(()=>ne?X&&X.type!=="conversationalDecision"&&!o.find(Ge=>Ge.fromId===X.id):D===a.length-1,[D,X,o,ne,a.length]),ke=()=>{M("click-ui"),Ke()?st():(w(!1),Me())},qe=()=>{M("click-ui"),w(!1),Le()},St=y&&!me&&!t&&!J,Ye=React$2.useMemo(()=>z()>=0&&H.length===0&&ne||D===0&&!ne||ie()||le(),[z,H.length,ne,D,ie,le]);useEkho({audioType:X==null?void 0:X.audioType,volume:X==null?void 0:X.audioVolume,voice:X==null?void 0:X.voice,started:b,slide:D,text:cleanTextOfHtmlTags(ce==null?void 0:ce.text),audio:X==null?void 0:X.audio,soundActions:u,getEvent:n,pauseTTS:t,onStart:()=>{var Ge;(Ge=ce==null?void 0:ce.emotion)!=null&&Ge.includes("think")||F(!0)},onError:()=>{N(!0)},onFinish:()=>{F(!1),St&&Me()}}),React$2.useEffect(()=>{var De;let Ge;return me?()=>{}:(((X==null?void 0:X.audioType)==="none"||C)&&!((De=ce==null?void 0:ce.emotion)!=null&&De.includes("think"))&&(F(!0),Ge=setTimeout(()=>{F(!1)},Te<minMs$1?minMs$1:Te)),()=>{Ge&&clearTimeout(Ge)})},[C,X,ce==null?void 0:ce.emotion,Te,me]),React$2.useEffect(()=>(St&&((X==null?void 0:X.audioType)==="none"||C)&&(!Ke()||Ke()&&R)&&j(Me,Te<minMs$1?minMs$1:Te),()=>{$()}),[ce,j,$,Me,X==null?void 0:X.audioType,St,C,R,a,Ke,Te]),React$2.useEffect(()=>{if(ne&&!g){const Ge=x==null?void 0:x.line;if(Ge>=0){v(!0),P(Ge);return}const De=z();De>=0&&(v(!0),P(De))}},[o,z,ne,a,g,x==null?void 0:x.line]);const ot=l({disabled:me,repeat:!1,forward:ke,rewind:Ye?null:qe});if(React$2.useEffect(()=>ot(),[ot]),J)return jsxRuntimeExports.jsx(ChangeCamera,{...X,transition:{type:"none"},emitEvent:e,success:!1,onFinish:Me},`change-camera-${D}`);if(me){const Ge=a[D].id?a.filter(Re=>Re.decision).findIndex(Re=>Re.id===a[D].id)+1:a.filter(Re=>Re.decision).findIndex(Re=>Re===a[D])+1,De={...X.payload,decisionNumber:Ge,required:!ne,branched:ne,onAddPoints:Ve,onFinish:Me,keyboardControl:l,emitEvent:e,getEvent:n,soundActions:u,inheritProps:{characters:Ne,background:f,flex:ge?ge.flex:!0,slots:ge?ge.slots:[]}};return jsxRuntimeExports.jsx(HtmlWrap,{children:jsxRuntimeExports.jsx(DecisionComponent,{...De})})}return jsxRuntimeExports.jsx(HtmlWrap,{children:jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{"data-testid":"conversational-pro-image",className:"conversation",style:B?{backgroundImage:`url("${B}")`}:null,children:[jsxRuntimeExports.jsx(SlotList,{...Qe,ttsStarted:k}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",dir:"auto",children:[ce?jsxRuntimeExports.jsx(Message,{current:ce,translate:fe}):null,jsxRuntimeExports.jsxs("div",{className:"conversation--controls",children:[jsxRuntimeExports.jsx("button",{"data-testid":"conversational-pro-button-back",className:`gat--btn__round ${Ye?"disabled":""}`,disabled:Ye?!0:"",type:"button",onClick:qe,"aria-label":LangIsRtl()?fe("storylines.misc.forward"):fe("storylines.misc.rewind"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),jsxRuntimeExports.jsx("button",{"data-testid":"conversational-pro-button-next",className:`gat--btn__round ${y&&Ke()?"glowing-animation":""}`,type:"button",onClick:ke,"aria-label":LangIsRtl()?fe("storylines.misc.rewind"):fe("storylines.misc.forward"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})]})]})})})}ConversationalProComponent.defaultProps={background:{},emitEvent:()=>{},soundActions:[()=>{},()=>{}]};function ConversationalComponent({emitEvent:l,getEvent:e,soundActions:n,messages:t,characters:a,alias:o,background:d,lodSettings:h}){var v;const[f,u]=React$2.useState(0),[p]=n,_=((v=d==null?void 0:d.img)==null?void 0:v.url)||null,R=t[f],x=a.map((b,T)=>({...b,name:o[T]?o[T]:b.name,uid:T})),S=()=>{const b=t.length-1;p("click-ui"),f+1<=b?u(f+1):l({type:"success"})},g=()=>{f>0&&(u(f-1),p("click-ui"))};return jsxRuntimeExports.jsx("div",{className:"conversation--layer",children:jsxRuntimeExports.jsxs("div",{"data-testid":"conversation-component",className:"conversation arcade-conversation",style:_?{backgroundImage:`url("${_}")`}:{},children:[jsxRuntimeExports.jsx(SlotList,{characters:x,lodSettings:h,currentMessage:R,slots:x,emitEvent:l,getEvent:e,flex:!0}),jsxRuntimeExports.jsxs("div",{className:"conversation--body",children:[R?jsxRuntimeExports.jsx(Message,{current:R,voiceOver:R.emotion===null}):jsxRuntimeExports.jsx("div",{}),jsxRuntimeExports.jsxs("div",{className:"conversation--controls arcade-conversation--controls",children:[jsxRuntimeExports.jsx("button",{"data-testid":"conversational-back-button",className:`gat--btn__round ${f>0?"":"visibility--hidden"}`,type:"button",onClick:g,children:jsxRuntimeExports.jsx("span",{className:"icon-back"})}),jsxRuntimeExports.jsx("button",{"data-testid":"conversational-next-button",className:"gat--btn__round",type:"button",onClick:S,children:jsxRuntimeExports.jsx("span",{className:"icon-next"})})]})]})]})})}function Vignette({vignette:l,alias:e,translate:n,backgroundImageCover:t}){var _;const o=(l.img||{url:"https://min.gamelearn.io/css-resources/gamelearn/resources/conversation.jpg"}).url,[d,h]=React$2.useState(!0),f=R=>{document.querySelector(`#${R}`).focus(),h(!d)},u=/\.(mp4|mov|webm)$/i.test(o),p={src:o,style:t?{minHeight:"100%",minWidth:"100%",position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}:{height:"100%",width:"100%"}};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsxs("div",{"data-testid":"comic-image",className:`comic-image ${t?"comic-image--cover":""}`,children:[u&&jsxRuntimeExports.jsx("video",{"data-testid":"videoTestId",autoPlay:!0,...p}),o&&!u&&jsxRuntimeExports.jsx("img",{src:o,alt:"comic pic"})]}),(_=l==null?void 0:l.textData)!=null&&_.text?jsxRuntimeExports.jsxs("div",{"data-testid":"comicCollapsable",className:`comic-collapsable ${d?"comic-collapsable--opened":""}`,children:[jsxRuntimeExports.jsx("button",{id:"buttonDown","data-testid":"buttonDown",onClick:()=>f("buttonUp"),type:"button",className:"un-btn comic-collapsable__headertoggle","aria-label":n("comic.toggleText"),children:jsxRuntimeExports.jsx("span",{className:"icon-down-arrow"})}),jsxRuntimeExports.jsxs("div",{className:"comic-collapsable__text",children:[e?jsxRuntimeExports.jsxs("b",{children:[e,": "]}):null,HTMLReactParser$1(l.textData.text)]})]}):null,jsxRuntimeExports.jsx("button",{id:"buttonUp","data-testid":"buttonUp",tabIndex:d?"-1":"0","aria-hidden":d,className:`unset-button comic-buttonup
|
|
70
70
|
${d?"":"comic-buttonup--visible"}`,type:"button",onClick:()=>f("buttonDown"),"aria-label":n("comic.toggleText"),children:jsxRuntimeExports.jsx("span",{className:"icon-up-arrow"})})]})}function Slide({slide:l,transition:e,translate:n,backgroundImageCover:t}){const a=l.transitionEffects||e;return jsxRuntimeExports.jsx("div",{className:`comic-slide__item ${a}`,"aria-label":"comic slide item",children:l.vignettes.map(o=>jsxRuntimeExports.jsx(Vignette,{vignette:o,alias:l.alias,"aria-hidden":"true",translate:n,backgroundImageCover:t},`Vignete ${o.vignetteOrder}`))})}const characterMs$2=75;function ComicComponent({slides:l,emitEvent:e,getEvent:n,soundActions:t=[()=>{},()=>{}],autoPlay:a,autoEnd:o,pause:d,isFirstNode:h=!1,progress:f,keyboardControl:u,backgroundImageCover:p=!1}){var ae,ee,K,ne,ue,me,J,H;const _=(f==null?void 0:f.slide)||0,R=W=>n({type:"translate",payload:W}),[x,S]=React$2.useState(!0),[g,v]=React$2.useState(!!a),[b,T]=React$2.useState(!1),{start:y,stop:w}=useTimeout(),[C,N]=React$2.useState(_),[D,P]=React$2.useState("slide-animation"),[k]=t,F=l==null?void 0:l[C],M=React$2.useCallback(()=>{S(!1),e({type:"success"})},[e]),j=React$2.useCallback(()=>{if(S(!1),T(!1),C+1<l.length&&!d){const W=C+1;P("slide-animation"),N(W),S(!0),e({type:"notifyProgress",payload:{slide:W}})}else o&&!d&&M()},[C,l.length,d,o,e,M]),$=React$2.useCallback(()=>{if(S(!1),T(!1),C-1>=0){const W=C-1;P("slide-animation"),N(W),S(!0),k("click-ui"),e({type:"notifyProgress",payload:{slide:W}})}},[k,C,e]),B=()=>{k("click-ui"),v(!1),j()},X=()=>{k("click-ui"),v(!1),$()},re=u({repeat:!1,rewind:C>0?X:null,forward:C+1>=l.length?M:B,escape:C+1>=l.length?M:null});return React$2.useEffect(()=>re(),[re]),useEkho({audioType:(ae=l==null?void 0:l[C])==null?void 0:ae.audioType,voice:(ee=l==null?void 0:l[C])==null?void 0:ee.voice,text:cleanTextOfHtmlTags((ne=(K=l==null?void 0:l[C])==null?void 0:K.vignettes[0].textData)==null?void 0:ne.text),audio:(ue=l==null?void 0:l[C])==null?void 0:ue.audio,slide:C,started:x,soundActions:t,getEvent:n,pauseTTS:d,volume:(me=l==null?void 0:l[C])!=null&&me.audioVolume||((J=l==null?void 0:l[C])==null?void 0:J.audioVolume)===0?(H=l==null?void 0:l[C])==null?void 0:H.audioVolume:.5,onError:()=>{T(!0)},onFinish:()=>{g&&!(F!=null&&F.slideTimer)&&j()}}),React$2.useEffect(()=>{var W,V;if(g){if(F!=null&&F.slideTimer)y(j,F.slideTimer*1e3);else if((F==null?void 0:F.audioType)==="none"&&!d||b&&!d){const z=characterMs$2*(((V=(W=F==null?void 0:F.vignettes[0])==null?void 0:W.textData)==null?void 0:V.text.length)||0);y(j,z<1400?1400:z)}}return()=>{w()}},[b,g,j,d,F==null?void 0:F.audio,F==null?void 0:F.audioType,F==null?void 0:F.slideTimer,F==null?void 0:F.vignettes,y,w]),l!=null&&l.length?jsxRuntimeExports.jsx("div",{dir:LangIsRtl()?"rtl":"auto",className:`comic component ${h?"":"growIn-animation"}`,role:"main","aria-label":"Comic",children:jsxRuntimeExports.jsxs("div",{className:"comic-slider",role:"navigation","aria-label":"Slider",children:[l[C]&&jsxRuntimeExports.jsx(Slide,{slide:l[C],transition:D,soundActions:t,emitEvent:e,role:"complementary","aria-hidden":"true",translate:R,backgroundImageCover:p},`comic page ${l[C].slideOrder}`),C>0&&jsxRuntimeExports.jsx("button",{type:"button",className:"comic-control comic-control--left gat--btn__round","data-testid":"btn-bck",onClick:X,"aria-label":LangIsRtl()?R("comic.next"):R("comic.previous"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-next":"icon-back"})}),C<l.length&&jsxRuntimeExports.jsx("button",{type:"button",className:`comic-control comic-control--right gat--btn__round
|
|
71
71
|
${g&&C+1>=l.length?"glowing-animation":""}`,"data-testid":"btn-nxt",onClick:()=>{C+1<l.length?B():(k("click-ui"),M())},"aria-label":LangIsRtl()?R("comic.previous"):R("comic.next"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})]})}):null}const characterMs$1=75;function CartelComponent({img:l,text:e,audio:n,audioType:t,voice:a,emitEvent:o,getEvent:d,soundActions:h,audioVolume:f,pause:u,keyboardControl:p,backgroundImageCover:_=!1,autoEnd:R=!1,customTimer:x}){const[S,g]=React$2.useState(!1),v=j=>d({type:"translate",payload:j}),b=(l==null?void 0:l.url)||"https://min.gamelearn.io/css-resources/gamelearn/resources/conversation.jpg",T=/\.(mp4|mov|webm)$/i.test(b),y=React$2.useRef(),w=React$2.useRef(),[C]=h;useEkho({audioType:t,voice:a,text:e,audio:n,soundActions:h,getEvent:d,volume:f,pauseTTS:u,onError:()=>{g(!0)},onFinish:()=>{R&&n&&!x&&N()}});const N=React$2.useCallback(()=>{C("click-ui"),o({type:"success"})},[o,C]),D=p({repeat:!1,forward:N,escape:N});React$2.useEffect(()=>D(),[D]);const P=(j,$)=>window.matchMedia("(min-width: 1280px)").matches?$:j,k=React$2.useCallback(()=>{if(_!==!0&&e&&y.current){const j=y.current.naturalWidth/y.current.naturalHeight;let $=y.current.height*j,B=y.current.height;if($>y.current.width&&($=y.current.width,B=y.current.width/j),w.current.style.width=`${$}px`,window.innerHeight<y.current.width)w.current.style.bottom=`${P(24,48)+P(36,100)}px`;else{const X=(window.innerHeight-B)/2+P(36,100);w.current.style.bottom=`${X}px`}}},[_,e]),F=React$2.useCallback(()=>{if(_!==!0&&e&&y.current){const j=y.current.videoWidth/y.current.videoHeight,$=y.current.getBoundingClientRect().height*j;w.current.style.width=`${$}px`,w.current.style.bottom=`${P(24,48)+P(36,100)}px`}},[_,e]);React$2.useEffect(()=>{y.current&&new ResizeObserver(()=>{P(24,48),T?F():k()}).observe(y.current)},[k,F,T]),React$2.useEffect(()=>{if(R&&!u){if(x&&x!==0){const j=x*1e3,$=setTimeout(()=>{N()},j);return()=>{clearTimeout($)}}else if(!n){const j=characterMs$1*(e.length||0),$=j<2400?2400:j,B=setTimeout(()=>{N()},$);return()=>{clearTimeout(B)}}}},[n,S,R,N,x,u,e.length]);const M={src:b,style:_?{minHeight:"100%",minWidth:"100%",position:"fixed",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}:{height:"100%",width:"100%"}};return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:`cartel ${_?"cartel--cover":""}`,children:jsxRuntimeExports.jsxs("div",{className:"cartel__imagewrap",children:[T&&jsxRuntimeExports.jsx("video",{autoPlay:!0,ref:y,...M,onLoadedData:F}),!T&&jsxRuntimeExports.jsx("img",{ref:y,onLoad:k,className:"cartel__image",src:b,alt:"cartel pic"}),e&&jsxRuntimeExports.jsx("div",{ref:w,className:"cartel__textwrap",children:jsxRuntimeExports.jsx("div",{className:"cartel__text",children:jsxRuntimeExports.jsx("span",{children:e})})})]})}),jsxRuntimeExports.jsx("div",{className:"position--absolute center right",children:jsxRuntimeExports.jsx("button",{"data-testid":"cartel-close-button",type:"button",className:"gat--btn__round",onClick:()=>N(),"aria-label":v("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:LangIsRtl()?"icon-back":"icon-next"})})})]})}var Typist$1={exports:{}};(function(l){l.exports=function(e){var n={};function t(a){if(n[a])return n[a].exports;var o=n[a]={exports:{},id:a,loaded:!1};return e[a].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}return t.m=e,t.c=n,t.p="",t(0)}([function(e,n,t){Object.defineProperty(n,"__esModule",{value:!0});var a=Object.assign||function(k){for(var F=1;F<arguments.length;F++){var M=arguments[F];for(var j in M)Object.prototype.hasOwnProperty.call(M,j)&&(k[j]=M[j])}return k},o=function(){function k(F,M){for(var j=0;j<M.length;j++){var $=M[j];$.enumerable=$.enumerable||!1,$.configurable=!0,"value"in $&&($.writable=!0),Object.defineProperty(F,$.key,$)}}return function(F,M,j){return M&&k(F.prototype,M),j&&k(F,j),F}}(),d=t(1),h=y(d),f=t(2),u=y(f),p=t(10),_=y(p),R=t(12),x=y(R),S=t(13),g=y(S),v=t(14),b=T(v);function T(k){if(k&&k.__esModule)return k;var F={};if(k!=null)for(var M in k)Object.prototype.hasOwnProperty.call(k,M)&&(F[M]=k[M]);return F.default=k,F}function y(k){return k&&k.__esModule?k:{default:k}}function w(k,F){if(!(k instanceof F))throw new TypeError("Cannot call a class as a function")}function C(k,F){if(!k)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return F&&(typeof F=="object"||typeof F=="function")?F:k}function N(k,F){if(typeof F!="function"&&F!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof F);k.prototype=Object.create(F&&F.prototype,{constructor:{value:k,enumerable:!1,writable:!0,configurable:!0}}),F&&(Object.setPrototypeOf?Object.setPrototypeOf(k,F):k.__proto__=F)}var D=["🔙","⏰"],P=function(k){N(F,k);function F(M){w(this,F);var j=C(this,(F.__proto__||Object.getPrototypeOf(F)).call(this,M));return j.state={textLines:[],isDone:!1},j.onTypingDone=function(){j.mounted&&(j.setState({isDone:!0}),j.props.onTypingDone())},j.delayGenerator=function($,B,X,re){var ae=j.props.avgTypingDelay,ee=j.props.stdTypingDelay;return j.props.delayGenerator(ae,ee,{line:$,lineIdx:B,character:X,charIdx:re,defDelayGenerator:function(){var ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ae,ue=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ee;return b.gaussianRnd(ne,ue)}})},j.typeLine=function($,B){if(!j.mounted)return Promise.resolve();var X=$,re=j.props.onLineTyped;return b.isBackspaceElement($)?($.props.delay>0&&(j.introducedDelay=$.props.delay),X="🔙".repeat($.props.count)):b.isDelayElement($)&&(j.introducedDelay=$.props.ms,X="⏰"),new Promise(function(ae,ee){j.setState({textLines:j.state.textLines.concat([""])},function(){b.eachPromise(X,j.typeCharacter,X,B).then(function(){return re(X,B)}).then(ae).catch(ee)})})},j.typeCharacter=function($,B,X,re){if(!j.mounted)return Promise.resolve();var ae=j.props.onCharacterTyped;return new Promise(function(ee){var K=j.state.textLines.slice();b.sleep(j.introducedDelay).then(function(){j.introducedDelay=null;var ne=$==="🔙",ue=$==="⏰";if(ue){ee();return}if(ne&&re>0){for(var me=re-1,J=K[me],H=me;H>=0&&!(J.length>0&&!D.includes(J[0]));H--)me=H,J=K[me];K[me]=J.substr(0,J.length-1)}else K[re]+=$;j.setState({textLines:K},function(){var W=j.delayGenerator(X,re,$,B);ae($,B),setTimeout(ee,W)})})})},j.mounted=!1,j.linesToType=[],j.introducedDelay=null,M.children&&(j.linesToType=b.extractTextFromElement(M.children)),j}return o(F,[{key:"componentDidMount",value:function(){this.mounted=!0;var j=this.props,$=j.children,B=j.startDelay;$?B>0&&typeof window<"u"?setTimeout(this.typeAllLines.bind(this),B):this.typeAllLines():this.onTypingDone()}},{key:"shouldComponentUpdate",value:function(j,$){if($.textLines.length!==this.state.textLines.length)return!0;for(var B=0;B<$.textLines.length;B++){var X=this.state.textLines[B],re=$.textLines[B];if(X!==re)return!0}return this.state.isDone!==$.isDone}},{key:"componentWillUnmount",value:function(){this.mounted=!1}},{key:"typeAllLines",value:function(){var j=this,$=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.linesToType;return b.eachPromise($,this.typeLine).then(function(){return j.onTypingDone()})}},{key:"render",value:function(){var j=this.props,$=j.className,B=j.cursor,X=this.state.isDone,re=b.cloneElementWithSpecifiedText({element:this.props.children,textLines:this.state.textLines});return h.default.createElement("div",{className:"Typist "+$},re,h.default.createElement(_.default,a({isDone:X},B)))}}]),F}(d.Component);P.propTypes={children:u.default.node,className:u.default.string,avgTypingDelay:u.default.number,stdTypingDelay:u.default.number,startDelay:u.default.number,cursor:u.default.object,onCharacterTyped:u.default.func,onLineTyped:u.default.func,onTypingDone:u.default.func,delayGenerator:u.default.func},P.defaultProps={className:"",avgTypingDelay:70,stdTypingDelay:25,startDelay:0,cursor:{},onCharacterTyped:function(){},onLineTyped:function(){},onTypingDone:function(){},delayGenerator:b.gaussianRnd},n.default=P,P.Backspace=x.default,P.Delay=g.default},function(e,n){e.exports=React$2},function(e,n,t){if(process.env.NODE_ENV!=="production"){var a=typeof Symbol=="function"&&Symbol.for&&Symbol.for("react.element")||60103,o=function(h){return typeof h=="object"&&h!==null&&h.$$typeof===a},d=!0;e.exports=t(3)(o,d)}else e.exports=t(9)()},function(e,n,t){var a=t(4),o=t(5),d=t(6),h=t(7),f=t(8);e.exports=function(u,p){var _=typeof Symbol=="function"&&Symbol.iterator,R="@@iterator";function x(K){var ne=K&&(_&&K[_]||K[R]);if(typeof ne=="function")return ne}var S="<<anonymous>>",g={array:y("array"),bool:y("boolean"),func:y("function"),number:y("number"),object:y("object"),string:y("string"),symbol:y("symbol"),any:w(),arrayOf:C,element:N(),instanceOf:D,node:M(),objectOf:k,oneOf:P,oneOfType:F,shape:j};function v(K,ne){return K===ne?K!==0||1/K===1/ne:K!==K&&ne!==ne}function b(K){this.message=K,this.stack=""}b.prototype=Error.prototype;function T(K){if(process.env.NODE_ENV!=="production")var ne={},ue=0;function me(H,W,V,z,Y,ie,le){if(z=z||S,ie=ie||V,le!==h){if(p)o(!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 fe=z+":"+V;!ne[fe]&&ue<3&&(d(!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.",ie,z),ne[fe]=!0,ue++)}}return W[V]==null?H?W[V]===null?new b("The "+Y+" `"+ie+"` is marked as required "+("in `"+z+"`, but its value is `null`.")):new b("The "+Y+" `"+ie+"` is marked as required in "+("`"+z+"`, but its value is `undefined`.")):null:K(W,V,z,Y,ie)}var J=me.bind(null,!1);return J.isRequired=me.bind(null,!0),J}function y(K){function ne(ue,me,J,H,W,V){var z=ue[me],Y=X(z);if(Y!==K){var ie=re(z);return new b("Invalid "+H+" `"+W+"` of type "+("`"+ie+"` supplied to `"+J+"`, expected ")+("`"+K+"`."))}return null}return T(ne)}function w(){return T(a.thatReturnsNull)}function C(K){function ne(ue,me,J,H,W){if(typeof K!="function")return new b("Property `"+W+"` of component `"+J+"` has invalid PropType notation inside arrayOf.");var V=ue[me];if(!Array.isArray(V)){var z=X(V);return new b("Invalid "+H+" `"+W+"` of type "+("`"+z+"` supplied to `"+J+"`, expected an array."))}for(var Y=0;Y<V.length;Y++){var ie=K(V,Y,J,H,W+"["+Y+"]",h);if(ie instanceof Error)return ie}return null}return T(ne)}function N(){function K(ne,ue,me,J,H){var W=ne[ue];if(!u(W)){var V=X(W);return new b("Invalid "+J+" `"+H+"` of type "+("`"+V+"` supplied to `"+me+"`, expected a single ReactElement."))}return null}return T(K)}function D(K){function ne(ue,me,J,H,W){if(!(ue[me]instanceof K)){var V=K.name||S,z=ee(ue[me]);return new b("Invalid "+H+" `"+W+"` of type "+("`"+z+"` supplied to `"+J+"`, expected ")+("instance of `"+V+"`."))}return null}return T(ne)}function P(K){if(!Array.isArray(K))return process.env.NODE_ENV!=="production"&&d(!1,"Invalid argument supplied to oneOf, expected an instance of array."),a.thatReturnsNull;function ne(ue,me,J,H,W){for(var V=ue[me],z=0;z<K.length;z++)if(v(V,K[z]))return null;var Y=JSON.stringify(K);return new b("Invalid "+H+" `"+W+"` of value `"+V+"` "+("supplied to `"+J+"`, expected one of "+Y+"."))}return T(ne)}function k(K){function ne(ue,me,J,H,W){if(typeof K!="function")return new b("Property `"+W+"` of component `"+J+"` has invalid PropType notation inside objectOf.");var V=ue[me],z=X(V);if(z!=="object")return new b("Invalid "+H+" `"+W+"` of type "+("`"+z+"` supplied to `"+J+"`, expected an object."));for(var Y in V)if(V.hasOwnProperty(Y)){var ie=K(V,Y,J,H,W+"."+Y,h);if(ie instanceof Error)return ie}return null}return T(ne)}function F(K){if(!Array.isArray(K))return process.env.NODE_ENV!=="production"&&d(!1,"Invalid argument supplied to oneOfType, expected an instance of array."),a.thatReturnsNull;for(var ne=0;ne<K.length;ne++){var ue=K[ne];if(typeof ue!="function")return d(!1,"Invalid argument supplid to oneOfType. Expected an array of check functions, but received %s at index %s.",ae(ue),ne),a.thatReturnsNull}function me(J,H,W,V,z){for(var Y=0;Y<K.length;Y++){var ie=K[Y];if(ie(J,H,W,V,z,h)==null)return null}return new b("Invalid "+V+" `"+z+"` supplied to "+("`"+W+"`."))}return T(me)}function M(){function K(ne,ue,me,J,H){return $(ne[ue])?null:new b("Invalid "+J+" `"+H+"` supplied to "+("`"+me+"`, expected a ReactNode."))}return T(K)}function j(K){function ne(ue,me,J,H,W){var V=ue[me],z=X(V);if(z!=="object")return new b("Invalid "+H+" `"+W+"` of type `"+z+"` "+("supplied to `"+J+"`, expected `object`."));for(var Y in K){var ie=K[Y];if(ie){var le=ie(V,Y,J,H,W+"."+Y,h);if(le)return le}}return null}return T(ne)}function $(K){switch(typeof K){case"number":case"string":case"undefined":return!0;case"boolean":return!K;case"object":if(Array.isArray(K))return K.every($);if(K===null||u(K))return!0;var ne=x(K);if(ne){var ue=ne.call(K),me;if(ne!==K.entries){for(;!(me=ue.next()).done;)if(!$(me.value))return!1}else for(;!(me=ue.next()).done;){var J=me.value;if(J&&!$(J[1]))return!1}}else return!1;return!0;default:return!1}}function B(K,ne){return K==="symbol"||ne["@@toStringTag"]==="Symbol"||typeof Symbol=="function"&&ne instanceof Symbol}function X(K){var ne=typeof K;return Array.isArray(K)?"array":K instanceof RegExp?"object":B(ne,K)?"symbol":ne}function re(K){if(typeof K>"u"||K===null)return""+K;var ne=X(K);if(ne==="object"){if(K instanceof Date)return"date";if(K instanceof RegExp)return"regexp"}return ne}function ae(K){var ne=re(K);switch(ne){case"array":case"object":return"an "+ne;case"boolean":case"date":case"regexp":return"a "+ne;default:return ne}}function ee(K){return!K.constructor||!K.constructor.name?S:K.constructor.name}return g.checkPropTypes=f,g.PropTypes=g,g}},function(e,n){function t(o){return function(){return o}}var a=function(){};a.thatReturns=t,a.thatReturnsFalse=t(!1),a.thatReturnsTrue=t(!0),a.thatReturnsNull=t(null),a.thatReturnsThis=function(){return this},a.thatReturnsArgument=function(o){return o},e.exports=a},function(e,n){var t=function(d){};process.env.NODE_ENV!=="production"&&(t=function(d){if(d===void 0)throw new Error("invariant requires an error message argument")});function a(o,d,h,f,u,p,_,R){if(t(d),!o){var x;if(d===void 0)x=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var S=[h,f,u,p,_,R],g=0;x=new Error(d.replace(/%s/g,function(){return S[g++]})),x.name="Invariant Violation"}throw x.framesToPop=1,x}}e.exports=a},function(e,n,t){var a=t(4),o=a;process.env.NODE_ENV!=="production"&&function(){var d=function(f){for(var u=arguments.length,p=Array(u>1?u-1:0),_=1;_<u;_++)p[_-1]=arguments[_];var R=0,x="Warning: "+f.replace(/%s/g,function(){return p[R++]});typeof console<"u"&&console.error(x);try{throw new Error(x)}catch{}};o=function(f,u){if(u===void 0)throw new Error("`warning(condition, format, ...args)` requires a warning message argument");if(u.indexOf("Failed Composite propType: ")!==0&&!f){for(var p=arguments.length,_=Array(p>2?p-2:0),R=2;R<p;R++)_[R-2]=arguments[R];d.apply(void 0,[u].concat(_))}}}(),e.exports=o},function(e,n){var t="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";e.exports=t},function(e,n,t){if(process.env.NODE_ENV!=="production")var a=t(5),o=t(6),d=t(7),h={};function f(u,p,_,R,x){if(process.env.NODE_ENV!=="production"){for(var S in u)if(u.hasOwnProperty(S)){var g;try{a(typeof u[S]=="function","%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.",R||"React class",_,S),g=u[S](p,S,R,_,null,d)}catch(b){g=b}if(o(!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).",R||"React class",_,S,typeof g),g instanceof Error&&!(g.message in h)){h[g.message]=!0;var v=x?x():"";o(!1,"Failed %s type: %s%s",_,g.message,v??"")}}}}e.exports=f},function(e,n,t){var a=t(4),o=t(5),d=t(7);e.exports=function(){function h(p,_,R,x,S,g){g!==d&&o(!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")}h.isRequired=h;function f(){return h}var u={array:h,bool:h,func:h,number:h,object:h,string:h,symbol:h,any:h,arrayOf:f,element:h,instanceOf:f,node:h,objectOf:f,oneOf:f,oneOfType:f,shape:f};return u.checkPropTypes=a,u.PropTypes=u,u}},function(e,n,t){Object.defineProperty(n,"__esModule",{value:!0});var a=function(){function S(g,v){for(var b=0;b<v.length;b++){var T=v[b];T.enumerable=T.enumerable||!1,T.configurable=!0,"value"in T&&(T.writable=!0),Object.defineProperty(g,T.key,T)}}return function(g,v,b){return v&&S(g.prototype,v),b&&S(g,b),g}}(),o=t(1),d=u(o),h=t(2),f=u(h);t(11);function u(S){return S&&S.__esModule?S:{default:S}}function p(S,g){if(!(S instanceof g))throw new TypeError("Cannot call a class as a function")}function _(S,g){if(!S)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return g&&(typeof g=="object"||typeof g=="function")?g:S}function R(S,g){if(typeof g!="function"&&g!==null)throw new TypeError("Super expression must either be null or a function, not "+typeof g);S.prototype=Object.create(g&&g.prototype,{constructor:{value:S,enumerable:!1,writable:!0,configurable:!0}}),g&&(Object.setPrototypeOf?Object.setPrototypeOf(S,g):S.__proto__=g)}var x=function(S){R(g,S);function g(v){p(this,g);var b=_(this,(g.__proto__||Object.getPrototypeOf(g)).call(this,v));return b._isReRenderingCursor=!1,b.state={shouldRender:b.props.show},b}return a(g,[{key:"componentWillReceiveProps",value:function(b){var T=this,y=!this.props.isDone&&b.isDone&&this.props.hideWhenDone;y&&setTimeout(function(){return T.setState({shouldRender:!1})},this.props.hideWhenDoneDelay)}},{key:"componentDidUpdate",value:function(){var b=this.props,T=b.show,y=b.isDone;T&&(y||this._isReRenderingCursor||this._reRenderCursor())}},{key:"_reRenderCursor",value:function(){var b=this;this._isReRenderingCursor=!0,this.setState({shouldRender:!1},function(){b.setState({shouldRender:!0},function(){b._isReRenderingCursor=!1})})}},{key:"render",value:function(){if(this.state.shouldRender){var b=this.props.blink?" Cursor--blinking":"";return d.default.createElement("span",{className:"Cursor"+b},this.props.element)}return null}}]),g}(o.Component);x.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},x.defaultProps={blink:!0,show:!0,element:"|",hideWhenDone:!1,hideWhenDoneDelay:1e3,isDone:!1},n.default=x},function(e,n){},function(e,n,t){Object.defineProperty(n,"__esModule",{value:!0});var a=t(1),o=f(a),d=t(2),h=f(d);function f(p){return p&&p.__esModule?p:{default:p}}var u=function(){return o.default.createElement("noscript",null)};u.componentName="Backspace",u.propTypes={count:h.default.number,delay:h.default.number},u.defaultProps={count:1,delay:0},n.default=u},function(e,n,t){Object.defineProperty(n,"__esModule",{value:!0});var a=t(1),o=f(a),d=t(2),h=f(d);function f(p){return p&&p.__esModule?p:{default:p}}var u=function(){return o.default.createElement("noscript",null)};u.componentName="Delay",u.propTypes={ms:h.default.number.isRequired},n.default=u},function(e,n,t){Object.defineProperty(n,"__esModule",{value:!0}),n.sleep=void 0;var a=function(){function T(y,w){var C=[],N=!0,D=!1,P=void 0;try{for(var k=y[Symbol.iterator](),F;!(N=(F=k.next()).done)&&(C.push(F.value),!(w&&C.length===w));N=!0);}catch(M){D=!0,P=M}finally{try{!N&&k.return&&k.return()}finally{if(D)throw P}}return C}return function(y,w){if(Array.isArray(y))return y;if(Symbol.iterator in Object(y))return T(y,w);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();n.gaussianRnd=u,n.eachPromise=p,n.exclude=_,n.isBackspaceElement=R,n.isDelayElement=x,n.extractTextFromElement=S,n.cloneElement=g,n.cloneElementWithSpecifiedText=b;var o=t(1),d=h(o);function h(T){return T&&T.__esModule?T:{default:T}}function f(T){if(Array.isArray(T)){for(var y=0,w=Array(T.length);y<T.length;y++)w[y]=T[y];return w}else return Array.from(T)}n.sleep=function(y){return new Promise(function(w){return y!=null?setTimeout(w,y):w()})};function u(T,y){for(var w=12,C=0,N=0;N<w;N++)C+=Math.random();return C-=w/2,Math.round(C*y)+T}function p(T,y){for(var w=arguments.length,C=Array(w>2?w-2:0),N=2;N<w;N++)C[N-2]=arguments[N];var D=function(k,F,M){return k.then(function(){return y.apply(void 0,[F,M].concat(C))})};return Array.from(T).reduce(D,Promise.resolve())}function _(T,y){var w={};for(var C in T)y.indexOf(C)===-1&&(w[C]=T[C]);return w}function R(T){return T&&T.type&&T.type.componentName==="Backspace"}function x(T){return T&&T.type&&T.type.componentName==="Delay"}function S(T){for(var y=T?[T]:[],w=[];y.length>0;){var C=y.pop();if(d.default.isValidElement(C))R(C)||x(C)?w.unshift(C):d.default.Children.forEach(C.props.children,function(j){y.push(j)});else if(Array.isArray(C)){var N=!0,D=!1,P=void 0;try{for(var k=C[Symbol.iterator](),F;!(N=(F=k.next()).done);N=!0){var M=F.value;y.push(M)}}catch(j){D=!0,P=j}finally{try{!N&&k.return&&k.return()}finally{if(D)throw P}}}else w.unshift(C)}return w}function g(T,y){var w=T.type,C=_(T.props,["children"]),N=new Date().getUTCMilliseconds(),D=N+Math.random()+Math.random();return C.key="Typist-element-"+w+"-"+D,d.default.createElement.apply(d.default,[w,C].concat(f(y)))}function v(T,y,w){if(w>=y.length)return[null,w];var C=w,N=function(M){var j=v(M,y,C),$=a(j,2),B=$[0],X=$[1];return C=X,B},D=d.default.isValidElement(T)&&!(R(T)||x(T));if(D){var P=d.default.Children.map(T.props.children,N)||[];return[g(T,P),C]}if(Array.isArray(T)){var k=T.map(N);return[k,C]}return[y[C],C+1]}function b(T){var y=T.element,w=T.textLines;if(y)return v(y,w,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:l,type:e}){const n=languages[e];if(n){const t=n.reduce((d,h)=>(d.length?d.length:d)+h.length),a=Math.floor(l*100/t),o=a===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(l*100/t)}%`},children:jsxRuntimeExports.jsxs("span",{className:o,children:[a,"%"]})})})}return null}function Code({codeContainer:l}){const e=l,n=e.split("<br>");return n.length>0?n.map((t,a)=>{const o=t.replace(/ /g," ");return jsxRuntimeExports.jsx("p",{children:o},`line_${0+a}`)}):jsxRuntimeExports.jsx("p",{children:e})}function HackerPuzzleComponent({emitEvent:l,getEvent:e,soundActions:n,info:t,themeNumber:a,type:o,writingSpeed:d,disableExit:h,setResolveAction:f}){const u=X=>e({type:"translate",payload:X}),[p]=n,{solution:_}=t,x=themes[`theme${a||1}`],[S,g]=React$2.useState(""),[v,b]=React$2.useState(0),[T,y]=React$2.useState(0),[w,C]=React$2.useState(!1),[N,D]=React$2.useState({start:0,end:0}),P=React$2.useRef(),k=React$2.useRef(),F=u("puzzle.hacker.congratulations"),M=(X,re)=>X>re.length?re.length:X,j=()=>{p("click-ui");const{rewards:X}=_.right;l({type:"addPoints",complex:!0,finish:!0,payload:X}),l({type:"passPuzzle"})};React$2.useEffect(()=>{P.current.focus(),w&&h(!0)},[w]),React$2.useEffect(()=>{f(X=>{p("score"),C(!0),l({type:"hidePuzzleButtons",payload:!1}),X()})},[f]);const $=()=>{if(languages[o]&&!w){k.current&&(k.current.scrollTop=P.current.scrollHeight);const X=languages[o],re=X[v],ae=X.reduce((K,ne)=>(K.length?K.length:K)+ne.length),ee=d>0?d:Math.floor(ae/50)+v;if(re){const K=re.split(""),ne=M(N.end,K),ue=K.slice(N.start,ne),me=S+ue.join("");y(T+ue.join("").length),g(me),ne===K.length?v+1>=X.length?(p("score"),C(!0)):(b(v+1),g(`${S+ue.join("")}<br>`),D({start:0,end:M(ee,K)})):D({start:ne,end:M(ne+ee,K)})}}},B=X=>{X.preventDefault(),$()};return jsxRuntimeExports.jsxs("div",{role:"button",tabIndex:0,"data-testid":"hacker",ref:P,onKeyDown:B,onTouchStart:B,className:`puzzle--hacker__container background-hacker-${x.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-${x.color} typography-hacker-${x.typo}`,children:[jsxRuntimeExports.jsxs("div",{className:"puzzle--hacker__code",ref:k,children:[jsxRuntimeExports.jsx(Code,{codeContainer:S}),w?jsxRuntimeExports.jsxs(Typist,{avgTypingDelay:110,onCharacterTyped:()=>{k.current&&(k.current.scrollTop=P.current.scrollHeight)},cursor:{hideWhenDone:!0},className:"puzzle--hacker__result",children:[jsxRuntimeExports.jsx(Typist.Delay,{ms:300}),_.right.desc?`// ${_.right.desc}`:`${F}`]}):null]}),jsxRuntimeExports.jsx(ProgressBar,{type:o,progress:T})]}),w?jsxRuntimeExports.jsx("div",{className:"position--absolute bottom center",children:jsxRuntimeExports.jsx("button",{type:"button",className:"gat--btn gat--btn__primary gat--btn__cracker",onClick:j,children:u("screens.continue")})}):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:l,soundActions:e,getEvent:n,info:t,user:a,login:o,password:d,image:h,setResolveAction:f,nodeId:u}){var ne;const p=ue=>n({type:"translate",payload:ue}),_=`login-puzzle_${u}`,R=LangIsRtl(),[x,S]=React$2.useState(""),[g,v]=React$2.useState(""),[b,T]=React$2.useState(!1),[y,w]=React$2.useState(""),[C,N]=React$2.useState(""),[D,P]=React$2.useState(!1),[k,F]=React$2.useState(!1),[M,j]=React$2.useState(!1),[$]=e,[B,X]=React$2.useState([]),re=((ne=h.img)==null?void 0:ne.url)||imagenPorDefecto,ae=()=>{const{rewards:ue}=t.solution.right,me=[...B,...ue];l({type:"addPoints",complex:!0,finish:!0,payload:me}),l({type:"passPuzzle"})},ee=()=>{$("click-ui");const ue={login:!0,password:!1};o&&(ue.login=a===x),ue.password=d===g,ue.login&&ue.password?(N("success"),P(!0),F(!1),$("score"),setTimeout(()=>{ae()},2e3)):(X([...B,...t.solution.wrong.rewards]),$("fail"),N("failed"),F(!0),l({type:"failPuzzle"}))},K=ue=>{let me="";if(ue.length>=0){for(let J=0;J<ue.length;J+=1)me+="•";w(me)}};return React$2.useEffect(()=>{f(()=>{const ue=[...B,...t.resolve.rewards];j(!0),setTimeout(()=>{l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:_,rewards:ue,finish:!0}})},2e3)})},[B,t.resolve.rewards,l,f,_]),jsxRuntimeExports.jsx("div",{className:"puzzle--layer",style:{backgroundImage:`url("${re}")`},children:jsxRuntimeExports.jsxs("div",{className:`puzzle--login ${a?"puzzle--login--withuser":""}`,children:[jsxRuntimeExports.jsx("span",{className:"icon-login-puzzle",children:" "}),jsxRuntimeExports.jsx("span",{className:"puzzle--login__title",children:p("puzzle.initSession")}),jsxRuntimeExports.jsxs("div",{children:[o&&jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx("div",{dir:"auto",className:"puzzle--login__label",children:p("puzzle.user")}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:"puzzle--login__group",children:[M?jsxRuntimeExports.jsx("input",{dir:R?"rtl":"auto",disabled:D,"data-testid":"username",className:"puzzle--login__input success",type:"text",placeholder:a,value:a}):jsxRuntimeExports.jsx("input",{dir:R?"rtl":"auto",disabled:D,"data-testid":"username",className:`puzzle--login__input ${C}`,type:"text",placeholder:p("puzzle.user"),onChange:ue=>{S(ue.target.value),N(""),F(!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:p("puzzle.password")})}),jsxRuntimeExports.jsxs("div",{dir:"auto",className:"puzzle--login__group",children:[M?jsxRuntimeExports.jsx("input",{dir:R?"rtl":"auto",disabled:!0,"data-testid":"password",className:"puzzle--login__input puzzle--login__input--fakepassword success",type:"text",placeholder:d,value:d,style:{opacity:1}}):jsxRuntimeExports.jsx("input",{dir:R?"rtl":"auto",disabled:D,"data-testid":"password",className:`puzzle--login__input puzzle--login__input--fakepassword ${C}`,type:"text",placeholder:p("puzzle.password"),onFocus:()=>{T(!0)},onBlur:()=>{T(!1)},onChange:ue=>{v(ue.target.value),K(ue.target.value),N(""),F(!1)}}),M?null:jsxRuntimeExports.jsx("div",{dir:R?"rtl":"auto",className:`login-fakepassword${b?" login-fakepassword--focus":""}${y.length?" login-fakepassword--fill":""} ${C||""}`,children:g?y:p("puzzle.password")}),jsxRuntimeExports.jsx("span",{className:"icon-circle-check",children:" "})]})]})]}),jsxRuntimeExports.jsx("button",{type:"button",className:`gat--btn gat--btn__primary ${g.length!==0&&!D?"":"disabled"}`,onClick:ee,children:p("puzzle.loginIn")}),!M&&k&&t.solution.wrong.desc!==""&&jsxRuntimeExports.jsx("div",{className:"puzzle--login__label--error",children:t.solution.wrong.desc})]})})}function FeedbackComponent$1({text:l,success:e,playSound:n,additionalStyle:t,functionOnClose:a,secondText:o,translate:d,shortText:h,hasTimeout:f,delay:u,timeExpired:p,keyboardControl:_}){const[R,x]=React$2.useState();React$2.useEffect(()=>{let b;return n&&n(e?"score":"fail"),l&&!h&&(b=setTimeout(()=>{x(!0)},1e3)),()=>{b&&clearTimeout(b)}},[n,e,h,l]),React$2.useEffect(()=>{let b;return f&&a&&(b=setTimeout(a,u)),()=>{b&&clearTimeout(b)}},[u,a,f]);const S=()=>e?"success":"failed",g=()=>e?"icon-correct-thumb":p?"icon-times-up":"icon-incorrect-thumb",v=_({disabled:!(l&&a&&R),repeat:!1,forward:a,close:a});return React$2.useEffect(()=>v(),[v]),jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:jsxRuntimeExports.jsxs("div",{"data-testid":"feedback-layer",className:`feedback-layer ${R?"feedback-layer--withexplain":""}`,children:[jsxRuntimeExports.jsxs("div",{className:`feedback-layer__header ${h?"feedback-layer__header--in-shortText":""} ${t||""} ${S()}`,children:[o&&jsxRuntimeExports.jsxs("span",{className:"puzzle--terminal__visor--file",children:[jsxRuntimeExports.jsx("span",{className:`puzzle--terminal__icon ${t||""}`}),jsxRuntimeExports.jsx("span",{children:o})]}),jsxRuntimeExports.jsx("span",{className:"feedback-layer__maintitle",children:!l||!h?jsxRuntimeExports.jsx("div",{title:d(`tooltip.${e?"correct":"incorrect"}`),className:`${g()}`}):HTMLReactParser$1(l)}),h&&jsxRuntimeExports.jsx("button",{type:"button",className:"feedback-layer__closeX",onClick:()=>a(),"aria-label":d("storylines.misc.closePiece"),children:jsxRuntimeExports.jsx("span",{className:"icon-close"})})]}),!h&&l!==""&&jsxRuntimeExports.jsx("div",{className:"feedback-layer__explainwrap",children:jsxRuntimeExports.jsxs("div",{className:"feedback-layer__explain",children:[jsxRuntimeExports.jsx("div",{dir:"auto",children:HTMLReactParser$1(l)}),l&&a&&R&&jsxRuntimeExports.jsx("button",{type:"button","data-testid":"close-feedback",className:"gat--btn__navigation",onClick:()=>a(),"aria-label":d("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};function KeyboardPuzzleComponent({emitEvent:l,getEvent:e,image:n,password:t,keyboard:a,info:o,disableExit:d,soundActions:h,setResolveAction:f,nodeId:u,keyboardControl:p,styles:_="default-theme"}){var ee,K;const[R,x]=React$2.useState(""),[S,g]=React$2.useState(""),[v,b]=React$2.useState(!1),[T,y]=React$2.useState(""),[w,C]=React$2.useState(!1),[N,D]=React$2.useState([]),P=ne=>e({type:"translate",payload:ne}),k=`keyboard-puzzle_${u}`,[F]=h,M=React$2.useCallback(ne=>{b(!1),C(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"addPoints",complex:!0,finish:!0,payload:ne})},[l]),j=()=>{if(v){const{rewards:ne}=o.solution.right,ue=[...N,...ne];F("score"),M(ue)}else l({type:"hidePuzzleButtons",payload:!1}),b(!1),d(!1),C(!1);y("")},$=ne=>{ne===t?(d(!1),x("success"),F("score"),l({type:"passPuzzle"}),b(!0),C(!0),o.solution.right.desc?y(o.solution.right.desc):setTimeout(()=>{const{rewards:ue}=o.solution.right,me=[...N,...ue];M(me)},3e3)):(C(!0),x("failed"),F("fail"),l({type:"failPuzzle"}),b(!1),D([...N,...o.solution.wrong.rewards]),l({type:"hidePuzzleButtons",payload:!1}),x(""),g(""),C(!0),o.solution.wrong.desc?y(o.solution.wrong.desc):setTimeout(()=>{j()},3e3))};React$2.useEffect(()=>{f(()=>{d(!1),F("score"),x("success"),b(!0),y(o.solution.right.desc),g(t);const ne=[...N,...o.resolve.rewards];setTimeout(()=>{b(!1),C(!1),l({type:"hidePuzzleButtons",payload:!1}),l({type:"puzzleAction",action:"resolve",payload:{element:k,rewards:ne,finish:!0}})},2e3)})},[f,d,o.solution.right.desc,F,o.resolve.rewards,N,t,l,k]);const B=(ne,ue)=>{const me=a[ne][ue];F("click-ui"),S.length<t.length+1&&(g(S+me),S.length+1===t.length&&$(S+me))},X=()=>{F("click-ui"),g(S.substring(0,S.length-1))},ae={backgroundImage:`url("${((ee=n.img)==null?void 0:ee.url)||""}")`,backgroudPosition:"center center"};return jsxRuntimeExports.jsxs("div",{className:`puzzle-keyboard puzzle-keyboard--${_}`,style:(K=n.img)!=null&&K.url?ae:null,children:[jsxRuntimeExports.jsx("div",{className:"puzzle-keyboard__header",children:jsxRuntimeExports.jsxs("div",{className:"puzzle-keyboard__digits",children:[t.split("").map((ne,ue)=>jsxRuntimeExports.jsx("div",{className:`puzzle-keyboard__digit ${R}`,children:S.split("")[ue]?S.split("")[ue]:""},`${ne+ue}`)),R!==""?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:R==="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:X,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:[_==="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--${_}`,children:a.map((ne,ue)=>(Array.isArray(ne)?ne:Object.values(ne)).map((me,J)=>jsxRuntimeExports.jsx("button",{className:`keyboard-key keyboard-key--${_} ${me==="*"?"keyboard-key--star":""}`,type:"button",onClick:()=>B(ue,J),children:jsxRuntimeExports.jsx("div",{children:me})},me)))}),_==="scifi-theme"&&jsxRuntimeExports.jsx("hr",{"aria-hidden":!0,className:"puzzle-keyboard__scifi-line"})]}),w&&jsxRuntimeExports.jsx(FeedbackComponent$1,{translate:P,text:T,success:v,functionOnClose:j,keyboardControl:p})]})}var lib$1={exports:{}},_FullInternals={},_CoreInternals={},Global={};(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l._registerNode=l.Konva=l.glob=void 0;const e=Math.PI/180;function n(){return typeof window<"u"&&({}.toString.call(window)==="[object Window]"||{}.toString.call(window)==="[object global]")}l.glob=typeof commonjsGlobal<"u"?commonjsGlobal:typeof window<"u"?window:typeof WorkerGlobalScope<"u"?self:{},l.Konva={_global:l.glob,version:"9.3.0",isBrowser:n(),isUnminified:/param/.test((function(a){}).toString()),dblClickWindow:400,getAngle(a){return l.Konva.angleDeg?a*e:a},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 l.Konva.DD.isDragging},isDragReady(){return!!l.Konva.DD.node},releaseCanvasOnDestroy:!0,document:l.glob.document,_injectGlobal(a){l.glob.Konva=a}};const t=a=>{l.Konva[a.prototype.getClassName()]=a};l._registerNode=t,l.Konva._injectGlobal(l.Konva)})(Global);var Util={};(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Util=l.Transform=void 0;const e=Global;class n{constructor(w=[1,0,0,1,0,0]){this.dirty=!1,this.m=w&&w.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 n(this.m)}copyInto(w){w.m[0]=this.m[0],w.m[1]=this.m[1],w.m[2]=this.m[2],w.m[3]=this.m[3],w.m[4]=this.m[4],w.m[5]=this.m[5]}point(w){var C=this.m;return{x:C[0]*w.x+C[2]*w.y+C[4],y:C[1]*w.x+C[3]*w.y+C[5]}}translate(w,C){return this.m[4]+=this.m[0]*w+this.m[2]*C,this.m[5]+=this.m[1]*w+this.m[3]*C,this}scale(w,C){return this.m[0]*=w,this.m[1]*=w,this.m[2]*=C,this.m[3]*=C,this}rotate(w){var C=Math.cos(w),N=Math.sin(w),D=this.m[0]*C+this.m[2]*N,P=this.m[1]*C+this.m[3]*N,k=this.m[0]*-N+this.m[2]*C,F=this.m[1]*-N+this.m[3]*C;return this.m[0]=D,this.m[1]=P,this.m[2]=k,this.m[3]=F,this}getTranslation(){return{x:this.m[4],y:this.m[5]}}skew(w,C){var N=this.m[0]+this.m[2]*C,D=this.m[1]+this.m[3]*C,P=this.m[2]+this.m[0]*w,k=this.m[3]+this.m[1]*w;return this.m[0]=N,this.m[1]=D,this.m[2]=P,this.m[3]=k,this}multiply(w){var C=this.m[0]*w.m[0]+this.m[2]*w.m[1],N=this.m[1]*w.m[0]+this.m[3]*w.m[1],D=this.m[0]*w.m[2]+this.m[2]*w.m[3],P=this.m[1]*w.m[2]+this.m[3]*w.m[3],k=this.m[0]*w.m[4]+this.m[2]*w.m[5]+this.m[4],F=this.m[1]*w.m[4]+this.m[3]*w.m[5]+this.m[5];return this.m[0]=C,this.m[1]=N,this.m[2]=D,this.m[3]=P,this.m[4]=k,this.m[5]=F,this}invert(){var w=1/(this.m[0]*this.m[3]-this.m[1]*this.m[2]),C=this.m[3]*w,N=-this.m[1]*w,D=-this.m[2]*w,P=this.m[0]*w,k=w*(this.m[2]*this.m[5]-this.m[3]*this.m[4]),F=w*(this.m[1]*this.m[4]-this.m[0]*this.m[5]);return this.m[0]=C,this.m[1]=N,this.m[2]=D,this.m[3]=P,this.m[4]=k,this.m[5]=F,this}getMatrix(){return this.m}decompose(){var w=this.m[0],C=this.m[1],N=this.m[2],D=this.m[3],P=this.m[4],k=this.m[5],F=w*D-C*N;let M={x:P,y:k,rotation:0,scaleX:0,scaleY:0,skewX:0,skewY:0};if(w!=0||C!=0){var j=Math.sqrt(w*w+C*C);M.rotation=C>0?Math.acos(w/j):-Math.acos(w/j),M.scaleX=j,M.scaleY=F/j,M.skewX=(w*N+C*D)/F,M.skewY=0}else if(N!=0||D!=0){var $=Math.sqrt(N*N+D*D);M.rotation=Math.PI/2-(D>0?Math.acos(-N/$):-Math.acos(N/$)),M.scaleX=F/$,M.scaleY=$,M.skewX=0,M.skewY=(w*N+C*D)/F}return M.rotation=l.Util._getRotation(M.rotation),M}}l.Transform=n;var t="[object Array]",a="[object Number]",o="[object String]",d="[object Boolean]",h=Math.PI/180,f=180/Math.PI,u="#",p="",_="0",R="Konva warning: ",x="Konva error: ",S="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]},v=/rgb\((\d{1,3}),(\d{1,3}),(\d{1,3})\)/,b=[];const T=typeof requestAnimationFrame<"u"&&requestAnimationFrame||function(y){setTimeout(y,60)};l.Util={_isElement(y){return!!(y&&y.nodeType==1)},_isFunction(y){return!!(y&&y.constructor&&y.call&&y.apply)},_isPlainObject(y){return!!y&&y.constructor===Object},_isArray(y){return Object.prototype.toString.call(y)===t},_isNumber(y){return Object.prototype.toString.call(y)===a&&!isNaN(y)&&isFinite(y)},_isString(y){return Object.prototype.toString.call(y)===o},_isBoolean(y){return Object.prototype.toString.call(y)===d},isObject(y){return y instanceof Object},isValidSelector(y){if(typeof y!="string")return!1;var w=y[0];return w==="#"||w==="."||w===w.toUpperCase()},_sign(y){return y===0||y>0?1:-1},requestAnimFrame(y){b.push(y),b.length===1&&T(function(){const w=b;b=[],w.forEach(function(C){C()})})},createCanvasElement(){var y=document.createElement("canvas");try{y.style=y.style||{}}catch{}return y},createImageElement(){return document.createElement("img")},_isInDocument(y){for(;y=y.parentNode;)if(y==document)return!0;return!1},_urlToImage(y,w){var C=l.Util.createImageElement();C.onload=function(){w(C)},C.src=y},_rgbToHex(y,w,C){return((1<<24)+(y<<16)+(w<<8)+C).toString(16).slice(1)},_hexToRgb(y){y=y.replace(u,p);var w=parseInt(y,16);return{r:w>>16&255,g:w>>8&255,b:w&255}},getRandomColor(){for(var y=(Math.random()*16777215<<0).toString(16);y.length<6;)y=_+y;return u+y},getRGB(y){var w;return y in g?(w=g[y],{r:w[0],g:w[1],b:w[2]}):y[0]===u?this._hexToRgb(y.substring(1)):y.substr(0,4)===S?(w=v.exec(y.replace(/ /g,"")),{r:parseInt(w[1],10),g:parseInt(w[2],10),b:parseInt(w[3],10)}):{r:0,g:0,b:0}},colorToRGBA(y){return y=y||"black",l.Util._namedColorToRBA(y)||l.Util._hex3ColorToRGBA(y)||l.Util._hex4ColorToRGBA(y)||l.Util._hex6ColorToRGBA(y)||l.Util._hex8ColorToRGBA(y)||l.Util._rgbColorToRGBA(y)||l.Util._rgbaColorToRGBA(y)||l.Util._hslColorToRGBA(y)},_namedColorToRBA(y){var w=g[y.toLowerCase()];return w?{r:w[0],g:w[1],b:w[2],a:1}:null},_rgbColorToRGBA(y){if(y.indexOf("rgb(")===0){y=y.match(/rgb\(([^)]+)\)/)[1];var w=y.split(/ *, */).map(Number);return{r:w[0],g:w[1],b:w[2],a:1}}},_rgbaColorToRGBA(y){if(y.indexOf("rgba(")===0){y=y.match(/rgba\(([^)]+)\)/)[1];var w=y.split(/ *, */).map((C,N)=>C.slice(-1)==="%"?N===3?parseInt(C)/100:parseInt(C)/100*255:Number(C));return{r:w[0],g:w[1],b:w[2],a:w[3]}}},_hex8ColorToRGBA(y){if(y[0]==="#"&&y.length===9)return{r:parseInt(y.slice(1,3),16),g:parseInt(y.slice(3,5),16),b:parseInt(y.slice(5,7),16),a:parseInt(y.slice(7,9),16)/255}},_hex6ColorToRGBA(y){if(y[0]==="#"&&y.length===7)return{r:parseInt(y.slice(1,3),16),g:parseInt(y.slice(3,5),16),b:parseInt(y.slice(5,7),16),a:1}},_hex4ColorToRGBA(y){if(y[0]==="#"&&y.length===5)return{r:parseInt(y[1]+y[1],16),g:parseInt(y[2]+y[2],16),b:parseInt(y[3]+y[3],16),a:parseInt(y[4]+y[4],16)/255}},_hex3ColorToRGBA(y){if(y[0]==="#"&&y.length===4)return{r:parseInt(y[1]+y[1],16),g:parseInt(y[2]+y[2],16),b:parseInt(y[3]+y[3],16),a:1}},_hslColorToRGBA(y){if(/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.test(y)){const[w,...C]=/hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(y),N=Number(C[0])/360,D=Number(C[1])/100,P=Number(C[2])/100;let k,F,M;if(D===0)return M=P*255,{r:Math.round(M),g:Math.round(M),b:Math.round(M),a:1};P<.5?k=P*(1+D):k=P+D-P*D;const j=2*P-k,$=[0,0,0];for(let B=0;B<3;B++)F=N+1/3*-(B-1),F<0&&F++,F>1&&F--,6*F<1?M=j+(k-j)*6*F:2*F<1?M=k:3*F<2?M=j+(k-j)*(2/3-F)*6:M=j,$[B]=M*255;return{r:Math.round($[0]),g:Math.round($[1]),b:Math.round($[2]),a:1}}},haveIntersection(y,w){return!(w.x>y.x+y.width||w.x+w.width<y.x||w.y>y.y+y.height||w.y+w.height<y.y)},cloneObject(y){var w={};for(var C in y)this._isPlainObject(y[C])?w[C]=this.cloneObject(y[C]):this._isArray(y[C])?w[C]=this.cloneArray(y[C]):w[C]=y[C];return w},cloneArray(y){return y.slice(0)},degToRad(y){return y*h},radToDeg(y){return y*f},_degToRad(y){return l.Util.warn("Util._degToRad is removed. Please use public Util.degToRad instead."),l.Util.degToRad(y)},_radToDeg(y){return l.Util.warn("Util._radToDeg is removed. Please use public Util.radToDeg instead."),l.Util.radToDeg(y)},_getRotation(y){return e.Konva.angleDeg?l.Util.radToDeg(y):y},_capitalize(y){return y.charAt(0).toUpperCase()+y.slice(1)},throw(y){throw new Error(x+y)},error(y){console.error(x+y)},warn(y){e.Konva.showWarnings&&console.warn(R+y)},each(y,w){for(var C in y)w(C,y[C])},_inRange(y,w,C){return w<=y&&y<C},_getProjectionToSegment(y,w,C,N,D,P){var k,F,M,j=(y-C)*(y-C)+(w-N)*(w-N);if(j==0)k=y,F=w,M=(D-C)*(D-C)+(P-N)*(P-N);else{var $=((D-y)*(C-y)+(P-w)*(N-w))/j;$<0?(k=y,F=w,M=(y-D)*(y-D)+(w-P)*(w-P)):$>1?(k=C,F=N,M=(C-D)*(C-D)+(N-P)*(N-P)):(k=y+$*(C-y),F=w+$*(N-w),M=(k-D)*(k-D)+(F-P)*(F-P))}return[k,F,M]},_getProjectionToLine(y,w,C){var N=l.Util.cloneObject(y),D=Number.MAX_VALUE;return w.forEach(function(P,k){if(!(!C&&k===w.length-1)){var F=w[(k+1)%w.length],M=l.Util._getProjectionToSegment(P.x,P.y,F.x,F.y,y.x,y.y),j=M[0],$=M[1],B=M[2];B<D&&(N.x=j,N.y=$,D=B)}}),N},_prepareArrayForTween(y,w,C){var N,D=[],P=[];if(y.length>w.length){var k=w;w=y,y=k}for(N=0;N<y.length;N+=2)D.push({x:y[N],y:y[N+1]});for(N=0;N<w.length;N+=2)P.push({x:w[N],y:w[N+1]});var F=[];return P.forEach(function(M){var j=l.Util._getProjectionToLine(M,D,C);F.push(j.x),F.push(j.y)}),F},_prepareToStringify(y){var w;y.visitedByCircularReferenceRemoval=!0;for(var C in y)if(y.hasOwnProperty(C)&&y[C]&&typeof y[C]=="object"){if(w=Object.getOwnPropertyDescriptor(y,C),y[C].visitedByCircularReferenceRemoval||l.Util._isElement(y[C]))if(w.configurable)delete y[C];else return null;else if(l.Util._prepareToStringify(y[C])===null)if(w.configurable)delete y[C];else return null}return delete y.visitedByCircularReferenceRemoval,y},_assign(y,w){for(var C in w)y[C]=w[C];return y},_getFirstPointerId(y){return y.touches?y.changedTouches[0].identifier:y.pointerId||999},releaseCanvas(...y){e.Konva.releaseCanvasOnDestroy&&y.forEach(w=>{w.width=0,w.height=0})},drawRoundedRectPath(y,w,C,N){let D=0,P=0,k=0,F=0;typeof N=="number"?D=P=k=F=Math.min(N,w/2,C/2):(D=Math.min(N[0]||0,w/2,C/2),P=Math.min(N[1]||0,w/2,C/2),F=Math.min(N[2]||0,w/2,C/2),k=Math.min(N[3]||0,w/2,C/2)),y.moveTo(D,0),y.lineTo(w-P,0),y.arc(w-P,P,P,Math.PI*3/2,0,!1),y.lineTo(w,C-F),y.arc(w-F,C-F,F,0,Math.PI/2,!1),y.lineTo(k,C),y.arc(k,C-k,k,Math.PI/2,Math.PI,!1),y.lineTo(0,D),y.arc(D,D,D,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(l){return Util_1$f.Util._isString(l)?'"'+l+'"':Object.prototype.toString.call(l)==="[object Number]"||Util_1$f.Util._isBoolean(l)?l:Object.prototype.toString.call(l)}function RGBComponent(l){return l>255?255:l<0?0:Math.round(l)}Validators.RGBComponent=RGBComponent;function alphaComponent(l){return l>1?1:l<1e-4?1e-4:l}Validators.alphaComponent=alphaComponent;function getNumberValidator(){if(Global_1$p.Konva.isUnminified)return function(l,e){return Util_1$f.Util._isNumber(l)||Util_1$f.Util.warn(_formatValue(l)+' is a not valid value for "'+e+'" attribute. The value should be a number.'),l}}Validators.getNumberValidator=getNumberValidator;function getNumberOrArrayOfNumbersValidator(l){if(Global_1$p.Konva.isUnminified)return function(e,n){let t=Util_1$f.Util._isNumber(e),a=Util_1$f.Util._isArray(e)&&e.length==l;return!t&&!a&&Util_1$f.Util.warn(_formatValue(e)+' is a not valid value for "'+n+'" attribute. The value should be a number or Array<number>('+l+")"),e}}Validators.getNumberOrArrayOfNumbersValidator=getNumberOrArrayOfNumbersValidator;function getNumberOrAutoValidator(){if(Global_1$p.Konva.isUnminified)return function(l,e){var n=Util_1$f.Util._isNumber(l),t=l==="auto";return n||t||Util_1$f.Util.warn(_formatValue(l)+' is a not valid value for "'+e+'" attribute. The value should be a number or "auto".'),l}}Validators.getNumberOrAutoValidator=getNumberOrAutoValidator;function getStringValidator(){if(Global_1$p.Konva.isUnminified)return function(l,e){return Util_1$f.Util._isString(l)||Util_1$f.Util.warn(_formatValue(l)+' is a not valid value for "'+e+'" attribute. The value should be a string.'),l}}Validators.getStringValidator=getStringValidator;function getStringOrGradientValidator(){if(Global_1$p.Konva.isUnminified)return function(l,e){const n=Util_1$f.Util._isString(l),t=Object.prototype.toString.call(l)==="[object CanvasGradient]"||l&&l.addColorStop;return n||t||Util_1$f.Util.warn(_formatValue(l)+' is a not valid value for "'+e+'" attribute. The value should be a string or a native gradient.'),l}}Validators.getStringOrGradientValidator=getStringOrGradientValidator;function getFunctionValidator(){if(Global_1$p.Konva.isUnminified)return function(l,e){return Util_1$f.Util._isFunction(l)||Util_1$f.Util.warn(_formatValue(l)+' is a not valid value for "'+e+'" attribute. The value should be a function.'),l}}Validators.getFunctionValidator=getFunctionValidator;function getNumberArrayValidator(){if(Global_1$p.Konva.isUnminified)return function(l,e){const n=Int8Array?Object.getPrototypeOf(Int8Array):null;return n&&l instanceof n||(Util_1$f.Util._isArray(l)?l.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(l)+' is a not valid value for "'+e+'" attribute. The value should be a array of numbers.')),l}}Validators.getNumberArrayValidator=getNumberArrayValidator;function getBooleanValidator(){if(Global_1$p.Konva.isUnminified)return function(l,e){var n=l===!0||l===!1;return n||Util_1$f.Util.warn(_formatValue(l)+' is a not valid value for "'+e+'" attribute. The value should be a boolean.'),l}}Validators.getBooleanValidator=getBooleanValidator;function getComponentValidator(l){if(Global_1$p.Konva.isUnminified)return function(e,n){return e==null||Util_1$f.Util.isObject(e)||Util_1$f.Util.warn(_formatValue(e)+' is a not valid value for "'+n+'" attribute. The value should be an object with properties '+l),e}}Validators.getComponentValidator=getComponentValidator;(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Factory=void 0;const e=Util,n=Validators;var t="get",a="set";l.Factory={addGetterSetter(o,d,h,f,u){l.Factory.addGetter(o,d,h),l.Factory.addSetter(o,d,f,u),l.Factory.addOverloadedGetterSetter(o,d)},addGetter(o,d,h){var f=t+e.Util._capitalize(d);o.prototype[f]=o.prototype[f]||function(){var u=this.attrs[d];return u===void 0?h:u}},addSetter(o,d,h,f){var u=a+e.Util._capitalize(d);o.prototype[u]||l.Factory.overWriteSetter(o,d,h,f)},overWriteSetter(o,d,h,f){var u=a+e.Util._capitalize(d);o.prototype[u]=function(p){return h&&p!==void 0&&p!==null&&(p=h.call(this,p,d)),this._setAttr(d,p),f&&f.call(this),this}},addComponentsGetterSetter(o,d,h,f,u){var p=h.length,_=e.Util._capitalize,R=t+_(d),x=a+_(d),S,g;o.prototype[R]=function(){var b={};for(S=0;S<p;S++)g=h[S],b[g]=this.getAttr(d+_(g));return b};var v=(0,n.getComponentValidator)(h);o.prototype[x]=function(b){var T=this.attrs[d],y;f&&(b=f.call(this,b)),v&&v.call(this,b,d);for(y in b)b.hasOwnProperty(y)&&this._setAttr(d+_(y),b[y]);return b||h.forEach(w=>{this._setAttr(d+_(w),void 0)}),this._fireChangeEvent(d,T,b),u&&u.call(this),this},l.Factory.addOverloadedGetterSetter(o,d)},addOverloadedGetterSetter(o,d){var h=e.Util._capitalize(d),f=a+h,u=t+h;o.prototype[d]=function(){return arguments.length?(this[f](arguments[0]),this):this[u]()}},addDeprecatedGetterSetter(o,d,h,f){e.Util.error("Adding deprecated "+d);var u=t+e.Util._capitalize(d),p=d+" property is deprecated and will be removed soon. Look at Konva change log for more information.";o.prototype[u]=function(){e.Util.error(p);var _=this.attrs[d];return _===void 0?h:_},l.Factory.addSetter(o,d,f,function(){e.Util.error(p)}),l.Factory.addOverloadedGetterSetter(o,d)},backCompat(o,d){e.Util.each(d,function(h,f){var u=o.prototype[f],p=t+e.Util._capitalize(h),_=a+e.Util._capitalize(h);function R(){u.apply(this,arguments),e.Util.error('"'+h+'" method is deprecated and will be removed soon. Use ""'+f+'" instead.')}o.prototype[h]=R,o.prototype[p]=R,o.prototype[_]=R})},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(l){var e=[],n=l.length,t=Util_1$e.Util,a,o;for(a=0;a<n;a++)o=l[a],t._isNumber(o)?o=Math.round(o*1e3)/1e3:t._isString(o)||(o=o+""),e.push(o);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,n){var t=this.traceArr,a=t.length,o="",d,h,f,u;for(d=0;d<a;d++)h=t[d],f=h.method,f?(u=h.args,o+=f,e?o+=DOUBLE_PAREN:Util_1$e.Util._isArray(u[0])?o+=OPEN_PAREN_BRACKET+u.join(COMMA)+CLOSE_BRACKET_PAREN:(n&&(u=u.map(p=>typeof p=="number"?Math.floor(p):p)),o+=OPEN_PAREN+u.join(COMMA)+CLOSE_PAREN)):(o+=h.property,e||(o+=EQUALS+h.val)),o+=SEMICOLON;return o}clearTrace(){this.traceArr=[]}_trace(e){var n=this.traceArr,t;n.push(e),t=n.length,t>=traceArrMax&&n.shift()}reset(){var e=this.getCanvas().getPixelRatio();this.setTransform(1*e,0,0,1*e,0,0)}getCanvas(){return this.canvas}clear(e){var n=this.getCanvas();e?this.clearRect(e.x||0,e.y||0,e.width||0,e.height||0):this.clearRect(0,0,n.getWidth()/n.pixelRatio,n.getHeight()/n.pixelRatio)}_applyLineCap(e){const n=e.attrs.lineCap;n&&this.setAttr("lineCap",n)}_applyOpacity(e){var n=e.getAbsoluteOpacity();n!==1&&this.setAttr("globalAlpha",n)}_applyLineJoin(e){const n=e.attrs.lineJoin;n&&this.setAttr("lineJoin",n)}setAttr(e,n){this._context[e]=n}arc(e,n,t,a,o,d){this._context.arc(e,n,t,a,o,d)}arcTo(e,n,t,a,o){this._context.arcTo(e,n,t,a,o)}beginPath(){this._context.beginPath()}bezierCurveTo(e,n,t,a,o,d){this._context.bezierCurveTo(e,n,t,a,o,d)}clearRect(e,n,t,a){this._context.clearRect(e,n,t,a)}clip(...e){this._context.clip.apply(this._context,e)}closePath(){this._context.closePath()}createImageData(e,n){var t=arguments;if(t.length===2)return this._context.createImageData(e,n);if(t.length===1)return this._context.createImageData(e)}createLinearGradient(e,n,t,a){return this._context.createLinearGradient(e,n,t,a)}createPattern(e,n){return this._context.createPattern(e,n)}createRadialGradient(e,n,t,a,o,d){return this._context.createRadialGradient(e,n,t,a,o,d)}drawImage(e,n,t,a,o,d,h,f,u){var p=arguments,_=this._context;p.length===3?_.drawImage(e,n,t):p.length===5?_.drawImage(e,n,t,a,o):p.length===9&&_.drawImage(e,n,t,a,o,d,h,f,u)}ellipse(e,n,t,a,o,d,h,f){this._context.ellipse(e,n,t,a,o,d,h,f)}isPointInPath(e,n,t,a){return t?this._context.isPointInPath(t,e,n,a):this._context.isPointInPath(e,n,a)}fill(...e){this._context.fill.apply(this._context,e)}fillRect(e,n,t,a){this._context.fillRect(e,n,t,a)}strokeRect(e,n,t,a){this._context.strokeRect(e,n,t,a)}fillText(e,n,t,a){a?this._context.fillText(e,n,t,a):this._context.fillText(e,n,t)}measureText(e){return this._context.measureText(e)}getImageData(e,n,t,a){return this._context.getImageData(e,n,t,a)}lineTo(e,n){this._context.lineTo(e,n)}moveTo(e,n){this._context.moveTo(e,n)}rect(e,n,t,a){this._context.rect(e,n,t,a)}putImageData(e,n,t){this._context.putImageData(e,n,t)}quadraticCurveTo(e,n,t,a){this._context.quadraticCurveTo(e,n,t,a)}restore(){this._context.restore()}rotate(e){this._context.rotate(e)}save(){this._context.save()}scale(e,n){this._context.scale(e,n)}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,n,t,a,o,d){this._context.setTransform(e,n,t,a,o,d)}stroke(e){e?this._context.stroke(e):this._context.stroke()}strokeText(e,n,t,a){this._context.strokeText(e,n,t,a)}transform(e,n,t,a,o,d){this._context.transform(e,n,t,a,o,d)}translate(e,n){this._context.translate(e,n)}_enableTrace(){var e=this,n=CONTEXT_METHODS.length,t=this.setAttr,a,o,d=function(h){var f=e[h],u;e[h]=function(){return o=simplifyArray(Array.prototype.slice.call(arguments,0)),u=f.apply(e,arguments),e._trace({method:h,args:o}),u}};for(a=0;a<n;a++)d(CONTEXT_METHODS[a]);e.setAttr=function(){t.apply(e,arguments);var h=arguments[0],f=arguments[1];(h==="shadowOffsetX"||h==="shadowOffsetY"||h==="shadowBlur")&&(f=f/this.canvas.getPixelRatio()),e._trace({property:h,val:f})}}_applyGlobalCompositeOperation(e){const n=e.attrs.globalCompositeOperation;var t=!n||n==="source-over";t||this.setAttr("globalCompositeOperation",n)}};Context$2.Context=Context$1;CONTEXT_PROPERTIES.forEach(function(l){Object.defineProperty(Context$1.prototype,l,{get(){return this._context[l]},set(e){this._context[l]=e}})});class SceneContext extends Context$1{constructor(e,{willReadFrequently:n=!1}={}){super(e),this._context=e._canvas.getContext("2d",{willReadFrequently:n})}_fillColor(e){var n=e.fill();this.setAttr("fillStyle",n),e._fillFunc(this)}_fillPattern(e){this.setAttr("fillStyle",e._getFillPattern()),e._fillFunc(this)}_fillLinearGradient(e){var n=e._getLinearGradient();n&&(this.setAttr("fillStyle",n),e._fillFunc(this))}_fillRadialGradient(e){const n=e._getRadialGradient();n&&(this.setAttr("fillStyle",n),e._fillFunc(this))}_fill(e){const n=e.fill(),t=e.getFillPriority();if(n&&t==="color"){this._fillColor(e);return}const a=e.getFillPatternImage();if(a&&t==="pattern"){this._fillPattern(e);return}const o=e.getFillLinearGradientColorStops();if(o&&t==="linear-gradient"){this._fillLinearGradient(e);return}const d=e.getFillRadialGradientColorStops();if(d&&t==="radial-gradient"){this._fillRadialGradient(e);return}n?this._fillColor(e):a?this._fillPattern(e):o?this._fillLinearGradient(e):d&&this._fillRadialGradient(e)}_strokeLinearGradient(e){const n=e.getStrokeLinearGradientStartPoint(),t=e.getStrokeLinearGradientEndPoint(),a=e.getStrokeLinearGradientColorStops(),o=this.createLinearGradient(n.x,n.y,t.x,t.y);if(a){for(var d=0;d<a.length;d+=2)o.addColorStop(a[d],a[d+1]);this.setAttr("strokeStyle",o)}}_stroke(e){var n=e.dash(),t=e.getStrokeScaleEnabled();if(e.hasStroke()){if(!t){this.save();var a=this.getCanvas().getPixelRatio();this.setTransform(a,0,0,a,0,0)}this._applyLineCap(e),n&&e.dashEnabled()&&(this.setLineDash(n),this.setAttr("lineDashOffset",e.dashOffset())),this.setAttr("lineWidth",e.strokeWidth()),e.getShadowForStrokeEnabled()||this.setAttr("shadowColor","rgba(0,0,0,0)");var o=e.getStrokeLinearGradientColorStops();o?this._strokeLinearGradient(e):this.setAttr("strokeStyle",e.stroke()),e._strokeFunc(this),t||this.restore()}}_applyShadow(e){var n,t,a,o=(n=e.getShadowRGBA())!==null&&n!==void 0?n:"black",d=(t=e.getShadowBlur())!==null&&t!==void 0?t:5,h=(a=e.getShadowOffset())!==null&&a!==void 0?a:{x:0,y:0},f=e.getAbsoluteScale(),u=this.canvas.getPixelRatio(),p=f.x*u,_=f.y*u;this.setAttr("shadowColor",o),this.setAttr("shadowBlur",d*Math.min(Math.abs(p),Math.abs(_))),this.setAttr("shadowOffsetX",h.x*p),this.setAttr("shadowOffsetY",h.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 o=e.getStrokeScaleEnabled();if(!o){this.save();var n=this.getCanvas().getPixelRatio();this.setTransform(n,0,0,n,0,0)}this._applyLineCap(e);var t=e.hitStrokeWidth(),a=t==="auto"?e.strokeWidth():t;this.setAttr("lineWidth",a),this.setAttr("strokeStyle",e.colorKey),e._strokeFuncHit(this),o||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 l=Util_1$d.Util.createCanvasElement(),e=l.getContext("2d");return _pixelRatio=function(){var n=Global_1$n.Konva._global.devicePixelRatio||1,t=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return n/t}(),Util_1$d.Util.releaseCanvas(l),_pixelRatio}class Canvas{constructor(e){this.pixelRatio=1,this.width=0,this.height=0,this.isCache=!1;var n=e||{},t=n.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 n=this.pixelRatio;this.pixelRatio=e,this.setSize(this.getWidth()/n,this.getHeight()/n)}setWidth(e){this.width=this._canvas.width=e*this.pixelRatio,this._canvas.style.width=e+"px";var n=this.pixelRatio,t=this.getContext()._context;t.scale(n,n)}setHeight(e){this.height=this._canvas.height=e*this.pixelRatio,this._canvas.style.height=e+"px";var n=this.pixelRatio,t=this.getContext()._context;t.scale(n,n)}getWidth(){return this.width}getHeight(){return this.height}setSize(e,n){this.setWidth(e||0),this.setHeight(n||0)}toDataURL(e,n){try{return this._canvas.toDataURL(e,n)}catch{try{return this._canvas.toDataURL()}catch(a){return Util_1$d.Util.error("Unable to get data URL. "+a.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(l){Object.defineProperty(l,"__esModule",{value:!0}),l.DD=void 0;const e=Global,n=Util;l.DD={get isDragging(){var t=!1;return l.DD._dragElements.forEach(a=>{a.dragStatus==="dragging"&&(t=!0)}),t},justDragged:!1,get node(){var t;return l.DD._dragElements.forEach(a=>{t=a.node}),t},_dragElements:new Map,_drag(t){const a=[];l.DD._dragElements.forEach((o,d)=>{const{node:h}=o,f=h.getStage();f.setPointersPositions(t),o.pointerId===void 0&&(o.pointerId=n.Util._getFirstPointerId(t));const u=f._changedPointerPositions.find(R=>R.id===o.pointerId);if(u){if(o.dragStatus!=="dragging"){var p=h.dragDistance(),_=Math.max(Math.abs(u.x-o.startPointerPos.x),Math.abs(u.y-o.startPointerPos.y));if(_<p||(h.startDrag({evt:t}),!h.isDragging()))return}h._setDragPosition(t,o),a.push(h)}}),a.forEach(o=>{o.fire("dragmove",{type:"dragmove",target:o,evt:t},!0)})},_endDragBefore(t){const a=[];l.DD._dragElements.forEach(o=>{const{node:d}=o,h=d.getStage();if(t&&h.setPointersPositions(t),!h._changedPointerPositions.find(p=>p.id===o.pointerId))return;(o.dragStatus==="dragging"||o.dragStatus==="stopped")&&(l.DD.justDragged=!0,e.Konva._mouseListenClick=!1,e.Konva._touchListenClick=!1,e.Konva._pointerListenClick=!1,o.dragStatus="stopped");const u=o.node.getLayer()||o.node instanceof e.Konva.Stage&&o.node;u&&a.indexOf(u)===-1&&a.push(u)}),a.forEach(o=>{o.draw()})},_endDragAfter(t){l.DD._dragElements.forEach((a,o)=>{a.dragStatus==="stopped"&&a.node.fire("dragend",{type:"dragend",target:a.node,evt:t},!0),a.dragStatus!=="dragging"&&l.DD._dragElements.delete(o)})}},e.Konva.isBrowser&&(window.addEventListener("mouseup",l.DD._endDragBefore,!0),window.addEventListener("touchend",l.DD._endDragBefore,!0),window.addEventListener("mousemove",l.DD._drag),window.addEventListener("touchmove",l.DD._drag),window.addEventListener("mouseup",l.DD._endDragAfter,!1),window.addEventListener("touchend",l.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,n){var t=this._cache.get(e),a=e===TRANSFORM||e===ABSOLUTE_TRANSFORM,o=t===void 0||a&&t.dirty===!0;return o&&(t=n.call(this),this._cache.set(e,t)),t}_calculate(e,n,t){if(!this._attachedDepsListeners.get(e)){const a=n.map(o=>o+"Change.konva").join(SPACE$1);this.on(a,()=>{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:n,hit:t}=this._cache.get(CANVAS);Util_1$c.Util.releaseCanvas(e,n,t),this._cache.delete(CANVAS)}return this._clearSelfAndDescendantCache(),this._requestDraw(),this}cache(e){var n=e||{},t={};(n.x===void 0||n.y===void 0||n.width===void 0||n.height===void 0)&&(t=this.getClientRect({skipTransform:!0,relativeTo:this.getParent()||void 0}));var a=Math.ceil(n.width||t.width),o=Math.ceil(n.height||t.height),d=n.pixelRatio,h=n.x===void 0?Math.floor(t.x):n.x,f=n.y===void 0?Math.floor(t.y):n.y,u=n.offset||0,p=n.drawBorder||!1,_=n.hitCanvasPixelRatio||1;if(!a||!o){Util_1$c.Util.error("Can not cache the node. Width or height of the node equals 0. Caching is skipped.");return}a+=u*2+1,o+=u*2+1,h-=u,f-=u;var R=new Canvas_1$1.SceneCanvas({pixelRatio:d,width:a,height:o}),x=new Canvas_1$1.SceneCanvas({pixelRatio:d,width:0,height:0,willReadFrequently:!0}),S=new Canvas_1$1.HitCanvas({pixelRatio:_,width:a,height:o}),g=R.getContext(),v=S.getContext();return S.isCache=!0,R.isCache=!0,this._cache.delete(CANVAS),this._filterUpToDate=!1,n.imageSmoothingEnabled===!1&&(R.getContext()._context.imageSmoothingEnabled=!1,x.getContext()._context.imageSmoothingEnabled=!1),g.save(),v.save(),g.translate(-h,-f),v.translate(-h,-f),this._isUnderCache=!0,this._clearSelfAndDescendantCache(ABSOLUTE_OPACITY),this._clearSelfAndDescendantCache(ABSOLUTE_SCALE),this.drawScene(R,this),this.drawHit(S,this),this._isUnderCache=!1,g.restore(),v.restore(),p&&(g.save(),g.beginPath(),g.rect(0,0,a,o),g.closePath(),g.setAttr("strokeStyle","red"),g.setAttr("lineWidth",5),g.stroke(),g.restore()),this._cache.set(CANVAS,{scene:R,filter:x,hit:S,x:h,y:f}),this._requestDraw(),this}isCached(){return this._cache.has(CANVAS)}getClientRect(e){throw new Error('abstract "getClientRect" method call')}_transformedRect(e,n){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}],a=1/0,o=1/0,d=-1/0,h=-1/0,f=this.getAbsoluteTransform(n);return t.forEach(function(u){var p=f.point(u);a===void 0&&(a=d=p.x,o=h=p.y),a=Math.min(a,p.x),o=Math.min(o,p.y),d=Math.max(d,p.x),h=Math.max(h,p.y)}),{x:a,y:o,width:d-a,height:h-o}}_drawCachedSceneCanvas(e){e.save(),e._applyOpacity(this),e._applyGlobalCompositeOperation(this);const n=this._getCanvasCache();e.translate(n.x,n.y);var t=this._getCachedSceneCanvas(),a=t.pixelRatio;e.drawImage(t._canvas,0,0,t.width/a,t.height/a),e.restore()}_drawCachedHitCanvas(e){var n=this._getCanvasCache(),t=n.hit;e.save(),e.translate(n.x,n.y),e.drawImage(t._canvas,0,0,t.width/t.pixelRatio,t.height/t.pixelRatio),e.restore()}_getCachedSceneCanvas(){var e=this.filters(),n=this._getCanvasCache(),t=n.scene,a=n.filter,o=a.getContext(),d,h,f,u;if(e){if(!this._filterUpToDate){var p=t.pixelRatio;a.setSize(t.width/t.pixelRatio,t.height/t.pixelRatio);try{for(d=e.length,o.clear(),o.drawImage(t._canvas,0,0,t.getWidth()/p,t.getHeight()/p),h=o.getImageData(0,0,a.getWidth(),a.getHeight()),f=0;f<d;f++){if(u=e[f],typeof u!="function"){Util_1$c.Util.error("Filter should be type of function, but got "+typeof u+" instead. Please check correct filters");continue}u.call(this,h),o.putImageData(h,0,0)}}catch(_){Util_1$c.Util.error("Unable to apply filter. "+_.message+" This post my help you https://konvajs.org/docs/posts/Tainted_Canvas.html.")}this._filterUpToDate=!0}return a}return t}on(e,n){if(this._cache&&this._cache.delete(ALL_LISTENERS),arguments.length===3)return this._delegate.apply(this,arguments);var t=e.split(SPACE$1),a=t.length,o,d,h,f,u;for(o=0;o<a;o++)d=t[o],h=d.split("."),f=h[0],u=h[1]||"",this.eventListeners[f]||(this.eventListeners[f]=[]),this.eventListeners[f].push({name:u,handler:n});return this}off(e,n){var t=(e||"").split(SPACE$1),a=t.length,o,d,h,f,u,p;if(this._cache&&this._cache.delete(ALL_LISTENERS),!e)for(d in this.eventListeners)this._off(d);for(o=0;o<a;o++)if(h=t[o],f=h.split("."),u=f[0],p=f[1],u)this.eventListeners[u]&&this._off(u,p,n);else for(d in this.eventListeners)this._off(d,p,n);return this}dispatchEvent(e){var n={target:this,type:e.type,evt:e};return this.fire(e.type,n),this}addEventListener(e,n){return this.on(e,function(t){n.call(this,t.evt)}),this}removeEventListener(e){return this.off(e),this}_delegate(e,n,t){var a=this;this.on(e,function(o){for(var d=o.target.findAncestors(n,!0,a),h=0;h<d.length;h++)o=Util_1$c.Util.cloneObject(o),o.currentTarget=d[h],t.call(d[h],o)})}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 n="get"+Util_1$c.Util._capitalize(e);return Util_1$c.Util._isFunction(this[n])?this[n]():this.attrs[e]}getAncestors(){for(var e=this.getParent(),n=[];e;)n.push(e),e=e.getParent();return n}getAttrs(){return this.attrs||{}}setAttrs(e){return this._batchTransformChanges(()=>{var n,t;if(!e)return this;for(n in e)n!==CHILDREN&&(t=SET+Util_1$c.Util._capitalize(n),Util_1$c.Util._isFunction(this[t])?this[t](e[n]):this._setAttr(n,e[n]))}),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,n=!1){if(e)return this._isVisible(e)&&this._isListening(e);var t=this.getLayer(),a=!1;DragAndDrop_1.DD._dragElements.forEach(d=>{d.dragStatus==="dragging"&&(d.node.nodeType==="Stage"||d.node.getLayer()===t)&&(a=!0)});var o=!n&&!Global_1$m.Konva.hitOnDragEnabled&&a;return this.isListening()&&this.isVisible()&&!o}show(){return this.visible(!0),this}hide(){return this.visible(!1),this}getZIndex(){return this.index||0}getAbsoluteZIndex(){var e=this.getDepth(),n=this,t=0,a,o,d,h;function f(p){for(a=[],o=p.length,d=0;d<o;d++)h=p[d],t++,h.nodeType!==SHAPE&&(a=a.concat(h.getChildren().slice())),h._id===n._id&&(d=o);a.length>0&&a[0].getDepth()<=e&&f(a)}const u=this.getStage();return n.nodeType!==UPPER_STAGE&&u&&f(u.getChildren()),t}getDepth(){for(var e=0,n=this.parent;n;)e++,n=n.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 n=e.getPointerPosition();if(!n)return null;var t=this.getAbsoluteTransform().copy();return t.invert(),t.point(n)}getAbsolutePosition(e){let n=!1,t=this.parent;for(;t;){if(t.isCached()){n=!0;break}t=t.parent}n&&!e&&(e=!0);var a=this.getAbsoluteTransform(e).getMatrix(),o=new Util_1$c.Transform,d=this.offset();return o.m=a.slice(),o.translate(d.x,d.y),o.getTranslation()}setAbsolutePosition(e){const{x:n,y:t,...a}=this._clearTransform();this.attrs.x=n,this.attrs.y=t,this._clearCache(TRANSFORM);var o=this._getAbsoluteTransform().copy();return o.invert(),o.translate(e.x,e.y),e={x:this.attrs.x+o.getTranslation().x,y:this.attrs.y+o.getTranslation().y},this._setTransform(a),this.setPosition({x:e.x,y:e.y}),this._clearCache(TRANSFORM),this._clearSelfAndDescendantCache(ABSOLUTE_TRANSFORM),this}_setTransform(e){var n;for(n in e)this.attrs[n]=e[n]}_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 n=e.x,t=e.y,a=this.x(),o=this.y();return n!==void 0&&(a+=n),t!==void 0&&(o+=t),this.setPosition({x:a,y:o}),this}_eachAncestorReverse(e,n){var t=[],a=this.getParent(),o,d;if(!(n&&n._id===this._id)){for(t.unshift(this);a&&(!n||a._id!==n._id);)t.unshift(a),a=a.parent;for(o=t.length,d=0;d<o;d++)e(t[d])}}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,n=this.parent.getChildren().length;return e<n-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,n=this.parent.getChildren().length;return e<n-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 n=this.index;return this.parent.children.splice(n,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(),n=this.getParent();return n&&!n._isUnderCache&&(e*=n.getAbsoluteOpacity()),e}moveTo(e){return this.getParent()!==e&&(this._remove(),e.add(this)),this}toObject(){var e={},n=this.getAttrs(),t,a,o,d,h;e.attrs={};for(t in n)a=n[t],h=Util_1$c.Util.isObject(a)&&!Util_1$c.Util._isPlainObject(a)&&!Util_1$c.Util._isArray(a),!h&&(o=typeof this[t]=="function"&&this[t],delete n[t],d=o?o.call(this):null,n[t]=a,d!==a&&(e.attrs[t]=a));return e.className=this.getClassName(),Util_1$c.Util._prepareToStringify(e)}toJSON(){return JSON.stringify(this.toObject())}getParent(){return this.parent}findAncestors(e,n,t){var a=[];n&&this._isMatch(e)&&a.push(this);for(var o=this.parent;o;){if(o===t)return a;o._isMatch(e)&&a.push(o),o=o.parent}return a}isAncestorOf(e){return!1}findAncestor(e,n,t){return this.findAncestors(e,n,t)[0]}_isMatch(e){if(!e)return!1;if(typeof e=="function")return e(this);var n=e.replace(/ /g,"").split(","),t=n.length,a,o;for(a=0;a<t;a++)if(o=n[a],Util_1$c.Util.isValidSelector(o)||(Util_1$c.Util.warn('Selector "'+o+'" 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?")),o.charAt(0)==="#"){if(this.id()===o.slice(1))return!0}else if(o.charAt(0)==="."){if(this.hasName(o.slice(1)))return!0}else if(this.className===o||this.nodeType===o)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,n={},t){return n.target=n.target||this,t?this._fireAndBubble(e,n):this._fire(e,n),this}getAbsoluteTransform(e){return e?this._getAbsoluteTransform(e):this._getCache(ABSOLUTE_TRANSFORM,this._getAbsoluteTransform)}_getAbsoluteTransform(e){var n;if(e)return n=new Util_1$c.Transform,this._eachAncestorReverse(function(a){var o=a.transformsEnabled();o==="all"?n.multiply(a.getTransform()):o==="position"&&n.translate(a.x()-a.offsetX(),a.y()-a.offsetY())},e),n;n=this._cache.get(ABSOLUTE_TRANSFORM)||new Util_1$c.Transform,this.parent?this.parent.getAbsoluteTransform().copyInto(n):n.reset();var t=this.transformsEnabled();if(t==="all")n.multiply(this.getTransform());else if(t==="position"){const a=this.attrs.x||0,o=this.attrs.y||0,d=this.attrs.offsetX||0,h=this.attrs.offsetY||0;n.translate(a-d,o-h)}return n.dirty=!1,n}getAbsoluteScale(e){for(var n=this;n;)n._isUnderCache&&(e=n),n=n.getParent();const a=this.getAbsoluteTransform(e).decompose();return{x:a.scaleX,y:a.scaleY}}getAbsoluteRotation(){return this.getAbsoluteTransform().decompose().rotation}getTransform(){return this._getCache(TRANSFORM,this._getTransform)}_getTransform(){var e,n,t=this._cache.get(TRANSFORM)||new Util_1$c.Transform;t.reset();var a=this.x(),o=this.y(),d=Global_1$m.Konva.getAngle(this.rotation()),h=(e=this.attrs.scaleX)!==null&&e!==void 0?e:1,f=(n=this.attrs.scaleY)!==null&&n!==void 0?n:1,u=this.attrs.skewX||0,p=this.attrs.skewY||0,_=this.attrs.offsetX||0,R=this.attrs.offsetY||0;return(a!==0||o!==0)&&t.translate(a,o),d!==0&&t.rotate(d),(u!==0||p!==0)&&t.skew(u,p),(h!==1||f!==1)&&t.scale(h,f),(_!==0||R!==0)&&t.translate(-1*_,-1*R),t.dirty=!1,t}clone(e){var n=Util_1$c.Util.cloneObject(this.attrs),t,a,o,d,h;for(t in e)n[t]=e[t];var f=new this.constructor(n);for(t in this.eventListeners)for(a=this.eventListeners[t],o=a.length,d=0;d<o;d++)h=a[d],h.name.indexOf(KONVA)<0&&(f.eventListeners[t]||(f.eventListeners[t]=[]),f.eventListeners[t].push(h));return f}_toKonvaCanvas(e){e=e||{};var n=this.getClientRect(),t=this.getStage(),a=e.x!==void 0?e.x:Math.floor(n.x),o=e.y!==void 0?e.y:Math.floor(n.y),d=e.pixelRatio||1,h=new Canvas_1$1.SceneCanvas({width:e.width||Math.ceil(n.width)||(t?t.width():0),height:e.height||Math.ceil(n.height)||(t?t.height():0),pixelRatio:d}),f=h.getContext();return e.imageSmoothingEnabled===!1&&(f._context.imageSmoothingEnabled=!1),f.save(),(a||o)&&f.translate(-1*a,-1*o),this.drawScene(h),f.restore(),h}toCanvas(e){return this._toKonvaCanvas(e)._canvas}toDataURL(e){e=e||{};var n=e.mimeType||null,t=e.quality||null,a=this._toKonvaCanvas(e).toDataURL(n,t);return e.callback&&e.callback(a),a}toImage(e){return new Promise((n,t)=>{try{const a=e==null?void 0:e.callback;a&&delete e.callback,Util_1$c.Util._urlToImage(this.toDataURL(e),function(o){n(o),a==null||a(o)})}catch(a){t(a)}})}toBlob(e){return new Promise((n,t)=>{try{const a=e==null?void 0:e.callback;a&&delete e.callback,this.toCanvas(e).toBlob(o=>{n(o),a==null||a(o)},e==null?void 0:e.mimeType,e==null?void 0:e.quality)}catch(a){t(a)}})}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,n,t){var a=this.eventListeners[e],o,d,h;for(o=0;o<a.length;o++)if(d=a[o].name,h=a[o].handler,(d!=="konva"||n==="konva")&&(!n||d===n)&&(!t||t===h)){if(a.splice(o,1),a.length===0){delete this.eventListeners[e];break}o--}}_fireChangeEvent(e,n,t){this._fire(e+CHANGE,{oldVal:n,newVal:t})}addName(e){if(!this.hasName(e)){var n=this.name(),t=n?n+" "+e:e;this.name(t)}return this}hasName(e){if(!e)return!1;const n=this.name();if(!n)return!1;var t=(n||"").split(/\s/g);return t.indexOf(e)!==-1}removeName(e){var n=(this.name()||"").split(/\s/g),t=n.indexOf(e);return t!==-1&&(n.splice(t,1),this.name(n.join(" "))),this}setAttr(e,n){var t=this[SET+Util_1$c.Util._capitalize(e)];return Util_1$c.Util._isFunction(t)?t.call(this,n):this._setAttr(e,n),this}_requestDraw(){if(Global_1$m.Konva.autoDrawEnabled){const e=this.getLayer()||this.getStage();e==null||e.batchDraw()}}_setAttr(e,n){var t=this.attrs[e];t===n&&!Util_1$c.Util.isObject(n)||(n==null?delete this.attrs[e]:this.attrs[e]=n,this._shouldFireChangeEvents&&this._fireChangeEvent(e,t,n),this._requestDraw())}_setComponentAttr(e,n,t){var a;t!==void 0&&(a=this.attrs[e],a||(this.attrs[e]=this.getAttr(e)),this.attrs[e][n]=t,this._fireChangeEvent(e,a,t))}_fireAndBubble(e,n,t){n&&this.nodeType===SHAPE&&(n.target=this);var a=(e===MOUSEENTER||e===MOUSELEAVE)&&(t&&(this===t||this.isAncestorOf&&this.isAncestorOf(t))||this.nodeType==="Stage"&&!t);if(!a){this._fire(e,n);var o=(e===MOUSEENTER||e===MOUSELEAVE)&&t&&t.isAncestorOf&&t.isAncestorOf(this)&&!t.isAncestorOf(this.parent);(n&&!n.cancelBubble||!n)&&this.parent&&this.parent.isListening()&&!o&&(t&&t.parent?this._fireAndBubble.call(this.parent,e,n,t):this._fireAndBubble.call(this.parent,e,n))}}_getProtoListeners(e){var n,t,a;const o=(n=this._cache.get(ALL_LISTENERS))!==null&&n!==void 0?n:{};let d=o==null?void 0:o[e];if(d===void 0){d=[];let h=Object.getPrototypeOf(this);for(;h;){const f=(a=(t=h.eventListeners)===null||t===void 0?void 0:t[e])!==null&&a!==void 0?a:[];d.push(...f),h=Object.getPrototypeOf(h)}o[e]=d,this._cache.set(ALL_LISTENERS,o)}return d}_fire(e,n){n=n||{},n.currentTarget=this,n.type=e;const t=this._getProtoListeners(e);if(t)for(var a=0;a<t.length;a++)t[a].handler.call(this,n);const o=this.eventListeners[e];if(o)for(var a=0;a<o.length;a++)o[a].handler.call(this,n)}draw(){return this.drawScene(),this.drawHit(),this}_createDragElement(e){var n=e?e.pointerId:void 0,t=this.getStage(),a=this.getAbsolutePosition();if(t){var o=t._getPointerById(n)||t._changedPointerPositions[0]||a;DragAndDrop_1.DD._dragElements.set(this._id,{node:this,startPointerPos:o,offset:{x:o.x-a.x,y:o.y-a.y},dragStatus:"ready",pointerId:n})}}startDrag(e,n=!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},n)}_setDragPosition(e,n){const t=this.getStage()._getPointerById(n.pointerId);if(t){var a={x:t.x-n.offset.x,y:t.y-n.offset.y},o=this.dragBoundFunc();if(o!==void 0){const d=o.call(this,a,e);d?a=d: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!==a.x||this._lastPos.y!==a.y)&&(this.setAbsolutePosition(a),this._requestDraw()),this._lastPos=a}}stopDrag(e){const n=DragAndDrop_1.DD._dragElements.get(this._id);n&&(n.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 n=e.evt.button!==void 0,t=!n||Global_1$m.Konva.dragButtons.indexOf(e.evt.button)>=0;if(t&&!this.isDragging()){var a=!1;DragAndDrop_1.DD._dragElements.forEach(o=>{this.isAncestorOf(o.node)&&(a=!0)}),a||this._createDragElement(e)}})}_dragChange(){if(this.attrs.draggable)this._listenDrag();else{this._dragCleanup();var e=this.getStage();if(!e)return;const n=DragAndDrop_1.DD._dragElements.get(this._id),t=n&&n.dragStatus==="dragging",a=n&&n.dragStatus==="ready";t?this.stopDrag():a&&DragAndDrop_1.DD._dragElements.delete(this._id)}}_dragCleanup(){this.off("mousedown.konva"),this.off("touchstart.konva")}isClientRectOnScreen(e={x:0,y:0}){const n=this.getStage();if(!n)return!1;const t={x:-e.x,y:-e.y,width:n.width()+2*e.x,height:n.height()+2*e.y};return Util_1$c.Util.haveIntersection(t,this.getClientRect())}static create(e,n){return Util_1$c.Util._isString(e)&&(e=JSON.parse(e)),this._createNode(e,n)}static _createNode(e,n){var t=Node.prototype.getClassName.call(e),a=e.children,o,d,h;n&&(e.attrs.container=n),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(o=new f(e.attrs),a)for(d=a.length,h=0;h<d;h++)o.add(Node._createNode(a[h]));return o}}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(l){return this._filterUpToDate=!1,l});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 n=this.children||[];var t=[];return n.forEach(function(a){e(a)&&t.push(a)}),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 n=0;n<e.length;n++)this.add(e[n]);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 n=this._generalFind(e,!0);return n.length>0?n[0]:void 0}_generalFind(e,n){var t=[];return this._descendants(a=>{const o=a._isMatch(e);return o&&t.push(a),!!(o&&n)}),t}_descendants(e){let n=!1;const t=this.getChildren();for(const a of t){if(n=e(a),n)return!0;if(a.hasChildren()&&(n=a._descendants(e),n))return!0}return!1}toObject(){var e=Node_1$h.Node.prototype.toObject.call(this);return e.children=[],this.getChildren().forEach(n=>{e.children.push(n.toObject())}),e}isAncestorOf(e){for(var n=e.getParent();n;){if(n._id===this._id)return!0;n=n.getParent()}return!1}clone(e){var n=Node_1$h.Node.prototype.clone.call(this,e);return this.getChildren().forEach(function(t){n.add(t.clone())}),n}getAllIntersections(e){var n=[];return this.find("Shape").forEach(t=>{t.isVisible()&&t.intersects(e)&&n.push(t)}),n}_clearSelfAndDescendantCache(e){var n;super._clearSelfAndDescendantCache(e),!this.isCached()&&((n=this.children)===null||n===void 0||n.forEach(function(t){t._clearSelfAndDescendantCache(e)}))}_setChildrenIndices(){var e;(e=this.children)===null||e===void 0||e.forEach(function(n,t){n.index=t}),this._requestDraw()}drawScene(e,n){var t=this.getLayer(),a=e||t&&t.getCanvas(),o=a&&a.getContext(),d=this._getCanvasCache(),h=d&&d.scene,f=a&&a.isCache;if(!this.isVisible()&&!f)return this;if(h){o.save();var u=this.getAbsoluteTransform(n).getMatrix();o.transform(u[0],u[1],u[2],u[3],u[4],u[5]),this._drawCachedSceneCanvas(o),o.restore()}else this._drawChildren("drawScene",a,n);return this}drawHit(e,n){if(!this.shouldDrawHit(n))return this;var t=this.getLayer(),a=e||t&&t.hitCanvas,o=a&&a.getContext(),d=this._getCanvasCache(),h=d&&d.hit;if(h){o.save();var f=this.getAbsoluteTransform(n).getMatrix();o.transform(f[0],f[1],f[2],f[3],f[4],f[5]),this._drawCachedHitCanvas(o),o.restore()}else this._drawChildren("drawHit",a,n);return this}_drawChildren(e,n,t){var a,o=n&&n.getContext(),d=this.clipWidth(),h=this.clipHeight(),f=this.clipFunc(),u=d&&h||f;const p=t===this;if(u){o.save();var _=this.getAbsoluteTransform(t),R=_.getMatrix();o.transform(R[0],R[1],R[2],R[3],R[4],R[5]),o.beginPath();let v;if(f)v=f.call(this,o,this);else{var x=this.clipX(),S=this.clipY();o.rect(x,S,d,h)}o.clip.apply(o,v),R=_.copy().invert().getMatrix(),o.transform(R[0],R[1],R[2],R[3],R[4],R[5])}var g=!p&&this.globalCompositeOperation()!=="source-over"&&e==="drawScene";g&&(o.save(),o._applyGlobalCompositeOperation(this)),(a=this.children)===null||a===void 0||a.forEach(function(v){v[e](n,t)}),g&&o.restore(),u&&o.restore()}getClientRect(e={}){var n,t=e.skipTransform,a=e.relativeTo,o,d,h,f,u={x:1/0,y:1/0,width:0,height:0},p=this;(n=this.children)===null||n===void 0||n.forEach(function(g){if(g.visible()){var v=g.getClientRect({relativeTo:p,skipShadow:e.skipShadow,skipStroke:e.skipStroke});v.width===0&&v.height===0||(o===void 0?(o=v.x,d=v.y,h=v.x+v.width,f=v.y+v.height):(o=Math.min(o,v.x),d=Math.min(d,v.y),h=Math.max(h,v.x+v.width),f=Math.max(f,v.y+v.height)))}});for(var _=this.find("Shape"),R=!1,x=0;x<_.length;x++){var S=_[x];if(S._isVisible(this)){R=!0;break}}return R&&o!==void 0?u={x:o,y:d,width:h-o,height:f-d}:u={x:0,y:0,width:0,height:0},t?u:this._transformedRect(u,a)}};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(l){return Captures.get(l)}PointerEvents.getCapturedShape=getCapturedShape;function createEvent(l){return{evt:l,pointerId:l.pointerId}}PointerEvents.createEvent=createEvent;function hasPointerCapture(l,e){return Captures.get(l)===e}PointerEvents.hasPointerCapture=hasPointerCapture;function setPointerCapture(l,e){releaseCapture(l),e.getStage()&&(Captures.set(l,e),SUPPORT_POINTER_EVENTS&&e._fire("gotpointercapture",createEvent(new PointerEvent("gotpointercapture"))))}PointerEvents.setPointerCapture=setPointerCapture;function releaseCapture(l,e){const n=Captures.get(l);if(!n)return;const t=n.getStage();t&&t.content,Captures.delete(l),SUPPORT_POINTER_EVENTS&&n._fire("lostpointercapture",createEvent(new PointerEvent("lostpointercapture")))}PointerEvents.releaseCapture=releaseCapture;(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Stage=l.stages=void 0;const e=Util,n=Factory,t=Container$2,a=Global,o=Canvas$1,d=DragAndDrop,h=Global,f=PointerEvents;var u="Stage",p="string",_="px",R="mouseout",x="mouseleave",S="mouseover",g="mouseenter",v="mousemove",b="mousedown",T="mouseup",y="pointermove",w="pointerdown",C="pointerup",N="pointercancel",D="lostpointercapture",P="pointerout",k="pointerleave",F="pointerover",M="pointerenter",j="contextmenu",$="touchstart",B="touchend",X="touchmove",re="touchcancel",ae="wheel",ee=5,K=[[g,"_pointerenter"],[b,"_pointerdown"],[v,"_pointermove"],[T,"_pointerup"],[x,"_pointerleave"],[$,"_pointerdown"],[X,"_pointermove"],[B,"_pointerup"],[re,"_pointercancel"],[S,"_pointerover"],[ae,"_wheel"],[j,"_contextmenu"],[w,"_pointerdown"],[y,"_pointermove"],[C,"_pointerup"],[N,"_pointercancel"],[D,"_lostpointercapture"]];const ne={mouse:{[P]:R,[k]:x,[F]:S,[M]:g,[y]:v,[w]:b,[C]:T,[N]:"mousecancel",pointerclick:"click",pointerdblclick:"dblclick"},touch:{[P]:"touchout",[k]:"touchleave",[F]:"touchover",[M]:"touchenter",[y]:X,[w]:$,[C]:B,[N]:re,pointerclick:"tap",pointerdblclick:"dbltap"},pointer:{[P]:P,[k]:k,[F]:F,[M]:M,[y]:y,[w]:w,[C]:C,[N]:N,pointerclick:"pointerclick",pointerdblclick:"pointerdblclick"}},ue=V=>V.indexOf("pointer")>=0?"pointer":V.indexOf("touch")>=0?"touch":"mouse",me=V=>{const z=ue(V);if(z==="pointer")return a.Konva.pointerEventsEnabled&&ne.pointer;if(z==="touch")return ne.touch;if(z==="mouse")return ne.mouse};function J(V={}){return(V.clipFunc||V.clipWidth||V.clipHeight)&&e.Util.warn("Stage does not support clipping. Please use clip for Layers or Groups."),V}const H="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);";l.stages=[];class W extends t.Container{constructor(z){super(J(z)),this._pointerPositions=[],this._changedPointerPositions=[],this._buildDOM(),this._bindContentEvents(),l.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",()=>{J(this.attrs)}),this._checkVisibility()}_validateAdd(z){const Y=z.getType()==="Layer",ie=z.getType()==="FastLayer";Y||ie||e.Util.throw("You may only add layers to the stage.")}_checkVisibility(){if(!this.content)return;const z=this.visible()?"":"none";this.content.style.display=z}setContainer(z){if(typeof z===p){if(z.charAt(0)==="."){var Y=z.slice(1);z=document.getElementsByClassName(Y)[0]}else{var ie;z.charAt(0)!=="#"?ie=z:ie=z.slice(1),z=document.getElementById(ie)}if(!z)throw"Can not find container in document with id "+ie}return this._setAttr("container",z),this.content&&(this.content.parentElement&&this.content.parentElement.removeChild(this.content),z.appendChild(this.content)),this}shouldDrawHit(){return!0}clear(){var z=this.children,Y=z.length,ie;for(ie=0;ie<Y;ie++)z[ie].clear();return this}clone(z){return z||(z={}),z.container=typeof document<"u"&&document.createElement("div"),t.Container.prototype.clone.call(this,z)}destroy(){super.destroy();var z=this.content;z&&e.Util._isInDocument(z)&&this.container().removeChild(z);var Y=l.stages.indexOf(this);return Y>-1&&l.stages.splice(Y,1),e.Util.releaseCanvas(this.bufferCanvas._canvas,this.bufferHitCanvas._canvas),this}getPointerPosition(){const z=this._pointerPositions[0]||this._changedPointerPositions[0];return z?{x:z.x,y:z.y}:(e.Util.warn(H),null)}_getPointerById(z){return this._pointerPositions.find(Y=>Y.id===z)}getPointersPositions(){return this._pointerPositions}getStage(){return this}getContent(){return this.content}_toKonvaCanvas(z){z=z||{},z.x=z.x||0,z.y=z.y||0,z.width=z.width||this.width(),z.height=z.height||this.height();var Y=new o.SceneCanvas({width:z.width,height:z.height,pixelRatio:z.pixelRatio||1}),ie=Y.getContext()._context,le=this.children;return(z.x||z.y)&&ie.translate(-1*z.x,-1*z.y),le.forEach(function(fe){if(fe.isVisible()){var ce=fe._toKonvaCanvas(z);ie.drawImage(ce._canvas,z.x,z.y,ce.getWidth()/ce.getPixelRatio(),ce.getHeight()/ce.getPixelRatio())}}),Y}getIntersection(z){if(!z)return null;var Y=this.children,ie=Y.length,le=ie-1,fe;for(fe=le;fe>=0;fe--){const ce=Y[fe].getIntersection(z);if(ce)return ce}return null}_resizeDOM(){var z=this.width(),Y=this.height();this.content&&(this.content.style.width=z+_,this.content.style.height=Y+_),this.bufferCanvas.setSize(z,Y),this.bufferHitCanvas.setSize(z,Y),this.children.forEach(ie=>{ie.setSize({width:z,height:Y}),ie.draw()})}add(z,...Y){if(arguments.length>1){for(var ie=0;ie<arguments.length;ie++)this.add(arguments[ie]);return this}super.add(z);var le=this.children.length;return le>ee&&e.Util.warn("The stage has "+le+" 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."),z.setSize({width:this.width(),height:this.height()}),z.draw(),a.Konva.isBrowser&&this.content.appendChild(z.canvas._canvas),this}getParent(){return null}getLayer(){return null}hasPointerCapture(z){return f.hasPointerCapture(z,this)}setPointerCapture(z){f.setPointerCapture(z,this)}releaseCapture(z){f.releaseCapture(z,this)}getLayers(){return this.children}_bindContentEvents(){a.Konva.isBrowser&&K.forEach(([z,Y])=>{this.content.addEventListener(z,ie=>{this[Y](ie)},{passive:!1})})}_pointerenter(z){this.setPointersPositions(z);const Y=me(z.type);Y&&this._fire(Y.pointerenter,{evt:z,target:this,currentTarget:this})}_pointerover(z){this.setPointersPositions(z);const Y=me(z.type);Y&&this._fire(Y.pointerover,{evt:z,target:this,currentTarget:this})}_getTargetShape(z){let Y=this[z+"targetShape"];return Y&&!Y.getStage()&&(Y=null),Y}_pointerleave(z){const Y=me(z.type),ie=ue(z.type);if(Y){this.setPointersPositions(z);var le=this._getTargetShape(ie),fe=!d.DD.isDragging||a.Konva.hitOnDragEnabled;le&&fe?(le._fireAndBubble(Y.pointerout,{evt:z}),le._fireAndBubble(Y.pointerleave,{evt:z}),this._fire(Y.pointerleave,{evt:z,target:this,currentTarget:this}),this[ie+"targetShape"]=null):fe&&(this._fire(Y.pointerleave,{evt:z,target:this,currentTarget:this}),this._fire(Y.pointerout,{evt:z,target:this,currentTarget:this})),this.pointerPos=null,this._pointerPositions=[]}}_pointerdown(z){const Y=me(z.type),ie=ue(z.type);if(Y){this.setPointersPositions(z);var le=!1;this._changedPointerPositions.forEach(fe=>{var ce=this.getIntersection(fe);if(d.DD.justDragged=!1,a.Konva["_"+ie+"ListenClick"]=!0,!ce||!ce.isListening())return;a.Konva.capturePointerEventsEnabled&&ce.setPointerCapture(fe.id),this[ie+"ClickStartShape"]=ce,ce._fireAndBubble(Y.pointerdown,{evt:z,pointerId:fe.id}),le=!0;const ge=z.type.indexOf("touch")>=0;ce.preventDefault()&&z.cancelable&&ge&&z.preventDefault()}),le||this._fire(Y.pointerdown,{evt:z,target:this,currentTarget:this,pointerId:this._pointerPositions[0].id})}}_pointermove(z){const Y=me(z.type),ie=ue(z.type);if(!Y)return;d.DD.isDragging&&d.DD.node.preventDefault()&&z.cancelable&&z.preventDefault(),this.setPointersPositions(z);var le=!d.DD.isDragging||a.Konva.hitOnDragEnabled;if(!le)return;var fe={};let ce=!1;var ge=this._getTargetShape(ie);this._changedPointerPositions.forEach(Se=>{const Te=f.getCapturedShape(Se.id)||this.getIntersection(Se),Fe=Se.id,Ne={evt:z,pointerId:Fe};var Qe=ge!==Te;if(Qe&&ge&&(ge._fireAndBubble(Y.pointerout,{...Ne},Te),ge._fireAndBubble(Y.pointerleave,{...Ne},Te)),Te){if(fe[Te._id])return;fe[Te._id]=!0}Te&&Te.isListening()?(ce=!0,Qe&&(Te._fireAndBubble(Y.pointerover,{...Ne},ge),Te._fireAndBubble(Y.pointerenter,{...Ne},ge),this[ie+"targetShape"]=Te),Te._fireAndBubble(Y.pointermove,{...Ne})):ge&&(this._fire(Y.pointerover,{evt:z,target:this,currentTarget:this,pointerId:Fe}),this[ie+"targetShape"]=null)}),ce||this._fire(Y.pointermove,{evt:z,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id})}_pointerup(z){const Y=me(z.type),ie=ue(z.type);if(!Y)return;this.setPointersPositions(z);const le=this[ie+"ClickStartShape"],fe=this[ie+"ClickEndShape"];var ce={};let ge=!1;this._changedPointerPositions.forEach(Se=>{const Te=f.getCapturedShape(Se.id)||this.getIntersection(Se);if(Te){if(Te.releaseCapture(Se.id),ce[Te._id])return;ce[Te._id]=!0}const Fe=Se.id,Ne={evt:z,pointerId:Fe};let Qe=!1;a.Konva["_"+ie+"InDblClickWindow"]?(Qe=!0,clearTimeout(this[ie+"DblTimeout"])):d.DD.justDragged||(a.Konva["_"+ie+"InDblClickWindow"]=!0,clearTimeout(this[ie+"DblTimeout"])),this[ie+"DblTimeout"]=setTimeout(function(){a.Konva["_"+ie+"InDblClickWindow"]=!1},a.Konva.dblClickWindow),Te&&Te.isListening()?(ge=!0,this[ie+"ClickEndShape"]=Te,Te._fireAndBubble(Y.pointerup,{...Ne}),a.Konva["_"+ie+"ListenClick"]&&le&&le===Te&&(Te._fireAndBubble(Y.pointerclick,{...Ne}),Qe&&fe&&fe===Te&&Te._fireAndBubble(Y.pointerdblclick,{...Ne}))):(this[ie+"ClickEndShape"]=null,a.Konva["_"+ie+"ListenClick"]&&this._fire(Y.pointerclick,{evt:z,target:this,currentTarget:this,pointerId:Fe}),Qe&&this._fire(Y.pointerdblclick,{evt:z,target:this,currentTarget:this,pointerId:Fe}))}),ge||this._fire(Y.pointerup,{evt:z,target:this,currentTarget:this,pointerId:this._changedPointerPositions[0].id}),a.Konva["_"+ie+"ListenClick"]=!1,z.cancelable&&ie!=="touch"&&z.preventDefault()}_contextmenu(z){this.setPointersPositions(z);var Y=this.getIntersection(this.getPointerPosition());Y&&Y.isListening()?Y._fireAndBubble(j,{evt:z}):this._fire(j,{evt:z,target:this,currentTarget:this})}_wheel(z){this.setPointersPositions(z);var Y=this.getIntersection(this.getPointerPosition());Y&&Y.isListening()?Y._fireAndBubble(ae,{evt:z}):this._fire(ae,{evt:z,target:this,currentTarget:this})}_pointercancel(z){this.setPointersPositions(z);const Y=f.getCapturedShape(z.pointerId)||this.getIntersection(this.getPointerPosition());Y&&Y._fireAndBubble(C,f.createEvent(z)),f.releaseCapture(z.pointerId)}_lostpointercapture(z){f.releaseCapture(z.pointerId)}setPointersPositions(z){var Y=this._getContentPosition(),ie=null,le=null;z=z||window.event,z.touches!==void 0?(this._pointerPositions=[],this._changedPointerPositions=[],Array.prototype.forEach.call(z.touches,fe=>{this._pointerPositions.push({id:fe.identifier,x:(fe.clientX-Y.left)/Y.scaleX,y:(fe.clientY-Y.top)/Y.scaleY})}),Array.prototype.forEach.call(z.changedTouches||z.touches,fe=>{this._changedPointerPositions.push({id:fe.identifier,x:(fe.clientX-Y.left)/Y.scaleX,y:(fe.clientY-Y.top)/Y.scaleY})})):(ie=(z.clientX-Y.left)/Y.scaleX,le=(z.clientY-Y.top)/Y.scaleY,this.pointerPos={x:ie,y:le},this._pointerPositions=[{x:ie,y:le,id:e.Util._getFirstPointerId(z)}],this._changedPointerPositions=[{x:ie,y:le,id:e.Util._getFirstPointerId(z)}])}_setPointerPosition(z){e.Util.warn('Method _setPointerPosition is deprecated. Use "stage.setPointersPositions(event)" instead.'),this.setPointersPositions(z)}_getContentPosition(){if(!this.content||!this.content.getBoundingClientRect)return{top:0,left:0,scaleX:1,scaleY:1};var z=this.content.getBoundingClientRect();return{top:z.top,left:z.left,scaleX:z.width/this.content.clientWidth||1,scaleY:z.height/this.content.clientHeight||1}}_buildDOM(){if(this.bufferCanvas=new o.SceneCanvas({width:this.width(),height:this.height()}),this.bufferHitCanvas=new o.HitCanvas({pixelRatio:1,width:this.width(),height:this.height()}),!!a.Konva.isBrowser){var z=this.container();if(!z)throw"Stage has no container. A container is required.";z.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"),z.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(z){z.batchDraw()}),this}}l.Stage=W,W.prototype.nodeType=u,(0,h._registerNode)(W),n.Factory.addGetterSetter(W,"container")})(Stage$1);var Layer$2={},Shape={};(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Shape=l.shapes=void 0;const e=Global,n=Util,t=Factory,a=Node$1,o=Validators,d=Global,h=PointerEvents;var f="hasShadow",u="shadowRGBA",p="patternImage",_="linearGradient",R="radialGradient";let x;function S(){return x||(x=n.Util.createCanvasElement().getContext("2d"),x)}l.shapes={};function g(k){const F=this.attrs.fillRule;F?k.fill(F):k.fill()}function v(k){k.stroke()}function b(k){k.fill()}function T(k){k.stroke()}function y(){this._clearCache(f)}function w(){this._clearCache(u)}function C(){this._clearCache(p)}function N(){this._clearCache(_)}function D(){this._clearCache(R)}class P extends a.Node{constructor(F){super(F);let M;for(;M=n.Util.getRandomColor(),!(M&&!(M in l.shapes)););this.colorKey=M,l.shapes[M]=this}getContext(){return n.Util.warn("shape.getContext() method is deprecated. Please do not use it."),this.getLayer().getContext()}getCanvas(){return n.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(p,this.__getFillPattern)}__getFillPattern(){if(this.fillPatternImage()){var F=S();const M=F.createPattern(this.fillPatternImage(),this.fillPatternRepeat()||"repeat");if(M&&M.setTransform){const j=new n.Transform;j.translate(this.fillPatternX(),this.fillPatternY()),j.rotate(e.Konva.getAngle(this.fillPatternRotation())),j.scale(this.fillPatternScaleX(),this.fillPatternScaleY()),j.translate(-1*this.fillPatternOffsetX(),-1*this.fillPatternOffsetY());const $=j.getMatrix(),B=typeof DOMMatrix>"u"?{a:$[0],b:$[1],c:$[2],d:$[3],e:$[4],f:$[5]}:new DOMMatrix($);M.setTransform(B)}return M}}_getLinearGradient(){return this._getCache(_,this.__getLinearGradient)}__getLinearGradient(){var F=this.fillLinearGradientColorStops();if(F){for(var M=S(),j=this.fillLinearGradientStartPoint(),$=this.fillLinearGradientEndPoint(),B=M.createLinearGradient(j.x,j.y,$.x,$.y),X=0;X<F.length;X+=2)B.addColorStop(F[X],F[X+1]);return B}}_getRadialGradient(){return this._getCache(R,this.__getRadialGradient)}__getRadialGradient(){var F=this.fillRadialGradientColorStops();if(F){for(var M=S(),j=this.fillRadialGradientStartPoint(),$=this.fillRadialGradientEndPoint(),B=M.createRadialGradient(j.x,j.y,this.fillRadialGradientStartRadius(),$.x,$.y,this.fillRadialGradientEndRadius()),X=0;X<F.length;X+=2)B.addColorStop(F[X],F[X+1]);return B}}getShadowRGBA(){return this._getCache(u,this._getShadowRGBA)}_getShadowRGBA(){if(this.hasShadow()){var F=n.Util.colorToRGBA(this.shadowColor());if(F)return"rgba("+F.r+","+F.g+","+F.b+","+F.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 F=this.hitStrokeWidth();return F==="auto"?this.hasStroke():this.strokeEnabled()&&!!F}intersects(F){var M=this.getStage();if(!M)return!1;const j=M.bufferHitCanvas;return j.getContext().clear(),this.drawHit(j,void 0,!0),j.context.getImageData(Math.round(F.x),Math.round(F.y),1,1).data[3]>0}destroy(){return a.Node.prototype.destroy.call(this),delete l.shapes[this.colorKey],delete this.colorKey,this}_useBufferCanvas(F){var M;if(!this.getStage()||!((M=this.attrs.perfectDrawEnabled)!==null&&M!==void 0?M:!0))return!1;const $=F||this.hasFill(),B=this.hasStroke(),X=this.getAbsoluteOpacity()!==1;if($&&B&&X)return!0;const re=this.hasShadow(),ae=this.shadowForStrokeEnabled();return!!($&&B&&re&&ae)}setStrokeHitEnabled(F){n.Util.warn("strokeHitEnabled property is deprecated. Please use hitStrokeWidth instead."),F?this.hitStrokeWidth("auto"):this.hitStrokeWidth(0)}getStrokeHitEnabled(){return this.hitStrokeWidth()!==0}getSelfRect(){var F=this.size();return{x:this._centroid?-F.width/2:0,y:this._centroid?-F.height/2:0,width:F.width,height:F.height}}getClientRect(F={}){const M=F.skipTransform,j=F.relativeTo,$=this.getSelfRect(),X=!F.skipStroke&&this.hasStroke()&&this.strokeWidth()||0,re=$.width+X,ae=$.height+X,ee=!F.skipShadow&&this.hasShadow(),K=ee?this.shadowOffsetX():0,ne=ee?this.shadowOffsetY():0,ue=re+Math.abs(K),me=ae+Math.abs(ne),J=ee&&this.shadowBlur()||0,H=ue+J*2,W=me+J*2,V={width:H,height:W,x:-(X/2+J)+Math.min(K,0)+$.x,y:-(X/2+J)+Math.min(ne,0)+$.y};return M?V:this._transformedRect(V,j)}drawScene(F,M){var j=this.getLayer(),$=F||j.getCanvas(),B=$.getContext(),X=this._getCanvasCache(),re=this.getSceneFunc(),ae=this.hasShadow(),ee,K,ne,ue=$.isCache,me=M===this;if(!this.isVisible()&&!me)return this;if(X){B.save();var J=this.getAbsoluteTransform(M).getMatrix();return B.transform(J[0],J[1],J[2],J[3],J[4],J[5]),this._drawCachedSceneCanvas(B),B.restore(),this}if(!re)return this;if(B.save(),this._useBufferCanvas()&&!ue){ee=this.getStage(),K=ee.bufferCanvas,ne=K.getContext(),ne.clear(),ne.save(),ne._applyLineJoin(this);var H=this.getAbsoluteTransform(M).getMatrix();ne.transform(H[0],H[1],H[2],H[3],H[4],H[5]),re.call(this,ne,this),ne.restore();var W=K.pixelRatio;ae&&B._applyShadow(this),B._applyOpacity(this),B._applyGlobalCompositeOperation(this),B.drawImage(K._canvas,0,0,K.width/W,K.height/W)}else{if(B._applyLineJoin(this),!me){var H=this.getAbsoluteTransform(M).getMatrix();B.transform(H[0],H[1],H[2],H[3],H[4],H[5]),B._applyOpacity(this),B._applyGlobalCompositeOperation(this)}ae&&B._applyShadow(this),re.call(this,B,this)}return B.restore(),this}drawHit(F,M,j=!1){if(!this.shouldDrawHit(M,j))return this;var $=this.getLayer(),B=F||$.hitCanvas,X=B&&B.getContext(),re=this.hitFunc()||this.sceneFunc(),ae=this._getCanvasCache(),ee=ae&&ae.hit;if(this.colorKey||n.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()"),ee){X.save();var K=this.getAbsoluteTransform(M).getMatrix();return X.transform(K[0],K[1],K[2],K[3],K[4],K[5]),this._drawCachedHitCanvas(X),X.restore(),this}if(!re)return this;if(X.save(),X._applyLineJoin(this),!(this===M)){var ue=this.getAbsoluteTransform(M).getMatrix();X.transform(ue[0],ue[1],ue[2],ue[3],ue[4],ue[5])}return re.call(this,X,this),X.restore(),this}drawHitFromCache(F=0){var M=this._getCanvasCache(),j=this._getCachedSceneCanvas(),$=M.hit,B=$.getContext(),X=$.getWidth(),re=$.getHeight(),ae,ee,K,ne,ue,me;B.clear(),B.drawImage(j._canvas,0,0,X,re);try{for(ae=B.getImageData(0,0,X,re),ee=ae.data,K=ee.length,ne=n.Util._hexToRgb(this.colorKey),ue=0;ue<K;ue+=4)me=ee[ue+3],me>F?(ee[ue]=ne.r,ee[ue+1]=ne.g,ee[ue+2]=ne.b,ee[ue+3]=255):ee[ue+3]=0;B.putImageData(ae,0,0)}catch(J){n.Util.error("Unable to draw hit graph from cached scene canvas. "+J.message)}return this}hasPointerCapture(F){return h.hasPointerCapture(F,this)}setPointerCapture(F){h.setPointerCapture(F,this)}releaseCapture(F){h.releaseCapture(F,this)}}l.Shape=P,P.prototype._fillFunc=g,P.prototype._strokeFunc=v,P.prototype._fillFuncHit=b,P.prototype._strokeFuncHit=T,P.prototype._centroid=!1,P.prototype.nodeType="Shape",(0,d._registerNode)(P),P.prototype.eventListeners={},P.prototype.on.call(P.prototype,"shadowColorChange.konva shadowBlurChange.konva shadowOffsetChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",y),P.prototype.on.call(P.prototype,"shadowColorChange.konva shadowOpacityChange.konva shadowEnabledChange.konva",w),P.prototype.on.call(P.prototype,"fillPriorityChange.konva fillPatternImageChange.konva fillPatternRepeatChange.konva fillPatternScaleXChange.konva fillPatternScaleYChange.konva fillPatternOffsetXChange.konva fillPatternOffsetYChange.konva fillPatternXChange.konva fillPatternYChange.konva fillPatternRotationChange.konva",C),P.prototype.on.call(P.prototype,"fillPriorityChange.konva fillLinearGradientColorStopsChange.konva fillLinearGradientStartPointXChange.konva fillLinearGradientStartPointYChange.konva fillLinearGradientEndPointXChange.konva fillLinearGradientEndPointYChange.konva",N),P.prototype.on.call(P.prototype,"fillPriorityChange.konva fillRadialGradientColorStopsChange.konva fillRadialGradientStartPointXChange.konva fillRadialGradientStartPointYChange.konva fillRadialGradientEndPointXChange.konva fillRadialGradientEndPointYChange.konva fillRadialGradientStartRadiusChange.konva fillRadialGradientEndRadiusChange.konva",D),t.Factory.addGetterSetter(P,"stroke",void 0,(0,o.getStringOrGradientValidator)()),t.Factory.addGetterSetter(P,"strokeWidth",2,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(P,"fillAfterStrokeEnabled",!1),t.Factory.addGetterSetter(P,"hitStrokeWidth","auto",(0,o.getNumberOrAutoValidator)()),t.Factory.addGetterSetter(P,"strokeHitEnabled",!0,(0,o.getBooleanValidator)()),t.Factory.addGetterSetter(P,"perfectDrawEnabled",!0,(0,o.getBooleanValidator)()),t.Factory.addGetterSetter(P,"shadowForStrokeEnabled",!0,(0,o.getBooleanValidator)()),t.Factory.addGetterSetter(P,"lineJoin"),t.Factory.addGetterSetter(P,"lineCap"),t.Factory.addGetterSetter(P,"sceneFunc"),t.Factory.addGetterSetter(P,"hitFunc"),t.Factory.addGetterSetter(P,"dash"),t.Factory.addGetterSetter(P,"dashOffset",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(P,"shadowColor",void 0,(0,o.getStringValidator)()),t.Factory.addGetterSetter(P,"shadowBlur",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(P,"shadowOpacity",1,(0,o.getNumberValidator)()),t.Factory.addComponentsGetterSetter(P,"shadowOffset",["x","y"]),t.Factory.addGetterSetter(P,"shadowOffsetX",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(P,"shadowOffsetY",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(P,"fillPatternImage"),t.Factory.addGetterSetter(P,"fill",void 0,(0,o.getStringOrGradientValidator)()),t.Factory.addGetterSetter(P,"fillPatternX",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(P,"fillPatternY",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(P,"fillLinearGradientColorStops"),t.Factory.addGetterSetter(P,"strokeLinearGradientColorStops"),t.Factory.addGetterSetter(P,"fillRadialGradientStartRadius",0),t.Factory.addGetterSetter(P,"fillRadialGradientEndRadius",0),t.Factory.addGetterSetter(P,"fillRadialGradientColorStops"),t.Factory.addGetterSetter(P,"fillPatternRepeat","repeat"),t.Factory.addGetterSetter(P,"fillEnabled",!0),t.Factory.addGetterSetter(P,"strokeEnabled",!0),t.Factory.addGetterSetter(P,"shadowEnabled",!0),t.Factory.addGetterSetter(P,"dashEnabled",!0),t.Factory.addGetterSetter(P,"strokeScaleEnabled",!0),t.Factory.addGetterSetter(P,"fillPriority","color"),t.Factory.addComponentsGetterSetter(P,"fillPatternOffset",["x","y"]),t.Factory.addGetterSetter(P,"fillPatternOffsetX",0,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(P,"fillPatternOffsetY",0,(0,o.getNumberValidator)()),t.Factory.addComponentsGetterSetter(P,"fillPatternScale",["x","y"]),t.Factory.addGetterSetter(P,"fillPatternScaleX",1,(0,o.getNumberValidator)()),t.Factory.addGetterSetter(P,"fillPatternScaleY",1,(0,o.getNumberValidator)()),t.Factory.addComponentsGetterSetter(P,"fillLinearGradientStartPoint",["x","y"]),t.Factory.addComponentsGetterSetter(P,"strokeLinearGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(P,"fillLinearGradientStartPointX",0),t.Factory.addGetterSetter(P,"strokeLinearGradientStartPointX",0),t.Factory.addGetterSetter(P,"fillLinearGradientStartPointY",0),t.Factory.addGetterSetter(P,"strokeLinearGradientStartPointY",0),t.Factory.addComponentsGetterSetter(P,"fillLinearGradientEndPoint",["x","y"]),t.Factory.addComponentsGetterSetter(P,"strokeLinearGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(P,"fillLinearGradientEndPointX",0),t.Factory.addGetterSetter(P,"strokeLinearGradientEndPointX",0),t.Factory.addGetterSetter(P,"fillLinearGradientEndPointY",0),t.Factory.addGetterSetter(P,"strokeLinearGradientEndPointY",0),t.Factory.addComponentsGetterSetter(P,"fillRadialGradientStartPoint",["x","y"]),t.Factory.addGetterSetter(P,"fillRadialGradientStartPointX",0),t.Factory.addGetterSetter(P,"fillRadialGradientStartPointY",0),t.Factory.addComponentsGetterSetter(P,"fillRadialGradientEndPoint",["x","y"]),t.Factory.addGetterSetter(P,"fillRadialGradientEndPointX",0),t.Factory.addGetterSetter(P,"fillRadialGradientEndPointY",0),t.Factory.addGetterSetter(P,"fillPatternRotation",0),t.Factory.addGetterSetter(P,"fillRule",void 0,(0,o.getStringValidator)()),t.Factory.backCompat(P,{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 n=this.getStage();return n&&n.content&&(n.content.removeChild(this.getNativeCanvasElement()),e<n.children.length-1?n.content.insertBefore(this.getNativeCanvasElement(),n.children[e+1].getCanvas()._canvas):n.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 n=this.getStage();return!n||!n.content?!1:(n.content.removeChild(this.getNativeCanvasElement()),this.index<n.children.length-1?n.content.insertBefore(this.getNativeCanvasElement(),n.children[this.index+1].getCanvas()._canvas):n.content.appendChild(this.getNativeCanvasElement()),!0)}moveDown(){if(Node_1$g.Node.prototype.moveDown.call(this)){var e=this.getStage();if(e){var n=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),n[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 n=e.children;e.content&&(e.content.removeChild(this.getNativeCanvasElement()),e.content.insertBefore(this.getNativeCanvasElement(),n[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:n}){return this.canvas.setSize(e,n),this.hitCanvas.setSize(e,n),this._setSmoothEnabled(),this}_validateAdd(e){var n=e.getType();n!=="Group"&&n!=="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 n=1,t=!1;;){for(let a=0;a<INTERSECTION_OFFSETS_LEN;a++){const o=INTERSECTION_OFFSETS[a],d=this._getIntersection({x:e.x+o.x*n,y:e.y+o.y*n}),h=d.shape;if(h)return h;if(t=!!d.antialiased,!d.antialiased)break}if(t)n+=1;else return null}}_getIntersection(e){const n=this.hitCanvas.pixelRatio,t=this.hitCanvas.context.getImageData(Math.round(e.x*n),Math.round(e.y*n),1,1).data,a=t[3];if(a===255){const o=Util_1$b.Util._rgbToHex(t[0],t[1],t[2]),d=Shape_1$g.shapes[HASH+o];return d?{shape:d}:{antialiased:!0}}else if(a>0)return{antialiased:!0};return{}}drawScene(e,n){var t=this.getLayer(),a=e||t&&t.getCanvas();return this._fire(BEFORE_DRAW,{node:this}),this.clearBeforeDraw()&&a.getContext().clear(),Container_1$1.Container.prototype.drawScene.call(this,a,n),this._fire(DRAW,{node:this}),this}drawHit(e,n){var t=this.getLayer(),a=e||t&&t.hitCanvas;return t&&t.clearBeforeDraw()&&t.getHitCanvas().getContext().clear(),Container_1$1.Container.prototype.drawHit.call(this,a,n),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,n=!!this.hitCanvas._canvas.parentNode;n?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 n=e.getType();n!=="Group"&&n!=="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$3={};Object.defineProperty(Animation$3,"__esModule",{value:!0});Animation$3.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$2=class au{constructor(e,n){this.id=au.animIdCounter++,this.frame={time:0,timeDiff:0,lastTime:now(),frameRate:0},this.func=e,this.setLayers(n)}setLayers(e){let n=[];return e&&(n=Array.isArray(e)?e:[e]),this.layers=n,this}getLayers(){return this.layers}addLayer(e){const n=this.layers,t=n.length;for(let a=0;a<t;a++)if(n[a]._id===e._id)return!1;return this.layers.push(e),!0}isRunning(){const n=au.animations,t=n.length;for(let a=0;a<t;a++)if(n[a].id===this.id)return!0;return!1}start(){return this.stop(),this.frame.timeDiff=0,this.frame.lastTime=now(),au._addAnimation(this),this}stop(){return au._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 n=e.id,t=this.animations,a=t.length;for(let o=0;o<a;o++)if(t[o].id===n){this.animations.splice(o,1);break}}static _runFrames(){const e={},n=this.animations;for(let t=0;t<n.length;t++){const a=n[t],o=a.layers,d=a.func;a._updateFrameObject(now());const h=o.length;let f;if(d?f=d.call(a,a.frame)!==!1:f=!0,!!f)for(let u=0;u<h;u++){const p=o[u];p._id!==void 0&&(e[p._id]=p)}}for(let t in e)e.hasOwnProperty(t)&&e[t].batchDraw()}static _animationLoop(){const e=au;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$3.Animation=Animation$2;Animation$2.animations=[];Animation$2.animIdCounter=0;Animation$2.animRunning=!1;var Tween$1={};(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Easings=l.Tween=void 0;const e=Util,n=Animation$3,t=Node$1,a=Global;var o={node:1,duration:1,easing:1,onFinish:1,yoyo:1},d=1,h=2,f=3,u=0,p=["fill","stroke","shadowColor"];class _{constructor(S,g,v,b,T,y,w){this.prop=S,this.propFunc=g,this.begin=b,this._pos=b,this.duration=y,this._change=0,this.prevPos=0,this.yoyo=w,this._time=0,this._position=0,this._startTime=0,this._finish=0,this.func=v,this._change=T-this.begin,this.pause()}fire(S){var g=this[S];g&&g()}setTime(S){S>this.duration?this.yoyo?(this._time=this.duration,this.reverse()):this.finish():S<0?this.yoyo?(this._time=0,this.play()):this.reset():(this._time=S,this.update())}getTime(){return this._time}setPosition(S){this.prevPos=this._pos,this.propFunc(S),this._pos=S}getPosition(S){return S===void 0&&(S=this._time),this.func(S,this.begin,this._change,this.duration)}play(){this.state=h,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(S){this.pause(),this._time=S,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 S=this.getTimer()-this._startTime;this.state===h?this.setTime(S):this.state===f&&this.setTime(this.duration-S)}pause(){this.state=d,this.fire("onPause")}getTimer(){return new Date().getTime()}}class R{constructor(S){var g=this,v=S.node,b=v._id,T,y=S.easing||l.Easings.Linear,w=!!S.yoyo,C;typeof S.duration>"u"?T=.3:S.duration===0?T=.001:T=S.duration,this.node=v,this._id=u++;var N=v.getLayer()||(v instanceof a.Konva.Stage?v.getLayers():null);N||e.Util.error("Tween constructor have `node` that is not in a layer. Please add node into layer first."),this.anim=new n.Animation(function(){g.tween.onEnterFrame()},N),this.tween=new _(C,function(D){g._tweenFunc(D)},y,0,1,T*1e3,w),this._addListeners(),R.attrs[b]||(R.attrs[b]={}),R.attrs[b][this._id]||(R.attrs[b][this._id]={}),R.tweens[b]||(R.tweens[b]={});for(C in S)o[C]===void 0&&this._addAttr(C,S[C]);this.reset(),this.onFinish=S.onFinish,this.onReset=S.onReset,this.onUpdate=S.onUpdate}_addAttr(S,g){var v=this.node,b=v._id,T,y,w,C,N,D,P,k;if(w=R.tweens[b][S],w&&delete R.attrs[b][w][S],T=v.getAttr(S),e.Util._isArray(g))if(y=[],N=Math.max(g.length,T.length),S==="points"&&g.length!==T.length&&(g.length>T.length?(P=T,T=e.Util._prepareArrayForTween(T,g,v.closed())):(D=g,g=e.Util._prepareArrayForTween(g,T,v.closed()))),S.indexOf("fill")===0)for(C=0;C<N;C++)if(C%2===0)y.push(g[C]-T[C]);else{var F=e.Util.colorToRGBA(T[C]);k=e.Util.colorToRGBA(g[C]),T[C]=F,y.push({r:k.r-F.r,g:k.g-F.g,b:k.b-F.b,a:k.a-F.a})}else for(C=0;C<N;C++)y.push(g[C]-T[C]);else p.indexOf(S)!==-1?(T=e.Util.colorToRGBA(T),k=e.Util.colorToRGBA(g),y={r:k.r-T.r,g:k.g-T.g,b:k.b-T.b,a:k.a-T.a}):y=g-T;R.attrs[b][this._id][S]={start:T,diff:y,end:g,trueEnd:D,trueStart:P},R.tweens[b][S]=this._id}_tweenFunc(S){var g=this.node,v=R.attrs[g._id][this._id],b,T,y,w,C,N,D,P;for(b in v){if(T=v[b],y=T.start,w=T.diff,P=T.end,e.Util._isArray(y))if(C=[],D=Math.max(y.length,P.length),b.indexOf("fill")===0)for(N=0;N<D;N++)N%2===0?C.push((y[N]||0)+w[N]*S):C.push("rgba("+Math.round(y[N].r+w[N].r*S)+","+Math.round(y[N].g+w[N].g*S)+","+Math.round(y[N].b+w[N].b*S)+","+(y[N].a+w[N].a*S)+")");else for(N=0;N<D;N++)C.push((y[N]||0)+w[N]*S);else p.indexOf(b)!==-1?C="rgba("+Math.round(y.r+w.r*S)+","+Math.round(y.g+w.g*S)+","+Math.round(y.b+w.b*S)+","+(y.a+w.a*S)+")":C=y+w*S;g.setAttr(b,C)}}_addListeners(){this.tween.onPlay=()=>{this.anim.start()},this.tween.onReverse=()=>{this.anim.start()},this.tween.onPause=()=>{this.anim.stop()},this.tween.onFinish=()=>{var S=this.node,g=R.attrs[S._id][this._id];g.points&&g.points.trueEnd&&S.setAttr("points",g.points.trueEnd),this.onFinish&&this.onFinish.call(this)},this.tween.onReset=()=>{var S=this.node,g=R.attrs[S._id][this._id];g.points&&g.points.trueStart&&S.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(S){return this.tween.seek(S*1e3),this}pause(){return this.tween.pause(),this}finish(){return this.tween.finish(),this}destroy(){var S=this.node._id,g=this._id,v=R.tweens[S],b;this.pause();for(b in v)delete R.tweens[S][b];delete R.attrs[S][g]}}l.Tween=R,R.attrs={},R.tweens={},t.Node.prototype.to=function(x){var S=x.onFinish;x.node=this,x.onFinish=function(){this.destroy(),S&&S()};var g=new R(x);g.play()},l.Easings={BackEaseIn(x,S,g,v){var b=1.70158;return g*(x/=v)*x*((b+1)*x-b)+S},BackEaseOut(x,S,g,v){var b=1.70158;return g*((x=x/v-1)*x*((b+1)*x+b)+1)+S},BackEaseInOut(x,S,g,v){var b=1.70158;return(x/=v/2)<1?g/2*(x*x*(((b*=1.525)+1)*x-b))+S:g/2*((x-=2)*x*(((b*=1.525)+1)*x+b)+2)+S},ElasticEaseIn(x,S,g,v,b,T){var y=0;return x===0?S:(x/=v)===1?S+g:(T||(T=v*.3),!b||b<Math.abs(g)?(b=g,y=T/4):y=T/(2*Math.PI)*Math.asin(g/b),-(b*Math.pow(2,10*(x-=1))*Math.sin((x*v-y)*(2*Math.PI)/T))+S)},ElasticEaseOut(x,S,g,v,b,T){var y=0;return x===0?S:(x/=v)===1?S+g:(T||(T=v*.3),!b||b<Math.abs(g)?(b=g,y=T/4):y=T/(2*Math.PI)*Math.asin(g/b),b*Math.pow(2,-10*x)*Math.sin((x*v-y)*(2*Math.PI)/T)+g+S)},ElasticEaseInOut(x,S,g,v,b,T){var y=0;return x===0?S:(x/=v/2)===2?S+g:(T||(T=v*(.3*1.5)),!b||b<Math.abs(g)?(b=g,y=T/4):y=T/(2*Math.PI)*Math.asin(g/b),x<1?-.5*(b*Math.pow(2,10*(x-=1))*Math.sin((x*v-y)*(2*Math.PI)/T))+S:b*Math.pow(2,-10*(x-=1))*Math.sin((x*v-y)*(2*Math.PI)/T)*.5+g+S)},BounceEaseOut(x,S,g,v){return(x/=v)<1/2.75?g*(7.5625*x*x)+S:x<2/2.75?g*(7.5625*(x-=1.5/2.75)*x+.75)+S:x<2.5/2.75?g*(7.5625*(x-=2.25/2.75)*x+.9375)+S:g*(7.5625*(x-=2.625/2.75)*x+.984375)+S},BounceEaseIn(x,S,g,v){return g-l.Easings.BounceEaseOut(v-x,0,g,v)+S},BounceEaseInOut(x,S,g,v){return x<v/2?l.Easings.BounceEaseIn(x*2,0,g,v)*.5+S:l.Easings.BounceEaseOut(x*2-v,0,g,v)*.5+g*.5+S},EaseIn(x,S,g,v){return g*(x/=v)*x+S},EaseOut(x,S,g,v){return-g*(x/=v)*(x-2)+S},EaseInOut(x,S,g,v){return(x/=v/2)<1?g/2*x*x+S:-g/2*(--x*(x-2)-1)+S},StrongEaseIn(x,S,g,v){return g*(x/=v)*x*x*x*x+S},StrongEaseOut(x,S,g,v){return g*((x=x/v-1)*x*x*x*x+1)+S},StrongEaseInOut(x,S,g,v){return(x/=v/2)<1?g/2*x*x*x*x*x+S:g/2*((x-=2)*x*x*x*x+2)+S},Linear(x,S,g,v){return g*x/v+S}}})(Tween$1);(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.Konva=void 0;const e=Global,n=Util,t=Node$1,a=Container$2,o=Stage$1,d=Layer$2,h=FastLayer$1,f=Group$2,u=DragAndDrop,p=Shape,_=Animation$3,R=Tween$1,x=Context$2,S=Canvas$1;l.Konva=n.Util._assign(e.Konva,{Util:n.Util,Transform:n.Transform,Node:t.Node,Container:a.Container,Stage:o.Stage,stages:o.stages,Layer:d.Layer,FastLayer:h.FastLayer,Group:f.Group,DD:u.DD,Shape:p.Shape,shapes:p.shapes,Animation:_.Animation,Tween:R.Tween,Easings:R.Easings,Context:x.Context,Canvas:S.Canvas}),l.default=l.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 n=Global_1$g.Konva.getAngle(this.angle()),t=this.clockwise();e.beginPath(),e.arc(0,0,this.outerRadius(),0,n,t),e.arc(0,0,this.innerRadius(),n,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(),n=this.outerRadius(),t=this.clockwise(),a=Global_1$g.Konva.getAngle(t?360-this.angle():this.angle()),o=Math.cos(Math.min(a,Math.PI)),d=1,h=Math.sin(Math.min(Math.max(Math.PI,a),3*Math.PI/2)),f=Math.sin(Math.min(a,Math.PI/2)),u=o*(o>0?e:n),p=d*n,_=h*(h>0?e:n),R=f*(f>0?n:e);return{x:u,y:t?-1*R:_,width:p-u,height:R-_}}}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(l,e,n,t,a,o,d){var h=Math.sqrt(Math.pow(n-l,2)+Math.pow(t-e,2)),f=Math.sqrt(Math.pow(a-n,2)+Math.pow(o-t,2)),u=d*h/(h+f),p=d*f/(h+f),_=n-u*(a-l),R=t-u*(o-e),x=n+p*(a-l),S=t+p*(o-e);return[_,R,x,S]}function expandPoints(l,e){var n=l.length,t=[],a,o;for(a=2;a<n-2;a+=2)o=getControlPoints(l[a-2],l[a-1],l[a],l[a+1],l[a+2],l[a+3],e),!isNaN(o[0])&&(t.push(o[0]),t.push(o[1]),t.push(l[a]),t.push(l[a+1]),t.push(o[2]),t.push(o[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 n=this.points(),t=n.length,a=this.tension(),o=this.closed(),d=this.bezier(),h,f,u;if(t){if(e.beginPath(),e.moveTo(n[0],n[1]),a!==0&&t>4){for(h=this.getTensionPoints(),f=h.length,u=o?0:4,o||e.quadraticCurveTo(h[0],h[1],h[2],h[3]);u<f-2;)e.bezierCurveTo(h[u++],h[u++],h[u++],h[u++],h[u++],h[u++]);o||e.quadraticCurveTo(h[f-2],h[f-1],n[t-2],n[t-1])}else if(d)for(u=2;u<t;)e.bezierCurveTo(n[u++],n[u++],n[u++],n[u++],n[u++],n[u++]);else for(u=2;u<t;u+=2)e.lineTo(n[u],n[u+1]);o?(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(),n=e.length,t=this.tension(),a=getControlPoints(e[n-2],e[n-1],e[0],e[1],e[2],e[3],t),o=getControlPoints(e[n-4],e[n-3],e[n-2],e[n-1],e[0],e[1],t),d=expandPoints(e,t),h=[a[2],a[3]].concat(d).concat([o[0],o[1],e[n-2],e[n-1],o[2],o[3],a[0],a[1],e[0],e[1]]);return h}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 n=e[0],t=e[0],a=e[1],o=e[1],d,h,f=0;f<e.length/2;f++)d=e[f*2],h=e[f*2+1],n=Math.min(n,d),t=Math.max(t,d),a=Math.min(a,h),o=Math.max(o,h);return{x:n,y:a,width:t-n,height:o-a}}};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(l){Object.defineProperty(l,"__esModule",{value:!0}),l.t2length=l.getQuadraticArcLength=l.getCubicArcLength=l.binomialCoefficients=l.cValues=l.tValues=void 0,l.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]],l.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]],l.binomialCoefficients=[[1],[1,1],[1,2,1],[1,3,3,1]];const e=(d,h,f)=>{let u,p,_;u=f/2,p=0;for(let x=0;x<20;x++)_=u*l.tValues[20][x]+u,p+=l.cValues[20][x]*t(d,h,_);return u*p};l.getCubicArcLength=e;const n=(d,h,f)=>{f===void 0&&(f=1);const u=d[0]-2*d[1]+d[2],p=h[0]-2*h[1]+h[2],_=2*d[1]-2*d[0],R=2*h[1]-2*h[0],x=4*(u*u+p*p),S=4*(u*_+p*R),g=_*_+R*R;if(x===0)return f*Math.sqrt(Math.pow(d[2]-d[0],2)+Math.pow(h[2]-h[0],2));const v=S/(2*x),b=g/x,T=f+v,y=b-v*v,w=T*T+y>0?Math.sqrt(T*T+y):0,C=v*v+y>0?Math.sqrt(v*v+y):0,N=v+Math.sqrt(v*v+y)!==0?y*Math.log(Math.abs((T+w)/(v+C))):0;return Math.sqrt(x)/2*(T*w-v*C+N)};l.getQuadraticArcLength=n;function t(d,h,f){const u=a(1,f,d),p=a(1,f,h),_=u*u+p*p;return Math.sqrt(_)}const a=(d,h,f)=>{const u=f.length-1;let p,_;if(u===0)return 0;if(d===0){_=0;for(let R=0;R<=u;R++)_+=l.binomialCoefficients[u][R]*Math.pow(1-h,u-R)*Math.pow(h,R)*f[R];return _}else{p=new Array(u);for(let R=0;R<u;R++)p[R]=u*(f[R+1]-f[R]);return a(d-1,h,p)}},o=(d,h,f)=>{let u=1,p=d/h,_=(d-f(p))/h,R=0;for(;u>.001;){const x=f(p+_),S=Math.abs(d-x)/h;if(S<u)u=S,p+=_;else{const g=f(p-_),v=Math.abs(d-g)/h;v<u?(u=v,p-=_):_/=2}if(R++,R>500)break}return p};l.t2length=o})(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 n=this.dataArray;e.beginPath();for(var t=!1,a=0;a<n.length;a++){var o=n[a].command,d=n[a].points;switch(o){case"L":e.lineTo(d[0],d[1]);break;case"M":e.moveTo(d[0],d[1]);break;case"C":e.bezierCurveTo(d[0],d[1],d[2],d[3],d[4],d[5]);break;case"Q":e.quadraticCurveTo(d[0],d[1],d[2],d[3]);break;case"A":var h=d[0],f=d[1],u=d[2],p=d[3],_=d[4],R=d[5],x=d[6],S=d[7],g=u>p?u:p,v=u>p?1:u/p,b=u>p?p/u:1;e.translate(h,f),e.rotate(x),e.scale(v,b),e.arc(0,0,g,_,_+R,1-S),e.scale(1/v,1/b),e.rotate(-x),e.translate(-h,-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(u){if(u.command==="A"){var p=u.points[4],_=u.points[5],R=u.points[4]+_,x=Math.PI/180;if(Math.abs(p-R)<x&&(x=Math.abs(p-R)),_<0)for(let S=p-x;S>R;S-=x){const g=Path.getPointOnEllipticalArc(u.points[0],u.points[1],u.points[2],u.points[3],S,0);e.push(g.x,g.y)}else for(let S=p+x;S<R;S+=x){const g=Path.getPointOnEllipticalArc(u.points[0],u.points[1],u.points[2],u.points[3],S,0);e.push(g.x,g.y)}}else if(u.command==="C")for(let S=0;S<=1;S+=.01){const g=Path.getPointOnCubicBezier(S,u.start.x,u.start.y,u.points[0],u.points[1],u.points[2],u.points[3],u.points[4],u.points[5]);e.push(g.x,g.y)}else e=e.concat(u.points)});for(var n=e[0],t=e[0],a=e[1],o=e[1],d,h,f=0;f<e.length/2;f++)d=e[f*2],h=e[f*2+1],isNaN(d)||(n=Math.min(n,d),t=Math.max(t,d)),isNaN(h)||(a=Math.min(a,h),o=Math.max(o,h));return{x:n,y:a,width:t-n,height:o-a}}getLength(){return this.pathLength}getPointAtLength(e){return Path.getPointAtLengthOfDataArray(e,this.dataArray)}static getLineLength(e,n,t,a){return Math.sqrt((t-e)*(t-e)+(a-n)*(a-n))}static getPathLength(e){let n=0;for(var t=0;t<e.length;++t)n+=e[t].pathLength;return n}static getPointAtLengthOfDataArray(e,n){var t,a=0,o=n.length;if(!o)return null;for(;a<o&&e>n[a].pathLength;)e-=n[a].pathLength,++a;if(a===o)return t=n[a-1].points.slice(-2),{x:t[0],y:t[1]};if(e<.01)return t=n[a].points.slice(0,2),{x:t[0],y:t[1]};var d=n[a],h=d.points;switch(d.command){case"L":return Path.getPointOnLine(e,d.start.x,d.start.y,h[0],h[1]);case"C":return Path.getPointOnCubicBezier((0,BezierFunctions_1.t2length)(e,Path.getPathLength(n),g=>(0,BezierFunctions_1.getCubicArcLength)([d.start.x,h[0],h[2],h[4]],[d.start.y,h[1],h[3],h[5]],g)),d.start.x,d.start.y,h[0],h[1],h[2],h[3],h[4],h[5]);case"Q":return Path.getPointOnQuadraticBezier((0,BezierFunctions_1.t2length)(e,Path.getPathLength(n),g=>(0,BezierFunctions_1.getQuadraticArcLength)([d.start.x,h[0],h[2]],[d.start.y,h[1],h[3]],g)),d.start.x,d.start.y,h[0],h[1],h[2],h[3]);case"A":var f=h[0],u=h[1],p=h[2],_=h[3],R=h[4],x=h[5],S=h[6];return R+=x*e/d.pathLength,Path.getPointOnEllipticalArc(f,u,p,_,R,S)}return null}static getPointOnLine(e,n,t,a,o,d,h){d===void 0&&(d=n),h===void 0&&(h=t);var f=(o-t)/(a-n+1e-8),u=Math.sqrt(e*e/(1+f*f));a<n&&(u*=-1);var p=f*u,_;if(a===n)_={x:d,y:h+p};else if((h-t)/(d-n+1e-8)===f)_={x:d+u,y:h+p};else{var R,x,S=this.getLineLength(n,t,a,o),g=(d-n)*(a-n)+(h-t)*(o-t);g=g/(S*S),R=n+g*(a-n),x=t+g*(o-t);var v=this.getLineLength(d,h,R,x),b=Math.sqrt(e*e-v*v);u=Math.sqrt(b*b/(1+f*f)),a<n&&(u*=-1),p=f*u,_={x:R+u,y:x+p}}return _}static getPointOnCubicBezier(e,n,t,a,o,d,h,f,u){function p(v){return v*v*v}function _(v){return 3*v*v*(1-v)}function R(v){return 3*v*(1-v)*(1-v)}function x(v){return(1-v)*(1-v)*(1-v)}var S=f*p(e)+d*_(e)+a*R(e)+n*x(e),g=u*p(e)+h*_(e)+o*R(e)+t*x(e);return{x:S,y:g}}static getPointOnQuadraticBezier(e,n,t,a,o,d,h){function f(x){return x*x}function u(x){return 2*x*(1-x)}function p(x){return(1-x)*(1-x)}var _=d*f(e)+a*u(e)+n*p(e),R=h*f(e)+o*u(e)+t*p(e);return{x:_,y:R}}static getPointOnEllipticalArc(e,n,t,a,o,d){var h=Math.cos(d),f=Math.sin(d),u={x:t*Math.cos(o),y:a*Math.sin(o)};return{x:e+(u.x*h-u.y*f),y:n+(u.x*f+u.y*h)}}static parsePathData(e){if(!e)return[];var n=e,t=["m","M","l","L","v","V","h","H","z","Z","c","C","q","Q","t","T","s","S","a","A"];n=n.replace(new RegExp(" ","g"),",");for(var a=0;a<t.length;a++)n=n.replace(new RegExp(t[a],"g"),"|"+t[a]);var o=n.split("|"),d=[],h=[],f=0,u=0,p=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,_;for(a=1;a<o.length;a++){var R=o[a],x=R.charAt(0);for(R=R.slice(1),h.length=0;_=p.exec(R);)h.push(_[0]);for(var S=[],g=0,v=h.length;g<v;g++){if(h[g]==="00"){S.push(0,0);continue}var b=parseFloat(h[g]);isNaN(b)?S.push(0):S.push(b)}for(;S.length>0&&!isNaN(S[0]);){var T="",y=[],w=f,C=u,N,D,P,k,F,M,j,$,B,X;switch(x){case"l":f+=S.shift(),u+=S.shift(),T="L",y.push(f,u);break;case"L":f=S.shift(),u=S.shift(),y.push(f,u);break;case"m":var re=S.shift(),ae=S.shift();if(f+=re,u+=ae,T="M",d.length>2&&d[d.length-1].command==="z"){for(var ee=d.length-2;ee>=0;ee--)if(d[ee].command==="M"){f=d[ee].points[0]+re,u=d[ee].points[1]+ae;break}}y.push(f,u),x="l";break;case"M":f=S.shift(),u=S.shift(),T="M",y.push(f,u),x="L";break;case"h":f+=S.shift(),T="L",y.push(f,u);break;case"H":f=S.shift(),T="L",y.push(f,u);break;case"v":u+=S.shift(),T="L",y.push(f,u);break;case"V":u=S.shift(),T="L",y.push(f,u);break;case"C":y.push(S.shift(),S.shift(),S.shift(),S.shift()),f=S.shift(),u=S.shift(),y.push(f,u);break;case"c":y.push(f+S.shift(),u+S.shift(),f+S.shift(),u+S.shift()),f+=S.shift(),u+=S.shift(),T="C",y.push(f,u);break;case"S":D=f,P=u,N=d[d.length-1],N.command==="C"&&(D=f+(f-N.points[2]),P=u+(u-N.points[3])),y.push(D,P,S.shift(),S.shift()),f=S.shift(),u=S.shift(),T="C",y.push(f,u);break;case"s":D=f,P=u,N=d[d.length-1],N.command==="C"&&(D=f+(f-N.points[2]),P=u+(u-N.points[3])),y.push(D,P,f+S.shift(),u+S.shift()),f+=S.shift(),u+=S.shift(),T="C",y.push(f,u);break;case"Q":y.push(S.shift(),S.shift()),f=S.shift(),u=S.shift(),y.push(f,u);break;case"q":y.push(f+S.shift(),u+S.shift()),f+=S.shift(),u+=S.shift(),T="Q",y.push(f,u);break;case"T":D=f,P=u,N=d[d.length-1],N.command==="Q"&&(D=f+(f-N.points[0]),P=u+(u-N.points[1])),f=S.shift(),u=S.shift(),T="Q",y.push(D,P,f,u);break;case"t":D=f,P=u,N=d[d.length-1],N.command==="Q"&&(D=f+(f-N.points[0]),P=u+(u-N.points[1])),f+=S.shift(),u+=S.shift(),T="Q",y.push(D,P,f,u);break;case"A":k=S.shift(),F=S.shift(),M=S.shift(),j=S.shift(),$=S.shift(),B=f,X=u,f=S.shift(),u=S.shift(),T="A",y=this.convertEndpointToCenterParameterization(B,X,f,u,j,$,k,F,M);break;case"a":k=S.shift(),F=S.shift(),M=S.shift(),j=S.shift(),$=S.shift(),B=f,X=u,f+=S.shift(),u+=S.shift(),T="A",y=this.convertEndpointToCenterParameterization(B,X,f,u,j,$,k,F,M);break}d.push({command:T||x,points:y,start:{x:w,y:C},pathLength:this.calcLength(w,C,T||x,y)})}(x==="z"||x==="Z")&&d.push({command:"z",points:[],start:void 0,pathLength:0})}return d}static calcLength(e,n,t,a){var o,d,h,f,u=Path;switch(t){case"L":return u.getLineLength(e,n,a[0],a[1]);case"C":return(0,BezierFunctions_1.getCubicArcLength)([e,a[0],a[2],a[4]],[n,a[1],a[3],a[5]],1);case"Q":return(0,BezierFunctions_1.getQuadraticArcLength)([e,a[0],a[2]],[n,a[1],a[3]],1);case"A":o=0;var p=a[4],_=a[5],R=a[4]+_,x=Math.PI/180;if(Math.abs(p-R)<x&&(x=Math.abs(p-R)),d=u.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],p,0),_<0)for(f=p-x;f>R;f-=x)h=u.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],f,0),o+=u.getLineLength(d.x,d.y,h.x,h.y),d=h;else for(f=p+x;f<R;f+=x)h=u.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],f,0),o+=u.getLineLength(d.x,d.y,h.x,h.y),d=h;return h=u.getPointOnEllipticalArc(a[0],a[1],a[2],a[3],R,0),o+=u.getLineLength(d.x,d.y,h.x,h.y),o}return 0}static convertEndpointToCenterParameterization(e,n,t,a,o,d,h,f,u){var p=u*(Math.PI/180),_=Math.cos(p)*(e-t)/2+Math.sin(p)*(n-a)/2,R=-1*Math.sin(p)*(e-t)/2+Math.cos(p)*(n-a)/2,x=_*_/(h*h)+R*R/(f*f);x>1&&(h*=Math.sqrt(x),f*=Math.sqrt(x));var S=Math.sqrt((h*h*(f*f)-h*h*(R*R)-f*f*(_*_))/(h*h*(R*R)+f*f*(_*_)));o===d&&(S*=-1),isNaN(S)&&(S=0);var g=S*h*R/f,v=S*-f*_/h,b=(e+t)/2+Math.cos(p)*g-Math.sin(p)*v,T=(n+a)/2+Math.sin(p)*g+Math.cos(p)*v,y=function(F){return Math.sqrt(F[0]*F[0]+F[1]*F[1])},w=function(F,M){return(F[0]*M[0]+F[1]*M[1])/(y(F)*y(M))},C=function(F,M){return(F[0]*M[1]<F[1]*M[0]?-1:1)*Math.acos(w(F,M))},N=C([1,0],[(_-g)/h,(R-v)/f]),D=[(_-g)/h,(R-v)/f],P=[(-1*_-g)/h,(-1*R-v)/f],k=C(D,P);return w(D,P)<=-1&&(k=Math.PI),w(D,P)>=1&&(k=0),d===0&&k>0&&(k=k-2*Math.PI),d===1&&k<0&&(k=k+2*Math.PI),[b,T,h,f,N,k,p,d]}}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 n=Math.PI*2,t=this.points(),a=t,o=this.tension()!==0&&t.length>4;o&&(a=this.getTensionPoints());var d=this.pointerLength(),h=t.length,f,u;if(o){const R=[a[a.length-4],a[a.length-3],a[a.length-2],a[a.length-1],t[h-2],t[h-1]],x=Path_1$2.Path.calcLength(a[a.length-4],a[a.length-3],"C",R),S=Path_1$2.Path.getPointOnQuadraticBezier(Math.min(1,1-d/x),R[0],R[1],R[2],R[3],R[4],R[5]);f=t[h-2]-S.x,u=t[h-1]-S.y}else f=t[h-2]-t[h-4],u=t[h-1]-t[h-3];var p=(Math.atan2(u,f)+n)%n,_=this.pointerWidth();this.pointerAtEnding()&&(e.save(),e.beginPath(),e.translate(t[h-2],t[h-1]),e.rotate(p),e.moveTo(0,0),e.lineTo(-d,_/2),e.lineTo(-d,-_/2),e.closePath(),e.restore(),this.__fillStroke(e)),this.pointerAtBeginning()&&(e.save(),e.beginPath(),e.translate(t[0],t[1]),o?(f=(a[0]+a[2])/2-t[0],u=(a[1]+a[3])/2-t[1]):(f=t[2]-t[0],u=t[3]-t[1]),e.rotate((Math.atan2(-u,-f)+n)%n),e.moveTo(0,0),e.lineTo(-d,_/2),e.lineTo(-d,-_/2),e.closePath(),e.restore(),this.__fillStroke(e))}__fillStroke(e){var n=this.dashEnabled();n&&(this.attrs.dashEnabled=!1,e.setLineDash([])),e.fillStrokeShape(this),n&&(this.attrs.dashEnabled=!0)}getSelfRect(){const e=super.getSelfRect(),n=this.pointerWidth()/2;return{x:e.x-n,y:e.y-n,width:e.width+n*2,height:e.height+n*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 n=this.radiusX(),t=this.radiusY();e.beginPath(),e.save(),n!==t&&e.scale(1,t/n),e.arc(0,0,n,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 Ay 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 n=this.getWidth(),t=this.getHeight(),a=this.cornerRadius(),o=this.attrs.image;let d;if(o){const h=this.attrs.cropWidth,f=this.attrs.cropHeight;h&&f?d=[o,this.cropX(),this.cropY(),h,f,0,0,n,t]:d=[o,0,0,n,t]}(this.hasFill()||this.hasStroke()||a)&&(e.beginPath(),a?Util_1$7.Util.drawRoundedRectPath(e,n,t,a):e.rect(0,0,n,t),e.closePath(),e.fillStrokeShape(this)),o&&(a&&e.clip(),e.drawImage.apply(e,d))}_hitFunc(e){var n=this.width(),t=this.height(),a=this.cornerRadius();e.beginPath(),a?Util_1$7.Util.drawRoundedRectPath(e,n,t,a):e.rect(0,0,n,t),e.closePath(),e.fillStrokeShape(this)}getWidth(){var e,n;return(e=this.attrs.width)!==null&&e!==void 0?e:(n=this.image())===null||n===void 0?void 0:n.width}getHeight(){var e,n;return(e=this.attrs.height)!==null&&e!==void 0?e:(n=this.image())===null||n===void 0?void 0:n.height}static fromURL(e,n,t=null){var a=Util_1$7.Util.createImageElement();a.onload=function(){var o=new Ay({image:a});n(o)},a.onerror=t,a.crossOrigin="Anonymous",a.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(n){this._addListeners(n.child),this._sync()})}getText(){return this.find("Text")[0]}getTag(){return this.find("Tag")[0]}_addListeners(e){var n=this,t,a=function(){n._sync()};for(t=0;t<attrChangeListLen$1;t++)e.on(ATTR_CHANGE_LIST$2[t]+CHANGE_KONVA$1,a)}getWidth(){return this.getText().width()}getHeight(){return this.getText().height()}_sync(){var e=this.getText(),n=this.getTag(),t,a,o,d,h,f,u;if(e&&n){switch(t=e.width(),a=e.height(),o=n.pointerDirection(),d=n.pointerWidth(),u=n.pointerHeight(),h=0,f=0,o){case UP:h=t/2,f=-1*u;break;case RIGHT$1:h=t+d,f=a/2;break;case DOWN:h=t/2,f=a+u;break;case LEFT$1:h=-1*d,f=a/2;break}n.setAttrs({x:-1*h,y:-1*f,width:t,height:a}),e.setAttrs({x:-1*h,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 n=this.width(),t=this.height(),a=this.pointerDirection(),o=this.pointerWidth(),d=this.pointerHeight(),h=this.cornerRadius();let f=0,u=0,p=0,_=0;typeof h=="number"?f=u=p=_=Math.min(h,n/2,t/2):(f=Math.min(h[0]||0,n/2,t/2),u=Math.min(h[1]||0,n/2,t/2),_=Math.min(h[2]||0,n/2,t/2),p=Math.min(h[3]||0,n/2,t/2)),e.beginPath(),e.moveTo(f,0),a===UP&&(e.lineTo((n-o)/2,0),e.lineTo(n/2,-1*d),e.lineTo((n+o)/2,0)),e.lineTo(n-u,0),e.arc(n-u,u,u,Math.PI*3/2,0,!1),a===RIGHT$1&&(e.lineTo(n,(t-d)/2),e.lineTo(n+o,t/2),e.lineTo(n,(t+d)/2)),e.lineTo(n,t-_),e.arc(n-_,t-_,_,0,Math.PI/2,!1),a===DOWN&&(e.lineTo((n+o)/2,t),e.lineTo(n/2,t+d),e.lineTo((n-o)/2,t)),e.lineTo(p,t),e.arc(p,t-p,p,Math.PI/2,Math.PI,!1),a===LEFT$1&&(e.lineTo(0,(t+d)/2),e.lineTo(-1*o,t/2),e.lineTo(0,(t-d)/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,n=0,t=this.pointerWidth(),a=this.pointerHeight(),o=this.pointerDirection(),d=this.width(),h=this.height();return o===UP?(n-=a,h+=a):o===DOWN?h+=a:o===LEFT$1?(e-=t*1.5,d+=t):o===RIGHT$1&&(d+=t*1.5),{x:e,y:n,width:d,height:h}}}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 n=this.cornerRadius(),t=this.width(),a=this.height();e.beginPath(),n?Util_1$6.Util.drawRoundedRectPath(e,t,a,n):e.rect(0,0,t,a),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 n=this._getPoints();e.beginPath(),e.moveTo(n[0].x,n[0].y);for(var t=1;t<n.length;t++)e.lineTo(n[t].x,n[t].y);e.closePath(),e.fillStrokeShape(this)}_getPoints(){const e=this.attrs.sides,n=this.attrs.radius||0,t=[];for(var a=0;a<e;a++)t.push({x:n*Math.sin(a*2*Math.PI/e),y:-1*n*Math.cos(a*2*Math.PI/e)});return t}getSelfRect(){const e=this._getPoints();var n=e[0].x,t=e[0].y,a=e[0].x,o=e[0].y;return e.forEach(d=>{n=Math.min(n,d.x),t=Math.max(t,d.x),a=Math.min(a,d.y),o=Math.max(o,d.y)}),{x:n,y:a,width:t-n,height:o-a}}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$3,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 n=this._updated;return this._updated=!1,n}),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 n=this.animation(),t=this.frameIndex(),a=t*4,o=this.animations()[n],d=this.frameOffsets(),h=o[a+0],f=o[a+1],u=o[a+2],p=o[a+3],_=this.image();if((this.hasFill()||this.hasStroke())&&(e.beginPath(),e.rect(0,0,u,p),e.closePath(),e.fillStrokeShape(this)),_)if(d){var R=d[n],x=t*2;e.drawImage(_,h,f,u,p,R[x+0],R[x+1],u,p)}else e.drawImage(_,h,f,u,p,0,0,u,p)}_hitFunc(e){var n=this.animation(),t=this.frameIndex(),a=t*4,o=this.animations()[n],d=this.frameOffsets(),h=o[a+2],f=o[a+3];if(e.beginPath(),d){var u=d[n],p=t*2;e.rect(u[p+0],u[p+1],h,f)}else e.rect(0,0,h,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(),n=this.animation(),t=this.animations(),a=t[n],o=a.length/4;e<o-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 n=this.innerRadius(),t=this.outerRadius(),a=this.numPoints();e.beginPath(),e.moveTo(0,0-t);for(var o=1;o<a*2;o++){var d=o%2===0?t:n,h=d*Math.sin(o*Math.PI/a),f=-1*d*Math.cos(o*Math.PI/a);e.lineTo(h,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(l){return Array.from(l)}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(l){return l.split(",").map(e=>{e=e.trim();const n=e.indexOf(" ")>=0,t=e.indexOf('"')>=0||e.indexOf("'")>=0;return n&&!t&&(e=`"${e}"`),e}).join(", ")}var dummyContext;function getDummyContext(){return dummyContext||(dummyContext=Util_1$5.Util.createCanvasElement().getContext(CONTEXT_2D),dummyContext)}function _fillFunc$1(l){l.fillText(this._partialText,this._partialTextX,this._partialTextY)}function _strokeFunc$1(l){l.setAttr("miterLimit",2),l.strokeText(this._partialText,this._partialTextX,this._partialTextY)}function checkDefaultFill(l){return l=l||{},!l.fillLinearGradientColorStops&&!l.fillRadialGradientColorStops&&!l.fillPatternImage&&(l.fill=l.fill||"black"),l}let Text$1=class extends Shape_1$3.Shape{constructor(e){super(checkDefaultFill(e)),this._partialTextX=0,this._partialTextY=0;for(var n=0;n<attrChangeListLen;n++)this.on(ATTR_CHANGE_LIST$1[n]+CHANGE_KONVA,this._setTextData);this._setTextData()}_sceneFunc(e){var n=this.textArr,t=n.length;if(this.text()){var a=this.padding(),o=this.fontSize(),d=this.lineHeight()*o,h=this.verticalAlign(),f=this.direction(),u=0,p=this.align(),_=this.getWidth(),R=this.letterSpacing(),x=this.fill(),S=this.textDecoration(),g=S.indexOf("underline")!==-1,v=S.indexOf("line-through")!==-1,b;f=f===INHERIT?e.direction:f;var T=0,T=d/2,y=0,w=0;for(f===RTL&&e.setAttr("direction",f),e.setAttr("font",this._getContextFont()),e.setAttr("textBaseline",MIDDLE),e.setAttr("textAlign",LEFT),h===MIDDLE?u=(this.getHeight()-t*d-a*2)/2:h===BOTTOM&&(u=this.getHeight()-t*d-a*2),e.translate(a,u+a),b=0;b<t;b++){var y=0,w=0,C=n[b],N=C.text,D=C.width,P=C.lastInParagraph,k,F,M;if(e.save(),p===RIGHT?y+=_-D-a*2:p===CENTER&&(y+=(_-D-a*2)/2),g){e.save(),e.beginPath(),e.moveTo(y,T+w+Math.round(o/2)),k=N.split(" ").length-1,F=k===0,M=p===JUSTIFY&&!P?_-a*2:D,e.lineTo(y+Math.round(M),T+w+Math.round(o/2)),e.lineWidth=o/15;const ae=this._getLinearGradient();e.strokeStyle=ae||x,e.stroke(),e.restore()}if(v){e.save(),e.beginPath(),e.moveTo(y,T+w),k=N.split(" ").length-1,F=k===0,M=p===JUSTIFY&&P&&!F?_-a*2:D,e.lineTo(y+Math.round(M),T+w),e.lineWidth=o/15;const ae=this._getLinearGradient();e.strokeStyle=ae||x,e.stroke(),e.restore()}if(f!==RTL&&(R!==0||p===JUSTIFY)){k=N.split(" ").length-1;for(var j=stringToArray(N),$=0;$<j.length;$++){var B=j[$];B===" "&&!P&&p===JUSTIFY&&(y+=(_-a*2-D)/k),this._partialTextX=y,this._partialTextY=T+w,this._partialText=B,e.fillStrokeShape(this),y+=this.measureSize(B).width+R}}else R!==0&&e.setAttr("letterSpacing",`${R}px`),this._partialTextX=y,this._partialTextY=T+w,this._partialText=N,e.fillStrokeShape(this);e.restore(),t>1&&(T+=d)}}}_hitFunc(e){var n=this.getWidth(),t=this.getHeight();e.beginPath(),e.rect(0,0,n,t),e.closePath(),e.fillStrokeShape(this)}setText(e){var n=Util_1$5.Util._isString(e)?e:e==null?"":e+"";return this._setAttr(TEXT,n),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 n=getDummyContext(),t=this.fontSize(),a;return n.save(),n.font=this._getContextFont(),a=n.measureText(e),n.restore(),{width:a.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 n=this.letterSpacing(),t=e.length;return getDummyContext().measureText(e).width+(t?n*(t-1):0)}_setTextData(){var e=this.text().split(`
|
|
72
72
|
`),n=+this.fontSize(),t=0,a=this.lineHeight()*n,o=this.attrs.width,d=this.attrs.height,h=o!==AUTO&&o!==void 0,f=d!==AUTO&&d!==void 0,u=this.padding(),p=o-u*2,_=d-u*2,R=0,x=this.wrap(),S=x!==NONE,g=x!==CHAR&&S,v=this.ellipsis();this.textArr=[],getDummyContext().font=this._getContextFont();for(var b=v?this._getTextWidth(ELLIPSIS):0,T=0,y=e.length;T<y;++T){var w=e[T],C=this._getTextWidth(w);if(h&&C>p)for(;w.length>0;){for(var N=0,D=w.length,P="",k=0;N<D;){var F=N+D>>>1,M=w.slice(0,F+1),j=this._getTextWidth(M)+b;j<=p?(N=F+1,P=M,k=j):D=F}if(P){if(g){var $,B=w[P.length],X=B===SPACE||B===DASH;X&&k<=p?$=P.length:$=Math.max(P.lastIndexOf(SPACE),P.lastIndexOf(DASH))+1,$>0&&(N=$,P=P.slice(0,N),k=this._getTextWidth(P))}P=P.trimRight(),this._addTextLine(P),t=Math.max(t,k),R+=a;var re=this._shouldHandleEllipsis(R);if(re){this._tryToAddEllipsisToLastLine();break}if(w=w.slice(N),w=w.trimLeft(),w.length>0&&(C=this._getTextWidth(w),C<=p)){this._addTextLine(w),R+=a,t=Math.max(t,C);break}}else break}else this._addTextLine(w),R+=a,t=Math.max(t,C),this._shouldHandleEllipsis(R)&&T<y-1&&this._tryToAddEllipsisToLastLine();if(this.textArr[this.textArr.length-1]&&(this.textArr[this.textArr.length-1].lastInParagraph=!0),f&&R+a>_)break}this.textHeight=n,this.textWidth=t}_shouldHandleEllipsis(e){var n=+this.fontSize(),t=this.lineHeight()*n,a=this.attrs.height,o=a!==AUTO&&a!==void 0,d=this.padding(),h=a-d*2,f=this.wrap(),u=f!==NONE;return!u||o&&e+t>h}_tryToAddEllipsisToLastLine(){var e=this.attrs.width,n=e!==AUTO&&e!==void 0,t=this.padding(),a=e-t*2,o=this.ellipsis(),d=this.textArr[this.textArr.length-1];if(!(!d||!o)){if(n){var h=this._getTextWidth(d.text+ELLIPSIS)<a;h||(d.text=d.text.slice(0,d.text.length-3))}this.textArr.splice(this.textArr.length-1,1),this._addTextLine(d.text+ELLIPSIS)}}getStrokeScaleEnabled(){return!0}_useBufferCanvas(){const e=this.textDecoration().indexOf("underline")!==-1||this.textDecoration().indexOf("line-through")!==-1,n=this.hasShadow();return e&&n?!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(l){l.fillText(this.partialText,0,0)}function _strokeFunc(l){l.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 n=this.pathLength;return e-1>n?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 n=this.textDecoration(),t=this.fill(),a=this.fontSize(),o=this.glyphInfo;n==="underline"&&e.beginPath();for(var d=0;d<o.length;d++){e.save();var h=o[d].p0;e.translate(h.x,h.y),e.rotate(o[d].rotation),this.partialText=o[d].text,e.fillStrokeShape(this),n==="underline"&&(d===0&&e.moveTo(0,a/2+1),e.lineTo(a,a/2+1)),e.restore()}n==="underline"&&(e.strokeStyle=t,e.lineWidth=a/20,e.stroke()),e.restore()}_hitFunc(e){e.beginPath();var n=this.glyphInfo;if(n.length>=1){var t=n[0].p0;e.moveTo(t.x,t.y)}for(var a=0;a<n.length;a++){var o=n[a].p1;e.lineTo(o.x,o.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 n=this.dummyCanvas,t=n.getContext("2d");t.save(),t.font=this._getContextFont();var a=t.measureText(e);return t.restore(),{width:a.width,height:parseInt(`${this.fontSize()}`,10)}}_setTextData(){const{width:e,height:n}=this._getTextSize(this.attrs.text);if(this.textWidth=e,this.textHeight=n,this.glyphInfo=[],!this.attrs.data)return null;const t=this.letterSpacing(),a=this.align(),o=this.kerningFunc(),d=Math.max(this.textWidth+((this.attrs.text||"").length-1)*t,0);let h=0;a==="center"&&(h=Math.max(0,this.pathLength/2-d/2)),a==="right"&&(h=Math.max(0,this.pathLength-d));const f=(0,Text_1$1.stringToArray)(this.text());let u=h;for(var p=0;p<f.length;p++){const _=this._getPointAtLength(u);if(!_)return;let R=this._getTextSize(f[p]).width+t;if(f[p]===" "&&a==="justify"){const T=this.text().split(" ").length-1;R+=(this.pathLength-d)/T}const x=this._getPointAtLength(u+R);if(!x)return;const S=Path_1$1.Path.getLineLength(_.x,_.y,x.x,x.y);let g=0;if(o)try{g=o(f[p-1],f[p])*this.fontSize()}catch{g=0}_.x+=g,x.x+=g,this.textWidth+=g;const v=Path_1$1.Path.getPointOnLine(g+S/2,_.x,_.y,x.x,x.y),b=Math.atan2(x.y-_.y,x.x-_.x);this.glyphInfo.push({transposeX:v.x,transposeY:v.y,text:f[p],rotation:b,p0:_,p1:x}),u+=R}}getSelfRect(){if(!this.glyphInfo.length)return{x:0,y:0,width:0,height:0};var e=[];this.glyphInfo.forEach(function(p){e.push(p.p0.x),e.push(p.p0.y),e.push(p.p1.x),e.push(p.p1.y)});for(var n=e[0]||0,t=e[0]||0,a=e[1]||0,o=e[1]||0,d,h,f=0;f<e.length/2;f++)d=e[f*2],h=e[f*2+1],n=Math.min(n,d),t=Math.max(t,d),a=Math.min(a,h),o=Math.max(o,h);var u=this.fontSize();return{x:n-u/2,y:a-u/2,width:t-n+u,height:o-a+u}}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(l=>l+`.${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(l,e,n){if(l==="rotater")return n;e+=Util_1$3.Util.degToRad(ANGLES[l]||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(l){return{x:l.x+l.width/2*Math.cos(l.rotation)+l.height/2*Math.sin(-l.rotation),y:l.y+l.height/2*Math.cos(l.rotation)+l.width/2*Math.sin(l.rotation)}}function rotateAroundPoint(l,e,n){const t=n.x+(l.x-n.x)*Math.cos(e)-(l.y-n.y)*Math.sin(e),a=n.y+(l.x-n.x)*Math.sin(e)+(l.y-n.y)*Math.cos(e);return{...l,rotation:l.rotation+e,x:t,y:a}}function rotateAroundCenter(l,e){const n=getCenter(l);return rotateAroundPoint(l,e,n)}function getSnap(l,e,n){let t=e;for(let a=0;a<l.length;a++){const o=Global_1$1.Konva.getAngle(l[a]),d=Math.abs(o-e)%(Math.PI*2);Math.min(d,Math.PI*2-d)<n&&(t=o)}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 n=e.filter(a=>a.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=n,e.length===1&&this.useSingleNodeRotation()?this.rotation(e[0].getAbsoluteRotation()):this.rotation(0),this._nodes.forEach(a=>{const o=()=>{this.nodes().length===1&&this.useSingleNodeRotation()&&this.rotation(this.nodes()[0].getAbsoluteRotation()),this._resetTransformCache(),!this._transforming&&!this.isDragging()&&this.update()},d=a._attrsAffectingSize.map(h=>h+"Change."+this._getEventNamespace()).join(" ");a.on(d,o),a.on(TRANSFORM_CHANGE_STR.map(h=>h+`.${this._getEventNamespace()}`).join(" "),o),a.on(`absoluteTransformChange.${this._getEventNamespace()}`,o),this._proxyDrag(a)}),this._resetTransformCache();var t=!!this.findOne(".top-left");return t&&this.update(),this}_proxyDrag(e){let n;e.on(`dragstart.${this._getEventNamespace()}`,t=>{n=e.getAbsolutePosition(),!this.isDragging()&&e!==this.findOne(".back")&&this.startDrag(t,!1)}),e.on(`dragmove.${this._getEventNamespace()}`,t=>{if(!n)return;const a=e.getAbsolutePosition(),o=a.x-n.x,d=a.y-n.y;this.nodes().forEach(h=>{if(h===e||h.isDragging())return;const f=h.getAbsolutePosition();h.setAbsolutePosition({x:f.x+o,y:f.y+d}),h.startDrag(t)}),n=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,n=this.rotation(),t){var a=e.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()}),o=e.getAbsoluteScale(t),d=e.getAbsolutePosition(t),h=a.x*o.x-e.offsetX()*o.x,f=a.y*o.y-e.offsetY()*o.y;const u=(Global_1$1.Konva.getAngle(e.getAbsoluteRotation())+Math.PI*2)%(Math.PI*2),p={x:d.x+h*Math.cos(u)+f*Math.sin(-u),y:d.y+f*Math.cos(u)+h*Math.sin(u),width:a.width*o.x,height:a.height*o.y,rotation:u};return rotateAroundPoint(p,-Global_1$1.Konva.getAngle(n),{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 n=[];this.nodes().map(u=>{const p=u.getClientRect({skipTransform:!0,skipShadow:!0,skipStroke:this.ignoreStroke()});var _=[{x:p.x,y:p.y},{x:p.x+p.width,y:p.y},{x:p.x+p.width,y:p.y+p.height},{x:p.x,y:p.y+p.height}],R=u.getAbsoluteTransform();_.forEach(function(x){var S=R.point(x);n.push(S)})});const t=new Util_1$3.Transform;t.rotate(-Global_1$1.Konva.getAngle(this.rotation()));var a=1/0,o=1/0,d=-1/0,h=-1/0;n.forEach(function(u){var p=t.point(u);a===void 0&&(a=d=p.x,o=h=p.y),a=Math.min(a,p.x),o=Math.min(o,p.y),d=Math.max(d,p.x),h=Math.max(h,p.y)}),t.invert();const f=t.point({x:a,y:o});return{x:f.x,y:f.y,width:d-a,height:h-o,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 n=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;n.on("mousedown touchstart",function(a){t._handleMouseDown(a)}),n.on("dragstart",a=>{n.stopDrag(),a.cancelBubble=!0}),n.on("dragend",a=>{a.cancelBubble=!0}),n.on("mouseenter",()=>{var a=Global_1$1.Konva.getAngle(this.rotation()),o=this.rotateAnchorCursor(),d=getCursor(e,a,o);n.getStage().content&&(n.getStage().content.style.cursor=d),this._cursorChange=!0}),n.on("mouseout",()=>{n.getStage().content&&(n.getStage().content.style.cursor=""),this._cursorChange=!1}),this.add(n)}_createBack(){var e=new Shape_1$1.Shape({name:"back",width:0,height:0,draggable:!0,sceneFunc(n,t){var a=t.getParent(),o=a.padding();n.beginPath(),n.rect(-o,-o,t.width()+o*2,t.height()+o*2),n.moveTo(t.width()/2,-o),a.rotateEnabled()&&a.rotateLineVisible()&&n.lineTo(t.width()/2,-a.rotateAnchorOffset()*Util_1$3.Util._sign(t.height())-o),n.fillStrokeShape(t)},hitFunc:(n,t)=>{if(this.shouldOverdrawWholeArea()){var a=this.padding();n.beginPath(),n.rect(-a,-a,t.width()+a*2,t.height()+a*2),n.fillStrokeShape(t)}}});this.add(e),this._proxyDrag(e),e.on("dragstart",n=>{n.cancelBubble=!0}),e.on("dragmove",n=>{n.cancelBubble=!0}),e.on("dragend",n=>{n.cancelBubble=!0}),this.on("dragmove",n=>{this.update()})}_handleMouseDown(e){this._movingAnchorName=e.target.name().split(" ")[0];var n=this._getNodeRect(),t=n.width,a=n.height,o=Math.sqrt(Math.pow(t,2)+Math.pow(a,2));this.sin=Math.abs(a/o),this.cos=Math.abs(t/o),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 d=e.target.getAbsolutePosition(),h=e.target.getStage().getPointerPosition();this._anchorDragOffset={x:h.x-d.x,y:h.y-d.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 n,t,a,o=this.findOne("."+this._movingAnchorName),d=o.getStage();d.setPointersPositions(e);const h=d.getPointerPosition();let f={x:h.x-this._anchorDragOffset.x,y:h.y-this._anchorDragOffset.y};const u=o.getAbsolutePosition();this.anchorDragBoundFunc()&&(f=this.anchorDragBoundFunc()(u,f,e)),o.setAbsolutePosition(f);const p=o.getAbsolutePosition();if(!(u.x===p.x&&u.y===p.y)){if(this._movingAnchorName==="rotater"){var _=this._getNodeRect();n=o.x()-_.width/2,t=-o.y()+_.height/2;let $=Math.atan2(-t,n)+Math.PI/2;_.height<0&&($-=Math.PI);var R=Global_1$1.Konva.getAngle(this.rotation());const B=R+$,X=Global_1$1.Konva.getAngle(this.rotationSnapTolerance()),ae=getSnap(this.rotationSnaps(),B,X)-_.rotation,ee=rotateAroundCenter(_,ae);this._fitNodesInto(ee,e);return}var x=this.shiftBehavior(),S;x==="inverted"?S=this.keepRatio()&&!e.shiftKey:x==="none"?S=this.keepRatio():S=this.keepRatio()||e.shiftKey;var y=this.centeredScaling()||e.altKey;if(this._movingAnchorName==="top-left"){if(S){var g=y?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-right").x(),y:this.findOne(".bottom-right").y()};a=Math.sqrt(Math.pow(g.x-o.x(),2)+Math.pow(g.y-o.y(),2));var v=this.findOne(".top-left").x()>g.x?-1:1,b=this.findOne(".top-left").y()>g.y?-1:1;n=a*this.cos*v,t=a*this.sin*b,this.findOne(".top-left").x(g.x-n),this.findOne(".top-left").y(g.y-t)}}else if(this._movingAnchorName==="top-center")this.findOne(".top-left").y(o.y());else if(this._movingAnchorName==="top-right"){if(S){var g=y?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".bottom-left").x(),y:this.findOne(".bottom-left").y()};a=Math.sqrt(Math.pow(o.x()-g.x,2)+Math.pow(g.y-o.y(),2));var v=this.findOne(".top-right").x()<g.x?-1:1,b=this.findOne(".top-right").y()>g.y?-1:1;n=a*this.cos*v,t=a*this.sin*b,this.findOne(".top-right").x(g.x+n),this.findOne(".top-right").y(g.y-t)}var T=o.position();this.findOne(".top-left").y(T.y),this.findOne(".bottom-right").x(T.x)}else if(this._movingAnchorName==="middle-left")this.findOne(".top-left").x(o.x());else if(this._movingAnchorName==="middle-right")this.findOne(".bottom-right").x(o.x());else if(this._movingAnchorName==="bottom-left"){if(S){var g=y?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-right").x(),y:this.findOne(".top-right").y()};a=Math.sqrt(Math.pow(g.x-o.x(),2)+Math.pow(o.y()-g.y,2));var v=g.x<o.x()?-1:1,b=o.y()<g.y?-1:1;n=a*this.cos*v,t=a*this.sin*b,o.x(g.x-n),o.y(g.y+t)}T=o.position(),this.findOne(".top-left").x(T.x),this.findOne(".bottom-right").y(T.y)}else if(this._movingAnchorName==="bottom-center")this.findOne(".bottom-right").y(o.y());else if(this._movingAnchorName==="bottom-right"){if(S){var g=y?{x:this.width()/2,y:this.height()/2}:{x:this.findOne(".top-left").x(),y:this.findOne(".top-left").y()};a=Math.sqrt(Math.pow(o.x()-g.x,2)+Math.pow(o.y()-g.y,2));var v=this.findOne(".bottom-right").x()<g.x?-1:1,b=this.findOne(".bottom-right").y()<g.y?-1:1;n=a*this.cos*v,t=a*this.sin*b,this.findOne(".bottom-right").x(g.x+n),this.findOne(".bottom-right").y(g.y+t)}}else console.error(new Error("Wrong position argument of selection resizer: "+this._movingAnchorName));var y=this.centeredScaling()||e.altKey;if(y){var w=this.findOne(".top-left"),C=this.findOne(".bottom-right"),N=w.x(),D=w.y(),P=this.getWidth()-C.x(),k=this.getHeight()-C.y();C.move({x:-N,y:-D}),w.move({x:P,y:k})}var F=this.findOne(".top-left").getAbsolutePosition();n=F.x,t=F.y;var M=this.findOne(".bottom-right").x()-this.findOne(".top-left").x(),j=this.findOne(".bottom-right").y()-this.findOne(".top-left").y();this._fitNodesInto({x:n,y:t,width:M,height:j,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 n=this.getNode();this._fire("transformend",{evt:e,target:n}),n&&this._nodes.forEach(t=>{t._fire("transformend",{evt:e,target:t})}),this._movingAnchorName=null}}_fitNodesInto(e,n){var t=this._getNodeRect();const a=1;if(Util_1$3.Util._inRange(e.width,-this.padding()*2-a,a)){this.update();return}if(Util_1$3.Util._inRange(e.height,-this.padding()*2-a,a)){this.update();return}var o=new Util_1$3.Transform;if(o.rotate(Global_1$1.Konva.getAngle(this.rotation())),this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("left")>=0){const R=o.point({x:-this.padding()*2,y:0});e.x+=R.x,e.y+=R.y,e.width+=this.padding()*2,this._movingAnchorName=this._movingAnchorName.replace("left","right"),this._anchorDragOffset.x-=R.x,this._anchorDragOffset.y-=R.y}else if(this._movingAnchorName&&e.width<0&&this._movingAnchorName.indexOf("right")>=0){const R=o.point({x:this.padding()*2,y:0});this._movingAnchorName=this._movingAnchorName.replace("right","left"),this._anchorDragOffset.x-=R.x,this._anchorDragOffset.y-=R.y,e.width+=this.padding()*2}if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("top")>=0){const R=o.point({x:0,y:-this.padding()*2});e.x+=R.x,e.y+=R.y,this._movingAnchorName=this._movingAnchorName.replace("top","bottom"),this._anchorDragOffset.x-=R.x,this._anchorDragOffset.y-=R.y,e.height+=this.padding()*2}else if(this._movingAnchorName&&e.height<0&&this._movingAnchorName.indexOf("bottom")>=0){const R=o.point({x:0,y:this.padding()*2});this._movingAnchorName=this._movingAnchorName.replace("bottom","top"),this._anchorDragOffset.x-=R.x,this._anchorDragOffset.y-=R.y,e.height+=this.padding()*2}if(this.boundBoxFunc()){const R=this.boundBoxFunc()(t,e);R?e=R:Util_1$3.Util.warn("boundBoxFunc returned falsy. You should return new bound rect from it!")}const d=1e7,h=new Util_1$3.Transform;h.translate(t.x,t.y),h.rotate(t.rotation),h.scale(t.width/d,t.height/d);const f=new Util_1$3.Transform,u=e.width/d,p=e.height/d;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(u),Math.abs(p))):(f.translate(e.x,e.y),f.rotate(e.rotation),f.scale(u,p));const _=f.multiply(h.invert());this._nodes.forEach(R=>{var x;const S=R.getParent().getAbsoluteTransform(),g=R.getTransform().copy();g.translate(R.offsetX(),R.offsetY());const v=new Util_1$3.Transform;v.multiply(S.copy().invert()).multiply(_).multiply(S).multiply(g);const b=v.decompose();R.setAttrs(b),this._fire("transform",{evt:n,target:R}),R._fire("transform",{evt:n,target:R}),(x=R.getLayer())===null||x===void 0||x.batchDraw()}),this.rotation(Util_1$3.Util._getRotation(e.rotation)),this._resetTransformCache(),this.update(),this.getLayer().batchDraw()}forceUpdate(){this._resetTransformCache(),this.update()}_batchChangeChild(e,n){this.findOne(e).setAttrs(n)}update(){var e,n=this._getNodeRect();this.rotation(Util_1$3.Util._getRotation(n.rotation));var t=n.width,a=n.height,o=this.enabledAnchors(),d=this.resizeEnabled(),h=this.padding(),f=this.anchorSize();const u=this.find("._anchor");u.forEach(_=>{_.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+h,offsetY:f/2+h,visible:d&&o.indexOf("top-left")>=0}),this._batchChangeChild(".top-center",{x:t/2,y:0,offsetY:f/2+h,visible:d&&o.indexOf("top-center")>=0}),this._batchChangeChild(".top-right",{x:t,y:0,offsetX:f/2-h,offsetY:f/2+h,visible:d&&o.indexOf("top-right")>=0}),this._batchChangeChild(".middle-left",{x:0,y:a/2,offsetX:f/2+h,visible:d&&o.indexOf("middle-left")>=0}),this._batchChangeChild(".middle-right",{x:t,y:a/2,offsetX:f/2-h,visible:d&&o.indexOf("middle-right")>=0}),this._batchChangeChild(".bottom-left",{x:0,y:a,offsetX:f/2+h,offsetY:f/2-h,visible:d&&o.indexOf("bottom-left")>=0}),this._batchChangeChild(".bottom-center",{x:t/2,y:a,offsetY:f/2-h,visible:d&&o.indexOf("bottom-center")>=0}),this._batchChangeChild(".bottom-right",{x:t,y:a,offsetX:f/2-h,offsetY:f/2-h,visible:d&&o.indexOf("bottom-right")>=0}),this._batchChangeChild(".rotater",{x:t/2,y:-this.rotateAnchorOffset()*Util_1$3.Util._sign(a)-h,visible:this.rotateEnabled()}),this._batchChangeChild(".back",{width:t,height:a,visible:this.borderEnabled(),stroke:this.borderStroke(),strokeWidth:this.borderStrokeWidth(),dash:this.borderDash(),x:0,y:0});const p=this.anchorStyleFunc();p&&u.forEach(_=>{p(_)}),(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 n=Node_1$f.Node.prototype.clone.call(this,e);return n}getClientRect(){return this.nodes().length>0?super.getClientRect():{x:0,y:0,width:0,height:0}}}Transformer$1.Transformer=Transformer;function validateAnchors(l){return l instanceof Array||Util_1$3.Util.warn("enabledAnchors value should be an array"),l instanceof Array&&l.forEach(function(e){ANCHORS_NAMES.indexOf(e)===-1&&Util_1$3.Util.warn("Unknown anchor name: "+e+". Available names are: "+ANCHORS_NAMES.join(", "))}),l||[]}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(l,e){var n=l.data,t=l.width,a=l.height,o,d,h,f,u,p,_,R,x,S,g,v,b,T,y,w,C,N,D,P,k,F,M,j,$=e+e+1,B=t-1,X=a-1,re=e+1,ae=re*(re+1)/2,ee=new BlurStack,K=null,ne=ee,ue=null,me=null,J=mul_table[e],H=shg_table[e];for(h=1;h<$;h++)ne=ne.next=new BlurStack,h===re&&(K=ne);for(ne.next=ee,_=p=0,d=0;d<a;d++){for(w=C=N=D=R=x=S=g=0,v=re*(P=n[p]),b=re*(k=n[p+1]),T=re*(F=n[p+2]),y=re*(M=n[p+3]),R+=ae*P,x+=ae*k,S+=ae*F,g+=ae*M,ne=ee,h=0;h<re;h++)ne.r=P,ne.g=k,ne.b=F,ne.a=M,ne=ne.next;for(h=1;h<re;h++)f=p+((B<h?B:h)<<2),R+=(ne.r=P=n[f])*(j=re-h),x+=(ne.g=k=n[f+1])*j,S+=(ne.b=F=n[f+2])*j,g+=(ne.a=M=n[f+3])*j,w+=P,C+=k,N+=F,D+=M,ne=ne.next;for(ue=ee,me=K,o=0;o<t;o++)n[p+3]=M=g*J>>H,M!==0?(M=255/M,n[p]=(R*J>>H)*M,n[p+1]=(x*J>>H)*M,n[p+2]=(S*J>>H)*M):n[p]=n[p+1]=n[p+2]=0,R-=v,x-=b,S-=T,g-=y,v-=ue.r,b-=ue.g,T-=ue.b,y-=ue.a,f=_+((f=o+e+1)<B?f:B)<<2,w+=ue.r=n[f],C+=ue.g=n[f+1],N+=ue.b=n[f+2],D+=ue.a=n[f+3],R+=w,x+=C,S+=N,g+=D,ue=ue.next,v+=P=me.r,b+=k=me.g,T+=F=me.b,y+=M=me.a,w-=P,C-=k,N-=F,D-=M,me=me.next,p+=4;_+=t}for(o=0;o<t;o++){for(C=N=D=w=x=S=g=R=0,p=o<<2,v=re*(P=n[p]),b=re*(k=n[p+1]),T=re*(F=n[p+2]),y=re*(M=n[p+3]),R+=ae*P,x+=ae*k,S+=ae*F,g+=ae*M,ne=ee,h=0;h<re;h++)ne.r=P,ne.g=k,ne.b=F,ne.a=M,ne=ne.next;for(u=t,h=1;h<=e;h++)p=u+o<<2,R+=(ne.r=P=n[p])*(j=re-h),x+=(ne.g=k=n[p+1])*j,S+=(ne.b=F=n[p+2])*j,g+=(ne.a=M=n[p+3])*j,w+=P,C+=k,N+=F,D+=M,ne=ne.next,h<X&&(u+=t);for(p=o,ue=ee,me=K,d=0;d<a;d++)f=p<<2,n[f+3]=M=g*J>>H,M>0?(M=255/M,n[f]=(R*J>>H)*M,n[f+1]=(x*J>>H)*M,n[f+2]=(S*J>>H)*M):n[f]=n[f+1]=n[f+2]=0,R-=v,x-=b,S-=T,g-=y,v-=ue.r,b-=ue.g,T-=ue.b,y-=ue.a,f=o+((f=d+re)<X?f:X)*t<<2,R+=w+=ue.r=n[f],x+=C+=ue.g=n[f+1],S+=N+=ue.b=n[f+2],g+=D+=ue.a=n[f+3],ue=ue.next,v+=P=me.r,b+=k=me.g,T+=F=me.b,y+=M=me.a,w-=P,C-=k,N-=F,D-=M,me=me.next,p+=t}}const Blur=function l(e){var n=Math.round(this.blurRadius());n>0&&filterGaussBlurRGBA(e,n)};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(l){var e=this.brightness()*255,n=l.data,t=n.length,a;for(a=0;a<t;a+=4)n[a]+=e,n[a+1]+=e,n[a+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(l){var e=Math.pow((this.contrast()+100)/100,2),n=l.data,t=n.length,a=150,o=150,d=150,h;for(h=0;h<t;h+=4)a=n[h],o=n[h+1],d=n[h+2],a/=255,a-=.5,a*=e,a+=.5,a*=255,o/=255,o-=.5,o*=e,o+=.5,o*=255,d/=255,d-=.5,d*=e,d+=.5,d*=255,a=a<0?0:a>255?255:a,o=o<0?0:o>255?255:o,d=d<0?0:d>255?255:d,n[h]=a,n[h+1]=o,n[h+2]=d};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(l){var e=this.embossStrength()*10,n=this.embossWhiteLevel()*255,t=this.embossDirection(),a=this.embossBlend(),o=0,d=0,h=l.data,f=l.width,u=l.height,p=f*4,_=u;switch(t){case"top-left":o=-1,d=-1;break;case"top":o=-1,d=0;break;case"top-right":o=-1,d=1;break;case"right":o=0,d=1;break;case"bottom-right":o=1,d=1;break;case"bottom":o=1,d=0;break;case"bottom-left":o=1,d=-1;break;case"left":o=0,d=-1;break;default:Util_1$2.Util.error("Unknown emboss direction: "+t)}do{var R=(_-1)*p,x=o;_+x<1&&(x=0),_+x>u&&(x=0);var S=(_-1+x)*f*4,g=f;do{var v=R+(g-1)*4,b=d;g+b<1&&(b=0),g+b>f&&(b=0);var T=S+(g-1+b)*4,y=h[v]-h[T],w=h[v+1]-h[T+1],C=h[v+2]-h[T+2],N=y,D=N>0?N:-N,P=w>0?w:-w,k=C>0?C:-C;if(P>D&&(N=w),k>D&&(N=C),N*=e,a){var F=h[v]+N,M=h[v+1]+N,j=h[v+2]+N;h[v]=F>255?255:F<0?0:F,h[v+1]=M>255?255:M<0?0:M,h[v+2]=j>255?255:j<0?0:j}else{var $=n-N;$<0?$=0:$>255&&($=255),h[v]=h[v+1]=h[v+2]=$}}while(--g)}while(--_)};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(l,e,n,t,a){var o=n-e,d=a-t,h;return o===0?t+d/2:d===0?t:(h=(l-e)/o,h=d*h+t,h)}const Enhance=function(l){var e=l.data,n=e.length,t=e[0],a=t,o,d=e[1],h=d,f,u=e[2],p=u,_,R,x=this.enhance();if(x!==0){for(R=0;R<n;R+=4)o=e[R+0],o<t?t=o:o>a&&(a=o),f=e[R+1],f<d?d=f:f>h&&(h=f),_=e[R+2],_<u?u=_:_>p&&(p=_);a===t&&(a=255,t=0),h===d&&(h=255,d=0),p===u&&(p=255,u=0);var S,g,v,b,T,y,w,C,N;for(x>0?(g=a+x*(255-a),v=t-x*(t-0),T=h+x*(255-h),y=d-x*(d-0),C=p+x*(255-p),N=u-x*(u-0)):(S=(a+t)*.5,g=a+x*(a-S),v=t+x*(t-S),b=(h+d)*.5,T=h+x*(h-b),y=d+x*(d-b),w=(p+u)*.5,C=p+x*(p-w),N=u+x*(u-w)),R=0;R<n;R+=4)e[R+0]=remap(e[R+0],t,a,v,g),e[R+1]=remap(e[R+1],d,h,y,T),e[R+2]=remap(e[R+2],u,p,N,C)}};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(l){var e=l.data,n=e.length,t,a;for(t=0;t<n;t+=4)a=.34*e[t]+.5*e[t+1]+.16*e[t+2],e[t]=a,e[t+1]=a,e[t+2]=a};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(l){var e=l.data,n=e.length,t=1,a=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,d=this.luminance()*127,h,f=t*a*Math.cos(o*Math.PI/180),u=t*a*Math.sin(o*Math.PI/180),p=.299*t+.701*f+.167*u,_=.587*t-.587*f+.33*u,R=.114*t-.114*f-.497*u,x=.299*t-.299*f-.328*u,S=.587*t+.413*f+.035*u,g=.114*t-.114*f+.293*u,v=.299*t-.3*f+1.25*u,b=.587*t-.586*f-1.05*u,T=.114*t+.886*f-.2*u,y,w,C,N;for(h=0;h<n;h+=4)y=e[h+0],w=e[h+1],C=e[h+2],N=e[h+3],e[h+0]=p*y+_*w+R*C+d,e[h+1]=x*y+S*w+g*C+d,e[h+2]=v*y+b*w+T*C+d,e[h+3]=N};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(l){var e=l.data,n=e.length,t=Math.pow(2,this.value()),a=Math.pow(2,this.saturation()),o=Math.abs(this.hue()+360)%360,d,h=t*a*Math.cos(o*Math.PI/180),f=t*a*Math.sin(o*Math.PI/180),u=.299*t+.701*h+.167*f,p=.587*t-.587*h+.33*f,_=.114*t-.114*h-.497*f,R=.299*t-.299*h-.328*f,x=.587*t+.413*h+.035*f,S=.114*t-.114*h+.293*f,g=.299*t-.3*h+1.25*f,v=.587*t-.586*h-1.05*f,b=.114*t+.886*h-.2*f,T,y,w,C;for(d=0;d<n;d+=4)T=e[d+0],y=e[d+1],w=e[d+2],C=e[d+3],e[d+0]=u*T+p*y+_*w,e[d+1]=R*T+x*y+S*w,e[d+2]=g*T+v*y+b*w,e[d+3]=C};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(l){var e=l.data,n=e.length,t;for(t=0;t<n;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(l,e,n){var t=l.data,a=e.data,o=l.width,d=l.height,h=n.polarCenterX||o/2,f=n.polarCenterY||d/2,u,p,_,R=0,x=0,S=0,g=0,v,b=Math.sqrt(h*h+f*f);p=o-h,_=d-f,v=Math.sqrt(p*p+_*_),b=v>b?v:b;var T=d,y=o,w,C,N=360/y*Math.PI/180,D,P;for(C=0;C<y;C+=1)for(D=Math.sin(C*N),P=Math.cos(C*N),w=0;w<T;w+=1)p=Math.floor(h+b*w/T*P),_=Math.floor(f+b*w/T*D),u=(_*o+p)*4,R=t[u+0],x=t[u+1],S=t[u+2],g=t[u+3],u=(C+w*o)*4,a[u+0]=R,a[u+1]=x,a[u+2]=S,a[u+3]=g},FromPolar=function(l,e,n){var t=l.data,a=e.data,o=l.width,d=l.height,h=n.polarCenterX||o/2,f=n.polarCenterY||d/2,u,p,_,R,x,S=0,g=0,v=0,b=0,T,y=Math.sqrt(h*h+f*f);p=o-h,_=d-f,T=Math.sqrt(p*p+_*_),y=T>y?T:y;var w=d,C=o,N,D,P=n.polarRotation||0,k,F;for(p=0;p<o;p+=1)for(_=0;_<d;_+=1)R=p-h,x=_-f,N=Math.sqrt(R*R+x*x)*w/y,D=(Math.atan2(x,R)*180/Math.PI+360+P)%360,D=D*C/360,k=Math.floor(D),F=Math.floor(N),u=(F*o+k)*4,S=t[u+0],g=t[u+1],v=t[u+2],b=t[u+3],u=(_*o+p)*4,a[u+0]=S,a[u+1]=g,a[u+2]=v,a[u+3]=b};const Kaleidoscope=function(l){var e=l.width,n=l.height,t,a,o,d,h,f,u,p,_,R,x=Math.round(this.kaleidoscopePower()),S=Math.round(this.kaleidoscopeAngle()),g=Math.floor(e*(S%360)/360);if(!(x<1)){var v=Util_1$1.Util.createCanvasElement();v.width=e,v.height=n;var b=v.getContext("2d").getImageData(0,0,e,n);Util_1$1.Util.releaseCanvas(v),ToPolar(l,b,{polarCenterX:e/2,polarCenterY:n/2});for(var T=e/Math.pow(2,x);T<=8;)T=T*2,x-=1;T=Math.ceil(T);var y=T,w=0,C=y,N=1;for(g+T>e&&(w=y,C=0,N=-1),a=0;a<n;a+=1)for(t=w;t!==C;t+=N)o=Math.round(t+g)%e,_=(e*a+o)*4,h=b.data[_+0],f=b.data[_+1],u=b.data[_+2],p=b.data[_+3],R=(e*a+t)*4,b.data[R+0]=h,b.data[R+1]=f,b.data[R+2]=u,b.data[R+3]=p;for(a=0;a<n;a+=1)for(y=Math.floor(T),d=0;d<x;d+=1){for(t=0;t<y+1;t+=1)_=(e*a+t)*4,h=b.data[_+0],f=b.data[_+1],u=b.data[_+2],p=b.data[_+3],R=(e*a+y*2-t-1)*4,b.data[R+0]=h,b.data[R+1]=f,b.data[R+2]=u,b.data[R+3]=p;y*=2}FromPolar(b,l,{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(l,e,n){var t=(n*l.width+e)*4,a=[];return a.push(l.data[t++],l.data[t++],l.data[t++],l.data[t++]),a}function rgbDistance(l,e){return Math.sqrt(Math.pow(l[0]-e[0],2)+Math.pow(l[1]-e[1],2)+Math.pow(l[2]-e[2],2))}function rgbMean(l){for(var e=[0,0,0],n=0;n<l.length;n++)e[0]+=l[n][0],e[1]+=l[n][1],e[2]+=l[n][2];return e[0]/=l.length,e[1]/=l.length,e[2]/=l.length,e}function backgroundMask(l,e){var n=pixelAt(l,0,0),t=pixelAt(l,l.width-1,0),a=pixelAt(l,0,l.height-1),o=pixelAt(l,l.width-1,l.height-1),d=e||10;if(rgbDistance(n,t)<d&&rgbDistance(t,o)<d&&rgbDistance(o,a)<d&&rgbDistance(a,n)<d){for(var h=rgbMean([t,n,o,a]),f=[],u=0;u<l.width*l.height;u++){var p=rgbDistance(h,[l.data[u*4],l.data[u*4+1],l.data[u*4+2]]);f[u]=p<d?0:255}return f}}function applyMask(l,e){for(var n=0;n<l.width*l.height;n++)l.data[4*n+3]=e[n]}function erodeMask(l,e,n){for(var t=[1,1,1,1,0,1,1,1,1],a=Math.round(Math.sqrt(t.length)),o=Math.floor(a/2),d=[],h=0;h<n;h++)for(var f=0;f<e;f++){for(var u=h*e+f,p=0,_=0;_<a;_++)for(var R=0;R<a;R++){var x=h+_-o,S=f+R-o;if(x>=0&&x<n&&S>=0&&S<e){var g=x*e+S,v=t[_*a+R];p+=l[g]*v}}d[u]=p===255*8?255:0}return d}function dilateMask(l,e,n){for(var t=[1,1,1,1,1,1,1,1,1],a=Math.round(Math.sqrt(t.length)),o=Math.floor(a/2),d=[],h=0;h<n;h++)for(var f=0;f<e;f++){for(var u=h*e+f,p=0,_=0;_<a;_++)for(var R=0;R<a;R++){var x=h+_-o,S=f+R-o;if(x>=0&&x<n&&S>=0&&S<e){var g=x*e+S,v=t[_*a+R];p+=l[g]*v}}d[u]=p>=255*4?255:0}return d}function smoothEdgeMask(l,e,n){for(var t=[.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111,.1111111111111111],a=Math.round(Math.sqrt(t.length)),o=Math.floor(a/2),d=[],h=0;h<n;h++)for(var f=0;f<e;f++){for(var u=h*e+f,p=0,_=0;_<a;_++)for(var R=0;R<a;R++){var x=h+_-o,S=f+R-o;if(x>=0&&x<n&&S>=0&&S<e){var g=x*e+S,v=t[_*a+R];p+=l[g]*v}}d[u]=p}return d}const Mask=function(l){var e=this.threshold(),n=backgroundMask(l,e);return n&&(n=erodeMask(n,l.width,l.height),n=dilateMask(n,l.width,l.height),n=smoothEdgeMask(n,l.width,l.height),applyMask(l,n)),l};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(l){var e=this.noise()*255,n=l.data,t=n.length,a=e/2,o;for(o=0;o<t;o+=4)n[o+0]+=a-2*a*Math.random(),n[o+1]+=a-2*a*Math.random(),n[o+2]+=a-2*a*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(l){var e=Math.ceil(this.pixelSize()),n=l.width,t=l.height,a,o,d,h,f,u,p,_=Math.ceil(n/e),R=Math.ceil(t/e),x,S,g,v,b,T,y,w=l.data;if(e<=0){Util_1.Util.error("pixelSize value can not be <= 0");return}for(b=0;b<_;b+=1)for(T=0;T<R;T+=1){for(h=0,f=0,u=0,p=0,x=b*e,S=x+e,g=T*e,v=g+e,y=0,a=x;a<S;a+=1)if(!(a>=n))for(o=g;o<v;o+=1)o>=t||(d=(n*o+a)*4,h+=w[d+0],f+=w[d+1],u+=w[d+2],p+=w[d+3],y+=1);for(h=h/y,f=f/y,u=u/y,p=p/y,a=x;a<S;a+=1)if(!(a>=n))for(o=g;o<v;o+=1)o>=t||(d=(n*o+a)*4,w[d+0]=h,w[d+1]=f,w[d+2]=u,w[d+3]=p)}};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(l){var e=Math.round(this.levels()*254)+1,n=l.data,t=n.length,a=255/e,o;for(o=0;o<t;o+=1)n[o]=Math.floor(n[o]/a)*a};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(l){var e=l.data,n=e.length,t=this.red(),a=this.green(),o=this.blue(),d,h;for(d=0;d<n;d+=4)h=(.34*e[d]+.5*e[d+1]+.16*e[d+2])/255,e[d]=h*t,e[d+1]=h*a,e[d+2]=h*o,e[d+3]=e[d+3]};RGB$1.RGB=RGB;Factory_1$2.Factory.addGetterSetter(Node_1$2.Node,"red",0,function(l){return this._filterUpToDate=!1,l>255?255:l<0?0:Math.round(l)});Factory_1$2.Factory.addGetterSetter(Node_1$2.Node,"green",0,function(l){return this._filterUpToDate=!1,l>255?255:l<0?0:Math.round(l)});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(l){var e=l.data,n=e.length,t=this.red(),a=this.green(),o=this.blue(),d=this.alpha(),h,f;for(h=0;h<n;h+=4)f=1-d,e[h]=t*d+e[h]*f,e[h+1]=a*d+e[h+1]*f,e[h+2]=o*d+e[h+2]*f};RGBA$1.RGBA=RGBA;Factory_1$1.Factory.addGetterSetter(Node_1$1.Node,"red",0,function(l){return this._filterUpToDate=!1,l>255?255:l<0?0:Math.round(l)});Factory_1$1.Factory.addGetterSetter(Node_1$1.Node,"green",0,function(l){return this._filterUpToDate=!1,l>255?255:l<0?0:Math.round(l)});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(l){return this._filterUpToDate=!1,l>1?1:l<0?0:l});var Sepia$1={};Object.defineProperty(Sepia$1,"__esModule",{value:!0});Sepia$1.Sepia=void 0;const Sepia=function(l){var e=l.data,n=e.length,t,a,o,d;for(t=0;t<n;t+=4)a=e[t+0],o=e[t+1],d=e[t+2],e[t+0]=Math.min(255,a*.393+o*.769+d*.189),e[t+1]=Math.min(255,a*.349+o*.686+d*.168),e[t+2]=Math.min(255,a*.272+o*.534+d*.131)};Sepia$1.Sepia=Sepia;var Solarize$1={};Object.defineProperty(Solarize$1,"__esModule",{value:!0});Solarize$1.Solarize=void 0;const Solarize=function(l){var e=l.data,n=l.width,t=l.height,a=n*4,o=t;do{var d=(o-1)*a,h=n;do{var f=d+(h-1)*4,u=e[f],p=e[f+1],_=e[f+2];u>127&&(u=255-u),p>127&&(p=255-p),_>127&&(_=255-_),e[f]=u,e[f+1]=p,e[f+2]=_}while(--h)}while(--o)};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(l){var e=this.threshold()*255,n=l.data,t=n.length,a;for(a=0;a<t;a+=1)n[a]=n[a]<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(l,e){Object.defineProperty(e,"__esModule",{value:!0}),e.Konva=void 0;var n=_CoreInternals;Object.defineProperty(e,"Konva",{enumerable:!0,get:function(){return n.Konva}});const t=_CoreInternals;l.exports=t.Konva})(Core,Core.exports);var CoreExports=Core.exports;const Konva=getDefaultExportFromCjs(CoreExports);var reactReconciler={exports:{}},scheduler={exports:{}},scheduler_production_min={};/**
|