(function(I,x){typeof exports=="object"&&typeof module!="undefined"?x(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],x):(I=typeof globalThis!="undefined"?globalThis:I||self,x(I["vue3-image-vue"]={},I.Vue))})(this,function(I,x){"use strict";var R="",B=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},L={exports:{}};(function(b,S){(function(m){var y="jsMind",j="0.4.6",w="hizzgdev@163.com",z=function(){},d=typeof console=="undefined"?{log:z,debug:z,error:z,warn:z,info:z}:console;if(!b.exports&&typeof m[y]!="undefined"){d.log(y+" has been already exist.");return}var T=m.document,s=function(e){return T.getElementById(e)},l=function(e){return T.createElement(e)},u=function(e,t){e.hasChildNodes()?e.firstChild.nodeValue=t:e.appendChild(T.createTextNode(t))},v=function(e,t){e.innerHTML=t},f=function(e){return!!e&&typeof e=="object"&&e.nodeType===1&&typeof e.style=="object"&&typeof e.ownerDocument=="object"};typeof String.prototype.startsWith!="function"&&(String.prototype.startsWith=function(e){return this.slice(0,e.length)===e});var p={container:"",editable:!1,theme:null,mode:"full",support_html:!0,view:{hmargin:100,vmargin:50,line_width:2,line_color:"#555"},layout:{hspace:30,vspace:20,pspace:13},default_event_handle:{enable_mousedown_handle:!0,enable_click_handle:!0,enable_dblclick_handle:!0},shortcut:{enable:!0,handles:{},mapping:{addchild:45,addbrother:13,editnode:113,delnode:46,toggle:32,left:37,up:38,right:39,down:40}}},r=function(e){r.current=this,this.version=j;var t={};if(r.util.json.merge(t,p),r.util.json.merge(t,e),!t.container){d.error("the options.container should not be null or empty.");return}this.options=t,this.inited=!1,this.mind=null,this.event_handles=[],this.init()};r.direction={left:-1,center:0,right:1},r.event_type={show:1,resize:2,edit:3,select:4},r.node=function(e,t,i,n,a,o,h,_){if(!e){d.error("invalid nodeid");return}if(typeof t!="number"){d.error("invalid node index");return}typeof _=="undefined"&&(_=!0),this.id=e,this.index=t,this.topic=i,this.data=n||{},this.isroot=a,this.parent=o,this.direction=h,this.expanded=!!_,this.children=[],this._data={}},r.node.compare=function(e,t){var i=0,n=e.index,a=t.index;return n>=0&&a>=0?i=n-a:n==-1&&a==-1?i=0:n==-1?i=1:a==-1?i=-1:i=0,i},r.node.inherited=function(e,t){if(!!e&&!!t){if(e.id===t.id||e.isroot)return!0;for(var i=e.id,n=t;!n.isroot;)if(n=n.parent,n.id===i)return!0}return!1},r.node.prototype={get_location:function(){var e=this._data.view;return{x:e.abs_x,y:e.abs_y}},get_size:function(){var e=this._data.view;return{w:e.width,h:e.height}}},r.mind=function(){this.name=null,this.author=null,this.version=null,this.root=null,this.selected=null,this.nodes={}},r.mind.prototype={get_node:function(e){return e in this.nodes?this.nodes[e]:(d.warn("the node[id="+e+"] can not be found"),null)},set_root:function(e,t,i){this.root==null?(this.root=new r.node(e,0,t,i,!0),this._put_node(this.root)):d.error("root node is already exist")},add_node:function(e,t,i,n,a,o,h){if(!r.util.is_node(e)){var _=this.get_node(e);return _?this.add_node(_,t,i,n,a,o,h):(d.error("the parent_node[id="+e+"] can not be found."),null)}var c=a||-1,g=null;if(e.isroot){var k=r.direction.right;if(isNaN(o)){for(var C=e.children,E=C.length,N=0,M=0;M<E;M++)C[M].direction===r.direction.left?N--:N++;k=E>1&&N>0?r.direction.left:r.direction.right}else k=o!=r.direction.left?r.direction.right:r.direction.left;g=new r.node(t,c,i,n,!1,e,k,h)}else g=new r.node(t,c,i,n,!1,e,e.direction,h);return this._put_node(g)?(e.children.push(g),this._reindex(e)):(d.error("fail, the nodeid '"+g.id+"' has been already exist."),g=null),g},insert_node_before:function(e,t,i,n){if(!r.util.is_node(e)){var a=this.get_node(e);return a?this.insert_node_before(a,t,i,n):(d.error("the node_before[id="+e+"] can not be found."),null)}var o=e.index-.5;return this.add_node(e.parent,t,i,n,o)},get_node_before:function(e){if(!r.util.is_node(e)){var t=this.get_node(e);return t?this.get_node_before(t):(d.error("the node[id="+e+"] can not be found."),null)}if(e.isroot)return null;var i=e.index-2;return i>=0?e.parent.children[i]:null},insert_node_after:function(e,t,i,n){if(!r.util.is_node(e)){var a=this.get_node(node_before);return a?this.insert_node_after(a,t,i,n):(d.error("the node_after[id="+e+"] can not be found."),null)}var o=e.index+.5;return this.add_node(e.parent,t,i,n,o)},get_node_after:function(e){if(!r.util.is_node(e)){var t=this.get_node(e);return t?this.get_node_after(t):(d.error("the node[id="+e+"] can not be found."),null)}if(e.isroot)return null;var i=e.index,n=e.parent.children;return n.length>=i?e.parent.children[i]:null},move_node:function(e,t,i,n){if(!r.util.is_node(e)){var a=this.get_node(e);return a?this.move_node(a,t,i,n):(d.error("the node[id="+e+"] can not be found."),null)}return i||(i=e.parent.id),this._move_node(e,t,i,n)},_flow_node_direction:function(e,t){typeof t=="undefined"?t=e.direction:e.direction=t;for(var i=e.children.length;i--;)this._flow_node_direction(e.children[i],t)},_move_node_internal:function(e,t){if(!!e&&!!t)if(t=="_last_")e.index=-1,this._reindex(e.parent);else if(t=="_first_")e.index=0,this._reindex(e.parent);else{var i=t?this.get_node(t):null;i!=null&&i.parent!=null&&i.parent.id==e.parent.id&&(e.index=i.index-.5,this._reindex(e.parent))}return e},_move_node:function(e,t,i,n){if(!!e&&!!i){if(e.parent.id!=i){for(var a=e.parent.children,o=a.length;o--;)if(a[o].id==e.id){a.splice(o,1);break}e.parent=this.get_node(i),e.parent.children.push(e)}e.parent.isroot?n==jsMind.direction.left?e.direction=n:e.direction=r.direction.right:e.direction=e.parent.direction,this._move_node_internal(e,t),this._flow_node_direction(e)}return e},remove_node:function(e){if(!r.util.is_node(e)){var t=this.get_node(e);return t?this.remove_node(t):(d.error("the node[id="+e+"] can not be found."),!1)}if(!e)return d.error("fail, the node can not be found"),!1;if(e.isroot)return d.error("fail, can not remove root node"),!1;this.selected!=null&&this.selected.id==e.id&&(this.selected=null);for(var i=e.children,n=i.length;n--;)this.remove_node(i[n]);i.length=0;for(var a=e.parent.children,o=a.length;o--;)if(a[o].id==e.id){a.splice(o,1);break}delete this.nodes[e.id];for(var h in e)delete e[h];return e=null,!0},_put_node:function(e){return e.id in this.nodes?(d.warn("the nodeid '"+e.id+"' has been already exist."),!1):(this.nodes[e.id]=e,!0)},_reindex:function(e){if(e instanceof r.node){e.children.sort(r.node.compare);for(var t=0;t<e.children.length;t++)e.children[t].index=t+1}}},r.format={node_tree:{example:{meta:{name:y,author:w,version:j},format:"node_tree",data:{id:"root",topic:"jsMind Example"}},get_mind:function(e){var t=r.format.node_tree,i=new r.mind;return i.name=e.meta.name,i.author=e.meta.author,i.version=e.meta.version,t._parse(i,e.data),i},get_data:function(e){var t=r.format.node_tree,i={};return i.meta={name:e.name,author:e.author,version:e.version},i.format="node_tree",i.data=t._buildnode(e.root),i},_parse:function(e,t){var i=r.format.node_tree,n=i._extract_data(t);if(e.set_root(t.id,t.topic,n),"children"in t)for(var a=t.children,o=0;o<a.length;o++)i._extract_subnode(e,e.root,a[o])},_extract_data:function(e){var t={};for(var i in e)i=="id"||i=="topic"||i=="children"||i=="direction"||i=="expanded"||(t[i]=e[i]);return t},_extract_subnode:function(e,t,i){var n=r.format.node_tree,a=n._extract_data(i),o=null;t.isroot&&(o=i.direction=="left"?r.direction.left:r.direction.right);var h=e.add_node(t,i.id,i.topic,a,null,o,i.expanded);if("children"in i)for(var _=i.children,c=0;c<_.length;c++)n._extract_subnode(e,h,_[c])},_buildnode:function(e){var t=r.format.node_tree;if(e instanceof r.node){var i={id:e.id,topic:e.topic,expanded:e.expanded};if(!!e.parent&&e.parent.isroot&&(i.direction=e.direction==r.direction.left?"left":"right"),e.data!=null){var n=e.data;for(var a in n)i[a]=n[a]}var o=e.children;if(o.length>0){i.children=[];for(var h=0;h<o.length;h++)i.children.push(t._buildnode(o[h]))}return i}}},node_array:{example:{meta:{name:y,author:w,version:j},format:"node_array",data:[{id:"root",topic:"jsMind Example",isroot:!0}]},get_mind:function(e){var t=r.format.node_array,i=new r.mind;return i.name=e.meta.name,i.author=e.meta.author,i.version=e.meta.version,t._parse(i,e.data),i},get_data:function(e){var t=r.format.node_array,i={};return i.meta={name:e.name,author:e.author,version:e.version},i.format="node_array",i.data=[],t._array(e,i.data),i},_parse:function(e,t){var i=r.format.node_array,n=t.slice(0);n.reverse();var a=i._extract_root(e,n);a?i._extract_subnode(e,a,n):d.error("root node can not be found")},_extract_root:function(e,t){for(var i=r.format.node_array,n=t.length;n--;)if("isroot"in t[n]&&t[n].isroot){var a=t[n],o=i._extract_data(a);return e.set_root(a.id,a.topic,o),t.splice(n,1),a.id}return null},_extract_subnode:function(e,t,i){for(var n=r.format.node_array,a=i.length,o=null,h=null,_=0;a--;)if(o=i[a],o.parentid==t){h=n._extract_data(o);var c=null,g=o.direction;g&&(c=g=="left"?r.direction.left:r.direction.right),e.add_node(t,o.id,o.topic,h,null,c,o.expanded),i.splice(a,1),_++;var k=n._extract_subnode(e,o.id,i);k>0&&(a=i.length,_+=k)}return _},_extract_data:function(e){var t={};for(var i in e)i=="id"||i=="topic"||i=="parentid"||i=="isroot"||i=="direction"||i=="expanded"||(t[i]=e[i]);return t},_array:function(e,t){var i=r.format.node_array;i._array_node(e.root,t)},_array_node:function(e,t){var i=r.format.node_array;if(e instanceof r.node){var n={id:e.id,topic:e.topic,expanded:e.expanded};if(e.parent&&(n.parentid=e.parent.id),e.isroot&&(n.isroot=!0),!!e.parent&&e.parent.isroot&&(n.direction=e.direction==r.direction.left?"left":"right"),e.data!=null){var a=e.data;for(var o in a)n[o]=a[o]}t.push(n);for(var h=e.children.length,_=0;_<h;_++)i._array_node(e.children[_],t)}}},freemind:{example:{meta:{name:y,author:w,version:j},format:"freemind",data:'<map version="1.0.1"><node ID="root" TEXT="freemind Example"/></map>'},get_mind:function(e){var t=r.format.freemind,i=new r.mind;i.name=e.meta.name,i.author=e.meta.author,i.version=e.meta.version;var n=e.data,a=t._parse_xml(n),o=t._find_root(a);return t._load_node(i,null,o),i},get_data:function(e){var t=r.format.freemind,i={};i.meta={name:e.name,author:e.author,version:e.version},i.format="freemind";var n=[];return n.push('<map version="1.0.1">'),t._buildmap(e.root,n),n.push("</map>"),i.data=n.join(" "),i},_parse_xml:function(e){var t=null;if(window.DOMParser){var i=new DOMParser;t=i.parseFromString(e,"text/xml")}else t=new ActiveXObject("Microsoft.XMLDOM"),t.async=!1,t.loadXML(e);return t},_find_root:function(e){for(var t=e.childNodes,i=null,n=null,a=0;a<t.length;a++)if(n=t[a],n.nodeType==1&&n.tagName=="map"){i=n;break}if(i){var o=i.childNodes;i=null;for(var a=0;a<o.length;a++)if(n=o[a],n.nodeType==1&&n.tagName=="node"){i=n;break}}return i},_load_node:function(e,t,i){var n=r.format.freemind,a=i.getAttribute("ID"),o=i.getAttribute("TEXT");if(o==null){for(var h=i.childNodes,_=null,c=0;c<h.length;c++)if(_=h[c],_.nodeType==1&&_.tagName==="richcontent"){o=_.textContent;break}}var g=n._load_attributes(i),k="expanded"in g?g.expanded=="true":!0;delete g.expanded;var C=i.getAttribute("POSITION"),E=null;C&&(E=C=="left"?r.direction.left:r.direction.right),t?e.add_node(t,a,o,g,null,E,k):e.set_root(a,o,g);for(var N=i.childNodes,M=null,c=0;c<N.length;c++)M=N[c],M.nodeType==1&&M.tagName=="node"&&n._load_node(e,a,M)},_load_attributes:function(e){for(var t=e.childNodes,i=null,n={},a=0;a<t.length;a++)i=t[a],i.nodeType==1&&i.tagName==="attribute"&&(n[i.getAttribute("NAME")]=i.getAttribute("VALUE"));return n},_buildmap:function(e,t){var i=r.format.freemind,n=null;!!e.parent&&e.parent.isroot&&(n=e.direction===r.direction.left?"left":"right"),t.push("<node"),t.push('ID="'+e.id+'"'),n&&t.push('POSITION="'+n+'"'),t.push('TEXT="'+e.topic+'">'),t.push('<attribute NAME="expanded" VALUE="'+e.expanded+'"/>');var a=e.data;if(a!=null)for(var o in a)t.push('<attribute NAME="'+o+'" VALUE="'+a[o]+'"/>');for(var h=e.children,_=0;_<h.length;_++)i._buildmap(h[_],t);t.push("</node>")}}},r.util={is_node:function(e){return!!e&&e instanceof r.node},ajax:{_xhr:function(){var e=null;if(window.XMLHttpRequest)e=new XMLHttpRequest;else try{e=new ActiveXObject("Microsoft.XMLHTTP")}catch{}return e},_eurl:function(e){return encodeURIComponent(e)},request:function(e,t,i,n,a){var o=r.util.ajax,h=null,_=[];for(var c in t)_.push(o._eurl(c)+"="+o._eurl(t[c]));_.length>0&&(h=_.join("&"));var g=o._xhr();!g||(g.onreadystatechange=function(){if(g.readyState==4)if(g.status==200||g.status==0){if(typeof n=="function"){var k=r.util.json.string2json(g.responseText);k!=null?n(k):n(g.responseText)}}else typeof a=="function"?a(g):d.error("xhr request failed.",g)},i=i||"GET",g.open(i,e,!0),g.setRequestHeader("If-Modified-Since","0"),i=="POST"?(g.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=utf-8"),g.send(h)):g.send())},get:function(e,t){return r.util.ajax.request(e,{},"GET",t)},post:function(e,t,i){return r.util.ajax.request(e,t,"POST",i)}},dom:{add_event:function(e,t,i){e.addEventListener?e.addEventListener(t,i,!1):e.attachEvent("on"+t,i)}},canvas:{bezierto:function(e,t,i,n,a){e.beginPath(),e.moveTo(t,i),e.bezierCurveTo(t+(n-t)*2/3,i,t,a,n,a),e.stroke()},lineto:function(e,t,i,n,a){e.beginPath(),e.moveTo(t,i),e.lineTo(n,a),e.stroke()},clear:function(e,t,i,n,a){e.clearRect(t,i,n,a)}},file:{read:function(e,t){var i=new FileReader;i.onload=function(){typeof t=="function"&&t(this.result,e.name)},i.readAsText(e)},save:function(e,t,i){var n;if(typeof m.Blob=="function")n=new Blob([e],{type:t});else{var a=m.BlobBuilder||m.MozBlobBuilder||m.WebKitBlobBuilder||m.MSBlobBuilder,o=new a;o.append(e),n=o.getBlob(t)}if(navigator.msSaveBlob)navigator.msSaveBlob(n,i);else{var h=m.URL||m.webkitURL,_=h.createObjectURL(n),c=l("a");if("download"in c){c.style.visibility="hidden",c.href=_,c.download=i,T.body.appendChild(c);var g=T.createEvent("MouseEvents");g.initEvent("click",!0,!0),c.dispatchEvent(g),T.body.removeChild(c)}else location.href=_}}},json:{json2string:function(e){if(JSON)try{var t=JSON.stringify(e);return t}catch(i){return d.warn(i),d.warn("can not convert to string"),null}},string2json:function(e){if(JSON)try{var t=JSON.parse(e);return t}catch(i){return d.warn(i),d.warn("can not parse to json"),null}},merge:function(e,t){for(var i in t)i in e&&typeof e[i]=="object"&&Object.prototype.toString.call(e[i]).toLowerCase()=="[object object]"&&!e[i].length?r.util.json.merge(e[i],t[i]):e[i]=t[i];return e}},uuid:{newid:function(){return(new Date().getTime().toString(16)+Math.random().toString(16).substr(2)).substr(2,16)}},text:{is_empty:function(e){return e?e.replace(/\s*/,"").length==0:!0}}},r.prototype={init:function(){if(!this.inited){this.inited=!0;var e=this.options,t={mode:e.mode,hspace:e.layout.hspace,vspace:e.layout.vspace,pspace:e.layout.pspace},i={container:e.container,support_html:e.support_html,hmargin:e.view.hmargin,vmargin:e.view.vmargin,line_width:e.view.line_width,line_color:e.view.line_color};this.data=new r.data_provider(this),this.layout=new r.layout_provider(this,t),this.view=new r.view_provider(this,i),this.shortcut=new r.shortcut_provider(this,e.shortcut),this.data.init(),this.layout.init(),this.view.init(),this.shortcut.init(),this._event_bind(),r.init_plugins(this)}},enable_edit:function(){this.options.editable=!0},disable_edit:function(){this.options.editable=!1},enable_event_handle:function(e){this.options.default_event_handle["enable_"+e+"_handle"]=!0},disable_event_handle:function(e){this.options.default_event_handle["enable_"+e+"_handle"]=!1},get_editable:function(){return this.options.editable},set_theme:function(e){var t=this.options.theme;this.options.theme=e||null,t!=this.options.theme&&(this.view.reset_theme(),this.view.reset_custom_style())},_event_bind:function(){this.view.add_event(this,"mousedown",this.mousedown_handle),this.view.add_event(this,"click",this.click_handle),this.view.add_event(this,"dblclick",this.dblclick_handle)},mousedown_handle:function(e){if(!!this.options.default_event_handle.enable_mousedown_handle){var t=e.target||event.srcElement,i=this.view.get_binded_nodeid(t);i?this.select_node(i):this.select_clear()}},click_handle:function(e){if(!!this.options.default_event_handle.enable_click_handle){var t=e.target||event.srcElement,i=this.view.is_expander(t);if(i){var n=this.view.get_binded_nodeid(t);n&&this.toggle_node(n)}}},dblclick_handle:function(e){if(!!this.options.default_event_handle.enable_dblclick_handle&&this.get_editable()){var t=e.target||event.srcElement,i=this.view.get_binded_nodeid(t);i&&this.begin_edit(i)}},begin_edit:function(e){if(!r.util.is_node(e)){var t=this.get_node(e);return t?this.begin_edit(t):(d.error("the node[id="+e+"] can not be found."),!1)}if(this.get_editable())this.view.edit_node_begin(e);else{d.error("fail, this mind map is not editable.");return}},end_edit:function(){this.view.edit_node_end()},toggle_node:function(e){if(!r.util.is_node(e)){var t=this.get_node(e);if(t)return this.toggle_node(t);d.error("the node[id="+e+"] can not be found.");return}e.isroot||(this.view.save_location(e),this.layout.toggle_node(e),this.view.relayout(),this.view.restore_location(e))},expand_node:function(e){if(!r.util.is_node(e)){var t=this.get_node(e);if(t)return this.expand_node(t);d.error("the node[id="+e+"] can not be found.");return}e.isroot||(this.view.save_location(e),this.layout.expand_node(e),this.view.relayout(),this.view.restore_location(e))},collapse_node:function(e){if(!r.util.is_node(e)){var t=this.get_node(e);if(t)return this.collapse_node(t);d.error("the node[id="+e+"] can not be found.");return}e.isroot||(this.view.save_location(e),this.layout.collapse_node(e),this.view.relayout(),this.view.restore_location(e))},expand_all:function(){this.layout.expand_all(),this.view.relayout()},collapse_all:function(){this.layout.collapse_all(),this.view.relayout()},expand_to_depth:function(e){this.layout.expand_to_depth(e),this.view.relayout()},_reset:function(){this.view.reset(),this.layout.reset(),this.data.reset()},_show:function(e){var t=e||r.format.node_array.example;if(this.mind=this.data.load(t),this.mind)d.debug("data.load ok");else{d.error("data.load error");return}this.view.load(),d.debug("view.load ok"),this.layout.layout(),d.debug("layout.layout ok"),this.view.show(!0),d.debug("view.show ok"),this.invoke_event_handle(r.event_type.show,{data:[e]})},show:function(e){this._reset(),this._show(e)},get_meta:function(){return{name:this.mind.name,author:this.mind.author,version:this.mind.version}},get_data:function(e){var t=e||"node_tree";return this.data.get_data(t)},get_root:function(){return this.mind.root},get_node:function(e){return this.mind.get_node(e)},add_node:function(e,t,i,n){if(this.get_editable()){var a=this.mind.add_node(e,t,i,n);return a&&(this.view.add_node(a),this.layout.layout(),this.view.show(!1),this.view.reset_node_custom_style(a),this.expand_node(e),this.invoke_event_handle(r.event_type.edit,{evt:"add_node",data:[e.id,t,i,n],node:t})),a}else return d.error("fail, this mind map is not editable"),null},insert_node_before:function(e,t,i,n){if(this.get_editable()){var a=r.util.is_node(e)?e.id:e,o=this.mind.insert_node_before(e,t,i,n);return o&&(this.view.add_node(o),this.layout.layout(),this.view.show(!1),this.invoke_event_handle(r.event_type.edit,{evt:"insert_node_before",data:[a,t,i,n],node:t})),o}else return d.error("fail, this mind map is not editable"),null},insert_node_after:function(e,t,i,n){if(this.get_editable()){var a=r.util.is_node(e)?e.id:e,o=this.mind.insert_node_after(e,t,i,n);return o&&(this.view.add_node(o),this.layout.layout(),this.view.show(!1),this.invoke_event_handle(r.event_type.edit,{evt:"insert_node_after",data:[a,t,i,n],node:t})),o}else return d.error("fail, this mind map is not editable"),null},remove_node:function(e){if(!r.util.is_node(e)){var t=this.get_node(e);return t?this.remove_node(t):(d.error("the node[id="+e+"] can not be found."),!1)}if(this.get_editable()){if(e.isroot)return d.error("fail, can not remove root node"),!1;var i=e.id,n=e.parent.id,a=this.get_node(n);return this.view.save_location(a),this.view.remove_node(e),this.mind.remove_node(e),this.layout.layout(),this.view.show(!1),this.view.restore_location(a),this.invoke_event_handle(r.event_type.edit,{evt:"remove_node",data:[i],node:n}),!0}else return d.error("fail, this mind map is not editable"),!1},update_node:function(e,t){if(this.get_editable()){if(r.util.text.is_empty(t)){d.warn("fail, topic can not be empty");return}var i=this.get_node(e);if(i){if(i.topic===t){d.info("nothing changed"),this.view.update_node(i);return}i.topic=t,this.view.update_node(i),this.layout.layout(),this.view.show(!1),this.invoke_event_handle(r.event_type.edit,{evt:"update_node",data:[e,t],node:e})}}else{d.error("fail, this mind map is not editable");return}},move_node:function(e,t,i,n){if(this.get_editable()){var a=this.mind.move_node(e,t,i,n);a&&(this.view.update_node(a),this.layout.layout(),this.view.show(!1),this.invoke_event_handle(r.event_type.edit,{evt:"move_node",data:[e,t,i,n],node:e}))}else{d.error("fail, this mind map is not editable");return}},select_node:function(e){if(!r.util.is_node(e)){var t=this.get_node(e);if(t)return this.select_node(t);d.error("the node[id="+e+"] can not be found.");return}!this.layout.is_visible(e)||(this.mind.selected=e,this.view.select_node(e))},get_selected_node:function(){return this.mind?this.mind.selected:null},select_clear:function(){this.mind&&(this.mind.selected=null,this.view.select_clear())},is_node_visible:function(e){return this.layout.is_visible(e)},find_node_before:function(e){if(!r.util.is_node(e)){var t=this.get_node(e);if(t)return this.find_node_before(t);d.error("the node[id="+e+"] can not be found.");return}if(e.isroot)return null;var i=null;if(e.parent.isroot)for(var n=e.parent.children,a=null,o=null,h=0;h<n.length;h++)o=n[h],e.direction===o.direction&&(e.id===o.id&&(i=a),a=o);else i=this.mind.get_node_before(e);return i},find_node_after:function(e){if(!r.util.is_node(e)){var t=this.get_node(e);if(t)return this.find_node_after(t);d.error("the node[id="+e+"] can not be found.");return}if(e.isroot)return null;var i=null;if(e.parent.isroot){for(var n=e.parent.children,a=!1,o=null,h=0;h<n.length;h++)if(o=n[h],e.direction===o.direction){if(a){i=o;break}e.id===o.id&&(a=!0)}}else i=this.mind.get_node_after(e);return i},set_node_color:function(e,t,i){if(this.get_editable()){var n=this.mind.get_node(e);n&&(t&&(n.data["background-color"]=t),i&&(n.data["foreground-color"]=i),this.view.reset_node_custom_style(n))}else return d.error("fail, this mind map is not editable"),null},set_node_font_style:function(e,t,i,n){if(this.get_editable()){var a=this.mind.get_node(e);a&&(t&&(a.data["font-size"]=t),i&&(a.data["font-weight"]=i),n&&(a.data["font-style"]=n),this.view.reset_node_custom_style(a),this.view.update_node(a),this.layout.layout(),this.view.show(!1))}else return d.error("fail, this mind map is not editable"),null},set_node_background_image:function(e,t,i,n,a){if(this.get_editable()){var o=this.mind.get_node(e);o&&(t&&(o.data["background-image"]=t),i&&(o.data.width=i),n&&(o.data.height=n),a&&(o.data["background-rotation"]=a),this.view.reset_node_custom_style(o),this.view.update_node(o),this.layout.layout(),this.view.show(!1))}else return d.error("fail, this mind map is not editable"),null},set_node_background_rotation:function(e,t){if(this.get_editable()){var i=this.mind.get_node(e);if(i){if(!i.data["background-image"])return d.error("fail, only can change rotation angle of node with background image"),null;i.data["background-rotation"]=t,this.view.reset_node_custom_style(i),this.view.update_node(i),this.layout.layout(),this.view.show(!1)}}else return d.error("fail, this mind map is not editable"),null},resize:function(){this.view.resize()},add_event_listener:function(e){typeof e=="function"&&this.event_handles.push(e)},invoke_event_handle:function(e,t){var i=this;m.setTimeout(function(){i._invoke_event_handle(e,t)},0)},_invoke_event_handle:function(e,t){for(var i=this.event_handles.length,n=0;n<i;n++)this.event_handles[n](e,t)}},r.data_provider=function(e){this.jm=e},r.data_provider.prototype={init:function(){d.debug("data.init")},reset:function(){d.debug("data.reset")},load:function(e){var t=null,i=null;return typeof e=="object"?e.format?t=e.format:t="node_tree":t="freemind",t=="node_array"?i=r.format.node_array.get_mind(e):t=="node_tree"?i=r.format.node_tree.get_mind(e):t=="freemind"?i=r.format.freemind.get_mind(e):d.warn("unsupported format"),i},get_data:function(e){var t=null;return e=="node_array"?t=r.format.node_array.get_data(this.jm.mind):e=="node_tree"?t=r.format.node_tree.get_data(this.jm.mind):e=="freemind"?t=r.format.freemind.get_data(this.jm.mind):d.error("unsupported "+e+" format"),t}},r.layout_provider=function(e,t){this.opts=t,this.jm=e,this.isside=this.opts.mode=="side",this.bounds=null,this.cache_valid=!1},r.layout_provider.prototype={init:function(){d.debug("layout.init")},reset:function(){d.debug("layout.reset"),this.bounds={n:0,s:0,w:0,e:0}},layout:function(){d.debug("layout.layout"),this.layout_direction(),this.layout_offset()},layout_direction:function(){this._layout_direction_root()},_layout_direction_root:function(){var e=this.jm.mind.root,t=null;"layout"in e._data?t=e._data.layout:(t={},e._data.layout=t);var i=e.children,n=i.length;if(t.direction=r.direction.center,t.side_index=0,this.isside)for(var a=n;a--;)this._layout_direction_side(i[a],r.direction.right,a);else for(var a=n,o=null;a--;)o=i[a],o.direction==r.direction.left?this._layout_direction_side(o,r.direction.left,a):this._layout_direction_side(o,r.direction.right,a)},_layout_direction_side:function(e,t,i){var n=null;"layout"in e._data?n=e._data.layout:(n={},e._data.layout=n);var a=e.children,o=a.length;n.direction=t,n.side_index=i;for(var h=o;h--;)this._layout_direction_side(a[h],t,h)},layout_offset:function(){var e=this.jm.mind.root,t=e._data.layout;t.offset_x=0,t.offset_y=0,t.outer_height=0;for(var i=e.children,n=i.length,a=[],o=[],h=null;n--;)h=i[n],h._data.layout.direction==r.direction.right?o.unshift(h):a.unshift(h);t.left_nodes=a,t.right_nodes=o,t.outer_height_left=this._layout_offset_subnodes(a),t.outer_height_right=this._layout_offset_subnodes(o),this.bounds.e=e._data.view.width/2,this.bounds.w=0-this.bounds.e,this.bounds.n=0,this.bounds.s=Math.max(t.outer_height_left,t.outer_height_right)},_layout_offset_subnodes:function(e){for(var t=0,i=e.length,n=i,a=null,o=0,h=null,_=0,c=null;n--;)a=e[n],h=a._data.layout,c==null&&(c=a.parent._data),o=this._layout_offset_subnodes(a.children),a.expanded||(o=0,this.set_visible(a.children,!1)),o=Math.max(a._data.view.height,o),h.outer_height=o,h.offset_y=_-o/2,h.offset_x=this.opts.hspace*h.direction+c.view.width*(c.layout.direction+h.direction)/2,a.parent.isroot||(h.offset_x+=this.opts.pspace*h.direction),_=_-o-this.opts.vspace,t+=o;i>1&&(t+=this.opts.vspace*(i-1)),n=i;for(var g=t/2;n--;)a=e[n],a._data.layout.offset_y+=g;return t},_layout_offset_subnodes_height:function(e){for(var t=0,i=e.length,n=i,a=null,o=0,h=null,_=0,c=null;n--;)a=e[n],h=a._data.layout,c==null&&(c=a.parent._data),o=this._layout_offset_subnodes_height(a.children),a.expanded||(o=0),o=Math.max(a._data.view.height,o),h.outer_height=o,h.offset_y=_-o/2,_=_-o-this.opts.vspace,t+=o;i>1&&(t+=this.opts.vspace*(i-1)),n=i;for(var g=t/2;n--;)a=e[n],a._data.layout.offset_y+=g;return t},get_node_offset:function(e){var t=e._data.layout,i=null;if("_offset_"in t&&this.cache_valid?i=t._offset_:(i={x:-1,y:-1},t._offset_=i),i.x==-1||i.y==-1){var n=t.offset_x,a=t.offset_y;if(!e.isroot){var o=this.get_node_offset(e.parent);n+=o.x,a+=o.y}i.x=n,i.y=a}return i},get_node_point:function(e){var t=e._data.view,i=this.get_node_offset(e),n={};return n.x=i.x+t.width*(e._data.layout.direction-1)/2,n.y=i.y-t.height/2,n},get_node_point_in:function(e){var t=this.get_node_offset(e);return t},get_node_point_out:function(e){var t=e._data.layout,i=null;if("_pout_"in t&&this.cache_valid?i=t._pout_:(i={x:-1,y:-1},t._pout_=i),i.x==-1||i.y==-1)if(e.isroot)i.x=0,i.y=0;else{var n=e._data.view,a=this.get_node_offset(e);i.x=a.x+(n.width+this.opts.pspace)*e._data.layout.direction,i.y=a.y}return i},get_expander_point:function(e){var t=this.get_node_point_out(e),i={};return e._data.layout.direction==r.direction.right?i.x=t.x-this.opts.pspace:i.x=t.x,i.y=t.y-Math.ceil(this.opts.pspace/2),i},get_min_size:function(){var e=this.jm.mind.nodes,t=null,i=null;for(var n in e)t=e[n],i=this.get_node_point_out(t),i.x>this.bounds.e&&(this.bounds.e=i.x),i.x<this.bounds.w&&(this.bounds.w=i.x);return{w:this.bounds.e-this.bounds.w,h:this.bounds.s-this.bounds.n}},toggle_node:function(e){e.isroot||(e.expanded?this.collapse_node(e):this.expand_node(e))},expand_node:function(e){e.expanded=!0,this.part_layout(e),this.set_visible(e.children,!0)},collapse_node:function(e){e.expanded=!1,this.part_layout(e),this.set_visible(e.children,!1)},expand_all:function(){var e=this.jm.mind.nodes,t=0,i;for(var n in e)i=e[n],i.expanded||(i.expanded=!0,t++);if(t>0){var a=this.jm.mind.root;this.part_layout(a),this.set_visible(a.children,!0)}},collapse_all:function(){var e=this.jm.mind.nodes,t=0,i;for(var n in e)i=e[n],i.expanded&&!i.isroot&&(i.expanded=!1,t++);if(t>0){var a=this.jm.mind.root;this.part_layout(a),this.set_visible(a.children,!0)}},expand_to_depth:function(e,t,i){if(!(e<1))for(var n=t||this.jm.mind.root.children,a=i||1,o=n.length,h=null;o--;)h=n[o],a<e&&(h.expanded||this.expand_node(h),this.expand_to_depth(e,h.children,a+1)),a==e&&h.expanded&&this.collapse_node(h)},part_layout:function(e){var t=this.jm.mind.root;if(t){var i=t._data.layout;e.isroot?(i.outer_height_right=this._layout_offset_subnodes_height(i.right_nodes),i.outer_height_left=this._layout_offset_subnodes_height(i.left_nodes)):e._data.layout.direction==r.direction.right?i.outer_height_right=this._layout_offset_subnodes_height(i.right_nodes):i.outer_height_left=this._layout_offset_subnodes_height(i.left_nodes),this.bounds.s=Math.max(i.outer_height_left,i.outer_height_right),this.cache_valid=!1}else d.warn("can not found root node")},set_visible:function(e,t){for(var i=e.length,n=null;i--;)n=e[i],n._data.layout,n.expanded?this.set_visible(n.children,t):this.set_visible(n.children,!1),n.isroot||(n._data.layout.visible=t)},is_expand:function(e){return e.expanded},is_visible:function(e){var t=e._data.layout;return!("visible"in t&&!t.visible)}},r.view_provider=function(e,t){this.opts=t,this.jm=e,this.layout=e.layout,this.container=null,this.e_panel=null,this.e_nodes=null,this.e_canvas=null,this.canvas_ctx=null,this.size={w:0,h:0},this.selected_node=null,this.editing_node=null},r.view_provider.prototype={init:function(){if(d.debug("view.init"),this.container=f(this.opts.container)?this.opts.container:s(this.opts.container),!this.container){d.error("the options.view.container was not be found in dom");return}this.e_panel=l("div"),this.e_canvas=l("canvas"),this.e_nodes=l("jmnodes"),this.e_editor=l("input"),this.e_panel.className="jsmind-inner",this.e_panel.appendChild(this.e_canvas),this.e_panel.appendChild(this.e_nodes),this.e_editor.className="jsmind-editor",this.e_editor.type="text",this.actualZoom=1,this.zoomStep=.1,this.minZoom=.5,this.maxZoom=2;var e=this;r.util.dom.add_event(this.e_editor,"keydown",function(t){var i=t||event;i.keyCode==13&&(e.edit_node_end(),i.stopPropagation())}),r.util.dom.add_event(this.e_editor,"blur",function(t){e.edit_node_end()}),this.container.appendChild(this.e_panel),this.init_canvas()},add_event:function(e,t,i){r.util.dom.add_event(this.e_nodes,t,function(n){var a=n||event;i.call(e,a)})},get_binded_nodeid:function(e){if(e==null)return null;var t=e.tagName.toLowerCase();return t=="jmnodes"||t=="body"||t=="html"?null:t=="jmnode"||t=="jmexpander"?e.getAttribute("nodeid"):this.get_binded_nodeid(e.parentElement)},is_expander:function(e){return e.tagName.toLowerCase()=="jmexpander"},reset:function(){d.debug("view.reset"),this.selected_node=null,this.clear_lines(),this.clear_nodes(),this.reset_theme()},reset_theme:function(){var e=this.jm.options.theme;e?this.e_nodes.className="theme-"+e:this.e_nodes.className=""},reset_custom_style:function(){var e=this.jm.mind.nodes;for(var t in e)this.reset_node_custom_style(e[t])},load:function(){d.debug("view.load"),this.init_nodes()},expand_size:function(){var e=this.layout.get_min_size(),t=e.w+this.opts.hmargin*2,i=e.h+this.opts.vmargin*2,n=this.e_panel.clientWidth,a=this.e_panel.clientHeight;n<t&&(n=t),a<i&&(a=i),this.size.w=n,this.size.h=a},init_canvas:function(){var e=this.e_canvas.getContext("2d");this.canvas_ctx=e},init_nodes_size:function(e){var t=e._data.view;t.width=t.element.clientWidth,t.height=t.element.clientHeight},init_nodes:function(){var e=this.jm.mind.nodes,t=T.createDocumentFragment();for(var i in e)this.create_node_element(e[i],t);this.e_nodes.appendChild(t);for(var i in e)this.init_nodes_size(e[i])},add_node:function(e){this.create_node_element(e,this.e_nodes),this.init_nodes_size(e)},create_node_element:function(e,t){var i=null;"view"in e._data?i=e._data.view:(i={},e._data.view=i);var n=l("jmnode");if(e.isroot)n.className="root";else{var a=l("jmexpander");u(a,"-"),a.setAttribute("nodeid",e.id),a.style.visibility="hidden",t.appendChild(a),i.expander=a}e.topic&&(this.opts.support_html?v(n,e.topic):u(n,e.topic)),n.setAttribute("nodeid",e.id),n.style.visibility="hidden",this._reset_node_custom_style(n,e.data),t.appendChild(n),i.element=n},remove_node:function(e){this.selected_node!=null&&this.selected_node.id==e.id&&(this.selected_node=null),this.editing_node!=null&&this.editing_node.id==e.id&&(e._data.view.element.removeChild(this.e_editor),this.editing_node=null);for(var t=e.children,i=t.length;i--;)this.remove_node(t[i]);if(e._data.view){var n=e._data.view.element,a=e._data.view.expander;this.e_nodes.removeChild(n),this.e_nodes.removeChild(a),e._data.view.element=null,e._data.view.expander=null}},update_node:function(e){var t=e._data.view,i=t.element;e.topic&&(this.opts.support_html?v(i,e.topic):u(i,e.topic)),t.width=i.clientWidth,t.height=i.clientHeight},select_node:function(e){this.selected_node&&(this.selected_node._data.view.element.className=this.selected_node._data.view.element.className.replace(/\s*selected\b/i,""),this.reset_node_custom_style(this.selected_node)),e&&(this.selected_node=e,e._data.view.element.className+=" selected",this.clear_node_custom_style(e))},select_clear:function(){this.select_node(null)},get_editing_node:function(){return this.editing_node},is_editing:function(){return!!this.editing_node},edit_node_begin:function(e){if(!e.topic){d.warn("don't edit image nodes");return}this.editing_node!=null&&this.edit_node_end(),this.editing_node=e;var t=e._data.view,i=t.element,n=e.topic,a=getComputedStyle(i);this.e_editor.value=n,this.e_editor.style.width=i.clientWidth-parseInt(a.getPropertyValue("padding-left"))-parseInt(a.getPropertyValue("padding-right"))+"px",i.innerHTML="",i.appendChild(this.e_editor),i.style.zIndex=5,this.e_editor.focus(),this.e_editor.select()},edit_node_end:function(){if(this.editing_node!=null){var e=this.editing_node;this.editing_node=null;var t=e._data.view,i=t.element,n=this.e_editor.value;i.style.zIndex="auto",i.removeChild(this.e_editor),r.util.text.is_empty(n)||e.topic===n?this.opts.support_html?v(i,e.topic):u(i,e.topic):this.jm.update_node(e.id,n)}},get_view_offset:function(){var e=this.layout.bounds,t=(this.size.w-e.e-e.w)/2,i=this.size.h/2;return{x:t,y:i}},resize:function(){this.e_canvas.width=1,this.e_canvas.height=1,this.e_nodes.style.width="1px",this.e_nodes.style.height="1px",this.expand_size(),this._show()},_show:function(){this.e_canvas.width=this.size.w,this.e_canvas.height=this.size.h,this.e_nodes.style.width=this.size.w+"px",this.e_nodes.style.height=this.size.h+"px",this.show_nodes(),this.show_lines(),this.jm.invoke_event_handle(r.event_type.resize,{data:[]})},zoomIn:function(){return this.setZoom(this.actualZoom+this.zoomStep)},zoomOut:function(){return this.setZoom(this.actualZoom-this.zoomStep)},setZoom:function(e){if(e<this.minZoom||e>this.maxZoom)return!1;this.actualZoom=e;for(var t=0;t<this.e_panel.children.length;t++)this.e_panel.children[t].style.transform="scale("+e+")";return this.show(!0),!0},_center_root:function(){var e=this.e_panel.clientWidth,t=this.e_panel.clientHeight;if(this.size.w>e){var i=this.get_view_offset();this.e_panel.scrollLeft=i.x-e/2}this.size.h>t&&(this.e_panel.scrollTop=(this.size.h-t)/2)},show:function(e){d.debug("view.show"),this.expand_size(),this._show(),e&&this._center_root()},relayout:function(){this.expand_size(),this._show()},save_location:function(e){var t=e._data.view;t._saved_location={x:parseInt(t.element.style.left)-this.e_panel.scrollLeft,y:parseInt(t.element.style.top)-this.e_panel.scrollTop}},restore_location:function(e){var t=e._data.view;this.e_panel.scrollLeft=parseInt(t.element.style.left)-t._saved_location.x,this.e_panel.scrollTop=parseInt(t.element.style.top)-t._saved_location.y},clear_nodes:function(){var e=this.jm.mind;if(e!=null){var t=e.nodes,i=null;for(var n in t)i=t[n],i._data.view.element=null,i._data.view.expander=null;this.e_nodes.innerHTML=""}},show_nodes:function(){var e=this.jm.mind.nodes,t=null,i=null,n=null,a=null,o=null,h="-",_=null,c=this.get_view_offset();for(var g in e){if(t=e[g],_=t._data.view,i=_.element,n=_.expander,!this.layout.is_visible(t)){i.style.display="none",n.style.display="none";continue}this.reset_node_custom_style(t),a=this.layout.get_node_point(t),_.abs_x=c.x+a.x,_.abs_y=c.y+a.y,i.style.left=c.x+a.x+"px",i.style.top=c.y+a.y+"px",i.style.display="",i.style.visibility="visible",!t.isroot&&t.children.length>0&&(h=t.expanded?"-":"+",o=this.layout.get_expander_point(t),n.style.left=c.x+o.x+"px",n.style.top=c.y+o.y+"px",n.style.display="",n.style.visibility="visible",u(n,h)),!t.isroot&&t.children.length==0&&(n.style.display="none",n.style.visibility="hidden")}},reset_node_custom_style:function(e){this._reset_node_custom_style(e._data.view.element,e.data)},_reset_node_custom_style:function(e,t){if("background-color"in t&&(e.style.backgroundColor=t["background-color"]),"foreground-color"in t&&(e.style.color=t["foreground-color"]),"width"in t&&(e.style.width=t.width+"px"),"height"in t&&(e.style.height=t.height+"px"),"font-size"in t&&(e.style.fontSize=t["font-size"]+"px"),"font-weight"in t&&(e.style.fontWeight=t["font-weight"]),"font-style"in t&&(e.style.fontStyle=t["font-style"]),"background-image"in t){var i=t["background-image"];if(i.startsWith("data")&&t.width&&t.height){var n=new Image;n.onload=function(){var a=l("canvas");a.width=e.clientWidth,a.height=e.clientHeight;var o=this;if(a.getContext){var h=a.getContext("2d");h.drawImage(o,2,2,e.clientWidth,e.clientHeight);var _=a.toDataURL();e.style.backgroundImage="url("+_+")"}},n.src=i}else e.style.backgroundImage="url("+i+")";e.style.backgroundSize="99%","background-rotation"in t&&(e.style.transform="rotate("+t["background-rotation"]+"deg)")}},clear_node_custom_style:function(e){var t=e._data.view.element;t.style.backgroundColor="",t.style.color=""},clear_lines:function(e){var t=e||this.canvas_ctx;r.util.canvas.clear(t,0,0,this.size.w,this.size.h)},show_lines:function(e){this.clear_lines(e);var t=this.jm.mind.nodes,i=null,n=null,a=null,o=this.get_view_offset();for(var h in t)i=t[h],!i.isroot&&("visible"in i._data.layout&&!i._data.layout.visible||(n=this.layout.get_node_point_in(i),a=this.layout.get_node_point_out(i.parent),this.draw_line(a,n,o,e)))},draw_line:function(e,t,i,n){var a=n||this.canvas_ctx;a.strokeStyle=this.opts.line_color,a.lineWidth=this.opts.line_width,a.lineCap="round",r.util.canvas.bezierto(a,e.x+i.x,e.y+i.y,t.x+i.x,t.y+i.y)}},r.shortcut_provider=function(e,t){this.jm=e,this.opts=t,this.mapping=t.mapping,this.handles=t.handles,this._mapping={}},r.shortcut_provider.prototype={init:function(){r.util.dom.add_event(T,"keydown",this.handler.bind(this)),this.handles.addchild=this.handle_addchild,this.handles.addbrother=this.handle_addbrother,this.handles.editnode=this.handle_editnode,this.handles.delnode=this.handle_delnode,this.handles.toggle=this.handle_toggle,this.handles.up=this.handle_up,this.handles.down=this.handle_down,this.handles.left=this.handle_left,this.handles.right=this.handle_right;for(var e in this.mapping)!!this.mapping[e]&&e in this.handles&&(this._mapping[this.mapping[e]]=this.handles[e])},enable_shortcut:function(){this.opts.enable=!0},disable_shortcut:function(){this.opts.enable=!1},handler:function(e){if(!this.jm.view.is_editing()){var t=e||event;if(!this.opts.enable)return!0;var i=t.keyCode;i in this._mapping&&this._mapping[i].call(this,this.jm,e)}},handle_addchild:function(e,t){var i=e.get_selected_node();if(i){var n=r.util.uuid.newid(),a=e.add_node(i,n,"New Node");a&&(e.select_node(n),e.begin_edit(n))}},handle_addbrother:function(e,t){var i=e.get_selected_node();if(!!i&&!i.isroot){var n=r.util.uuid.newid(),a=e.insert_node_after(i,n,"New Node");a&&(e.select_node(n),e.begin_edit(n))}},handle_editnode:function(e,t){var i=e.get_selected_node();i&&e.begin_edit(i)},handle_delnode:function(e,t){var i=e.get_selected_node();!!i&&!i.isroot&&(e.select_node(i.parent),e.remove_node(i))},handle_toggle:function(e,t){var i=t||event,n=e.get_selected_node();n&&(e.toggle_node(n.id),i.stopPropagation(),i.preventDefault())},handle_up:function(e,t){var i=t||event,n=e.get_selected_node();if(n){var a=e.find_node_before(n);if(!a){var o=e.find_node_before(n.parent);!!o&&o.children.length>0&&(a=o.children[o.children.length-1])}a&&e.select_node(a),i.stopPropagation(),i.preventDefault()}},handle_down:function(e,t){var i=t||event,n=e.get_selected_node();if(n){var a=e.find_node_after(n);if(!a){var o=e.find_node_after(n.parent);!!o&&o.children.length>0&&(a=o.children[0])}a&&e.select_node(a),i.stopPropagation(),i.preventDefault()}},handle_left:function(e,t){this._handle_direction(e,t,r.direction.left)},handle_right:function(e,t){this._handle_direction(e,t,r.direction.right)},_handle_direction:function(e,t,i){var n=t||event,a=e.get_selected_node(),o=null;if(a){if(a.isroot){for(var h=a.children,_=[],c=0;c<h.length;c++)h[c].direction===i&&_.push(c);o=h[_[Math.floor((_.length-1)/2)]]}else if(a.direction===i){var _=a.children,g=_.length;g>0&&(o=_[Math.floor((g-1)/2)])}else o=a.parent;o&&e.select_node(o),n.stopPropagation(),n.preventDefault()}}},r.plugin=function(e,t){this.name=e,this.init=t},r.plugins=[],r.register_plugin=function(e){e instanceof r.plugin&&r.plugins.push(e)},r.init_plugins=function(e){m.setTimeout(function(){r._init_plugins(e)},0)},r._init_plugins=function(e){for(var t=r.plugins.length,i=null,n=0;n<t;n++)i=r.plugins[n].init,typeof i=="function"&&i(e)},r.show=function(e,t){var i=new r(e);return i.show(t),i},b.exports=r})(typeof window!="undefined"?window:B)})(L);var A=L.exports;(function(b){var S=b.document,m="jsMind",y=b[m];if(!!y&&typeof y.draggable=="undefined"){var j=y.util.dom,w=y.util.canvas,z="getSelection"in b?function(){b.getSelection().removeAllRanges()}:function(){S.selection.empty()},d={line_width:5,lookup_delay:500,lookup_interval:80};y.draggable=function(s){this.jm=s,this.e_canvas=null,this.canvas_ctx=null,this.shadow=null,this.shadow_w=0,this.shadow_h=0,this.active_node=null,this.target_node=null,this.target_direct=null,this.client_w=0,this.client_h=0,this.offset_x=0,this.offset_y=0,this.hlookup_delay=0,this.hlookup_timer=0,this.capture=!1,this.moved=!1},y.draggable.prototype={init:function(){this._create_canvas(),this._create_shadow(),this._event_bind()},resize:function(){this.jm.view.e_nodes.appendChild(this.shadow),this.e_canvas.width=this.jm.view.size.w,this.e_canvas.height=this.jm.view.size.h},_create_canvas:function(){var s=S.createElement("canvas");this.jm.view.e_panel.appendChild(s);var l=s.getContext("2d");this.e_canvas=s,this.canvas_ctx=l},_create_shadow:function(){var s=S.createElement("jmnode");s.style.visibility="hidden",s.style.zIndex="3",s.style.cursor="move",s.style.opacity="0.7",this.shadow=s},reset_shadow:function(s){var l=this.shadow.style;this.shadow.innerHTML=s.innerHTML,l.left=s.style.left,l.top=s.style.top,l.width=s.style.width,l.height=s.style.height,l.backgroundImage=s.style.backgroundImage,l.backgroundSize=s.style.backgroundSize,l.transform=s.style.transform,this.shadow_w=this.shadow.clientWidth,this.shadow_h=this.shadow.clientHeight},show_shadow:function(){this.moved||(this.shadow.style.visibility="visible")},hide_shadow:function(){this.shadow.style.visibility="hidden"},clear_lines:function(){w.clear(this.canvas_ctx,0,0,this.jm.view.size.w,this.jm.view.size.h)},_magnet_shadow:function(s){s&&(this.canvas_ctx.lineWidth=d.line_width,this.canvas_ctx.strokeStyle="rgba(0,0,0,0.3)",this.canvas_ctx.lineCap="round",this.clear_lines(),w.lineto(this.canvas_ctx,s.sp.x,s.sp.y,s.np.x,s.np.y))},_lookup_close_node:function(){var s=this.jm.get_root(),l=s.get_location(),u=s.get_size(),v=l.x+u.w/2,f=this.shadow_w,p=this.shadow_h,r=this.shadow.offsetLeft,e=this.shadow.offsetTop,t,i,n=r+f/2>=v?y.direction.right:y.direction.left,a=this.jm.mind.nodes,o=null,h=Number.MAX_VALUE,_=0,c=null,g=null,k=null;for(var C in a){var E,N;if(o=a[C],o.isroot||o.direction==n){if(o.id==this.active_node.id)continue;if(t=o.get_size(),i=o.get_location(),n==y.direction.right){if(r-i.x-t.w<=0)continue;_=Math.abs(r-i.x-t.w)+Math.abs(e+p/2-i.y-t.h/2),E={x:i.x+t.w-d.line_width,y:i.y+t.h/2},N={x:r+d.line_width,y:e+p/2}}else{if(i.x-r-f<=0)continue;_=Math.abs(r+f-i.x)+Math.abs(e+p/2-i.y-t.h/2),E={x:i.x+d.line_width,y:i.y+t.h/2},N={x:r+f-d.line_width,y:e+p/2}}_<h&&(c=o,g=E,k=N,h=_)}}var M=null;return c&&(M={node:c,direction:n,sp:k,np:g}),M},lookup_close_node:function(){var s=this._lookup_close_node();s&&(this._magnet_shadow(s),this.target_node=s.node,this.target_direct=s.direction)},_event_bind:function(){var s=this,l=this.jm.view.container;j.add_event(l,"mousedown",function(u){var v=u||event;s.dragstart.call(s,v)}),j.add_event(l,"mousemove",function(u){var v=u||event;s.drag.call(s,v)}),j.add_event(l,"mouseup",function(u){var v=u||event;s.dragend.call(s,v)}),j.add_event(l,"touchstart",function(u){var v=u||event;s.dragstart.call(s,v)}),j.add_event(l,"touchmove",function(u){var v=u||event;s.drag.call(s,v)}),j.add_event(l,"touchend",function(u){var v=u||event;s.dragend.call(s,v)})},dragstart:function(s){if(!!this.jm.get_editable()&&!this.capture){this.active_node=null;var l=this.jm.view,u=s.target||event.srcElement;if(u.tagName.toLowerCase()=="jmnode"){var v=l.get_binded_nodeid(u);if(v){var f=this.jm.get_node(v);if(!f.isroot){this.reset_shadow(u),this.active_node=f,this.offset_x=(s.clientX||s.touches[0].clientX)-u.offsetLeft,this.offset_y=(s.clientY||s.touches[0].clientY)-u.offsetTop,this.client_hw=Math.floor(u.clientWidth/2),this.client_hh=Math.floor(u.clientHeight/2),this.hlookup_delay!=0&&b.clearTimeout(this.hlookup_delay),this.hlookup_timer!=0&&b.clearInterval(this.hlookup_timer);var p=this;this.hlookup_delay=b.setTimeout(function(){p.hlookup_delay=0,p.hlookup_timer=b.setInterval(function(){p.lookup_close_node.call(p)},d.lookup_interval)},d.lookup_delay),this.capture=!0}}}}},drag:function(s){if(!!this.jm.get_editable()&&this.capture){s.preventDefault(),this.show_shadow(),this.moved=!0,z();var l=(s.clientX||s.touches[0].clientX)-this.offset_x,u=(s.clientY||s.touches[0].clientY)-this.offset_y;l+this.client_hw,u+this.client_hh,this.shadow.style.left=l+"px",this.shadow.style.top=u+"px",z()}},dragend:function(s){if(!!this.jm.get_editable()){if(this.capture){if(this.hlookup_delay!=0&&(b.clearTimeout(this.hlookup_delay),this.hlookup_delay=0,this.clear_lines()),this.hlookup_timer!=0&&(b.clearInterval(this.hlookup_timer),this.hlookup_timer=0,this.clear_lines()),this.moved){var l=this.active_node,u=this.target_node,v=this.target_direct;this.move_node(l,u,v)}this.hide_shadow()}this.moved=!1,this.capture=!1}},move_node:function(s,l,u){var v=this.shadow.offsetTop;if(!!l&&!!s&&!y.node.inherited(s,l)){for(var f=l.children,p=f.length,r=null,e=Number.MAX_VALUE,t=null,i="_last_";p--;)if(r=f[p],r.direction==u&&r.id!=s.id){var n=r.get_location().y-v;n>0&&n<e&&(e=n,t=r,i="_first_")}t&&(i=t.id),this.jm.move_node(s.id,i,l.id,u)}this.active_node=null,this.target_node=null,this.target_direct=null},jm_event_handle:function(s,l){s===y.event_type.resize&&this.resize()}};var T=new y.plugin("draggable",function(s){var l=new y.draggable(s);l.init(),s.add_event_listener(function(u,v){l.jm_event_handle.call(l,u,v)})});y.register_plugin(T)}})(window),function(b){var S="jsMind",m=b[S];if(!!m&&typeof m.screenshot=="undefined"){var y=b.document,j=function(s){return y.createElement(s)},w=function(s,l){return s.getPropertyValue(l)},z=function(s){var l=w(s,"visibility"),u=w(s,"display");return l!=="hidden"&&u!=="none"},d=m.util.canvas;d.rect=function(s,l,u,v,f,p){v<2*p&&(p=v/2),f<2*p&&(p=f/2),s.moveTo(l+p,u),s.arcTo(l+v,u,l+v,u+f,p),s.arcTo(l+v,u+f,l,u+f,p),s.arcTo(l,u+f,l,u,p),s.arcTo(l,u,l+v,u,p)},d.text_multiline=function(s,l,u,v,f,p,r){var e="",t=l.length,i=l.split(""),n=null;s.textAlign="left",s.textBaseline="top";for(var a=0;a<t;a++)n=e+i[a],s.measureText(n).width>f&&a>0?(s.fillText(e,u,v),e=i[a],v+=r):e=n;s.fillText(e,u,v)},d.text_ellipsis=function(s,e,u,v,f,p){var r=v+p/2,e=d.fittingString(s,e,f);s.textAlign="left",s.textBaseline="middle",s.fillText(e,u,r,f)},d.fittingString=function(s,l,u){var v=s.measureText(l).width,f="\u2026",p=s.measureText(f).width;if(v<=u||v<=p)return l;for(var r=l.length;v>=u-p&&r-- >0;)l=l.substring(0,r),v=s.measureText(l).width;return l+f},d.image=function(s,l,u,v,f,p,r,e,t){var i=new Image;i.onload=function(){s.save(),s.translate(u,v),s.save(),s.beginPath(),d.rect(s,0,0,f,p,r),s.closePath(),s.clip(),s.translate(f/2,p/2),s.rotate(e*Math.PI/180),s.drawImage(i,-f/2,-p/2),s.restore(),s.restore(),t()},i.src=l},m.screenshot=function(s){this.jm=s,this.canvas_elem=null,this.canvas_ctx=null,this._inited=!1},m.screenshot.prototype={init:function(){if(!this._inited){console.log("init");var s=j("canvas"),l=s.getContext("2d");this.canvas_elem=s,this.canvas_ctx=l,this.jm.view.e_panel.appendChild(s),this._inited=!0,this.resize()}},shoot:function(s){this.init(),this._watermark();var l=this;this._draw(function(){s&&s(l),l.clean()})},shootDownload:function(){this.shoot(function(s){s._download()})},shootAsDataURL:function(s){this.shoot(function(l){s(l.canvas_elem.toDataURL())})},resize:function(){this._inited&&(this.canvas_elem.width=this.jm.view.size.w,this.canvas_elem.height=this.jm.view.size.h)},clean:function(){var s=this.canvas_elem;this.canvas_ctx.clearRect(0,0,s.width,s.height)},_draw:function(s){var l=this.canvas_ctx;l.textAlign="left",l.textBaseline="top",this._draw_lines(),this._draw_nodes(s)},_watermark:function(){var s=this.canvas_elem,l=this.canvas_ctx;l.textAlign="right",l.textBaseline="bottom",l.fillStyle="#000",l.font="11px Verdana,Arial,Helvetica,sans-serif",l.fillText("hizzgdev.github.io/jsmind",s.width-5.5,s.height-2.5),l.textAlign="left",l.fillText(b.location,5.5,s.height-2.5)},_draw_lines:function(){this.jm.view.show_lines(this.canvas_ctx)},_draw_nodes:function(s){var l=this.jm.mind.nodes,u;for(var v in l)u=l[v],this._draw_node(u);function f(){console.log("check_node_ready"+new Date);var p=!0;for(var r in l)u=l[r],p=p&u.ready;p?b.setTimeout(s,200):b.setTimeout(f,200)}f()},_draw_node:function(s){var l=this.canvas_ctx,u=s._data.view,v=u.element,f=getComputedStyle(v);if(!z(f)){s.ready=!0;return}var p=w(f,"background-color"),r=parseInt(w(f,"border-top-left-radius")),e=w(f,"color"),t=parseInt(w(f,"padding-left")),i=parseInt(w(f,"padding-right")),n=parseInt(w(f,"padding-top")),a=parseInt(w(f,"padding-bottom")),o=w(f,"text-overflow"),h=w(f,"font-style")+" "+w(f,"font-variant")+" "+w(f,"font-weight")+" "+w(f,"font-size")+"/"+w(f,"line-height")+" "+w(f,"font-family"),_={x:u.abs_x,y:u.abs_y,w:u.width+1,h:u.height+1},c={x:_.x+t,y:_.y+n,w:_.w-t-i,h:_.h-n-a};if(l.font=h,l.fillStyle=p,l.beginPath(),d.rect(l,_.x,_.y,_.w,_.h,r),l.closePath(),l.fill(),l.fillStyle=e,"background-image"in s.data){var g=w(f,"background-image").slice(5,-2);s.ready=!1;var k=0;"background-rotation"in s.data&&(k=s.data["background-rotation"]),d.image(l,g,_.x,_.y,_.w,_.h,r,k,function(){s.ready=!0})}if(s.topic)if(o==="ellipsis")d.text_ellipsis(l,s.topic,c.x,c.y,c.w,c.h);else{var C=parseInt(w(f,"line-height"));d.text_multiline(l,s.topic,c.x,c.y,c.w,c.h,C)}u.expander&&this._draw_expander(u.expander),"background-image"in s.data||(s.ready=!0)},_draw_expander:function(s){var l=this.canvas_ctx,u=getComputedStyle(s);if(!!z(u)){var v=w(u,"left"),f=w(u,"top");w(u,"font");var p=parseInt(v),r=parseInt(f),e=s.innerHTML==="+";l.lineWidth=1,l.beginPath(),l.arc(p+7,r+7,5,0,Math.PI*2,!0),l.moveTo(p+10,r+7),l.lineTo(p+4,r+7),e&&(l.moveTo(p+7,r+4),l.lineTo(p+7,r+10)),l.closePath(),l.stroke()}},_download:function(){var s=this.canvas_elem,l=this.jm.mind.name+".png";if(navigator.msSaveBlob&&!!s.msToBlob){var u=s.msToBlob();navigator.msSaveBlob(u,l)}else{var v=this.canvas_elem.toDataURL(),f=j("a");if("download"in f){f.style.visibility="hidden",f.href=v,f.download=l,y.body.appendChild(f);var p=y.createEvent("MouseEvents");p.initEvent("click",!0,!0),f.dispatchEvent(p),y.body.removeChild(f)}else location.href=v}},jm_event_handle:function(s,l){s===m.event_type.resize&&this.resize()}};var T=new m.plugin("screenshot",function(s){var l=new m.screenshot(s);s.screenshot=l,s.shoot=function(){l.shoot()},s.add_event_listener(function(u,v){l.jm_event_handle.call(l,u,v)})});m.register_plugin(T)}}(window);var X="",O=(b,S)=>{const m=b.__vccOpts||b;for(const[y,j]of S)m[y]=j;return m};const P=b=>(x.pushScopeId("data-v-b8129f5e"),b=b(),x.popScopeId(),b),D=[P(()=>x.createElementVNode("div",{id:"jsmind_container"},null,-1)),P(()=>x.createElementVNode("div",{style:{display:"none"}},[x.createElementVNode("input",{class:"file",type:"file",id:"image-chooser",accept:"image/*"})],-1))];var H=O(x.defineComponent({props:{values:{default:()=>({})},options:{default:()=>({})},height:{default:""}},emits:["initJM"],setup(b,{emit:S}){var T;const m=b;let y=x.ref({});const j=x.ref(1),w=x.ref({}),z=x.reactive({container:"jsmind_container",editable:!1,theme:"primary",mode:"full",support_html:!0,default_event_handle:{enable_mousedown_handle:!1,enable_click_handle:!1},view:{engine:"canvas",hmargin:100,vmargin:50,line_width:2,line_color:"#555"},layout:{hspace:30,vspace:20,pspace:13},shortcut:{enable:!0,handles:{SavePNG(){y.screenshot.shootDownload()}},mapping:{addchild:45,addbrother:13,editnode:113,delnode:46,toggle:32,left:37,up:38,right:39,down:40,SavePNG:((T=A.key)==null?void 0:T.ctrl)+83}}});x.watchEffect(()=>{m.values&&j.value++});const d=()=>{w.value=m.values;let s=document.getElementsByClassName("jsmind-inner")[0];s!=null&&s.remove();const l=Object.assign(z,m.options);y.value=A.show(l,w.value),S("initJM",y)};return x.watch(()=>m.values,()=>{d()},{deep:!0}),x.onMounted(()=>{d()}),(s,l)=>(x.openBlock(),x.createElementBlock("div",{key:j.value,style:x.normalizeStyle({height:b.height})},D,4))}}),[["__scopeId","data-v-b8129f5e"]]);const W=Array.isArray;I.Mind=H,I.isArray=W,Object.defineProperties(I,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
