!function(window){function getMetaKeyCode(t){var e=4096,n=8192,i=16384,r=0;return"string"==typeof t?t.toLowerCase().split(/\+\s*/).forEach(function(t){switch(t){case"ctrl":case"cmd":r|=e;break;case"alt":r|=n;break;case"shift":r|=i;break;default:r|=keymap[t]}}):((t.ctrlKey||t.metaKey)&&(r|=e),t.altKey&&(r|=n),t.shiftKey&&(r|=i),r|=t.keyCode),r}function updateCircle(t,e,n){var i=e.getStyle("padding-left"),r=e.getStyle("padding-right"),o=e.getStyle("padding-top"),a=e.getStyle("padding-bottom"),s=Math.max(n.width,n.height),l={x:n.x-i,y:n.y-o,width:s+i+r,height:s+o+a},u=e.isSelected()?"selected-":"";return s=Math.max(l.width,l.height),t.setPosition(l.x,l.y).setSize(s,s).setRadius(s/2).fill(e.getData("background")||e.getStyle(u+"background")||e.getStyle("background")).stroke(e.getStyle(u+"stroke"||e.getStyle("stroke")),e.getStyle(u+"stroke-width")),new kity.Box(l)}function asc(t,e){return t.getIndex()-e.getIndex()}function desc(t,e){return-asc(t,e)}function canArrange(t){var e=t.getSelectedNode();return e&&e.parent&&e.parent.children.length>1}!function(t,e){"object"==typeof module&&"object"==typeof module.exports?module.exports=t.document?e(t,!0):function(t){if(!t.document)throw new Error("jQuery requires a window with a document");return e(t)}:e(t)}("undefined"!=typeof window?window:this,function(t,e){function n(t){var e=t.length,n=Z.type(t);return"function"===n||Z.isWindow(t)?!1:1===t.nodeType&&e?!0:"array"===n||0===e||"number"==typeof e&&e>0&&e-1 in t}function i(t,e,n){if(Z.isFunction(e))return Z.grep(t,function(t,i){return!!e.call(t,i,t)!==n});if(e.nodeType)return Z.grep(t,function(t){return t===e!==n});if("string"==typeof e){if(se.test(e))return Z.filter(e,t,n);e=Z.filter(e,t)}return Z.grep(t,function(t){return q.call(e,t)>=0!==n})}function r(t,e){for(;(t=t[e])&&1!==t.nodeType;);return t}function o(t){var e=pe[t]={};return Z.each(t.match(fe)||[],function(t,n){e[n]=!0}),e}function a(){Q.removeEventListener("DOMContentLoaded",a,!1),t.removeEventListener("load",a,!1),Z.ready()}function s(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=Z.expando+Math.random()}function l(t,e,n){var i;if(void 0===n&&1===t.nodeType)if(i="data-"+e.replace(be,"-$1").toLowerCase(),n=t.getAttribute(i),"string"==typeof n){try{n="true"===n?!0:"false"===n?!1:"null"===n?null:+n+""===n?+n:_e.test(n)?Z.parseJSON(n):n}catch(r){}ye.set(t,e,n)}else n=void 0;return n}function u(){return!0}function c(){return!1}function h(){try{return Q.activeElement}catch(t){}}function d(t,e){return Z.nodeName(t,"table")&&Z.nodeName(11!==e.nodeType?e:e.firstChild,"tr")?t.getElementsByTagName("tbody")[0]||t.appendChild(t.ownerDocument.createElement("tbody")):t}function f(t){return t.type=(null!==t.getAttribute("type"))+"/"+t.type,t}function p(t){var e=Be.exec(t.type);return e?t.type=e[1]:t.removeAttribute("type"),t}function g(t,e){for(var n=0,i=t.length;i>n;n++)ve.set(t[n],"globalEval",!e||ve.get(e[n],"globalEval"))}function m(t,e){var n,i,r,o,a,s,l,u;if(1===e.nodeType){if(ve.hasData(t)&&(o=ve.access(t),a=ve.set(e,o),u=o.events)){delete a.handle,a.events={};for(r in u)for(n=0,i=u[r].length;i>n;n++)Z.event.add(e,r,u[r][n])}ye.hasData(t)&&(s=ye.access(t),l=Z.extend({},s),ye.set(e,l))}}function v(t,e){var n=t.getElementsByTagName?t.getElementsByTagName(e||"*"):t.querySelectorAll?t.querySelectorAll(e||"*"):[];return void 0===e||e&&Z.nodeName(t,e)?Z.merge([t],n):n}function y(t,e){var n=e.nodeName.toLowerCase();"input"===n&&Ce.test(t.type)?e.checked=t.checked:("input"===n||"textarea"===n)&&(e.defaultValue=t.defaultValue)}function _(e,n){var i,r=Z(n.createElement(e)).appendTo(n.body),o=t.getDefaultComputedStyle&&(i=t.getDefaultComputedStyle(r[0]))?i.display:Z.css(r[0],"display");return r.detach(),o}function b(t){var e=Q,n=Ve[t];return n||(n=_(t,e),"none"!==n&&n||(He=(He||Z("').appendTo(this.__element),r(this.__element).addClass(e.classPrefix+"ppanel")},__position:function(){var t=null,n=e.classPrefix+"ppanel-position";r(this.__element).addClass(n),t=this.__getLocation(),r(this.__element).css("top",t.top+"px").css("left",t.left+"px")},__resize:function(){var e=t.getBound(this.__target);switch(this.__options.resize){case"all":this.__resizeWidth(e),this.__resizeHeight();break;case"width":this.__resizeWidth(e);break;case"height":this.__resizeHeight()}},__resizeWidth:function(t){if(this.__target){var e=r(this.__element),n=e.outerWidth(),i=e.outerHeight(),o=t.width-n-i;this.__element.style.minWidth=o+"px"}},__resizeHeight:function(){var e=null,n=null,i=0;n=t.getRect(this.__element),n.height=this.__element.scrollHeight,n.bottom=n.top+n.height,e=this.__getBoundRect(),i=n.bottom-e.bottom,i>0?(this.__height_resized=!0,i=n.height-i-this.__options.diff,r(this.__element).css("height",i+"px")):this.__height_resized&&(this.__element.style.height=null)},__getLocation:function(){var e=t.getBound(this.__target);switch(this.__layout){case i.CENTER:case i.MIDDLE:return this.__getCenterLayout(e);case i.LEFT:case i.RIGHT:case i.BOTTOM:case i.TOP:return this.__getOuterLayout(e);default:return this.__getInnerLayout(e)}return location},__getCenterLayout:function(e){var n={top:0,left:0},i=t.getRect(this.__element),r=0;return r=e.height-i.height,r>0&&(n.top=e.top+r/2),r=e.width-i.width,r>0&&(n.left=e.left+r/2),n},__getOuterLayout:function(e){var n={top:0,left:0},r=t.getRect(this.__element);switch(this.__layout){case i.TOP:n.left=e.left,n.top=e.top-r.height;break;case i.LEFT:n.top=e.top,n.left=e.left-r.width;break;case i.RIGHT:n.top=e.top,n.left=e.right;break;case i.BOTTOM:default:n.left=e.left,n.top=e.bottom}return n},__getInnerLayout:function(e){var n={top:0,left:0},r=e,o=t.getRect(this.__element);switch(this.__layout){case i.LEFT_TOP:n.top=r.top,n.left=r.left;break;case i.RIGHT_TOP:n.top=r.top,n.left=r.left+r.width-o.width;break;case i.LEFT_BOTTOM:n.top=r.top+r.height-o.height,n.left=r.left;break;case i.RIGHT_BOTTOM:n.top=r.top+r.height-o.height,n.left=r.left+r.width-o.width}return this.__correctionLocation(n)},__getBoundRect:function(){var e=-1,n=-1,i=null;return"body"===this.__options.bound.tagName.toLowerCase()?(i=t.getView(this.__options.bound),e=r(i).width(),n=r(i).height(),{top:0,left:0,right:e,bottom:n,width:e,height:n}):t.getRect(this.__options.bound)},__correctionLocation:function(e){var n=t.getRect(this.__element),r=t.getRect(this.__target),o=this.__getBoundRect();switch(this.__layout){case i.LEFT_TOP:case i.LEFT_BOTTOM:e.left+n.width>o.right&&(e.left+=r.width-n.width);break;case i.RIGHT_TOP:case i.RIGHT_BOTTOM:e.leftt||t>=this.__options.items.length||(n=this.__currentSelected,this.__currentSelected=t,r=this.__options.items[this.__currentSelected],i=r+" "+(this.__options.suffix||""),this.__inputWidget.setValue(i),e!==!1&&this.trigger("change",{from:this.__options.items[n]||null,to:r}))},__initOptions:function(){var e=this.__options.items;this.callBase(),this.widgetName="SpinButton",this.__tpl=n,this.__buttons=[],this.__panelWidget=null,this.__inputWidget=null,this.__currentSelected=-1,t.each(e,function(t,n){e[t]=n+""})}})}},_p[58]={value:function(){var t=_p.r(4),e=_p.r(12),n=_p.r(33),i=_p.r(37),r=_p.r(51);return _p.r(13).createClass("Tabs",{base:_p.r(60),constructor:function(e){var n={selected:0,buttons:[],panels:[]};e=t.extend({},n,e),this.callBase(e)},getButtons:function(){return this.__btns},getButton:function(t){return this.getButtons()[t]||null},getButtonByValue:function(e){var n=null;return t.each(this.__btns,function(t,i){return i.getValue()===e?(n=i,!1):void 0}),n},getPanels:function(){return this.__panels},getPanel:function(t){return this.getPanels()[t]||null},getPanelByValue:function(e){var n=null;return t.each(this.__panels,function(t,i){return i.getValue()===e?(n=i,!1):void 0}),n},getSelectedIndex:function(){return this.__selected},getSelected:function(){var t=this.getSelectedIndex();return{button:this.getButton(t),panel:this.getPanel(t)}},appendTab:function(t){return t.panels=t.panels||[],this.__renderByOptions(t)},removeTab:function(t){if(0>t)return null;var e=this.__btns.splice(t,1),n=this.__panels.splice(t,1);return e.length?(e=e[0],n=n[0],e.remove(),n.remove(),{button:e,panel:n}):null},select:function(t){var e=null;return this.__selectItem(t)?(e=this.__getInfo(t),this.trigger("tabsselect",e),this.__prevSelected!==this.__selected&&this.trigger("tabschange",{from:this.__getInfo(this.__prevSelected),to:e}),this):this},getIndexByButton:function(e){return t.inArray(e,this.__btns)},appendButtonTo:function(e){t.each(this.__btns,function(t,n){n.appendTo(e)})},appendPanelTo:function(e){t.each(this.__panels,function(t,n){n.appendTo(e)})},__render:function(){this.callBase(),this.__btnWrap=t(".fui-tabs-button-wrap",this.__element)[0],this.__panelWrap=t(".fui-tabs-panel-wrap",this.__element)[0],this.__renderByOptions(this.__options),this.__selectItem(this.__options.selected)},__renderByOptions:function(e){var n=this,o=[],a=this.__btns,s=this.__panels,l=this.__btnWrap,u=this.__panelWrap;return t.each(e.buttons,function(t,c){var h=null,d=null;"object"!=typeof c&&(c={label:c}),h=new i(c),h.on("click",function(){n.select(n.getIndexByButton(this))}),c=e.panels[t]||{},c.hide=!0,d=new r(c),a.push(h),s.push(d),o.push({button:h,panel:d}),h.appendTo(l),d.appendTo(u)}),o},__initOptions:function(){this.callBase(),this.widgetName="Tabs",this.__tpl=n,this.__btns=[],this.__panels=[],this.__prevSelected=-1,this.__selected=-1,this.__btnWrap=null,this.__panelWrap=null,null===this.__options.panels&&(this.__options.panels=[],this.__options.panels.length=this.__options.buttons.length)},__selectItem:function(t){var n=this.getButton(t),i=this.getButton(this.__selected),r=e.classPrefix+"selected";return n?(i&&(i.removeClass(r),this.getPanel(this.__selected).hide()),n.addClass(r),this.getPanel(t).show(),this.__prevSelected=this.__selected,this.__selected=t,!0):!1},__getInfo:function(t){return{index:t,button:this.getButton(t),panel:this.getPanel(t)}}})}},_p[59]={value:function(){var t=_p.r(4),e=_p.r(12);return _p.r(13).createClass("ToggleButton",{base:_p.r(37),constructor:function(e){var n={pressed:!1};e=t.extend({},n,e),this.callBase(e)},isPressed:function(){return this.__state},press:function(){var n=e.classPrefix+"button-pressed";t(this.__element).addClass(n),this.__updateState(!0)},bounce:function(){var n=e.classPrefix+"button-pressed";t(this.__element).removeClass(n),this.__updateState(!1)},toggle:function(){this.__state?this.bounce():this.press()},__initOptions:function(){this.callBase(),this.widgetName="ToggleButton",this.__state=!1},__render:function(){return this.callBase(),t(this.__element).addClass(e.classPrefix+"toggle-button"),this.__initButtonState(),this },__initButtonState:function(){this.__options.pressed&&(t(this.__element).addClass(e.classPrefix+"button-pressed"),this.__state=!0)},__initEvent:function(){this.callBase(),this.on("click",function(){this.toggle()})},__updateState:function(t){t=!!t,this.__state=t,this.trigger("change",t,!t)}})}},_p[60]={value:function(){function t(){return e+ ++n}var e="_fui_",n=0,i=_p.r(12),r=_p.r(11),o=_p.r(4),a=_p.r(13),s=a.createClass("Widget",{constructor:function(t){var e={id:null,className:"",disabled:!1,preventDefault:!1,text:"",value:null,hide:!1,width:null,height:null};this.__widgetType="widget",this.__tpl="",this.__compiledTpl="",this.__options={},this.__element=null,this.__allow_focus=!!i.allowFocus,this.widgetName="Widget",this.__extendOptions(e,t),this.__initOptions(),this.__render(),this.__initEvent(),this.__initWidgets&&this.__initWidgets()},getId:function(){return this.id},getValue:function(){return this.__options.value},getOptions:function(){return this.__options},setValue:function(t){return this.__options.value=t,this},show:function(){return this.__show(),this},hide:function(){return this.__hide(),this},addClass:function(t){return o(this.__element).addClass(t),this},removeClass:function(t){return o(this.__element).removeClass(t),this},setStyle:function(){return o.fn.css.apply(o(this.__element),arguments),this},getStyle:function(){return o.fn.css.apply(o(this.__element),arguments)},isDisabled:function(){return this.__options.disabled},enable:function(){return this.__options.disabled=!1,o(this.__element).removeClass(i.classPrefix+"disabled"),this},disable:function(){return this.__options.disabled=!0,o(this.__element).addClass(i.classPrefix+"disabled"),this},cloneElement:function(){return this.__element.cloneNode(!0)},getElement:function(){return this.__element},appendTo:function(t){if(a.isElement(t))t.appendChild(this.__element);else{if(!(t instanceof s))throw new Error("TypeError: Widget.appendTo()");t.__appendChild(this)}return this},remove:function(){var t=this.__element.parentNode;return t&&t.removeChild(this.__element),this},off:function(t,e){return o(this.__element).off(e&&e.__fui_listener),this},on:function(t,e){return this.__options.preventDefault||this.__on(t,e),this},__initOptions:function(){},__render:function(){var t=null,e=this.__tpl,n=this.__options,s=null;return this.id=this.__id(),r.__registerInstance(this),this.__compiledTpl=a.Tpl.compile(e,n),this.__element=o(this.__compiledTpl)[0],this.__element.setAttribute("id",this.id),t=o(this.__element),n.disabled&&t.addClass(i.classPrefix+"disabled"),t.addClass(i.classPrefix+"widget"),s=n.className,s.length>0&&t.addClass(o.isArray(s)?s.join(" "):s),this.__initBasicEnv(),n.hide&&this.__hide(),n.style&&this.setStyle(n.style),this},__appendChild:function(t){return this.__element.appendChild(t.getElement())},__initEvent:function(){this.on("mousedown",function(t){var e=t.target.tagName.toLowerCase();i.control[e]||this.__allowFocus()?t.stopPropagation():t.preventDefault()})},__on:function(t,e){var n=this;return e.__fui_listener=function(t,i){for(var r=[],o=0,a=arguments.length;a>o;o++)1!==o&&r.push(arguments[o]);return t.widget=i,n.isDisabled()?void 0:e.apply(n,r)},o(this.__element).on(t,e.__fui_listener),this},trigger:function(){return this.__options.preventDefault||this.__trigger.apply(this,arguments),this},__allowShowTitle:function(){return!0},__allowFocus:function(){return!!this.__allow_focus},__trigger:function(t){var e=[].slice.call(arguments,1);return o(this.__element).trigger(t,[this].concat(e)),this},__triggerHandler:function(t){var e=[this].concat([].slice.call(arguments,1));return o(this.__element).triggerHandler(t,e)},__fire:function(t,e){var n={cancel:!1};return/^(before|after)/.test(t)?this:(this.__trigger("before"+t,n),n.cancel===!0?this:(n=e.call(this,t),this.__trigger(t),this.__trigger("after"+t,n),this))},__extendOptions:function(){var t=[{},this.__options],e=[!0];t=t.concat([].slice.call(arguments,0));for(var n=0,i=t.length;i>n;n++)"string"!=typeof t[n]&&e.push(t[n]);this.__options=o.extend.apply(o,e)},__hide:function(){o(this.__element).addClass(i.classPrefix+"hide")},__show:function(){o(this.__element).removeClass(i.classPrefix+"hide")},__initBasicEnv:function(){this.__options.text&&this.__allowShowTitle()&&this.__element.setAttribute("title",this.__options.text),this.__options.width&&(this.__element.style.width=this.__options.width+"px"),this.__options.height&&(this.__element.style.height=this.__options.height+"px"),this.widgetName&&this.__element.setAttribute("rule",this.widgetName)},__id:function(){return this.__options.id||t()}});return s}},_p[61]={value:function(){_p.r(1),_p.r(2)}};var moduleMapping={"fui.export":61};use("fui.export")}(),function(t){function e(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t}function n(){Error.apply(this,arguments)}function i(t){if(Error.call(this,t),"object"==typeof t)for(var e in t)t.hasOwnProperty(e)&&(this[e]=t[e]);else this.detail=t}function r(t,e){this.id=t,this.username=e}function o(t){this.content=t,this.type=t instanceof Blob?u.file.TYPE_BLOB:"string"==typeof t?u.file.TYPE_TEXT:"object"==typeof t?u.file.TYPE_JSON:u.file.TYPE_UNKNOWN}function a(t){this.setPath(t),this.isDir=!1,this.data=null,this.size=0,this.createTime=new Date,this.modifyTime=new Date}function s(t,e,n){this.user=t,this.file=e,this.access=n||0}function l(t,e,n){this.path=t,this.method=e,this.user=n,this.dupPolicy=u.file.DUP_FAIL,this.newPath=null,this.acl=null,this.extra=null,this.dataType=u.file.TYPE_TEXT}var u={version:"1.0"};u.provider={},u.file={},u.user={};var c={},h=null,d=function(){return new t.resolve(null)},f={check:d,login:d,logout:d,init:d,current:d};e(n,Error),e(i,Error),u.AuthError=n,u.FileRequestError=i,a.prototype.setPath=function(t){u.file.anlysisPath(t,this)},u.file.anlysisPath=function(t,e){e=e||{};for(var n=t.split("/");"/"==n[0]||""===n[0];)n.shift();for(;"/"==n[n.length-1]||""===n[n.length-1];)n.pop();if(e.filename=n.pop()||null,e.parentPath=n.length?"/"+n.join("/")+"/":e.filename?"/":null,e.filename){var i=e.filename.split(".");e.extension=i.length>1?"."+i.pop():null,e.name=i.join("."),e.path=e.parentPath+e.filename}else e.path="/";return e},u.user.User=r,u.file.Data=o,u.file.File=a,u.file.Acl=s,u.file.FileRequest=l,u.file.TYPE_TEXT="text",u.file.TYPE_JSON="json",u.file.TYPE_BLOB="blob",u.file.TYPE_UNKNOWN="unknown",u.file.METHOD_READ="read",u.file.METHOD_WRITE="write",u.file.METHOD_LIST="list",u.file.METHOD_MOVE="move",u.file.METHOD_DELETE="delete",u.file.METHOD_MKDIR="mkdir",u.file.METHOD_ACL_READ="readAcl",u.file.METHOD_ACL_WRITE="writeAcl",u.file.DUP_OVERWRITE="overwrite",u.file.DUP_FAIL="fail",u.file.DUP_RENAME="rename",u.file.ACCESS_PUBLIC=1,u.file.ACCESS_READ=2,u.file.ACCESS_WRITE=4,u.file.ACCESS_CREATE=8,u.file.ACCESS_DELETE=16,u.file.ACCESS_ACL_READ=32,u.file.ACCESS_ACL_WRITE=64,u.file.ACCESS_ALL=65534,u.provider.register=function(t,e){if(c[t]=e,h||(h=e),"function"!=typeof e.handle)throw new Error("Not implement: provider.handle()")},u.provider.use=function(t){h=c[t]},u.provider.init=function(t,e){var n=c[t];return n&&"function"==typeof n.init?n.init.call(n,e):null},u.user.impl=function(t){f=t},["check","login","logout","init","current"].forEach(function(t){u.user[t]=function(){return f[t].apply(f,arguments)}}),["read","write","list","move","delete","mkdir","readAcl","writeAcl"].forEach(function(e){u.file[e]=function(n){return u.user.check().then(function(i){var r=n.provider?c[n.provider]:h,o=new l(n.path,e,i);"read"==e&&(o.dataType=n.dataType||u.file.TYPE_TEXT),"write"==e&&(o.dupPolicy=n.ondup,o.data=new u.file.Data(n.content),delete n.ondup),"move"==e&&(o.dupPolicy=n.ondup,o.newPath=n.newPath,delete n.newPath),"writeAcl"==e&&(o.acl=n.acl,delete n.acl),delete n.provider,delete n.path,o.extra=n;var a=r.handle(o);return t.resolve(a)})}}),window.fio=u}(Promise),function(){function t(t){this.tokens=[],this.tokens.links={},this.options=t||u.defaults,this.rules=c.normal,this.options.gfm&&(this.rules=this.options.tables?c.tables:c.gfm)}function e(t,e){if(this.options=e||u.defaults,this.links=t,this.rules=h.normal,this.renderer=this.options.renderer||new n,this.renderer.options=this.options,!this.links)throw new Error("Tokens array requires a `links` property.");this.options.gfm?this.rules=this.options.breaks?h.breaks:h.gfm:this.options.pedantic&&(this.rules=h.pedantic)}function n(t){this.options=t||{}}function i(t){this.tokens=[],this.token=null,this.options=t||u.defaults,this.options.renderer=this.options.renderer||new n,this.renderer=this.options.renderer,this.renderer.options=this.options}function r(t,e){return t.replace(e?/&/g:/&(?!#?\w+;)/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'")}function o(t){return t.replace(/&([#\w]+);/g,function(t,e){return e=e.toLowerCase(),"colon"===e?":":"#"===e.charAt(0)?String.fromCharCode("x"===e.charAt(1)?parseInt(e.substring(2),16):+e.substring(1)):""})}function a(t,e){return t=t.source,e=e||"",function n(i,r){return i?(r=r.source||r,r=r.replace(/(^|[^\[])\^/g,"$1"),t=t.replace(i,r),n):new RegExp(t,e)}}function s(){}function l(t){for(var e,n,i=1;iAn error occured:

"+r(d.message+"",!0)+"
";throw d}}var c={newline:/^\n+/,code:/^( {4}[^\n]+\n*)+/,fences:s,hr:/^( *[-*_]){3,} *(?:\n+|$)/,heading:/^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,nptable:s,lheading:/^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,blockquote:/^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,list:/^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,html:/^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,def:/^ *\[([^\]]+)\]: *]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,table:s,paragraph:/^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,text:/^[^\n]+/};c.bullet=/(?:[*+-]|\d+\.)/,c.item=/^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/,c.item=a(c.item,"gm")(/bull/g,c.bullet)(),c.list=a(c.list)(/bull/g,c.bullet)("hr","\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))")("def","\\n+(?="+c.def.source+")")(),c.blockquote=a(c.blockquote)("def",c.def)(),c._tag="(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b",c.html=a(c.html)("comment",//)("closed",/<(tag)[\s\S]+?<\/\1>/)("closing",/])*?>/)(/tag/g,c._tag)(),c.paragraph=a(c.paragraph)("hr",c.hr)("heading",c.heading)("lheading",c.lheading)("blockquote",c.blockquote)("tag","<"+c._tag)("def",c.def)(),c.normal=l({},c),c.gfm=l({},c.normal,{fences:/^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,paragraph:/^/}),c.gfm.paragraph=a(c.paragraph)("(?!","(?!"+c.gfm.fences.source.replace("\\1","\\2")+"|"+c.list.source.replace("\\1","\\3")+"|")(),c.tables=l({},c.gfm,{nptable:/^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,table:/^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/}),t.rules=c,t.lex=function(e,n){var i=new t(n);return i.lex(e)},t.prototype.lex=function(t){return t=t.replace(/\r\n|\r/g,"\n").replace(/\t/g," ").replace(/\u00a0/g," ").replace(/\u2424/g,"\n"),this.token(t,!0)},t.prototype.token=function(t,e,n){for(var i,r,o,a,s,l,u,h,d,t=t.replace(/^ +$/gm,"");t;)if((o=this.rules.newline.exec(t))&&(t=t.substring(o[0].length),o[0].length>1&&this.tokens.push({type:"space"})),o=this.rules.code.exec(t))t=t.substring(o[0].length),o=o[0].replace(/^ {4}/gm,""),this.tokens.push({type:"code",text:this.options.pedantic?o:o.replace(/\n+$/,"")});else if(o=this.rules.fences.exec(t))t=t.substring(o[0].length),this.tokens.push({type:"code",lang:o[2],text:o[3]});else if(o=this.rules.heading.exec(t))t=t.substring(o[0].length),this.tokens.push({type:"heading",depth:o[1].length,text:o[2]});else if(e&&(o=this.rules.nptable.exec(t))){for(t=t.substring(o[0].length),l={type:"table",header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/\n$/,"").split("\n")},h=0;h ?/gm,""),this.token(o,e,!0),this.tokens.push({type:"blockquote_end"});else if(o=this.rules.list.exec(t)){for(t=t.substring(o[0].length),a=o[2],this.tokens.push({type:"list_start",ordered:a.length>1}),o=o[0].match(this.rules.item),i=!1,d=o.length,h=0;d>h;h++)l=o[h],u=l.length,l=l.replace(/^ *([*+-]|\d+\.) +/,""),~l.indexOf("\n ")&&(u-=l.length,l=this.options.pedantic?l.replace(/^ {1,4}/gm,""):l.replace(new RegExp("^ {1,"+u+"}","gm"),"")),this.options.smartLists&&h!==d-1&&(s=c.bullet.exec(o[h+1])[0],a===s||a.length>1&&s.length>1||(t=o.slice(h+1).join("\n")+t,h=d-1)),r=i||/\n\n(?!\s*$)/.test(l),h!==d-1&&(i="\n"===l.charAt(l.length-1),r||(r=i)),this.tokens.push({type:r?"loose_item_start":"list_item_start"}),this.token(l,!1,n),this.tokens.push({type:"list_item_end"});this.tokens.push({type:"list_end"})}else if(o=this.rules.html.exec(t))t=t.substring(o[0].length),this.tokens.push({type:this.options.sanitize?"paragraph":"html",pre:"pre"===o[1]||"script"===o[1]||"style"===o[1],text:o[0]});else if(!n&&e&&(o=this.rules.def.exec(t)))t=t.substring(o[0].length),this.tokens.links[o[1].toLowerCase()]={href:o[2],title:o[3]};else if(e&&(o=this.rules.table.exec(t))){for(t=t.substring(o[0].length),l={type:"table",header:o[1].replace(/^ *| *\| *$/g,"").split(/ *\| */),align:o[2].replace(/^ *|\| *$/g,"").split(/ *\| */),cells:o[3].replace(/(?: *\| *)?\n$/,"").split("\n")},h=0;h])/,autolink:/^<([^ >]+(@|:\/)[^ >]+)>/,url:s,tag:/^|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,link:/^!?\[(inside)\]\(href\)/,reflink:/^!?\[(inside)\]\s*\[([^\]]*)\]/,nolink:/^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,strong:/^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,em:/^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,code:/^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,br:/^ {2,}\n(?!\s*$)/,del:s,text:/^[\s\S]+?(?=[\\?(?:\s+['"]([\s\S]*?)['"])?\s*/,h.link=a(h.link)("inside",h._inside)("href",h._href)(),h.reflink=a(h.reflink)("inside",h._inside)(),h.normal=l({},h),h.pedantic=l({},h.normal,{strong:/^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,em:/^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/}),h.gfm=l({},h.normal,{escape:a(h.escape)("])","~|])")(),url:/^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,del:/^~~(?=\S)([\s\S]*?\S)~~/,text:a(h.text)("]|","~]|")("|","|https?://|")()}),h.breaks=l({},h.gfm,{br:a(h.br)("{2,}","*")(),text:a(h.gfm.text)("{2,}","*")()}),e.rules=h,e.output=function(t,n,i){var r=new e(n,i);return r.output(t)},e.prototype.output=function(t){for(var e,n,i,o,a="";t;)if(o=this.rules.escape.exec(t))t=t.substring(o[0].length),a+=o[1];else if(o=this.rules.autolink.exec(t))t=t.substring(o[0].length),"@"===o[2]?(n=this.mangle(":"===o[1].charAt(6)?o[1].substring(7):o[1]),i=this.mangle("mailto:")+n):(n=r(o[1]),i=n),a+=this.renderer.link(i,null,n);else if(this.inLink||!(o=this.rules.url.exec(t))){if(o=this.rules.tag.exec(t))!this.inLink&&/^/i.test(o[0])&&(this.inLink=!1),t=t.substring(o[0].length),a+=this.options.sanitize?r(o[0]):o[0];else if(o=this.rules.link.exec(t))t=t.substring(o[0].length),this.inLink=!0,a+=this.outputLink(o,{href:o[2],title:o[3]}),this.inLink=!1;else if((o=this.rules.reflink.exec(t))||(o=this.rules.nolink.exec(t))){if(t=t.substring(o[0].length),e=(o[2]||o[1]).replace(/\s+/g," "),e=this.links[e.toLowerCase()],!e||!e.href){a+=o[0].charAt(0),t=o[0].substring(1)+t;continue}this.inLink=!0,a+=this.outputLink(o,e),this.inLink=!1}else if(o=this.rules.strong.exec(t))t=t.substring(o[0].length),a+=this.renderer.strong(this.output(o[2]||o[1]));else if(o=this.rules.em.exec(t))t=t.substring(o[0].length),a+=this.renderer.em(this.output(o[2]||o[1]));else if(o=this.rules.code.exec(t))t=t.substring(o[0].length),a+=this.renderer.codespan(r(o[2],!0));else if(o=this.rules.br.exec(t))t=t.substring(o[0].length),a+=this.renderer.br();else if(o=this.rules.del.exec(t))t=t.substring(o[0].length),a+=this.renderer.del(this.output(o[1]));else if(o=this.rules.text.exec(t))t=t.substring(o[0].length),a+=r(this.smartypants(o[0]));else if(t)throw new Error("Infinite loop on byte: "+t.charCodeAt(0))}else t=t.substring(o[0].length),n=r(o[1]),i=n,a+=this.renderer.link(i,null,n);return a},e.prototype.outputLink=function(t,e){var n=r(e.href),i=e.title?r(e.title):null;return"!"!==t[0].charAt(0)?this.renderer.link(n,i,this.output(t[1])):this.renderer.image(n,i,r(t[1]))},e.prototype.smartypants=function(t){return this.options.smartypants?t.replace(/--/g,"—").replace(/(^|[-\u2014\/(\[{"\s])'/g,"$1‘").replace(/'/g,"’").replace(/(^|[-\u2014\/(\[{\u2018\s])"/g,"$1“").replace(/"/g,"”").replace(/\.{3}/g,"…"):t},e.prototype.mangle=function(t){for(var e,n="",i=t.length,r=0;i>r;r++)e=t.charCodeAt(r),Math.random()>.5&&(e="x"+e.toString(16)),n+="&#"+e+";";return n},n.prototype.code=function(t,e,n){if(this.options.highlight){var i=this.options.highlight(t,e);null!=i&&i!==t&&(n=!0,t=i)}return e?'
'+(n?t:r(t,!0))+"\n
\n":"
"+(n?t:r(t,!0))+"\n
"},n.prototype.blockquote=function(t){return"
\n"+t+"
\n"},n.prototype.html=function(t){return t},n.prototype.heading=function(t,e,n){return"'+t+"\n"},n.prototype.hr=function(){return this.options.xhtml?"
\n":"
\n"},n.prototype.list=function(t,e){var n=e?"ol":"ul";return"<"+n+">\n"+t+"\n"},n.prototype.listitem=function(t){return"
  • "+t+"
  • \n"},n.prototype.paragraph=function(t){return"

    "+t+"

    \n"},n.prototype.table=function(t,e){return"\n\n"+t+"\n\n"+e+"\n
    \n"},n.prototype.tablerow=function(t){return"\n"+t+"\n"},n.prototype.tablecell=function(t,e){var n=e.header?"th":"td",i=e.align?"<"+n+' style="text-align:'+e.align+'">':"<"+n+">";return i+t+"\n"},n.prototype.strong=function(t){return""+t+""},n.prototype.em=function(t){return""+t+""},n.prototype.codespan=function(t){return""+t+""},n.prototype.br=function(){return this.options.xhtml?"
    ":"
    "},n.prototype.del=function(t){return""+t+""},n.prototype.link=function(t,e,n){if(this.options.sanitize){try{var i=decodeURIComponent(o(t)).replace(/[^\w:]/g,"").toLowerCase()}catch(r){return""}if(0===i.indexOf("javascript:"))return""}var a='
    "},n.prototype.image=function(t,e,n){var i=''+n+'":">"},i.parse=function(t,e,n){var r=new i(e,n);return r.parse(t)},i.prototype.parse=function(t){this.inline=new e(t.links,this.options,this.renderer),this.tokens=t.reverse();for(var n="";this.next();)n+=this.tok();return n},i.prototype.next=function(){return this.token=this.tokens.pop()},i.prototype.peek=function(){return this.tokens[this.tokens.length-1]||0},i.prototype.parseText=function(){for(var t=this.token.text;"text"===this.peek().type;)t+="\n"+this.next().text;return this.inline.output(t)},i.prototype.tok=function(){switch(this.token.type){case"space":return"";case"hr":return this.renderer.hr();case"heading":return this.renderer.heading(this.inline.output(this.token.text),this.token.depth,this.token.text);case"code":return this.renderer.code(this.token.text,this.token.lang,this.token.escaped);case"table":var t,e,n,i,r,o="",a="";for(n="",t=0;tta&&setTimeout(vo(Sn,this,!0),20),En(this),Po(),Ze(this),this.curOp.forceUpdate=!0,Er(this,r),i.autofocus&&!ca||So()==o.input?setTimeout(vo(Jn,this),20):Zn(this);for(var a in Da)Da.hasOwnProperty(a)&&Da[a](this,i[a],Ia);b(this);for(var s=0;sta&&(n.gutters.style.zIndex=-1,n.scroller.style.paddingRight=0),ua&&(i.style.width="0px"),ea||(n.scroller.draggable=!0),aa&&(n.inputDiv.style.height="1px",n.inputDiv.style.position="absolute"),Zo&&8>ta&&(n.scrollbarH.style.minHeight=n.scrollbarV.style.minWidth="18px"),t.appendChild?t.appendChild(n.wrapper):t(n.wrapper),n.viewFrom=n.viewTo=e.first,n.view=[],n.externalMeasured=null,n.viewOffset=0,n.lastSizeC=0,n.updateLineNumbers=null,n.lineNumWidth=n.lineNumInnerWidth=n.lineNumChars=null,n.prevInput="",n.alignWidgets=!1,n.pollingFast=!1,n.poll=new lo,n.cachedCharWidth=n.cachedTextHeight=n.cachedPaddingH=null,n.inaccurateSelection=!1,n.maxLine=null,n.maxLineLength=0,n.maxLineChanged=!1,n.wheelDX=n.wheelDY=n.wheelStartX=n.wheelStartY=null,n.shift=!1,n.selForContextMenu=null}function n(e){e.doc.mode=t.getMode(e.options,e.doc.modeOption),i(e)}function i(t){t.doc.iter(function(t){t.stateAfter&&(t.stateAfter=null),t.styles&&(t.styles=null)}),t.doc.frontier=t.doc.first,we(t,100),t.state.modeGen++,t.curOp&&gn(t)}function r(t){t.options.lineWrapping?(Lo(t.display.wrapper,"CodeMirror-wrap"),t.display.sizer.style.minWidth=""):(Mo(t.display.wrapper,"CodeMirror-wrap"),f(t)),a(t),gn(t),Ve(t),setTimeout(function(){v(t)},100)}function o(t){var e=Qe(t.display),n=t.options.lineWrapping,i=n&&Math.max(5,t.display.scroller.clientWidth/Je(t.display)-3);return function(r){if(nr(t.doc,r))return 0;var o=0;if(r.widgets)for(var a=0;ae.maxLineLength&&(e.maxLineLength=n,e.maxLine=t)})}function p(t){var e=fo(t.gutters,"CodeMirror-linenumbers");-1==e&&t.lineNumbers?t.gutters=t.gutters.concat(["CodeMirror-linenumbers"]):e>-1&&!t.lineNumbers&&(t.gutters=t.gutters.slice(0),t.gutters.splice(e,1))}function g(t){return t.display.scroller.clientHeight-t.display.wrapper.clientHeighte.clientWidth;o&&e.scrollWidth<=e.clientWidth+1&&i>0&&!e.hScrollbarTakesSpace&&(o=!1);var a=r>e.clientHeight;if(a?(n.scrollbarV.style.display="block",n.scrollbarV.style.bottom=o?i+"px":"0",n.scrollbarV.firstChild.style.height=Math.max(0,r-e.clientHeight+(e.barHeight||n.scrollbarV.clientHeight))+"px"):(n.scrollbarV.style.display="",n.scrollbarV.firstChild.style.height="0"),o?(n.scrollbarH.style.display="block",n.scrollbarH.style.right=a?i+"px":"0",n.scrollbarH.firstChild.style.width=e.scrollWidth-e.clientWidth+(e.barWidth||n.scrollbarH.clientWidth)+"px"):(n.scrollbarH.style.display="",n.scrollbarH.firstChild.style.width="0"),o&&a?(n.scrollbarFiller.style.display="block",n.scrollbarFiller.style.height=n.scrollbarFiller.style.width=i+"px"):n.scrollbarFiller.style.display="",o&&t.options.coverGutterNextToScrollbar&&t.options.fixedGutter?(n.gutterFiller.style.display="block",n.gutterFiller.style.height=i+"px",n.gutterFiller.style.width=n.gutters.offsetWidth+"px"):n.gutterFiller.style.display="",!t.state.checkedOverlayScrollbar&&e.clientHeight>0){if(0===i){var s=ha&&!sa?"12px":"18px";n.scrollbarV.style.minWidth=n.scrollbarH.style.minHeight=s;var l=function(e){to(e)!=n.scrollbarV&&to(e)!=n.scrollbarH&&cn(t,On)(e)};us(n.scrollbarV,"mousedown",l),us(n.scrollbarH,"mousedown",l)}t.state.checkedOverlayScrollbar=!0}}function y(t,e,n){var i=n&&null!=n.top?Math.max(0,n.top):t.scroller.scrollTop;i=Math.floor(i-Te(t));var r=n&&null!=n.bottom?n.bottom:i+t.wrapper.clientHeight,o=Ir(e,i),a=Ir(e,r);if(n&&n.ensure){var s=n.ensure.from.line,l=n.ensure.to.line;if(o>s)return{from:s,to:Ir(e,Br(Nr(e,s))+t.wrapper.clientHeight)};if(Math.min(l,e.lastLine())>=a)return{from:Ir(e,Br(Nr(e,l))-t.wrapper.clientHeight),to:l}}return{from:o,to:Math.max(a,o+1)}}function _(t){var e=t.display,n=e.view;if(e.alignWidgets||e.gutters.firstChild&&t.options.fixedGutter){for(var i=w(e)-e.scroller.scrollLeft+t.doc.scrollLeft,r=e.gutters.offsetWidth,o=i+"px",a=0;a=n.viewFrom&&e.visible.to<=n.viewTo&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo)&&0==xn(t))return!1;b(t)&&(vn(t),e.dims=P(t));var r=i.first+i.size,o=Math.max(e.visible.from-t.options.viewportMargin,i.first),a=Math.min(r,e.visible.to+t.options.viewportMargin);n.viewFroma&&n.viewTo-a<20&&(a=Math.min(r,n.viewTo)),va&&(o=tr(t.doc,o),a=er(t.doc,a));var s=o!=n.viewFrom||a!=n.viewTo||n.lastSizeC!=e.wrapperHeight;bn(t,o,a),n.viewOffset=Br(Nr(t.doc,n.viewFrom)),t.display.mover.style.top=n.viewOffset+"px";var l=xn(t);if(!s&&0==l&&!e.force&&(null==n.updateLineNumbers||n.updateLineNumbers>=n.viewTo))return!1;var u=So();return l>4&&(n.lineDiv.style.display="none"),A(t,n.updateLineNumbers,e.dims),l>4&&(n.lineDiv.style.display=""),u&&So()!=u&&u.offsetHeight&&u.focus(),wo(n.cursorDiv),wo(n.selectionDiv),s&&(n.lastSizeC=e.wrapperHeight,we(t,400)),n.updateLineNumbers=null,!0}function S(t,e){for(var n=e.force,i=e.viewport,r=!0;;r=!1){if(r&&t.options.lineWrapping&&e.oldScrollerWidth!=t.display.scroller.clientWidth)n=!0;else if(n=!1,i&&null!=i.top&&(i={top:Math.min(t.doc.height+Me(t.display)-fs-t.display.scroller.clientHeight,i.top)}),e.visible=y(t.display,t.doc,i),e.visible.from>=t.display.viewFrom&&e.visible.to<=t.display.viewTo)break;if(!C(t,e))break;E(t);var o=m(t);ye(t),M(t,o),v(t,o)}no(t,"update",t),(t.display.viewFrom!=e.oldViewFrom||t.display.viewTo!=e.oldViewTo)&&no(t,"viewportChange",t,t.display.viewFrom,t.display.viewTo)}function T(t,e){var n=new k(t,e);if(C(t,n)){E(t),S(t,n);var i=m(t);ye(t),M(t,i),v(t,i)}}function M(t,e){t.display.sizer.style.minHeight=t.display.heightForcer.style.top=e.docHeight+"px",t.display.gutters.style.height=Math.max(e.docHeight,e.clientHeight-fs)+"px"}function L(t,e){t.display.sizer.offsetWidth+t.display.gutters.offsetWidthta){var a=o.node.offsetTop+o.node.offsetHeight;r=a-n,n=a}else{var s=o.node.getBoundingClientRect();r=s.bottom-s.top}var l=o.line.height-r;if(2>r&&(r=Qe(e)),(l>.001||-.001>l)&&(Or(o.line,r),N(o.line),o.rest))for(var u=0;u=e&&h.lineNumber;h.changes&&(fo(h.changes,"gutter")>-1&&(d=!1),O(t,h,u,n)),d&&(wo(h.lineNumber),h.lineNumber.appendChild(document.createTextNode(x(t.options,u)))),s=h.node.nextSibling}else{var f=z(t,h,u,n);a.insertBefore(f,s)}u+=h.size}for(;s;)s=i(s)}function O(t,e,n,i){for(var r=0;rta&&(t.node.style.zIndex=2)),t.node}function I(t){var e=t.bgClass?t.bgClass+" "+(t.line.bgClass||""):t.line.bgClass;if(e&&(e+=" CodeMirror-linebackground"),t.background)e?t.background.className=e:(t.background.parentNode.removeChild(t.background),t.background=null);else if(e){var n=D(t);t.background=n.insertBefore(xo("div",null,e),n.firstChild)}}function B(t,e){var n=t.display.externalMeasured;return n&&n.line==e.line?(t.display.externalMeasured=null,e.measure=n.measure,n.built):vr(t,e)}function R(t,e){var n=e.text.className,i=B(t,e);e.text==e.node&&(e.node=i.pre),e.text.parentNode.replaceChild(i.pre,e.text),e.text=i.pre,i.bgClass!=e.bgClass||i.textClass!=e.textClass?(e.bgClass=i.bgClass,e.textClass=i.textClass,W(e)):n&&(e.text.className=n)}function W(t){I(t),t.line.wrapClass?D(t).className=t.line.wrapClass:t.node!=t.text&&(t.node.className="");var e=t.textClass?t.textClass+" "+(t.line.textClass||""):t.line.textClass;t.text.className=e||""}function H(t,e,n,i){e.gutter&&(e.node.removeChild(e.gutter),e.gutter=null);var r=e.line.gutterMarkers;if(t.options.lineNumbers||r){var o=D(e),a=e.gutter=o.insertBefore(xo("div",null,"CodeMirror-gutter-wrapper","position: absolute; left: "+(t.options.fixedGutter?i.fixedPos:-i.gutterTotalWidth)+"px"),e.text);if(!t.options.lineNumbers||r&&r["CodeMirror-linenumbers"]||(e.lineNumber=a.appendChild(xo("div",x(t.options,n),"CodeMirror-linenumber CodeMirror-gutter-elt","left: "+i.gutterLeft["CodeMirror-linenumbers"]+"px; width: "+t.display.lineNumInnerWidth+"px"))),r)for(var s=0;s=0){var a=$(o.from(),r.from()),s=q(o.to(),r.to()),l=o.empty()?r.from()==r.head:o.from()==o.head;e>=i&&--e,t.splice(--i,2,new X(l?s:a,l?a:s))}}return new G(t,e)}function Q(t,e){return new G([new X(t,e||t)],0)}function J(t,e){return Math.max(t.first,Math.min(e,t.first+t.size-1))}function Z(t,e){if(e.linen?ya(n,Nr(t,n).text.length):te(e,Nr(t,e.line).text.length)}function te(t,e){var n=t.ch;return null==n||n>e?ya(t.line,e):0>n?ya(t.line,0):t}function ee(t,e){return e>=t.first&&e=o.ch:u.to>o.ch))){if(i&&(hs(c,"beforeCursorEnter"),c.explicitlyCleared)){if(s.markedSpans){--l;continue}break}if(!c.atomic)continue;var h=c.find(0>a?-1:1);if(0==_a(h,o)&&(h.ch+=a,h.ch<0?h=h.line>t.first?Z(t,ya(h.line-1)):null:h.ch>s.text.length&&(h=h.linee&&(e=0),e=Math.round(e),i=Math.round(i),s.appendChild(xo("div",null,"CodeMirror-selected","position: absolute; left: "+t+"px; top: "+e+"px; width: "+(null==n?c-t:n)+"px; height: "+(i-e)+"px"))}function r(e,n,r){function o(n,i){return Ke(t,ya(e,n),"div",h,i)}var s,l,h=Nr(a,e),d=h.text.length;return Ro(Rr(h),n||0,null==r?d:r,function(t,e,a){var h,f,p,g=o(t,"left");if(t==e)h=g,f=p=g.left;else{if(h=o(e-1,"right"),"rtl"==a){var m=g;g=h,h=m}f=g.left,p=h.right}null==n&&0==t&&(f=u),h.top-g.top>3&&(i(f,g.top,null,g.bottom),f=u,g.bottoml.bottom||h.bottom==l.bottom&&h.right>l.right)&&(l=h),u+1>f&&(f=u),i(f,h.top,p-f,h.bottom)}),{start:s,end:l}}var o=t.display,a=t.doc,s=document.createDocumentFragment(),l=Le(t.display),u=l.left,c=o.lineSpace.offsetWidth-l.right,h=e.from(),d=e.to();if(h.line==d.line)r(h.line,h.ch,d.ch);else{var f=Nr(a,h.line),p=Nr(a,d.line),g=Ji(f)==Ji(p),m=r(h.line,h.ch,g?f.text.length+1:null).end,v=r(d.line,g?0:null,d.ch).start;g&&(m.top0?e.blinker=setInterval(function(){e.cursorDiv.style.visibility=(n=!n)?"":"hidden"},t.options.cursorBlinkRate):t.options.cursorBlinkRate<0&&(e.cursorDiv.style.visibility="hidden")}}function we(t,e){t.doc.mode.startState&&t.doc.frontier=t.display.viewTo)){var n=+new Date+t.options.workTime,i=za(e.mode,Se(t,e.frontier)),r=[];e.iter(e.frontier,Math.min(e.first+e.size,t.display.viewTo+500),function(o){if(e.frontier>=t.display.viewFrom){var a=o.styles,s=fr(t,o,i,!0);o.styles=s.styles;var l=o.styleClasses,u=s.classes;u?o.styleClasses=u:l&&(o.styleClasses=null);for(var c=!a||a.length!=o.styles.length||l!=u&&(!l||!u||l.bgClass!=u.bgClass||l.textClass!=u.textClass),h=0;!c&&hn?(we(t,t.options.workDelay),!0):void 0}),r.length&&un(t,function(){for(var e=0;ea;--s){if(s<=o.first)return o.first;var l=Nr(o,s-1);if(l.stateAfter&&(!n||s<=o.frontier))return s;var u=ys(l.text,null,t.options.tabSize);(null==r||i>u)&&(r=s-1,i=u)}return r}function Se(t,e,n){var i=t.doc,r=t.display;if(!i.mode.startState)return!0;var o=Ce(t,e,n),a=o>i.first&&Nr(i,o-1).stateAfter;return a=a?za(i.mode,a):Fa(i.mode),i.iter(o,e,function(n){gr(t,n.text,a);var s=o==e-1||o%5==0||o>=r.viewFrom&&o2&&o.push((l.bottom+u.top)/2-n.top)}}o.push(n.bottom-n.top)}}function Ne(t,e,n){if(t.line==e)return{map:t.measure.map,cache:t.measure.cache};for(var i=0;in)return{map:t.measure.maps[i],cache:t.measure.caches[i],before:!0}}function Pe(t,e){e=Ji(e);var n=Dr(e),i=t.display.externalMeasured=new fn(t.doc,e,n);i.lineN=n;var r=i.built=vr(t,i);return i.text=r.pre,ko(t.display.lineMeasure,r.pre),i}function Ae(t,e,n,i){return Ie(t,De(t,e),n,i)}function Oe(t,e){if(e>=t.display.viewFrom&&e=n.lineN&&en?(o=0,a=1,s="left"):h>n?(o=n-c,a=o+1):(u==l.length-3||n==h&&l[u+3]>n)&&(a=h-c,o=a-1,n>=h&&(s="right")),null!=o){if(r=l[u+2],c==h&&i==(r.insertLeft?"left":"right")&&(s=i),"left"==i&&0==o)for(;u&&l[u-2]==l[u-3]&&l[u-1].insertLeft;)r=l[(u-=3)+2],s="left";if("right"==i&&o==h-c)for(;uu;u++){for(;o&&bo(e.line.text.charAt(c+o));)--o;for(;h>c+a&&bo(e.line.text.charAt(c+a));)++a;if(Zo&&9>ta&&0==o&&a==h-c)d=r.parentNode.getBoundingClientRect();else if(Zo&&t.options.lineWrapping){var f=xs(r,o,a).getClientRects();d=f.length?f["right"==i?f.length-1:0]:ka}else d=xs(r,o,a).getBoundingClientRect()||ka;if(d.left||d.right||0==o)break;a=o,o-=1,s="right"}Zo&&11>ta&&(d=Re(t.display.measure,d))}else{o>0&&(s=i="right");var f;d=t.options.lineWrapping&&(f=r.getClientRects()).length>1?f["right"==i?f.length-1:0]:r.getBoundingClientRect()}if(Zo&&9>ta&&!o&&(!d||!d.left&&!d.right)){var p=r.parentNode.getClientRects()[0];d=p?{left:p.left,right:p.left+Je(t.display),top:p.top,bottom:p.bottom}:ka}for(var g=d.top-e.rect.top,m=d.bottom-e.rect.top,v=(g+m)/2,y=e.view.measure.heights,u=0;un.from?a(t-1):a(t,i)}i=i||Nr(t.doc,e.line),r||(r=De(t,i));var l=Rr(i),u=e.ch;if(!l)return a(u);var c=qo(l,u),h=s(u,c);return null!=Is&&(h.other=s(u,Is)),h}function $e(t,e){var n=0,e=Z(t.doc,e);t.options.lineWrapping||(n=Je(t.display)*e.ch);var i=Nr(t.doc,e.line),r=Br(i)+Te(t.display);return{left:n,right:n,top:r,bottom:r+i.height}}function Ge(t,e,n,i){var r=ya(t,e);return r.xRel=i,n&&(r.outside=!0),r}function Xe(t,e,n){var i=t.doc;if(n+=t.display.viewOffset,0>n)return Ge(i.first,0,!0,-1);var r=Ir(i,n),o=i.first+i.size-1;if(r>o)return Ge(i.first+i.size-1,Nr(i,o).text.length,!0,1);0>e&&(e=0);for(var a=Nr(i,r);;){var s=Ye(t,a,r,e,n),l=Yi(a),u=l&&l.find(0,!0);if(!l||!(s.ch>u.from.ch||s.ch==u.from.ch&&s.xRel>0))return s;r=Dr(a=u.to.line)}}function Ye(t,e,n,i,r){function o(i){var r=qe(t,ya(n,i),"line",e,u);return s=!0,a>r.bottom?r.left-l:am)return Ge(n,f,v,1);for(;;){if(c?f==d||f==Go(e,d,1):1>=f-d){for(var y=p>i||m-i>=i-p?d:f,_=i-(y==d?p:m);bo(e.text.charAt(y));)++y;var b=Ge(n,y,y==d?g:v,-1>_?-1:_>1?1:0);return b}var x=Math.ceil(h/2),w=d+x;if(c){w=d;for(var k=0;x>k;++k)w=Go(e,w,1)}var C=o(w);C>i?(f=w,m=C,(v=s)&&(m+=1e3),h=x):(d=w,p=C,g=s,h-=x)}}function Qe(t){if(null!=t.cachedTextHeight)return t.cachedTextHeight;if(null==ba){ba=xo("pre");for(var e=0;49>e;++e)ba.appendChild(document.createTextNode("x")),ba.appendChild(xo("br"));ba.appendChild(document.createTextNode("x"))}ko(t.measure,ba);var n=ba.offsetHeight/50;return n>3&&(t.cachedTextHeight=n),wo(t.measure),n||1}function Je(t){if(null!=t.cachedCharWidth)return t.cachedCharWidth;var e=xo("span","xxxxxxxxxx"),n=xo("pre",[e]);ko(t.measure,n);var i=e.getBoundingClientRect(),r=(i.right-i.left)/10;return r>2&&(t.cachedCharWidth=r),r||10}function Ze(t){t.curOp={cm:t,viewChanged:!1,startHeight:t.doc.height,forceUpdate:!1,updateInput:null,typing:!1,changeObjs:null,cursorActivityHandlers:null,cursorActivityCalled:0,selectionChanged:!1,updateMaxLine:!1,scrollLeft:null,scrollTop:null,scrollToPos:null,id:++Sa},Ca?Ca.ops.push(t.curOp):t.curOp.ownsGroup=Ca={ops:[t.curOp],delayedCallbacks:[]}}function tn(t){var e=t.delayedCallbacks,n=0;do{for(;n=n.viewTo)||n.maxLineChanged&&e.options.lineWrapping,t.update=t.mustUpdate&&new k(e,t.mustUpdate&&{top:t.scrollTop,ensure:t.scrollToPos},t.forceUpdate)}function on(t){t.updatedDisplay=t.mustUpdate&&C(t.cm,t.update)}function an(t){var e=t.cm,n=e.display;t.updatedDisplay&&E(e),t.barMeasure=m(e),n.maxLineChanged&&!e.options.lineWrapping&&(t.adjustWidthTo=Ae(e,n.maxLine,n.maxLine.text.length).left+3,t.maxScrollLeft=Math.max(0,n.sizer.offsetLeft+t.adjustWidthTo+fs-n.scroller.clientWidth)),(t.updatedDisplay||t.selectionChanged)&&(t.newSelectionNodes=me(e))}function sn(t){var e=t.cm;null!=t.adjustWidthTo&&(e.display.sizer.style.minWidth=t.adjustWidthTo+"px",t.maxScrollLeft1&&v(e),t.updatedDisplay&&S(e,t.update),null==n.wheelStartX||null==t.scrollTop&&null==t.scrollLeft&&!t.scrollToPos||(n.wheelStartX=n.wheelStartY=null),null!=t.scrollTop&&(n.scroller.scrollTop!=t.scrollTop||t.forceScroll)){var r=Math.max(0,Math.min(n.scroller.scrollHeight-n.scroller.clientHeight,t.scrollTop));n.scroller.scrollTop=n.scrollbarV.scrollTop=i.scrollTop=r}if(null!=t.scrollLeft&&(n.scroller.scrollLeft!=t.scrollLeft||t.forceScroll)){var o=Math.max(0,Math.min(n.scroller.scrollWidth-n.scroller.clientWidth,t.scrollLeft));n.scroller.scrollLeft=n.scrollbarH.scrollLeft=i.scrollLeft=o,_(e)}if(t.scrollToPos){var a=gi(e,Z(i,t.scrollToPos.from),Z(i,t.scrollToPos.to),t.scrollToPos.margin);t.scrollToPos.isCursor&&e.state.focused&&pi(e,a)}var s=t.maybeHiddenMarkers,l=t.maybeUnhiddenMarkers;if(s)for(var u=0;ut.barMeasure.clientWidth&&t.barMeasure.scrollWidtho;o=i){var a=new fn(t.doc,Nr(t.doc,o),o);i=o+a.size,r.push(a)}return r}function gn(t,e,n,i){null==e&&(e=t.doc.first),null==n&&(n=t.doc.first+t.doc.size),i||(i=0);var r=t.display;if(i&&ne)&&(r.updateLineNumbers=e),t.curOp.viewChanged=!0,e>=r.viewTo)va&&tr(t.doc,e)r.viewFrom?vn(t):(r.viewFrom+=i,r.viewTo+=i);else if(e<=r.viewFrom&&n>=r.viewTo)vn(t);else if(e<=r.viewFrom){var o=_n(t,n,n+i,1);o?(r.view=r.view.slice(o.index),r.viewFrom=o.lineN,r.viewTo+=i):vn(t)}else if(n>=r.viewTo){var o=_n(t,e,e,-1);o?(r.view=r.view.slice(0,o.index),r.viewTo=o.lineN):vn(t)}else{var a=_n(t,e,e,-1),s=_n(t,n,n+i,1);a&&s?(r.view=r.view.slice(0,a.index).concat(pn(t,a.lineN,s.lineN)).concat(r.view.slice(s.index)),r.viewTo+=i):vn(t)}var l=r.externalMeasured;l&&(n=r.lineN&&e=i.viewTo)){var o=i.view[yn(t,e)];if(null!=o.node){var a=o.changes||(o.changes=[]);-1==fo(a,n)&&a.push(n)}}}function vn(t){t.display.viewFrom=t.display.viewTo=t.doc.first,t.display.view=[],t.display.viewOffset=0}function yn(t,e){if(e>=t.display.viewTo)return null;if(e-=t.display.viewFrom,0>e)return null;for(var n=t.display.view,i=0;ie)return i}function _n(t,e,n,i){var r,o=yn(t,e),a=t.display.view;if(!va||n==t.doc.first+t.doc.size)return{index:o,lineN:n};for(var s=0,l=t.display.viewFrom;o>s;s++)l+=a[s].size;if(l!=e){if(i>0){if(o==a.length-1)return null;r=l+a[o].size-e,o++}else r=l-e;e+=r,n+=r}for(;tr(t.doc,n)!=n;){if(o==(0>i?0:a.length-1))return null;n+=i*a[o-(0>i?1:0)].size,o+=i}return{index:o,lineN:n}}function bn(t,e,n){var i=t.display,r=i.view;0==r.length||e>=i.viewTo||n<=i.viewFrom?(i.view=pn(t,e,n),i.viewFrom=e):(i.viewFrom>e?i.view=pn(t,e,i.viewFrom).concat(i.view):i.viewFromn&&(i.view=i.view.slice(0,yn(t,n)))),i.viewTo=n}function xn(t){for(var e=t.display.view,n=0,i=0;i=9&&t.display.inputHasSelection===r||ha&&/[\uf700-\uf7ff]/.test(r))return Sn(t),!1;var o=!t.curOp;o&&Ze(t),t.display.shift=!1,8203!=r.charCodeAt(0)||i.sel!=t.display.selForContextMenu||n||(n="​");for(var a=0,s=Math.min(n.length,r.length);s>a&&n.charCodeAt(a)==r.charCodeAt(a);)++a;var l=r.slice(a),u=Ns(l),c=null;t.state.pasteIncoming&&i.sel.ranges.length>1&&(Ta&&Ta.join("\n")==l?c=i.sel.ranges.length%Ta.length==0&&po(Ta,Ns):u.length==i.sel.ranges.length&&(c=po(u,function(t){return[t]})));for(var h=i.sel.ranges.length-1;h>=0;h--){var d=i.sel.ranges[h],f=d.from(),p=d.to();a-1){xi(t,y.line,"smart");break}}else v.electricInput&&v.electricInput.test(Nr(i,y.line).text.slice(0,y.ch))&&xi(t,y.line,"smart")}}return _i(t),t.curOp.updateInput=g,t.curOp.typing=!0,r.length>1e3||r.indexOf("\n")>-1?e.value=t.display.prevInput="":t.display.prevInput=r,o&&en(t),t.state.pasteIncoming=t.state.cutIncoming=!1,!0}function Sn(t,e){var n,i,r=t.doc;if(t.somethingSelected()){t.display.prevInput="";var o=r.sel.primary();n=As&&(o.to().line-o.from().line>100||(i=t.getSelection()).length>1e3);var a=n?"-":i||t.getSelection();t.display.input.value=a,t.state.focused&&bs(t.display.input),Zo&&ta>=9&&(t.display.inputHasSelection=a)}else e||(t.display.prevInput=t.display.input.value="",Zo&&ta>=9&&(t.display.inputHasSelection=null));t.display.inaccurateSelection=n}function Tn(t){"nocursor"==t.options.readOnly||ca&&So()==t.display.input||t.display.input.focus()}function Mn(t){t.state.focused||(Tn(t),Jn(t))}function Ln(t){return t.options.readOnly||t.doc.cantEdit}function En(t){function e(){t.state.focused&&setTimeout(vo(Tn,t),0)}function n(e){ro(t,e)||ls(e)}function i(e){if(t.somethingSelected())Ta=t.getSelections(),r.inaccurateSelection&&(r.prevInput="",r.inaccurateSelection=!1,r.input.value=Ta.join("\n"),bs(r.input));else{for(var n=[],i=[],o=0;ota?us(r.scroller,"dblclick",cn(t,function(e){if(!ro(t,e)){var n=An(t,e);if(n&&!Wn(t,e)&&!Pn(t.display,e)){as(e);var i=t.findWordAt(n);re(t.doc,i.anchor,i.head)}}})):us(r.scroller,"dblclick",function(e){ro(t,e)||as(e)}),us(r.lineSpace,"selectstart",function(t){Pn(r,t)||as(t)}),ga||us(r.scroller,"contextmenu",function(e){ti(t,e)}),us(r.scroller,"scroll",function(){r.scroller.clientHeight&&(zn(t,r.scroller.scrollTop),Fn(t,r.scroller.scrollLeft,!0),hs(t,"scroll",t))}),us(r.scrollbarV,"scroll",function(){r.scroller.clientHeight&&zn(t,r.scrollbarV.scrollTop)}),us(r.scrollbarH,"scroll",function(){r.scroller.clientHeight&&Fn(t,r.scrollbarH.scrollLeft)}),us(r.scroller,"mousewheel",function(e){jn(t,e)}),us(r.scroller,"DOMMouseScroll",function(e){jn(t,e)}),us(r.scrollbarH,"mousedown",e),us(r.scrollbarV,"mousedown",e),us(r.wrapper,"scroll",function(){r.wrapper.scrollTop=r.wrapper.scrollLeft=0}),us(r.input,"keyup",function(e){Yn.call(t,e)}),us(r.input,"input",function(){Zo&&ta>=9&&t.display.inputHasSelection&&(t.display.inputHasSelection=null),kn(t)}),us(r.input,"keydown",cn(t,Gn)),us(r.input,"keypress",cn(t,Qn)),us(r.input,"focus",vo(Jn,t)),us(r.input,"blur",vo(Zn,t)),t.options.dragDrop&&(us(r.scroller,"dragstart",function(e){Vn(t,e)}),us(r.scroller,"dragenter",n),us(r.scroller,"dragover",n),us(r.scroller,"drop",cn(t,Hn))),us(r.scroller,"paste",function(e){Pn(r,e)||(t.state.pasteIncoming=!0,Tn(t),kn(t))}),us(r.input,"paste",function(){if(ea&&!t.state.fakedLastChar&&!(new Date-t.state.lastMiddleDown<200)){var e=r.input.selectionStart,n=r.input.selectionEnd;r.input.value+="$",r.input.selectionEnd=n,r.input.selectionStart=e,t.state.fakedLastChar=!0}t.state.pasteIncoming=!0,kn(t)}),us(r.input,"cut",i),us(r.input,"copy",i),aa&&us(r.sizer,"mouseup",function(){So()==r.input&&r.input.blur(),Tn(t)})}function Nn(t){var e=t.display;e.cachedCharWidth=e.cachedTextHeight=e.cachedPaddingH=null,t.setSize()}function Pn(t,e){for(var n=to(e);n!=t.wrapper;n=n.parentNode)if(!n||n.ignoreEvents||n.parentNode==t.sizer&&n!=t.mover)return!0}function An(t,e,n,i){var r=t.display;if(!n){var o=to(e);if(o==r.scrollbarH||o==r.scrollbarV||o==r.scrollbarFiller||o==r.gutterFiller)return null}var a,s,l=r.lineSpace.getBoundingClientRect();try{a=e.clientX-l.left,s=e.clientY-l.top}catch(e){return null}var u,c=Xe(t,a,s);if(i&&1==c.xRel&&(u=Nr(t.doc,c.line).text).length==c.ch){var h=ys(u,u.length,t.options.tabSize)-u.length;c=ya(c.line,Math.max(0,Math.round((a-Le(t.display).left)/Je(t.display))-h))}return c}function On(t){if(!ro(this,t)){var e=this,n=e.display;if(n.shift=t.shiftKey,Pn(n,t))return void(ea||(n.scroller.draggable=!1,setTimeout(function(){n.scroller.draggable=!0},100)));if(!Wn(e,t)){var i=An(e,t);switch(window.focus(),eo(t)){case 1:i?Dn(e,t,i):to(t)==n.scroller&&as(t);break;case 2:ea&&(e.state.lastMiddleDown=+new Date),i&&re(e.doc,i),setTimeout(vo(Tn,e),20),as(t);break;case 3:ga&&ti(e,t)}}}}function Dn(t,e,n){setTimeout(vo(Mn,t),0);var i,r=+new Date;wa&&wa.time>r-400&&0==_a(wa.pos,n)?i="triple":xa&&xa.time>r-400&&0==_a(xa.pos,n)?(i="double",wa={time:r,pos:n}):(i="single",xa={time:r,pos:n});var o=t.doc.sel,a=ha?e.metaKey:e.ctrlKey;t.options.dragDrop&&Es&&!Ln(t)&&"single"==i&&o.contains(n)>-1&&o.somethingSelected()?In(t,e,n,a):Bn(t,e,n,i,a)}function In(t,e,n,i){var r=t.display,o=cn(t,function(a){ea&&(r.scroller.draggable=!1),t.state.draggingText=!1,cs(document,"mouseup",o),cs(r.scroller,"drop",o),Math.abs(e.clientX-a.clientX)+Math.abs(e.clientY-a.clientY)<10&&(as(a),i||re(t.doc,n),Tn(t),Zo&&9==ta&&setTimeout(function(){document.body.focus(),Tn(t)},20))});ea&&(r.scroller.draggable=!0),t.state.draggingText=o,r.scroller.dragDrop&&r.scroller.dragDrop(),us(document,"mouseup",o),us(r.scroller,"drop",o)}function Bn(t,e,n,i,r){function o(e){if(0!=_a(g,e))if(g=e,"rect"==i){for(var r=[],o=t.options.tabSize,a=ys(Nr(u,n.line).text,n.ch,o),s=ys(Nr(u,e.line).text,e.ch,o),l=Math.min(a,s),f=Math.max(a,s),p=Math.min(n.line,e.line),m=Math.min(t.lastLine(),Math.max(n.line,e.line));m>=p;p++){var v=Nr(u,p).text,y=uo(v,l,o);l==f?r.push(new X(ya(p,y),ya(p,y))):v.length>y&&r.push(new X(ya(p,y),ya(p,uo(v,f,o))))}r.length||r.push(new X(n,n)),ce(u,Y(d.ranges.slice(0,h).concat(r),h),{origin:"*mouse",scroll:!1}),t.scrollIntoView(e)}else{var _=c,b=_.anchor,x=e;if("single"!=i){if("double"==i)var w=t.findWordAt(e);else var w=new X(ya(e.line,0),Z(u,ya(e.line+1,0)));_a(w.anchor,b)>0?(x=w.head,b=$(_.from(),w.anchor)):(x=w.anchor,b=q(_.to(),w.head))}var r=d.ranges.slice(0);r[h]=new X(Z(u,b),x),ce(u,Y(r,h),ms)}}function a(e){var n=++v,r=An(t,e,!0,"rect"==i);if(r)if(0!=_a(r,g)){Mn(t),o(r);var s=y(l,u);(r.line>=s.to||r.linem.bottom?20:0;c&&setTimeout(cn(t,function(){v==n&&(l.scroller.scrollTop+=c,a(e))}),50)}}function s(e){v=1/0,as(e),Tn(t),cs(document,"mousemove",_),cs(document,"mouseup",b),u.history.lastSelOrigin=null}var l=t.display,u=t.doc;as(e);var c,h,d=u.sel;if(r&&!e.shiftKey?(h=u.sel.contains(n),c=h>-1?u.sel.ranges[h]:new X(n,n)):c=u.sel.primary(),e.altKey)i="rect",r||(c=new X(n,n)),n=An(t,e,!0,!0),h=-1;else if("double"==i){var f=t.findWordAt(n);c=t.display.shift||u.extend?ie(u,c,f.anchor,f.head):f}else if("triple"==i){var p=new X(ya(n.line,0),Z(u,ya(n.line+1,0)));c=t.display.shift||u.extend?ie(u,c,p.anchor,p.head):p}else c=ie(u,c,n);r?h>-1?ae(u,h,c,ms):(h=u.sel.ranges.length,ce(u,Y(u.sel.ranges.concat([c]),h),{scroll:!1,origin:"*mouse"})):(h=0,ce(u,new G([c],0),ms),d=u.sel);var g=n,m=l.wrapper.getBoundingClientRect(),v=0,_=cn(t,function(t){eo(t)?a(t):s(t)}),b=cn(t,s);us(document,"mousemove",_),us(document,"mouseup",b)}function Rn(t,e,n,i,r){try{var o=e.clientX,a=e.clientY}catch(e){return!1}if(o>=Math.floor(t.display.gutters.getBoundingClientRect().right))return!1;i&&as(e);var s=t.display,l=s.lineDiv.getBoundingClientRect();if(a>l.bottom||!ao(t,n))return Zr(e);a-=l.top-s.viewOffset;for(var u=0;u=o){var h=Ir(t.doc,a),d=t.options.gutters[u];return r(t,n,t,h,d,e),Zr(e)}}}function Wn(t,e){return Rn(t,e,"gutterClick",!0,no)}function Hn(t){var e=this;if(!ro(e,t)&&!Pn(e.display,t)){as(t),Zo&&(Ma=+new Date);var n=An(e,t,!0),i=t.dataTransfer.files;if(n&&!Ln(e))if(i&&i.length&&window.FileReader&&window.File)for(var r=i.length,o=Array(r),a=0,s=function(t,i){var s=new FileReader;s.onload=cn(e,function(){if(o[i]=s.result,++a==r){n=Z(e.doc,n);var t={from:n,to:n,text:Ns(o.join("\n")),origin:"paste"};si(e.doc,t),ue(e.doc,Q(n,Aa(t)))}}),s.readAsText(t)},l=0;r>l;++l)s(i[l],l);else{if(e.state.draggingText&&e.doc.sel.contains(n)>-1)return e.state.draggingText(t),void setTimeout(vo(Tn,e),20);try{var o=t.dataTransfer.getData("Text");if(o){if(e.state.draggingText&&!(ha?t.metaKey:t.ctrlKey))var u=e.listSelections();if(he(e.doc,Q(n,n)),u)for(var l=0;lo.clientWidth||i&&o.scrollHeight>o.clientHeight){if(i&&ha&&ea)t:for(var a=e.target,s=r.view;a!=o;a=a.parentNode)for(var l=0;lu?c=Math.max(0,c+u-50):h=Math.min(t.doc.height,h+u+50),T(t,{top:c,bottom:h})}20>La&&(null==r.wheelStartX?(r.wheelStartX=o.scrollLeft,r.wheelStartY=o.scrollTop,r.wheelDX=n,r.wheelDY=i,setTimeout(function(){if(null!=r.wheelStartX){var t=o.scrollLeft-r.wheelStartX,e=o.scrollTop-r.wheelStartY,n=e&&r.wheelDY&&e/r.wheelDY||t&&r.wheelDX&&t/r.wheelDX;r.wheelStartX=r.wheelStartY=null,n&&(Ea=(Ea*La+n)/(La+1),++La)}},200)):(r.wheelDX+=n,r.wheelDY+=i))}}function Un(t,e,n){if("string"==typeof e&&(e=ja[e],!e))return!1;t.display.pollingFast&&Cn(t)&&(t.display.pollingFast=!1);var i=t.display.shift,r=!1;try{Ln(t)&&(t.state.suppressEdits=!0),n&&(t.display.shift=!1),r=e(t)!=ps}finally{t.display.shift=i,t.state.suppressEdits=!1}return r}function Kn(t){var e=t.state.keyMaps.slice(0);return t.options.extraKeys&&e.push(t.options.extraKeys),e.push(t.options.keyMap),e}function qn(t,e){var n=Mi(t.options.keyMap),i=n.auto;clearTimeout(Na),i&&!qa(e)&&(Na=setTimeout(function(){Mi(t.options.keyMap)==n&&(t.options.keyMap=i.call?i.call(null,t):i,s(t))},50));var r=$a(e,!0),o=!1;if(!r)return!1;var a=Kn(t);return o=e.shiftKey?Ka("Shift-"+r,a,function(e){return Un(t,e,!0)})||Ka(r,a,function(e){return("string"==typeof e?/^go[A-Z]/.test(e):e.motion)?Un(t,e):void 0}):Ka(r,a,function(e){return Un(t,e)}),o&&(as(e),xe(t),no(t,"keyHandled",t,r,e)),o}function $n(t,e,n){var i=Ka("'"+n+"'",Kn(t),function(e){return Un(t,e,!0)});return i&&(as(e),xe(t),no(t,"keyHandled",t,"'"+n+"'",e)),i}function Gn(t){var e=this;if(Mn(e),!ro(e,t)){Zo&&11>ta&&27==t.keyCode&&(t.returnValue=!1);var n=t.keyCode;e.display.shift=16==n||t.shiftKey;var i=qn(e,t);ra&&(Pa=i?n:null,!i&&88==n&&!As&&(ha?t.metaKey:t.ctrlKey)&&e.replaceSelection("",null,"cut")),18!=n||/\bCodeMirror-crosshair\b/.test(e.display.lineDiv.className)||Xn(e)}}function Xn(t){function e(t){18!=t.keyCode&&t.altKey||(Mo(n,"CodeMirror-crosshair"),cs(document,"keyup",e),cs(document,"mouseover",e))}var n=t.display.lineDiv;Lo(n,"CodeMirror-crosshair"),us(document,"keyup",e),us(document,"mouseover",e)}function Yn(t){16==t.keyCode&&(this.doc.sel.shift=!1),ro(this,t)}function Qn(t){var e=this;if(!(ro(e,t)||t.ctrlKey&&!t.altKey||ha&&t.metaKey)){var n=t.keyCode,i=t.charCode;if(ra&&n==Pa)return Pa=null,void as(t);if(!(ra&&(!t.which||t.which<10)||aa)||!qn(e,t)){var r=String.fromCharCode(null==i?n:i);$n(e,t,r)||(Zo&&ta>=9&&(e.display.inputHasSelection=null),kn(e))}}}function Jn(t){"nocursor"!=t.options.readOnly&&(t.state.focused||(hs(t,"focus",t),t.state.focused=!0,Lo(t.display.wrapper,"CodeMirror-focused"),t.curOp||t.display.selForContextMenu==t.doc.sel||(Sn(t),ea&&setTimeout(vo(Sn,t,!0),0))),wn(t),xe(t))}function Zn(t){t.state.focused&&(hs(t,"blur",t),t.state.focused=!1,Mo(t.display.wrapper,"CodeMirror-focused")),clearInterval(t.display.blinker),setTimeout(function(){t.state.focused||(t.display.shift=!1)},150)}function ti(t,e){function n(){if(null!=r.input.selectionStart){var e=t.somethingSelected(),n=r.input.value="​"+(e?r.input.value:"");r.prevInput=e?"":"​",r.input.selectionStart=1,r.input.selectionEnd=n.length,r.selForContextMenu=t.doc.sel}}function i(){if(r.inputDiv.style.position="relative",r.input.style.cssText=l,Zo&&9>ta&&(r.scrollbarV.scrollTop=r.scroller.scrollTop=a),wn(t),null!=r.input.selectionStart){(!Zo||Zo&&9>ta)&&n();var e=0,i=function(){r.selForContextMenu==t.doc.sel&&0==r.input.selectionStart?cn(t,ja.selectAll)(t):e++<10?r.detectingSelectAll=setTimeout(i,500):Sn(t)};r.detectingSelectAll=setTimeout(i,200)}}if(!ro(t,e,"contextmenu")){var r=t.display;if(!Pn(r,e)&&!ei(t,e)){var o=An(t,e),a=r.scroller.scrollTop;if(o&&!ra){var s=t.options.resetSelectionOnContextMenu;s&&-1==t.doc.sel.contains(o)&&cn(t,ce)(t.doc,Q(o),gs);var l=r.input.style.cssText;if(r.inputDiv.style.position="absolute",r.input.style.cssText="position: fixed; width: 30px; height: 30px; top: "+(e.clientY-5)+"px; left: "+(e.clientX-5)+"px; z-index: 1000; background: "+(Zo?"rgba(255, 255, 255, .05)":"transparent")+"; outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);",ea)var u=window.scrollY;if(Tn(t),ea&&window.scrollTo(null,u),Sn(t),t.somethingSelected()||(r.input.value=r.prevInput=" "),r.selForContextMenu=t.doc.sel,clearTimeout(r.detectingSelectAll),Zo&&ta>=9&&n(),ga){ls(e);var c=function(){cs(window,"mouseup",c),setTimeout(i,20)};us(window,"mouseup",c)}else setTimeout(i,50)}}}}function ei(t,e){return ao(t,"gutterContextMenu")?Rn(t,e,"gutterContextMenu",!1,hs):!1}function ni(t,e){if(_a(t,e.from)<0)return t;if(_a(t,e.to)<=0)return Aa(e);var n=t.line+e.text.length-(e.to.line-e.from.line)-1,i=t.ch;return t.line==e.to.line&&(i+=Aa(e).ch-e.to.ch),ya(n,i)}function ii(t,e){for(var n=[],i=0;i=0;--r)li(t,{from:i[r].from,to:i[r].to,text:r?[""]:e.text});else li(t,e)}}function li(t,e){if(1!=e.text.length||""!=e.text[0]||0!=_a(e.from,e.to)){var n=ii(t,e);Fr(t,e,n,t.cm?t.cm.curOp.id:0/0),hi(t,e,n,Hi(t,e));var i=[];Lr(t,function(t,n){n||-1!=fo(i,t.history)||(Jr(t.history,e),i.push(t.history)),hi(t,e,null,Hi(t,e))})}}function ui(t,e,n){if(!t.cm||!t.cm.state.suppressEdits){for(var i,r=t.history,o=t.sel,a="undo"==e?r.done:r.undone,s="undo"==e?r.undone:r.done,l=0;l=0;--l){var h=i.changes[l];if(h.origin=e,c&&!ai(t,h,!1))return void(a.length=0);u.push(Hr(t,h));var d=l?ii(t,h):ho(a);hi(t,h,d,zi(t,h)),!l&&t.cm&&t.cm.scrollIntoView({from:h.from,to:Aa(h)});var f=[];Lr(t,function(t,e){e||-1!=fo(f,t.history)||(Jr(t.history,h),f.push(t.history)),hi(t,h,null,zi(t,h))})}}}}function ci(t,e){if(0!=e&&(t.first+=e,t.sel=new G(po(t.sel.ranges,function(t){return new X(ya(t.anchor.line+e,t.anchor.ch),ya(t.head.line+e,t.head.ch))}),t.sel.primIndex),t.cm)){gn(t.cm,t.first,t.first-e,e);for(var n=t.cm.display,i=n.viewFrom;it.lastLine())){if(e.from.lineo&&(e={from:e.from,to:ya(o,Nr(t,o).text.length),text:[e.text[0]],origin:e.origin}),e.removed=Pr(t,e.from,e.to),n||(n=ii(t,e)),t.cm?di(t.cm,e,i):Sr(t,e,i),he(t,n,gs)}}function di(t,e,n){var i=t.doc,r=t.display,a=e.from,s=e.to,l=!1,u=a.line;t.options.lineWrapping||(u=Dr(Ji(Nr(i,a.line))),i.iter(u,s.line+1,function(t){return t==r.maxLine?(l=!0,!0):void 0})),i.sel.contains(e.from,e.to)>-1&&oo(t),Sr(i,e,n,o(t)),t.options.lineWrapping||(i.iter(u,a.line+e.text.length,function(t){var e=d(t);e>r.maxLineLength&&(r.maxLine=t,r.maxLineLength=e,r.maxLineChanged=!0,l=!1)}),l&&(t.curOp.updateMaxLine=!0)),i.frontier=Math.min(i.frontier,a.line),we(t,400);var c=e.text.length-(s.line-a.line)-1;a.line!=s.line||1!=e.text.length||Cr(t.doc,e)?gn(t,a.line,s.line+1,c):mn(t,a.line,"text");var h=ao(t,"changes"),f=ao(t,"change");if(f||h){var p={from:a,to:s,text:e.text,removed:e.removed,origin:e.origin};f&&no(t,"change",t,p),h&&(t.curOp.changeObjs||(t.curOp.changeObjs=[])).push(p)}t.display.selForContextMenu=null}function fi(t,e,n,i,r){if(i||(i=n),_a(i,n)<0){var o=i;i=n,n=o}"string"==typeof e&&(e=Ns(e)),si(t,{from:n,to:i,text:e,origin:r})}function pi(t,e){var n=t.display,i=n.sizer.getBoundingClientRect(),r=null;if(e.top+i.top<0?r=!0:e.bottom+i.top>(window.innerHeight||document.documentElement.clientHeight)&&(r=!1),null!=r&&!la){var o=xo("div","​",null,"position: absolute; top: "+(e.top-n.viewOffset-Te(t.display))+"px; height: "+(e.bottom-e.top+fs)+"px; left: "+e.left+"px; width: 2px;");t.display.lineSpace.appendChild(o),o.scrollIntoView(r),t.display.lineSpace.removeChild(o)}}function gi(t,e,n,i){null==i&&(i=0);for(var r=0;5>r;r++){var o=!1,a=qe(t,e),s=n&&n!=e?qe(t,n):a,l=vi(t,Math.min(a.left,s.left),Math.min(a.top,s.top)-i,Math.max(a.left,s.left),Math.max(a.bottom,s.bottom)+i),u=t.doc.scrollTop,c=t.doc.scrollLeft;if(null!=l.scrollTop&&(zn(t,l.scrollTop),Math.abs(t.doc.scrollTop-u)>1&&(o=!0)),null!=l.scrollLeft&&(Fn(t,l.scrollLeft),Math.abs(t.doc.scrollLeft-c)>1&&(o=!0)),!o)return a}}function mi(t,e,n,i,r){var o=vi(t,e,n,i,r);null!=o.scrollTop&&zn(t,o.scrollTop),null!=o.scrollLeft&&Fn(t,o.scrollLeft)}function vi(t,e,n,i,r){var o=t.display,a=Qe(t.display);0>n&&(n=0);var s=t.curOp&&null!=t.curOp.scrollTop?t.curOp.scrollTop:o.scroller.scrollTop,l=o.scroller.clientHeight-fs,u={};r-n>l&&(r=n+l);var c=t.doc.height+Me(o),h=a>n,d=r>c-a;if(s>n)u.scrollTop=h?0:n;else if(r>s+l){var f=Math.min(n,(d?c:r)-l);f!=s&&(u.scrollTop=f)}var p=t.curOp&&null!=t.curOp.scrollLeft?t.curOp.scrollLeft:o.scroller.scrollLeft,g=o.scroller.clientWidth-fs-o.gutters.offsetWidth,m=i-e>g;return m&&(i=e+g),10>e?u.scrollLeft=0:p>e?u.scrollLeft=Math.max(0,e-(m?0:10)):i>g+p-3&&(u.scrollLeft=i+(m?0:10)-g),u}function yi(t,e,n){(null!=e||null!=n)&&bi(t),null!=e&&(t.curOp.scrollLeft=(null==t.curOp.scrollLeft?t.doc.scrollLeft:t.curOp.scrollLeft)+e),null!=n&&(t.curOp.scrollTop=(null==t.curOp.scrollTop?t.doc.scrollTop:t.curOp.scrollTop)+n)}function _i(t){bi(t);var e=t.getCursor(),n=e,i=e;t.options.lineWrapping||(n=e.ch?ya(e.line,e.ch-1):e,i=ya(e.line,e.ch+1)),t.curOp.scrollToPos={from:n,to:i,margin:t.options.cursorScrollMargin,isCursor:!0}}function bi(t){var e=t.curOp.scrollToPos;if(e){t.curOp.scrollToPos=null;var n=$e(t,e.from),i=$e(t,e.to),r=vi(t,Math.min(n.left,i.left),Math.min(n.top,i.top)-e.margin,Math.max(n.right,i.right),Math.max(n.bottom,i.bottom)+e.margin);t.scrollTo(r.scrollLeft,r.scrollTop)}}function xi(t,e,n,i){var r,o=t.doc;null==n&&(n="add"),"smart"==n&&(o.mode.indent?r=Se(t,e):n="prev");var a=t.options.tabSize,s=Nr(o,e),l=ys(s.text,null,a);s.stateAfter&&(s.stateAfter=null);var u,c=s.text.match(/^\s*/)[0];if(i||/\S/.test(s.text)){if("smart"==n&&(u=o.mode.indent(r,s.text.slice(c.length),s.text),u==ps||u>150)){if(!i)return;n="prev"}}else u=0,n="not";"prev"==n?u=e>o.first?ys(Nr(o,e-1).text,null,a):0:"add"==n?u=l+t.options.indentUnit:"subtract"==n?u=l-t.options.indentUnit:"number"==typeof n&&(u=l+n),u=Math.max(0,u);var h="",d=0;if(t.options.indentWithTabs)for(var f=Math.floor(u/a);f;--f)d+=a,h+=" ";if(u>d&&(h+=co(u-d)),h!=c)fi(o,h,ya(e,0),ya(e,c.length),"+input");else for(var f=0;f=0;e--)fi(t.doc,"",i[e].from,i[e].to,"+delete");_i(t)})}function Ci(t,e,n,i,r){function o(){var e=s+n;return e=t.first+t.size?h=!1:(s=e,c=Nr(t,e))}function a(t){var e=(r?Go:Xo)(c,l,n,!0);if(null==e){if(t||!o())return h=!1;l=r?(0>n?zo:Vo)(c):0>n?c.text.length:0}else l=e;return!0}var s=e.line,l=e.ch,u=n,c=Nr(t,s),h=!0;if("char"==i)a();else if("column"==i)a(!0);else if("word"==i||"group"==i)for(var d=null,f="group"==i,p=t.cm&&t.cm.getHelper(e,"wordChars"),g=!0;!(0>n)||a(!g);g=!1){var m=c.text.charAt(l)||"\n",v=yo(m,p)?"w":f&&"\n"==m?"n":!f||/\s/.test(m)?null:"p";if(!f||g||v||(v="s"),d&&d!=v){0>n&&(n=1,a());break}if(v&&(d=v),n>0&&!a(!g))break}var y=ge(t,ya(s,l),u,!0);return h||(y.hitSide=!0),y}function Si(t,e,n,i){var r,o=t.doc,a=e.left;if("page"==i){var s=Math.min(t.display.wrapper.clientHeight,window.innerHeight||document.documentElement.clientHeight);r=e.top+n*(s-(0>n?1.5:.5)*Qe(t.display))}else"line"==i&&(r=n>0?e.bottom+3:e.top-3);for(;;){var l=Xe(t,a,r);if(!l.outside)break;if(0>n?0>=r:r>=o.height){l.hitSide=!0;break}r+=5*n}return l}function Ti(e,n,i,r){t.defaults[e]=n,i&&(Da[e]=r?function(t,e,n){n!=Ia&&i(t,e,n)}:i)}function Mi(t){return"string"==typeof t?Ua[t]:t}function Li(t,e,n,i,r){if(i&&i.shared)return Ei(t,e,n,i,r);if(t.cm&&!t.cm.curOp)return cn(t.cm,Li)(t,e,n,i,r);var o=new Xa(t,r),a=_a(e,n);if(i&&mo(i,o,!1),a>0||0==a&&o.clearWhenEmpty!==!1)return o;if(o.replacedWith&&(o.collapsed=!0,o.widgetNode=xo("span",[o.replacedWith],"CodeMirror-widget"),i.handleMouseEvents||(o.widgetNode.ignoreEvents=!0),i.insertLeft&&(o.widgetNode.insertLeft=!0)),o.collapsed){if(Qi(t,e.line,e,n,o)||e.line!=n.line&&Qi(t,n.line,e,n,o))throw new Error("Inserting collapsed marker partially overlapping an existing one");va=!0}o.addToHistory&&Fr(t,{from:e,to:n,origin:"markText"},t.sel,0/0);var s,l=e.line,u=t.cm;if(t.iter(l,n.line+1,function(t){u&&o.collapsed&&!u.options.lineWrapping&&Ji(t)==u.display.maxLine&&(s=!0),o.collapsed&&l!=e.line&&Or(t,0),Bi(t,new Oi(o,l==e.line?e.ch:null,l==n.line?n.ch:null)),++l}),o.collapsed&&t.iter(e.line,n.line+1,function(e){nr(t,e)&&Or(e,0)}),o.clearOnEnter&&us(o,"beforeCursorEnter",function(){o.clear()}),o.readOnly&&(ma=!0,(t.history.done.length||t.history.undone.length)&&t.clearHistory()),o.collapsed&&(o.id=++Ya,o.atomic=!0),u){if(s&&(u.curOp.updateMaxLine=!0),o.collapsed)gn(u,e.line,n.line+1);else if(o.className||o.title||o.startStyle||o.endStyle)for(var c=e.line;c<=n.line;c++)mn(u,c,"text");o.atomic&&fe(u.doc),no(u,"markerAdded",u,o)}return o}function Ei(t,e,n,i,r){i=mo(i),i.shared=!1;var o=[Li(t,e,n,i,r)],a=o[0],s=i.widgetNode;return Lr(t,function(t){s&&(i.widgetNode=s.cloneNode(!0)),o.push(Li(t,Z(t,e),Z(t,n),i,r));for(var l=0;l=e:o.to>e);(i||(i=[])).push(new Oi(a,o.from,l?null:o.to))}}return i}function Wi(t,e,n){if(t)for(var i,r=0;r=e:o.to>e);if(s||o.from==e&&"bookmark"==a.type&&(!n||o.marker.insertLeft)){var l=null==o.from||(a.inclusiveLeft?o.from<=e:o.from0&&s)for(var h=0;hh;++h)p.push(g);p.push(l)}return p}function Vi(t){for(var e=0;e0)){var c=[l,1],h=_a(u.from,s.from),d=_a(u.to,s.to);(0>h||!a.inclusiveLeft&&!h)&&c.push({from:u.from,to:s.from}),(d>0||!a.inclusiveRight&&!d)&&c.push({from:s.to,to:u.to}),r.splice.apply(r,c),l+=c.length-1}}return r}function ji(t){var e=t.markedSpans;if(e){for(var n=0;n=0&&0>=h||0>=c&&h>=0)&&(0>=c&&(_a(u.to,n)>0||l.marker.inclusiveRight&&r.inclusiveLeft)||c>=0&&(_a(u.from,i)<0||l.marker.inclusiveLeft&&r.inclusiveRight)))return!0}}}function Ji(t){for(var e;e=Xi(t);)t=e.find(-1,!0).line;return t}function Zi(t){for(var e,n;e=Yi(t);)t=e.find(1,!0).line,(n||(n=[])).push(t);return n}function tr(t,e){var n=Nr(t,e),i=Ji(n);return n==i?e:Dr(i)}function er(t,e){if(e>t.lastLine())return e;var n,i=Nr(t,e);if(!nr(t,i))return e;for(;n=Yi(i);)i=n.find(1,!0).line;return Dr(i)+1}function nr(t,e){var n=va&&e.markedSpans;if(n)for(var i,r=0;ri;i++){var r=t.token(e,n);if(e.pos>e.start)return r}throw new Error("Mode "+t.name+" failed to advance stream.")}function dr(e,n,i,r,o,a,s){var l=i.flattenSpans;null==l&&(l=e.options.flattenSpans);var u,c=0,h=null,d=new Ga(n,e.options.tabSize);for(""==n&&ur(cr(i,r),a);!d.eol();){if(d.pos>e.options.maxHighlightLength?(l=!1,s&&gr(e,n,r,d.pos),d.pos=n.length,u=null):u=ur(hr(i,d,r),a),e.options.addModeClass){var f=t.innerMode(i,r).mode.name;f&&(u="m-"+(u?f+" "+u:f))}l&&h==u||(cu;){var i=r[l];i>t&&r.splice(l,1,t,r[l+1],i),l+=2,u=Math.min(t,i)}if(e)if(s.opaque)r.splice(n,l-n,t,"cm-overlay "+e),l=n+2;else for(;l>n;n+=2){var o=r[n+1];r[n+1]=(o?o+" ":"")+"cm-overlay "+e}},o)}return{styles:r,classes:o.bgClass||o.textClass?o:null}}function pr(t,e){if(!e.styles||e.styles[0]!=t.state.modeGen){var n=fr(t,e,e.stateAfter=Se(t,Dr(e)));e.styles=n.styles,n.classes?e.styleClasses=n.classes:e.styleClasses&&(e.styleClasses=null)}return e.styles}function gr(t,e,n,i){var r=t.doc.mode,o=new Ga(e,t.options.tabSize); for(o.start=o.pos=i||0,""==e&&cr(r,n);!o.eol()&&o.pos<=t.options.maxHighlightLength;)hr(r,o,n),o.start=o.pos}function mr(t,e){if(!t||/^\s*$/.test(t))return null;var n=e.addModeClass?es:ts;return n[t]||(n[t]=t.replace(/\S+/g,"cm-$&"))}function vr(t,e){var n=xo("span",null,null,ea?"padding-right: .1px":null),i={pre:xo("pre",[n]),content:n,col:0,pos:0,cm:t};e.measure={};for(var r=0;r<=(e.rest?e.rest.length:0);r++){var o,a=r?e.rest[r-1]:e.line;i.pos=0,i.addToken=_r,(Zo||ea)&&t.getOption("lineWrapping")&&(i.addToken=br(i.addToken)),Io(t.display.measure)&&(o=Rr(a))&&(i.addToken=xr(i.addToken,o)),i.map=[],kr(a,i,pr(t,a)),a.styleClasses&&(a.styleClasses.bgClass&&(i.bgClass=Eo(a.styleClasses.bgClass,i.bgClass||"")),a.styleClasses.textClass&&(i.textClass=Eo(a.styleClasses.textClass,i.textClass||""))),0==i.map.length&&i.map.push(0,0,i.content.appendChild(Do(t.display.measure))),0==r?(e.measure.map=i.map,e.measure.cache={}):((e.measure.maps||(e.measure.maps=[])).push(i.map),(e.measure.caches||(e.measure.caches=[])).push({}))}return hs(t,"renderLine",t,e.line,i.pre),i.pre.className&&(i.textClass=Eo(i.pre.className,i.textClass||"")),i}function yr(t){var e=xo("span","•","cm-invalidchar");return e.title="\\u"+t.charCodeAt(0).toString(16),e}function _r(t,e,n,i,r,o){if(e){var a=t.cm.options.specialChars,s=!1;if(a.test(e))for(var l=document.createDocumentFragment(),u=0;;){a.lastIndex=u;var c=a.exec(e),h=c?c.index-u:e.length-u;if(h){var d=document.createTextNode(e.slice(u,u+h));l.appendChild(Zo&&9>ta?xo("span",[d]):d),t.map.push(t.pos,t.pos+h,d),t.col+=h,t.pos+=h}if(!c)break;if(u+=h+1," "==c[0]){var f=t.cm.options.tabSize,p=f-t.col%f,d=l.appendChild(xo("span",co(p),"cm-tab"));t.col+=p}else{var d=t.cm.options.specialCharPlaceholder(c[0]);l.appendChild(Zo&&9>ta?xo("span",[d]):d),t.col+=1}t.map.push(t.pos,t.pos+1,d),t.pos++}else{t.col+=e.length;var l=document.createTextNode(e);t.map.push(t.pos,t.pos+e.length,l),Zo&&9>ta&&(s=!0),t.pos+=e.length}if(n||i||r||s){var g=n||"";i&&(g+=i),r&&(g+=r);var m=xo("span",[l],g);return o&&(m.title=o),t.content.appendChild(m)}t.content.appendChild(l)}}function br(t){function e(t){for(var e=" ",n=0;nl&&h.from<=l)break}if(h.to>=u)return t(n,i,r,o,a,s);t(n,i.slice(0,h.to-l),r,o,null,s),o=null,i=i.slice(h.to-l),l=h.to}}}function wr(t,e,n,i){var r=!i&&n.widgetNode;r&&(t.map.push(t.pos,t.pos+e,r),t.content.appendChild(r)),t.pos+=e}function kr(t,e,n){var i=t.markedSpans,r=t.text,o=0;if(i)for(var a,s,l,u,c,h,d=r.length,f=0,p=1,g="",m=0;;){if(m==f){s=l=u=c="",h=null,m=1/0;for(var v=[],y=0;yf)?(null!=_.to&&m>_.to&&(m=_.to,l=""),b.className&&(s+=" "+b.className),b.startStyle&&_.from==f&&(u+=" "+b.startStyle),b.endStyle&&_.to==m&&(l+=" "+b.endStyle),b.title&&!c&&(c=b.title),b.collapsed&&(!h||$i(h.marker,b)<0)&&(h=_)):_.from>f&&m>_.from&&(m=_.from),"bookmark"==b.type&&_.from==f&&b.widgetNode&&v.push(b)}if(h&&(h.from||0)==f&&(wr(e,(null==h.to?d+1:h.to)-f,h.marker,null==h.from),null==h.to))return;if(!h&&v.length)for(var y=0;y=d)break;for(var x=Math.min(d,m);;){if(g){var w=f+g.length;if(!h){var k=w>x?g.slice(0,x-f):g;e.addToken(e,k,a?a+s:s,u,f+k.length==m?l:"",c)}if(w>=x){g=g.slice(x-f),f=x;break}f=w,u=""}g=r.slice(o,o=n[p++]),a=mr(n[p++],e.cm.options)}}else for(var p=1;p1&&t.remove(a.line+1,f-1),t.insert(a.line+1,g)}no(t,"change",t,e)}function Tr(t){this.lines=t,this.parent=null;for(var e=0,n=0;ee||e>=t.size)throw new Error("There is no line "+(e+t.first)+" in the document.");for(var n=t;!n.lines;)for(var i=0;;++i){var r=n.children[i],o=r.chunkSize();if(o>e){n=r;break}e-=o}return n.lines[e]}function Pr(t,e,n){var i=[],r=e.line;return t.iter(e.line,n.line+1,function(t){var o=t.text;r==n.line&&(o=o.slice(0,n.ch)),r==e.line&&(o=o.slice(e.ch)),i.push(o),++r}),i}function Ar(t,e,n){var i=[];return t.iter(e,n,function(t){i.push(t.text)}),i}function Or(t,e){var n=e-t.height;if(n)for(var i=t;i;i=i.parent)i.height+=n}function Dr(t){if(null==t.parent)return null;for(var e=t.parent,n=fo(e.lines,t),i=e.parent;i;e=i,i=i.parent)for(var r=0;i.children[r]!=e;++r)n+=i.children[r].chunkSize();return n+e.first}function Ir(t,e){var n=t.first;t:do{for(var i=0;ie){t=r;continue t}e-=o,n+=r.chunkSize()}return n}while(!t.lines);for(var i=0;ie)break;e-=s}return n+i}function Br(t){t=Ji(t);for(var e=0,n=t.parent,i=0;i1&&!t.done[t.done.length-2].ranges?(t.done.pop(),ho(t.done)):void 0}function Fr(t,e,n,i){var r=t.history;r.undone.length=0;var o,a=+new Date;if((r.lastOp==i||r.lastOrigin==e.origin&&e.origin&&("+"==e.origin.charAt(0)&&t.cm&&r.lastModTime>a-t.cm.options.historyEventDelay||"*"==e.origin.charAt(0)))&&(o=zr(r,r.lastOp==i))){var s=ho(o.changes);0==_a(e.from,e.to)&&0==_a(e.from,s.to)?s.to=Aa(e):o.changes.push(Hr(t,e))}else{var l=ho(r.done);for(l&&l.ranges||Kr(t.sel,r.done),o={changes:[Hr(t,e)],generation:r.generation},r.done.push(o);r.done.length>r.undoDepth;)r.done.shift(),r.done[0].ranges||r.done.shift()}r.done.push(n),r.generation=++r.maxGeneration,r.lastModTime=r.lastSelTime=a,r.lastOp=r.lastSelOp=i,r.lastOrigin=r.lastSelOrigin=e.origin,s||hs(t,"historyAdded")}function jr(t,e,n,i){var r=e.charAt(0);return"*"==r||"+"==r&&n.ranges.length==i.ranges.length&&n.somethingSelected()==i.somethingSelected()&&new Date-t.history.lastSelTime<=(t.cm?t.cm.options.historyEventDelay:500)}function Ur(t,e,n,i){var r=t.history,o=i&&i.origin;n==r.lastSelOp||o&&r.lastSelOrigin==o&&(r.lastModTime==r.lastSelTime&&r.lastOrigin==o||jr(t,o,ho(r.done),e))?r.done[r.done.length-1]=e:Kr(e,r.done),r.lastSelTime=+new Date,r.lastSelOrigin=o,r.lastSelOp=n,i&&i.clearRedo!==!1&&Vr(r.undone)}function Kr(t,e){var n=ho(e);n&&n.ranges&&n.equals(t)||e.push(t)}function qr(t,e,n,i){var r=e["spans_"+t.id],o=0;t.iter(Math.max(t.first,n),Math.min(t.first+t.size,i),function(n){n.markedSpans&&((r||(r=e["spans_"+t.id]={}))[o]=n.markedSpans),++o})}function $r(t){if(!t)return null;for(var e,n=0;n-1&&(ho(s)[h]=c[h],delete c[h])}}}return r}function Yr(t,e,n,i){n0}function so(t){t.prototype.on=function(t,e){us(this,t,e)},t.prototype.off=function(t,e){cs(this,t,e)}}function lo(){this.id=null}function uo(t,e,n){for(var i=0,r=0;;){var o=t.indexOf(" ",i);-1==o&&(o=t.length);var a=o-i;if(o==t.length||r+a>=e)return i+Math.min(a,e-r);if(r+=o-i,r+=n-r%n,i=o+1,r>=e)return i}}function co(t){for(;_s.length<=t;)_s.push(ho(_s)+" ");return _s[t]}function ho(t){return t[t.length-1]}function fo(t,e){for(var n=0;n-1&&ks(t)?!0:e.test(t):ks(t)}function _o(t){for(var e in t)if(t.hasOwnProperty(e)&&t[e])return!1;return!0}function bo(t){return t.charCodeAt(0)>=768&&Cs.test(t)}function xo(t,e,n,i){var r=document.createElement(t);if(n&&(r.className=n),i&&(r.style.cssText=i),"string"==typeof e)r.appendChild(document.createTextNode(e));else if(e)for(var o=0;o0;--e)t.removeChild(t.firstChild);return t}function ko(t,e){return wo(t).appendChild(e)}function Co(t,e){if(t.contains)return t.contains(e);for(;e=e.parentNode;)if(e==t)return!0}function So(){return document.activeElement}function To(t){return new RegExp("\\b"+t+"\\b\\s*")}function Mo(t,e){var n=To(e);n.test(t.className)&&(t.className=t.className.replace(n,""))}function Lo(t,e){To(e).test(t.className)||(t.className+=" "+e)}function Eo(t,e){for(var n=t.split(" "),i=0;i2&&!(Zo&&8>ta))}return Ts?xo("span","​"):xo("span"," ",null,"display: inline-block; width: 1px; margin-right: -1px")}function Io(t){if(null!=Ms)return Ms;var e=ko(t,document.createTextNode("AخA")),n=xs(e,0,1).getBoundingClientRect();if(!n||n.left==n.right)return!1;var i=xs(e,1,2).getBoundingClientRect();return Ms=i.right-n.right<3}function Bo(t){if(null!=Os)return Os;var e=ko(t,xo("span","x")),n=e.getBoundingClientRect(),i=xs(e,0,1).getBoundingClientRect();return Os=Math.abs(n.left-i.left)>1}function Ro(t,e,n,i){if(!t)return i(e,n,"ltr");for(var r=!1,o=0;oe||e==n&&a.to==e)&&(i(Math.max(a.from,e),Math.min(a.to,n),1==a.level?"rtl":"ltr"),r=!0)}r||i(e,n,"ltr")}function Wo(t){return t.level%2?t.to:t.from}function Ho(t){return t.level%2?t.from:t.to}function Vo(t){var e=Rr(t);return e?Wo(e[0]):0}function zo(t){var e=Rr(t);return e?Ho(ho(e)):t.text.length}function Fo(t,e){var n=Nr(t.doc,e),i=Ji(n);i!=n&&(e=Dr(i));var r=Rr(i),o=r?r[0].level%2?zo(i):Vo(i):0;return ya(e,o)}function jo(t,e){for(var n,i=Nr(t.doc,e);n=Yi(i);)i=n.find(1,!0).line,e=null;var r=Rr(i),o=r?r[0].level%2?Vo(i):zo(i):i.text.length;return ya(null==e?Dr(i):e,o)}function Uo(t,e){var n=Fo(t,e.line),i=Nr(t.doc,n.line),r=Rr(i);if(!r||0==r[0].level){var o=Math.max(0,i.text.search(/\S/)),a=e.line==n.line&&e.ch<=o&&e.ch;return ya(n.line,a?0:o)}return n}function Ko(t,e,n){var i=t[0].level;return e==i?!0:n==i?!1:n>e}function qo(t,e){Is=null;for(var n,i=0;ie)return i;if(r.from==e||r.to==e){if(null!=n)return Ko(t,r.level,t[n].level)?(r.from!=r.to&&(Is=n),i):(r.from!=r.to&&(Is=i),n);n=i}}return n}function $o(t,e,n,i){if(!i)return e+n;do e+=n;while(e>0&&bo(t.text.charAt(e)));return e}function Go(t,e,n,i){var r=Rr(t);if(!r)return Xo(t,e,n,i);for(var o=qo(r,e),a=r[o],s=$o(t,e,a.level%2?-n:n,i);;){if(s>a.from&&s0==a.level%2?a.to:a.from);if(a=r[o+=n],!a)return null;s=n>0==a.level%2?$o(t,a.to,-1,i):$o(t,a.from,1,i)}}function Xo(t,e,n,i){var r=e+n;if(i)for(;r>0&&bo(t.text.charAt(r));)r+=n;return 0>r||r>t.text.length?null:r}var Yo=/gecko\/\d/i.test(navigator.userAgent),Qo=/MSIE \d/.test(navigator.userAgent),Jo=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Zo=Qo||Jo,ta=Zo&&(Qo?document.documentMode||6:Jo[1]),ea=/WebKit\//.test(navigator.userAgent),na=ea&&/Qt\/\d+\.\d+/.test(navigator.userAgent),ia=/Chrome\//.test(navigator.userAgent),ra=/Opera\//.test(navigator.userAgent),oa=/Apple Computer/.test(navigator.vendor),aa=/KHTML\//.test(navigator.userAgent),sa=/Mac OS X 1\d\D([8-9]|\d\d)\D/.test(navigator.userAgent),la=/PhantomJS/.test(navigator.userAgent),ua=/AppleWebKit/.test(navigator.userAgent)&&/Mobile\/\w+/.test(navigator.userAgent),ca=ua||/Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(navigator.userAgent),ha=ua||/Mac/.test(navigator.platform),da=/win/i.test(navigator.platform),fa=ra&&navigator.userAgent.match(/Version\/(\d*\.\d*)/);fa&&(fa=Number(fa[1])),fa&&fa>=15&&(ra=!1,ea=!0);var pa=ha&&(na||ra&&(null==fa||12.11>fa)),ga=Yo||Zo&&ta>=9,ma=!1,va=!1,ya=t.Pos=function(t,e){return this instanceof ya?(this.line=t,void(this.ch=e)):new ya(t,e)},_a=t.cmpPos=function(t,e){return t.line-e.line||t.ch-e.ch};G.prototype={primary:function(){return this.ranges[this.primIndex]},equals:function(t){if(t==this)return!0;if(t.primIndex!=this.primIndex||t.ranges.length!=this.ranges.length)return!1;for(var e=0;e=0&&_a(t,i.to())<=0)return n}return-1}},X.prototype={from:function(){return $(this.anchor,this.head)},to:function(){return q(this.anchor,this.head)},empty:function(){return this.head.line==this.anchor.line&&this.head.ch==this.anchor.ch}};var ba,xa,wa,ka={left:0,right:0,top:0,bottom:0},Ca=null,Sa=0,Ta=null,Ma=0,La=0,Ea=null;Zo?Ea=-.53:Yo?Ea=15:ia?Ea=-.7:oa&&(Ea=-1/3);var Na,Pa=null,Aa=t.changeEnd=function(t){return t.text?ya(t.from.line+t.text.length-1,ho(t.text).length+(1==t.text.length?t.from.ch:0)):t.to};t.prototype={constructor:t,focus:function(){window.focus(),Tn(this),kn(this)},setOption:function(t,e){var n=this.options,i=n[t];(n[t]!=e||"mode"==t)&&(n[t]=e,Da.hasOwnProperty(t)&&cn(this,Da[t])(this,e,i))},getOption:function(t){return this.options[t]},getDoc:function(){return this.doc},addKeyMap:function(t,e){this.state.keyMaps[e?"push":"unshift"](t)},removeKeyMap:function(t){for(var e=this.state.keyMaps,n=0;nn&&(xi(this,r.head.line,t,!0),n=r.head.line,i==this.doc.sel.primIndex&&_i(this));else{var o=r.from(),a=r.to(),s=Math.max(n,o.line);n=Math.min(this.lastLine(),a.line-(a.ch?0:1))+1;for(var l=s;n>l;++l)xi(this,l,t);var u=this.doc.sel.ranges;0==o.ch&&e.length==u.length&&u[i].from().ch>0&&ae(this.doc,i,new X(o,u[i].to()),gs)}}}),getTokenAt:function(t,e){var n=this.doc;t=Z(n,t);for(var i=Se(this,t.line,e),r=this.doc.mode,o=Nr(n,t.line),a=new Ga(o.text,this.options.tabSize);a.pos>1;if((a?n[2*a-1]:0)>=o)r=a;else{if(!(n[2*a+1]s?e:0==s?null:e.slice(0,s-1)},getModeAt:function(e){var n=this.doc.mode;return n.innerMode?t.innerMode(n,this.getTokenAt(e).state).mode:n},getHelper:function(t,e){return this.getHelpers(t,e)[0]},getHelpers:function(t,e){var n=[];if(!Va.hasOwnProperty(e))return Va;var i=Va[e],r=this.getModeAt(t);if("string"==typeof r[e])i[r[e]]&&n.push(i[r[e]]);else if(r[e])for(var o=0;oi&&(t=i,n=!0);var r=Nr(this.doc,t);return je(this,r,{top:0,left:0},e||"page").top+(n?this.doc.height-Br(r):0)},defaultTextHeight:function(){return Qe(this.display)},defaultCharWidth:function(){return Je(this.display)},setGutterMarker:hn(function(t,e,n){return wi(this.doc,t,"gutter",function(t){var i=t.gutterMarkers||(t.gutterMarkers={});return i[e]=n,!n&&_o(i)&&(t.gutterMarkers=null),!0})}),clearGutter:hn(function(t){var e=this,n=e.doc,i=n.first;n.iter(function(n){n.gutterMarkers&&n.gutterMarkers[t]&&(n.gutterMarkers[t]=null,mn(e,i,"gutter"),_o(n.gutterMarkers)&&(n.gutterMarkers=null)),++i})}),addLineWidget:hn(function(t,e,n){return ar(this,t,e,n)}),removeLineWidget:function(t){t.clear()},lineInfo:function(t){if("number"==typeof t){if(!ee(this.doc,t))return null;var e=t;if(t=Nr(this.doc,t),!t)return null}else{var e=Dr(t);if(null==e)return null}return{line:e,handle:t,text:t.text,gutterMarkers:t.gutterMarkers,textClass:t.textClass,bgClass:t.bgClass,wrapClass:t.wrapClass,widgets:t.widgets}},getViewport:function(){return{from:this.display.viewFrom,to:this.display.viewTo}},addWidget:function(t,e,n,i,r){var o=this.display;t=qe(this,Z(this.doc,t));var a=t.bottom,s=t.left;if(e.style.position="absolute",o.sizer.appendChild(e),"over"==i)a=t.top;else if("above"==i||"near"==i){var l=Math.max(o.wrapper.clientHeight,this.doc.height),u=Math.max(o.sizer.clientWidth,o.lineSpace.clientWidth);("above"==i||t.bottom+e.offsetHeight>l)&&t.top>e.offsetHeight?a=t.top-e.offsetHeight:t.bottom+e.offsetHeight<=l&&(a=t.bottom),s+e.offsetWidth>u&&(s=u-e.offsetWidth)}e.style.top=a+"px",e.style.left=e.style.right="","right"==r?(s=o.sizer.clientWidth-e.offsetWidth,e.style.right="0px"):("left"==r?s=0:"middle"==r&&(s=(o.sizer.clientWidth-e.offsetWidth)/2),e.style.left=s+"px"),n&&mi(this,s,a,s+e.offsetWidth,a+e.offsetHeight)},triggerOnKeyDown:hn(Gn),triggerOnKeyPress:hn(Qn),triggerOnKeyUp:Yn,execCommand:function(t){return ja.hasOwnProperty(t)?ja[t](this):void 0},findPosH:function(t,e,n,i){var r=1;0>e&&(r=-1,e=-e);for(var o=0,a=Z(this.doc,t);e>o&&(a=Ci(this.doc,a,r,n,i),!a.hitSide);++o);return a},moveH:hn(function(t,e){var n=this;n.extendSelectionsBy(function(i){return n.display.shift||n.doc.extend||i.empty()?Ci(n.doc,i.head,t,e,n.options.rtlMoveVisually):0>t?i.from():i.to()},vs)}),deleteH:hn(function(t,e){var n=this.doc.sel,i=this.doc;n.somethingSelected()?i.replaceSelection("",null,"+delete"):ki(this,function(n){var r=Ci(i,n.head,t,e,!1);return 0>t?{from:r,to:n.head}:{from:n.head,to:r}})}),findPosV:function(t,e,n,i){var r=1,o=i;0>e&&(r=-1,e=-e);for(var a=0,s=Z(this.doc,t);e>a;++a){var l=qe(this,s,"div");if(null==o?o=l.left:l.left=o,s=Si(this,l,r,n),s.hitSide)break}return s},moveV:hn(function(t,e){var n=this,i=this.doc,r=[],o=!n.display.shift&&!i.extend&&i.sel.somethingSelected();if(i.extendSelectionsBy(function(a){if(o)return 0>t?a.from():a.to();var s=qe(n,a.head,"div");null!=a.goalColumn&&(s.left=a.goalColumn),r.push(s.left);var l=Si(n,s,t,e);return"page"==e&&a==i.sel.primary()&&yi(n,null,Ke(n,l,"div").top-s.top),l},vs),r.length)for(var a=0;a0&&s(n.charAt(i-1));)--i;for(;r.5)&&a(this),hs(this,"refresh",this)}),swapDoc:hn(function(t){var e=this.doc;return e.cm=null,Er(this,t),Ve(this),Sn(this),this.scrollTo(t.scrollLeft,t.scrollTop),this.curOp.forceScroll=!0,no(this,"swapDoc",this,e),e}),getInputField:function(){return this.display.input},getWrapperElement:function(){return this.display.wrapper},getScrollerElement:function(){return this.display.scroller},getGutterElement:function(){return this.display.gutters}},so(t);var Oa=t.defaults={},Da=t.optionHandlers={},Ia=t.Init={toString:function(){return"CodeMirror.Init"}};Ti("value","",function(t,e){t.setValue(e)},!0),Ti("mode",null,function(t,e){t.doc.modeOption=e,n(t)},!0),Ti("indentUnit",2,n,!0),Ti("indentWithTabs",!1),Ti("smartIndent",!0),Ti("tabSize",4,function(t){i(t),Ve(t),gn(t)},!0),Ti("specialChars",/[\t\u0000-\u0019\u00ad\u200b-\u200f\u2028\u2029\ufeff]/g,function(t,e){t.options.specialChars=new RegExp(e.source+(e.test(" ")?"":"| "),"g"),t.refresh()},!0),Ti("specialCharPlaceholder",yr,function(t){t.refresh()},!0),Ti("electricChars",!0),Ti("rtlMoveVisually",!da),Ti("wholeLineUpdateBefore",!0),Ti("theme","default",function(t){l(t),u(t)},!0),Ti("keyMap","default",s),Ti("extraKeys",null),Ti("lineWrapping",!1,r,!0),Ti("gutters",[],function(t){p(t.options),u(t)},!0),Ti("fixedGutter",!0,function(t,e){t.display.gutters.style.left=e?w(t.display)+"px":"0",t.refresh()},!0),Ti("coverGutterNextToScrollbar",!1,v,!0),Ti("lineNumbers",!1,function(t){p(t.options),u(t)},!0),Ti("firstLineNumber",1,u,!0),Ti("lineNumberFormatter",function(t){return t},u,!0),Ti("showCursorWhenSelecting",!1,ye,!0),Ti("resetSelectionOnContextMenu",!0),Ti("readOnly",!1,function(t,e){"nocursor"==e?(Zn(t),t.display.input.blur(),t.display.disabled=!0):(t.display.disabled=!1,e||Sn(t))}),Ti("disableInput",!1,function(t,e){e||Sn(t)},!0),Ti("dragDrop",!0),Ti("cursorBlinkRate",530),Ti("cursorScrollMargin",0),Ti("cursorHeight",1,ye,!0),Ti("singleCursorHeightPerLine",!0,ye,!0),Ti("workTime",100),Ti("workDelay",100),Ti("flattenSpans",!0,i,!0),Ti("addModeClass",!1,i,!0),Ti("pollInterval",100),Ti("undoDepth",200,function(t,e){t.doc.history.undoDepth=e}),Ti("historyEventDelay",1250),Ti("viewportMargin",10,function(t){t.refresh()},!0),Ti("maxHighlightLength",1e4,i,!0),Ti("moveInputWithCursor",!0,function(t,e){e||(t.display.inputDiv.style.top=t.display.inputDiv.style.left=0)}),Ti("tabindex",null,function(t,e){t.display.input.tabIndex=e||""}),Ti("autofocus",null);var Ba=t.modes={},Ra=t.mimeModes={};t.defineMode=function(e,n){t.defaults.mode||"null"==e||(t.defaults.mode=e),arguments.length>2&&(n.dependencies=Array.prototype.slice.call(arguments,2)),Ba[e]=n},t.defineMIME=function(t,e){Ra[t]=e},t.resolveMode=function(e){if("string"==typeof e&&Ra.hasOwnProperty(e))e=Ra[e];else if(e&&"string"==typeof e.name&&Ra.hasOwnProperty(e.name)){var n=Ra[e.name];"string"==typeof n&&(n={name:n}),e=go(n,e),e.name=n.name}else if("string"==typeof e&&/^[\w\-]+\/[\w\-]+\+xml$/.test(e))return t.resolveMode("application/xml");return"string"==typeof e?{name:e}:e||{name:"null"}},t.getMode=function(e,n){var n=t.resolveMode(n),i=Ba[n.name];if(!i)return t.getMode(e,"text/plain");var r=i(e,n);if(Wa.hasOwnProperty(n.name)){var o=Wa[n.name];for(var a in o)o.hasOwnProperty(a)&&(r.hasOwnProperty(a)&&(r["_"+a]=r[a]),r[a]=o[a])}if(r.name=n.name,n.helperType&&(r.helperType=n.helperType),n.modeProps)for(var a in n.modeProps)r[a]=n.modeProps[a];return r},t.defineMode("null",function(){return{token:function(t){t.skipToEnd()}}}),t.defineMIME("text/plain","null");var Wa=t.modeExtensions={};t.extendMode=function(t,e){var n=Wa.hasOwnProperty(t)?Wa[t]:Wa[t]={};mo(e,n)},t.defineExtension=function(e,n){t.prototype[e]=n},t.defineDocExtension=function(t,e){is.prototype[t]=e},t.defineOption=Ti;var Ha=[];t.defineInitHook=function(t){Ha.push(t)};var Va=t.helpers={};t.registerHelper=function(e,n,i){Va.hasOwnProperty(e)||(Va[e]=t[e]={_global:[]}),Va[e][n]=i},t.registerGlobalHelper=function(e,n,i,r){t.registerHelper(e,n,r),Va[e]._global.push({pred:i,val:r})};var za=t.copyState=function(t,e){if(e===!0)return e;if(t.copyState)return t.copyState(e);var n={};for(var i in e){var r=e[i];r instanceof Array&&(r=r.concat([])),n[i]=r}return n},Fa=t.startState=function(t,e,n){return t.startState?t.startState(e,n):!0};t.innerMode=function(t,e){for(;t.innerMode;){var n=t.innerMode(e);if(!n||n.mode==t)break;e=n.state,t=n.mode}return n||{mode:t,state:e}};var ja=t.commands={selectAll:function(t){t.setSelection(ya(t.firstLine(),0),ya(t.lastLine()),gs)},singleSelection:function(t){t.setSelection(t.getCursor("anchor"),t.getCursor("head"),gs)},killLine:function(t){ki(t,function(e){if(e.empty()){var n=Nr(t.doc,e.head.line).text.length;return e.head.ch==n&&e.head.line0)r=new ya(r.line,r.ch+1),t.replaceRange(o.charAt(r.ch-1)+o.charAt(r.ch-2),ya(r.line,r.ch-2),r,"+transpose");else if(r.line>t.doc.first){var a=Nr(t.doc,r.line-1).text;a&&t.replaceRange(o.charAt(0)+"\n"+a.charAt(a.length-1),ya(r.line-1,a.length-1),ya(r.line,1),"+transpose")}n.push(new X(r,r))}t.setSelections(n)})},newlineAndIndent:function(t){un(t,function(){for(var e=t.listSelections().length,n=0;e>n;n++){var i=t.listSelections()[n];t.replaceRange("\n",i.anchor,i.head,"+input"),t.indentLine(i.from().line+1,null,!0),_i(t)}})},toggleOverwrite:function(t){t.toggleOverwrite()}},Ua=t.keyMap={};Ua.basic={Left:"goCharLeft",Right:"goCharRight",Up:"goLineUp",Down:"goLineDown",End:"goLineEnd",Home:"goLineStartSmart",PageUp:"goPageUp",PageDown:"goPageDown",Delete:"delCharAfter",Backspace:"delCharBefore","Shift-Backspace":"delCharBefore",Tab:"defaultTab","Shift-Tab":"indentAuto",Enter:"newlineAndIndent",Insert:"toggleOverwrite",Esc:"singleSelection"},Ua.pcDefault={"Ctrl-A":"selectAll","Ctrl-D":"deleteLine","Ctrl-Z":"undo","Shift-Ctrl-Z":"redo","Ctrl-Y":"redo","Ctrl-Home":"goDocStart","Ctrl-End":"goDocEnd","Ctrl-Up":"goLineUp","Ctrl-Down":"goLineDown","Ctrl-Left":"goGroupLeft","Ctrl-Right":"goGroupRight","Alt-Left":"goLineStart","Alt-Right":"goLineEnd","Ctrl-Backspace":"delGroupBefore","Ctrl-Delete":"delGroupAfter","Ctrl-S":"save","Ctrl-F":"find","Ctrl-G":"findNext","Shift-Ctrl-G":"findPrev","Shift-Ctrl-F":"replace","Shift-Ctrl-R":"replaceAll","Ctrl-[":"indentLess","Ctrl-]":"indentMore","Ctrl-U":"undoSelection","Shift-Ctrl-U":"redoSelection","Alt-U":"redoSelection",fallthrough:"basic"},Ua.macDefault={"Cmd-A":"selectAll","Cmd-D":"deleteLine","Cmd-Z":"undo","Shift-Cmd-Z":"redo","Cmd-Y":"redo","Cmd-Home":"goDocStart","Cmd-Up":"goDocStart","Cmd-End":"goDocEnd","Cmd-Down":"goDocEnd","Alt-Left":"goGroupLeft","Alt-Right":"goGroupRight","Cmd-Left":"goLineLeft","Cmd-Right":"goLineRight","Alt-Backspace":"delGroupBefore","Ctrl-Alt-Backspace":"delGroupAfter","Alt-Delete":"delGroupAfter","Cmd-S":"save","Cmd-F":"find","Cmd-G":"findNext","Shift-Cmd-G":"findPrev","Cmd-Alt-F":"replace","Shift-Cmd-Alt-F":"replaceAll","Cmd-[":"indentLess","Cmd-]":"indentMore","Cmd-Backspace":"delWrappedLineLeft","Cmd-Delete":"delWrappedLineRight","Cmd-U":"undoSelection","Shift-Cmd-U":"redoSelection","Ctrl-Up":"goDocStart","Ctrl-Down":"goDocEnd",fallthrough:["basic","emacsy"]},Ua.emacsy={"Ctrl-F":"goCharRight","Ctrl-B":"goCharLeft","Ctrl-P":"goLineUp","Ctrl-N":"goLineDown","Alt-F":"goWordRight","Alt-B":"goWordLeft","Ctrl-A":"goLineStart","Ctrl-E":"goLineEnd","Ctrl-V":"goPageDown","Shift-Ctrl-V":"goPageUp","Ctrl-D":"delCharAfter","Ctrl-H":"delCharBefore","Alt-D":"delWordAfter","Alt-Backspace":"delWordBefore","Ctrl-K":"killLine","Ctrl-T":"transposeChars"},Ua["default"]=ha?Ua.macDefault:Ua.pcDefault;var Ka=t.lookupKey=function(t,e,n){function i(e){e=Mi(e);var r=e[t];if(r===!1)return"stop";if(null!=r&&n(r))return!0;if(e.nofallthrough)return"stop";var o=e.fallthrough;if(null==o)return!1;if("[object Array]"!=Object.prototype.toString.call(o))return i(o);for(var a=0;a=this.string.length},sol:function(){return this.pos==this.lineStart},peek:function(){return this.string.charAt(this.pos)||void 0},next:function(){return this.pose},eatSpace:function(){for(var t=this.pos;/[\s\u00a0]/.test(this.string.charAt(this.pos));)++this.pos;return this.pos>t},skipToEnd:function(){this.pos=this.string.length},skipTo:function(t){var e=this.string.indexOf(t,this.pos);return e>-1?(this.pos=e,!0):void 0},backUp:function(t){this.pos-=t},column:function(){return this.lastColumnPos0?null:(i&&e!==!1&&(this.pos+=i[0].length),i)}var r=function(t){return n?t.toLowerCase():t},o=this.string.substr(this.pos,t.length);return r(o)==r(t)?(e!==!1&&(this.pos+=t.length),!0):void 0},current:function(){return this.string.slice(this.start,this.pos)},hideFirstChars:function(t,e){this.lineStart+=t;try{return e()}finally{this.lineStart-=t}}};var Xa=t.TextMarker=function(t,e){this.lines=[],this.type=e,this.doc=t};so(Xa),Xa.prototype.clear=function(){if(!this.explicitlyCleared){var t=this.doc.cm,e=t&&!t.curOp;if(e&&Ze(t),ao(this,"clear")){var n=this.find();n&&no(this,"clear",n.from,n.to)}for(var i=null,r=null,o=0;ot.display.maxLineLength&&(t.display.maxLine=l,t.display.maxLineLength=u,t.display.maxLineChanged=!0)}null!=i&&t&&this.collapsed&&gn(t,i,r+1),this.lines.length=0,this.explicitlyCleared=!0,this.atomic&&this.doc.cantEdit&&(this.doc.cantEdit=!1,t&&fe(t.doc)),t&&no(t,"markerCleared",t,this),e&&en(t),this.parent&&this.parent.clear()}},Xa.prototype.find=function(t,e){null==t&&"bookmark"==this.type&&(t=1);for(var n,i,r=0;rn;++n){var r=this.lines[n];this.height-=r.height,lr(r),no(r,"delete")}this.lines.splice(t,e)},collapse:function(t){t.push.apply(t,this.lines)},insertInner:function(t,e,n){this.height+=n,this.lines=this.lines.slice(0,t).concat(e).concat(this.lines.slice(t));for(var i=0;it;++t)if(n(this.lines[t]))return!0}},Mr.prototype={chunkSize:function(){return this.size},removeInner:function(t,e){this.size-=e;for(var n=0;nt){var o=Math.min(e,r-t),a=i.height;if(i.removeInner(t,o),this.height-=a-i.height,r==o&&(this.children.splice(n--,1),i.parent=null),0==(e-=o))break;t=0}else t-=r}if(this.size-e<25&&(this.children.length>1||!(this.children[0]instanceof Tr))){var s=[];this.collapse(s),this.children=[new Tr(s)],this.children[0].parent=this}},collapse:function(t){for(var e=0;e=t){if(r.insertInner(t,e,n),r.lines&&r.lines.length>50){for(;r.lines.length>50;){var a=r.lines.splice(r.lines.length-25,25),s=new Tr(a);r.height-=s.height,this.children.splice(i+1,0,s),s.parent=this}this.maybeSpill()}break}t-=o}},maybeSpill:function(){if(!(this.children.length<=10)){var t=this;do{var e=t.children.splice(t.children.length-5,5),n=new Mr(e);if(t.parent){t.size-=n.size,t.height-=n.height;var i=fo(t.parent.children,t);t.parent.children.splice(i+1,0,n)}else{var r=new Mr(t.children);r.parent=t,t.children=[r,n],t=r}n.parent=t.parent}while(t.children.length>10);t.parent.maybeSpill()}},iterN:function(t,e,n){for(var i=0;it){var a=Math.min(e,o-t);if(r.iterN(t,a,n))return!0;if(0==(e-=a))break;t=0}else t-=o}}};var ns=0,is=t.Doc=function(t,e,n){if(!(this instanceof is))return new is(t,e,n);null==n&&(n=0),Mr.call(this,[new Tr([new Za("",null)])]),this.first=n,this.scrollTop=this.scrollLeft=0,this.cantEdit=!1,this.cleanGeneration=1,this.frontier=n;var i=ya(n,0);this.sel=Q(i),this.history=new Wr(null),this.id=++ns,this.modeOption=e,"string"==typeof t&&(t=Ns(t)),Sr(this,{from:i,to:i,text:t}),ce(this,Q(i),gs)};is.prototype=go(Mr.prototype,{constructor:is,iter:function(t,e,n){n?this.iterN(t-this.first,e-t,n):this.iterN(this.first,this.first+this.size,t)},insert:function(t,e){for(var n=0,i=0;i=0;o--)si(this,i[o]);s?ue(this,s):this.cm&&_i(this.cm)}),undo:dn(function(){ui(this,"undo")}),redo:dn(function(){ui(this,"redo")}),undoSelection:dn(function(){ui(this,"undo",!0)}),redoSelection:dn(function(){ui(this,"redo",!0)}),setExtending:function(t){this.extend=t},getExtending:function(){return this.extend},historySize:function(){for(var t=this.history,e=0,n=0,i=0;i=t.ch)&&e.push(r.marker.parent||r.marker)}return e},findMarks:function(t,e,n){t=Z(this,t),e=Z(this,e);var i=[],r=t.line;return this.iter(t.line,e.line+1,function(o){var a=o.markedSpans;if(a)for(var s=0;sl.to||null==l.from&&r!=t.line||r==e.line&&l.from>e.ch||n&&!n(l.marker)||i.push(l.marker.parent||l.marker)}++r}),i},getAllMarks:function(){var t=[];return this.iter(function(e){var n=e.markedSpans;if(n)for(var i=0;it?(e=t,!0):(t-=r,void++n)}),Z(this,ya(n,e))},indexFromPos:function(t){t=Z(this,t);var e=t.ch;return t.linee&&(e=t.from),null!=t.to&&t.tos||s>=e)return a+(e-o);a+=s-o,a+=n-a%n,o=s+1}},_s=[""],bs=function(t){t.select()};ua?bs=function(t){t.selectionStart=0,t.selectionEnd=t.value.length}:Zo&&(bs=function(t){try{t.select()}catch(e){}}),[].indexOf&&(fo=function(t,e){return t.indexOf(e)}),[].map&&(po=function(t,e){return t.map(e)});var xs,ws=/[\u00df\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/,ks=t.isWordChar=function(t){return/\w/.test(t)||t>"€"&&(t.toUpperCase()!=t.toLowerCase()||ws.test(t))},Cs=/[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/;xs=document.createRange?function(t,e,n){var i=document.createRange();return i.setEnd(t,n),i.setStart(t,e),i}:function(t,e,n){var i=document.body.createTextRange();return i.moveToElementText(t.parentNode),i.collapse(!0),i.moveEnd("character",n),i.moveStart("character",e),i},Zo&&11>ta&&(So=function(){try{return document.activeElement}catch(t){return document.body}});var Ss,Ts,Ms,Ls=!1,Es=function(){if(Zo&&9>ta)return!1;var t=xo("div");return"draggable"in t||"dragDrop"in t}(),Ns=t.splitLines=3!="\n\nb".split(/\n/).length?function(t){for(var e=0,n=[],i=t.length;i>=e;){var r=t.indexOf("\n",e);-1==r&&(r=t.length);var o=t.slice(e,"\r"==t.charAt(r-1)?r-1:r),a=o.indexOf("\r");-1!=a?(n.push(o.slice(0,a)),e+=a+1):(n.push(o),e=r+1)}return n}:function(t){return t.split(/\r\n?|\n/)},Ps=window.getSelection?function(t){try{return t.selectionStart!=t.selectionEnd}catch(e){return!1}}:function(t){try{var e=t.ownerDocument.selection.createRange()}catch(n){}return e&&e.parentElement()==t?0!=e.compareEndPoints("StartToEnd",e):!1},As=function(){var t=xo("div");return"oncopy"in t?!0:(t.setAttribute("oncopy","return;"),"function"==typeof t.oncopy)}(),Os=null,Ds={3:"Enter",8:"Backspace",9:"Tab",13:"Enter",16:"Shift",17:"Ctrl",18:"Alt",19:"Pause",20:"CapsLock",27:"Esc",32:"Space",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"Left",38:"Up",39:"Right",40:"Down",44:"PrintScrn",45:"Insert",46:"Delete",59:";",61:"=",91:"Mod",92:"Mod",93:"Mod",107:"=",109:"-",127:"Delete",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'",63232:"Up",63233:"Down",63234:"Left",63235:"Right",63272:"Delete",63273:"Home",63275:"End",63276:"PageUp",63277:"PageDown",63302:"Insert"};t.keyNames=Ds,function(){for(var t=0;10>t;t++)Ds[t+48]=Ds[t+96]=String(t);for(var t=65;90>=t;t++)Ds[t]=String.fromCharCode(t);for(var t=1;12>=t;t++)Ds[t+111]=Ds[t+63235]="F"+t}();var Is,Bs=function(){function t(t){return 247>=t?n.charAt(t):t>=1424&&1524>=t?"R":t>=1536&&1773>=t?i.charAt(t-1536):t>=1774&&2220>=t?"r":t>=8192&&8203>=t?"w":8204==t?"b":"L"}function e(t,e,n){this.level=t,this.from=e,this.to=n}var n="bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN",i="rrrrrrrrrrrr,rNNmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmrrrrrrrnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmNmmmm",r=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/,o=/[stwN]/,a=/[LRr]/,s=/[Lb1n]/,l=/[1n]/,u="L";return function(n){if(!r.test(n))return!1;for(var i,c=n.length,h=[],d=0;c>d;++d)h.push(i=t(n.charCodeAt(d)));for(var d=0,f=u;c>d;++d){var i=h[d];"m"==i?h[d]=f:f=i}for(var d=0,p=u;c>d;++d){var i=h[d];"1"==i&&"r"==p?h[d]="n":a.test(i)&&(p=i,"r"==i&&(h[d]="R"))}for(var d=1,f=h[0];c-1>d;++d){var i=h[d];"+"==i&&"1"==f&&"1"==h[d+1]?h[d]="1":","!=i||f!=h[d+1]||"1"!=f&&"n"!=f||(h[d]=f),f=i}for(var d=0;c>d;++d){var i=h[d];if(","==i)h[d]="N";else if("%"==i){for(var g=d+1;c>g&&"%"==h[g];++g);for(var m=d&&"!"==h[d-1]||c>g&&"1"==h[g]?"1":"N",v=d;g>v;++v)h[v]=m;d=g-1}}for(var d=0,p=u;c>d;++d){var i=h[d];"L"==p&&"1"==i?h[d]="L":a.test(i)&&(p=i)}for(var d=0;c>d;++d)if(o.test(h[d])){for(var g=d+1;c>g&&o.test(h[g]);++g);for(var y="L"==(d?h[d-1]:u),_="L"==(c>g?h[g]:u),m=y||_?"L":"R",v=d;g>v;++v)h[v]=m;d=g-1}for(var b,x=[],d=0;c>d;)if(s.test(h[d])){var w=d;for(++d;c>d&&s.test(h[d]);++d);x.push(new e(0,w,d))}else{var k=d,C=x.length;for(++d;c>d&&"L"!=h[d];++d);for(var v=k;d>v;)if(l.test(h[v])){v>k&&x.splice(C,0,new e(1,k,v));var S=v;for(++v;d>v&&l.test(h[v]);++v);x.splice(C,0,new e(2,S,v)),k=v}else++v;d>k&&x.splice(C,0,new e(1,k,d))}return 1==x[0].level&&(b=n.match(/^\s+/))&&(x[0].from=b[0].length,x.unshift(new e(0,0,b[0].length))),1==ho(x).level&&(b=n.match(/\s+$/))&&(ho(x).to-=b[0].length,x.push(new e(0,c-b[0].length,c))),x[0].level!=ho(x).level&&x.push(new e(x[0].level,c,c)),x}}();return t.version="4.7.0",t}),function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";t.defineMode("xml",function(e,n){function i(t,e){function n(n){return e.tokenize=n,n(t,e)}var i=t.next();if("<"==i)return t.eat("!")?t.eat("[")?t.match("CDATA[")?n(a("atom","]]>")):null:t.match("--")?n(a("comment","-->")):t.match("DOCTYPE",!0,!0)?(t.eatWhile(/[\w\._\-]/),n(s(1))):null:t.eat("?")?(t.eatWhile(/[\w\._\-]/),e.tokenize=a("meta","?>"),"meta"):(k=t.eat("/")?"closeTag":"openTag",e.tokenize=r,"tag bracket");if("&"==i){var o;return o=t.eat("#")?t.eat("x")?t.eatWhile(/[a-fA-F\d]/)&&t.eat(";"):t.eatWhile(/[\d]/)&&t.eat(";"):t.eatWhile(/[\w\.\-:]/)&&t.eat(";"),o?"atom":"error"}return t.eatWhile(/[^&<]/),null}function r(t,e){var n=t.next();if(">"==n||"/"==n&&t.eat(">"))return e.tokenize=i,k=">"==n?"endTag":"selfcloseTag","tag bracket";if("="==n)return k="equals",null;if("<"==n){e.tokenize=i,e.state=h,e.tagName=e.tagStart=null;var r=e.tokenize(t,e);return r?r+" tag error":"tag error"}return/[\'\"]/.test(n)?(e.tokenize=o(n),e.stringStartCol=t.column(),e.tokenize(t,e)):(t.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/),"word")}function o(t){var e=function(e,n){for(;!e.eol();)if(e.next()==t){n.tokenize=r;break}return"string"};return e.isInAttribute=!0,e}function a(t,e){return function(n,r){for(;!n.eol();){if(n.match(e)){r.tokenize=i;break}n.next()}return t}}function s(t){return function(e,n){for(var r;null!=(r=e.next());){if("<"==r)return n.tokenize=s(t+1),n.tokenize(e,n);if(">"==r){if(1==t){n.tokenize=i;break}return n.tokenize=s(t-1),n.tokenize(e,n)}}return"meta"}}function l(t,e,n){this.prev=t.context,this.tagName=e,this.indent=t.indented,this.startOfLine=n,(S.doNotIndent.hasOwnProperty(e)||t.context&&t.context.noIndent)&&(this.noIndent=!0)}function u(t){t.context&&(t.context=t.context.prev)}function c(t,e){for(var n;;){if(!t.context)return;if(n=t.context.tagName,!S.contextGrabbers.hasOwnProperty(n)||!S.contextGrabbers[n].hasOwnProperty(e))return;u(t)}}function h(t,e,n){return"openTag"==t?(n.tagStart=e.column(),d):"closeTag"==t?f:h}function d(t,e,n){return"word"==t?(n.tagName=e.current(),C="tag",m):(C="error",d)}function f(t,e,n){if("word"==t){var i=e.current();return n.context&&n.context.tagName!=i&&S.implicitlyClosed.hasOwnProperty(n.context.tagName)&&u(n),n.context&&n.context.tagName==i?(C="tag",p):(C="tag error",g)}return C="error",g}function p(t,e,n){return"endTag"!=t?(C="error",p):(u(n),h)}function g(t,e,n){return C="error",p(t,e,n)}function m(t,e,n){if("word"==t)return C="attribute",v;if("endTag"==t||"selfcloseTag"==t){var i=n.tagName,r=n.tagStart;return n.tagName=n.tagStart=null,"selfcloseTag"==t||S.autoSelfClosers.hasOwnProperty(i)?c(n,i):(c(n,i),n.context=new l(n,i,r==n.indented)),h }return C="error",m}function v(t,e,n){return"equals"==t?y:(S.allowMissing||(C="error"),m(t,e,n))}function y(t,e,n){return"string"==t?_:"word"==t&&S.allowUnquoted?(C="string",m):(C="error",m(t,e,n))}function _(t,e,n){return"string"==t?_:m(t,e,n)}var b=e.indentUnit,x=n.multilineTagIndentFactor||1,w=n.multilineTagIndentPastTag;null==w&&(w=!0);var k,C,S=n.htmlMode?{autoSelfClosers:{area:!0,base:!0,br:!0,col:!0,command:!0,embed:!0,frame:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0,menuitem:!0},implicitlyClosed:{dd:!0,li:!0,optgroup:!0,option:!0,p:!0,rp:!0,rt:!0,tbody:!0,td:!0,tfoot:!0,th:!0,tr:!0},contextGrabbers:{dd:{dd:!0,dt:!0},dt:{dd:!0,dt:!0},li:{li:!0},option:{option:!0,optgroup:!0},optgroup:{optgroup:!0},p:{address:!0,article:!0,aside:!0,blockquote:!0,dir:!0,div:!0,dl:!0,fieldset:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,menu:!0,nav:!0,ol:!0,p:!0,pre:!0,section:!0,table:!0,ul:!0},rp:{rp:!0,rt:!0},rt:{rp:!0,rt:!0},tbody:{tbody:!0,tfoot:!0},td:{td:!0,th:!0},tfoot:{tbody:!0},th:{td:!0,th:!0},thead:{tbody:!0,tfoot:!0},tr:{tr:!0}},doNotIndent:{pre:!0},allowUnquoted:!0,allowMissing:!0,caseFold:!0}:{autoSelfClosers:{},implicitlyClosed:{},contextGrabbers:{},doNotIndent:{},allowUnquoted:!1,allowMissing:!1,caseFold:!1},T=n.alignCDATA;return{startState:function(){return{tokenize:i,state:h,indented:0,tagName:null,tagStart:null,context:null}},token:function(t,e){if(!e.tagName&&t.sol()&&(e.indented=t.indentation()),t.eatSpace())return null;k=null;var n=e.tokenize(t,e);return(n||k)&&"comment"!=n&&(C=null,e.state=e.state(k||n,t,e),C&&(n="error"==C?n+" error":C)),n},indent:function(e,n,o){var a=e.context;if(e.tokenize.isInAttribute)return e.tagStart==e.indented?e.stringStartCol+1:e.indented+b;if(a&&a.noIndent)return t.Pass;if(e.tokenize!=r&&e.tokenize!=i)return o?o.match(/^(\s*)/)[0].length:0;if(e.tagName)return w?e.tagStart+e.tagName.length+2:e.tagStart+b*x;if(T&&/$/,blockCommentStart:"",configuration:n.htmlMode?"html":"xml",helperType:n.htmlMode?"html":"xml"}}),t.defineMIME("text/xml","xml"),t.defineMIME("application/xml","xml"),t.mimeModes.hasOwnProperty("text/html")||t.defineMIME("text/html",{name:"xml",htmlMode:!0})}),function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";t.defineMode("javascript",function(e,n){function i(t){for(var e,n=!1,i=!1;null!=(e=t.next());){if(!n){if("/"==e&&!i)return;"["==e?i=!0:i&&"]"==e&&(i=!1)}n=!n&&"\\"==e}}function r(t,e,n){return pe=t,ge=n,e}function o(t,e){var n=t.next();if('"'==n||"'"==n)return e.tokenize=a(n),e.tokenize(t,e);if("."==n&&t.match(/^\d+(?:[eE][+\-]?\d+)?/))return r("number","number");if("."==n&&t.match(".."))return r("spread","meta");if(/[\[\]{}\(\),;\:\.]/.test(n))return r(n);if("="==n&&t.eat(">"))return r("=>","operator");if("0"==n&&t.eat(/x/i))return t.eatWhile(/[\da-f]/i),r("number","number");if(/\d/.test(n))return t.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/),r("number","number");if("/"==n)return t.eat("*")?(e.tokenize=s,s(t,e)):t.eat("/")?(t.skipToEnd(),r("comment","comment")):"operator"==e.lastType||"keyword c"==e.lastType||"sof"==e.lastType||/^[\[{}\(,;:]$/.test(e.lastType)?(i(t),t.eatWhile(/[gimy]/),r("regexp","string-2")):(t.eatWhile(ke),r("operator","operator",t.current()));if("`"==n)return e.tokenize=l,l(t,e);if("#"==n)return t.skipToEnd(),r("error","error");if(ke.test(n))return t.eatWhile(ke),r("operator","operator",t.current());if(xe.test(n)){t.eatWhile(xe);var o=t.current(),u=we.propertyIsEnumerable(o)&&we[o];return u&&"."!=e.lastType?r(u.type,u.style,o):r("variable","variable",o)}}function a(t){return function(e,n){var i,a=!1;if(ye&&"@"==e.peek()&&e.match(Ce))return n.tokenize=o,r("jsonld-keyword","meta");for(;null!=(i=e.next())&&(i!=t||a);)a=!a&&"\\"==i;return a||(n.tokenize=o),r("string","string")}}function s(t,e){for(var n,i=!1;n=t.next();){if("/"==n&&i){e.tokenize=o;break}i="*"==n}return r("comment","comment")}function l(t,e){for(var n,i=!1;null!=(n=t.next());){if(!i&&("`"==n||"$"==n&&t.eat("{"))){e.tokenize=o;break}i=!i&&"\\"==n}return r("quasi","string-2",t.current())}function u(t,e){e.fatArrowAt&&(e.fatArrowAt=null);var n=t.string.indexOf("=>",t.start);if(!(0>n)){for(var i=0,r=!1,o=n-1;o>=0;--o){var a=t.string.charAt(o),s=Se.indexOf(a);if(s>=0&&3>s){if(!i){++o;break}if(0==--i)break}else if(s>=3&&6>s)++i;else if(xe.test(a))r=!0;else if(r&&!i){++o;break}}r&&!i&&(e.fatArrowAt=o)}}function c(t,e,n,i,r,o){this.indented=t,this.column=e,this.type=n,this.prev=r,this.info=o,null!=i&&(this.align=i)}function h(t,e){for(var n=t.localVars;n;n=n.next)if(n.name==e)return!0;for(var i=t.context;i;i=i.prev)for(var n=i.vars;n;n=n.next)if(n.name==e)return!0}function d(t,e,n,i,r){var o=t.cc;for(Me.state=t,Me.stream=r,Me.marked=null,Me.cc=o,Me.style=e,t.lexical.hasOwnProperty("align")||(t.lexical.align=!0);;){var a=o.length?o.pop():_e?w:x;if(a(n,i)){for(;o.length&&o[o.length-1].lex;)o.pop()();return Me.marked?Me.marked:"variable"==n&&h(t,i)?"variable-2":e}}}function f(){for(var t=arguments.length-1;t>=0;t--)Me.cc.push(arguments[t])}function p(){return f.apply(null,arguments),!0}function g(t){function e(e){for(var n=e;n;n=n.next)if(n.name==t)return!0;return!1}var i=Me.state;if(i.context){if(Me.marked="def",e(i.localVars))return;i.localVars={name:t,next:i.localVars}}else{if(e(i.globalVars))return;n.globalVars&&(i.globalVars={name:t,next:i.globalVars})}}function m(){Me.state.context={prev:Me.state.context,vars:Me.state.localVars},Me.state.localVars=Le}function v(){Me.state.localVars=Me.state.context.vars,Me.state.context=Me.state.context.prev}function y(t,e){var n=function(){var n=Me.state,i=n.indented;if("stat"==n.lexical.type)i=n.lexical.indented;else for(var r=n.lexical;r&&")"==r.type&&r.align;r=r.prev)i=r.indented;n.lexical=new c(i,Me.stream.column(),t,null,n.lexical,e)};return n.lex=!0,n}function _(){var t=Me.state;t.lexical.prev&&(")"==t.lexical.type&&(t.indented=t.lexical.indented),t.lexical=t.lexical.prev)}function b(t){function e(n){return n==t?p():";"==t?f():p(e)}return e}function x(t,e){return"var"==t?p(y("vardef",e.length),j,b(";"),_):"keyword a"==t?p(y("form"),w,x,_):"keyword b"==t?p(y("form"),x,_):"{"==t?p(y("}"),V,_):";"==t?p():"if"==t?("else"==Me.state.lexical.info&&Me.state.cc[Me.state.cc.length-1]==_&&Me.state.cc.pop()(),p(y("form"),w,x,_,G)):"function"==t?p(te):"for"==t?p(y("form"),X,x,_):"variable"==t?p(y("stat"),O):"switch"==t?p(y("form"),w,y("}","switch"),b("{"),V,_,_):"case"==t?p(w,b(":")):"default"==t?p(b(":")):"catch"==t?p(y("form"),m,b("("),ee,b(")"),x,_,v):"module"==t?p(y("form"),m,ae,v,_):"class"==t?p(y("form"),ne,_):"export"==t?p(y("form"),se,_):"import"==t?p(y("form"),le,_):f(y("stat"),w,b(";"),_)}function w(t){return C(t,!1)}function k(t){return C(t,!0)}function C(t,e){if(Me.state.fatArrowAt==Me.stream.start){var n=e?A:P;if("("==t)return p(m,y(")"),W(U,")"),_,b("=>"),n,v);if("variable"==t)return f(m,U,b("=>"),n,v)}var i=e?L:M;return Te.hasOwnProperty(t)?p(i):"function"==t?p(te,i):"keyword c"==t?p(e?T:S):"("==t?p(y(")"),S,fe,b(")"),_,i):"operator"==t||"spread"==t?p(e?k:w):"["==t?p(y("]"),he,_,i):"{"==t?H(I,"}",null,i):"quasi"==t?f(E,i):p()}function S(t){return t.match(/[;\}\)\],]/)?f():f(w)}function T(t){return t.match(/[;\}\)\],]/)?f():f(k)}function M(t,e){return","==t?p(w):L(t,e,!1)}function L(t,e,n){var i=0==n?M:L,r=0==n?w:k;return"=>"==t?p(m,n?A:P,v):"operator"==t?/\+\+|--/.test(e)?p(i):"?"==e?p(w,b(":"),r):p(r):"quasi"==t?f(E,i):";"!=t?"("==t?H(k,")","call",i):"."==t?p(D,i):"["==t?p(y("]"),S,b("]"),_,i):void 0:void 0}function E(t,e){return"quasi"!=t?f():"${"!=e.slice(e.length-2)?p(E):p(w,N)}function N(t){return"}"==t?(Me.marked="string-2",Me.state.tokenize=l,p(E)):void 0}function P(t){return u(Me.stream,Me.state),f("{"==t?x:w)}function A(t){return u(Me.stream,Me.state),f("{"==t?x:k)}function O(t){return":"==t?p(_,x):f(M,b(";"),_)}function D(t){return"variable"==t?(Me.marked="property",p()):void 0}function I(t,e){return"variable"==t||"keyword"==Me.style?(Me.marked="property",p("get"==e||"set"==e?B:R)):"number"==t||"string"==t?(Me.marked=ye?"property":Me.style+" property",p(R)):"jsonld-keyword"==t?p(R):"["==t?p(w,b("]"),R):void 0}function B(t){return"variable"!=t?f(R):(Me.marked="property",p(te))}function R(t){return":"==t?p(k):"("==t?f(te):void 0}function W(t,e){function n(i){if(","==i){var r=Me.state.lexical;return"call"==r.info&&(r.pos=(r.pos||0)+1),p(t,n)}return i==e?p():p(b(e))}return function(i){return i==e?p():f(t,n)}}function H(t,e,n){for(var i=3;i!?|~^]/,Ce=/^@(context|id|value|language|type|container|list|set|reverse|index|base|vocab|graph)"/,Se="([{}])",Te={atom:!0,number:!0,variable:!0,string:!0,regexp:!0,"this":!0,"jsonld-keyword":!0},Me={state:null,column:null,marked:null,cc:null},Le={name:"this",next:{name:"arguments"}};return _.lex=!0,{startState:function(t){var e={tokenize:o,lastType:"sof",cc:[],lexical:new c((t||0)-me,0,"block",!1),localVars:n.localVars,context:n.localVars&&{vars:n.localVars},indented:0};return n.globalVars&&"object"==typeof n.globalVars&&(e.globalVars=n.globalVars),e},token:function(t,e){if(t.sol()&&(e.lexical.hasOwnProperty("align")||(e.lexical.align=!1),e.indented=t.indentation(),u(t,e)),e.tokenize!=s&&t.eatSpace())return null;var n=e.tokenize(t,e);return"comment"==pe?n:(e.lastType="operator"!=pe||"++"!=ge&&"--"!=ge?pe:"incdec",d(e,n,pe,ge,t))},indent:function(e,i){if(e.tokenize==s)return t.Pass;if(e.tokenize!=o)return 0;var r=i&&i.charAt(0),a=e.lexical;if(!/^\s*else\b/.test(i))for(var l=e.cc.length-1;l>=0;--l){var u=e.cc[l];if(u==_)a=a.prev;else if(u!=G)break}"stat"==a.type&&"}"==r&&(a=a.prev),ve&&")"==a.type&&"stat"==a.prev.type&&(a=a.prev);var c=a.type,h=r==c;return"vardef"==c?a.indented+("operator"==e.lastType||","==e.lastType?a.info+1:0):"form"==c&&"{"==r?a.indented:"form"==c?a.indented+me:"stat"==c?a.indented+("operator"==e.lastType||","==e.lastType?ve||me:0):"switch"!=a.info||h||0==n.doubleIndentSwitch?a.align?a.column+(h?0:1):a.indented+(h?0:me):a.indented+(/^(?:case|default)\b/.test(i)?me:2*me)},electricInput:/^\s*(?:case .*?:|default:|\{|\})$/,blockCommentStart:_e?null:"/*",blockCommentEnd:_e?null:"*/",lineComment:_e?null:"//",fold:"brace",helperType:_e?"json":"javascript",jsonldMode:ye,jsonMode:_e}}),t.registerHelper("wordChars","javascript",/[\w$]/),t.defineMIME("text/javascript","javascript"),t.defineMIME("text/ecmascript","javascript"),t.defineMIME("application/javascript","javascript"),t.defineMIME("application/x-javascript","javascript"),t.defineMIME("application/ecmascript","javascript"),t.defineMIME("application/json",{name:"javascript",json:!0}),t.defineMIME("application/x-json",{name:"javascript",json:!0}),t.defineMIME("application/ld+json",{name:"javascript",jsonld:!0}),t.defineMIME("text/typescript",{name:"javascript",typescript:!0}),t.defineMIME("application/typescript",{name:"javascript",typescript:!0})}),function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";function e(t){for(var e={},n=0;n")?(t.match("-->"),e.tokenize=null):t.skipToEnd(),["comment","comment"]}t.defineMode("css",function(e,n){function i(t,e){return f=e,t}function r(t,e){var n=t.next();if(m[n]){var r=m[n](t,e);if(r!==!1)return r}return"@"==n?(t.eatWhile(/[\w\\\-]/),i("def",t.current())):"="==n||("~"==n||"|"==n)&&t.eat("=")?i(null,"compare"):'"'==n||"'"==n?(e.tokenize=o(n),e.tokenize(t,e)):"#"==n?(t.eatWhile(/[\w\\\-]/),i("atom","hash")):"!"==n?(t.match(/^\s*\w*/),i("keyword","important")):/\d/.test(n)||"."==n&&t.eat(/\d/)?(t.eatWhile(/[\w.%]/),i("number","unit")):"-"!==n?/[,+>*\/]/.test(n)?i(null,"select-op"):"."==n&&t.match(/^-?[_a-z][_a-z0-9-]*/i)?i("qualifier","qualifier"):/[:;{}\[\]\(\)]/.test(n)?i(null,n):"u"==n&&t.match("rl(")?(t.backUp(1),e.tokenize=a,i("property","word")):/[\w\\\-]/.test(n)?(t.eatWhile(/[\w\\\-]/),i("property","word")):i(null,null):/[\d.]/.test(t.peek())?(t.eatWhile(/[\w.%]/),i("number","unit")):t.match(/^\w+-/)?i("meta","meta"):void 0}function o(t){return function(e,n){for(var r,o=!1;null!=(r=e.next());){if(r==t&&!o){")"==t&&e.backUp(1);break}o=!o&&"\\"==r}return(r==t||!o&&")"!=t)&&(n.tokenize=null),i("string","string")}}function a(t,e){return t.next(),e.tokenize=t.match(/\s*[\"\')]/,!1)?null:o(")"),i(null,"(")}function s(t,e,n){this.type=t,this.indent=e,this.prev=n}function l(t,e,n){return t.context=new s(n,e.indentation()+g,t.context),n}function u(t){return t.context=t.context.prev,t.context.type}function c(t,e,n){return S[n.context.type](t,e,n)}function h(t,e,n,i){for(var r=i||1;r>0;r--)n.context=n.context.prev;return c(t,e,n)}function d(t){var e=t.current().toLowerCase();p=w.hasOwnProperty(e)?"atom":x.hasOwnProperty(e)?"keyword":"variable"}n.propertyKeywords||(n=t.resolveMode("text/css"));var f,p,g=e.indentUnit,m=n.tokenHooks,v=n.mediaTypes||{},y=n.mediaFeatures||{},_=n.propertyKeywords||{},b=n.nonStandardPropertyKeywords||{},x=n.colorKeywords||{},w=n.valueKeywords||{},k=n.fontProperties||{},C=n.allowNested,S={};return S.top=function(t,e,n){if("{"==t)return l(n,e,"block");if("}"==t&&n.context.prev)return u(n);if("@media"==t)return l(n,e,"media");if("@font-face"==t)return"font_face_before";if(/^@(-(moz|ms|o|webkit)-)?keyframes$/.test(t))return"keyframes";if(t&&"@"==t.charAt(0))return l(n,e,"at");if("hash"==t)p="builtin";else if("word"==t)p="tag";else{if("variable-definition"==t)return"maybeprop";if("interpolation"==t)return l(n,e,"interpolation");if(":"==t)return"pseudo";if(C&&"("==t)return l(n,e,"parens")}return n.context.type},S.block=function(t,e,n){if("word"==t){var i=e.current().toLowerCase();return _.hasOwnProperty(i)?(p="property","maybeprop"):b.hasOwnProperty(i)?(p="string-2","maybeprop"):C?(p=e.match(/^\s*:/,!1)?"property":"tag","block"):(p+=" error","maybeprop")}return"meta"==t?"block":C||"hash"!=t&&"qualifier"!=t?S.top(t,e,n):(p="error","block")},S.maybeprop=function(t,e,n){return":"==t?l(n,e,"prop"):c(t,e,n)},S.prop=function(t,e,n){if(";"==t)return u(n);if("{"==t&&C)return l(n,e,"propBlock");if("}"==t||"{"==t)return h(t,e,n);if("("==t)return l(n,e,"parens");if("hash"!=t||/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(e.current())){if("word"==t)d(e);else if("interpolation"==t)return l(n,e,"interpolation")}else p+=" error";return"prop"},S.propBlock=function(t,e,n){return"}"==t?u(n):"word"==t?(p="property","maybeprop"):n.context.type},S.parens=function(t,e,n){return"{"==t||"}"==t?h(t,e,n):")"==t?u(n):"("==t?l(n,e,"parens"):("word"==t&&d(e),"parens")},S.pseudo=function(t,e,n){return"word"==t?(p="variable-3",n.context.type):c(t,e,n)},S.media=function(t,e,n){if("("==t)return l(n,e,"media_parens");if("}"==t)return h(t,e,n);if("{"==t)return u(n)&&l(n,e,C?"block":"top");if("word"==t){var i=e.current().toLowerCase();p="only"==i||"not"==i||"and"==i?"keyword":v.hasOwnProperty(i)?"attribute":y.hasOwnProperty(i)?"property":"error"}return n.context.type},S.media_parens=function(t,e,n){return")"==t?u(n):"{"==t||"}"==t?h(t,e,n,2):S.media(t,e,n)},S.font_face_before=function(t,e,n){return"{"==t?l(n,e,"font_face"):c(t,e,n)},S.font_face=function(t,e,n){return"}"==t?u(n):"word"==t?(p=k.hasOwnProperty(e.current().toLowerCase())?"property":"error","maybeprop"):"font_face"},S.keyframes=function(t,e,n){return"word"==t?(p="variable","keyframes"):"{"==t?l(n,e,"top"):c(t,e,n)},S.at=function(t,e,n){return";"==t?u(n):"{"==t||"}"==t?h(t,e,n):("word"==t?p="tag":"hash"==t&&(p="builtin"),"at")},S.interpolation=function(t,e,n){return"}"==t?u(n):"{"==t||";"==t?h(t,e,n):("variable"!=t&&(p="error"),"interpolation")},{startState:function(t){return{tokenize:null,state:"top",context:new s("top",t||0,null)}},token:function(t,e){if(!e.tokenize&&t.eatSpace())return null;var n=(e.tokenize||r)(t,e);return n&&"object"==typeof n&&(f=n[1],n=n[0]),p=n,e.state=S[e.state](f,t,e),p},indent:function(t,e){var n=t.context,i=e&&e.charAt(0),r=n.indent;return"prop"!=n.type||"}"!=i&&")"!=i||(n=n.prev),!n.prev||("}"!=i||"block"!=n.type&&"top"!=n.type&&"interpolation"!=n.type&&"font_face"!=n.type)&&(")"!=i||"parens"!=n.type&&"media_parens"!=n.type)&&("{"!=i||"at"!=n.type&&"media"!=n.type)||(r=n.indent-g,n=n.prev),r},electricChars:"}",blockCommentStart:"/*",blockCommentEnd:"*/",fold:"brace"}});var r=["all","aural","braille","handheld","print","projection","screen","tty","tv","embossed"],o=e(r),a=["width","min-width","max-width","height","min-height","max-height","device-width","min-device-width","max-device-width","device-height","min-device-height","max-device-height","aspect-ratio","min-aspect-ratio","max-aspect-ratio","device-aspect-ratio","min-device-aspect-ratio","max-device-aspect-ratio","color","min-color","max-color","color-index","min-color-index","max-color-index","monochrome","min-monochrome","max-monochrome","resolution","min-resolution","max-resolution","scan","grid"],s=e(a),l=["align-content","align-items","align-self","alignment-adjust","alignment-baseline","anchor-point","animation","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-timing-function","appearance","azimuth","backface-visibility","background","background-attachment","background-clip","background-color","background-image","background-origin","background-position","background-repeat","background-size","baseline-shift","binding","bleed","bookmark-label","bookmark-level","bookmark-state","bookmark-target","border","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-decoration-break","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","clear","clip","color","color-profile","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","content","counter-increment","counter-reset","crop","cue","cue-after","cue-before","cursor","direction","display","dominant-baseline","drop-initial-after-adjust","drop-initial-after-align","drop-initial-before-adjust","drop-initial-before-align","drop-initial-size","drop-initial-value","elevation","empty-cells","fit","fit-position","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","float-offset","flow-from","flow-into","font","font-feature-settings","font-family","font-kerning","font-language-override","font-size","font-size-adjust","font-stretch","font-style","font-synthesis","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-ligatures","font-variant-numeric","font-variant-position","font-weight","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-position","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphens","icon","image-orientation","image-rendering","image-resolution","inline-box-align","justify-content","left","letter-spacing","line-break","line-height","line-stacking","line-stacking-ruby","line-stacking-shift","line-stacking-strategy","list-style","list-style-image","list-style-position","list-style-type","margin","margin-bottom","margin-left","margin-right","margin-top","marker-offset","marks","marquee-direction","marquee-loop","marquee-play-count","marquee-speed","marquee-style","max-height","max-width","min-height","min-width","move-to","nav-down","nav-index","nav-left","nav-right","nav-up","object-fit","object-position","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-style","overflow-wrap","overflow-x","overflow-y","padding","padding-bottom","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","page-policy","pause","pause-after","pause-before","perspective","perspective-origin","pitch","pitch-range","play-during","position","presentation-level","punctuation-trim","quotes","region-break-after","region-break-before","region-break-inside","region-fragment","rendering-intent","resize","rest","rest-after","rest-before","richness","right","rotation","rotation-point","ruby-align","ruby-overhang","ruby-position","ruby-span","shape-image-threshold","shape-inside","shape-margin","shape-outside","size","speak","speak-as","speak-header","speak-numeral","speak-punctuation","speech-rate","stress","string-set","tab-size","table-layout","target","target-name","target-new","target-position","text-align","text-align-last","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-style","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-height","text-indent","text-justify","text-outline","text-overflow","text-shadow","text-size-adjust","text-space-collapse","text-transform","text-underline-position","text-wrap","top","transform","transform-origin","transform-style","transition","transition-delay","transition-duration","transition-property","transition-timing-function","unicode-bidi","vertical-align","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","volume","white-space","widows","width","word-break","word-spacing","word-wrap","z-index","clip-path","clip-rule","mask","enable-background","filter","flood-color","flood-opacity","lighting-color","stop-color","stop-opacity","pointer-events","color-interpolation","color-interpolation-filters","color-rendering","fill","fill-opacity","fill-rule","image-rendering","marker","marker-end","marker-mid","marker-start","shape-rendering","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","text-rendering","baseline-shift","dominant-baseline","glyph-orientation-horizontal","glyph-orientation-vertical","text-anchor","writing-mode"],u=e(l),c=["scrollbar-arrow-color","scrollbar-base-color","scrollbar-dark-shadow-color","scrollbar-face-color","scrollbar-highlight-color","scrollbar-shadow-color","scrollbar-3d-light-color","scrollbar-track-color","shape-inside","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","zoom"],h=e(c),d=["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen"],f=e(d),p=["above","absolute","activeborder","activecaption","afar","after-white-space","ahead","alias","all","all-scroll","alternate","always","amharic","amharic-abegede","antialiased","appworkspace","arabic-indic","armenian","asterisks","auto","avoid","avoid-column","avoid-page","avoid-region","background","backwards","baseline","below","bidi-override","binary","bengali","blink","block","block-axis","bold","bolder","border","border-box","both","bottom","break","break-all","break-word","button","button-bevel","buttonface","buttonhighlight","buttonshadow","buttontext","cambodian","capitalize","caps-lock-indicator","caption","captiontext","caret","cell","center","checkbox","circle","cjk-earthly-branch","cjk-heavenly-stem","cjk-ideographic","clear","clip","close-quote","col-resize","collapse","column","compact","condensed","contain","content","content-box","context-menu","continuous","copy","cover","crop","cross","crosshair","currentcolor","cursive","dashed","decimal","decimal-leading-zero","default","default-button","destination-atop","destination-in","destination-out","destination-over","devanagari","disc","discard","document","dot-dash","dot-dot-dash","dotted","double","down","e-resize","ease","ease-in","ease-in-out","ease-out","element","ellipse","ellipsis","embed","end","ethiopic","ethiopic-abegede","ethiopic-abegede-am-et","ethiopic-abegede-gez","ethiopic-abegede-ti-er","ethiopic-abegede-ti-et","ethiopic-halehame-aa-er","ethiopic-halehame-aa-et","ethiopic-halehame-am-et","ethiopic-halehame-gez","ethiopic-halehame-om-et","ethiopic-halehame-sid-et","ethiopic-halehame-so-et","ethiopic-halehame-ti-er","ethiopic-halehame-ti-et","ethiopic-halehame-tig","ew-resize","expanded","extra-condensed","extra-expanded","fantasy","fast","fill","fixed","flat","footnotes","forwards","from","geometricPrecision","georgian","graytext","groove","gujarati","gurmukhi","hand","hangul","hangul-consonant","hebrew","help","hidden","hide","higher","highlight","highlighttext","hiragana","hiragana-iroha","horizontal","hsl","hsla","icon","ignore","inactiveborder","inactivecaption","inactivecaptiontext","infinite","infobackground","infotext","inherit","initial","inline","inline-axis","inline-block","inline-table","inset","inside","intrinsic","invert","italic","justify","kannada","katakana","katakana-iroha","keep-all","khmer","landscape","lao","large","larger","left","level","lighter","line-through","linear","lines","list-item","listbox","listitem","local","logical","loud","lower","lower-alpha","lower-armenian","lower-greek","lower-hexadecimal","lower-latin","lower-norwegian","lower-roman","lowercase","ltr","malayalam","match","media-controls-background","media-current-time-display","media-fullscreen-button","media-mute-button","media-play-button","media-return-to-realtime-button","media-rewind-button","media-seek-back-button","media-seek-forward-button","media-slider","media-sliderthumb","media-time-remaining-display","media-volume-slider","media-volume-slider-container","media-volume-sliderthumb","medium","menu","menulist","menulist-button","menulist-text","menulist-textfield","menutext","message-box","middle","min-intrinsic","mix","mongolian","monospace","move","multiple","myanmar","n-resize","narrower","ne-resize","nesw-resize","no-close-quote","no-drop","no-open-quote","no-repeat","none","normal","not-allowed","nowrap","ns-resize","nw-resize","nwse-resize","oblique","octal","open-quote","optimizeLegibility","optimizeSpeed","oriya","oromo","outset","outside","outside-shape","overlay","overline","padding","padding-box","painted","page","paused","persian","plus-darker","plus-lighter","pointer","polygon","portrait","pre","pre-line","pre-wrap","preserve-3d","progress","push-button","radio","read-only","read-write","read-write-plaintext-only","rectangle","region","relative","repeat","repeat-x","repeat-y","reset","reverse","rgb","rgba","ridge","right","round","row-resize","rtl","run-in","running","s-resize","sans-serif","scroll","scrollbar","se-resize","searchfield","searchfield-cancel-button","searchfield-decoration","searchfield-results-button","searchfield-results-decoration","semi-condensed","semi-expanded","separate","serif","show","sidama","single","skip-white-space","slide","slider-horizontal","slider-vertical","sliderthumb-horizontal","sliderthumb-vertical","slow","small","small-caps","small-caption","smaller","solid","somali","source-atop","source-in","source-out","source-over","space","square","square-button","start","static","status-bar","stretch","stroke","sub","subpixel-antialiased","super","sw-resize","table","table-caption","table-cell","table-column","table-column-group","table-footer-group","table-header-group","table-row","table-row-group","telugu","text","text-bottom","text-top","textarea","textfield","thai","thick","thin","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","tibetan","tigre","tigrinya-er","tigrinya-er-abegede","tigrinya-et","tigrinya-et-abegede","to","top","transparent","ultra-condensed","ultra-expanded","underline","up","upper-alpha","upper-armenian","upper-greek","upper-hexadecimal","upper-latin","upper-norwegian","upper-roman","uppercase","urdu","url","vertical","vertical-text","visible","visibleFill","visiblePainted","visibleStroke","visual","w-resize","wait","wave","wider","window","windowframe","windowtext","x-large","x-small","xor","xx-large","xx-small"],g=e(p),m=["font-family","src","unicode-range","font-variant","font-feature-settings","font-stretch","font-weight","font-style"],v=e(m),y=r.concat(a).concat(l).concat(c).concat(d).concat(p); t.registerHelper("hintWords","css",y),t.defineMIME("text/css",{mediaTypes:o,mediaFeatures:s,propertyKeywords:u,nonStandardPropertyKeywords:h,colorKeywords:f,valueKeywords:g,fontProperties:v,tokenHooks:{"<":function(t,e){return t.match("!--")?(e.tokenize=i,i(t,e)):!1},"/":function(t,e){return t.eat("*")?(e.tokenize=n,n(t,e)):!1}},name:"css"}),t.defineMIME("text/x-scss",{mediaTypes:o,mediaFeatures:s,propertyKeywords:u,nonStandardPropertyKeywords:h,colorKeywords:f,valueKeywords:g,fontProperties:v,allowNested:!0,tokenHooks:{"/":function(t,e){return t.eat("/")?(t.skipToEnd(),["comment","comment"]):t.eat("*")?(e.tokenize=n,n(t,e)):["operator","operator"]},":":function(t){return t.match(/\s*\{/)?[null,"{"]:!1},$:function(t){return t.match(/^[\w-]+/),t.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"]},"#":function(t){return t.eat("{")?[null,"interpolation"]:!1}},name:"css",helperType:"scss"}),t.defineMIME("text/x-less",{mediaTypes:o,mediaFeatures:s,propertyKeywords:u,nonStandardPropertyKeywords:h,colorKeywords:f,valueKeywords:g,fontProperties:v,allowNested:!0,tokenHooks:{"/":function(t,e){return t.eat("/")?(t.skipToEnd(),["comment","comment"]):t.eat("*")?(e.tokenize=n,n(t,e)):["operator","operator"]},"@":function(t){return t.match(/^(charset|document|font-face|import|(-(moz|ms|o|webkit)-)?keyframes|media|namespace|page|supports)\b/,!1)?!1:(t.eatWhile(/[\w\\\-]/),t.match(/^\s*:/,!1)?["variable-2","variable-definition"]:["variable-2","variable"])},"&":function(){return["atom","atom"]}},name:"css",helperType:"less"})}),function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("../xml/xml"),require("../javascript/javascript"),require("../css/css")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../javascript/javascript","../css/css"],t):t(CodeMirror)}(function(t){"use strict";t.defineMode("htmlmixed",function(e,n){function i(t,e){var n=e.htmlState.tagName;n&&(n=n.toLowerCase());var i=s.token(t,e.htmlState);if("script"==n&&/\btag\b/.test(i)&&">"==t.current()){var r=t.string.slice(Math.max(0,t.pos-100),t.pos).match(/\btype\s*=\s*("[^"]+"|'[^']+'|\S+)[^<]*$/i);r=r?r[1]:"",r&&/[\"\']/.test(r.charAt(0))&&(r=r.slice(1,r.length-1));for(var c=0;c"==t.current()&&(e.token=a,e.localMode=l,e.localState=l.startState(s.indent(e.htmlState,"")));return i}function r(t,e,n){var i,r=t.current(),o=r.search(e);return o>-1?t.backUp(r.length-o):(i=r.match(/<\/?$/))&&(t.backUp(r.length),t.match(e,!1)||t.match(r)),n}function o(t,e){return t.match(/^<\/\s*script\s*>/i,!1)?(e.token=i,e.localState=e.localMode=null,i(t,e)):r(t,/<\/\s*script\s*>/,e.localMode.token(t,e.localState))}function a(t,e){return t.match(/^<\/\s*style\s*>/i,!1)?(e.token=i,e.localState=e.localMode=null,i(t,e)):r(t,/<\/\s*style\s*>/,l.token(t,e.localState))}var s=t.getMode(e,{name:"xml",htmlMode:!0,multilineTagIndentFactor:n.multilineTagIndentFactor,multilineTagIndentPastTag:n.multilineTagIndentPastTag}),l=t.getMode(e,"css"),u=[],c=n&&n.scriptTypes;if(u.push({matches:/^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^$/i,mode:t.getMode(e,"javascript")}),c)for(var h=0;h=0?(e.indentationDiff<4&&(e.indentation-=e.indentationDiff),e.list=null):e.list!==!1&&e.indentation>0?(e.list=null,e.listDepth=Math.floor(e.indentation/4)):e.list!==!1&&(e.list=!1,e.listDepth=0);var s=null;if(e.indentationDiff>=4)return e.indentation-=4,t.skipToEnd(),S;if(t.eatSpace())return null;if(s=t.match(j))return e.header=s[0].length<=6?s[0].length:6,n.highlightFormatting&&(e.formatting="header"),e.f=e.inline,u(e);if(e.prevLineHasContent&&(s=t.match(U)))return e.header="="==s[0].charAt(0)?1:2,n.highlightFormatting&&(e.formatting="header"),e.f=e.inline,u(e);if(t.eat(">"))return e.indentation++,e.quote=o?1:e.quote+1,n.highlightFormatting&&(e.formatting="quote"),t.eatSpace(),u(e);if("["===t.peek())return i(t,e,g);if(t.match(H,!0))return N;if((!e.prevLineHasContent||a)&&(t.match(V,!1)||t.match(z,!1))){var c=null;return t.match(V,!0)?c="ul":(t.match(z,!0),c="ol"),e.indentation+=4,e.list=!0,e.listDepth++,n.taskLists&&t.match(F,!1)&&(e.taskList=!0),e.f=e.inline,n.highlightFormatting&&(e.formatting=["list","list-"+c]),u(e)}return n.fencedCodeBlocks&&t.match(/^```([\w+#]*)/,!0)?(e.localMode=w(RegExp.$1),e.localMode&&(e.localState=e.localMode.startState()),r(t,e,l),n.highlightFormatting&&(e.formatting="code-block"),e.code=!0,u(e)):i(t,e,e.inline)}function s(t,e){var n=b.token(t,e.htmlState);return(_&&null===e.htmlState.tagStart&&!e.htmlState.context||e.md_inside&&t.current().indexOf(">")>-1)&&(e.f=h,e.block=a,e.htmlState=null),n}function l(t,e){if(t.sol()&&t.match(/^```/,!0)){e.localMode=e.localState=null,e.f=h,e.block=a,n.highlightFormatting&&(e.formatting="code-block"),e.code=!0;var i=u(e);return e.code=!1,i}return e.localMode?e.localMode.token(t,e.localState):(t.skipToEnd(),S)}function u(t){var e=[];if(t.formatting){e.push(A),"string"==typeof t.formatting&&(t.formatting=[t.formatting]);for(var i=0;i=t.quote?A+"-"+t.formatting[i]+"-"+t.quote:"error")}if(t.taskOpen)return e.push("meta"),e.length?e.join(" "):null;if(t.taskClosed)return e.push("property"),e.length?e.join(" "):null;if(t.linkHref)return e.push(B),e.length?e.join(" "):null;if(t.strong&&e.push(W),t.em&&e.push(R),t.linkText&&e.push(I),t.code&&e.push(S),t.header&&(e.push(C),e.push(C+"-"+t.header)),t.quote&&(e.push(T),e.push(!n.maxBlockquoteDepth||n.maxBlockquoteDepth>=t.quote?T+"-"+t.quote:T+"-"+n.maxBlockquoteDepth)),t.list!==!1){var r=(t.listDepth-1)%3;e.push(r?1===r?L:E:M)}return t.trailingSpaceNewLine?e.push("trailing-space-new-line"):t.trailingSpace&&e.push("trailing-space-"+(t.trailingSpace%2?"a":"b")),e.length?e.join(" "):null}function c(t,e){return t.match(K,!0)?u(e):void 0}function h(e,i){var o=i.text(e,i);if("undefined"!=typeof o)return o;if(i.list)return i.list=null,u(i);if(i.taskList){var a="x"!==e.match(F,!0)[1];return a?i.taskOpen=!0:i.taskClosed=!0,n.highlightFormatting&&(i.formatting="task"),i.taskList=!1,u(i)}if(i.taskOpen=!1,i.taskClosed=!1,i.header&&e.match(/^#+$/,!0))return n.highlightFormatting&&(i.formatting="header"),u(i);var l=e.sol(),c=e.next();if("\\"===c&&(e.next(),n.highlightFormatting)){var h=u(i);return h?h+" formatting-escape":"formatting-escape"}if(i.linkTitle){i.linkTitle=!1;var p=c;"("===c&&(p=")"),p=(p+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1");var g="^\\s*(?:[^"+p+"\\\\]+|\\\\\\\\|\\\\.)"+p;if(e.match(new RegExp(g),!0))return B}if("`"===c){var m=i.formatting;n.highlightFormatting&&(i.formatting="code");var v=u(i),y=e.pos;e.eatWhile("`");var _=1+e.pos-y;return i.code?_===k?(i.code=!1,v):(i.formatting=m,u(i)):(k=_,i.code=!0,u(i))}if(i.code)return u(i);if("!"===c&&e.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return e.match(/\[[^\]]*\]/),i.inline=i.f=f,P;if("["===c&&e.match(/.*\](\(| ?\[)/,!1))return i.linkText=!0,n.highlightFormatting&&(i.formatting="link"),u(i);if("]"===c&&i.linkText){n.highlightFormatting&&(i.formatting="link");var h=u(i);return i.linkText=!1,i.inline=i.f=f,h}if("<"===c&&e.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){i.f=i.inline=d,n.highlightFormatting&&(i.formatting="link");var h=u(i);return h?h+=" ":h="",h+O}if("<"===c&&e.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){i.f=i.inline=d,n.highlightFormatting&&(i.formatting="link");var h=u(i);return h?h+=" ":h="",h+D}if("<"===c&&e.match(/^\w/,!1)){if(-1!=e.string.indexOf(">")){var x=e.string.substring(1,e.string.indexOf(">"));/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(x)&&(i.md_inside=!0)}return e.backUp(1),i.htmlState=t.startState(b),r(e,i,s)}if("<"===c&&e.match(/^\/\w*?>/))return i.md_inside=!1,"tag";var w=!1;if(!n.underscoresBreakWords&&"_"===c&&"_"!==e.peek()&&e.match(/(\w)/,!1)){var C=e.pos-2;if(C>=0){var S=e.string.charAt(C);"_"!==S&&S.match(/(\w)/,!1)&&(w=!0)}}if("*"===c||"_"===c&&!w)if(l&&" "===e.peek());else{if(i.strong===c&&e.eat(c)){n.highlightFormatting&&(i.formatting="strong");var v=u(i);return i.strong=!1,v}if(!i.strong&&e.eat(c))return i.strong=c,n.highlightFormatting&&(i.formatting="strong"),u(i);if(i.em===c){n.highlightFormatting&&(i.formatting="em");var v=u(i);return i.em=!1,v}if(!i.em)return i.em=c,n.highlightFormatting&&(i.formatting="em"),u(i)}else if(" "===c&&(e.eat("*")||e.eat("_"))){if(" "===e.peek())return u(i);e.backUp(1)}return" "===c&&(e.match(/ +$/,!1)?i.trailingSpace++:i.trailingSpace&&(i.trailingSpaceNewLine=!0)),u(i)}function d(t,e){var i=t.next();if(">"===i){e.f=e.inline=h,n.highlightFormatting&&(e.formatting="link");var r=u(e);return r?r+=" ":r="",r+O}return t.match(/^[^>]+/,!0),O}function f(t,e){if(t.eatSpace())return null;var i=t.next();return"("===i||"["===i?(e.f=e.inline=p("("===i?")":"]"),n.highlightFormatting&&(e.formatting="link-string"),e.linkHref=!0,u(e)):"error"}function p(t){return function(e,i){var r=e.next();if(r===t){i.f=i.inline=h,n.highlightFormatting&&(i.formatting="link-string");var o=u(i);return i.linkHref=!1,o}return e.match(y(t),!0)&&e.backUp(1),i.linkHref=!0,u(i)}}function g(t,e){return t.match(/^[^\]]*\]:/,!1)?(e.f=m,t.next(),n.highlightFormatting&&(e.formatting="link"),e.linkText=!0,u(e)):i(t,e,h)}function m(t,e){if(t.match(/^\]:/,!0)){e.f=e.inline=v,n.highlightFormatting&&(e.formatting="link");var i=u(e);return e.linkText=!1,i}return t.match(/^[^\]]+/,!0),I}function v(t,e){return t.eatSpace()?null:(t.match(/^[^\s]+/,!0),void 0===t.peek()?e.linkTitle=!0:t.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),e.f=e.inline=h,B)}function y(t){return q[t]||(t=(t+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),q[t]=new RegExp("^(?:[^\\\\]|\\\\.)*?("+t+")")),q[t]}var _=t.modes.hasOwnProperty("xml"),b=t.getMode(e,_?{name:"xml",htmlMode:!0}:"text/plain"),x={html:"htmlmixed",js:"javascript",json:"application/json",c:"text/x-csrc","c++":"text/x-c++src",java:"text/x-java",csharp:"text/x-csharp","c#":"text/x-csharp",scala:"text/x-scala"},w=function(){var n,i,r={},o={},a=[];for(var s in t.modes)t.modes.propertyIsEnumerable(s)&&a.push(s);for(n=0;n` "'(]+/,q=[],$={startState:function(){return{f:a,prevLineHasContent:!1,thisLineHasContent:!1,block:a,htmlState:null,indentation:0,inline:h,text:c,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,em:!1,strong:!1,header:0,taskList:!1,list:!1,listDepth:0,quote:0,trailingSpace:0,trailingSpaceNewLine:!1}},copyState:function(e){return{f:e.f,prevLineHasContent:e.prevLineHasContent,thisLineHasContent:e.thisLineHasContent,block:e.block,htmlState:e.htmlState&&t.copyState(b,e.htmlState),indentation:e.indentation,localMode:e.localMode,localState:e.localMode?t.copyState(e.localMode,e.localState):null,inline:e.inline,text:e.text,formatting:!1,linkTitle:e.linkTitle,em:e.em,strong:e.strong,header:e.header,taskList:e.taskList,list:e.list,listDepth:e.listDepth,quote:e.quote,trailingSpace:e.trailingSpace,trailingSpaceNewLine:e.trailingSpaceNewLine,md_inside:e.md_inside}},token:function(t,e){if(e.formatting=!1,t.sol()){var n=!!e.header;if(e.header=0,t.match(/^\s*$/,!0)||n)return e.prevLineHasContent=!1,o(e),n?this.token(t,e):null;e.prevLineHasContent=e.thisLineHasContent,e.thisLineHasContent=!0,e.taskList=!1,e.code=!1,e.trailingSpace=0,e.trailingSpaceNewLine=!1,e.f=e.block;var i=t.match(/^\s*/,!0)[0].replace(/\t/g," ").length,r=4*Math.floor((i-e.indentation)/4);r>4&&(r=4);var a=e.indentation+r;if(e.indentationDiff=a-e.indentation,e.indentation=a,i>0)return null}var s=e.f(t,e);return t.start==t.pos?this.token(t,e):s},innerMode:function(t){return t.block==s?{state:t.htmlState,mode:b}:t.localState?{state:t.localState,mode:t.localMode}:{state:t,mode:$}},blankLine:o,getType:u,fold:"markdown"};return $},"xml"),t.defineMIME("text/x-markdown","markdown")}),function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror")):"function"==typeof define&&define.amd?define(["../../lib/codemirror"],t):t(CodeMirror)}(function(t){"use strict";t.overlayMode=function(e,n,i){return{startState:function(){return{base:t.startState(e),overlay:t.startState(n),basePos:0,baseCur:null,overlayPos:0,overlayCur:null,lineSeen:null}},copyState:function(i){return{base:t.copyState(e,i.base),overlay:t.copyState(n,i.overlay),basePos:i.basePos,baseCur:null,overlayPos:i.overlayPos,overlayCur:null}},token:function(t,r){return(t.sol()||t.string!=r.lineSeen||Math.min(r.basePos,r.overlayPos)]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i)&&"]("!=t.string.slice(t.start-2,t.start)?(e.combineTokens=!0,"link"):(t.next(),null)},blankLine:i},a={underscoresBreakWords:!1,taskLists:!0,fencedCodeBlocks:!0};for(var s in n)a[s]=n[s];return a.name="markdown",t.defineMIME("gfmBase",a),t.overlayMode(t.getMode(e,"gfmBase"),o)},"markdown")}),function(){function use(t){_p.r([moduleMapping[t]])}var _p={r:function(t){if(_p[t].inited)return _p[t].value;if("function"!=typeof _p[t].value)return _p[t].inited=!0,_p[t].value;var e={exports:{}},n=_p[t].value(null,e.exports,e);if(_p[t].inited=!0,_p[t].value=n,void 0!==n)return n;for(var i in e.exports)if(e.exports.hasOwnProperty(i))return _p[t].inited=!0,_p[t].value=e.exports,e.exports}};_p[0]={value:function(){function t(t){var e=parseFloat(t,10);return/ms/.test(t)?e:/s/.test(t)?1e3*e:/min/.test(t)?60*e*1e3:e}var e=_p.r(8),n=_p.r(1),i=_p.r(11).createClass("Animator",{constructor:function(t,e,n){if(1==arguments.length){var i=arguments[0];this.beginValue=i.beginValue,this.finishValue=i.finishValue,this.setter=i.setter}else this.beginValue=t,this.finishValue=e,this.setter=n},start:function(e,n,i,r,o){2===arguments.length&&"object"==typeof n&&(i=n.easing,r=n.delay,o=n.callback,n=n.duration),4===arguments.length&&"function"==typeof r&&(o=r,r=0);var a=this.create(e,n,i,o);return r=t(r),r>0?setTimeout(function(){a.play()},r):a.play(),a},create:function(r,o,a,s){var l;return o=o&&t(o)||i.DEFAULT_DURATION,a=a||i.DEFAULT_EASING,"string"==typeof a&&(a=n[a]),l=new e(this,r,o,a),"function"==typeof s&&l.on("finish",s),l},reverse:function(){return new i(this.finishValue,this.beginValue,this.setter)}});i.DEFAULT_DURATION=300,i.DEFAULT_EASING="linear";var r=_p.r(60);return _p.r(11).extendClass(r,{animate:function(t,e,n,i,r){function o(){a.shift(),a.length&&setTimeout(a[0].t.play.bind(a[0].t),a[0].d)}var a=this._KityAnimateQueue=this._KityAnimateQueue||[],s=t.create(this,e,n,r);return s.on("finish",o),a.push({t:s,d:i}),1==a.length&&setTimeout(s.play.bind(s),i),this},timeline:function(){return this._KityAnimateQueue[0].t},stop:function(){var t=this._KityAnimateQueue;if(t)for(;t.length;)t.shift().t.stop();return this}}),i}},_p[1]={value:function(){var t={linear:function(t,e,n,i){return n*(t/i)+e},swing:function(e,n,i,r){return t.easeOutQuad(e,n,i,r)},ease:function(e,n,i,r){return t.easeInOutCubic(e,n,i,r)},easeInQuad:function(t,e,n,i){return n*(t/=i)*t+e},easeOutQuad:function(t,e,n,i){return-n*(t/=i)*(t-2)+e},easeInOutQuad:function(t,e,n,i){return(t/=i/2)<1?n/2*t*t+e:-n/2*(--t*(t-2)-1)+e},easeInCubic:function(t,e,n,i){return n*(t/=i)*t*t+e},easeOutCubic:function(t,e,n,i){return n*((t=t/i-1)*t*t+1)+e},easeInOutCubic:function(t,e,n,i){return(t/=i/2)<1?n/2*t*t*t+e:n/2*((t-=2)*t*t+2)+e},easeInQuart:function(t,e,n,i){return n*(t/=i)*t*t*t+e},easeOutQuart:function(t,e,n,i){return-n*((t=t/i-1)*t*t*t-1)+e},easeInOutQuart:function(t,e,n,i){return(t/=i/2)<1?n/2*t*t*t*t+e:-n/2*((t-=2)*t*t*t-2)+e},easeInQuint:function(t,e,n,i){return n*(t/=i)*t*t*t*t+e},easeOutQuint:function(t,e,n,i){return n*((t=t/i-1)*t*t*t*t+1)+e},easeInOutQuint:function(t,e,n,i){return(t/=i/2)<1?n/2*t*t*t*t*t+e:n/2*((t-=2)*t*t*t*t+2)+e},easeInSine:function(t,e,n,i){return-n*Math.cos(t/i*(Math.PI/2))+n+e},easeOutSine:function(t,e,n,i){return n*Math.sin(t/i*(Math.PI/2))+e},easeInOutSine:function(t,e,n,i){return-n/2*(Math.cos(Math.PI*t/i)-1)+e},easeInExpo:function(t,e,n,i){return 0===t?e:n*Math.pow(2,10*(t/i-1))+e},easeOutExpo:function(t,e,n,i){return t==i?e+n:n*(-Math.pow(2,-10*t/i)+1)+e},easeInOutExpo:function(t,e,n,i){return 0===t?e:t==i?e+n:(t/=i/2)<1?n/2*Math.pow(2,10*(t-1))+e:n/2*(-Math.pow(2,-10*--t)+2)+e},easeInCirc:function(t,e,n,i){return-n*(Math.sqrt(1-(t/=i)*t)-1)+e},easeOutCirc:function(t,e,n,i){return n*Math.sqrt(1-(t=t/i-1)*t)+e},easeInOutCirc:function(t,e,n,i){return(t/=i/2)<1?-n/2*(Math.sqrt(1-t*t)-1)+e:n/2*(Math.sqrt(1-(t-=2)*t)+1)+e},easeInElastic:function(t,e,n,i){var r=1.70158,o=0,a=n;return 0===t?e:1==(t/=i)?e+n:(o||(o=.3*i),at?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(t*i-r)*Math.PI/o)+e:a*Math.pow(2,-10*(t-=1))*Math.sin(2*(t*i-r)*Math.PI/o)*.5+n+e},easeInBack:function(t,e,n,i,r){return void 0==r&&(r=1.70158),n*(t/=i)*t*((r+1)*t-r)+e},easeOutBack:function(t,e,n,i,r){return void 0==r&&(r=1.70158),n*((t=t/i-1)*t*((r+1)*t+r)+1)+e},easeInOutBack:function(t,e,n,i,r){return void 0==r&&(r=1.70158),(t/=i/2)<1?n/2*t*t*(((r*=1.525)+1)*t-r)+e:n/2*((t-=2)*t*(((r*=1.525)+1)*t+r)+2)+e},easeInBounce:function(e,n,i,r){return i-t.easeOutBounce(r-e,0,i,r)+n},easeOutBounce:function(t,e,n,i){return(t/=i)<1/2.75?7.5625*n*t*t+e:2/2.75>t?n*(7.5625*(t-=1.5/2.75)*t+.75)+e:2.5/2.75>t?n*(7.5625*(t-=2.25/2.75)*t+.9375)+e:n*(7.5625*(t-=2.625/2.75)*t+.984375)+e},easeInOutBounce:function(e,n,i,r){return r/2>e?.5*t.easeInBounce(2*e,0,i,r)+n:.5*t.easeOutBounce(2*e-r,0,i,r)+.5*i+n}};return t}},_p[2]={value:function(t,e){function n(t){1===h.push(t)&&(l=u(i))}function i(){var t=h;for(h=[];t.length;)s(t.pop());l=0}function r(t){var e=a(t);return n(e),e}function o(t){var e=h.indexOf(t);~e&&h.splice(e,1),0===h.length&&c(l)}function a(t){var e={index:0,time:+new Date,elapsed:0,action:t,next:function(){n(e)}};return e}function s(t){var e=+new Date,n=e-t.time;n>200&&(n=1e3/60),t.dur=n,t.elapsed+=n,t.time=e,t.action.call(null,t),t.index++}var l,u=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||function(t){return setTimeout(t,1e3/60)},c=window.cancelAnimationFrame||window.mozCancelAnimationFrame||window.webkitCancelAnimationFrame||window.msCancelAnimationFrame||window.clearTimeout,h=[];e.requestFrame=r,e.releaseFrame=o}},_p[3]={value:function(){var t=_p.r(0),e=_p.r(34),n=_p.r(46),i=_p.r(60),r=_p.r(11).createClass("MotionAnimator",{base:t,constructor:function(t,i){var r=this;this.callBase({beginValue:0,finishValue:1,setter:function(t,i){var o=r.motionPath instanceof n?r.motionPath.getPathData():r.motionPath,a=e.pointAtPath(o,i);t.setTranslate(a.x,a.y),this.doRotate&&t.setRotate(a.tan.getAngle())}}),this.doRotate=i,this.motionPath=t}});return _p.r(11).extendClass(i,{motion:function(t,e,n,i,o){return this.animate(new r(t),e,n,i,o)}}),r}},_p[4]={value:function(){var t=_p.r(0),e=_p.r(11).createClass("OpacityAnimator",{base:t,constructor:function(t){this.callBase({beginValue:function(t){return t.getOpacity()},finishValue:t,setter:function(t,e){t.setOpacity(e)}})}}),n=_p.r(60);return _p.r(11).extendClass(n,{fxOpacity:function(t,n,i,r,o){return this.animate(new e(t),n,i,r,o)},fadeTo:function(){return this.fxOpacity.apply(this,arguments)},fadeIn:function(){return this.fxOpacity.apply(this,[1].concat([].slice.call(arguments)))},fadeOut:function(){return this.fxOpacity.apply(this,[0].concat([].slice.call(arguments)))}}),e}},_p[5]={value:function(){var t=_p.r(0),e=_p.r(34),n=_p.r(11).createClass("OpacityAnimator",{base:t,constructor:function(t){this.callBase({beginValue:function(t){return this.beginPath=t.getPathData(),0},finishValue:1,setter:function(n,i){n.setPathData(e.pathTween(this.beginPath,t,i))}})}}),i=_p.r(46);return _p.r(11).extendClass(i,{fxPath:function(t,e,i,r,o){return this.animate(new n(t),e,i,r,o)}}),n}},_p[6]={value:function(){var t=_p.r(0),e=_p.r(11).createClass("RotateAnimator",{base:t,constructor:function(t){this.callBase({beginValue:0,finishValue:t,setter:function(t,e,n){var i=n.getDelta();t.rotate(i,ax,ay)}})}}),n=_p.r(60);return _p.r(11).extendClass(n,{fxRotate:function(t,n,i,r,o){return this.animate(new e(t),n,i,r,o)}}),e}},_p[7]={value:function(){var t=_p.r(0),e=_p.r(11).createClass("ScaleAnimator",{base:t,constructor:function(t,e){this.callBase({beginValue:0,finishValue:1,setter:function(n,i,r){var o=r.getDelta(),a=Math.pow(t,o),s=Math.pow(e,o);n.scale(s,a)}})}}),n=_p.r(60);return _p.r(11).extendClass(n,{fxScale:function(t,n,i,r,o,a){return this.animate(new e(t,n),i,r,o,a)}}),e}},_p[8]={value:function(){function t(t,e,n){return r.paralle(t,e,function(t,e){return t+(e-t)*n})}function e(t,e){return r.paralle(t,e,function(t,e){return e-t})}function n(t,e,n){this.timeline=t,this.target=t.target,this.type=e;for(var i in n)n.hasOwnProperty(i)&&(this[i]=n[i])}var i=_p.r(33),r=_p.r(12),o=_p.r(2),a=_p.r(11).createClass("Timeline",{mixins:[i],constructor:function(t,e,n,i){this.callMixin(),this.target=e,this.time=0,this.duration=n,this.easing=i,this.animator=t,this.beginValue=t.beginValue,this.finishValue=t.finishValue,this.setter=t.setter,this.status="ready"},nextFrame:function(t){"playing"==this.status&&(this.time+=t.dur,this.setValue(this.getValue()),this.time>=this.duration&&this.timeUp(),t.next())},getPlayTime:function(){return this.rollbacking?this.duration-this.time:this.time},getTimeProportion:function(){return this.getPlayTime()/this.duration},getValueProportion:function(){return this.easing(this.getPlayTime(),0,1,this.duration)},getValue:function(){var e=this.beginValue,n=this.finishValue,i=this.getValueProportion();return t(e,n,i)},setValue:function(t){this.lastValue=this.currentValue,this.currentValue=t,this.setter.call(this.target,this.target,t,this)},getDelta:function(){return this.lastValue=void 0===this.lastValue?this.beginValue:this.lastValue,e(this.lastValue,this.currentValue)},play:function(){var t=this.status;switch(this.status="playing",t){case"ready":r.isFunction(this.beginValue)&&(this.beginValue=this.beginValue.call(this.target,this.target)),r.isFunction(this.finishValue)&&(this.finishValue=this.finishValue.call(this.target,this.target)),this.time=0,this.setValue(this.beginValue),this.frame=o.requestFrame(this.nextFrame.bind(this));break;case"finished":case"stoped":this.time=0,this.frame=o.requestFrame(this.nextFrame.bind(this));break;case"paused":this.frame.next()}return this.fire("play",new n(this,"play",{lastStatus:t})),this},pause:function(){return this.status="paused",this.fire("pause",new n(this,"pause")),o.releaseFrame(this.frame),this},stop:function(){return this.status="stoped",this.setValue(this.finishValue),this.rollbacking=!1,this.fire("stop",new n(this,"stop")),o.releaseFrame(this.frame),this},timeUp:function(){this.repeatOption?(this.time=0,this.rollback?this.rollbacking?(this.decreaseRepeat(),this.rollbacking=!1):(this.rollbacking=!0,this.fire("rollback",new n(this,"rollback"))):this.decreaseRepeat(),this.repeatOption?this.fire("repeat",new n(this,"repeat")):this.finish()):this.finish()},finish:function(){this.setValue(this.finishValue),this.status="finished",this.fire("finish",new n(this,"finish")),o.releaseFrame(this.frame)},decreaseRepeat:function(){this.repeatOption!==!0&&this.repeatOption--},repeat:function(t,e){return this.repeatOption=t,this.rollback=e,this}});return a.requestFrame=o.requestFrame,a.releaseFrame=o.releaseFrame,a}},_p[9]={value:function(){var t=_p.r(0),e=_p.r(11).createClass("TranslateAnimator",{base:t,constructor:function(t,e){this.callBase({x:0,y:0},{x:t,y:e},function(t,e,n){var i=n.getDelta();t.translate(i.x,i.y)})}}),n=_p.r(60);return _p.r(11).extendClass(n,{fxTranslate:function(t,n,i,r,o,a){return this.animate(new e(t,n),i,r,o,a)}}),e}},_p[10]={value:function(){var t=function(){var t,e=navigator.userAgent.toLowerCase(),n=window.opera;t={ie:/(msie\s|trident.*rv:)([\w.]+)/.test(e),opera:!!n&&n.version,webkit:e.indexOf(" applewebkit/")>-1,mac:e.indexOf("macintosh")>-1},t.gecko="Gecko"==navigator.product&&!t.webkit&&!t.opera&&!t.ie;var i=0;if(t.ie&&(i=1*(e.match(/(msie\s|trident.*rv:)([\w.]+)/)[2]||0),t.ie11Compat=11==document.documentMode,t.ie9Compat=9==document.documentMode),t.gecko){var r=e.match(/rv:([\d\.]+)/);r&&(r=r[1].split("."),i=1e4*r[0]+100*(r[1]||0)+1*(r[2]||0))}return/chrome\/(\d+\.\d)/i.test(e)&&(t.chrome=+RegExp.$1),/(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(e)&&!/chrome/i.test(e)&&(t.safari=+(RegExp.$1||RegExp.$2)),t.opera&&(i=parseFloat(n.version())),t.webkit&&(i=parseFloat(e.match(/ applewebkit\/(\d+)/)[1])),t.version=i,t.isCompatible=!t.mobile&&(t.ie&&i>=6||t.gecko&&i>=10801||t.opera&&i>=9.5||t.air&&i>=1||t.webkit&&i>=522||!1),t}();return t}},_p[11]={value:function(require,exports){function Class(){}function checkBaseConstructorCall(t,e){var n=t.toString();if(!/this\.callBase/.test(n))throw new Error(e+" : 类构造函数没有调用父类的构造函数!为了安全,请调用父类的构造函数")}function inherit(constructor,BaseClass,classname){var KityClass=eval("(function "+classname+"( __inherit__flag ) {if( __inherit__flag != KITY_INHERIT_FLAG ) {KityClass.__KityConstructor.apply(this, arguments);}this.__KityClassName = KityClass.__KityClassName;})");KityClass.__KityConstructor=constructor,KityClass.prototype=new BaseClass(KITY_INHERIT_FLAG);for(var methodName in BaseClass.prototype)BaseClass.prototype.hasOwnProperty(methodName)&&0!==methodName.indexOf("__Kity")&&(KityClass.prototype[methodName]=BaseClass.prototype[methodName]);return KityClass.prototype.constructor=KityClass,KityClass}function mixin(t,e){if(!1==e instanceof Array)return t;var n,i,r,o=e.length;for(t.__KityMixins={constructor:[]},n=0;o>n;n++){i=e[n].prototype;for(r in i)!1!==i.hasOwnProperty(r)&&0!==r.indexOf("__Kity")&&("constructor"===r?t.__KityMixins.constructor.push(i[r]):t.prototype[r]=t.__KityMixins[r]=i[r])}return t}function extend(t,e){e.__KityClassName&&(e=e.prototype);for(var n in e)if(e.hasOwnProperty(n)&&n.indexOf("__Kity")&&"constructor"!=n){var i=t.prototype[n]=e[n];i.__KityMethodClass=t,i.__KityMethodName=n}return t}exports.Class=Class,Class.__KityClassName="Class",Class.prototype.base=function(t){var e=arguments.callee.caller,n=e.__KityMethodClass.__KityBaseClass.prototype[t];return n.apply(this,Array.prototype.slice.call(arguments,1))},Class.prototype.callBase=function(){var t=arguments.callee.caller,e=t.__KityMethodClass.__KityBaseClass.prototype[t.__KityMethodName];return e.apply(this,arguments)},Class.prototype.mixin=function(t){var e=arguments.callee.caller,n=e.__KityMethodClass.__KityMixins;if(!n)return this;var i=n[t];return i.apply(this,Array.prototype.slice.call(arguments,1))},Class.prototype.callMixin=function(){var t=arguments.callee.caller,e=t.__KityMethodName,n=t.__KityMethodClass.__KityMixins;if(!n)return this;var i=n[e];if("constructor"==e){for(var r=0,o=i.length;o>r;r++)i[r].call(this);return this}return i.apply(this,arguments)},Class.prototype.pipe=function(t){return"function"==typeof t&&t.call(this,this),this},Class.prototype.getType=function(){return this.__KityClassName},Class.prototype.getClass=function(){return this.constructor};var KITY_INHERIT_FLAG="__KITY_INHERIT_FLAG_"+ +new Date;exports.createClass=function(t,e){var n,i,r;return 1===arguments.length&&(e=arguments[0],t="AnonymousClass"),r=e.base||Class,e.hasOwnProperty("constructor")?(n=e.constructor,r!=Class&&checkBaseConstructorCall(n,t)):n=function(){this.callBase.apply(this,arguments),this.callMixin.apply(this,arguments) },i=inherit(n,r,t),i=mixin(i,e.mixins),i.__KityClassName=n.__KityClassName=t,i.__KityBaseClass=n.__KityBaseClass=r,i.__KityMethodName=n.__KityMethodName="constructor",i.__KityMethodClass=n.__KityMethodClass=i,delete e.mixins,delete e.constructor,delete e.base,i=extend(i,e)},exports.extendClass=extend}},_p[12]={value:function(){var t={each:function(t,e,n){if(null!==t)if(t.length===+t.length){for(var i=0,r=t.length;r>i;i++)if(e.call(n,t[i],i,t)===!1)return!1}else for(var o in t)if(t.hasOwnProperty(o)&&e.call(n,t[o],o,t)===!1)return!1},extend:function(t){for(var e=arguments,n=this.isBoolean(e[e.length-1])?e[e.length-1]:!1,i=this.isBoolean(e[e.length-1])?e.length-1:e.length,r=1;i>r;r++){var o=e[r];for(var a in o)n&&t.hasOwnProperty(a)||(t[a]=o[a])}return t},deepExtend:function(t){for(var e=arguments,n=this.isBoolean(e[e.length-1])?e[e.length-1]:!1,i=this.isBoolean(e[e.length-1])?e.length-1:e.length,r=1;i>r;r++){var o=e[r];for(var a in o)n&&t.hasOwnProperty(a)||(this.isObject(t[a])&&this.isObject(o[a])?this.deepExtend(t[a],o[a],n):t[a]=o[a])}return t},clone:function(t){var e={};for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e},copy:function(t){return"object"!=typeof t?t:"function"==typeof t?null:JSON.parse(JSON.stringify(t))},queryPath:function(t,e){for(var n=t.split("."),i=0,r=e,o=n.length;o>i;){if(!(n[i]in r))return void 0;if(r=r[n[i]],i++,i>=o||void 0===r)return r}},getValue:function(t,e){return void 0!==t?t:e},flatten:function(e){var n,i=[],r=e.length;for(n=0;r>n;n++)e[n]instanceof Array?i=i.concat(t.flatten(e[n])):i.push(e[n]);return i},paralle:function(e,n,i){var r,o,a,s;if(e instanceof Array){for(s=[],o=0;oa;a++)e[5*a+3]=o[a]/255;return e[18]=t.get("a"),this.colorMatrixEffect.set("values",e.join(" ")),this},setOpacity:function(t){var e=this.colorMatrixEffect.get("values").split(" ");return e[18]=t,this.colorMatrixEffect.set("values",e.join(" ")),this},setOffset:function(t,e){this.setOffsetX(t),this.setOffsetY(e)},setOffsetX:function(t){this.offsetEffect.set("dx",t)},setOffsetY:function(t){this.offsetEffect.set("dy",t)},setDeviation:function(t){this.gaussianblurEffect.set("stdDeviation",t)}})}},_p[23]={value:function(){return _p.r(11).createClass("Bezier",{mixins:[_p.r(51)],base:_p.r(46),constructor:function(t){this.callBase(),t=t||[],this.changeable=!0,this.setBezierPoints(t)},getBezierPoints:function(){return this.getPoints()},setBezierPoints:function(t){return this.setPoints(t)},onContainerChanged:function(){this.changeable&&this.update()},update:function(){var t=null,e=this.getBezierPoints();if(!(e.length<2)){t=this.getDrawer(),t.clear();var n=e[0].getVertex(),i=null,r=null;t.moveTo(n.x,n.y);for(var o=1,a=e.length;a>o;o++)n=e[o].getVertex(),r=e[o].getBackward(),i=e[o-1].getForward(),t.bezierTo(i.x,i.y,r.x,r.y,n.x,n.y);return this}}})}},_p[24]={value:function(){var t=_p.r(63),e=_p.r(73),n=_p.r(11).createClass("BezierPoint",{constructor:function(e,n,i){this.vertex=new t(e,n),this.forward=new t(e,n),this.backward=new t(e,n),this.setSmooth(void 0===i||i),this.setSymReflaction(!0)},clone:function(){var t=new n,e=null;return e=this.getVertex(),t.setVertex(e.x,e.y),e=this.getForward(),t.setForward(e.x,e.y),e=this.getBackward(),t.setBackward(e.x,e.y),t.setSymReflaction(this.isSymReflaction),t.setSmooth(this.isSmooth()),t},setVertex:function(t,e){return this.vertex.setPoint(t,e),this.update(),this},moveTo:function(t,e){var n=this.forward.getPoint(),i=this.backward.getPoint(),r=this.vertex.getPoint(),o={left:t-r.x,top:e-r.y};this.forward.setPoint(n.x+o.left,n.y+o.top),this.backward.setPoint(i.x+o.left,i.y+o.top),this.vertex.setPoint(t,e),this.update()},setForward:function(t,e){return this.forward.setPoint(t,e),this.smooth&&this.updateAnother(this.forward,this.backward),this.update(),this.lastControlPointSet=this.forward,this},setBackward:function(t,e){return this.backward.setPoint(t,e),this.smooth&&this.updateAnother(this.backward,this.forward),this.update(),this.lastControlPointSet=this.backward,this},setSymReflaction:function(t){return this.symReflaction=t,this.smooth&&this.setSmooth(!0),this},isSymReflaction:function(){return this.symReflaction},updateAnother:function(t,n){var i=this.getVertex(),r=e.fromPoints(t.getPoint(),i),o=e.fromPoints(i,n.getPoint());return o=r.normalize(this.isSymReflaction()?r.length():o.length()),n.setPoint(i.x+o.x,i.y+o.y),this},setSmooth:function(t){var e;return this.smooth=!!t,this.smooth&&(e=this.lastControlPointSet)&&this.updateAnother(e,e==this.forward?this.backward:this.forward),this},isSmooth:function(){return this.smooth},getVertex:function(){return this.vertex.getPoint()},getForward:function(){return this.forward.getPoint()},getBackward:function(){return this.backward.getPoint()},update:function(){return this.container?void(this.container.update&&this.container.update(this)):this}});return n}},_p[25]={value:function(){var t=_p.r(11).createClass("Box",{constructor:function(t,e,n,i){var r=arguments[0];r&&"object"==typeof r&&(t=r.x,e=r.y,n=r.width,i=r.height),0>n&&(t-=n=-n),0>i&&(e-=i=-i),this.x=t||0,this.y=e||0,this.width=n||0,this.height=i||0,this.left=this.x,this.right=this.x+this.width,this.top=this.y,this.bottom=this.y+this.height,this.cx=this.x+this.width/2,this.cy=this.y+this.height/2},getRangeX:function(){return[this.left,this.right]},getRangeY:function(){return[this.top,this.bottom]},merge:function(e){if(this.isEmpty())return new t(e.x,e.y,e.width,e.height);var n=Math.min(this.left,e.left),i=Math.max(this.right,e.right),r=Math.min(this.top,e.top),o=Math.max(this.bottom,e.bottom);return new t(n,r,i-n,o-r)},intersect:function(e){!e instanceof t&&(e=new t(e));var n=Math.max(this.left,e.left),i=Math.min(this.right,e.right),r=Math.max(this.top,e.top),o=Math.min(this.bottom,e.bottom);return n>i||r>o?new t:new t(n,r,i-n,o-r)},expand:function(e,n,i,r){if(arguments.length<1)return new t(this);arguments.length<2&&(n=e),arguments.length<3&&(i=e),arguments.length<4&&(r=n);var o=this.left-r,a=this.top-e,s=this.width+n,l=this.height+e;return new t(o,a,s,l)},valueOf:function(){return[this.x,this.y,this.width,this.height]},toString:function(){return this.valueOf().join(" ")},isEmpty:function(){return!this.width||!this.height}});return t.parse=function(e){return"string"==typeof e?t.parse(e.split(/[\s,]+/).map(parseFloat)):e instanceof Array?new t(e[0],e[1],e[2],e[3]):"x"in e?new t(e):null},t}},_p[26]={value:function(){return _p.r(11).createClass("Circle",{base:_p.r(32),constructor:function(t,e,n){this.callBase(t,t,e,n)},getRadius:function(){return this.getRadiusX()},setRadius:function(t){return this.callBase(t,t)}})}},_p[27]={value:function(){var t=_p.r(11),e=_p.r(60),n=t.createClass("Clip",{base:e,mixins:[_p.r(61)],constructor:function(t){this.callBase("clipPath",t)},clip:function(t){return t.getNode().setAttribute("clip-path",this),this}});return t.extendClass(e,{clipWith:function(t){return t instanceof e&&(t=new n(t.getPaper()).addShape(t)),t.clip(this),this}}),n}},_p[28]={value:function(){var t=_p.r(12),e=_p.r(64),n={},i=_p.r(11).createClass("Color",{constructor:function(){var e=null;"string"==typeof arguments[0]?(e=n.parseToValue(arguments[0]),null===e&&(e={r:0,g:0,b:0,h:0,s:0,l:0,a:1})):(e={r:0|arguments[0],g:0|arguments[1],b:0|arguments[2],a:void 0===arguments[3]?1:parseFloat(arguments[3])},e=n.overflowFormat(e),e=t.extend(e,n.rgbValueToHslValue(e))),this._color=e},set:function(e,r){if(!i._MAX_VALUE[e])throw new Error("Color set(): Illegal parameter");return"a"!==e&&(r=Math.floor(r)),"h"==e&&(r=(r+360)%360),this._color[e]=Math.max(i._MIN_VALUE[e],Math.min(i._MAX_VALUE[e],r)),-1!=="rgb".indexOf(e)?this._color=t.extend(this._color,n.rgbValueToHslValue(this._color)):-1!=="hsl".indexOf(e)&&(this._color=t.extend(this._color,n.hslValueToRGBValue(this._color))),this},inc:function(t,e){return e=this.get(t)+e,"h"==t?e=(e+360)%360:(e=Math.min(i._MAX_VALUE[t],e),e=Math.max(i._MIN_VALUE[t],e)),this.clone().set(t,e)},dec:function(t,e){return this.inc(t,-e)},clone:function(){return new i(this.toRGBA())},get:function(t){return i._MAX_VALUE[t]?this._color[t]:null},getValues:function(){return t.clone(this._color)},valueOf:function(){return this.getValues()},toRGB:function(){return n.toString(this._color,"rgb")},toRGBA:function(){return n.toString(this._color,"rgba")},toHEX:function(){return n.toString(this._color,"hex")},toHSL:function(){return n.toString(this._color,"hsl")},toHSLA:function(){return n.toString(this._color,"hsla")},toString:function(){return 1===this._color.a?this.toRGB():this.toRGBA()}});return t.extend(i,{_MAX_VALUE:{r:255,g:255,b:255,h:360,s:100,l:100,a:1},_MIN_VALUE:{r:0,g:0,b:0,h:0,s:0,l:0,a:0},R:"r",G:"g",B:"b",H:"h",S:"s",L:"l",A:"a",parse:function(e){var r;return t.isString(e)&&(r=n.parseToValue(e)),t.isObject(e)&&"r"in e&&(r=e),null===r?new i:new i(r.r,r.g,r.b,r.a)},createHSL:function(t,e,n){return i.createHSLA(t,e,n,1)},createHSLA:function(t,e,n,r){var o=null;return e+="%",n+="%",o=["hsla("+t,e,n,r+")"],i.parse(o.join(", "))},createRGB:function(t,e,n){return i.createRGBA(t,e,n,1)},createRGBA:function(t,e,n,r){return new i(t,e,n,r)}}),t.extend(n,{parseToValue:function(t){var i={};if(t=e.EXTEND_STANDARD[t]||e.COLOR_STANDARD[t]||t,/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(t))i=n.hexToValue(t);else if(/^(rgba?)/i.test(t))i=n.rgbaToValue(t);else{if(!/^(hsla?)/i.test(t))return null;i=n.hslaToValue(t)}return n.overflowFormat(i)},hexToValue:function(e){var i={},r=["r","g","b"];return/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(e)?(e=RegExp.$1.split(""),t.each(r,function(t,r){i[t]=n.toNumber(3===e.length?e[r]+e[r]:e[2*r]+e[2*r+1])}),i=t.extend(i,n.rgbValueToHslValue(i)),i.a=1,i):null},rgbaToValue:function(e){var i={},r=!1,o=["r","g","b"];return/^(rgba?)/i.test(e)?(r=4===RegExp.$1.length,e=e.replace(/^rgba?/i,"").replace(/\s+/g,"").replace(/[^0-9,.]/g,"").split(","),t.each(o,function(t,n){i[t]=0|e[n]}),i=t.extend(i,n.rgbValueToHslValue(i)),i.a=r?parseFloat(e[3]):1,i):null},hslaToValue:function(e){var i={},r=!1;return/^(hsla?)/i.test(e)?(r=4===RegExp.$1.length,e=e.replace(/^hsla?/i,"").replace(/\s+/g,"").replace(/[^0-9,.]/g,"").split(","),i.h=0|e[0],i.s=0|e[1],i.l=0|e[2],i=t.extend(i,n.hslValueToRGBValue(i)),i=n.hslValueToRGBValue(i),i.a=r?parseFloat(e[3]):1,i):null},hslValueToRGBValue:function(e){function n(t,e,n){return 0>n?n+=1:n>1&&(n-=1),1>6*n?t+6*(e-t)*n:1>2*n?e:2>3*n?t+6*(e-t)*(2/3-n):t}var i=null,r=null,o={};return e=t.extend({},e),e.h=e.h/360,e.s=e.s/100,e.l=e.l/100,0===e.s?o.r=o.g=o.b=e.l:(i=e.l<.5?e.l*(1+e.s):e.l+e.s-e.l*e.s,r=2*e.l-i,o.r=n(r,i,e.h+1/3),o.g=n(r,i,e.h),o.b=n(r,i,e.h-1/3)),o.r=Math.min(Math.round(255*o.r),255),o.g=Math.min(Math.round(255*o.g),255),o.b=Math.min(Math.round(255*o.b),255),o},rgbValueToHslValue:function(e){var n=null,i=null,r={};return e=t.extend({},e),e.r=e.r/255,e.g=e.g/255,e.b=e.b/255,n=Math.max(e.r,e.g,e.b),i=Math.min(e.r,e.g,e.b),n===i?r.h=0:n===e.r?r.h=e.g>=e.b?60*(e.g-e.b)/(n-i):60*(e.g-e.b)/(n-i)+360:n===e.g?r.h=60*(e.b-e.r)/(n-i)+120:n===e.b&&(r.h=60*(e.r-e.g)/(n-i)+240),r.l=(n+i)/2,r.s=0===r.l||n===i?0:r.l>0&&r.l<=.5?(n-i)/(n+i):(n-i)/(2-n-i),r.h=Math.round(r.h),r.s=Math.round(100*r.s),r.l=Math.round(100*r.l),r},toString:function(e,i){var r=[];return e=t.extend({},e),-1!==i.indexOf("hsl")&&(e.s+="%",e.l+="%"),"hex"!==i?(t.each(i.split(""),function(t){r.push(e[t])}),(i+"("+r.join(", ")+")").toLowerCase()):(r.push(n.toHexValue(+e.r)),r.push(n.toHexValue(+e.g)),r.push(n.toHexValue(+e.b)),("#"+r.join("")).toLowerCase())},toNumber:function(t){return 0|Number("0x"+t)},toHexValue:function(t){var e=t.toString(16);return 1===e.length?"0"+e:e},overflowFormat:function(e){var n=t.extend({},e),r="rgba";return t.each(r.split(""),function(t){n.hasOwnProperty(t)&&(n[t]=Math.min(i._MAX_VALUE[t],n[t]),n[t]=Math.max(i._MIN_VALUE[t],n[t]))}),n}}),i}},_p[29]={value:function(){function t(){return this.container.removeItem(this),this}return _p.r(11).createClass("Container",{getItems:function(){return this.items||(this.items=[])},getItem:function(t){return this.getItems()[t]},getFirstItem:function(){return this.getItem(0)},getLastItem:function(){return this.getItem(this.getItems().length-1)},indexOf:function(t){return this.getItems().indexOf(t)},eachItem:function(t){var e,n=this.getItems(),i=n.length;for(e=0;i>e;e++)t.call(this,e,n[e]);return this},addItem:function(e,n,i){var r=this.getItems(),o=r.length;return~r.indexOf(e)?this:(n>=0&&o>n||(n=o),r.splice(n,0,e),"object"==typeof e&&(e.container=this,e.remove=t),this.handleAdd(e,n),i||this.onContainerChanged("add",[e]),this)},addItems:function(t){for(var e=0,n=t.length;n>e;e++)this.addItem(t[e],-1,!0);return this.onContainerChanged("add",t),this},setItems:function(t){return this.clear().addItems(t)},appendItem:function(t){return this.addItem(t)},prependItem:function(t){return this.addItem(t,0)},removeItem:function(t,e){if("number"!=typeof t)return this.removeItem(this.indexOf(t));var n=this.getItems(),i=(n.length,n[t]);return void 0===i?this:(n.splice(t,1),i.container&&delete i.container,i.remove&&delete i.remove,this.handleRemove(i,t),e||this.onContainerChanged("remove",[i]),this)},clear:function(){for(var t,e=[];t=this.getFirstItem();)e.push(t),this.removeItem(0,!0);return this.onContainerChanged("remove",e),this},onContainerChanged:function(){},handleAdd:function(){},handleRemove:function(){}})}},_p[30]={value:function(){var t=_p.r(12),e={getCurvePanLines:function(t,n){var i=e.getCenterPoints(t),r=e.getPanLine(t.length,i);return e.getMovedPanLines(t,r,n)},getCenterPoints:function(t){for(var e={},n=null,i=0,r=0,o=t.length;o>i;i++)r=i===o-1?0:i+1,n=i+","+r,e[n]={x:(t[i].x+t[r].y)/2,y:(t[i].x+t[r].y)/2};return e},getPanLine:function(t,e){for(var n,i={},r=null,o=0;t>o;o++){var a=null,s=null;n=(o+1)%t,r=n,a=e[o+","+n],o=n,n=(o+1)%t,s=e[o+","+n],i[r]={points:[{x:a.x,y:a.y},{x:s.x,y:s.y}],center:{x:(a.x+s.x)/2,y:(a.y+s.y)/2}},o=(r+t-1)%t}return i},getMovedPanLines:function(e,n,i){var r={};return t.each(e,function(e,o){var a=n[o],s=a.center,l={x:s.x-e.x,y:s.y-e.y},u=r[o]={points:[],center:{x:e.x,y:e.y}};t.each(a.points,function(t){var e={x:t.x-l.x,y:t.y-l.y},n=u.center,r=e.x-n.x,o=e.y-n.y;e.x=n.x+i*r,e.y=n.y+i*o,u.points.push(e)})}),r}};return _p.r(11).createClass("Curve",{base:_p.r(46),mixins:[_p.r(51)],constructor:function(t,e){this.callBase(),this.setPoints(t||[]),this.closeState=!!e,this.changeable=!0,this.smoothFactor=1,this.update()},onContainerChanged:function(){this.changeable&&this.update()},setSmoothFactor:function(t){return this.smoothFactor=0>t?0:t,this.update(),this},getSmoothFactor:function(){return this.smoothFactor},update:function(){var t=this.getPoints(),n=null,i=this.getDrawer(),r=null,o=null,a=null;if(i.clear(),0===t.length)return this;if(i.moveTo(t[0]),1===t.length)return this;if(2===t.length)return i.lineTo(t[1]),this;n=e.getCurvePanLines(t,this.getSmoothFactor());for(var s=1,l=t.length;l>s;s++)r=n[s].center,o=this.closeState||s!=l-1?n[s].points[0]:n[s].center,a=this.closeState||1!=s?n[s-1].points[1]:n[s-1].center,i.bezierTo(a.x,a.y,o.x,o.y,r.x,r.y);return this.closeState&&(r=n[0].center,o=n[0].points[0],a=n[t.length-1].points[1],i.bezierTo(a.x,a.y,o.x,o.y,r.x,r.y)),this},close:function(){return this.closeState=!0,this.update()},open:function(){return this.closeState=!1,this.update()},isClose:function(){return!!this.closeState}})}},_p[31]={value:function(){return _p.r(11).createClass("Data",{constructor:function(){this._data={}},setData:function(t,e){return this._data[t]=e,this},getData:function(t){return this._data[t]},removeData:function(t){return delete this._data[t],this}})}},_p[32]={value:function(){var t=(_p.r(12),_p.r(50));return _p.r(11).createClass("Ellipse",{base:_p.r(46),constructor:function(t,e,n,i){this.callBase(),this.rx=t||0,this.ry=e||0,this.cx=n||0,this.cy=i||0,this.update()},update:function(){var t=this.rx,e=this.ry,n=this.cx+t,i=this.cx-t,r=this.cy,o=this.getDrawer();return o.clear(),o.moveTo(n,r),o.arcTo(t,e,0,1,1,i,r),o.arcTo(t,e,0,1,1,n,r),this},getRadius:function(){return{x:this.rx,y:this.ry}},getRadiusX:function(){return this.rx},getRadiusY:function(){return this.ry},getCenter:function(){return new t(this.cx,this.cy)},getCenterX:function(){return this.cx},getCenterY:function(){return this.cy},setRadius:function(t,e){return this.rx=t,this.ry=e,this.update()},setRadiusX:function(t){return this.rx=t,this.update()},setRadiusY:function(t){return this.ry=t,this.update()},setCenter:function(e,n){if(1==arguments.length){var i=t.parse(arguments[0]);e=i.x,n=i.y}return this.cx=e,this.cy=n,this.update()},setCenterX:function(t){return this.cx=t,this.update()},setCenterY:function(t){return this.cy=t,this.update()}})}},_p[33]={value:function(){function t(t,e,i){return i=!!i,a.isString(t)&&(t=t.match(/\S+/g)),a.each(t,function(t){n.call(this,this.node,t,e,i)},this),this}function e(t,e){var n=null,i=this._EVNET_UID,o=void 0===e;return n=u[i][t],o||(o=!0,a.each(n,function(t,i){t===e?delete n[i]:o=!1})),o&&(r(this.node,t,l[i][t]),delete u[i][t],delete l[i][t]),this}function n(t,e,n,r){var o=this._EVNET_UID,c=this;l[o]||(l[o]={}),l[o][e]||(l[o][e]=function(t){t=new s(t||window.event),a.each(u[o][e],function(n){var i;return n&&(i=n.call(c,t),r&&c.off(e,n)),i},c)}),u[o]||(u[o]={}),u[o][e]?u[o][e].push(n):(u[o][e]=[n],t&&"on"+e in t&&i(t,e,l[o][e]))}function i(t,e,n){t.addEventListener?t.addEventListener(e,n,!1):t.attachEvent("on"+e,n)}function r(t,e,n){t.removeEventListener?t.removeEventListener(e,n,!1):t.detachEvent(e,n)}function o(t,e,n){var i=null,r=null,o=l[t._EVNET_UID];o&&(r=o[e],r&&(i=a.extend({type:e,target:t},n||{}),r.call(t,i)))}!function(){function t(t,e){e=e||{bubbles:!1,cancelable:!1,detail:void 0};var n=document.createEvent("CustomEvent");return n.initCustomEvent(t,e.bubbles,e.cancelable,e.detail),n}t.prototype=window.Event.prototype,window.CustomEvent=t}();var a=_p.r(12),s=_p.r(62),l={},u={},c=0;return _p.r(11).createClass("EventHandler",{constructor:function(){this._EVNET_UID=++c},addEventListener:function(e,n){return t.call(this,e,n,!1)},addOnceEventListener:function(e,n){return t.call(this,e,n,!0)},removeEventListener:function(t,n){return e.call(this,t,n)},on:function(){return this.addEventListener.apply(this,arguments)},once:function(){return this.addOnceEventListener.apply(this,arguments)},off:function(){return this.removeEventListener.apply(this,arguments)},fire:function(){return this.trigger.apply(this,arguments)},trigger:function(t,e){return o(this,t,e),this}})}},_p[34]={value:function(){function t(t){var e,n,i,r,o;for(e=[],n=0;nn;n++)if(t[n]===e)return t.push(t.splice(n,1)[0])}function r(){var o=Array.prototype.slice.call(arguments,0),a=o.join("␀"),s=r.cache=r.cache||{},l=r.count=r.count||[];return s.hasOwnProperty(a)?(i(l,a),n?n(s[a]):s[a]):(l.length>=1e3&&delete s[l.shift()],l.push(a),s[a]=t.apply(e,o),n?n(s[a]):s[a])}return r}function n(t,e,i,r,o,a,s,l,u,c){var h,d,f,p,g,m,v,y,_,b,x,w,k,C,S,T,M,L,E,N,P,A,O,D,I,B,R,W,H,V,z,F=Math,j=F.PI,U=Math.abs,K=120*j/180,q=j/180*(+o||0),$=[],G=function(t,e,n){var i=t*F.cos(n)-e*F.sin(n),r=t*F.sin(n)+e*F.cos(n);return{x:i,y:r}};if(c?(w=c[0],k=c[1],b=c[2],x=c[3]):(h=G(t,e,-q),t=h.x,e=h.y,h=G(l,u,-q),l=h.x,u=h.y,d=F.cos(j/180*o),f=F.sin(j/180*o),g=(t-l)/2,m=(e-u)/2,p=g*g/(i*i)+m*m/(r*r),p>1&&(p=F.sqrt(p),i=p*i,r=p*r),v=i*i,y=r*r,_=(a==s?-1:1)*F.sqrt(U((v*y-v*m*m-y*g*g)/(v*m*m+y*g*g))),b=_*i*m/r+(t+l)/2,x=_*-r*g/i+(e+u)/2,w=F.asin(((e-x)/r).toFixed(9)),k=F.asin(((u-x)/r).toFixed(9)),w=b>t?j-w:w,k=b>l?j-k:k,0>w&&(w=2*j+w),0>k&&(k=2*j+k),s&&w>k&&(w-=2*j),!s&&k>w&&(k-=2*j)),C=k-w,U(C)>K&&(S=k,T=l,M=u,k=w+K*(s&&k>w?1:-1),l=b+i*F.cos(k),u=x+r*F.sin(k),$=n(l,u,i,r,o,0,s,T,M,[k,S,b,x])),C=k-w,L=F.cos(w),E=F.sin(w),N=F.cos(k),P=F.sin(k),A=F.tan(C/4),O=4/3*i*A,D=4/3*r*A,I=[t,e],B=[t+O*E,e-D*L],R=[l+O*P,u-D*N],W=[l,u],B[0]=2*I[0]-B[0],B[1]=2*I[1]-B[1],c)return[B,R,W].concat($);for($=[B,R,W].concat($).join().split(","),H=[],V=0,z=$.length;z>V;V++)H[V]=V%2?G($[V-1],$[V],q).y:G($[V],$[V+1],q).x;return H}function i(t,e,n,i,r,o){var a=1/3,s=2/3;return[a*t+s*n,a*e+s*i,a*r+s*n,a*o+s*i,r,o]}function r(t,e){function n(t){return function(e,n){return e+t*(n-e)}}var i=n(e||.5),r=t,o=r[0],a=r[1],s=r[2],l=r[3],u=r[4],c=r[5],h=r[6],d=r[7],f=i(o,s),p=i(a,l),g=i(s,u),m=i(l,c),v=i(u,h),y=i(c,d),_=i(f,g),b=i(p,m),x=i(g,v),w=i(m,y),k=i(_,x),C=i(b,w);return[[o,a,f,p,_,b,k,C],[k,C,x,w,v,y,h,d]]}var o=_p.r(12),a=_p.r(50),s=_p.r(73),l=_p.r(43),u={},c=/([achlmrqstvz])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\s]*,?\s*)+)/gi,h=/(-?\d*\.?\d*(?:e[\-+]?\d+)?)\s*,?\s*/gi,d={a:7,c:6,h:1,l:2,m:2,q:4,s:4,t:2,v:1,z:0};u.pathToString=function(t){return t=t||this,"string"==typeof t?t:t instanceof Array?(t=o.flatten(t),t.join(",").replace(/,?([achlmqrstvxz]),?/gi,"$1")):void 0},u.parsePathString=e(function(t){var e=[];return t.replace(c,function(t,n,i){var r=[],o=n.toLowerCase();if(i.replace(h,function(t,e){e&&r.push(+e)}),"m"==o&&r.length>2&&(e.push([n].concat(r.splice(0,2))),o="l",n="m"==n?"l":"L"),"r"==o)e.push([n].concat(r));else for(;r.length>=d[o]&&(e.push([n].concat(r.splice(0,d[o]))),d[o]););}),e.isUniform=!0,e.toString=u.pathToString,e}),u.pathToAbsolute=e(function(t){var e,n,i,r,o,a,s,l,c=t.isUniform?t:u.parsePathString(u.pathToString(t)),h=[],d=0,f=0,p=0,g=0,m=0;for("M"==c[0][0]&&(d=+c[0][1],f=+c[0][2],p=d,g=f,m++,h[0]=["M",d,f]),i=m,a=c.length;a>i;i++){if(h.push(e=[]),n=c[i],n[0]!=n[0].toUpperCase())switch(e[0]=n[0].toUpperCase(),e[0]){case"A":e[1]=n[1],e[2]=n[2],e[3]=n[3],e[4]=n[4],e[5]=n[5],e[6]=+(n[6]+d),e[7]=+(n[7]+f);break;case"V":e[1]=+n[1]+f;break;case"H":e[1]=+n[1]+d;break;case"M":p=+n[1]+d,g=+n[2]+f;break;default:for(r=1,s=n.length;s>r;r++)e[r]=+n[r]+(r%2?d:f)}else for(o=0,l=n.length;l>o;o++)e[o]=n[o];switch(e[0]){case"Z":d=p,f=g;break;case"H":d=e[1];break;case"V":f=e[1];break;case"M":p=e[e.length-2],g=e[e.length-1];break;default:d=e[e.length-2],f=e[e.length-1]}}return h.isUniform=!0,h.isAbsolute=!0,h.toString=u.pathToString,h}),u.pathToCurve=e(function(t){var e,r,o,a,s,l,c,h,d,f,p,g,m=[];for(t.isAbsolute||(t=u.pathToAbsolute(t)),e=0;ee&&(e=0),Math.pow(e,.5)}var n,i,r,o,a,s,l,u,c,h,d,f=t;return n=-3*f[0]+9*f[2]-9*f[4]+3*f[6],i=6*f[0]-12*f[2]+6*f[4],r=-3*f[0]+3*f[2],o=-3*f[1]+9*f[3]-9*f[5]+3*f[7],a=6*f[1]-12*f[3]+6*f[5],s=-3*f[1]+3*f[3],l=Math.pow(n,2)+Math.pow(o,2),u=2*(n*i+o*a),c=2*(n*r+o*s)+Math.pow(i,2)+Math.pow(a,2),h=2*(i*r+a*s),d=Math.pow(r,2)+Math.pow(s,2),(e(0)+e(1)+4*(e(.125)+e(.375)+e(.625)+e(.875))+2*(e(.25)+e(.5)+e(.75)))/24});var f=e(function(t){var e,n,i,r,o,a,s;for(a=[],s=0,e=0,n=t.length;n>e;e++)i=t[e],"M"!=i[0]?"Z"!=i[0]?(o=u.bezierLength(r.concat(i.slice(1))),a.push([s,s+o]),s+=o,r=i.slice(4)):a.push(null):(r=i.slice(1),a.push(null));return a.totalLength=s,a});u.subPath=function(t,e,n){var i;if(n=n||0,i=e-n,i-=0|i,n-=0|n,e=n+i,e>1)return u.subPath(t,1,n).concat(u.subPath(t,e-1));t.isCurve||(t=u.pathToCurve(t));var r,o,a,s,l,c,h,d,p,g=f(t),m=g.totalLength,v=m*e,y=m*(n||0),_=[];for(r=0,o=t.length;o>r;r++)if("M"!=t[r][0]){if("Z"!=t[r][0])if(a=g[r][0],s=g[r][1],l=s-a,h=c.concat(t[r].slice(1)),y>s)c=h.slice(h.length-2);else{if(y>=a)d=u.subBezier(h,Math.min((v-a)/l,1),(y-a)/l),p=!0,c=d.slice(0,2),_.push(["M"].concat(d.slice(0,2))),_.push(["C"].concat(d.slice(2)));else if(v>=s)_.push(t[r].slice());else{if(!(v>=a))break;d=u.subBezier(h,(v-a)/l),_.push(["C"].concat(d.slice(2))),p=!1}c=h.slice(h.length-2)}}else c=t[r].slice(1),p&&_.push(t[r].slice());return _.isAbsolute=!0,_.isCurve=!0,_.isUniform=!0,_.toString=u.pathToString,_},u.pointAtPath=function(t,e){t.isCurve||(t=u.pathToCurve(t));var n=u.subPath(t,e),i="Z"==n[n.length-1][0]?n[n.length-2]:n[n.length-1];i=i.slice(1);var r=a.parse(i.slice(4)),o=a.parse(i.slice(2,4));return r.tan=s.fromPoints(o,r).normalize(),r},u.pathLength=e(function(t){t.isCurve||(t=u.pathToCurve(t));var e=f(t);return e.totalLength}),u.pathKeyPoints=e(function(t){var e,n,i;for(t.isCurve||(t=u.pathToCurve(t)),i=[],e=0,n=t.length;n>e;e++)"z"!=t[e][0]&&i.push(t[e].slice(t[e].length-2));return i});var p=e(function(e,n){function i(t,e){return t[e||t.i]&&t[e||t.i][0]}function r(t,e){return t[e||t.i]&&t[e||t.i].slice(1)}function o(t,e){var n=r(t,e);return n&&n.slice(-2)}function a(t){return"Z"==i(t)?(t.splice(t.i,1),!0):!1}function s(t){return"M"==i(t)?(t.o.splice(t.o.i,0,["M"].concat(o(t.o,t.o.i-1))),t.i++,t.o.i++,!0):!1}function l(t){for(var e,n=1;!e;)e=o(t,t.length-n++);for(t.o.i=t.i;t.lengthn;n++)for(o.push(s=[t[n][0]]),r=1;rr&&o.setAttribute("stop-opacity",r),this.node.appendChild(o),this}})}},_p[36]={value:function(){var t=_p.r(61);return _p.r(11).createClass("Group",{mixins:[t],base:_p.r(60),constructor:function(){this.callBase("g")}})}},_p[37]={value:function(){var t=_p.r(61);return _p.r(11).createClass("HyperLink",{mixins:[t],base:_p.r(60),constructor:function(t){this.callBase("a"),this.setHref(t)},setHref:function(t){return this.node.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",t),this},getHref:function(){return this.node.getAttributeNS("xlink:href")},setTarget:function(t){return this.node.setAttribute("target",t),this},getTarget:function(){return this.node.getAttribute("target")}})}},_p[38]={value:function(){return _p.r(11).createClass("Image",{base:_p.r(60),constructor:function(t,e,n,i,r){this.callBase("image"),this.url=t,this.width=e||0,this.height=n||0,this.x=i||0,this.y=r||0,this.update()},update:function(){return this.node.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",this.url),this.node.setAttribute("x",this.x),this.node.setAttribute("y",this.y),this.node.setAttribute("width",this.width),this.node.setAttribute("height",this.height),this},setUrl:function(t){return this.url=""===t?null:t,this.update()},getUrl:function(){return this.url},setWidth:function(t){return this.width=t,this.update()},getWidth:function(){return this.width},setHeight:function(t){return this.height=t,this.update()},getHeight:function(){return this.height},setX:function(t){return this.x=t,this.update()},getX:function(){return this.x},setY:function(t){return this.y=t,this.update()},getY:function(){return this.y}})}},_p[39]={value:function(){return _p.r(11).createClass("Line",{base:_p.r(46),constructor:function(t,e,n,i){this.callBase(),this.point1={x:t||0,y:e||0},this.point2={x:n||0,y:i||0},this.update()},setPoint1:function(t,e){return this.point1.x=t,this.point1.y=e,this.update()},setPoint2:function(t,e){return this.point2.x=t,this.point2.y=e,this.update()},getPoint1:function(){return{x:this.point1.x,y:this.point1.y}},getPoint2:function(){return{x:this.point2.x,y:this.point2.y}},update:function(){var t=this.getDrawer();return t.clear(),t.moveTo(this.point1.x,this.point1.y),t.lineTo(this.point2.x,this.point2.y),this}})}},_p[40]={value:function(){var t=(_p.r(67),_p.r(35));return _p.r(11).createClass("LinearGradientBrush",{base:t,constructor:function(t){this.callBase("linearGradient",t),this.setStartPosition(0,0),this.setEndPosition(1,0)},setStartPosition:function(t,e){return this.node.setAttribute("x1",t),this.node.setAttribute("y1",e),this},setEndPosition:function(t,e){return this.node.setAttribute("x2",t),this.node.setAttribute("y2",e),this},getStartPosition:function(){return{x:+this.node.getAttribute("x1"),y:+this.node.getAttribute("y1")}},getEndPosition:function(){return{x:+this.node.getAttribute("x2"),y:+this.node.getAttribute("y2")}}})}},_p[41]={value:function(){var t=_p.r(50),e=_p.r(11).createClass("Marker",{base:_p.r(58),mixins:[_p.r(61),_p.r(75)],constructor:function(){this.callBase("marker"),this.setOrient("auto")},setRef:function(t,e){return 1===arguments.length&&(e=t.y,t=t.x),this.node.setAttribute("refX",t),this.node.setAttribute("refY",e),this},getRef:function(){return new t(+this.node.getAttribute("refX"),+this.node.getAttribute("refY"))},setWidth:function(t){return this.node.setAttribute("markerWidth",this.width=t),this},setOrient:function(t){return this.node.setAttribute("orient",this.orient=t),this},getOrient:function(){return this.orient},getWidth:function(){return+this.width},setHeight:function(t){return this.node.setAttribute("markerHeight",this.height=t),this},getHeight:function(){return+this.height}}),n=_p.r(46);return _p.r(11).extendClass(n,{setMarker:function(t,e){return e=e||"end",t?this.node.setAttribute("marker-"+e,t.toString()):this.node.removeAttribute("marker-"+e),this}}),e}},_p[42]={value:function(){var t=_p.r(11),e=_p.r(60),n=t.createClass("Mask",{base:e,mixins:[_p.r(61)],constructor:function(){this.callBase("mask")},mask:function(t){return t.getNode().setAttribute("mask","url(#"+this.getId()+")"),this}});return t.extendClass(e,{maskWith:function(t){return t.mask(this),this}}),n}},_p[43]={value:function(){function t(t,e){return{a:e.a*t.a+e.c*t.b,b:e.b*t.a+e.d*t.b,c:e.a*t.c+e.c*t.d,d:e.b*t.c+e.d*t.d,e:e.a*t.e+e.c*t.f+e.e,f:e.b*t.e+e.d*t.f+e.f}}function e(t){return t*Math.PI/180}var n=_p.r(12),i=_p.r(25),r=/matrix\s*\((.+)\)/i,o=_p.r(50),a=_p.r(11).createClass("Matrix",{constructor:function(){arguments.length?this.setMatrix.apply(this,arguments):this.setMatrix(1,0,0,1,0,0)},translate:function(e,n){return this.m=t(this.m,{a:1,c:0,e:e,b:0,d:1,f:n}),this},rotate:function(n){var i=e(n),r=Math.sin(i),o=Math.cos(i);return this.m=t(this.m,{a:o,c:-r,e:0,b:r,d:o,f:0}),this},scale:function(e,n){return void 0===n&&(n=e),this.m=t(this.m,{a:e,c:0,e:0,b:0,d:n,f:0}),this},skew:function(n,i){void 0===i&&(i=n);var r=Math.tan(e(n)),o=Math.tan(e(i));return this.m=t(this.m,{a:1,c:r,e:0,b:o,d:1,f:0}),this},inverse:function(){var t,e,n,i,r,o,s,l=this.m,u=l.a,c=l.b,h=l.c,d=l.d,f=l.e,p=l.f;return t=u*d-c*h,e=d/t,n=-c/t,i=-h/t,r=u/t,o=(h*p-f*d)/t,s=(c*f-u*p)/t,new a(e,n,i,r,o,s)},setMatrix:function(t,e,i,r,o,a){return this.m=1===arguments.length?n.clone(arguments[0]):{a:t,b:e,c:i,d:r,e:o,f:a},this},getMatrix:function(){return n.clone(this.m)},getTranslate:function(){var t=this.m;return{x:t.e/t.a,y:t.f/t.d}},mergeMatrix:function(e){return new a(t(this.m,e.m))},merge:function(t){return this.mergeMatrix(t)},toString:function(){return this.valueOf().join(" ")},valueOf:function(){var t=this.m;return[t.a,t.b,t.c,t.d,t.e,t.f]},equals:function(t){var e=this.m,n=t.m;return e.a==n.a&&e.b==n.b&&e.c==n.c&&e.d==n.d&&e.e==n.e&&e.f==n.f},transformPoint:function(){return a.transformPoint.apply(null,[].slice.call(arguments).concat([this.m]))},transformBox:function(t){return a.transformBox(t,this.m)},clone:function(){return new a(this.m)}});return a.parse=function(t){var e,n=parseFloat;if(t instanceof Array)return new a({a:t[0],b:t[1],c:t[2],d:t[3],e:t[4],f:t[5]});if(e=r.exec(t)){var i=e[1].split(",");return 6!=i.length&&(i=e[1].split(" ")),new a({a:n(i[0]),b:n(i[1]),c:n(i[2]),d:n(i[3]),e:n(i[4]),f:n(i[5])})}return new a},a.transformPoint=function(t,e,n){return 2===arguments.length&&(n=e,e=t.y,t=t.x),new o(n.a*t+n.c*e+n.e,n.b*t+n.d*e+n.f)},a.transformBox=function(t,e){for(var r,o,s=Number.MAX_VALUE,l=-Number.MAX_VALUE,u=Number.MAX_VALUE,c=-Number.MAX_VALUE,h=[[t.x,t.y],[t.x+t.width,t.y],[t.x,t.y+t.height],[t.x+t.width,t.y+t.height]],d=[];r=h.pop();)o=a.transformPoint(r[0],r[1],e),d.push(o),s=Math.min(s,o.x),l=Math.max(l,o.x),u=Math.min(u,o.y),c=Math.max(c,o.y);return t=new i({x:s,y:u,width:l-s,height:c-u}),n.extend(t,{closurePoints:d}),t},a.getCTM=function(t,e){function n(t,e){var n;try{n=e.getScreenCTM().inverse()}catch(i){throw new Error("Can not inverse source element' ctm.")}return n.multiply(t.getScreenCTM())}var i={a:1,b:0,c:0,d:1,e:0,f:0},r=t.shapeNode||t.node;switch(e=e||"parent"){case"screen":i=r.getScreenCTM();break;case"doc":case"paper":i=r.getCTM();break;case"view":case"top":t.getPaper()&&(i=void 0!==r.getTransformToElement?r.getTransformToElement(t.getPaper().shapeNode):n(r,t.getPaper().shapeNode));break;case"parent":t.node.parentNode&&(i=void 0!==r.getTransformToElement?r.getTransformToElement(t.node.parentNode):n(r,t.node.parentNode));break;default:e.node&&(i=void 0!==r.getTransformToElement?r.getTransformToElement(e.shapeNode||e.node):n(r,e.shapeNode||e.node))}return i?new a(i.a,i.b,i.c,i.d,i.e,i.f):new a},a}},_p[44]={value:function(){var t=_p.r(64),e=_p.r(28),n=_p.r(12),i=_p.r(11).createClass("Palette",{constructor:function(){this.color={}},get:function(n){var i=this.color[n]||t.EXTEND_STANDARD[n]||t.COLOR_STANDARD[n]||"";return i?new e(i):null},getColorValue:function(e){return this.color[e]||t.EXTEND_STANDARD[e]||t.COLOR_STANDARD[e]||""},add:function(t,n){return this.color[t]="string"==typeof n?new e(n).toRGBA():n.toRGBA(),n},remove:function(t){return this.color.hasOwnProperty(t)?(delete this.color[t],!0):!1}});return n.extend(i,{getColor:function(n){var i=t.EXTEND_STANDARD[n]||t.COLOR_STANDARD[n];return i?new e(i):null},getColorValue:function(e){return t.EXTEND_STANDARD[e]||t.COLOR_STANDARD[e]||""},addColor:function(n,i){return t.EXTEND_STANDARD[n]="string"==typeof i?new e(i).toRGBA():i.toRGBA(),i},removeColor:function(e){return t.EXTEND_STANDARD.hasOwnProperty(e)?(delete t.EXTEND_STANDARD[e],!0):!1}}),i}},_p[45]={value:function(){var t=_p.r(11),e=_p.r(12),n=_p.r(67),i=_p.r(29),r=_p.r(61),o=_p.r(75),a=_p.r(33),s=_p.r(66),l=_p.r(43),u=t.createClass("Paper",{mixins:[r,a,s,o],constructor:function(t){this.callBase(),this.node=this.createSVGNode(),this.node.paper=this,this.node.appendChild(this.resourceNode=n.createNode("defs")),this.node.appendChild(this.shapeNode=n.createNode("g")),this.resources=new i,this.setWidth("100%").setHeight("100%"),t&&this.renderTo(t),this.callMixin()},renderTo:function(t){e.isString(t)&&(t=document.getElementById(t)),this.container=t,t.appendChild(this.node)},createSVGNode:function(){var t=n.createNode("svg");return t.setAttribute("xmlns","http://www.w3.org/2000/svg"),t.setAttribute("xmlns:xlink","http://www.w3.org/1999/xlink"),t.setAttribute("version","1.1"),t},getNode:function(){return this.node},getContainer:function(){return this.container},getWidth:function(){return this.node.clientWidth},setWidth:function(t){return this.node.setAttribute("width",t),this},getHeight:function(){return this.node.clientHeight},setHeight:function(t){return this.node.setAttribute("height",t),this},setViewPort:function(t,e,n){var i,r;1==arguments.length&&(i=arguments[0],t=i.center.x,e=i.center.y,n=i.zoom),n=n||1,r=this.getViewBox();var o=new l,a=r.x+r.width/2-t,s=r.y+r.height/2-e;return o.translate(-t,-e),o.scale(n),o.translate(t,e),o.translate(a,s),this.shapeNode.setAttribute("transform","matrix("+o+")"),this.viewport={center:{x:t,y:e},offset:{x:a,y:s},zoom:n},this},getViewPort:function(){if(!this.viewport){var t=this.getViewBox();return{zoom:1,center:{x:t.x+t.width/2,y:t.y+t.height/2},offset:{x:0,y:0}}}return this.viewport},getViewPortMatrix:function(){return l.parse(this.shapeNode.getAttribute("transform"))},getViewPortTransform:function(){var t=this.shapeNode.getCTM();return new l(t.a,t.b,t.c,t.d,t.e,t.f)},getTransform:function(){return this.getViewPortTransform().reverse()},addResource:function(t){return this.resources.appendItem(t),t.node&&this.resourceNode.appendChild(t.node),this},removeResource:function(t){return t.remove&&t.remove(),t.node&&this.resourceNode.removeChild(t.node),this},getPaper:function(){return this}}),c=_p.r(60);return t.extendClass(c,{getPaper:function(){for(var t=this.container;t&&t instanceof u==!1;)t=t.container;return t},isAttached:function(){return!!this.getPaper()},whenPaperReady:function(t){function e(){var e=n.getPaper();return e&&t&&t.call(n,e),e}var n=this;return e()||this.on("add treeadd",function i(){e()&&(n.off("add",i),n.off("treeadd",i))}),this}}),u}},_p[46]={value:function(){var t=_p.r(12),e=_p.r(11).createClass,n=_p.r(60),i=_p.r(67),r=_p.r(34),o=Array.prototype.slice,a=(t.flatten,e("PathDrawer",{constructor:function(t){this.segment=[],this.path=t,this.__clear=!1},getPath:function(){return this.path},redraw:function(){return this._transation=this._transation||[],this.clear()},done:function(){var t=this._transation;return this._transation=null,this.push(t),this},clear:function(){return this._transation?this._transation=[]:this.path.setPathData("M 0 0"),this._clear=!0,this},push:function(){var t,e=o.call(arguments);return this._transation?(this._transation.push(e),this):(this._clear?(t="",this._clear=!1):t=this.path.getPathData(),t=t||"",this.path.setPathData(t+r.pathToString(e)),this)},moveTo:function(){return this.push("M",o.call(arguments))},moveBy:function(){return this.push("m",o.call(arguments))},lineTo:function(){return this.push("L",o.call(arguments))},lineBy:function(){return this.push("l",o.call(arguments))},arcTo:function(){return this.push("A",o.call(arguments))},arcBy:function(){return this.push("a",arguments)},carcTo:function(t){return this.push("A",[t,t,0].concat(o.call(arguments,1)))},carcBy:function(t){return this.push("a",[t,t,0].concat(o.call(arguments,1)))},bezierTo:function(){return this.push("C",o.call(arguments))},bezierBy:function(){return this.push("c",o.call(arguments))},close:function(){return this.push("z")}}));return e("Path",{base:n,constructor:function(t){this.callBase("path"),t&&this.setPathData(t),this.node.setAttribute("fill",i.defaults.fill),this.node.setAttribute("stroke",i.defaults.stroke)},setPathData:function(t){return t=t||"M0,0",this.pathdata=r.pathToString(t),this.node.setAttribute("d",this.pathdata),this.trigger("shapeupdate",{type:"pathdata"}),this},getPathData:function(){return this.pathdata||""},getDrawer:function(){return new a(this)},isClosed:function(){var t=this.getPathData();return!!~t.indexOf("z")||!!~t.indexOf("Z")}})}},_p[47]={value:function(){{var t=_p.r(58),e=_p.r(61);_p.r(67)}return _p.r(11).createClass("PatternBrush",{base:t,mixins:[e],constructor:function(t){this.callBase("pattern",t),this.node.setAttribute("patternUnits","userSpaceOnUse")},setX:function(t){return this.x=t,this.node.setAttribute("x",t),this},setY:function(t){return this.y=t,this.node.setAttribute("y",t),this},setWidth:function(t){return this.width=t,this.node.setAttribute("width",t),this},setHeight:function(t){return this.height=t,this.node.setAttribute("height",t),this},getWidth:function(){return this.width},getHeight:function(){return this.height}})}},_p[48]={value:function(){var t=_p.r(28);return _p.r(11).createClass("Pen",{constructor:function(t,e){this.brush=t,this.width=e||1,this.linecap=null,this.linejoin=null,this.dashArray=null,this.opacity=1},getBrush:function(){return this.brush},setBrush:function(t){return this.brush=t,this},setColor:function(t){return this.setBrush(t)},getColor:function(){return this.brush instanceof t?this.brush:null},getWidth:function(){return this.width},setWidth:function(t){return this.width=t,this},getOpacity:function(){return this.opacity},setOpacity:function(t){this.opacity=t},getLineCap:function(){return this.linecap},setLineCap:function(t){return this.linecap=t,this},getLineJoin:function(){return this.linejoin},setLineJoin:function(t){return this.linejoin=t,this},getDashArray:function(){return this.dashArray},setDashArray:function(t){return this.dashArray=t,this},stroke:function(t){var e=t.node;e.setAttribute("stroke",this.brush.toString()),e.setAttribute("stroke-width",this.getWidth()),this.getOpacity()<1&&e.setAttribute("stroke-opacity",this.getOpacity()),this.getLineCap()&&e.setAttribute("stroke-linecap",this.getLineCap()),this.getLineJoin()&&e.setAttribute("stroke-linejoin",this.getLineJoin()),this.getDashArray()&&e.setAttribute("stroke-dasharray",this.getDashArray())}})}},_p[49]={value:function(){return _p.r(11).createClass({base:_p.r(68),constructor:function(t,e,n){this.callBase([0,t],e,n)},getRadius:function(){return this.getSectionArray()[1]},setRadius:function(t){this.setSectionArray([0,t])}})}},_p[50]={value:function(){var t=_p.r(11).createClass("Point",{constructor:function(t,e){this.x=t||0,this.y=e||0},offset:function(e,n){return 1==arguments.length&&(n=e.y,e=e.x),new t(this.x+e,this.y+n)},valueOf:function(){return[this.x,this.y]},toString:function(){return this.valueOf().join(" ")},spof:function(){return new t((0|this.x)+.5,(0|this.y)+.5)},round:function(){return new t(0|this.x,0|this.y)},isOrigin:function(){return 0===this.x&&0===this.y}});return t.fromPolar=function(e,n,i){return"rad"!=i&&(n=n/180*Math.PI),new t(e*Math.cos(n),e*Math.sin(n))},t.parse=function(e){return e?e instanceof t?e:"string"==typeof e?t.parse(e.split(/\s*[\s,]\s*/)):"0"in e&&"1"in e?new t(e[0],e[1]):void 0:new t},t}},_p[51]={value:function(){return _p.r(11).createClass("PointContainer",{base:_p.r(29),constructor:function(){this.callBase()},addPoint:function(){return this.addItem.apply(this,arguments)},prependPoint:function(){return this.prependItem.apply(this,arguments)},appendPoint:function(){return this.appendItem.apply(this,arguments)},removePoint:function(){return this.removeItem.apply(this,arguments)},addPoints:function(){return this.addItems.apply(this,arguments)},setPoints:function(){return this.setItems.apply(this,arguments)},getPoint:function(){return this.getItem.apply(this,arguments)},getPoints:function(){return this.getItems.apply(this,arguments)},getFirstPoint:function(){return this.getFirstItem.apply(this,arguments)},getLastPoint:function(){return this.getLastItem.apply(this,arguments)}})}},_p[52]={value:function(){_p.r(12);return _p.r(11).createClass("Poly",{base:_p.r(46),mixins:[_p.r(51)],constructor:function(t,e){this.callBase(),this.closeable=!!e,this.setPoints(t||[]),this.changeable=!0,this.update()},onContainerChanged:function(){this.changeable&&this.update()},update:function(){var t=this.getDrawer(),e=this.getPoints();if(t.clear(),!e.length)return this;t.moveTo(e[0]);for(var n,i=1,r=e.length;r>i;i++)n=e[i],t.lineTo(n);return this.closeable&&e.length>2&&t.close(),this}})}},_p[53]={value:function(){return _p.r(11).createClass("Polygon",{base:_p.r(52),constructor:function(t){this.callBase(t,!0)}})}},_p[54]={value:function(){return _p.r(11).createClass("Polyline",{base:_p.r(52),constructor:function(t){this.callBase(t)}})}},_p[55]={value:function(){var t=_p.r(35);return _p.r(11).createClass("RadialGradientBrush",{base:t,constructor:function(t){this.callBase("radialGradient",t),this.setCenter(.5,.5),this.setFocal(.5,.5),this.setRadius(.5)},setCenter:function(t,e){return this.node.setAttribute("cx",t),this.node.setAttribute("cy",e),this},getCenter:function(){return{x:+this.node.getAttribute("cx"),y:+this.node.getAttribute("cy")}},setFocal:function(t,e){return this.node.setAttribute("fx",t),this.node.setAttribute("fy",e),this},getFocal:function(){return{x:+this.node.getAttribute("fx"),y:+this.node.getAttribute("fy")}},setRadius:function(t){return this.node.setAttribute("r",t),this},getRadius:function(){return+this.node.getAttribute("r")}})}},_p[56]={value:function(){var t={},e=_p.r(12),n=_p.r(50),i=_p.r(25);e.extend(t,{formatRadius:function(t,e,n){var i=Math.floor(Math.min(t/2,e/2));return Math.min(i,n)}});var r=_p.r(11).createClass("Rect",{base:_p.r(46),constructor:function(e,n,i,r,o){this.callBase(),this.x=i||0,this.y=r||0,this.width=e||0,this.height=n||0,this.radius=t.formatRadius(this.width,this.height,o||0),this.update()},update:function(){var t=this.x,e=this.y,n=this.width,i=this.height,r=this.radius,o=this.getDrawer().redraw();return r?(n-=2*r,i-=2*r,o.push("M",t+r,e),o.push("h",n),o.push("a",r,r,0,0,1,r,r),o.push("v",i),o.push("a",r,r,0,0,1,-r,r),o.push("h",-n),o.push("a",r,r,0,0,1,-r,-r),o.push("v",-i),o.push("a",r,r,0,0,1,r,-r),o.push("z")):(o.push("M",t,e),o.push("h",n),o.push("v",i),o.push("h",-n),o.push("z")),o.done(),this},setWidth:function(t){return this.width=t,this.update()},setHeight:function(t){return this.height=t,this.update()},setSize:function(t,e){return this.width=t,this.height=e,this.update()},setBox:function(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this.update()},getBox:function(){return new i(this.x,this.y,this.width,this.height)},getRadius:function(){return this.radius},setRadius:function(e){return this.radius=t.formatRadius(this.width,this.height,e||0),this.update()},getPosition:function(){return new n(this.x,this.y)},setPosition:function(t,e){if(1==arguments.length){var i=n.parse(arguments[0]);e=i.y,t=i.x}return this.x=t,this.y=e,this.update()},getWidth:function(){return this.width},getHeight:function(){return this.height},getPositionX:function(){return this.x},getPositionY:function(){return this.y},setPositionX:function(t){return this.x=t,this.update()},setPositionY:function(t){return this.y=t,this.update()}});return r}},_p[57]={value:function(){var t=_p.r(50);return _p.r(11).createClass("RegularPolygon",{base:_p.r(46),constructor:function(e,n,i,r){this.callBase(),this.radius=n||0,this.side=Math.max(e||3,3),arguments.length>2&&3==arguments.length&&(r=i.y,i=i.x),this.center=new t(i,r),this.draw()},getSide:function(){return this.side},setSide:function(t){return this.side=t,this.draw()},getRadius:function(){return this.radius},setRadius:function(t){return this.radius=t,this.draw()},draw:function(){var e,n=this.radius,i=this.side,r=2*Math.PI/i,o=this.getDrawer();for(o.clear(),o.moveTo(t.fromPolar(n,Math.PI/2,"rad").offset(this.center)),e=0;i>=e;e++)o.lineTo(t.fromPolar(n,r*e+Math.PI/2,"rad").offset(this.center));return o.close(),this}})}},_p[58]={value:function(){var t=_p.r(67);return _p.r(11).createClass("Resource",{constructor:function(e,n){this.callBase(),this.node=t.createNode(e),n&&n.addResource(this)},toString:function(){return"url(#"+this.node.id+")"}})}},_p[59]={value:function(){return _p.r(11).createClass({base:_p.r(68),constructor:function(t,e){this.callBase([t,e],360,0)},getInnerRadius:function(){return this.getSectionArray()[0]},getOuterRadius:function(){return this.getSectionArray()[1]},setInnerRadius:function(t){this.setSectionArray([t,this.getOuterRadius()])},setOuterRadius:function(t){this.setSectionArray([this.getInnerRadius(),t])}})}},_p[60]={value:function(){var t=_p.r(67),e=_p.r(12),n=_p.r(33),i=_p.r(66),r=_p.r(31),o=_p.r(43),a=(_p.r(48),Array.prototype.slice),s=_p.r(25),l=_p.r(11).createClass("Shape",{mixins:[n,i,r],constructor:function(e){this.node=t.createNode(e),this.node.shape=this,this.transform={translate:null,rotate:null,scale:null,matrix:null},this.callMixin()},getId:function(){return this.node.id},setId:function(t){return this.node.id=t,this},getNode:function(){return this.node},getBoundaryBox:function(){var t;try{t=this.node.getBBox()}catch(e){t={x:this.node.clientLeft,y:this.node.clientTop,width:this.node.clientWidth,height:this.node.clientHeight}}return new s(t)},getRenderBox:function(t){var e=this.getBoundaryBox(),n=this.getTransform(t);return n.transformBox(e)},getWidth:function(){return this.getRenderBox().width},getHeight:function(){return this.getRenderBox().height},getSize:function(){var t=this.getRenderBox();return delete t.x,delete t.y,t},setOpacity:function(t){return this.node.setAttribute("opacity",t),this},getOpacity:function(){var t=this.node.getAttribute("opacity");return t?+t:1},setVisible:function(t){return t?this.node.removeAttribute("display"):this.node.setAttribute("display","none"),this},getVisible:function(){this.node.getAttribute("display")},hasAncestor:function(t){for(var e=this.container;e;){if(e===t)return!0;e=e.container}return!1},getTransform:function(t){return o.getCTM(this,t)},clearTransform:function(){return this.node.removeAttribute("transform"),this.transform={translate:null,rotate:null,scale:null,matrix:null},this.trigger("shapeupdate",{type:"transform"}),this},_applyTransform:function(){var t=this.transform,n=[];return t.translate&&n.push(["translate(",t.translate,")"]),t.rotate&&n.push(["rotate(",t.rotate,")"]),t.scale&&n.push(["scale(",t.scale,")"]),t.matrix&&n.push(["matrix(",t.matrix,")"]),this.node.setAttribute("transform",e.flatten(n).join(" ")),this},setMatrix:function(t){return this.transform.matrix=t,this._applyTransform()},setTranslate:function(t){return this.transform.translate=null!==t&&a.call(arguments)||null,this._applyTransform()},setRotate:function(t){return this.transform.rotate=null!==t&&a.call(arguments)||null,this._applyTransform()},setScale:function(t){return this.transform.scale=null!==t&&a.call(arguments)||null,this._applyTransform()},translate:function(t,e){var n=this.transform.matrix||new o;return void 0===e&&(e=0),this.transform.matrix=n.translate(t,e),this._applyTransform()},rotate:function(t){var e=this.transform.matrix||new o;return this.transform.matrix=e.rotate(t),this._applyTransform()},scale:function(t,e){var n=this.transform.matrix||new o;return void 0===e&&(e=t),this.transform.matrix=n.scale(t,e),this._applyTransform()},skew:function(t,e){var n=this.transform.matrix||new o;return void 0===e&&(e=t),this.transform.matrix=n.skew(t,e),this._applyTransform()},stroke:function(t,e){return t&&t.stroke?t.stroke(this):t?(this.node.setAttribute("stroke",t.toString()),e&&this.node.setAttribute("stroke-width",e)):null===t&&this.node.removeAttribute("stroe"),this},fill:function(t){return t&&this.node.setAttribute("fill",t.toString()),null===t&&this.node.removeAttribute("fill"),this},setAttr:function(t,n){var i=this;return e.isObject(t)&&e.each(t,function(t,e){i.setAttr(e,t)}),void 0===n||null===n||""===n?this.node.removeAttribute(t):this.node.setAttribute(t,n),this},getAttr:function(t){return this.node.getAttribute(t)}});return l}},_p[61]={value:function(){var t=_p.r(29),e=_p.r(12),n=_p.r(11).createClass("ShapeContainer",{base:t,isShapeContainer:!0,handleAdd:function(t,e){var n=this.getShapeNode();n.insertBefore(t.node,n.childNodes[e]||null),t.trigger("add",{container:this}),t.notifyTreeModification&&t.notifyTreeModification("treeadd",this)},handleRemove:function(t){var e=this.getShapeNode();e.removeChild(t.node),t.trigger("remove",{container:this}),t.notifyTreeModification&&t.notifyTreeModification("treeremove",this)},notifyTreeModification:function(t,e){this.eachItem(function(n,i){i.notifyTreeModification&&i.notifyTreeModification(t,e),i.trigger(t,{container:e})})},getShape:function(t){return this.getItem(t)},addShape:function(t,e){return this.addItem(t,e)},put:function(t){return this.addShape(t),t},appendShape:function(t){return this.addShape(t)},prependShape:function(t){return this.addShape(t,0)},replaceShape:function(t,e){var n=this.indexOf(e);if(-1!==n)return this.removeShape(n),this.addShape(t,n),this},addShapeBefore:function(t,e){var n=this.indexOf(e);return this.addShape(t,n)},addShapeAfter:function(t,e){var n=this.indexOf(e);return this.addShape(t,-1===n?void 0:n+1)},addShapes:function(t){return this.addItems(t)},removeShape:function(t){return this.removeItem(t)},getShapes:function(){return this.getItems()},getShapesByType:function(t){function n(r){t.toLowerCase()==r.getType().toLowerCase()&&i.push(r),r.isShapeContainer&&e.each(r.getShapes(),function(t){n(t)})}var i=[];return n(this),i},getShapeById:function(t){return this.getShapeNode().getElementById(t).shape},arrangeShape:function(t,e){return this.removeShape(t).addShape(t,e)},getShapeNode:function(){return this.shapeNode||this.node}}),i=_p.r(60);return _p.r(11).extendClass(i,{bringTo:function(t){return this.container.arrangeShape(this,t),this},bringFront:function(){return this.bringTo(this.container.indexOf(this)+1)},bringBack:function(){return this.bringTo(this.container.indexOf(this)-1)},bringTop:function(){return this.container.removeShape(this).addShape(this),this},bringRear:function(){return this.bringTo(0)},bringRefer:function(t,e){return t.container&&(this.remove&&this.remove(),t.container.addShape(this,t.container.indexOf(t)+(e||0))),this},bringAbove:function(t){return this.bringRefer(t)},bringBelow:function(t){return this.bringRefer(t,1)},replaceBy:function(t){return this.container&&(t.bringAbove(this),this.remove()),this}}),n}},_p[62]={value:function(){var t=_p.r(43),e=_p.r(12),n=_p.r(50);return _p.r(11).createClass("ShapeEvent",{constructor:function(t){var n=null;e.isObject(t.target)?e.extend(this,t):(this.type=t.type,n=t.target,n.correspondingUseElement&&(n=n.correspondingUseElement),this.originEvent=t,this.targetShape=n.shape||n.paper||t.currentTarget&&(t.currentTarget.shape||t.currentTarget.paper),t._kityParam&&e.extend(this,t._kityParam))},preventDefault:function(){var t=this.originEvent;return t?t.preventDefault?(t.preventDefault(),t.cancelable):(t.returnValue=!1,!0):!0},getPosition:function(e,i){if(!this.originEvent)return null;var r=this.originEvent.touches?this.originEvent.touches[i||0]:this.originEvent,o=this.targetShape,a=o.shapeNode||o.node,s=new n(r&&r.clientX||0,r&&r.clientY||0),l=t.transformPoint(s,a.getScreenCTM().inverse()),u=t.getCTM(o,e||"view").transformPoint(l);return u},stopPropagation:function(){var t=this.originEvent;return t?void(t.stopPropagation?t.stopPropagation():t.cancelBubble=!1):!0}})}},_p[63]={value:function(){return _p.r(11).createClass("ShapePoint",{base:_p.r(50),constructor:function(t,e){this.callBase(t,e)},setX:function(t){return this.setPoint(t,this.y)},setY:function(t){return this.setPoint(this.x,t)},setPoint:function(t,e){return this.x=t,this.y=e,this.update(),this},getPoint:function(){return this},update:function(){return this.container&&this.container.update&&this.container.update(),this}})}},_p[64]={value:{COLOR_STANDARD:{aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00"},EXTEND_STANDARD:{}}},_p[65]={value:function(){var t={3:.2,5:.38196601125,6:.57735026919,8:.541196100146,10:.726542528005,12:.707106781187},e=_p.r(50); return _p.r(11).createClass("Star",{base:_p.r(46),constructor:function(t,n,i,r,o){this.callBase(),this.vertex=t||3,this.radius=n||0,this.shrink=i,this.offset=r||new e(0,0),this.angleOffset=o||0,this.draw()},getVertex:function(){return this.vertex},setVertex:function(t){return this.vertex=t,this.draw()},getRadius:function(){return this.radius},setRadius:function(t){return this.radius=t,this.draw()},getShrink:function(){return this.shrink},setShrink:function(t){return this.shrink=t,this.draw()},getOffset:function(){return this.offset},setOffset:function(t){return this.offset=t,this.draw()},getAngleOffset:function(){return this.angleOffset},setAngleOffset:function(t){return this.angleOffset=t,this.draw()},draw:function(){var n,i,r=this.radius,o=this.radius*(this.shrink||t[this.vertex]||.5),a=this.vertex,s=this.offset,l=90,u=180/a,c=this.angleOffset,h=this.getDrawer();for(h.clear(),h.moveTo(e.fromPolar(o,l)),n=1;2*a>=n;n++)i=l+u*n,h.lineTo(n%2?e.fromPolar(r,i+c).offset(s):e.fromPolar(o,i));h.close()}})}},_p[66]={value:function(){function t(t){return t.classList||(t.classList=new e(t)),t.classList}var e=_p.r(11).createClass("ClassList",{constructor:function(t){this._node=t,this._list=t.className.toString().split(" ")},_update:function(){this._node.className=this._list.join(" ")},add:function(t){this._list.push(t),this._update()},remove:function(t){var e=this._list.indexOf(t);~e&&this._list.splice(e,1),this._update()},contains:function(t){return!!~this._list.indexOf(t)}});return _p.r(11).createClass("Styled",{addClass:function(e){return t(this.node).add(e),this},removeClass:function(e){return t(this.node).remove(e),this},hasClass:function(e){return t(this.node).contains(e)},setStyle:function(t){if(2==arguments.length)return this.node.style[arguments[0]]=arguments[1],this;for(var e in t)t.hasOwnProperty(e)&&(this.node.style[e]=t[e]);return this}})}},_p[67]={value:function(){var t=document,e=0,n={createNode:function(i){var r=t.createElementNS(n.ns,i);return r.id="kity_"+i+"_"+e++,r},defaults:{stroke:"none",fill:"none"},xlink:"http://www.w3.org/1999/xlink",ns:"http://www.w3.org/2000/svg"};return n}},_p[68]={value:function(){var t=_p.r(50);return _p.r(11).createClass("Sweep",{base:_p.r(46),constructor:function(t,e,n){this.callBase(),this.sectionArray=t||[],this.angle=e||0,this.angleOffset=n||0,this.draw()},getSectionArray:function(){return this.sectionArray},setSectionArray:function(t){return this.sectionArray=t,this.draw()},getAngle:function(){return this.angle},setAngle:function(t){return this.angle=t,this.draw()},getAngleOffset:function(){return this.angleOffset},setAngleOffset:function(t){return this.angleOffset=t,this.draw()},draw:function(){var t,e=this.sectionArray;for(t=0;ti?0:1,l=this.getDrawer();return l.redraw(),0===i?void l.done():(l.moveTo(t.fromPolar(e,r)),l.lineTo(t.fromPolar(n,r)),n&&(l.carcTo(n,0,s,t.fromPolar(n,o)),l.carcTo(n,0,s,t.fromPolar(n,a))),l.lineTo(t.fromPolar(e,a)),e&&(l.carcTo(e,0,s,t.fromPolar(e,o)),l.carcTo(e,0,s,t.fromPolar(e,r))),l.close(),void l.done())}})}},_p[69]={value:function(){function t(t){var e=t._cachedFontHash;if(o[e])return o[e];var n=t.getContent();t.setContent("百度Fex");var i=t.getBoundaryBox(),r=t.getY(),a=r-i.y+ +t.node.getAttribute("dy"),s=a-i.height;return t.setContent(n),o[e]={top:a,bottom:s,middle:(a+s)/2}}var e=_p.r(70),n=_p.r(61),i=_p.r(67),r=_p.r(12),o={};return _p.r(11).createClass("Text",{base:e,mixins:[n],constructor:function(t){this.callBase("text"),void 0!==t&&this.setContent(t),this._buildFontHash()},_buildFontHash:function(){var t=window.getComputedStyle(this.node);this._cachedFontHash=[t.fontFamily,t.fontSize,t.fontStretch,t.fontStyle,t.fontVariant,t.fontWeight].join("-")},_fontChanged:function(t){var e=this._lastFont,n=r.extend({},e,t);if(!e)return this._lastFont=t,!0;var i=e.family!=n.family||e.size!=n.size||e.style!=n.style||e.weight!=n.weight;return this._lastFont=n,i},setX:function(t){return this.node.setAttribute("x",t),this},setPosition:function(t,e){return this.setX(t).setY(e)},setY:function(t){return this.node.setAttribute("y",t),this},getX:function(){return+this.node.getAttribute("x")||0},getY:function(){return+this.node.getAttribute("y")||0},setFont:function(t){return this.callBase(t),this._fontChanged(t)&&(this._buildFontHash(),this.setVerticalAlign(this.getVerticalAlign())),this},setTextAnchor:function(t){return this.node.setAttribute("text-anchor",t),this},getTextAnchor:function(){return this.node.getAttribute("text-anchor")||"start"},setVerticalAlign:function(e){return this.whenPaperReady(function(){var n;switch(e){case"top":n=t(this).top;break;case"bottom":n=t(this).bottom;break;case"middle":n=t(this).middle;break;default:n=0}this.node.setAttribute("dy",n)}),this.verticalAlign=e,this},getVerticalAlign:function(){return this.verticalAlign||"baseline"},setStartOffset:function(t){this.shapeNode!=this.node&&this.shapeNode.setAttribute("startOffset",100*t+"%")},addSpan:function(t){return this.addShape(t),this},setPath:function(t){var e=this.shapeNode;if(this.shapeNode==this.node){for(e=this.shapeNode=i.createNode("textPath");this.node.firstChild;)this.shapeNode.appendChild(this.node.firstChild);this.node.appendChild(e)}return e.setAttributeNS(i.xlink,"xlink:href","#"+t.node.id),this.setTextAnchor(this.getTextAnchor()),this}})}},_p[70]={value:function(){var t=_p.r(60);return _p.r(11).createClass("TextContent",{base:t,constructor:function(t){this.callBase(t),this.shapeNode=this.shapeNode||this.node,this.shapeNode.setAttribute("text-rendering","geometricPrecision")},clearContent:function(){for(;this.shapeNode.firstChild;)this.shapeNode.removeChild(this.shapeNode.firstChild);return this},setContent:function(t){return this.shapeNode.textContent=t,this},getContent:function(){return this.shapeNode.textContent},appendContent:function(t){return this.shapeNode.textContent+=t,this},setSize:function(t){return this.setFontSize(t)},setFontSize:function(t){return this.setFont({size:t})},setFontFamily:function(t){return this.setFont({family:t})},setFontBold:function(t){return this.setFont({weight:t?"bold":"normal"})},setFontItalic:function(t){return this.setFont({style:t?"italic":"normal"})},setFont:function(t){var e=this.node;return["family","size","weight","style"].forEach(function(n){null===t[n]?e.removeAttribute("font-"+n):t[n]&&e.setAttribute("font-"+n,t[n])}),this},getExtentOfChar:function(t){return this.node.getExtentOfChar(t)},getRotationOfChar:function(t){return this.node.getRotationOfChar(t)},getCharNumAtPosition:function(t,e){return this.node.getCharNumAtPosition(this.node.viewportElement.createSVGPoint(t,e))}})}},_p[71]={value:function(){var t=_p.r(70),e=_p.r(66);return _p.r(11).createClass("TextSpan",{base:t,mixins:[e],constructor:function(t){this.callBase("tspan"),this.setContent(t)}})}},_p[72]={value:function(){var t=_p.r(67),e=_p.r(11),n=e.createClass("Use",{base:_p.r(60),constructor:function(t){this.callBase("use"),this.ref(t)},ref:function(e){if(!e)return this.node.removeAttributeNS(t.xlink,"xlink:href"),this;var n=e.getId();return n&&this.node.setAttributeNS(t.xlink,"xlink:href","#"+n),"none"===e.node.getAttribute("fill")&&e.node.removeAttribute("fill"),"none"===e.node.getAttribute("stroke")&&e.node.removeAttribute("stroke"),this}}),i=_p.r(60);return e.extendClass(i,{use:function(){return new n(this)}}),n}},_p[73]={value:function(){var t=_p.r(50),e=_p.r(43),n=_p.r(11).createClass("Vector",{base:t,constructor:function(t,e){this.callBase(t,e)},square:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.square())},add:function(t){return new n(this.x+t.x,this.y+t.y)},minus:function(t){return new n(this.x-t.x,this.y-t.y)},dot:function(t){return this.x*t.x+this.y*t.y},project:function(t){return t.multipy(this.dot(t)/t.square())},normalize:function(t){return void 0===t&&(t=1),this.multipy(t/this.length())},multipy:function(t){return new n(this.x*t,this.y*t)},rotate:function(t,i){"rad"==i&&(t=t/Math.PI*180);var r=(new e).rotate(t).transformPoint(this);return new n(r.x,r.y)},vertical:function(){return new n(this.y,-this.x)},reverse:function(){return this.multipy(-1)},getAngle:function(){var t=this.length();if(0===t)return 0;var e=Math.acos(this.x/t),n=this.y>0?1:-1;return 180*n*e/Math.PI}});return n.fromPoints=function(t,e){return new n(e.x-t.x,e.y-t.y)},n.fromPolar=function(){var e=t.fromPolar.apply(t,arguments);return new n(e.x,e.y)},_p.r(11).extendClass(t,{asVector:function(){return new n(this.x,this.y)}}),n}},_p[74]={value:function(){var t=_p.r(61),e=_p.r(75);return _p.r(11).createClass("View",{mixins:[t,e],base:_p.r(74),constructor:function(){this.callBase("view")}})}},_p[75]={value:function(){return _p.r(11).createClass("ViewBox",{getViewBox:function(){var t=this.node.getAttribute("viewBox");return null===t?{x:0,y:0,width:this.node.clientWidth||this.node.parentNode.clientWidth,height:this.node.clientHeight||this.node.parentNode.clientHeight}:(t=t.split(" "),{x:+t[0],y:+t[1],width:+t[2],height:+t[3]})},setViewBox:function(t,e,n,i){return this.node.setAttribute("viewBox",[t,e,n,i].join(" ")),this}})}},_p[76]={value:function(){var t={},e=_p.r(12);return t.version="2.0.0",e.extend(t,{createClass:_p.r(11).createClass,extendClass:_p.r(11).extendClass,Utils:e,Browser:_p.r(10),Box:_p.r(25),Bezier:_p.r(23),BezierPoint:_p.r(24),Circle:_p.r(26),Clip:_p.r(27),Color:_p.r(28),Container:_p.r(29),Curve:_p.r(30),Ellipse:_p.r(32),Group:_p.r(36),Gradient:_p.r(35),HyperLink:_p.r(37),Image:_p.r(38),Line:_p.r(39),LinearGradient:_p.r(40),Mask:_p.r(42),Matrix:_p.r(43),Marker:_p.r(41),Palette:_p.r(44),Paper:_p.r(45),Path:_p.r(46),Pattern:_p.r(47),Pen:_p.r(48),Point:_p.r(50),PointContainer:_p.r(51),Polygon:_p.r(53),Polyline:_p.r(54),Pie:_p.r(49),RadialGradient:_p.r(55),Resource:_p.r(58),Rect:_p.r(56),RegularPolygon:_p.r(57),Ring:_p.r(59),Shape:_p.r(60),ShapePoint:_p.r(63),ShapeContainer:_p.r(61),Sweep:_p.r(68),Star:_p.r(65),Text:_p.r(69),TextSpan:_p.r(71),Use:_p.r(72),Vector:_p.r(73),g:_p.r(34),Animator:_p.r(0),Easing:_p.r(1),OpacityAnimator:_p.r(4),RotateAnimator:_p.r(6),ScaleAnimator:_p.r(7),Timeline:_p.r(8),TranslateAnimator:_p.r(9),PathAnimator:_p.r(5),MotionAnimator:_p.r(3),requestFrame:_p.r(2).requestFrame,releaseFrame:_p.r(2).releaseFrame,Filter:_p.r(20),GaussianblurFilter:_p.r(21),ProjectionFilter:_p.r(22),ColorMatrixEffect:_p.r(13),CompositeEffect:_p.r(14),ConvolveMatrixEffect:_p.r(15),Effect:_p.r(16),GaussianblurEffect:_p.r(17),OffsetEffect:_p.r(18)}),window.kity=t}};var moduleMapping={kity:76};use("kity")}();var KityMinder=window.KM=window.KityMinder=function(){var t={},e=0,n={};return{version:"1.3.5",uuid:function(t){return t=t||"unknown",n[t]=n[t]||0,++n[t],t+"_"+n[t]},createMinder:function(t,e){e=e||{},e.renderTo=Utils.isString(t)?document.getElementById(t):t;var n=new Minder(e);return this.addMinder(e.renderTo,n),n},addMinder:function(n,i){var r;r="string"==typeof n?n:n.id||"KM_INSTANCE_"+e++,t[r]=i},getMinder:function(n,i){var r;return r="string"==typeof n?n:n.id||"KM_INSTANCE_"+e++,t[r]||this.createMinder(n,i)},LANG:{}}}(),utils=Utils=KityMinder.Utils={extend:kity.Utils.extend.bind(kity.Utils),listen:function(t,e,n){var i=utils.isArray(e)?e:utils.trim(e).split(/\s+/),r=i.length;if(r)for(;r--;)if(e=i[r],t.addEventListener)t.addEventListener(e,n,!1);else{n._d||(n._d={els:[]});var o=e+n.toString(),a=utils.indexOf(n._d.els,t);n._d[o]&&-1!=a||(-1==a&&n._d.els.push(t),n._d[o]||(n._d[o]=function(t){return n.call(t.srcElement,t||window.event)}),t.attachEvent("on"+e,n._d[o]))}t=null},trim:function(t){return t.replace(/(^[ \t\n\r]+)|([ \t\n\r]+$)/g,"")},each:function(t,e,n){if(null!=t)if(t.length===+t.length){for(var i=0,r=t.length;r>i;i++)if(e.call(n,i,t[i],t)===!1)return!1}else for(var o in t)if(t.hasOwnProperty(o)&&e.call(n,o,t[o],t)===!1)return!1},addCssRule:function(t,e,n){var i;return void 0===e||e&&e.nodeType&&9==e.nodeType?(n=e&&e.nodeType&&9==e.nodeType?e:n||document,i=n.getElementById(t),i?i.innerHTML:void 0):(n=n||document,i=n.getElementById(t),""===e?i?(i.parentNode.removeChild(i),!0):!1:void(i?i.innerHTML=e:(i=n.createElement("style"),i.id=t,i.innerHTML=e,n.getElementsByTagName("head")[0].appendChild(i))))},keys:function(t){var e=[];for(var n in t)t.hasOwnProperty(n)&&e.push(n);return e},proxy:function(t,e){return function(){return t.apply(e,arguments)}},indexOf:function(t,e,n){var i=-1;return n=this.isNumber(n)?n:0,this.each(t,function(t,r){return r>=n&&t===e?(i=r,!1):void 0}),i},argsToArray:function(t,e){return Array.prototype.slice.call(t,e||0)},clonePlainObject:function(t,e){var n;e=e||{};for(var i in t)t.hasOwnProperty(i)&&(n=t[i],utils.isObject(n)||utils.isArray(n)?(e[i]=utils.isArray(n)?[]:{},utils.clonePlainObject(t[i],e[i])):e[i]=n);return e},compareObject:function(t,e){var n;if(this.isEmptyObject(t)!==this.isEmptyObject(e))return!1;if(this.getObjectLength(t)!=this.getObjectLength(e))return!1;for(var i in t)if(t.hasOwnProperty(i)){if(n=t[i],void 0===e[i])return!1;if(this.isObject(n)||this.isArray(n)){if(this.isObject(e[i])!==this.isObject(n))return!1;if(this.isArray(n)!==this.isArray(e[i]))return!1;if(this.compareObject(n,e[i])===!1)return!1}else if(n!=e[i])return!1}return!0},getObjectLength:function(t){if(this.isArray(t)||this.isString(t))return t.length;var e=0;for(var n in t)t.hasOwnProperty(n)&&e++;return e},isEmptyObject:function(t){if(null==t)return!0;if(this.isArray(t)||this.isString(t))return 0===t.length;for(var e in t)if(t.hasOwnProperty(e))return!1;return!0},loadFile:function(){function t(t,n){try{for(var i,r=0;i=e[r++];)if(i.doc===t&&i.url==(n.src||n.href))return i}catch(o){return null}}var e=[];return function(n,i,r){var o=t(n,i);if(o)return void(o.ready?r&&r():o.funs.push(r));if(e.push({doc:n,url:i.src||i.href,funs:[r]}),!n.body){var a=[];for(var s in i)"tag"!=s&&a.push(s+'="'+i[s]+'"');return void n.write("<"+i.tag+" "+a.join(" ")+" >")}if(!i.id||!n.getElementById(i.id)){var l=n.createElement(i.tag);delete i.tag;for(var s in i)l.setAttribute(s,i[s]);l.onload=l.onreadystatechange=function(){if(!this.readyState||/loaded|complete/.test(this.readyState)){if(o=t(n,i),o.funs.length>0){o.ready=1;for(var e;e=o.funs.pop();)e()}l.onload=l.onreadystatechange=null}},n.getElementsByTagName("head")[0].appendChild(l)}}}(),clone:function(t,e){var n;e=e||{};for(var i in t)t.hasOwnProperty(i)&&(n=t[i],"object"==typeof n?(e[i]=utils.isArray(n)?[]:{},utils.clone(t[i],e[i])):e[i]=n);return e},unhtml:function(t,e){return t?t.replace(e||/[&<">'](?:(amp|lt|quot|gt|#39|nbsp);)?/g,function(t,e){return e?t:{"<":"<","&":"&",'"':""",">":">","'":"'"}[t]}):""},cloneArr:function(t){return[].concat(t)},clearWhitespace:function(t){return t.replace(/[\u200b\t\r\n]/g,"")},getValueByIndex:function(t,e){var n=0,i=0;return utils.each(t,function(t,r){if(n+r.length>=e){if(e-n==r.length){if(1==r.length&&0===r[0].width)return void n++;i={x:r[r.length-1].x+r[r.length-1].width,y:r[r.length-1].y}}else i=r[e-n];return!1}n+=r.length+(1==r.length&&0===r[0].width?0:1)}),i},getNodeIndex:function(t,e){for(var n=t,i=0;n=n.previousSibling;)e&&3==n.nodeType?n.nodeType!=n.nextSibling.nodeType&&i++:i++;return i}};Utils.each(["String","Function","Array","Number","RegExp","Object"],function(t,e){KityMinder.Utils["is"+e]=function(t){return Object.prototype.toString.apply(t)=="[object "+e+"]"}});var browser=KityMinder.browser=function(){var t=navigator.userAgent.toLowerCase(),e=window.opera,n={ie:/(msie\s|trident.*rv:)([\w.]+)/.test(t),opera:!!e&&e.version,webkit:t.indexOf(" applewebkit/")>-1,mac:t.indexOf("macintosh")>-1,quirks:"BackCompat"==document.compatMode,ipad:t.indexOf("ipad")>-1};n.gecko="Gecko"==navigator.product&&!n.webkit&&!n.opera&&!n.ie;var i=0;if(n.ie){var r=t.match(/(?:msie\s([\w.]+))/),o=t.match(/(?:trident.*rv:([\w.]+))/);i=r&&o&&r[1]&&o[1]?Math.max(1*r[1],1*o[1]):r&&r[1]?1*r[1]:o&&o[1]?1*o[1]:0,n.ie11Compat=11==document.documentMode,n.ie9Compat=9==document.documentMode,n.ie8=!!document.documentMode,n.ie8Compat=8==document.documentMode,n.ie7Compat=7==i&&!document.documentMode||7==document.documentMode,n.ie6Compat=7>i||n.quirks,n.ie9above=i>8,n.ie9below=9>i}if(n.gecko){var a=t.match(/rv:([\d\.]+)/);a&&(a=a[1].split("."),i=1e4*a[0]+100*(a[1]||0)+1*(a[2]||0))}return/chrome\/(\d+\.\d)/i.test(t)&&(n.chrome=+RegExp.$1),/(\d+\.\d)?(?:\.\d)?\s+safari\/?(\d+\.\d+)?/i.test(t)&&!/chrome/i.test(t)&&(n.safari=+(RegExp.$1||RegExp.$2)),n.opera&&(i=parseFloat(e.version())),n.webkit&&(i=parseFloat(t.match(/ applewebkit\/(\d+)/)[1])),n.version=i,n.isCompatible=!n.mobile&&(n.ie&&i>=6||n.gecko&&i>=10801||n.opera&&i>=9.5||n.air&&i>=1||n.webkit&&i>=522||!1),n}(),ie=browser.ie,webkit=browser.webkit,gecko=browser.gecko,opera=browser.opera,Minder=KityMinder.Minder=kity.createClass("KityMinder",{constructor:function(t){this._options=Utils.extend(window.KITYMINDER_CONFIG||{},t);for(var e=Minder._initFnQueue.slice();e.length;)e.shift().call(this,t);this.fire("ready")}});Minder._initFnQueue=[],Minder.registerInit=function(t){Minder._initFnQueue.push(t)};var Command=kity.createClass("Command",{constructor:function(){this._isContentChange=!0,this._isSelectionChange=!1},execute:function(){},setContentChanged:function(t){this._isContentChange=!!t},isContentChanged:function(){return this._isContentChange},setSelectionChanged:function(t){this._isSelectionChange=!!t},isSelectionChanged:function(){return this._isContentChange},queryState:function(){return 0},queryValue:function(){return 0},isNeedUndo:function(){return!0}});kity.extendClass(Minder,{_getCommand:function(t){return this._commands[t.toLowerCase()]},_queryCommand:function(t,e,n){var i=this._getCommand(t);if(i){var r=i["query"+e];if(r)return r.apply(i,[this].concat(n))}return 0},queryCommandState:function(t){return this._queryCommand(t,"State",Utils.argsToArray(1))},queryCommandValue:function(t){return this._queryCommand(t,"Value",Utils.argsToArray(1))},execCommand:function(t){t=t.toLowerCase();var e,n,i,r,o=Utils.argsToArray(arguments,1),a=this;return e=this._getCommand(t),r={command:e,commandName:t.toLowerCase(),commandArgs:o},e&&~this.queryCommandState(t)?(!this._hasEnterExecCommand&&e.isNeedUndo()?(this._hasEnterExecCommand=!0,n=this._fire(new MinderEvent("beforeExecCommand",r,!0)),n||(this._fire(new MinderEvent("saveScene")),this._fire(new MinderEvent("preExecCommand",r,!1)),i=e.execute.apply(e,[a].concat(o)),this._fire(new MinderEvent("execCommand",r,!1)),this._fire(new MinderEvent("saveScene")),e.isContentChanged()&&this._firePharse(new MinderEvent("contentchange")),this._interactChange()),this._hasEnterExecCommand=!1):(i=e.execute.apply(e,[a].concat(o)),this._hasEnterExecCommand||this._interactChange()),void 0===i?null:i):!1}});var MinderNode=KityMinder.MinderNode=kity.createClass("MinderNode",{constructor:function(t){this.parent=null,this.root=this,this.children=[],this.data={},this.tmpData={},this.initContainers(),Utils.isString(t)?this.setText(t):this.setData(t)},initContainers:function(){this.rc=(new kity.Group).setId(KityMinder.uuid("minder_node")),this.rc.minderNode=this},isRoot:function(){return this.root===this},isLeaf:function(){return 0===this.children.length},getRoot:function(){return this.root||this},getParent:function(){return this.parent},getLevel:function(){for(var t=0,e=this.parent;e;)t++,e=e.parent;return t},getComplex:function(){var t=0;return this.traverse(function(){t++}),t},getType:function(){return this.type=["root","main","sub"][Math.min(this.getLevel(),2)],this.type},isAncestorOf:function(t){for(var e=t.parent;e;){if(e==this)return!0;e=e.parent}return!1},setText:function(t){return utils.isArray(t)&&(t=t.join("\n")),this.setData("text",t)},getText:function(t){var e=this.getData("text")||"";return t&&(e=e.split("\n")),e},preTraverse:function(t,e){var n=this.getChildren();e||t(this);for(var i=0;i=0&&(e=this.children.splice(n,1)[0],e.parent=null,e.root=e)},getChild:function(t){return this.children[t]},getFirstChild:function(){return this.children[0]},getLastChild:function(){return this.children[this.children.length-1]},getData:function(t){return void 0===t?this.data:this.data[t]},setData:function(t,e){return void 0===t?this.data={}:utils.isObject(t)?Utils.extend(this.data,t):void 0===e?(this.data[t]=null,delete this.data[t]):this.data[t]=e,this},getRenderContainer:function(){return this.rc},getCommonAncestor:function(t){return Utils.getNodeCommonAncestor(this,t)},contains:function(t){return this==t||this.isAncestorOf(t)},clone:function(){function t(e,n){var i=new KM.MinderNode;i.data=Utils.clonePlainObject(n.getData()),i.tmpData=Utils.clonePlainObject(n.getTmpData()),e&&e.appendChild(i);for(var r,o=0;r=n.children[o++];)t(i,r);return i}return t(null,this)},equals:function(t,e){function n(){r&&i.setSelectedFlag(),o&&t.setSelectedFlag()}var i=this;if(e){var r=!1,o=!1;i.isSelected()&&(r=!0,i.clearSelectedFlag()),t.isSelected()&&(o=!0,t.clearSelectedFlag())}if(t.children.length!=this.children.length)return n(),!1;if(utils.compareObject(t.getData(),i.getData())===!1)return n(),!1;if(utils.compareObject(t.getTmpData(),i.getTmpData())===!1)return n(),!1;for(var a,s=0;a=i.children[s];s++)if(a.equals(t.children[s],e)===!1)return n(),!1;return n(),!0},clearChildren:function(){this.children=[]},setTmpData:function(t,e){var n=this;utils.isObject(t)&&utils.each(t,function(t,e){n.setTmpData(t,e)}),void 0===e||null===e||""===e?delete this.tmpData[t]:this.tmpData[t]=e},getTmpData:function(t){return void 0===t?this.tmpData:this.tmpData[t]},setValue:function(t){return this.data={},this.setData(utils.clonePlainObject(t.getData())),this.tmpData={},this.setTmpData(utils.clonePlainObject(t.getTmpData())),this}});MinderNode.getCommonAncestor=function(t,e){if(t instanceof Array)return MinderNode.getCommonAncestor.apply(this,t);switch(arguments.length){case 1:return t.parent||t;case 2:if(t.isAncestorOf(e))return t;if(e.isAncestorOf(t))return e;for(var n=t.parent;n&&!n.isAncestorOf(e);)n=n.parent;return n;default:return Array.prototype.reduce.call(arguments,function(t,e){return MinderNode.getCommonAncestor(t,e)},t)}},kity.extendClass(Minder,{getRoot:function(){return this._root},setRoot:function(t){this._root=t,t.minder=this},createNode:function(t,e,n){var i=new MinderNode(t);return this.fire("nodecreate",{node:i,parent:e,index:n}),this.appendNode(i,e,n),i},appendNode:function(t,e,n){return e&&e.insertChild(t,n),this.attachNode(t),this},removeNode:function(t){t.parent&&(t.parent.removeChild(t),this.detachNode(t),this.fire("noderemove",{node:t}))},attachNode:function(t){var e=this._rc;t.traverse(function(t){t.attached=!0,e.addShape(t.getRenderContainer())}),e.addShape(t.getRenderContainer()),this.fire("nodeattach",{node:t})},detachNode:function(t){var e=this._rc;t.traverse(function(t){t.attached=!1,e.removeShape(t.getRenderContainer())}),this.fire("nodedetach",{node:t})},getMinderTitle:function(){return this.getRoot().getText()}}),kity.extendClass(MinderNode,{getMinder:function(){return this.getRoot().minder}}),kity.extendClass(Minder,{getOptions:function(t){var e;return t?(e=this.getPreferences(t),e&&e[t]||this._options[t]):(e=this.getPreferences(),utils.extend(e,this._options,!0))},setDefaultOptions:function(t,e,n){var i={};Utils.isString(t)?i[t]=e:i=t,utils.extend(this._options,i,!n)},setOptions:function(t,e){this.setPreferences(t,e)}}),Minder.registerInit(function(){this.setDefaultOptions(KM.defaultOptions)});var MinderEvent=kity.createClass("MindEvent",{constructor:function(t,e,n){e=e||{},e.getType&&"ShapeEvent"==e.getType()?(this.kityEvent=e,this.originEvent=e.originEvent,this.getPosition=e.getPosition.bind(e)):e.target&&e.preventDefault?this.originEvent=e:kity.Utils.extend(this,e),this.type=t,this._canstop=n||!1},getTargetNode:function(){var t=this.kityEvent&&this.kityEvent.targetShape;if(!t)return null;for(;!t.minderNode&&t.container;)t=t.container;var e=t.minderNode;return e&&t.getOpacity()<1?null:e||null},stopPropagation:function(){this._stoped=!0},stopPropagationImmediately:function(){this._immediatelyStoped=!0,this._stoped=!0},shouldStopPropagation:function(){return this._canstop&&this._stoped},shouldStopPropagationImmediately:function(){return this._canstop&&this._immediatelyStoped},preventDefault:function(){this.originEvent.preventDefault()},isRightMB:function(){var t=!1;return this.originEvent?("which"in this.originEvent?t=3==this.originEvent.which:"button"in this.originEvent&&(t=2==this.originEvent.button),t):!1},getKeyCode:function(){var t=this.originEvent;return t.keyCode||t.which}});Minder.registerInit(function(){this._initEvents()}),kity.extendClass(Minder,{_initEvents:function(){this._eventCallbacks={}},_bindEvents:function(){this._bindPaperEvents(),this._bindKeyboardEvents()},_resetEvents:function(){this._initEvents(),this._bindEvents()},_bindPaperEvents:function(){this._paper.on("click dblclick mousedown contextmenu mouseup mousemove mouseover mousewheel DOMMouseScroll touchstart touchmove touchend dragenter dragleave drop",this._firePharse.bind(this)),window&&(window.addEventListener("resize",this._firePharse.bind(this)),window.addEventListener("blur",this._firePharse.bind(this)))},_bindKeyboardEvents:function(){-1==navigator.userAgent.indexOf("iPhone")&&-1==navigator.userAgent.indexOf("iPod")&&-1==navigator.userAgent.indexOf("iPad")&&Utils.listen(document.body,"keydown keyup keypress paste",this._firePharse.bind(this))},_firePharse:function(t){var e,n,i;"DOMMouseScroll"==t.type&&(t.type="mousewheel",t.wheelDelta=t.originEvent.wheelDelta=-10*t.originEvent.detail,t.wheelDeltaX=t.originEvent.mozMovementX,t.wheelDeltaY=t.originEvent.mozMovementY),e=new MinderEvent("before"+t.type,t,!0),this._fire(e)||(n=new MinderEvent("pre"+t.type,t,!0),i=new MinderEvent(t.type,t,!0),(this._fire(n)||this._fire(i))&&this._fire(new MinderEvent("after"+t.type,t,!1)))},_interactChange:function(){var t=this;t._interactScheduled||(setTimeout(function(){t._fire(new MinderEvent("interactchange")),t._interactScheduled=!1},100),t._interactScheduled=!0)},_listen:function(t,e){var n=this._eventCallbacks[t]||(this._eventCallbacks[t]=[]);n.push(e)},_fire:function(t){var e=this.getStatus(),n=this._eventCallbacks[t.type.toLowerCase()]||[];if(e&&(n=n.concat(this._eventCallbacks[e+"."+t.type.toLowerCase()]||[])),0!==n.length){for(var i=(this.getStatus(),0);i",this._status),e&&console.trace())),this):this}}(),rollbackStatus:function(){this.setStatus(this._rollbackStatus)},getRollbackStatus:function(){return this._rollbackStatus},getStatus:function(){return this._status}}),Minder.registerInit(function(){this._initPaper()}),kity.extendClass(Minder,{_initPaper:function(){this._paper=new kity.Paper,this._paper.getNode().setAttribute("contenteditable",!0),this._paper.getNode().ondragstart=function(t){t.preventDefault()},this._paper.shapeNode.setAttribute("transform","translate(0.5, 0.5)"),this._addRenderContainer(),this.setRoot(this.createNode(this.getLang().maintopic)),this._options.renderTo&&this.renderTo(this._options.renderTo)},_addRenderContainer:function(){this._rc=(new kity.Group).setId(KityMinder.uuid("minder")),this._paper.addShape(this._rc)},renderTo:function(t){this._paper.renderTo(this._renderTarget=t),this._bindEvents()},getRenderContainer:function(){return this._rc},getPaper:function(){return this._paper},getRenderTarget:function(){return this._renderTarget}}),Minder.registerInit(function(){this._initSelection()}),kity.extendClass(Minder,{_initSelection:function(){this._selectedNodes=[]},renderChangedSelection:function(t){var e=this.getSelectedNodes(),n=[],i=0;for(e.forEach(function(e){-1==t.indexOf(e)&&(n.push(e),e.setTmpData("selected",!0))}),t.forEach(function(t){-1==e.indexOf(t)&&(n.push(t),t.setTmpData("selected",!1))}),n.length&&(this._interactChange(),this.fire("selectionchange"));i=0;--n)if(t[n].isAncestorOf(e))return!0;return!1}var n,i=this.getSelectedNodes().slice(0),r=[],o=i.indexOf(this.getRoot());for(~o&&!t&&i.splice(o,1),i.sort(function(t,e){return t.getLevel()-e.getLevel()});n=i.pop();)e(i,n)||r.push(n);return r}}),kity.extendClass(MinderNode,{isSelected:function(){return this.getTmpData("selected")},clearSelectedFlag:function(){this.setTmpData("selected")},setSelectedFlag:function(){this.setTmpData("selected",!0)}}),kity.extendClass(MinderEvent,{isShortcutKey:function(t){var e=this.originEvent;return e?getMetaKeyCode(t)==getMetaKeyCode(e):!1}}),Minder.registerInit(function(){this._initShortcutKey()}),kity.extendClass(Minder,{_initShortcutKey:function(){this._bindShortcutKeys()},_bindShortcutKeys:function(){var t=this._shortcutKeys={},e="hasOwnProperty";this.on("keydown",function(n){for(var i in t)if(t[e](i)&&n.isShortcutKey(i)){var r=t[i];if(r.__statusCondition&&r.__statusCondition!=this.getStatus())return;r(),n.preventDefault()}})},addShortcut:function(t,e){var n=this._shortcutKeys;t.split(/\|\s*/).forEach(function(t){var i,r=t.split("::");r.length>1&&(t=r[1],i=r[0],e.__statusCondition=i),n[t]=e})},addCommandShortcutKeys:function(t,e){var n=this._commandShortcutKeys||(this._commandShortcutKeys={}),i={};e?i[t]=e:i=t;var r=this;utils.each(i,function(t,e){n[t]=e,r.addShortcut(e,function(){0===r.queryCommandState(t)&&r.execCommand(t)})})},getCommandShortcutKey:function(t){var e=this._commandShortcutKeys; return e&&e[t]||null}}),Minder.registerInit(function(){this._initContextMenu()}),kity.extendClass(Minder,{_initContextMenu:function(){this.contextmenus=[]},addContextMenu:function(t){return utils.isArray(t)?this.contextmenus=this.contextmenus.concat(t):this.contextmenus.push(t),this},getContextMenu:function(){return this.contextmenus}}),function(){var t;KityMinder.registerModule=function(e,n){t||(t={}),t[e]=n},KityMinder.getModules=function(){return t}}(),Minder.registerInit(function(){this._initModules()}),kity.extendClass(Minder,{_initModules:function(){var t=KityMinder.getModules(),e=this._options.modules||Utils.keys(t);this._commands={},this._query={},this._modules={},this._rendererClasses={};var n,i,r,o,a,s,l,u=this;for(n=0;n200&&(e=0),r(t,t.parent?t.parent.getGlobalLayoutTransform():new kity.Matrix),s}});var Layout=kity.createClass("Layout",{doLayout:function(){throw new Error("Not Implement: Layout.doLayout()")},align:function(t,e,n){var i=this;n=n||0,t.forEach(function(t){var r=i.getTreeBox([t]),o=t.getLayoutTransform();switch(e){case"left":return o.translate(n-r.left,0);case"right":return o.translate(n-r.right,0);case"top":return o.translate(0,n-r.top);case"bottom":return o.translate(0,n-r.bottom)}})},stack:function(t,e,n){var i=this,r=0;return n=n||function(t,e,n){return t.getStyle({x:"margin-right",y:"margin-bottom"}[n])+e.getStyle({x:"margin-left",y:"margin-top"}[n])},t.forEach(function(t,o,a){var s=i.getTreeBox([t]),l={x:s.width,y:s.height}[e],u={x:s.left,y:s.top}[e],c=t.getLayoutTransform();"x"==e?c.translate(r-u,0):c.translate(0,r-u),r+=l,a[o+1]&&(r+=n(t,a[o+1],e))}),r},move:function(t,e,n){t.forEach(function(t){t.getLayoutTransform().translate(e,n)})},getBranchBox:function(t){var e,n,i,r,o=new kity.Box;for(e=0;en;n++){for(i=0;i0?"down":"up");KityMinder.registerLayout(e,kity.createClass({base:Layout,doLayout:function(e,n){var i=e.getContentBox(),r=20;if(e.setVertexOut(new kity.Point(i.left+r,t>0?i.bottom:i.top)),e.setLayoutVectorOut(new kity.Vector(0,t)),n.length){n.forEach(function(t){var e=t.getContentBox();t.setLayoutTransform(new kity.Matrix),t.setVertexIn(new kity.Point(e.left,e.cy)),t.setLayoutVectorIn(new kity.Vector(1,0))}),this.align(n,"left"),this.stack(n,"y");var o=0;o+=i.left,o+=r,o+=n[0].getStyle("margin-left");var a=0;t>0?(a+=i.bottom,a+=e.getStyle("margin-bottom"),a+=n[0].getStyle("margin-top")):(a-=this.getTreeBox(n).bottom,a+=i.top,a-=e.getStyle("margin-top"),a-=n[0].getStyle("margin-bottom")),this.move(n,o,a)}},getOrderHint:function(t){var e=[],n=t.getLayoutBox(),i=t.getLevel()>1?3:5;return e.push({type:"up",node:t,area:{x:n.x,y:n.top-t.getStyle("margin-top")-i,width:n.width,height:t.getStyle("margin-top")},path:["M",n.x,n.top-i,"L",n.right,n.top-i]}),e.push({type:"down",node:t,area:{x:n.x,y:n.bottom+i,width:n.width,height:t.getStyle("margin-bottom")},path:["M",n.x,n.bottom+i,"L",n.right,n.bottom+i]}),e}}))});var layouts=["left","right","top","bottom"];layouts.forEach(function(t){function e(t){var e=[],i=t.getLayoutBox(),r=5;return"x"==n?(e.push({type:"up",node:t,area:{x:i.x,y:i.top-t.getStyle("margin-top")-r,width:i.width,height:t.getStyle("margin-top")},path:["M",i.x,i.top-r,"L",i.right,i.top-r]}),e.push({type:"down",node:t,area:{x:i.x,y:i.bottom+r,width:i.width,height:t.getStyle("margin-bottom")},path:["M",i.x,i.bottom+r,"L",i.right,i.bottom+r]})):(e.push({type:"up",node:t,area:{x:i.left-t.getStyle("margin-left")-r,y:i.top,width:t.getStyle("margin-left"),height:i.height},path:["M",i.left-r,i.top,"L",i.left-r,i.bottom]}),e.push({type:"down",node:t,area:{x:i.right+r,y:i.top,width:t.getStyle("margin-right"),height:i.height},path:["M",i.right+r,i.top,"L",i.right+r,i.bottom]})),e}var n="left"==t||"right"==t?"x":"y",i="left"==t||"top"==t?-1:1,r={left:"right",right:"left",top:"bottom",bottom:"top",x:"y",y:"x"};KityMinder.registerLayout(t,kity.createClass({base:Layout,doLayout:function(e,o){var a=e.getContentBox();if("x"==n?(e.setVertexOut(new kity.Point(a[t],a.cy)),e.setLayoutVectorOut(new kity.Vector(i,0))):(e.setVertexOut(new kity.Point(a.cx,a[t])),e.setLayoutVectorOut(new kity.Vector(0,i))),!o.length)return!1;o.forEach(function(e){var o=e.getContentBox();e.setLayoutTransform(new kity.Matrix),"x"==n?(e.setVertexIn(new kity.Point(o[r[t]],o.cy)),e.setLayoutVectorIn(new kity.Vector(i,0))):(e.setVertexIn(new kity.Point(o.cx,o[r[t]])),e.setLayoutVectorIn(new kity.Vector(0,i)))}),this.align(o,r[t]),this.stack(o,r[n]);var s,l,u=this.getBranchBox(o);"x"==n?(s=a[t],s+=i*e.getStyle("margin-"+t),s+=i*o[0].getStyle("margin-"+r[t]),l=a.bottom,l-=a.height/2,l-=u.height/2,l-=u.y):(s=a.right,s-=a.width/2,s-=u.width/2,s-=u.x,l=a[t],l+=i*e.getStyle("margin-"+t),l+=i*o[0].getStyle("margin-"+r[t])),this.move(o,s,l)},getOrderHint:e}))}),KityMinder.registerLayout("fish-bone-master",kity.createClass("FishBoneMasterLayout",{base:Layout,doLayout:function(t,e){var n=[],i=[],r=e[0],o=t.getContentBox();if(t.setVertexOut(new kity.Point(o.right,o.cy)),t.setLayoutVectorOut(new kity.Vector(1,0)),r){var a=(r.getContentBox(),t.getStyle("margin-right")),s=r.getStyle("margin-left"),l=r.getStyle("margin-top"),u=r.getStyle("margin-bottom");e.forEach(function(t,e){t.setLayoutTransform(new kity.Matrix);var r=t.getContentBox();e%2?(i.push(t),t.setVertexIn(new kity.Point(r.left,r.top)),t.setLayoutVectorIn(new kity.Vector(1,1))):(n.push(t),t.setVertexIn(new kity.Point(r.left,r.bottom)),t.setLayoutVectorIn(new kity.Vector(1,-1)))}),this.stack(n,"x"),this.stack(i,"x"),this.align(n,"bottom"),this.align(i,"top");var c=o.right+a+s,h=o.cy-u-t.getStyle("margin-top"),d=o.cy+l+t.getStyle("margin-bottom");this.move(n,c,h),this.move(i,c+s,d)}}})),KityMinder.registerLayout("fish-bone-slave",kity.createClass("FishBoneSlaveLayout",{base:Layout,doLayout:function(t,e,n){var i=this,r=Math.abs,o=.382,a=t.getContentBox(),s=t.getLayoutVectorIn();t.setLayoutVectorOut(s);var l=a.left+a.width*o,u=new kity.Point(l,s.y>0?a.bottom:a.top);t.setVertexOut(u);var c=e[0];if(c){var h=c.getContentBox();e.forEach(function(t){t.setLayoutTransform(new kity.Matrix),t.setLayoutVectorIn(new kity.Vector(1,0)),t.setVertexIn(new kity.Point(h.left,h.cy))}),this.stack(e,"y"),this.align(e,"left");var d=0,f=0;d+=u.x,t.getLayoutVectorOut().y<0?(f-=this.getTreeBox(e).bottom,f+=t.getContentBox().top,f-=t.getStyle("margin-top"),f-=c.getStyle("margin-bottom")):(f+=t.getContentBox().bottom,f+=t.getStyle("margin-bottom"),f+=c.getStyle("margin-top")),this.move(e,d,f),2==n&&e.forEach(function(t){var e=t.getLayoutTransform(),n=t.getContentBox(),o=e.transformPoint(new kity.Point(n.left,0));i.move([t],r(o.y-u.y),0)})}}})),KityMinder.registerLayout("tianpan",kity.createClass({base:Layout,doLayout:function(t,e){if(0!=e.length){var n,i,r,o=this,a=t.getContentBox(),s=5,l=Math.max(a.width,50);e.forEach(function(t){t.setLayoutTransform(new kity.Matrix),r=o.getTreeBox(t),l=Math.max(Math.max(r.width,r.height),l)}),l=l/1.5/Math.PI,e.forEach(function(t,e){n=l*(Math.cos(s)+Math.sin(s)*s),i=l*(Math.sin(s)-Math.cos(s)*s),s+=.9-.02*e,t.setLayoutVectorIn(new kity.Vector(1,0)),t.setVertexIn(new kity.Point(a.cx,a.cy)),t.setLayoutTransform(new kity.Matrix),o.move([t],n,i)})}},getOrderHint:function(t){var e=[],n=t.getLayoutBox(),i=5;return e.push({type:"up",node:t,area:{x:n.x,y:n.top-t.getStyle("margin-top")-i,width:n.width,height:t.getStyle("margin-top")},path:["M",n.x,n.top-i,"L",n.right,n.top-i]}),e.push({type:"down",node:t,area:{x:n.x,y:n.bottom+i,width:n.width,height:t.getStyle("margin-bottom")},path:["M",n.x,n.bottom+i,"L",n.right,n.bottom+i]}),e}})),KityMinder.registerConnectProvider("bezier",function(t,e,n){var i=e.getLayoutVertexOut(),r=t.getLayoutVertexIn(),o=e.getLayoutVectorOut().normalize(),a=Math.round,s=Math.abs,l=[];if(l.push("M",a(i.x),a(i.y)),s(o.x)>s(o.y)){var u=(r.x+i.x)/2;l.push("C",u,i.y,u,r.y,r.x,r.y)}else{var c=(r.y+i.y)/2;l.push("C",i.x,c,r.x,c,r.x,r.y)}n.setMarker(null),n.setPathData(l)}),KityMinder.registerConnectProvider("poly",function(t,e,n){var i=e.getLayoutVertexOut(),r=t.getLayoutVertexIn(),o=e.getLayoutVectorOut().normalize(),a=Math.round,s=Math.abs,l=[];switch(l.push("M",a(i.x),a(i.y)),!0){case s(o.x)>s(o.y)&&o.x<0:l.push("h",-e.getStyle("margin-left")),l.push("v",r.y-i.y),l.push("H",r.x);break;case s(o.x)>s(o.y)&&o.x>=0:l.push("h",e.getStyle("margin-right")),l.push("v",r.y-i.y),l.push("H",r.x);break;case s(o.x)<=s(o.y)&&o.y<0:l.push("v",-e.getStyle("margin-top")),l.push("h",r.x-i.x),l.push("V",r.y);break;case s(o.x)<=s(o.y)&&o.y>=0:l.push("v",e.getStyle("margin-bottom")),l.push("h",r.x-i.x),l.push("V",r.y)}n.setMarker(null),n.setPathData(l)});var connectMarker=(new kity.Marker).pipe(function(){var t=7,e=new kity.Circle(t-1);this.addShape(e),this.setRef(t-1,0).setViewBox(-t,-t,t+t,t+t).setWidth(t).setHeight(t),this.dot=e,this.node.setAttribute("markerUnits","userSpaceOnUse")});KityMinder.registerConnectProvider("arc",function(t,e,n,i,r){var o,a,s,l=t.getLayoutBox(),u=e.getLayoutBox(),c=Math.abs,h=[],d=l.x>u.x?"right":"left";t.getMinder().getPaper().addResource(connectMarker),o=new kity.Point(u.cx,u.cy),a="left"==d?new kity.Point(l.right+2,l.cy):new kity.Point(l.left-2,l.cy),s=kity.Vector.fromPoints(o,a),h.push("M",o),h.push("A",c(s.x),c(s.y),0,0,s.x*s.y>0?0:1,a),n.setMarker(connectMarker),connectMarker.dot.fill(r),n.setPathData(h)}),KityMinder.registerConnectProvider("under",function(t,e,n){var i,r,o,a,s=t.getLayoutBox(),l=e.getLayoutBox(),u=(Math.abs,[]),c=s.x>l.x?"right":"left",h=(t.getStyle("connect-radius"),s.bottom+3),d="sub"==e.getType()?l.bottom+3:l.cy;"right"==c?(i=new kity.Point(l.right,d),r=new kity.Point(s.left-10,h),o=new kity.Point(s.right,h)):(i=new kity.Point(l.left,d),r=new kity.Point(s.right+10,h),o=new kity.Point(s.left,h)),a=(i.x+r.x)/2,u.push("M",i),u.push("C",a,i.y,a,r.y,r),u.push("L",o),n.setMarker(null),n.setPathData(u)}),KityMinder.registerConnectProvider("l",function(t,e,n){var i=e.getLayoutVertexOut(),r=t.getLayoutVertexIn(),o=e.getLayoutVectorOut(),a=[],s=Math.round,l=Math.abs;a.push("M",i.round()),l(o.x)>l(o.y)?a.push("H",s(r.x)):a.push("V",r.y),a.push("L",r),n.setPathData(a)}),KityMinder.registerConnectProvider("fish-bone-master",function(t,e,n){var i=e.getLayoutVertexOut(),r=t.getLayoutVertexIn(),o=Math.abs,a=o(i.y-r.y),s=o(i.x-r.x),l=[];l.push("M",i.x,i.y),l.push("h",s-a),l.push("L",r.x,r.y),n.setMarker(null),n.setPathData(l)});var connectMarker=(new kity.Marker).pipe(function(){var t=7,e=new kity.Circle(t-1);this.addShape(e),this.setRef(t-1,0).setViewBox(-t,-t,t+t,t+t).setWidth(t).setHeight(t),this.dot=e,this.node.setAttribute("markerUnits","userSpaceOnUse")});KityMinder.registerConnectProvider("arc_tp",function(t,e,n,i,r){var o=t.getLayoutBox(),a=e.getLayoutBox();if(t.getIndex()>0){var s=t.getIndex();a=e.getChildren()[s-1].getLayoutBox()}{var l,u,c,h=(Math.abs,[]);o.x>a.x?"right":"left"}t.getMinder().getPaper().addResource(connectMarker),l=new kity.Point(a.cx,a.cy),u=new kity.Point(o.cx,o.cy);var d=Math.sqrt(Math.abs(l.x-u.x)*Math.abs(l.x-u.x)+Math.abs(l.y-u.y)*Math.abs(l.y-u.y));d=0==t.getIndex()?.4*d:d,c=kity.Vector.fromPoints(l,u),h.push("M",l),h.push("A",d,d,0,0,1,u),n.setMarker(connectMarker),connectMarker.dot.fill(r),n.setPathData(h)}),["classic","classic-compact"].forEach(function(t){var e="classic-compact"==t;KityMinder.registerTheme(t,{background:"#3A4144 url(ui/theme/default/images/grid.png) repeat","root-color":"#430","root-background":"#e9df98","root-stroke":"#e9df98","root-font-size":24,"root-padding":e?[10,25]:[15,25],"root-margin":e?[15,25]:[30,100],"root-radius":30,"root-space":10,"root-shadow":"rgba(0, 0, 0, .25)","main-color":"#333","main-background":"#a4c5c0","main-stroke":"#a4c5c0","main-font-size":16,"main-padding":e?[5,15]:[6,20],"main-margin":e?[5,10]:20,"main-radius":10,"main-space":5,"main-shadow":"rgba(0, 0, 0, .25)","sub-color":"white","sub-background":"transparent","sub-stroke":"none","sub-font-size":12,"sub-padding":[5,10],"sub-margin":e?[5,10]:[15,20],"sub-tree-margin":30,"sub-radius":5,"sub-space":5,"connect-color":"white","connect-width":2,"main-connect-width":3,"connect-radius":5,"selected-background":"rgb(254, 219, 0)","selected-stroke":"rgb(254, 219, 0)","selected-color":"black","marquee-background":"rgba(255,255,255,.3)","marquee-stroke":"white","drop-hint-color":"yellow","sub-drop-hint-width":2,"main-drop-hint-width":4,"root-drop-hint-width":4,"order-hint-area-color":"rgba(0, 255, 0, .5)","order-hint-path-color":"#0f0","order-hint-path-width":1,"text-selection-color":"rgb(27,171,255)","line-height":1.5}) }),["snow","snow-compact"].forEach(function(t){var e="snow-compact"==t;KityMinder.registerTheme(t,{background:"#3A4144 url(ui/theme/default/images/grid.png) repeat","root-color":"#430","root-background":"#e9df98","root-stroke":"#e9df98","root-font-size":24,"root-padding":e?[5,10]:[15,25],"root-margin":e?15:30,"root-radius":5,"root-space":10,"root-shadow":"rgba(0, 0, 0, .25)","main-color":"#333","main-background":"#a4c5c0","main-stroke":"#a4c5c0","main-font-size":16,"main-padding":e?[4,10]:[6,20],"main-margin":e?[5,10]:[20,40],"main-radius":5,"main-space":5,"main-shadow":"rgba(0, 0, 0, .25)","sub-color":"black","sub-background":"white","sub-stroke":"white","sub-font-size":12,"sub-padding":[5,10],"sub-margin":e?[5,10]:[10,20],"sub-radius":5,"sub-space":5,"connect-color":"white","connect-width":2,"main-connect-width":3,"connect-radius":5,"selected-background":"rgb(254, 219, 0)","selected-stroke":"rgb(254, 219, 0)","marquee-background":"rgba(255,255,255,.3)","marquee-stroke":"white","drop-hint-color":"yellow","drop-hint-width":4,"order-hint-area-color":"rgba(0, 255, 0, .5)","order-hint-path-color":"#0f0","order-hint-path-width":1,"text-selection-color":"rgb(27,171,255)","line-height":1.5})}),function(){function t(t,e,n){return kity.Color.createHSL(t,e,n)}function e(e,n){return{background:"#fbfbfb","root-color":"white","root-background":t(e,37,60),"root-stroke":t(e,37,60),"root-font-size":16,"root-padding":n?[6,12]:[12,24],"root-margin":n?10:[30,100],"root-radius":5,"root-space":10,"main-color":"black","main-background":t(e,33,95),"main-stroke":t(e,37,60),"main-stroke-width":1,"main-font-size":14,"main-padding":[6,20],"main-margin":n?8:20,"main-radius":3,"main-space":5,"sub-color":"black","sub-background":"transparent","sub-stroke":"none","sub-font-size":12,"sub-padding":n?[3,5]:[5,10],"sub-margin":n?[4,8]:[15,20],"sub-radius":5,"sub-space":5,"connect-color":t(e,37,60),"connect-width":1,"connect-radius":5,"selected-stroke":t(e,26,30),"selected-stroke-width":"3","marquee-background":t(e,100,80).set("a",.1),"marquee-stroke":t(e,37,60),"drop-hint-color":t(e,26,35),"drop-hint-width":5,"order-hint-area-color":t(e,100,30).set("a",.5),"order-hint-path-color":t(e,100,25),"order-hint-path-width":1,"text-selection-color":t(e,100,20),"line-height":1.5}}var n,i={red:0,soil:25,green:122,blue:204,purple:246,pink:334};for(n in i)KityMinder.registerTheme("fresh-"+n,e(i[n])),KityMinder.registerTheme("fresh-"+n+"-compat",e(i[n],!0))}(),KityMinder.registerTheme("fish",{background:"#3A4144 url(ui/theme/default/images/grid.png) repeat","root-color":"#430","root-background":"#e9df98","root-stroke":"#e9df98","root-font-size":24,"root-padding":[35,35],"root-margin":30,"root-radius":100,"root-space":10,"root-shadow":"rgba(0, 0, 0, .25)","main-color":"#333","main-background":"#a4c5c0","main-stroke":"#a4c5c0","main-font-size":16,"main-padding":[6,20],"main-margin":[20,20],"main-radius":5,"main-space":5,"main-shadow":"rgba(0, 0, 0, .25)","sub-color":"black","sub-background":"white","sub-stroke":"white","sub-font-size":12,"sub-padding":[5,10],"sub-margin":[10],"sub-radius":5,"sub-space":5,"connect-color":"white","connect-width":3,"main-connect-width":3,"connect-radius":5,"selected-background":"rgb(254, 219, 0)","selected-stroke":"rgb(254, 219, 0)","marquee-background":"rgba(255,255,255,.3)","marquee-stroke":"white","drop-hint-color":"yellow","drop-hint-width":4,"order-hint-area-color":"rgba(0, 255, 0, .5)","order-hint-path-color":"#0f0","order-hint-path-width":1,"text-selection-color":"rgb(27,171,255)","line-height":1.5}),KityMinder.registerTheme("wire",{background:"black",color:"#999",stroke:"none",padding:10,margin:20,"font-size":14,"connect-color":"#999","connect-width":1,"selected-background":"#999","selected-color":"black","marquee-background":"rgba(255,255,255,.3)","marquee-stroke":"white","drop-hint-color":"yellow","sub-drop-hint-width":2,"main-drop-hint-width":4,"root-drop-hint-width":4,"order-hint-area-color":"rgba(0, 255, 0, .5)","order-hint-path-color":"#0f0","order-hint-path-width":1,"text-selection-color":"rgb(27,171,255)","line-height":1.5}),["tianpan","tianpan-compact"].forEach(function(t){var e="tianpan-compact"==t;KityMinder.registerTheme(t,{background:"#3A4144 url(ui/theme/default/images/grid.png) repeat","root-color":"#430","root-background":"#e9df98","root-stroke":"#e9df98","root-font-size":25,"root-padding":e?15:20,"root-margin":e?[15,25]:100,"root-radius":30,"root-space":10,"root-shadow":"rgba(0, 0, 0, .25)","root-shape":"circle","main-color":"#333","main-background":"#a4c5c0","main-stroke":"#a4c5c0","main-font-size":15,"main-padding":e?10:12,"main-margin":e?10:12,"main-radius":10,"main-space":5,"main-shadow":"rgba(0, 0, 0, .25)","main-shape":"circle","sub-color":"#333","sub-background":"#99ca6a","sub-stroke":"#a4c5c0","sub-font-size":13,"sub-padding":5,"sub-margin":e?6:10,"sub-tree-margin":30,"sub-radius":5,"sub-space":5,"sub-shadow":"rgba(0, 0, 0, .25)","sub-shape":"circle","connect-color":"white","connect-width":2,"main-connect-width":3,"connect-radius":5,"selected-background":"rgb(254, 219, 0)","selected-stroke":"rgb(254, 219, 0)","selected-color":"black","marquee-background":"rgba(255,255,255,.3)","marquee-stroke":"white","drop-hint-color":"yellow","sub-drop-hint-width":2,"main-drop-hint-width":4,"root-drop-hint-width":4,"order-hint-area-color":"rgba(0, 255, 0, .5)","order-hint-path-color":"#0f0","order-hint-path-width":1,"text-selection-color":"rgb(27,171,255)","line-height":1.4})}),KityMinder.registerTemplate("default",{getLayout:function(t){if(t.getData("layout"))return t.getData("layout");var e=t.getLevel();return 0===e?"mind":1===e?t.getLayoutPointPreview().x>0?"right":"left":t.parent.getLayout()},getConnect:function(t){return 1==t.getLevel()?"arc":"under"}}),KityMinder.registerTemplate("structure",{getLayout:function(t){return t.getData("layout")||"bottom"},getConnect:function(){return"poly"}}),KityMinder.registerTemplate("filetree",{getLayout:function(t){return t.getData("layout")?t.getData("layout"):t.isRoot()?"bottom":"filetree-down"},getConnect:function(t){return 1==t.getLevel()?"poly":"l"}}),KityMinder.registerTemplate("right",{getLayout:function(t){return t.getData("layout")||"right"},getConnect:function(t){return 1==t.getLevel()?"arc":"bezier"}}),KityMinder.registerTemplate("fish-bone",{getLayout:function(t){if(t.getData("layout"))return t.getData("layout");var e=t.getLevel();return 0===e?"fish-bone-master":1===e?"fish-bone-slave":t.getLayoutPointPreview().y>0?"filetree-up":"filetree-down"},getConnect:function(t){switch(t.getLevel()){case 1:return"fish-bone-master";case 2:return"line";default:return"l"}}}),KityMinder.registerTemplate("tianpan",{getLayout:function(t){if(t.getData("layout"))return t.getData("layout");var e=t.getLevel();return 0===e?"tianpan":t.parent.getLayout()},getConnect:function(){return"arc_tp"}});var AppendChildCommand=kity.createClass("AppendChildCommand",{base:Command,execute:function(t,e){var n=t.getSelectedNode();if(!n)return null;e=e||t.getLang("topic"),n.expand();var i=t.createNode(e,n);t.select(i,!0),i.render(),t.layout(600)},queryState:function(t){var e=t.getSelectedNode();return e?0:-1}}),AppendSiblingCommand=kity.createClass("AppendSiblingCommand",{base:Command,execute:function(t,e){var n=t.getSelectedNode(),i=n.parent;if(!i)return t.execCommand("AppendChildNode",e);e=e||t.getLang("topic");var r=t.createNode(e,i,n.getIndex()+1);t.select(r,!0),r.render(),t.layout(600)},queryState:function(t){var e=t.getSelectedNode();return e?0:-1}}),RemoveNodeCommand=kity.createClass("RemoverNodeCommand",{base:Command,execute:function(t){var e=t.getSelectedNodes(),n=MinderNode.getCommonAncestor.apply(null,e);e.forEach(function(e){e.isRoot()||t.removeNode(e)}),t.select(n||t.getRoot(),!0),t.layout(600)},queryState:function(t){var e=t.getSelectedNode();return e?0:-1}}),EditNodeCommand=kity.createClass("EditNodeCommand",{base:Command,execute:function(t){var e=t.getSelectedNode();return e?(t.select(e,!0),void t.textEditNode(e)):null},queryState:function(t){var e=t.getSelectedNode();return e?0:-1},isNeedUndo:function(){return!1}}),$importDialog,$exportDialog,ImportTextNode=kity.createClass("ImportTextNode",{base:Command,execute:function(t){function e(e){var i;if(e)try{o=n.decode(e,!0)}catch(r){i="文本格式解析错误. "+r.message}else i=t.getLang("contentIsRequired");i?(a.addClass("validate-error"),l.text(i),s.disable()):(a.removeClass("validate-error"),l.text(""),s.enable())}if(!$importDialog){var n=t.getProtocol("plain"),i=300;$importDialog=new FUI.Dialog({width:500,height:i,prompt:!0,caption:t.getLang("ui.importtextnode")}).appendTo(document.getElementById("content-wrapper"));var r=$($importDialog.getBodyElement());r.html([''].join(""));var o,a=r.find("textarea"),s=$importDialog.getButton(0),l=$('');a.after(l),a.on("input",function(){e(a.val())}),a.on("keydown keyup",function(t){if(9===t.keyCode&&"keydown"===t.type){t.preventDefault();var e=this.selectionStart;this.value=this.value.substring(0,this.selectionStart)+" "+this.value.substring(this.selectionEnd),this.selectionEnd=e+1}(13!==t.keyCode||t.shiftKey)&&t.stopPropagation()}),$importDialog.on("open",function(){e(a.val()),setTimeout(function(){a[0].focus()},10)}),$importDialog.on("ok",function(){function e(n,i){if(n&&i){var r=t.createNode(i.data.text,n);return i.children&&i.children.forEach(function(t){e(r,t)}),r.render(),r}}var n=[],i=t.getSelectedNode();o&&o.children&&i&&(i.expand(),o.children.forEach(function(t){n.push(e(i,t))})),t.select(n,!0),t.layout(300),a.val(""),n=null,o=null})}$importDialog.open()},queryState:function(t){var e=t.getSelectedNode();return e?0:-1}}),ExportTextNode=kity.createClass("ExportTextNode",{base:Command,execute:function(t){if(!$exportDialog){var e=t.getProtocol("plain"),n=300;$exportDialog=new FUI.Dialog({width:500,height:n,prompt:!0,caption:t.getLang("ui.exporttextnode")}).appendTo(document.getElementById("content-wrapper"));var i=$($exportDialog.getBodyElement());i.html([''].join(""));var r=i.find("textarea");r.on("keydown keyup",function(t){if(9===t.keyCode&&"keydown"===t.type){t.preventDefault();var e=this.selectionStart;this.value=this.value.substring(0,this.selectionStart)+" "+this.value.substring(this.selectionEnd),this.selectionEnd=e+1}(13!==t.keyCode||t.shiftKey)&&t.stopPropagation()}),$exportDialog.on("open",function(){r.val(e.encode(t.getSelectedNode())),setTimeout(function(){r[0].focus()},10)})}$exportDialog.open()},queryState:function(t){var e=t.getSelectedNode();return e?0:-1}});KityMinder.registerModule("NodeModule",function(){return{commands:{AppendChildNode:AppendChildCommand,AppendSiblingNode:AppendSiblingCommand,ImportTextNode:ImportTextNode,ExportTextNode:ExportTextNode,RemoveNode:RemoveNodeCommand,EditNode:EditNodeCommand},contextmenu:[{command:"appendsiblingnode"},{command:"appendchildnode"},{command:"editnode"},{command:"removenode"},{command:"importtextnode"},{command:"exporttextnode"},{divider:1}],commandShortcutKeys:{appendsiblingnode:"normal::Enter",appendchildnode:"normal::Insert|Tab",editnode:"normal::F2",removenode:"normal::Del|Backspace"}}});var FONT_ADJUST={"微软雅黑,Microsoft YaHei":-.15,"arial black,avant garde":-.17,"default":-.15},TextRenderer=KityMinder.TextRenderer=kity.createClass("TextRenderer",{base:Renderer,create:function(){return(new kity.Group).setId(KityMinder.uuid("node_text"))},update:function(t,e){function n(t){return e.getData(t)||e.getStyle(t)}var i=e.getText(!0),r=e.getStyle("line-height"),o=n("font-size"),a=n("font-family")||"default",s=r*o*i.length-(r-1)*o,l=-s/2,u=FONT_ADJUST[a]||0;t.setTranslate(0,u*o);var c=new kity.Box,h=Math.round;this.setTextStyle(e,t);var d=i.length,f=t.getItems().length;if(f>d)for(var p,g=d;p=t.getItem(g);)t.removeItem(g);else if(d>f)for(var m=d-f,g=0;m>g;g++){var v=(new kity.Text).setAttr("text-rendering","inherit");kity.Browser.ie?v.setVerticalAlign("top"):v.setAttr("dominant-baseline","text-before-edge"),t.addItem(v)}for(var y,v,g=0;y=i[g],v=t.getItem(g);g++)v.setContent(y);this.setTextStyle(e,t);var _=e.getText()+[n("font-size"),n("font-name"),n("font-weight"),n("font-style")].join("/");return e._currentTextHash==_&&e._currentTextGroupBox?e._currentTextGroupBox:(e._currentTextHash=_,function(){t.eachItem(function(t,e){var n=l+t*o*r;e.setY(n),c=c.merge(new kity.Box(0,n,e.getBoundaryBox().width||1,o))});var n=0,i=e.getStyle("shape");i&&"circle"==i&&(n=Math.max(c.width,c.height)/2-c.height/2);var a=new kity.Box(h(c.x),h(c.y-n),h(c.width),h(c.height));return e._currentTextGroupBox=a,a})},setTextStyle:function(t,e){var n=TextRenderer._styleHooks;n.forEach(function(n){n(t,e)})}});utils.extend(TextRenderer,{_styleHooks:[],registerStyleHook:function(t){TextRenderer._styleHooks.push(t)}}),kity.extendClass(MinderNode,{getTextGroup:function(){return this.getRenderer("TextRenderer").getRenderShape()}}),KityMinder.registerModule("text",{renderers:{center:TextRenderer}}),KityMinder.registerModule("Expand",function(){var t=this,e="expandState",n="expand",i="collapse";kity.extendClass(MinderNode,{expand:function(){return this.setData(e,n),this},collapse:function(){return this.setData(e,i),this},isExpanded:function(){var t=this.getData(e)!==i;return t&&(this.isRoot()||this.parent.isExpanded())},isCollapsed:function(){return!this.isExpanded()}});var r=kity.createClass("ExpandCommand",{base:Command,execute:function(t,e){var n=t.getSelectedNode();if(n){for(e&&(n=n.parent);n.parent;)n.expand(),n=n.parent;n.renderTree(),t.layout(100)}},queryState:function(t){return t.getSelectedNode()?0:-1}}),o=kity.createClass("ExpandToLevelCommand",{base:Command,execute:function(t,e){t.getRoot().traverse(function(t){t.getLevel()i;i++)t.isShortcutKey("Alt+"+i)&&this.execCommand("expandtolevel",i)}}},renderers:{outside:s},contextmenu:[{command:"expandtoleaf",query:function(){return!t.getSelectedNode()},fn:function(t){t.execCommand("expandtolevel",9999)}},{command:"expandtolevel1",query:function(){return!t.getSelectedNode()},fn:function(t){t.execCommand("expandtolevel",1)}},{command:"expandtolevel2",query:function(){return!t.getSelectedNode()},fn:function(t){t.execCommand("expandtolevel",2)}},{command:"expandtolevel3",query:function(){return!t.getSelectedNode()},fn:function(t){t.execCommand("expandtolevel",3)}},{divider:!0}]}});var OutlineRenderer=kity.createClass("OutlineRenderer",{base:Renderer,create:function(){var t=(new kity.Rect).setId(KityMinder.uuid("node_outline"));return this.bringToBack=!0,t},update:function(t,e,n){var i=e.getStyle("shape");if(i&&"circle"==i)return updateCircle(t,e,n);var r=e.getStyle("padding-left"),o=e.getStyle("padding-right"),a=e.getStyle("padding-top"),s=e.getStyle("padding-bottom"),l={x:n.x-r,y:n.y-a,width:n.width+r+o,height:n.height+a+s},u=e.isSelected()?"selected-":"";return t.setPosition(l.x,l.y).setSize(l.width,l.height).setRadius(e.getStyle("radius")).fill(e.getData("background")||e.getStyle(u+"background")||e.getStyle("background")).stroke(e.getStyle(u+"stroke"||e.getStyle("stroke")),e.getStyle(u+"stroke-width")),new kity.Box(l)}}),ShadowRenderer=kity.createClass("ShadowRenderer",{base:Renderer,create:function(){return this.bringToBack=!0,new kity.Rect},shouldRender:function(t){return t.getStyle("shadow")},update:function(t,e,n){t.setPosition(n.x+4,n.y+5).fill(e.getStyle("shadow"));var i=e.getStyle("shape");if(i){if("circle"==i){var r=Math.max(n.width,n.height);t.setSize(r,r),t.setRadius(r/2)}}else t.setSize(n.width,n.height),t.setRadius(e.getStyle("radius"))}}),marker=new kity.Marker;marker.setWidth(10),marker.setHeight(12),marker.setRef(0,0),marker.setViewBox(-6,-4,8,10),marker.addShape((new kity.Path).setPathData("M-5-3l5,3,-5,3").stroke("#33ffff"));var wireframeOption=/wire/.test(window.location.href),WireframeRenderer=kity.createClass("WireframeRenderer",{base:Renderer,create:function(){var t=new kity.Group,e=this.oxy=(new kity.Path).stroke("#f6f").setPathData("M0,-50L0,50M-50,0L50,0"),n=this.wireframe=(new kity.Rect).stroke("lightgreen"),i=this.vectorIn=(new kity.Path).stroke("#66ffff"),r=this.vectorOut=(new kity.Path).stroke("#66ffff");return i.setMarker(marker,"end"),r.setMarker(marker,"end"),t.addShapes([e,n,i,r])},shouldRender:function(){return wireframeOption},update:function(t,e,n){this.wireframe.setPosition(n.x,n.y).setSize(n.width,n.height);var i=e.getVertexIn(),r=e.getVertexOut(),o=e.getLayoutVectorIn().normalize(30),a=e.getLayoutVectorOut().normalize(30);this.vectorIn.setPathData(["M",i.offset(o.reverse()),"L",i]),this.vectorOut.setPathData(["M",r,"l",a])}});KityMinder.registerModule("OutlineModule",function(){return{events:wireframeOption?{ready:function(){this.getPaper().addResource(marker)},layoutallfinish:function(){this.getRoot().traverse(function(t){t.getRenderer("WireframeRenderer").update(null,t,t.getContentBox())})}}:null,renderers:{outline:OutlineRenderer,outside:[ShadowRenderer,WireframeRenderer]}}}),KityMinder.Geometry=function(){function t(t){return t.width=t.right-t.left,t.height=t.bottom-t.top,t.x=t.left,t.y=t.top,t.cx=t.x+t.width/2,t.cy=t.y+t.height/2,t}function e(t){"x"in t&&(t.left=t.x,t.right=t.x+t.width,t.top=t.y,t.bottom=t.y+t.height)}var n={},i=Math.min,r=Math.max,o=(Math.abs,Object.prototype.hasOwnProperty);return n.isNumberInRange=function(t,e){return t>e[0]&&ta&&u>s?t({left:a,right:l,top:s,bottom:u}):null},n.snapToSharp=function(t){return utils.isNumber(t)?(0|t)+.5:utils.isArray(t)?t.map(n.snapToSharp):(["x","y","left","top","right","bottom"].forEach(function(e){o.call(t,e)&&(t[e]=n.snapToSharp(t[e]))}),t)},n.expandBox=function(e,n,i){return void 0===i&&(i=n),t({left:e.left-n,top:e.top-i,right:e.right+n,bottom:e.bottom+i})},n}(),KityMinder.registerModule("HistoryModule",function(){var t=this,e=kity.createClass("Scene",{constructor:function(t,e){this.data=t.clone(),this.inputStatus=e},getData:function(){return this.data},cloneData:function(){return this.getData().clone()},equals:function(t){return this.getData().equals(t.getData())},isInputStatus:function(){return this.inputStatus},setInputStatus:function(t){this.inputStatus=t}}),n=kity.createClass("HistoryManager",{constructor:function(t){this.list=[],this.index=0,this.hasUndo=!1,this.hasRedo=!1,this.km=t},undo:function(){if(this.hasUndo){var t=this.list[this.index];if(t&&t.isInputStatus())return this.saveScene(),this.restore(--this.index),void t.setInputStatus(!1);if(1==this.list.length)return void this.restore(0);if(!this.list[this.index-1]&&1==this.list.length)return void this.reset();for(;this.list[this.index].equals(this.list[this.index-1]);)if(this.index--,0===this.index)return this.restore(0);this.restore(--this.index)}},redo:function(){if(this.hasRedo){for(;this.list[this.index].equals(this.list[this.index+1]);)if(this.index++,this.index==this.list.length-1)return this.restore(this.index);this.restore(++this.index)}},partialRenewal:function(e){function n(t,e){return t.getText()!=e.getText()?!1:utils.compareObject(t.getData(),e.getData())===!1?!1:utils.compareObject(t.getTmpData(),e.getTmpData())===!1?!1:!0}function i(e,n){n.isSelected()&&o.push(n),t.appendNode(n,e),n.render();for(var r,a=utils.cloneArr(n.children),s=0;r=a[s++];)i(n,r)}function r(e,a){n(e,a)===!1&&e.setValue(a),e.render(),e.isSelected()&&o.push(e);for(var s,l,u=0,c=0;s=e.children[u],l=a.children[c],s||l;u++,c++)s&&!l?(u--,t.removeNode(s)):!s&&l?(c--,i(e,l)):r(s,l)}var o=[];r(t.getRoot(),e),t.layout(200),t.select(o,!0),o=[]},restore:function(t){t=void 0===t?this.index:t;var e=this.list[t];this.partialRenewal(e.cloneData()),this.update(),this.km.fire("restoreScene"),this.km.fire("contentChange")},getScene:function(t){return new e(this.km.getRoot(),t)},saveScene:function(t){var e=this.getScene(t),n=this.list[this.index];return n&&n.equals(e)?void(t&&(n.setInputStatus(!0),this.update())):(this.list=this.list.slice(0,this.index+1),this.list.push(e),this.list.length>this.km.getOptions("maxUndoCount")&&this.list.shift(),this.index=this.list.length-1,void this.update())},update:function(){this.hasRedo=!!this.list[this.index+1],this.hasUndo=!!this.list[this.index-1];var t=this.list[this.index];t&&t.isInputStatus()&&(this.hasUndo=!0)},reset:function(){this.list=[],this.index=0,this.hasUndo=!1,this.hasRedo=!1}});return this.historyManager=new n(this),{defaultOptions:{maxUndoCount:20,maxInputCount:20},commands:{undo:kity.createClass("UndoCommand",{base:Command,execute:function(t){t.historyManager.undo()},queryState:function(t){return t.historyManager.hasUndo?0:-1},isNeedUndo:function(){return!1}}),redo:kity.createClass("RedoCommand",{base:Command,execute:function(t){t.historyManager.redo()},queryState:function(t){return t.historyManager.hasRedo?0:-1},isNeedUndo:function(){return!1}})},commandShortcutKeys:{undo:"ctrl+z",redo:"ctrl+y"},events:{saveScene:function(t){this.historyManager.saveScene(t.inputStatus)},"import":function(){this.historyManager.reset()}}}}),KityMinder.registerModule("ProgressModule",function(){var t=this,e="progress",n="#FFED83",i="#43BC00",r="M10,3c4.418,0,8,3.582,8,8h1c0-5.523-3.477-10-9-10S1,5.477,1,11h1C2,6.582,5.582,3,10,3z",o="#8E8E8E",a="M10,0C4.477,0,0,4.477,0,10c0,5.523,4.477,10,10,10s10-4.477,10-10C20,4.477,15.523,0,10,0zM10,18c-4.418,0-8-3.582-8-8s3.582-8,8-8s8,3.582,8,8S14.418,18,10,18z",s=(new kity.LinearGradient).pipe(function(t){t.setStartPosition(0,0),t.setEndPosition(0,1),t.addStop(0,"#fff"),t.addStop(1,"#ccc")}),l="M15.812,7.896l-6.75,6.75l-4.5-4.5L6.25,8.459l2.812,2.803l5.062-5.053L15.812,7.896z",u="#EEE";t.getPaper().addResource(s);var c=kity.createClass("ProgressIcon",{base:kity.Group,constructor:function(t){this.callBase(),this.setSize(20),this.create(),this.setValue(t),this.setId(KityMinder.uuid("node_progress")),this.translate(.5,.5)},setSize:function(t){this.width=this.height=t},create:function(){var t,e,c,h,d;t=new kity.Circle(9).fill(n),e=new kity.Pie(9,0).fill(i),c=(new kity.Path).setPathData(r).setTranslate(-10,-10).fill(o),h=(new kity.Path).setTranslate(-10,-10).setPathData(a).fill(s),d=(new kity.Path).setTranslate(-10,-10).setPathData(l).fill(u),this.addShapes([t,e,c,d,h]),this.pie=e,this.check=d},setValue:function(t){this.pie.setAngle(-360*(t-1)/8),this.check.setVisible(9==t)}}),h=kity.createClass("ProgressCommand",{base:Command,execute:function(t,n){for(var i=t.getSelectedNodes(),r=0;rn&&r>o?(t=n,e=t/r):e>i&&(e=i,t=e*r),{width:0|t,height:0|e}}var n=kity.createClass("ImageCommand",{base:Command,execute:function(n,i,r){var o=n.getSelectedNodes();t(i,function(t,a){t&&(utils.each(o,function(o,s){var l=e(t,a,n.getOptions("maxImageWidth"),n.getOptions("maxImageHeight"));s.setData("image",i),s.setData("imageTitle",r),s.setData("imageSize",l),s.render()}),n.fire("saveScene"),n.layout(300))})},queryState:function(t){var e=t.getSelectedNodes(),n=0;return 0===e.length?-1:(utils.each(e,function(t,e){return e&&e.getData("image")?(n=0,!1):void 0}),n)},queryValue:function(t){var e=t.getSelectedNode();return{url:e.getData("image"),title:e.getData("imageTitle")}}}),i=kity.createClass("RemoveImageCommand",{base:Command,execute:function(t){var e=t.getSelectedNodes();utils.each(e,function(t,e){e.setData("image").render()}),t.layout(300)},queryState:function(t){var e=t.getSelectedNodes();if(0===e.length)return-1;var n=!1;return utils.each(e,function(t,e){return e.getData("image")?(n=!0,!1):void 0}),n?0:-1}}),r=kity.createClass("ImageRenderer",{base:KityMinder.Renderer,create:function(t){return new kity.Image(t.getData("image"))},shouldRender:function(t){return t.getData("image")},update:function(t,e,n){var i=e.getData("image"),r=e.getData("imageTitle"),o=e.getData("imageSize"),a=e.getStyle("space-top");if(o){r&&t.node.setAttributeNS("http://www.w3.org/1999/xlink","title",r);var s=n.cx-o.width/2,l=n.y-o.height-a;return t.setUrl(i).setX(0|s).setY(0|l).setWidth(0|o.width).setHeight(0|o.height),new kity.Box(0|s,0|l,0|o.width,0|o.height)}}});return{defaultOptions:{maxImageWidth:200,maxImageHeight:200},commands:{image:n,removeimage:i},renderers:{top:r}}}),KityMinder.registerModule("Resource",function(){var t=function(){var t,e,n,i,r,o,a,s,l,u,c;return c=4*(1<<30),t=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],r=[608135816,2242054355,320440878,57701188,2752067618,698298832,137296536,3964562569,1160258022,953160567,3193202383,887688300,3232508343,3380367581,1065670069,3041331479],u=function(t){return 0>t&&(t+=c),("00000000"+t.toString(16)).slice(-8)},o=[[16,50,84,118,152,186,220,254],[174,132,249,109,193,32,123,53],[139,12,37,223,234,99,23,73],[151,19,205,235,98,165,4,143],[9,117,66,250,30,203,134,211],[194,166,176,56,212,87,239,145],[92,241,222,164,112,54,41,184],[189,231,28,147,5,79,104,162],[246,158,59,128,44,125,65,90],[42,72,103,81,191,233,195,13]],a=function(t,e,n){var i=s[t]^s[e];s[t]=i>>>n|i<<32-n},e=function(t,e,u,c,h){var d=i+o[n][t]%16,f=i+(o[n][t]>>4);e%=4,u=4+u%4,c=8+c%4,h=12+h%4,s[e]+=s[u]+(l[d]^r[f%16]),a(h,e,16),s[c]+=s[h],a(u,c,12),s[e]+=s[u]+(l[f]^r[d%16]),a(h,e,8),s[c]+=s[h],a(u,c,7)},function(o,a){a instanceof Array&&4===a.length||(a=[0,0,0,0]);var c,h,d,f,p,g,m,v;for(h=t.slice(0),c=r.slice(0,8),n=0;4>n;n+=1)c[n]^=a[n];if(d=16*o.length,p=d%512>446||d%512===0?0:d,d%512===432)o+="老";else{for(o+="耀";o.length%32!==27;)o+="\x00";o+=""}for(l=[],v=0;vn;n+=1)for(v=0;8>v;v+=1)4>v?e(v,v,v,v,v):e(v,v,v+1,v+2,v+3);for(v=0;8>v;v+=1)h[v]^=a[v%4]^s[v]^s[v+8]}return h.map(u).join("")}}(),e=[51,303,75,200,157,0,26,254].map(function(t){return kity.Color.createHSL(t,100,85)});kity.extendClass(Minder,{getHashCode:function(e){e=t(e);var n,i,r=1315423911;for(n=e.length-1;n>=0;n--)i=e.charCodeAt(n),r^=(r<<5)+i+(r>>2);return 2147483647&r},getResourceColor:function(t){var n,i=this._getResourceColorIndexMapping();return i.hasOwnProperty(t)||(n=this._getNextResourceColorIndex(),i[t]=n),e[i[t]]||kity.Color.createHSL(Math.floor(this.getHashCode(t)/2147483647*359),100,85)},getUsedResource:function(){var t,e=this._getResourceColorIndexMapping(),n=[]; for(t in e)e.hasOwnProperty(t)&&n.push(t);return n},_getNextResourceColorIndex:function(){var t,n,i,r=this._getResourceColorIndexMapping();n=[];for(t in r)r.hasOwnProperty(t)&&n.push(r[t]);for(i=0;i10){this.setStatus("hand",!0);var o=e._minder.getPaper();o.setStyle("cursor","-webkit-grabbing")}}}).on("hand.beforemousedown hand.beforetouchstart",function(t){if(e.isEnabled()){i=t.getPosition(),t.stopPropagation();var n=e._minder.getPaper();n.setStyle("cursor","-webkit-grabbing")}}).on("hand.beforemousemove hand.beforetouchmove",function(t){if(i){r=t.getPosition();var n=kity.Vector.fromPoints(i,r);e.move(n),t.stopPropagation(),t.preventDefault(),t.originEvent.preventDefault(),i=r}}).on("mouseup touchend",t),window.addEventListener("mouseup",t),this._minder.on("contextmenu",function(t){t.preventDefault()})}});KityMinder.registerModule("View",function(){var t=kity.createClass("ToggleHandCommand",{base:Command,execute:function(t){"hand"!=t.getStatus()?t.setStatus("hand",!0):t.rollbackStatus(),this.setContentChanged(!1)},queryState:function(t){return"hand"==t.getStatus()?1:0},enableReadOnly:!0}),e=kity.createClass("CameraCommand",{base:Command,execute:function(t,e,n){e=e||t.getRoot();var i=t.getPaper().getViewPort(),r=e.getRenderContainer().getRenderBox("view"),o=i.center.x-r.x-r.width/2,a=i.center.y-r.y,s=t._viewDragger;s.move(new kity.Point(o,a),n),this.setContentChanged(!1)},enableReadOnly:!0}),n=kity.createClass("MoveCommand",{base:Command,execute:function(t,e,n){var i=t._viewDragger,r=t._lastClientSize;switch(e){case"up":i.move(new kity.Point(0,r.height/2),n);break;case"down":i.move(new kity.Point(0,-r.height/2),n);break;case"left":i.move(new kity.Point(r.width/2,0),n);break;case"right":i.move(new kity.Point(-r.width/2,0),n)}},enableReadOnly:!0});return{init:function(){this._viewDragger=new ViewDragger(this)},commands:{hand:t,camera:e,move:n},events:{keydown:function(t){var e=this;["up","down","left","right"].forEach(function(n){t.isShortcutKey("ctrl+"+n)&&"textedit"!=e.getStatus()&&(e.removeAllSelectedNodes(),e.execCommand("move",n,100),t.preventDefault())}),t.isShortcutKey("ctrl+enter")&&e.execCommand("camera",e.getRoot(),100)},statuschange:function(t){this._viewDragger.setEnabled("hand"==t.currentStatus)},mousewheel:function(t){var e,n;t=t.originEvent,t.ctrlKey||t.shiftKey||("wheelDeltaX"in t?(e=t.wheelDeltaX||0,n=t.wheelDeltaY||0):(e=0,n=t.wheelDelta),this._viewDragger.move({x:e/2.5,y:n/2.5}),t.preventDefault())},"normal.dblclick readonly.dblclick":function(t){t.kityEvent.targetShape instanceof kity.Paper&&this.execCommand("camera",this.getRoot(),800)},ready:function(){this.execCommand("camera",null,0),this._lastClientSize={width:this.getRenderTarget().clientWidth,height:this.getRenderTarget().clientHeight}},resize:function(){var t={width:this.getRenderTarget().clientWidth,height:this.getRenderTarget().clientHeight},e=this._lastClientSize;this._viewDragger.move(new kity.Point((t.width-e.width)/2|0,(t.height-e.height)/2|0)),this._lastClientSize=t},"selectionchange layoutallfinish":function(){var t=this.getSelectedNode();if(t){var e=this._viewDragger,n=e.getView(),i=t.getLayoutBox(),r=50,o=0,a=0;i.right>n.right?o+=n.right-i.right-r:i.leftn.bottom&&(a+=n.bottom-i.bottom-r),i.top=0;r--)i=e[r],i.parent&&(i.parent.removeChild(i),n.appendChild(i),i.render());n.expand(),t.select(e,!0)}}),DropHinter=kity.createClass("DropHinter",{base:kity.Group,constructor:function(){this.callBase(),this.rect=new kity.Rect,this.addShape(this.rect)},render:function(t){this.setVisible(!!t),t&&(this.rect.setBox(t.getLayoutBox()).setRadius(t.getStyle("radius")||0).stroke(t.getStyle("drop-hint-color")||"yellow",t.getStyle("drop-hint-width")||2),this.bringTop())}}),OrderHinter=kity.createClass("OrderHinter",{base:kity.Group,constructor:function(){this.callBase(),this.area=new kity.Rect,this.path=new kity.Path,this.addShapes([this.area,this.path])},render:function(t){this.setVisible(!!t),t&&(this.area.setBox(t.area),this.area.fill(t.node.getStyle("order-hint-area-color")||"rgba(0, 255, 0, .5)"),this.path.setPathData(t.path),this.path.stroke(t.node.getStyle("order-hint-path-color")||"#0f0",t.node.getStyle("order-hint-path-width")||1))}}),TreeDragger=kity.createClass("TreeDragger",{constructor:function(t){this._minder=t,this._dropHinter=new DropHinter,this._orderHinter=new OrderHinter,t.getRenderContainer().addShapes([this._dropHinter,this._orderHinter])},dragStart:function(t){this._startPosition=t},dragMove:function(t){var e=10;if(this._startPosition){var n=kity.Vector.fromPoints(this._dragPosition||this._startPosition,t),i=this._minder;if(this._dragPosition=t,!this._dragMode){if(GM.getDistance(this._dragPosition,this._startPosition)e&&"down"==t.type&&e++,e>i&&"up"==t.type&&e--,t.node.setLayoutOffset(null),this._minder.execCommand("arrange",this._dragSources,e),this._renderOrderHint(null)}else this._minder.fire("savescene");this._minder.layout(300),this._leaveDragMode(),this._minder.fire("contentchange")}},_enterDragMode:function(){return this._calcDragSources(),this._dragSources.length?(this._fadeDragSources(.5),this._calcDropTargets(),this._calcOrderHints(),this._dragMode=!0,this._minder.setStatus("dragtree"),!0):(this._startPosition=null,!1)},_calcDragSources:function(){this._dragSources=this._minder.getSelectedAncestors()},_fadeDragSources:function(t){var e=this._minder;this._dragSources.forEach(function(n){n.getRenderContainer().setOpacity(t,200),n.traverse(function(n){1>t?e.detachNode(n):e.attachNode(n)},!0)})},_calcDropTargets:function(){function t(e,n){var i,r=[];return r.push(n),n.getChildren().forEach(function(n){for(i=0;i.5*Math.min(i(e),i(n))?!0:t.width+1>=Math.min(e.width,n.width)?!0:t.height+1>=Math.min(e.height,n.height)?!0:!1:!1}),this._renderDropHint(this._dropSucceedTarget),!!this._dropSucceedTarget},_orderTest:function(){return this._orderSucceedHint=this._boxTest(this._orderHints,function(t){return t.area}),this._renderOrderHint(this._orderSucceedHint),!!this._orderSucceedHint},_renderDropHint:function(t){this._dropHinter.render(t)},_renderOrderHint:function(t){this._orderHinter.render(t)},preventDragMove:function(){this._startPosition=null}});KityMinder.registerModule("DragTree",function(){var t;return{init:function(){t=new TreeDragger(this),window.addEventListener("mouseup",function(){t.dragEnd()})},events:{"normal.mousedown inputready.mousedown":function(e){e.originEvent.button||e.getTargetNode()&&e.getTargetNode()!=this.getRoot()&&t.dragStart(e.getPosition(this.getRenderContainer()))},"normal.mousemove dragtree.mousemove":function(e){t.dragMove(e.getPosition(this.getRenderContainer()))},"normal.mouseup dragtree.beforemouseup":function(e){t.dragEnd(),e.preventDefault()},statuschange:function(e){"textedit"==e.lastStatus&&"normal"==e.currentStatus&&t.preventDragMove()}},commands:{movetoparent:MoveToParentCommand}}}),KityMinder.registerModule("KeyboardModule",function(){function t(t){var e,i=[];t.traverse(function(t){e=t.getLayoutBox(),e.width&&e.height&&i.push({left:e.x,top:e.y,right:e.x+e.width,bottom:e.y+e.height,width:e.width,height:e.height,node:t,text:t.getText()})});for(var r=0;ru?c:0>c?u:a(u*u+c*c),{cx:h,cy:h}}function n(t,n){for(var i,r,o=t[n],a={},s=0;so.right&&(!a.right||r.cxo.bottom&&(!a.down||r.cy$$_kityminder_bookmark_$$")[0]);var t=[];utils.each(e.container.getElementsByTagName("br"),function(e,n){t.push(n)}),utils.each(t,function(t,e){var n=document.createTextNode("\n");e.parentNode.insertBefore(n,e),e.parentNode.removeChild(e)});var n=e.container.textContent.replace(/[\u200b\t\r]/g,""),r=n.indexOf("$$_kityminder_bookmark_$$");e.re.setContainerTxt(n.replace("$$_kityminder_bookmark_$$","")),e.range.setStartOffset(r).collapse(!0).select(),e._setTextToContainer(i)},50);if(i==keymap.x)return void setTimeout(function(){e._setTextToContainer(i)},50)}this.isShortcutCopyKey=!1,e._setTextToContainer(i)},_beforeKeyup:function(t){var e=this,n=t.originEvent,i=n.keyCode;switch(i){case keymap.Enter:case keymap.Tab:case keymap.Insert:case keymap.F2:return browser.ipad?void(this.selection.isShow()?(this.re.clear(),this.km.setStatus("inputready"),clearTimeout(e.inputTextTimer),t.preventDefault()):(this.km.setStatus("normal"),this.km.fire("contentchange"))):(keymap.Enter==i&&(this.isTypeText||browser.mac&&browser.gecko)&&e._setTextToContainer(i,!0),this.re.keydownNode===this.re.minderNode&&(this.km.rollbackStatus(),this.re.clear()),void t.preventDefault());case keymap.Del:case keymap.Backspace:case keymap.Spacebar:return browser.ipad&&this.selection.isHide()?void this.km.setStatus("normal"):void e._setTextToContainer(i,!0)}return this.isTypeText?void e._setTextToContainer(i,!0):browser.mac&&browser.gecko?void e._setTextToContainer(i,!0):(e._setTextToContainer(i,!0),e.km.fire("saveScene",{inputStatus:!0}),!0)},_keyup:function(){var t,e=this,n=this.km.getSelectedNode();if("normal"==this.km.getStatus()&&n&&this.selection.isHide()){if(this.isShortcutCopyKey)return;n&&this.km.isSingleSelect()&&n.isSelected()&&(this.re.updateByMinderNode(n),this.selection.setHide().setStartOffset(0).setEndOffset(this.re.getTxtOfContainer().length).setColor(n.getStyle("text-selection-color")),setTimeout(function(){e.re.updateContainerRangeBySel()}),browser.ie&&(t=setInterval(function(){var n=e.range.nativeSel.getRangeAt(0);!n||n.collapsed?e.range.select():clearInterval(t)})),this.km.setStatus("inputready"))}},_handlerEnterkey:function(){function t(t){t&&3==t.nodeType&&0===t.nodeValue.length&&t.parentNode.removeChild(t)}var e=this.range,n=document.createElement("br"),i=this;e.collapsed||e.deleteContents(),e.insertNode(n),t(n.previousSibling),t(n.nextSibling),e.setStartAfter(n),e.collapse(!0);var r=e.startContainer.childNodes[e.startOffset];r||(n=n.cloneNode(!1),e.startContainer.appendChild(n),e.setStartBefore(n),e.collapse(!0)),e.select(),i._setTextToContainer(keymap.Enter)}}}()),Minder.Range=kity.createClass("Range",function(){function t(t,e){var n=t[e+"Container"],i=t[e+"Offset"],r=0;return 1==n.nodeType&&(n=n.childNodes[i],!n&&t.startContainer&&"DIV"==t.startContainer.nodeName?(t.startContainer.innerHTML="

    ",i=0):3==n.nodeType&&(i=0)),utils.each(t.container.childNodes,function(t,e){return e===n?1==e.nodeType?!1:(r+=i,!1):void(r+=1==e.nodeType?1:utils.clearWhitespace(e.nodeValue).length)}),r}function e(t,e,n){var i=0,r=t.container;utils.each(r.childNodes,function(o,a){if(1==a.nodeType)return i==e?(t["set"+n](r,o),!1):void i++;var s=utils.clearWhitespace(a.nodeValue).length;return i+s>=e?(t["set"+n](a,e-i),!1):void(i+=s)})}return{constructor:function(t){this.nativeRange=document.createRange(),this.nativeSel=window.getSelection(),this.startContainer=this.endContainer=this.startOffset=this.endOffset=null,this.collapsed=!1,this.container=t||null},hasNativeRange:function(){return 0!==this.nativeSel.rangeCount},deleteContents:function(){return this.nativeRange.deleteContents(),this._updateBoundary()},select:function(){var t=this.nativeRange.startContainer;if(1==t.nodeType&&0===t.childNodes.length){var e=document.createTextNode("​");t.appendChild(e),this.nativeRange.setStart(e,1),this.nativeRange.collapse(!0)}else this.collapsed&&1==t.nodeType&&(t=t.childNodes[this.startOffset],t&&3==t.nodeType&&0===t.nodeValue.length&&(this.nativeRange.setStart(t,1),this.nativeRange.collapse(!0)));try{this.nativeSel.removeAllRanges()}catch(n){}return this.nativeSel.addRange(this.nativeRange),this},_updateBoundary:function(){var t=this.nativeRange;return this.startContainer=t.startContainer,this.startContainer=t.startContainer,this.endContainer=t.endContainer,this.startOffset=t.startOffset,this.endOffset=t.endOffset,this.collapsed=t.collapsed,this},setStartOffset:function(t){return e(this,t,"Start"),this},setEndOffset:function(t){return e(this,t,"End"),this},setStart:function(t,e){return this.nativeRange.setStart(t,e),this._updateBoundary(),this},setStartAfter:function(t){return this.setStart(t.parentNode,utils.getNodeIndex(t)+1)},setStartBefore:function(t){return this.setStart(t.parentNode,utils.getNodeIndex(t))},setEnd:function(t,e){return this.nativeRange.setEnd(t,e),this._updateBoundary(),this},update:function(){return this.updateNativeRange()._updateBoundary(),this},getStart:function(){return this.update(),{startContainer:this.startContainer,startOffset:this.startOffset}},getStartOffset:function(){return t(this,"start")},getEndOffset:function(){return t(this,"end")},collapse:function(t){return this.nativeRange.collapse(t===!0),this._updateBoundary(),this},isCollapsed:function(){return this._updateBoundary(),this.collapsed},insertNode:function(t){return this.nativeRange.insertNode(t),this._updateBoundary()},updateNativeRange:function(){return this.nativeRange=this.nativeSel.getRangeAt(0),this},clear:function(){return this.nativeSel.removeAllRanges(),this}}}()),Minder.Receiver=kity.createClass("Receiver",{clear:function(){return this.container.innerHTML="",this.selection&&this.selection.setHide(),this.range&&this.range.clear(),this.index=0,this},constructor:function(t,e,n){this.setKityMinder(t);var i=document.createElement("div");i.setAttribute("contenteditable",!0),i.className="km_receiver",this.container=i,utils.addCssRule("km_receiver_css"," .km_receiver{white-space:nowrap;position:absolute;padding:0;margin:0;word-wrap:break-word;"+(/\?debug#?/.test(location.href)?"":"clip:rect(1em 1em 1em 1em);")),this.index=0,this.selection=e,this.range=n,this.range.container=i},setRange:function(t,e){this.index=e||this.index,this.range=t,t.setStartOffset(this.index),t.collapse(!0);var n=this;return setTimeout(function(){n.container.focus(),t.select() }),this},setTextGroup:function(t){return this.textGroup=t,this},setKityMinder:function(t){return this.km=t,this},updateByMinderNode:function(t){return this.setMinderNode(t),this._addSelection(),this.setTextGroup(t.getTextGroup()),this.setContainerStyle(),this.updateTextOffsetData(),this.setSelectionHeight(),this.setContainerTxt(),this},setMinderNode:function(t){return this.minderNode=t,this.selection.setMinderNode(t),this},_addSelection:function(){return this.selection.container&&this.selection.remove(),this.minderNode.getRenderContainer().addShape(this.selection),this},getMinderNode:function(){return this.minderNode},updateIndex:function(){return this.index=this.range.getStartOffset(),this},setSelection:function(t){return this.selection=t,this},updateSelection:function(t){return this.selection.update(this.textData,t),this},getOffsetByIndex:function(t){return utils.getValueByIndex(this.textData,void 0!==t?t:this.index)},getBaseOffset:function(){var t=this.textGroup.getRenderBox("screen");return t},setContainerStyle:function(){var t=this.getBaseOffset();return this.container.style.cssText=";left:"+(browser.ipad?"-":"")+t.x+"px;top:"+(t.y+(/\?debug#?/.test(location.href)?this.textGroup.getItems().length*this.getlineHeight():0))+"px;width:"+t.width+"px;height:"+t.height+"px;",this},updateTextOffsetData:function(){var t,e=this,n=this.minderNode.getData("font-size")||this.minderNode.getStyle("font-size"),i=this.minderNode.getStyle("line-height")*n,r=(e.textGroup.getShapes().length*i-(i-n))/2;return this.textData=[],e.textGroup.eachItem(function(n,o){e.textData[n]=[];for(var a=n*i+1,s=o.getContent(),l=0,u=s.length;u>l;l++){try{t=o.getExtentOfChar(l)}catch(c){console.log(c)}e.textData[n].push({x:t.x,y:a-r,width:t.width,height:t.height})}0===s.length&&e.textData[n].push({x:0,y:a-r,width:0,height:i})}),this},getlineHeight:function(){return this.minderNode.getStyle("line-height")*(this.minderNode.getData("font-size")||this.minderNode.getStyle("font-size"))},updateIndexByMouse:function(t){var e=this;e.updateTextOffsetData(),this.index=0;var n=this.getlineHeight();return utils.each(this.textData,function(i,r){var o=r[0];return o.y<=t.y&&o.y+n>=t.y?(utils.each(r,function(n,i){return 0===n&&t.x<=i.x?!1:t.x>=i.x&&t.x<=i.x+i.width?(e.index+=t.x-i.x>i.width/2?n+1:n,!1):n==r.length-1&&t.x>=i.x?(e.index+=1==r.length&&0===r[0].width?0:r.length,!1):void 0}),!1):void(e.index+=r.length+(1==r.length&&0===r[0].width?0:1))}),this.selection.setStartOffset(this.index).collapse(!0),this},setSelectionHeight:function(){return this.selection.setHeight(1*(this.minderNode.getData("font-size")||this.minderNode.getStyle("font-size"))),this},updateSelectionByMousePosition:function(t){var e=this,n=0,i=this.getlineHeight();return utils.each(this.textData,function(r,o){var a=o[0];return a.y<=t.y&&a.y+i>=t.y?(utils.each(o,function(e,i){return 0===e&&t.x<=i.x?!1:t.x>=i.x&&t.x<=i.x+i.width?(n+=e,t.x-i.x>i.width/2&&(n+=1),!1):e==o.length-1&&t.x>=i.x?(n+=1==o.length&&0===o[0].width?0:o.length,!1):void 0}),!1):a.y>t.y&&0===r?(n=0,!1):r==e.textData.length-1&&a.y+i/g,">")}return t?(t=e(t),t=t.replace(/[\n]/g,"
    ")):(t="",this.textGroup.eachItem(function(n,i){t+=e(i.getContent())+"
    "})),this.container.innerHTML=t,this},setReady:function(){this._ready=!0},clearReady:function(){this._ready=!1},isReady:function(){return this._ready},focus:function(){this.container.focus()},getTxtOfContainer:function(){var t="",e=this.container;return utils.each(e.childNodes,function(n,i){3==i.nodeType?t+=i.nodeValue.replace(/[\u200b]/g,""):i!==e.lastChild&&(t+="\n")}),t}}),Minder.Selection=kity.createClass("Selection",{base:kity.Path,constructor:function(t){this.callBase(),this.height=t||20,this.setAttr("id","_kity_selection"),this.width=2,this.fill("rgb(27,171,255)"),this.setHide(),this.timer=null,this.collapsed=!0,this.startOffset=this.endOffset=0,this.setOpacity(.5),this.setStyle("cursor","text"),this._show=!1,this.offset=[],this.setTranslate(-.5,-1.5)},setMinderNode:function(t){this.minderNode=t},setColor:function(t){this.fill(t)},updateOffsetByTextData:function(t){if(this.collapsed)return this.offset=utils.getValueByIndex(t,this.startOffset),this;var e=[],n={},i=this.startOffset,r=this.endOffset,o=0;return utils.each(t,function(t,a){return n={width:0,x:0,y:0},utils.each(a,function(t,e){if(o>=i&&r>=o)if(0===t||o===i)n.x=e.x,n.y=e.y,n.width=e.width;else if(r>o)n.width+=e.width;else if(o===r)return!1;o++}),void 0!==n.x&&e.push(n),o===r?!1:void((1!=a.length||0!==a[0].width)&&o++)}),this.offset=e,this},updatePosition:function(t){var e=this,n=Math.round,i=function(t,e,i,r){return["M",n(t),n(e),"h",n(i),"v",n(r),"h",-n(i),"v",-n(r),"z"]};if(t=void 0!==t?t:this.offset,this.collapsed){if(isNaN(t.x)||isNaN(t.y))return console&&console.warn("editor.selection.js 不正确的偏移位置"),this;this.setPathData(i(t.x,t.y,this.width,this.height))}else this.setPathData(t.reduce(function(t,n){return t.concat(i(n.x,n.y,n.width,e.height))},[]));return this._show=!0,this},collapse:function(t){return this.setOpacity(1),this.collapsed=!0,t?this.endOffset=this.startOffset:this.startOffset=this.endOffset,this},setStartOffset:function(t){return this.startOffset=t,this.startOffset>=this.endOffset?(this.collapse(!0),this):(this.collapsed=!1,this.setOpacity(.5),this)},setEndOffset:function(t){return this.endOffset=t,this.endOffset<=this.startOffset?(this.startOffset=t,this.collapse(!0),this):(this.collapsed=!1,this.setOpacity(.5),this)},update:function(t,e){return t&&this.updateOffsetByTextData(t,e),this.updatePosition(),this.setShow(),this},setHeight:function(t){return this.height=Math.round(t)+2,this},setHide:function(){return clearInterval(this.timer),this.setStyle("display","none"),this._show=!1,this},setHoldShow:function(){return this.setStyle("display",""),clearInterval(this.timer),this},setShow:function(){this.bringTop(),clearInterval(this.timer);var t=this,e="";return t.setStyle("display",""),t._show=!0,this.collapsed&&(t.setOpacity(1),this.timer=setInterval(function(){t.setStyle("display",e),e=e?"":"none"},400)),this},setShowStatus:function(){return this._show=!0,this},isShow:function(){return this._show},isHide:function(){return!this._show}}),KityMinder.registerModule("basestylemodule",function(){function t(t,e){return t.getData(e)||t.getStyle(e)}var e=this;return KityMinder.TextRenderer.registerStyleHook(function(e,n){{var i=t(e,"font-weight"),r=t(e,"font-style");[i,r].join("/")}n.eachItem(function(t,e){e.setFont({weight:i,style:r})})}),{commands:{bold:kity.createClass("boldCommand",{base:Command,execute:function(t){var e=t.getSelectedNodes();1==this.queryState("bold")?utils.each(e,function(t,e){e.setData("font-weight").render()}):utils.each(e,function(t,e){e.setData("font-weight","bold").render()}),t.layout()},queryState:function(){var t=e.getSelectedNodes(),n=0;return 0===t.length?-1:(utils.each(t,function(t,e){return e&&e.getData("font-weight")?(n=1,!1):void 0}),n)}}),italic:kity.createClass("italicCommand",{base:Command,execute:function(t){var e=t.getSelectedNodes();1==this.queryState("italic")?utils.each(e,function(t,e){e.setData("font-style").render()}):utils.each(e,function(t,e){e.setData("font-style","italic").render()}),t.layout()},queryState:function(){var t=e.getSelectedNodes(),n=0;return 0===t.length?-1:(utils.each(t,function(t,e){return e&&e.getData("font-style")?(n=1,!1):void 0}),n)}})},commandShortcutKeys:{bold:"ctrl+b",italic:"ctrl+i"}}}),KityMinder.registerModule("fontmodule",function(){function t(t,e){return t.getData(e)||t.getStyle(e)}KityMinder.TextRenderer.registerStyleHook(function(e,n){var i=e.getData("color"),r=e.getStyle("selected-color"),o=e.getStyle("color"),a=i||(e.isSelected()&&r?r:o),s=t(e,"font-family"),l=t(e,"font-size"),u=[s,l].join("/");n.fill(a),e.setTmpData("fore-color",a.toString()),n.eachItem(function(t,e){e.setFont({family:s,size:l})}),e.setTmpData("font-hash",u)});var e=[{name:"Arial",val:"arial,helvetica,sans-serif"},{name:"arialBlack",val:"arial black,avant garde"},{name:"Comic Sans Ms",val:"comic sans ms"},{name:"Impact",val:"impact,chicago"},{name:"Times New Roman",val:"times new roman"},{name:"Andale Mono",val:"andale mono"}],n=[{name:"宋体",val:"宋体,SimSun"},{name:"微软雅黑",val:"微软雅黑,Microsoft YaHei"},{name:"楷体",val:"楷体,楷体_GB2312,SimKai"},{name:"黑体",val:"黑体, SimHei"},{name:"隶书",val:"隶书, SimLi"},{name:"Sans-Serif",val:"sans-serif"}];return-1!=KITYMINDER_CONFIG.lang.indexOf("zh-")&&(e=n.concat(e)),{defaultOptions:{fontfamily:e,fontsize:[10,12,16,18,24,32,48]},commands:{forecolor:kity.createClass("fontcolorCommand",{base:Command,execute:function(t,e){var n=t.getSelectedNodes();utils.each(n,function(t,n){n.setData("color",e),n.render()})},queryState:function(t){return 0==t.getSelectedNodes().length?-1:0},queryValue:function(t){return 1==t.getSelectedNodes().length?t.getSelectedNodes()[0].getData("color"):"mixed"}}),background:kity.createClass("backgroudCommand",{base:Command,execute:function(t,e){var n=t.getSelectedNodes();utils.each(n,function(t,n){n.setData("background",e),n.render()})},queryState:function(t){return 0==t.getSelectedNodes().length?-1:0},queryValue:function(t){return 1==t.getSelectedNodes().length?t.getSelectedNodes()[0].getData("background"):"mixed"}}),fontfamily:kity.createClass("fontfamilyCommand",{base:Command,execute:function(t,e){var n=t.getSelectedNodes();utils.each(n,function(n,i){i.setData("font-family",e),i.render(),t.layout()})},queryState:function(t){return 0===t.getSelectedNodes().length?-1:0},queryValue:function(t){var e=t.getSelectedNode();return e?e.getData("font-family"):null}}),fontsize:kity.createClass("fontsizeCommand",{base:Command,execute:function(t,e){var n=t.getSelectedNodes();utils.each(n,function(n,i){i.setData("font-size",e),i.render(),t.layout(300)})},queryState:function(t){return 0==t.getSelectedNodes().length?-1:0},queryValue:function(t){var e=t.getSelectedNode();return e?e.getData("font-size"):null}})}}}),KityMinder.registerModule("Zoom",function(){function t(){var t=r._zoomValue>=100?"optimize-speed":"geometricPrecision";r.getRenderContainer().setAttr("text-rendering",t)}function e(t){var e=t.shapeNode,n=e.getCTM(),i=new kity.Matrix(n.a,n.b,n.c,n.d,(0|n.e)+.5,(0|n.f)+.5);e.setAttribute("transform","matrix("+i.toString()+")")}function n(e,n){{var r=e.getPaper();r.getViewPort()}if(n){if(t(),e.getRoot().getComplex()>200)e._zoomValue=n,e.zoom(n),e.fire("viewchange");else{var o=new kity.Animator({beginValue:e._zoomValue,finishValue:n,setter:function(t,e){t.zoom(e)}});e._zoomValue=n,i&&i.pause(),i=o.start(e,300,"easeInOutSine"),i.on("finish",function(){e.fire("viewchange")})}e.fire("zoom",{zoom:n})}}var i,r=this;r.setDefaultOptions("zoom",[10,20,30,50,80,100,120,150,200]),kity.extendClass(Minder,{zoom:function(t){var n=this.getPaper(),i=n.getViewPort();i.zoom=t/100,i.center={x:i.center.x,y:i.center.y},n.setViewPort(i),100==t&&e(n)},getZoomValue:function(){return this._zoomValue}});var o=kity.createClass("Zoom",{base:Command,execute:n,queryValue:function(t){return t._zoomValue}}),a=kity.createClass("ZoomInCommand",{base:Command,execute:function(t){n(t,this.nextValue(t))},queryState:function(t){return+!this.nextValue(t)},nextValue:function(t){var e,n=t.getOptions("zoom");for(e=0;et._zoomValue)return n[e];return 0},enableReadOnly:!0}),s=kity.createClass("ZoomOutCommand",{base:Command,execute:function(t){n(t,this.nextValue(t))},queryState:function(t){return+!this.nextValue(t)},nextValue:function(t){var e,n=t.getOptions("zoom");for(e=n.length-1;e>=0;e--)if(n[e]100&&(clearTimeout(this._wheelZoomTimeout),this._wheelZoomTimeout=setTimeout(function(){n.getPaper()._zoom||1;0>e?n.execCommand("zoom-in"):e>0&&n.execCommand("zoom-out")},100),t.originEvent.preventDefault())}}},commandShortcutKeys:{"zoom-in":"ctrl+=","zoom-out":"ctrl+-"}}}),KityMinder.registerModule("hyperlink",function(){var t="M16.614,10.224h-1.278c-1.668,0-3.07-1.07-3.599-2.556h4.877c0.707,0,1.278-0.571,1.278-1.278V3.834 c0-0.707-0.571-1.278-1.278-1.278h-4.877C12.266,1.071,13.668,0,15.336,0h1.278c2.116,0,3.834,1.716,3.834,3.834V6.39 C20.448,8.508,18.73,10.224,16.614,10.224z M5.112,5.112c0-0.707,0.573-1.278,1.278-1.278h7.668c0.707,0,1.278,0.571,1.278,1.278 S14.765,6.39,14.058,6.39H6.39C5.685,6.39,5.112,5.819,5.112,5.112z M2.556,3.834V6.39c0,0.707,0.573,1.278,1.278,1.278h4.877 c-0.528,1.486-1.932,2.556-3.599,2.556H3.834C1.716,10.224,0,8.508,0,6.39V3.834C0,1.716,1.716,0,3.834,0h1.278 c1.667,0,3.071,1.071,3.599,2.556H3.834C3.129,2.556,2.556,3.127,2.556,3.834z";return{commands:{hyperlink:kity.createClass("hyperlink",{base:Command,execute:function(t,e,n){var i=t.getSelectedNodes();utils.each(i,function(t,i){i.setData("hyperlink",e),i.setData("hyperlinkTitle",n),i.render()}),t.layout()},queryState:function(t){var e=t.getSelectedNodes(),n=0;return 0===e.length?-1:(utils.each(e,function(t,e){return e&&e.getData("hyperlink")?(n=0,!1):void 0}),n)},queryValue:function(t){var e=t.getSelectedNode();return{url:e.getData("hyperlink"),title:e.getData("hyperlinkTitle")}}}),unhyperlink:kity.createClass("hyperlink",{base:Command,execute:function(t){var e=t.getSelectedNodes();utils.each(e,function(t,e){e.setData("hyperlink"),e.render()}),t.layout()},queryState:function(t){var e=t.getSelectedNodes();if(0===e.length)return-1;var n=!1;return utils.each(e,function(t,e){return e.getData("hyperlink")?(n=!0,!1):void 0}),n?0:-1}})},renderers:{right:kity.createClass("hyperlinkrender",{base:KityMinder.Renderer,create:function(){var e=new kity.HyperLink,n=new kity.Path,i=new kity.Rect(24,22,-2,-6,4).fill("rgba(255, 255, 255, 0)");return n.setPathData(t).fill("#666"),e.addShape(i),e.addShape(n),e.setTarget("_blank"),e.setStyle("cursor","pointer"),e.on("mouseover",function(){i.fill("rgba(255, 255, 200, .8)")}).on("mouseout",function(){i.fill("rgba(255, 255, 255, 0)")}),e},shouldRender:function(t){return t.getData("hyperlink")},update:function(t,e,n){var i=e.getData("hyperlink");t.setHref(i);var r=e.getData("hyperlinkTitle");r=r?[r,"(",i,")"].join(""):i,t.node.setAttributeNS("http://www.w3.org/1999/xlink","title",r);var o=e.getStyle("space-right");return t.setTranslate(n.right+o+2,-5),new kity.Box({x:n.right+o,y:-11,width:24,height:22})}})}}}),kity.extendClass(MinderNode,{arrange:function(t){var e=this.parent;if(e){var n=e.children;if(!(0>t||t>=n.length))return n.splice(this.getIndex(),1),n.splice(t,0,this),this}}});var ArrangeUpCommand=kity.createClass("ArrangeUpCommand",{base:Command,execute:function(t){var e=t.getSelectedNodes();e.sort(asc);var n=e.map(function(t){return t.getIndex()});e.forEach(function(t,e){t.arrange(n[e]-1)}),t.layout(300)},queryState:function(t){var e=t.getSelectedNode();return e?0:-1}}),ArrangeDownCommand=kity.createClass("ArrangeUpCommand",{base:Command,execute:function(t){var e=t.getSelectedNodes();e.sort(desc);var n=e.map(function(t){return t.getIndex()});e.forEach(function(t,e){t.arrange(n[e]+1)}),t.layout(300)},queryState:function(t){var e=t.getSelectedNode();return e?0:-1}}),ArrangeCommand=kity.createClass("ArrangeCommand",{base:Command,execute:function(t,e,n){if(e=e&&e.slice()||t.getSelectedNodes().slice(),e.length){var i=MinderNode.getCommonAncestor(e);if(i==e[0].parent){var r=e.map(function(t){return{index:t.getIndex(),node:t}}),o=Math.min.apply(Math,r.map(function(t){return t.index}))>=n;r.sort(function(t,e){return o?e.index-t.index:t.index-e.index}),r.forEach(function(t){t.node.arrange(n)}),t.layout(300)}}},queryState:function(t){var e=t.getSelectedNode();return e?0:-1}});KityMinder.registerModule("ArrangeModule",{commands:{arrangeup:ArrangeUpCommand,arrangedown:ArrangeDownCommand,arrange:ArrangeCommand},contextmenu:[{command:"arrangeup"},{command:"arrangedown"},{divider:!0}],commandShortcutKeys:{arrangeup:"normal::alt+Up",arrangedown:"normal::alt+Down"}}),KityMinder.registerModule("ClipboardModule",function(){function t(e,i){r.push(i),n.appendNode(i,e),i.render(),i.setLayoutOffset(null);for(var o,a=utils.cloneArr(i.children),s=0;o=a[s];s++)t(i,o)}function e(t){t.length&&(t.sort(function(t,e){return t.getIndex()-e.getIndex()}),i=t.map(function(t){return t.clone()}))}var n=this,i=[],r=[],o=kity.createClass("CopyCommand",{base:Command,execute:function(t){e(t.getSelectedAncestors(!0)),this.setContentChanged(!1)}}),a=kity.createClass("CutCommand",{base:Command,execute:function(t){var n=t.getSelectedAncestors();0!==n.length&&(e(n),t.select(MinderNode.getCommonAncestor(n),!0),n.slice().forEach(function(e){t.removeNode(e)}),t.layout(300))}}),s=kity.createClass("PasteCommand",{base:Command,execute:function(e){if(i.length){var n=e.getSelectedNode();if(!n)return;for(var o,a=0;o=i[a];a++)t(n,o.clone());e.select(r,!0),r=[],e.layout(300)}},queryState:function(t){return t.getSelectedNode()?0:-1}});return{commands:{copy:o,cut:a,paste:s},commandShortcutKeys:{copy:"normal::ctrl+c|",cut:"normal::ctrl+x",paste:"normal::ctrl+v"}}}),KityMinder.registerModule("StyleModule",function(){function t(t){for(var n=t.getData(),i=0;i0)for(var a in o)r=t[o[a].marker_id],r&&(i.data[r[0]]=r[1]);else r=t[o.marker_id],r&&(i.data[r[0]]=r[1])}e["xlink:href"]&&(i.data.hyperlink=e["xlink:href"]);var s=e.children&&e.children.topics,l=s&&(s.topic||s[0]&&s[0].topic);if(l){var u=l;if(u.length&&u.length>0){i.children=[];for(var a in u)i.children.push({}),n(u[a],i.children[a])}else i.children=[{}],n(u,i.children[0])}}function i(t){var e=$.xml2json(t),i={},r=e.sheet,o=utils.isArray(r)?r[0].topic:r.topic;return n(o,i),i}function r(t){return new Promise(function(e,n){zip.createReader(new zip.BlobReader(t),function(t){t.getEntries(e)},n)})}function o(t){return new Promise(function(e,n){for(var r,o;(r=t.pop())&&"content.xml"!=r.filename.split("/").pop();)r=null;r?r.getData(new zip.TextWriter,function(t){try{o=i($.parseXML(t)),e(o)}catch(r){n(r)}}):n(new Error("Content document missing"))})}return r(e).then(o)},encode:function(t,e,n){function i(){return new Promise(function(t,e){var n=new XMLHttpRequest;n.open("POST",o),n.responseType="blob",n.onload=t,n.onerror=e;var i=new FormData;i.append("type","xmind"),i.append("data",a),n.send(i)}).then(function(t){return t.target.response})}function r(){function t(t,e){var n=document.createElement("input");return n.type="hidden",n.name=t,n.value=e,n}var e=n.filename||"xmind.xmind",i=document.createElement("form");i.setAttribute("action",o),i.setAttribute("method","POST"),i.appendChild(t("filename",e)),i.appendChild(t("type","xmind")),i.appendChild(t("data",a)),i.appendChild(t("download","1")),document.body.appendChild(i),i.submit(),document.body.removeChild(i)}var o="native-support/export.php",a=JSON.stringify(t);return n&&n.download?r():i()},recognizePriority:-1}}),KityMinder.registerProtocol("freemind",function(){function t(e,i){i.data={text:e.TEXT};var r;if(e.icon){var o,a=e.icon;if(a.length&&a.length>0)for(r in a)o=n[a[r].BUILTIN],o&&(i.data[o[0]]=o[1]);else o=n[a.BUILTIN],o&&(i.data[o[0]]=o[1])}if(e.LINK&&(i.data.hyperlink=e.LINK),e.node){var s=e.node;if(s.length&&s.length>0){i.children=[];for(r in s)i.children.push({}),t(s[r],i.children[r])}else i.children=[{}],t(s,i.children[0])}}function e(e){var n=$.xml2json(e),i={};return t(n.node,i),i}var n={"full-1":["priority",1],"full-2":["priority",2],"full-3":["priority",3],"full-4":["priority",4],"full-5":["priority",5],"full-6":["priority",6],"full-7":["priority",7],"full-8":["priority",8]};return{fileDescription:"Freemind 格式",fileExtension:".mm",dataType:"text",decode:function(t){return new Promise(function(n,i){try{n(e(t))}catch(r){i(new Error("XML 文件损坏!"))}})},encode:function(t,e,n){function i(){return new Promise(function(t,e){var n=new XMLHttpRequest;n.open("POST",o),n.responseType="blob",n.onload=t,n.onerror=e;var i=new FormData;i.append("type","freemind"),i.append("data",a),n.send(i)}).then(function(t){return t.target.response})}function r(){function t(t,e){var n=document.createElement("input");return n.type="hidden",n.name=t,n.value=e,n}var e=n.filename||"freemind.mm",i=document.createElement("form");i.setAttribute("action",o),i.setAttribute("method","POST"),i.appendChild(t("filename",e)),i.appendChild(t("type","freemind")),i.appendChild(t("data",a)),i.appendChild(t("download","1")),document.body.appendChild(i),i.submit(),document.body.removeChild(i)}var o="native-support/export.php",a=JSON.stringify(t);return n&&n.download?r():i()}}}),KityMinder.registerProtocol("mindmanager",function(){function t(e,n){if(n.data={text:e.Text&&e.Text.PlainText||""},e.Task){var i;e.Task.TaskPriority&&(i=r[e.Task.TaskPriority],i&&(n.data[i[0]]=i[1])),e.Task.TaskPercentage&&(i=r[e.Task.TaskPercentage],i&&(n.data[i[0]]=i[1]))}if(e.Hyperlink&&(n.data.hyperlink=e.Hyperlink.Url),e.SubTopics&&e.SubTopics.Topic){var o=e.SubTopics.Topic;if(o.length&&o.length>0){n.children=[];for(var a in o)n.children.push({}),t(o[a],n.children[a])}else n.children=[{}],t(o,n.children[0])}}function e(e){var n=$.xml2json(e),i={};return t(n.OneTopic.Topic,i),i}function n(t){return new Promise(function(e,n){zip.createReader(new zip.BlobReader(t),function(t){t.getEntries(e)},n)})}function i(t){return new Promise(function(n,i){for(var r,o;(r=t.pop())&&"Document.xml"!=r.filename.split("/").pop();)r=null;r?r.getData(new zip.TextWriter,function(t){o=e($.parseXML(t)),n(o)}):i(new Error("Main document missing"))})}var r={"urn:mindjet:Prio1":["PriorityIcon",1],"urn:mindjet:Prio2":["PriorityIcon",2],"urn:mindjet:Prio3":["PriorityIcon",3],"urn:mindjet:Prio4":["PriorityIcon",4],"urn:mindjet:Prio5":["PriorityIcon",5],0:["ProgressIcon",1],25:["ProgressIcon",2],50:["ProgressIcon",3],75:["ProgressIcon",4],100:["ProgressIcon",5]};return{fileDescription:"MindManager 格式",fileExtension:".mmap",dataType:"blob",decode:function(t){return n(t).then(i)},encode:null,recognizePriority:-1}}),KityMinder.registerProtocol("plain",function(){function t(t,e){for(var n="";e--;)n+=t;return n}function e(n,i){var r="";return i=i||0,r+=t(l,i),r+=n.data.text+a,n.children&&n.children.forEach(function(t){r+=e(t,i+1)}),r}function n(t){return!/\S/.test(t)}function i(t){for(var e=0;t.charAt(e)===l;)e++;return e}function r(t){return{data:{text:t.replace(new RegExp("^"+l+"*"),"")}}}function o(t,e){function o(t,e){var n=t.children||(t.children=[]);n.push(e)}var a,l,u,c,h,d={},f=t.split(s);e?(d[0]=a=r("root"),l=1):l=0;for(var p=0;pu+1?c&&o(c,n):(u=i.level,c=r(i.content,f[u-1]),f[u]=c));return s(f[1]),f[1]}function r(t,e){var n={data:{text:t,note:""}};return e&&(e.children?e.children.push(n):e.children=[n]),n}function o(t,e){t.data.note+=e+"\n"}function a(t){var e=/^(#+)?\s*(.*)$/.exec(t);return{level:e[1]&&e[1].length||null,content:e[2],noteStart:t==c,noteClose:t==h,codeBlock:/^\s*```/.test(t)}}function s(t){if(/\S/.test(t.data.note)){for(var e=t.data.note.split("\n");e.length&&!/\S/.test(e[0]);)e.shift();for(;e.length&&!/\S/.test(e[e.length-1]);)e.pop();t.data.note=e.join("\n")}else t.data.note=null,delete t.data.note;t.children&&t.children.forEach(s)}var l=/\r\n|\r|\n/,u="",c="",h="";return{fileDescription:"Markdown/GFM 格式",fileExtension:".md",mineType:"text/markdown",dataType:"text",encode:function(e){return t(e)},decode:function(t){return i(t)},recognizePriority:-1}}),KityMinder.registerProtocol("json",function(){return{fileDescription:"KityMinder 格式",fileExtension:".km",dataType:"text",mineType:"application/json",encode:function(t){return JSON.stringify(t)},decode:function(t){return JSON.parse(t)}}}),kity.Browser.ie||KityMinder.registerProtocol("png",function(t){function e(t){return new Promise(function(e,n){var i=document.createElement("img");i.onload=function(){e(this)},i.onerror=function(t){n(t)},i.crossOrigin="",i.src=t})}function n(){var e,n,i,o,a,s=t.getPaper(),l=(s.container,t.getRenderContainer()),u=l.getRenderBox(),c=u.width+1,h=u.height+1;return e=s.shapeNode.getAttribute("transform"),s.shapeNode.setAttribute("transform","translate(0.5, 0.5)"),l.translate(-u.x,-u.y),n=s.container.innerHTML,l.translate(u.x,u.y),s.shapeNode.setAttribute("transform",e),i=$(n).filter("svg"),i.attr({width:u.width+1,height:u.height+1,style:'font-family: Arial, "Microsoft Yahei","Heiti SC";'}),n=$("
    ").append(i).html(),n=n.replace(' xmlns="http://www.w3.org/2000/svg" xmlns:NS1="" NS1:ns1:xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:NS2="" NS2:xmlns:ns1=""',""),n=n.replace(/ /g," "),o=new Blob([n],{type:"image/svg+xml"}),a=r.createObjectURL(o),{width:c,height:h,dataUrl:a,xml:n}}function i(){function i(t,e){t.save(),t.fillStyle=e,t.fillRect(0,0,l.width,l.height),t.restore()}function o(t,e,n,i){t.drawImage(e,n,i)}function a(t){try{var e=t.toDataURL("png");return e}catch(n){throw new Error("当前浏览器版本不支持导出 PNG 功能,请尝试升级到最新版本!")}}function s(){return"undefined"!=typeof window.canvg?new Promise(function(t){window.canvg(l,f.xml,{ignoreMouse:!0,ignoreAnimation:!0,ignoreDimensions:!0,ignoreClear:!0,offsetX:v,offsetY:v,renderCallback:function(){t(a(l))}})}):e(m).then(function(t){return o(u,t,v,v),r.revokeObjectURL(m),a(l)})}var l=document.createElement("canvas"),u=l.getContext("2d"),c=t.getStyle("background").toString(),h=/url\((.+)\)/.exec(c),d=kity.Color.parse(c),f=n(),p=f.width,g=f.height,m=f.dataUrl,v=20;return l.width=p+2*v,l.height=g+2*v,h?e(h[1]).then(function(t){return i(u,u.createPattern(t,"repeat")),s()}):(i(u,d.toString()),s())}var r=window.URL||window.webkitURL||window;return{fileDescription:"PNG 图片",fileExtension:".png",mineType:"image/png",dataType:"base64",encode:i,recognizePriority:-1}}),kity.Browser.ie||KityMinder.registerProtocol("svg",function(t){return{fileDescription:"SVG 矢量图",fileExtension:".svg",mineType:"image/svg+xml",dataType:"text",encode:function(){var e,n,i=t.getPaper(),r=i.shapeNode.getAttribute("transform"),o=t.getRenderContainer(),a=o.getRenderBox(),s=(o.getTransform(),a.width),l=a.height,u=20;return i.shapeNode.setAttribute("transform","translate(0.5, 0.5)"),e=i.container.innerHTML,i.shapeNode.setAttribute("transform",r),n=$(e).filter("svg"),n.attr({width:s+2*u|0,height:l+2*u|0,style:'font-family: Arial, "Microsoft Yahei", "Heiti SC"; background: '+t.getStyle("background")}),n[0].setAttribute("viewBox",[a.x-u|0,a.y-u|0,s+2*u|0,l+2*u|0].join(" ")),e=$("
    ").append(n).html(),e=$("
    ").append(n).html(),e=e.replace(/ /g," ")},recognizePriority:-1}}),function(){var t=[];KityMinder.registerUI=function(e,n,i){"function"==typeof n&&(i=n,n=null),t.push({id:e,ui:i,deps:n})},kity.extendClass(Minder,{initUI:function(e){var n=this._ui={},i=this;t.forEach(function(t){var e=t.deps;e&&(e=e.map(function(t){return i.getUI(t)})),n[t.id]=t.ui.apply(null,[i].concat(e||[]))}),$("#content-wrapper").delegate("#panel, #tab-container, .fui-dialog, #main-menu","keydown keyup",function(t){t.stopPropagation()}),$("#content-wrapper").delegate("input","mousedown mousemove mouseup contextmenu",function(t){t.stopPropagation()}),i.getPaper().addClass("loading-target"),this.fire("interactchange"),this.fire("uiready"),setTimeout(function(){e&&e()},10)},getUI:function(t){return this._ui[t]}}),$.ajaxSetup({cache:!1}),$.extend($,{pajax:function(){var t=$.ajax.apply($,arguments);return new Promise(function(e,n){t.done(e),t.fail(function(t,e,i){var r=new Error(e);r.getDetail=function(){try{return"jQuery XHR Error: \n"+JSON.stringify(i)}catch(t){return i}},n(r)})})}}),$(function(){var t=["kmcat_warn.png","kmcat_sad.png","icons.png","template_large.png","history.png","feedback.png","iconpriority.png","iconprogress.png","template.png","layout.png","next-level.png","prev-level.png"];t.forEach(function(t){(new Image).src="ui/theme/default/images/"+t})})}(),KityMinder.registerUI("eve",function(){return{setup:function(t){var e={};return t.on=function(t,n){var i=e[t]||(e[t]=[]);return i.push(n),this},t.off=function(t,n){var i=e[t];if(i){var r=i.indexOf(n);~r?i.splice(r,1):n[t]=null}return this},t.once=function(e,n){return this.on(e,function i(){n.apply(t,arguments),t.off(e,i)})},t.fire=function(n){var i=e[n],r=[].slice.call(arguments,1); return i&&i.forEach(function(e){e.apply(t,r)}),this},t}}}),KityMinder.registerUI("memory",function(){var t=window.localStorage,e=t.uiMemory?JSON.parse(t.uiMemory):{};return{get:function(t){return e[t]||null},set:function(n,i){e[n]=i,t.uiMemory=JSON.stringify(e)}}}),kity.extendClass(FUI.Widget,{setEnable:function(t){t===!1?this.disable():this.enable()},setActive:function(t){t===!1?this.removeClass("active"):this.addClass("active")},bindExecution:function(t,e){var n=this;n.on(t,function(){n.interactFlag||e.apply(n,arguments)})},bindCommandState:function(t,e,n){var i=this;t.on("interactchange",function(){if(i.interactFlag=!0,n){var t=this.queryCommandValue(e);t!=i.lastHandleCommandValue&&(n.call(i,t),i.lastHandleCommandValue=t)}i.setEnable(-1!==this.queryCommandState(e)),i.setActive(1===this.queryCommandState(e)),i.interactFlag=!1})}}),KityMinder.registerUI("axss",function(){function t(t){var e=document.createElement("div");e.innerHTML=t,$(e).find("script, iframe, link").remove();for(var n in e)0===n.indexOf("on")&&e.removeAttribute(n);return e.innerHTML}return t}),KityMinder.registerUI("widget/commandbutton",function(t){return{generate:function(e,n){var i=new FUI.Button({label:t.getLang("ui.command."+e)||t.getLang("ui."+e),text:t.getLang("ui.command."+e)||t.getLang("ui."+e),className:["command-widget","command-button",e]});return i.bindExecution("click",n||function(){t.execCommand(e)}),i.bindCommandState(t,e),i}}}),KityMinder.registerUI("widget/commandbuttonset",function(t){function e(e,n){return n.map(function(n){var i=t.getLang([e,n].join("."))||n;return{label:i,text:i,value:n,className:[e,n].join(" ")}})}function n(n,i){var r=new FUI.Buttonset({id:"template-set",buttons:"object"==typeof i[0]?i:e(n,i),className:["command-widget","command-buttonset",n].join(" ")});return r.bindExecution("change",function(){t.execCommand(n,r.getValue())}),r.bindCommandState(t,n,function(t){this.selectByValue(t)}),r}return{generate:n}}),KityMinder.registerUI("widget/commandinputmenu",function(t){function e(e,n){var i=new FUI.InputMenu({menu:{items:n},input:{placeholder:t.getLang("ui."+e)},className:["command-widget","command-inputmenu",e]});i.bindCommandState(t,e,function(t){i.selectByValue(t)||i.clearSelect()});var r=-1;return i.bindExecution("select",function(n,o){~o.index?t.execCommand(e,o.value):i.select(r),r=o.index}),i}return{generate:e}}),KityMinder.registerUI("widget/commandselectmenu",function(t){function e(e,n){return n.map(function(n){var i=t.getLang([e,n].join("."))||n;return{clazz:"Button",label:i,text:i,value:n,className:[e,n].join(" ")}})}function n(n,i,r){var o=new FUI.SelectMenu({widgets:"object"==typeof i[0]?i:e(n,i),className:["command-widget","command-selectmenu",n].join(" "),column:r||3});return o.bindExecution("change",function(){t.execCommand(n,o.getValue())}),o.bindCommandState(t,n,function(t){void 0!==t&&this.selectByValue(t)}),o}return{generate:n}}),KityMinder.registerUI("widget/notice",function(t){function e(t,e){function n(){var e=t.text(),n=new RegExp("at.+"+p+".+\\:(\\d+)\\:(\\d+)\\)?","g");t.text(e.replace(n,function(t,e,n){var i={line:+e,column:+n},r=d.originalPositionFor(i),o=r.name;i={line:r.line,column:r.column},r=h.originalPositionFor(i),o=o||"";var a="at "+o+" ("+r.source.replace("../","")+":"+r.line+":"+r.column+")";return-1!=a.indexOf("promise")&&(a="at Promise."+o),a}))}if(p){if(h)return n();e.addClass("loading"),setTimeout(function(){e.removeClass("loading")},5e3);var i=document.createElement("script");i.onload=function(){Promise.all([$.pajax({url:p.replace("min.js","js.map"),dataType:"json"}),$.pajax({url:p.replace(".js",".map"),dataType:"json"})]).then(function(t){h=new window.sourceMap.SourceMapConsumer(t[0]),d=new window.sourceMap.SourceMapConsumer(t[1]),n(),e.removeClass("loading")})},i.src="lib/source-map.min.js",document.head.appendChild(i)}}function n(e,i,r){u.hasClass("show")||u.empty(),clearTimeout(n.ttl2),i?u.addClass("warn"):u.removeClass("warn");var o=t.getUI("menu/menu");u.css({top:o&&o.isVisible()?$("#main-menu .main-menu-level1").offset().top:$("#kityminder").offset().top+20}),u.append($("

    ").text(e)),u.addClass("show"),clearTimeout(n.ttl),r=r||(i?5e3:3e3),n.ttl=setTimeout(function(){u.removeClass("show"),n.ttl2=setTimeout(function(){u.empty()},1e3)},r)}function i(t){n(t,i)}function r(t){return t=t||new Error,"string"==typeof t&&(t=new Error(t)),t.getDetail?t:("undefined"!=typeof fio&&t instanceof fio.FileRequestError?(t.description=t.status?s.pcs_code[t.detail.error_code]:s.err_network,t.getDetail=function(){return JSON.stringify(t,null,4)}):"readyState"in t||(t.getDetail=function(){return t.stack||(new Error).stack}),t)}function o(n,i){1==arguments.length&&(i=n,n="unknown"),f.empty(),i=r(i);{var u=$("

    ").addClass("error-content").appendTo(f);$("

    ").text(s[n]||s.err_unknown).appendTo(u),$("

    ").text(i.message||i.description||s.unknownreason).appendTo(u)}if(i.getDetail){var h=$("

    ").addClass("error-detail").append($('').text(t.getLang("ui.error_detail"))).appendTo(f),d=$("
    ").addClass("error-detail-wrapper").appendTo(h),p=$("