@logicflow/extension 2.0.0-beta.8 → 2.0.0-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +754 -754
- package/dist/index.min.js +1 -1
- package/es/tools/label/LabelOverlay.js +1 -1
- package/es/tools/label/index.js +1 -1
- package/lib/tools/label/LabelOverlay.js +1 -1
- package/lib/tools/label/index.js +1 -1
- package/package.json +2 -2
- package/src/tools/label/LabelOverlay.tsx +1 -1
- package/src/tools/label/index.ts +1 -1
package/dist/index.min.js
CHANGED
|
@@ -38,5 +38,5 @@ var cm,dm=4294967295,pm=Array.prototype,hm=Object.prototype.hasOwnProperty,fm=Cr
|
|
|
38
38
|
*
|
|
39
39
|
* Copyright 2017-2024 Andreas Borgen (https://github.com/Sphinxxxx), Adam Brooks (https://github.com/dissimulate)
|
|
40
40
|
* Released under the ISC license.
|
|
41
|
-
*/String.prototype.startsWith=String.prototype.startsWith||function(t){return 0===this.indexOf(t)},String.prototype.padStart=String.prototype.padStart||function(t,e){for(var n=this;n.length<t;)n=e+n;return n};var yT={cb:"0f8ff",tqw:"aebd7",q:"-ffff",qmrn:"7fffd4",zr:"0ffff",bg:"5f5dc",bsq:"e4c4",bck:"---",nch:"ebcd",b:"--ff",bvt:"8a2be2",brwn:"a52a2a",brw:"deb887",ctb:"5f9ea0",hrt:"7fff-",chcT:"d2691e",cr:"7f50",rnw:"6495ed",crns:"8dc",crms:"dc143c",cn:"-ffff",Db:"--8b",Dcn:"-8b8b",Dgnr:"b8860b",Dgr:"a9a9a9",Dgrn:"-64-",Dkhk:"bdb76b",Dmgn:"8b-8b",Dvgr:"556b2f",Drng:"8c-",Drch:"9932cc",Dr:"8b--",Dsmn:"e9967a",Dsgr:"8fbc8f",DsTb:"483d8b",DsTg:"2f4f4f",Dtrq:"-ced1",Dvt:"94-d3",ppnk:"1493",pskb:"-bfff",mgr:"696969",grb:"1e90ff",rbrc:"b22222",rwht:"af0",stg:"228b22",chs:"-ff",gnsb:"dcdcdc",st:"8f8ff",g:"d7-",gnr:"daa520",gr:"808080",grn:"-8-0",grnw:"adff2f",hnw:"0fff0",htpn:"69b4",nnr:"cd5c5c",ng:"4b-82",vr:"0",khk:"0e68c",vnr:"e6e6fa",nrb:"0f5",wngr:"7cfc-",mnch:"acd",Lb:"add8e6",Lcr:"08080",Lcn:"e0ffff",Lgnr:"afad2",Lgr:"d3d3d3",Lgrn:"90ee90",Lpnk:"b6c1",Lsmn:"a07a",Lsgr:"20b2aa",Lskb:"87cefa",LsTg:"778899",Lstb:"b0c4de",Lw:"e0",m:"-ff-",mgrn:"32cd32",nn:"af0e6",mgnt:"-ff",mrn:"8--0",mqm:"66cdaa",mmb:"--cd",mmrc:"ba55d3",mmpr:"9370db",msg:"3cb371",mmsT:"7b68ee","":"-fa9a",mtr:"48d1cc",mmvt:"c71585",mnLb:"191970",ntc:"5fffa",mstr:"e4e1",mccs:"e4b5",vjw:"dead",nv:"--80",c:"df5e6",v:"808-0",vrb:"6b8e23",rng:"a5-",rngr:"45-",rch:"da70d6",pgnr:"eee8aa",pgrn:"98fb98",ptrq:"afeeee",pvtr:"db7093",ppwh:"efd5",pchp:"dab9",pr:"cd853f",pnk:"c0cb",pm:"dda0dd",pwrb:"b0e0e6",prp:"8-080",cc:"663399",r:"--",sbr:"bc8f8f",rb:"4169e1",sbrw:"8b4513",smn:"a8072",nbr:"4a460",sgrn:"2e8b57",ssh:"5ee",snn:"a0522d",svr:"c0c0c0",skb:"87ceeb",sTb:"6a5acd",sTgr:"708090",snw:"afa",n:"-ff7f",stb:"4682b4",tn:"d2b48c",t:"-8080",thst:"d8bfd8",tmT:"6347",trqs:"40e0d0",vt:"ee82ee",whT:"5deb3",wht:"",hts:"5f5f5",w:"-",wgrn:"9acd32"};function mT(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return(e>0?t.toFixed(e).replace(/0+$/,"").replace(/\.$/,""):t.toString())||"0"}var bT=function(){function t(e,n,o,r){fT(this,t);var i=this;if(void 0===e);else if(Array.isArray(e))this.rgba=e;else if(void 0===o){var a=e&&""+e;a&&function(e){if(e.startsWith("hsl")){var n=e.match(/([\-\d\.e]+)/g).map(Number),o=vT(n,4),r=o[0],a=o[1],s=o[2],l=o[3];void 0===l&&(l=1),r/=360,a/=100,s/=100,i.hsla=[r,a,s,l]}else if(e.startsWith("rgb")){var u=e.match(/([\-\d\.e]+)/g).map(Number),c=vT(u,4),d=c[0],p=c[1],h=c[2],f=c[3];void 0===f&&(f=1),i.rgba=[d,p,h,f]}else e.startsWith("#")?i.rgba=t.hexToRgb(e):i.rgba=t.nameToRgb(e)||t.hexToRgb(e)}(a.toLowerCase())}else this.rgba=[e,n,o,void 0===r?1:r]}return gT(t,[{key:"printRGB",value:function(t){var e=(t?this.rgba:this.rgba.slice(0,3)).map((function(t,e){return mT(t,3===e?3:0)}));return t?"rgba("+e+")":"rgb("+e+")"}},{key:"printHSL",value:function(t){var e=[360,100,100,1],n=["","%","%",""],o=(t?this.hsla:this.hsla.slice(0,3)).map((function(t,o){return mT(t*e[o],3===o?3:1)+n[o]}));return t?"hsla("+o+")":"hsl("+o+")"}},{key:"printHex",value:function(t){var e=this.hex;return t?e:e.substring(0,7)}},{key:"rgba",get:function(){if(this._rgba)return this._rgba;if(!this._hsla)throw new Error("No color is set");return this._rgba=t.hslToRgb(this._hsla)},set:function(t){3===t.length&&(t[3]=1),this._rgba=t,this._hsla=null}},{key:"rgbString",get:function(){return this.printRGB()}},{key:"rgbaString",get:function(){return this.printRGB(!0)}},{key:"hsla",get:function(){if(this._hsla)return this._hsla;if(!this._rgba)throw new Error("No color is set");return this._hsla=t.rgbToHsl(this._rgba)},set:function(t){3===t.length&&(t[3]=1),this._hsla=t,this._rgba=null}},{key:"hslString",get:function(){return this.printHSL()}},{key:"hslaString",get:function(){return this.printHSL(!0)}},{key:"hex",get:function(){var t=this.rgba.map((function(t,e){return e<3?t.toString(16):Math.round(255*t).toString(16)}));return"#"+t.map((function(t){return t.padStart(2,"0")})).join("")},set:function(e){this.rgba=t.hexToRgb(e)}}],[{key:"hexToRgb",value:function(t){var e=(t.startsWith("#")?t.slice(1):t).replace(/^(\w{3})$/,"$1F").replace(/^(\w)(\w)(\w)(\w)$/,"$1$1$2$2$3$3$4$4").replace(/^(\w{6})$/,"$1FF");if(!e.match(/^([0-9a-fA-F]{8})$/))throw new Error("Unknown hex color; "+t);var n=e.match(/^(\w\w)(\w\w)(\w\w)(\w\w)$/).slice(1).map((function(t){return parseInt(t,16)}));return n[3]=n[3]/255,n}},{key:"nameToRgb",value:function(e){var n=e.toLowerCase().replace("at","T").replace(/[aeiouyldf]/g,"").replace("ght","L").replace("rk","D").slice(-5,4),o=yT[n];return void 0===o?o:t.hexToRgb(o.replace(/\-/g,"00").padStart(6,"f"))}},{key:"rgbToHsl",value:function(t){var e=vT(t,4),n=e[0],o=e[1],r=e[2],i=e[3];n/=255,o/=255,r/=255;var a=Math.max(n,o,r),s=Math.min(n,o,r),l=void 0,u=void 0,c=(a+s)/2;if(a===s)l=u=0;else{var d=a-s;switch(u=c>.5?d/(2-a-s):d/(a+s),a){case n:l=(o-r)/d+(o<r?6:0);break;case o:l=(r-n)/d+2;break;case r:l=(n-o)/d+4}l/=6}return[l,u,c,i]}},{key:"hslToRgb",value:function(t){var e=vT(t,4),n=e[0],o=e[1],r=e[2],i=e[3],a=void 0,s=void 0,l=void 0;if(0===o)a=s=l=r;else{var u=function(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t},c=r<.5?r*(1+o):r+o-r*o,d=2*r-c;a=u(d,c,n+1/3),s=u(d,c,n),l=u(d,c,n-1/3)}var p=[255*a,255*s,255*l].map(Math.round);return p[3]=i,p}}]),t}(),_T=function(){function t(){fT(this,t),this._events=[]}return gT(t,[{key:"add",value:function(t,e,n){t.addEventListener(e,n,!1),this._events.push({target:t,type:e,handler:n})}},{key:"remove",value:function(e,n,o){this._events=this._events.filter((function(r){var i=!0;return e&&e!==r.target&&(i=!1),n&&n!==r.type&&(i=!1),o&&o!==r.handler&&(i=!1),i&&t._doRemove(r.target,r.type,r.handler),!i}))}},{key:"destroy",value:function(){this._events.forEach((function(e){return t._doRemove(e.target,e.type,e.handler)})),this._events=[]}}],[{key:"_doRemove",value:function(t,e,n){t.removeEventListener(e,n,!1)}}]),t}();function xT(t,e,n){var o=!1;function r(t,e,n){return Math.max(e,Math.min(t,n))}function i(t,i,a){if(a&&(o=!0),o){t.preventDefault();var s=e.getBoundingClientRect(),l=s.width,u=s.height,c=i.clientX,d=i.clientY,p=r(c-s.left,0,l),h=r(d-s.top,0,u);n(p/l,h/u)}}function a(t,e){1===(void 0===t.buttons?t.which:t.buttons)?i(t,t,e):o=!1}function s(t,e){1===t.touches.length?i(t,t.touches[0],e):o=!1}t.add(e,"mousedown",(function(t){a(t,!0)})),t.add(e,"touchstart",(function(t){s(t,!0)})),t.add(window,"mousemove",a),t.add(e,"touchmove",s),t.add(window,"mouseup",(function(t){o=!1})),t.add(e,"touchend",(function(t){o=!1})),t.add(e,"touchcancel",(function(t){o=!1}))}var ET="keydown",wT="mousedown",ST="focusin";function CT(t,e){return(e||document).querySelector(t)}function MT(t){t.preventDefault(),t.stopPropagation()}function OT(t,e,n,o,r){t.add(e,ET,(function(t){n.indexOf(t.key)>=0&&(r&&MT(t),o(t))}))}var TT=function(){function t(e){fT(this,t),this.settings={popup:"right",layout:"default",alpha:!0,editor:!0,editorFormat:"hex",cancelButton:!1,defaultColor:"#0cf"},this._events=new _T,this.onChange=null,this.onDone=null,this.onOpen=null,this.onClose=null,this.setOptions(e)}return gT(t,[{key:"setOptions",value:function(t){var e=this;if(t){var n=this.settings;if(t instanceof HTMLElement)n.parent=t;else{n.parent&&t.parent&&n.parent!==t.parent&&(this._events.remove(n.parent),this._popupInited=!1),function(t,e,n){for(var o in t)n&&n.indexOf(o)>=0||(e[o]=t[o])}(t,n),t.onChange&&(this.onChange=t.onChange),t.onDone&&(this.onDone=t.onDone),t.onOpen&&(this.onOpen=t.onOpen),t.onClose&&(this.onClose=t.onClose);var o=t.color||t.colour;o&&this._setColor(o)}var r=n.parent;if(r&&n.popup&&!this._popupInited){var i=function(t){return e.openHandler(t)};this._events.add(r,"click",i),OT(this._events,r,[" ","Spacebar","Enter"],i),this._popupInited=!0}else t.parent&&!n.popup&&this.show()}}},{key:"openHandler",value:function(t){if(this.show()){t&&t.preventDefault(),this.settings.parent.style.pointerEvents="none";var e=t&&t.type===ET?this._domEdit:this.domElement;setTimeout((function(){return e.focus()}),100),this.onOpen&&this.onOpen(this.colour)}}},{key:"closeHandler",value:function(t){var e=t&&t.type,n=!1;if(t)if(e===wT||e===ST){var o=(this.__containedEvent||0)+100;t.timeStamp>o&&(n=!0)}else MT(t),n=!0;else n=!0;n&&this.hide()&&(this.settings.parent.style.pointerEvents="",e!==wT&&this.settings.parent.focus(),this.onClose&&this.onClose(this.colour))}},{key:"movePopup",value:function(t,e){this.closeHandler(),this.setOptions(t),e&&this.openHandler()}},{key:"setColor",value:function(t,e){this._setColor(t,{silent:e})}},{key:"_setColor",value:function(t,e){if("string"==typeof t&&(t=t.trim()),t){e=e||{};var n=void 0;try{n=new bT(t)}catch(t){if(e.failSilently)return;throw t}if(!this.settings.alpha){var o=n.hsla;o[3]=1,n.hsla=o}this.colour=this.color=n,this._setHSLA(null,null,null,null,e)}}},{key:"setColour",value:function(t,e){this.setColor(t,e)}},{key:"show",value:function(){if(!this.settings.parent)return!1;if(this.domElement){var t=this._toggleDOM(!0);return this._setPosition(),t}var e,n,o=this.settings.template||'<div class="picker_wrapper" tabindex="-1"><div class="picker_arrow"></div><div class="picker_hue picker_slider"><div class="picker_selector"></div></div><div class="picker_sl"><div class="picker_selector"></div></div><div class="picker_alpha picker_slider"><div class="picker_selector"></div></div><div class="picker_editor"><input aria-label="Type a color name or hex value"/></div><div class="picker_sample"></div><div class="picker_done"><button>Ok</button></div><div class="picker_cancel"><button>Cancel</button></div></div>',r=(e=o,(n=document.createElement("div")).innerHTML=e,n.firstElementChild);return this.domElement=r,this._domH=CT(".picker_hue",r),this._domSL=CT(".picker_sl",r),this._domA=CT(".picker_alpha",r),this._domEdit=CT(".picker_editor input",r),this._domSample=CT(".picker_sample",r),this._domOkay=CT(".picker_done button",r),this._domCancel=CT(".picker_cancel button",r),r.classList.add("layout_"+this.settings.layout),this.settings.alpha||r.classList.add("no_alpha"),this.settings.editor||r.classList.add("no_editor"),this.settings.cancelButton||r.classList.add("no_cancel"),this._ifPopup((function(){return r.classList.add("popup")})),this._setPosition(),this.colour?this._updateUI():this._setColor(this.settings.defaultColor),this._bindEvents(),!0}},{key:"hide",value:function(){return this._toggleDOM(!1)}},{key:"destroy",value:function(){this._events.destroy(),this.domElement&&this.settings.parent.removeChild(this.domElement)}},{key:"_bindEvents",value:function(){var t=this,e=this,n=this.domElement,o=this._events;function r(t,e,n){o.add(t,e,n)}r(n,"click",(function(t){return t.preventDefault()})),xT(o,this._domH,(function(t,n){return e._setHSLA(t)})),xT(o,this._domSL,(function(t,n){return e._setHSLA(null,t,1-n)})),this.settings.alpha&&xT(o,this._domA,(function(t,n){return e._setHSLA(null,null,null,1-n)}));var i=this._domEdit;r(i,"input",(function(t){e._setColor(this.value,{fromEditor:!0,failSilently:!0})})),r(i,"focus",(function(t){var e=this;e.selectionStart===e.selectionEnd&&e.select()})),this._ifPopup((function(){var e=function(e){return t.closeHandler(e)};r(window,wT,e),r(window,ST,e),OT(o,n,["Esc","Escape"],e);var i=function(e){t.__containedEvent=e.timeStamp};r(n,wT,i),r(n,ST,i),r(t._domCancel,"click",e)}));var a=function(e){t._ifPopup((function(){return t.closeHandler(e)})),t.onDone&&t.onDone(t.colour)};r(this._domOkay,"click",a),OT(o,n,["Enter"],a)}},{key:"_setPosition",value:function(){var t=this.settings.parent,e=this.domElement;t!==e.parentNode&&t.appendChild(e),this._ifPopup((function(n){"static"===getComputedStyle(t).position&&(t.style.position="relative");var o=!0===n?"popup_right":"popup_"+n;["popup_top","popup_bottom","popup_left","popup_right"].forEach((function(t){t===o?e.classList.add(t):e.classList.remove(t)})),e.classList.add(o)}))}},{key:"_setHSLA",value:function(t,e,n,o,r){r=r||{};var i=this.colour,a=i.hsla;[t,e,n,o].forEach((function(t,e){(t||0===t)&&(a[e]=t)})),i.hsla=a,this._updateUI(r),this.onChange&&!r.silent&&this.onChange(i)}},{key:"_updateUI",value:function(t){if(this.domElement){t=t||{};var e=this.colour,n=e.hsla,o="hsl("+360*n[0]+", 100%, 50%)",r=e.hslString,i=e.hslaString,a=this._domH,s=this._domSL,l=this._domA,u=CT(".picker_selector",a),c=CT(".picker_selector",s),d=CT(".picker_selector",l);m(0,u,n[0]),this._domSL.style.backgroundColor=this._domH.style.color=o,m(0,c,n[1]),b(0,c,1-n[2]),s.style.color=r,b(0,d,1-n[3]);var p=r,h=p.replace("hsl","hsla").replace(")",", 0)"),f="linear-gradient("+[p,h]+")";if(this._domA.style.background=f+", linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0 / 2em 2em,\n linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em / 2em 2em",!t.fromEditor){var g=this.settings.editorFormat,v=this.settings.alpha,y=void 0;switch(g){case"rgb":y=e.printRGB(v);break;case"hsl":y=e.printHSL(v);break;default:y=e.printHex(v)}this._domEdit.value=y}this._domSample.style.color=i}function m(t,e,n){e.style.left=100*n+"%"}function b(t,e,n){e.style.top=100*n+"%"}}},{key:"_ifPopup",value:function(t,e){this.settings.parent&&this.settings.popup?t&&t(this.settings.popup):e&&e()}},{key:"_toggleDOM",value:function(t){var e=this.domElement;if(!e)return!1;var n=t?"":"none",o=e.style.display!==n;return o&&(e.style.display=n),o}}]),t}(),NT=document.createElement("style");NT.textContent='.picker_wrapper.no_alpha .picker_alpha{display:none}.picker_wrapper.no_editor .picker_editor{position:absolute;z-index:-1;opacity:0}.picker_wrapper.no_cancel .picker_cancel{display:none}.layout_default.picker_wrapper{display:flex;flex-flow:row wrap;justify-content:space-between;align-items:stretch;font-size:10px;width:25em;padding:.5em}.layout_default.picker_wrapper input,.layout_default.picker_wrapper button{font-size:1rem}.layout_default.picker_wrapper>*{margin:.5em}.layout_default.picker_wrapper::before{content:"";display:block;width:100%;height:0;order:1}.layout_default .picker_slider,.layout_default .picker_selector{padding:1em}.layout_default .picker_hue{width:100%}.layout_default .picker_sl{flex:1 1 auto}.layout_default .picker_sl::before{content:"";display:block;padding-bottom:100%}.layout_default .picker_editor{order:1;width:6.5rem}.layout_default .picker_editor input{width:100%;height:100%}.layout_default .picker_sample{order:1;flex:1 1 auto}.layout_default .picker_done,.layout_default .picker_cancel{order:1}.picker_wrapper{box-sizing:border-box;background:#f2f2f2;box-shadow:0 0 0 1px silver;cursor:default;font-family:sans-serif;color:#444;pointer-events:auto}.picker_wrapper:focus{outline:none}.picker_wrapper button,.picker_wrapper input{box-sizing:border-box;border:none;box-shadow:0 0 0 1px silver;outline:none}.picker_wrapper button:focus,.picker_wrapper button:active,.picker_wrapper input:focus,.picker_wrapper input:active{box-shadow:0 0 2px 1px #1e90ff}.picker_wrapper button{padding:.4em .6em;cursor:pointer;background-color:#f5f5f5;background-image:linear-gradient(0deg, gainsboro, transparent)}.picker_wrapper button:active{background-image:linear-gradient(0deg, transparent, gainsboro)}.picker_wrapper button:hover{background-color:#fff}.picker_selector{position:absolute;z-index:1;display:block;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%);border:2px solid #fff;border-radius:100%;box-shadow:0 0 3px 1px #67b9ff;background:currentColor;cursor:pointer}.picker_slider .picker_selector{border-radius:2px}.picker_hue{position:relative;background-image:linear-gradient(90deg, red, yellow, lime, cyan, blue, magenta, red);box-shadow:0 0 0 1px silver}.picker_sl{position:relative;box-shadow:0 0 0 1px silver;background-image:linear-gradient(180deg, white, rgba(255, 255, 255, 0) 50%),linear-gradient(0deg, black, rgba(0, 0, 0, 0) 50%),linear-gradient(90deg, #808080, rgba(128, 128, 128, 0))}.picker_alpha,.picker_sample{position:relative;background:linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0/2em 2em,linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em/2em 2em;box-shadow:0 0 0 1px silver}.picker_alpha .picker_selector,.picker_sample .picker_selector{background:none}.picker_editor input{font-family:monospace;padding:.2em .4em}.picker_sample::before{content:"";position:absolute;display:block;width:100%;height:100%;background:currentColor}.picker_arrow{position:absolute;z-index:-1}.picker_wrapper.popup{position:absolute;z-index:2;margin:1.5em}.picker_wrapper.popup,.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{background:#f2f2f2;box-shadow:0 0 10px 1px rgba(0,0,0,.4)}.picker_wrapper.popup .picker_arrow{width:3em;height:3em;margin:0}.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{content:"";display:block;position:absolute;top:0;left:0;z-index:-99}.picker_wrapper.popup .picker_arrow::before{width:100%;height:100%;-webkit-transform:skew(45deg);transform:skew(45deg);-webkit-transform-origin:0 100%;transform-origin:0 100%}.picker_wrapper.popup .picker_arrow::after{width:150%;height:150%;box-shadow:none}.popup.popup_top{bottom:100%;left:0}.popup.popup_top .picker_arrow{bottom:0;left:0;-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.popup.popup_bottom{top:100%;left:0}.popup.popup_bottom .picker_arrow{top:0;left:0;-webkit-transform:rotate(90deg) scale(1, -1);transform:rotate(90deg) scale(1, -1)}.popup.popup_left{top:0;right:100%}.popup.popup_left .picker_arrow{top:0;right:0;-webkit-transform:scale(-1, 1);transform:scale(-1, 1)}.popup.popup_right{top:0;left:100%}.popup.popup_right .picker_arrow{top:0;left:0}',document.documentElement.firstElementChild.appendChild(NT),TT.StyleElement=NT;var AT={},PT={get exports(){return AT},set exports(t){AT=t}};!function(t){t.exports=function(){var t="object",e="function",n="undefined",o=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],r=["setStart","setStartBefore","setStartAfter","setEnd","setEndBefore","setEndAfter","collapse","selectNode","selectNodeContents","compareBoundaryPoints","deleteContents","extractContents","cloneContents","insertNode","surroundContents","cloneRange","toString","detach"],i=["boundingHeight","boundingLeft","boundingTop","boundingWidth","htmlText","text"],a=["collapse","compareEndPoints","duplicate","moveToElementText","parentElement","select","setEndPoint","getBoundingClientRect"];function s(n,o){var r=typeof n[o];return r==e||!(r!=t||!n[o])||"unknown"==r}function l(e,n){return!(typeof e[n]!=t||!e[n])}function u(t,e){return typeof t[e]!=n}function c(t){return function(e,n){for(var o=n.length;o--;)if(!t(e,n[o]))return!1;return!0}}var d=c(s),p=c(l),h=c(u);function f(t){return t&&d(t,a)&&h(t,i)}function g(t){return l(t,"body")?t.body:t.getElementsByTagName("body")[0]}var v,y,m=[].forEach?function(t,e){t.forEach(e)}:function(t,e){for(var n=0,o=t.length;n<o;++n)e(t[n],n)},b={},_=typeof window!=n&&typeof document!=n,x={isHostMethod:s,isHostObject:l,isHostProperty:u,areHostMethods:d,areHostObjects:p,areHostProperties:h,isTextRange:f,getBody:g,forEach:m},E={version:"1.3.1",initialized:!1,isBrowser:_,supported:!0,util:x,features:{},modules:b,config:{alertOnFail:!1,alertOnWarn:!1,preferTextRange:!1,autoInitialize:typeof rangyAutoInitialize==n||rangyAutoInitialize}};function w(t){typeof console!=n&&s(console,"log")&&console.log(t)}function S(t,e){_&&e?alert(t):w(t)}function C(t){E.initialized=!0,E.supported=!1,S("Rangy is not supported in this environment. Reason: "+t,E.config.alertOnFail)}function M(t){S("Rangy warning: "+t,E.config.alertOnWarn)}E.fail=C,E.warn=M,{}.hasOwnProperty?(x.extend=v=function(t,e,n){var o,r;for(var i in e)e.hasOwnProperty(i)&&(o=t[i],r=e[i],n&&null!==o&&"object"==typeof o&&null!==r&&"object"==typeof r&&v(o,r,!0),t[i]=r);return e.hasOwnProperty("toString")&&(t.toString=e.toString),t},x.createOptions=function(t,e){var n={};return v(n,e),t&&v(n,t),n}):C("hasOwnProperty not supported"),_||C("Rangy can only run in a browser"),function(){var t;if(_){var e=document.createElement("div");e.appendChild(document.createElement("span"));var n=[].slice;try{1==n.call(e.childNodes,0)[0].nodeType&&(t=function(t){return n.call(t,0)})}catch(t){}}t||(t=function(t){for(var e=[],n=0,o=t.length;n<o;++n)e[n]=t[n];return e}),x.toArray=t}(),_&&(s(document,"addEventListener")?y=function(t,e,n){t.addEventListener(e,n,!1)}:s(document,"attachEvent")?y=function(t,e,n){t.attachEvent("on"+e,n)}:C("Document does not have required addEventListener or attachEvent method"),x.addListener=y);var O=[];function T(t){return t.message||t.description||String(t)}function N(){if(_&&!E.initialized){var t,e=!1,n=!1;s(document,"createRange")&&(t=document.createRange(),d(t,r)&&h(t,o)&&(e=!0));var i=g(document);if(i&&"body"==i.nodeName.toLowerCase())if(i&&s(i,"createTextRange")&&f(t=i.createTextRange())&&(n=!0),e||n){var a;for(var l in E.initialized=!0,E.features={implementsDomRange:e,implementsTextRange:n},b)(a=b[l])instanceof R&&a.init(a,E);for(var u=0,c=O.length;u<c;++u)try{O[u](E)}catch(t){w("Rangy init listener threw an exception. Continuing. Detail: "+T(t))}}else C("Neither Range nor TextRange are available");else C("No body element found")}}function A(t,e,n){n&&(t+=" in module "+n.name),E.warn("DEPRECATED: "+t+" is deprecated. Please use "+e+" instead.")}function P(t,e,n,o){t[e]=function(){return A(e,n,o),t[n].apply(t,x.toArray(arguments))}}x.deprecationNotice=A,x.createAliasForDeprecatedMethod=P,E.init=N,E.addInitListener=function(t){E.initialized?t(E):O.push(t)};var D=[];function k(t){t=t||window,N();for(var e=0,n=D.length;e<n;++e)D[e](t)}function R(t,e,n){this.name=t,this.dependencies=e,this.initialized=!1,this.supported=!1,this.initializer=n}function I(t,e,n){var o=new R(t,e,(function(e){if(!e.initialized){e.initialized=!0;try{n(E,e),e.supported=!0}catch(e){w("Module '"+t+"' failed to load: "+T(e)),e.stack&&w(e.stack)}}}));return b[t]=o,o}function L(){}function j(){}E.addShimListener=function(t){D.push(t)},_&&(E.shim=E.createMissingNativeApi=k,P(E,"createMissingNativeApi","shim")),R.prototype={init:function(){for(var t,e,n=this.dependencies||[],o=0,r=n.length;o<r;++o){if(e=n[o],!((t=b[e])&&t instanceof R))throw new Error("required module '"+e+"' not found");if(t.init(),!t.supported)throw new Error("required module '"+e+"' not supported")}this.initializer(this)},fail:function(t){throw this.initialized=!0,this.supported=!1,new Error(t)},warn:function(t){E.warn("Module "+this.name+": "+t)},deprecationNotice:function(t,e){E.warn("DEPRECATED: "+t+" in module "+this.name+" is deprecated. Please use "+e+" instead")},createError:function(t){return new Error("Error in Rangy "+this.name+" module: "+t)}},E.createModule=function(t){var e,n;2==arguments.length?(e=arguments[1],n=[]):(e=arguments[2],n=arguments[1]);var o=I(t,n,e);E.initialized&&E.supported&&o.init()},E.createCoreModule=function(t,e,n){I(t,e,n)},E.RangePrototype=L,E.rangePrototype=new L,E.selectionPrototype=new j,E.createCoreModule("DomUtil",[],(function(t,e){var n="undefined",o=t.util,r=o.getBody;o.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||e.fail("document missing a Node creation method"),o.isHostMethod(document,"getElementsByTagName")||e.fail("document missing getElementsByTagName method");var i=document.createElement("div");o.areHostMethods(i,["insertBefore","appendChild","cloneNode"]||!o.areHostObjects(i,["previousSibling","nextSibling","childNodes","parentNode"]))||e.fail("Incomplete Element implementation"),o.isHostProperty(i,"innerHTML")||e.fail("Element is missing innerHTML property");var a=document.createTextNode("test");o.areHostMethods(a,["splitText","deleteData","insertData","appendData","cloneNode"]||!o.areHostObjects(i,["previousSibling","nextSibling","childNodes","parentNode"])||!o.areHostProperties(a,["data"]))||e.fail("Incomplete Text Node implementation");var s=function(t,e){for(var n=t.length;n--;)if(t[n]===e)return!0;return!1};function l(t){var e;return typeof t.namespaceURI==n||null===(e=t.namespaceURI)||"http://www.w3.org/1999/xhtml"==e}function u(t){var e=t.parentNode;return 1==e.nodeType?e:null}function c(t){for(var e=0;t=t.previousSibling;)++e;return e}function d(t){switch(t.nodeType){case 7:case 10:return 0;case 3:case 8:return t.length;default:return t.childNodes.length}}function p(t,e){var n,o=[];for(n=t;n;n=n.parentNode)o.push(n);for(n=e;n;n=n.parentNode)if(s(o,n))return n;return null}function h(t,e,n){for(var o=n?e:e.parentNode;o;){if(o===t)return!0;o=o.parentNode}return!1}function f(t,e){return h(t,e,!0)}function g(t,e,n){for(var o,r=n?t:t.parentNode;r;){if((o=r.parentNode)===e)return r;r=o}return null}function v(t){var e=t.nodeType;return 3==e||4==e||8==e}function y(t){if(!t)return!1;var e=t.nodeType;return 3==e||8==e}function m(t,e){var n=e.nextSibling,o=e.parentNode;return n?o.insertBefore(t,n):o.appendChild(t),t}function b(t,e,n){var o=t.cloneNode(!1);if(o.deleteData(0,e),t.deleteData(e,t.length-e),m(o,t),n)for(var r,i=0;r=n[i++];)r.node==t&&r.offset>e?(r.node=o,r.offset-=e):r.node==t.parentNode&&r.offset>c(t)&&++r.offset;return o}function _(t){if(9==t.nodeType)return t;if(typeof t.ownerDocument!=n)return t.ownerDocument;if(typeof t.document!=n)return t.document;if(t.parentNode)return _(t.parentNode);throw e.createError("getDocument: no document found for node")}function x(t){var o=_(t);if(typeof o.defaultView!=n)return o.defaultView;if(typeof o.parentWindow!=n)return o.parentWindow;throw e.createError("Cannot get a window object for node")}function E(t){if(typeof t.contentDocument!=n)return t.contentDocument;if(typeof t.contentWindow!=n)return t.contentWindow.document;throw e.createError("getIframeDocument: No Document object found for iframe element")}function w(t){if(typeof t.contentWindow!=n)return t.contentWindow;if(typeof t.contentDocument!=n)return t.contentDocument.defaultView;throw e.createError("getIframeWindow: No Window object found for iframe element")}function S(t){return t&&o.isHostMethod(t,"setTimeout")&&o.isHostObject(t,"document")}function C(t,e,n){var r;if(t?o.isHostProperty(t,"nodeType")?r=1==t.nodeType&&"iframe"==t.tagName.toLowerCase()?E(t):_(t):S(t)&&(r=t.document):r=document,!r)throw e.createError(n+"(): Parameter must be a Window object or DOM node");return r}function M(t){for(var e;e=t.parentNode;)t=e;return t}function O(t,n,o,r){var i,a,s,l,u;if(t==o)return n===r?0:n<r?-1:1;if(i=g(o,t,!0))return n<=c(i)?-1:1;if(i=g(t,o,!0))return c(i)<r?-1:1;if(!(a=p(t,o)))throw new Error("comparePoints error: nodes have no common ancestor");if((s=t===a?a:g(t,a,!0))===(l=o===a?a:g(o,a,!0)))throw e.createError("comparePoints got to case 4 and childA and childB are the same!");for(u=a.firstChild;u;){if(u===s)return-1;if(u===l)return 1;u=u.nextSibling}}var T,N=!1;function A(t){try{return t.parentNode,!1}catch(t){return!0}}function P(t){if(!t)return"[No node]";if(N&&A(t))return"[Broken node]";if(v(t))return'"'+t.data+'"';if(1==t.nodeType){var e=t.id?' id="'+t.id+'"':"";return"<"+t.nodeName+e+">[index:"+c(t)+",length:"+t.childNodes.length+"]["+(t.innerHTML||"[innerHTML not supported]").slice(0,25)+"]"}return t.nodeName}function D(t){for(var e,n=_(t).createDocumentFragment();e=t.firstChild;)n.appendChild(e);return n}function k(t,e,n){var o=r(t),i=t.createElement("div");i.contentEditable=""+!!n,e&&(i.innerHTML=e);var a=o.firstChild;return a?o.insertBefore(i,a):o.appendChild(i),i}function R(t){return t.parentNode.removeChild(t)}function I(t){this.root=t,this._next=t}function L(t){return new I(t)}function j(t,e){this.node=t,this.offset=e}function B(t){this.code=this[t],this.codeName=t,this.message="DOMException: "+this.codeName}!function(){var e=document.createElement("b");e.innerHTML="1";var n=e.firstChild;e.innerHTML="<br />",N=A(n),t.features.crashyTextNodes=N}(),typeof window.getComputedStyle!=n?T=function(t,e){return x(t).getComputedStyle(t,null)[e]}:typeof document.documentElement.currentStyle!=n?T=function(t,e){return t.currentStyle?t.currentStyle[e]:""}:e.fail("No means of obtaining computed style properties found"),I.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var t,e,n=this._current=this._next;if(this._current)if(t=n.firstChild)this._next=t;else{for(e=null;n!==this.root&&!(e=n.nextSibling);)n=n.parentNode;this._next=e}return this._current},detach:function(){this._current=this._next=this.root=null}},j.prototype={equals:function(t){return!!t&&this.node===t.node&&this.offset==t.offset},inspect:function(){return"[DomPosition("+P(this.node)+":"+this.offset+")]"},toString:function(){return this.inspect()}},B.prototype={INDEX_SIZE_ERR:1,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INVALID_STATE_ERR:11,INVALID_NODE_TYPE_ERR:24},B.prototype.toString=function(){return this.message},t.dom={arrayContains:s,isHtmlNamespace:l,parentElement:u,getNodeIndex:c,getNodeLength:d,getCommonAncestor:p,isAncestorOf:h,isOrIsAncestorOf:f,getClosestAncestorIn:g,isCharacterDataNode:v,isTextOrCommentNode:y,insertAfter:m,splitDataNode:b,getDocument:_,getWindow:x,getIframeWindow:w,getIframeDocument:E,getBody:r,isWindow:S,getContentDocument:C,getRootContainer:M,comparePoints:O,isBrokenNode:A,inspectNode:P,getComputedStyleProperty:T,createTestElement:k,removeNode:R,fragmentFromNodeChildren:D,createIterator:L,DomPosition:j},t.DOMException=B})),E.createCoreModule("DomRange",["DomUtil"],(function(t,e){var n=t.dom,o=t.util,r=n.DomPosition,i=t.DOMException,a=n.isCharacterDataNode,s=n.getNodeIndex,l=n.isOrIsAncestorOf,u=n.getDocument,c=n.comparePoints,d=n.splitDataNode,p=n.getClosestAncestorIn,h=n.getNodeLength,f=n.arrayContains,g=n.getRootContainer,v=t.features.crashyTextNodes,y=n.removeNode;function m(t,e){return 3!=t.nodeType&&(l(t,e.startContainer)||l(t,e.endContainer))}function b(t){return t.document||u(t.startContainer)}function _(t){return g(t.startContainer)}function x(t){return new r(t.parentNode,s(t))}function E(t){return new r(t.parentNode,s(t)+1)}function w(t,e,o){var r=11==t.nodeType?t.firstChild:t;return a(e)?o==e.length?n.insertAfter(t,e):e.parentNode.insertBefore(t,0==o?e:d(e,o)):o>=e.childNodes.length?e.appendChild(t):e.insertBefore(t,e.childNodes[o]),r}function S(t,e,n){if(Z(t),Z(e),b(e)!=b(t))throw new i("WRONG_DOCUMENT_ERR");var o=c(t.startContainer,t.startOffset,e.endContainer,e.endOffset),r=c(t.endContainer,t.endOffset,e.startContainer,e.startOffset);return n?o<=0&&r>=0:o<0&&r>0}function C(t){for(var e,n,o,r=b(t.range).createDocumentFragment();n=t.next();){if(e=t.isPartiallySelectedSubtree(),n=n.cloneNode(!e),e&&(o=t.getSubtreeIterator(),n.appendChild(C(o)),o.detach()),10==n.nodeType)throw new i("HIERARCHY_REQUEST_ERR");r.appendChild(n)}return r}function M(t,e,o){var r,i,a,s;for(o=o||{stop:!1};a=t.next();)if(t.isPartiallySelectedSubtree()){if(!1===e(a))return void(o.stop=!0);if(M(s=t.getSubtreeIterator(),e,o),s.detach(),o.stop)return}else for(r=n.createIterator(a);i=r.next();)if(!1===e(i))return void(o.stop=!0)}function O(t){for(var e;t.next();)t.isPartiallySelectedSubtree()?(O(e=t.getSubtreeIterator()),e.detach()):t.remove()}function T(t){for(var e,n,o=b(t.range).createDocumentFragment();e=t.next();){if(t.isPartiallySelectedSubtree()?(e=e.cloneNode(!1),n=t.getSubtreeIterator(),e.appendChild(T(n)),n.detach()):t.remove(),10==e.nodeType)throw new i("HIERARCHY_REQUEST_ERR");o.appendChild(e)}return o}function N(t,e,n){var o,r=!(!e||!e.length),i=!!n;r&&(o=new RegExp("^("+e.join("|")+")$"));var s=[];return M(new P(t,!1),(function(e){if((!r||o.test(e.nodeType))&&(!i||n(e))){var l=t.startContainer;if(e!=l||!a(l)||t.startOffset!=l.length){var u=t.endContainer;e==u&&a(u)&&0==t.endOffset||s.push(e)}}})),s}function A(t){return"["+(void 0===t.getName?"Range":t.getName())+"("+n.inspectNode(t.startContainer)+":"+t.startOffset+", "+n.inspectNode(t.endContainer)+":"+t.endOffset+")]"}function P(t,e){if(this.range=t,this.clonePartiallySelectedTextNodes=e,!t.collapsed){this.sc=t.startContainer,this.so=t.startOffset,this.ec=t.endContainer,this.eo=t.endOffset;var n=t.commonAncestorContainer;this.sc===this.ec&&a(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc!==n||a(this.sc)?p(this.sc,n,!0):this.sc.childNodes[this.so],this._last=this.ec!==n||a(this.ec)?p(this.ec,n,!0):this.ec.childNodes[this.eo-1])}}P.prototype={_current:null,_next:null,_first:null,_last:null,isSingleCharacterDataNode:!1,reset:function(){this._current=null,this._next=this._first},hasNext:function(){return!!this._next},next:function(){var t=this._current=this._next;return t&&(this._next=t!==this._last?t.nextSibling:null,a(t)&&this.clonePartiallySelectedTextNodes&&(t===this.ec&&(t=t.cloneNode(!0)).deleteData(this.eo,t.length-this.eo),this._current===this.sc&&(t=t.cloneNode(!0)).deleteData(0,this.so))),t},remove:function(){var t,e,n=this._current;!a(n)||n!==this.sc&&n!==this.ec?n.parentNode&&y(n):(t=n===this.sc?this.so:0)!=(e=n===this.ec?this.eo:n.length)&&n.deleteData(t,e-t)},isPartiallySelectedSubtree:function(){return m(this._current,this.range)},getSubtreeIterator:function(){var t;if(this.isSingleCharacterDataNode)(t=this.range.cloneRange()).collapse(!1);else{t=new yt(b(this.range));var e=this._current,n=e,o=0,r=e,i=h(e);l(e,this.sc)&&(n=this.sc,o=this.so),l(e,this.ec)&&(r=this.ec,i=this.eo),vt(t,n,o,r,i)}return new P(t,this.clonePartiallySelectedTextNodes)},detach:function(){this.range=this._current=this._next=this._first=this._last=this.sc=this.so=this.ec=this.eo=null}};var D=[1,3,4,5,7,8,10],k=[2,9,11],R=[5,6,10,12],I=[1,3,4,5,7,8,10,11],L=[1,3,4,5,7,8];function j(t){return function(e,n){for(var o,r=n?e:e.parentNode;r;){if(o=r.nodeType,f(t,o))return r;r=r.parentNode}return null}}var B=j([9,11]),H=j(R),z=j([6,10,12]),F=j([1]);function W(t,e){if(z(t,e))throw new i("INVALID_NODE_TYPE_ERR")}function G(t,e){if(!f(e,t.nodeType))throw new i("INVALID_NODE_TYPE_ERR")}function X(t,e){if(e<0||e>(a(t)?t.length:t.childNodes.length))throw new i("INDEX_SIZE_ERR")}function U(t,e){if(B(t,!0)!==B(e,!0))throw new i("WRONG_DOCUMENT_ERR")}function Y(t){if(H(t,!0))throw new i("NO_MODIFICATION_ALLOWED_ERR")}function V(t,e){if(!t)throw new i(e)}function K(t,e){return e<=(a(t)?t.length:t.childNodes.length)}function q(t){return!!t.startContainer&&!!t.endContainer&&!(v&&(n.isBrokenNode(t.startContainer)||n.isBrokenNode(t.endContainer)))&&g(t.startContainer)==g(t.endContainer)&&K(t.startContainer,t.startOffset)&&K(t.endContainer,t.endOffset)}function Z(t){if(!q(t))throw new Error("Range error: Range is not valid. This usually happens after DOM mutation. Range: ("+t.inspect()+")")}var $=document.createElement("style"),J=!1;try{$.innerHTML="<b>x</b>",J=3==$.firstChild.nodeType}catch(t){}t.features.htmlParsingConforms=J;var Q=J?function(t){var e=this.startContainer,o=u(e);if(!e)throw new i("INVALID_STATE_ERR");var r=null;return 1==e.nodeType?r=e:a(e)&&(r=n.parentElement(e)),(r=null===r||"HTML"==r.nodeName&&n.isHtmlNamespace(u(r).documentElement)&&n.isHtmlNamespace(r)?o.createElement("body"):r.cloneNode(!1)).innerHTML=t,n.fragmentFromNodeChildren(r)}:function(t){var e=b(this).createElement("body");return e.innerHTML=t,n.fragmentFromNodeChildren(e)};function tt(t,e){Z(t);var n=t.startContainer,o=t.startOffset,r=t.endContainer,i=t.endOffset,l=n===r;a(r)&&i>0&&i<r.length&&d(r,i,e),a(n)&&o>0&&o<n.length&&(n=d(n,o,e),l?(i-=o,r=n):r==n.parentNode&&i>=s(n)&&i++,o=0),t.setStartAndEnd(n,o,r,i)}function et(t){Z(t);var e=t.commonAncestorContainer.parentNode.cloneNode(!1);return e.appendChild(t.cloneContents()),e.innerHTML}var nt=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],ot=0,rt=1,it=2,at=3,st=0,lt=1,ut=2,ct=3;function dt(t){t.START_TO_START=ot,t.START_TO_END=rt,t.END_TO_END=it,t.END_TO_START=at,t.NODE_BEFORE=st,t.NODE_AFTER=lt,t.NODE_BEFORE_AND_AFTER=ut,t.NODE_INSIDE=ct}function pt(t){dt(t),dt(t.prototype)}function ht(t,e){return function(){Z(this);var n,o=this.startContainer,r=this.startOffset,i=this.commonAncestorContainer,a=new P(this,!0);o!==i&&(o=(n=E(p(o,i,!0))).node,r=n.offset),M(a,Y),a.reset();var s=t(a);return a.detach(),e(this,o,r,o,r),s}}function ft(e,n){function r(t,e){return function(n){G(n,D),G(g(n),k);var o=(t?x:E)(n);(e?i:l)(this,o.node,o.offset)}}function i(t,e,o){var r=t.endContainer,i=t.endOffset;e===t.startContainer&&o===t.startOffset||(g(e)==g(r)&&1!=c(e,o,r,i)||(r=e,i=o),n(t,e,o,r,i))}function l(t,e,o){var r=t.startContainer,i=t.startOffset;e===t.endContainer&&o===t.endOffset||(g(e)==g(r)&&-1!=c(e,o,r,i)||(r=e,i=o),n(t,r,i,e,o))}var u=function(){};u.prototype=t.rangePrototype,e.prototype=new u,o.extend(e.prototype,{setStart:function(t,e){W(t,!0),X(t,e),i(this,t,e)},setEnd:function(t,e){W(t,!0),X(t,e),l(this,t,e)},setStartAndEnd:function(){var t=arguments,e=t[0],o=t[1],r=e,i=o;switch(t.length){case 3:i=t[2];break;case 4:r=t[2],i=t[3]}W(e,!0),X(e,o),W(r,!0),X(r,i),n(this,e,o,r,i)},setBoundary:function(t,e,n){this["set"+(n?"Start":"End")](t,e)},setStartBefore:r(!0,!0),setStartAfter:r(!1,!0),setEndBefore:r(!0,!1),setEndAfter:r(!1,!1),collapse:function(t){Z(this),t?n(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset):n(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(t){W(t,!0),n(this,t,0,t,h(t))},selectNode:function(t){W(t,!1),G(t,D);var e=x(t),o=E(t);n(this,e.node,e.offset,o.node,o.offset)},extractContents:ht(T,n),deleteContents:ht(O,n),canSurroundContents:function(){Z(this),Y(this.startContainer),Y(this.endContainer);var t=new P(this,!0),e=t._first&&m(t._first,this)||t._last&&m(t._last,this);return t.detach(),!e},splitBoundaries:function(){tt(this)},splitBoundariesPreservingPositions:function(t){tt(this,t)},normalizeBoundaries:function(){Z(this);var t,e=this.startContainer,o=this.startOffset,r=this.endContainer,i=this.endOffset,l=function(t){var e=t.nextSibling;e&&e.nodeType==t.nodeType&&(r=t,i=t.length,t.appendData(e.data),y(e))},u=function(t){var n=t.previousSibling;if(n&&n.nodeType==t.nodeType){e=t;var a=t.length;if(o=n.length,t.insertData(0,n.data),y(n),e==r)i+=o,r=e;else if(r==t.parentNode){var l=s(t);i==l?(r=t,i=a):i>l&&i--}}},c=!0;if(a(r))i==r.length?l(r):0==i&&(t=r.previousSibling)&&t.nodeType==r.nodeType&&(i=t.length,e==r&&(c=!1),t.appendData(r.data),y(r),r=t);else{if(i>0){var d=r.childNodes[i-1];d&&a(d)&&l(d)}c=!this.collapsed}if(c){if(a(e))0==o?u(e):o==e.length&&(t=e.nextSibling)&&t.nodeType==e.nodeType&&(r==t&&(r=e,i+=e.length),e.appendData(t.data),y(t));else if(o<e.childNodes.length){var p=e.childNodes[o];p&&a(p)&&u(p)}}else e=r,o=i;n(this,e,o,r,i)},collapseToPoint:function(t,e){W(t,!0),X(t,e),this.setStartAndEnd(t,e)},parentElement:function(){return Z(this),this.commonAncestorContainer?F(this.commonAncestorContainer,!0):null}}),pt(e)}function gt(t){t.collapsed=t.startContainer===t.endContainer&&t.startOffset===t.endOffset,t.commonAncestorContainer=t.collapsed?t.startContainer:n.getCommonAncestor(t.startContainer,t.endContainer)}function vt(t,e,o,r,i){t.startContainer=e,t.startOffset=o,t.endContainer=r,t.endOffset=i,t.document=n.getDocument(e),gt(t)}function yt(t){vt(this,t,0,t,0)}o.extend(t.rangePrototype,{compareBoundaryPoints:function(t,e){var n,o,r,i;Z(this),U(this.startContainer,e.startContainer);var a=t==at||t==ot?"start":"end",s=t==rt||t==ot?"start":"end";return n=this[a+"Container"],o=this[a+"Offset"],r=e[s+"Container"],i=e[s+"Offset"],c(n,o,r,i)},insertNode:function(t){if(Z(this),G(t,I),Y(this.startContainer),l(t,this.startContainer))throw new i("HIERARCHY_REQUEST_ERR");var e=w(t,this.startContainer,this.startOffset);this.setStartBefore(e)},cloneContents:function(){var t,e;if(Z(this),this.collapsed)return b(this).createDocumentFragment();if(this.startContainer===this.endContainer&&a(this.startContainer))return(t=this.startContainer.cloneNode(!0)).data=t.data.slice(this.startOffset,this.endOffset),(e=b(this).createDocumentFragment()).appendChild(t),e;var n=new P(this,!0);return t=C(n),n.detach(),t},canSurroundContents:function(){Z(this),Y(this.startContainer),Y(this.endContainer);var t=new P(this,!0),e=t._first&&m(t._first,this)||t._last&&m(t._last,this);return t.detach(),!e},surroundContents:function(t){if(G(t,L),!this.canSurroundContents())throw new i("INVALID_STATE_ERR");var e=this.extractContents();if(t.hasChildNodes())for(;t.lastChild;)t.removeChild(t.lastChild);w(t,this.startContainer,this.startOffset),t.appendChild(e),this.selectNode(t)},cloneRange:function(){Z(this);for(var t,e=new yt(b(this)),n=nt.length;n--;)e[t=nt[n]]=this[t];return e},toString:function(){Z(this);var t=this.startContainer;if(t===this.endContainer&&a(t))return 3==t.nodeType||4==t.nodeType?t.data.slice(this.startOffset,this.endOffset):"";var e=[],n=new P(this,!0);return M(n,(function(t){3!=t.nodeType&&4!=t.nodeType||e.push(t.data)})),n.detach(),e.join("")},compareNode:function(t){Z(this);var e=t.parentNode,n=s(t);if(!e)throw new i("NOT_FOUND_ERR");var o=this.comparePoint(e,n),r=this.comparePoint(e,n+1);return o<0?r>0?ut:st:r>0?lt:ct},comparePoint:function(t,e){return Z(this),V(t,"HIERARCHY_REQUEST_ERR"),U(t,this.startContainer),c(t,e,this.startContainer,this.startOffset)<0?-1:c(t,e,this.endContainer,this.endOffset)>0?1:0},createContextualFragment:Q,toHtml:function(){return et(this)},intersectsNode:function(t,e){if(Z(this),g(t)!=_(this))return!1;var n=t.parentNode,o=s(t);if(!n)return!0;var r=c(n,o,this.endContainer,this.endOffset),i=c(n,o+1,this.startContainer,this.startOffset);return e?r<=0&&i>=0:r<0&&i>0},isPointInRange:function(t,e){return Z(this),V(t,"HIERARCHY_REQUEST_ERR"),U(t,this.startContainer),c(t,e,this.startContainer,this.startOffset)>=0&&c(t,e,this.endContainer,this.endOffset)<=0},intersectsRange:function(t){return S(this,t,!1)},intersectsOrTouchesRange:function(t){return S(this,t,!0)},intersection:function(t){if(this.intersectsRange(t)){var e=c(this.startContainer,this.startOffset,t.startContainer,t.startOffset),n=c(this.endContainer,this.endOffset,t.endContainer,t.endOffset),o=this.cloneRange();return-1==e&&o.setStart(t.startContainer,t.startOffset),1==n&&o.setEnd(t.endContainer,t.endOffset),o}return null},union:function(t){if(this.intersectsOrTouchesRange(t)){var e=this.cloneRange();return-1==c(t.startContainer,t.startOffset,this.startContainer,this.startOffset)&&e.setStart(t.startContainer,t.startOffset),1==c(t.endContainer,t.endOffset,this.endContainer,this.endOffset)&&e.setEnd(t.endContainer,t.endOffset),e}throw new i("Ranges do not intersect")},containsNode:function(t,e){return e?this.intersectsNode(t,!1):this.compareNode(t)==ct},containsNodeContents:function(t){return this.comparePoint(t,0)>=0&&this.comparePoint(t,h(t))<=0},containsRange:function(t){var e=this.intersection(t);return null!==e&&t.equals(e)},containsNodeText:function(t){var e=this.cloneRange();e.selectNode(t);var n=e.getNodes([3]);if(n.length>0){e.setStart(n[0],0);var o=n.pop();return e.setEnd(o,o.length),this.containsRange(e)}return this.containsNodeContents(t)},getNodes:function(t,e){return Z(this),N(this,t,e)},getDocument:function(){return b(this)},collapseBefore:function(t){this.setEndBefore(t),this.collapse(!1)},collapseAfter:function(t){this.setStartAfter(t),this.collapse(!0)},getBookmark:function(e){var o=b(this),r=t.createRange(o);e=e||n.getBody(o),r.selectNodeContents(e);var i=this.intersection(r),a=0,s=0;return i&&(r.setEnd(i.startContainer,i.startOffset),s=(a=r.toString().length)+i.toString().length),{start:a,end:s,containerNode:e}},moveToBookmark:function(t){var e=t.containerNode,n=0;this.setStart(e,0),this.collapse(!0);for(var o,r,i,a,s=[e],l=!1,u=!1;!u&&(o=s.pop());)if(3==o.nodeType)r=n+o.length,!l&&t.start>=n&&t.start<=r&&(this.setStart(o,t.start-n),l=!0),l&&t.end>=n&&t.end<=r&&(this.setEnd(o,t.end-n),u=!0),n=r;else for(i=(a=o.childNodes).length;i--;)s.push(a[i])},getName:function(){return"DomRange"},equals:function(t){return yt.rangesEqual(this,t)},isValid:function(){return q(this)},inspect:function(){return A(this)},detach:function(){}}),ft(yt,vt),o.extend(yt,{rangeProperties:nt,RangeIterator:P,copyComparisonConstants:pt,createPrototypeRange:ft,inspect:A,toHtml:et,getRangeDocument:b,rangesEqual:function(t,e){return t.startContainer===e.startContainer&&t.startOffset===e.startOffset&&t.endContainer===e.endContainer&&t.endOffset===e.endOffset}}),t.DomRange=yt})),E.createCoreModule("WrappedRange",["DomRange"],(function(t,e){var n,o,r=t.dom,i=t.util,a=r.DomPosition,s=t.DomRange,l=r.getBody,u=r.getContentDocument,c=r.isCharacterDataNode;if(t.features.implementsDomRange&&function(){var o,a,c=s.rangeProperties;function d(t){for(var e,n=c.length;n--;)t[e=c[n]]=t.nativeRange[e];t.collapsed=t.startContainer===t.endContainer&&t.startOffset===t.endOffset}function p(t,e,n,o,r){var i=t.startContainer!==e||t.startOffset!=n,a=t.endContainer!==o||t.endOffset!=r,s=!t.equals(t.nativeRange);(i||a||s)&&(t.setEnd(o,r),t.setStart(e,n))}n=function(t){if(!t)throw e.createError("WrappedRange: Range must be specified");this.nativeRange=t,d(this)},s.createPrototypeRange(n,p),(o=n.prototype).selectNode=function(t){this.nativeRange.selectNode(t),d(this)},o.cloneContents=function(){return this.nativeRange.cloneContents()},o.surroundContents=function(t){this.nativeRange.surroundContents(t),d(this)},o.collapse=function(t){this.nativeRange.collapse(t),d(this)},o.cloneRange=function(){return new n(this.nativeRange.cloneRange())},o.refresh=function(){d(this)},o.toString=function(){return this.nativeRange.toString()};var h=document.createTextNode("test");l(document).appendChild(h);var f=document.createRange();f.setStart(h,0),f.setEnd(h,0);try{f.setStart(h,1),o.setStart=function(t,e){this.nativeRange.setStart(t,e),d(this)},o.setEnd=function(t,e){this.nativeRange.setEnd(t,e),d(this)},a=function(t){return function(e){this.nativeRange[t](e),d(this)}}}catch(t){o.setStart=function(t,e){try{this.nativeRange.setStart(t,e)}catch(n){this.nativeRange.setEnd(t,e),this.nativeRange.setStart(t,e)}d(this)},o.setEnd=function(t,e){try{this.nativeRange.setEnd(t,e)}catch(n){this.nativeRange.setStart(t,e),this.nativeRange.setEnd(t,e)}d(this)},a=function(t,e){return function(n){try{this.nativeRange[t](n)}catch(o){this.nativeRange[e](n),this.nativeRange[t](n)}d(this)}}}o.setStartBefore=a("setStartBefore","setEndBefore"),o.setStartAfter=a("setStartAfter","setEndAfter"),o.setEndBefore=a("setEndBefore","setStartBefore"),o.setEndAfter=a("setEndAfter","setStartAfter"),o.selectNodeContents=function(t){this.setStartAndEnd(t,0,r.getNodeLength(t))},f.selectNodeContents(h),f.setEnd(h,3);var g=document.createRange();g.selectNodeContents(h),g.setEnd(h,4),g.setStart(h,2),-1==f.compareBoundaryPoints(f.START_TO_END,g)&&1==f.compareBoundaryPoints(f.END_TO_START,g)?o.compareBoundaryPoints=function(t,e){return t==(e=e.nativeRange||e).START_TO_END?t=e.END_TO_START:t==e.END_TO_START&&(t=e.START_TO_END),this.nativeRange.compareBoundaryPoints(t,e)}:o.compareBoundaryPoints=function(t,e){return this.nativeRange.compareBoundaryPoints(t,e.nativeRange||e)};var v=document.createElement("div");v.innerHTML="123";var y=v.firstChild,m=l(document);m.appendChild(v),f.setStart(y,1),f.setEnd(y,2),f.deleteContents(),"13"==y.data&&(o.deleteContents=function(){this.nativeRange.deleteContents(),d(this)},o.extractContents=function(){var t=this.nativeRange.extractContents();return d(this),t}),m.removeChild(v),m=null,i.isHostMethod(f,"createContextualFragment")&&(o.createContextualFragment=function(t){return this.nativeRange.createContextualFragment(t)}),l(document).removeChild(h),o.getName=function(){return"WrappedRange"},t.WrappedRange=n,t.createNativeRange=function(t){return(t=u(t,e,"createNativeRange")).createRange()}}(),t.features.implementsTextRange){var d=function(t){var e=t.parentElement(),n=t.duplicate();n.collapse(!0);var o=n.parentElement();(n=t.duplicate()).collapse(!1);var i=n.parentElement(),a=o==i?o:r.getCommonAncestor(o,i);return a==e?a:r.getCommonAncestor(e,a)},p=function(t){return 0==t.compareEndPoints("StartToEnd",t)},h=function(t,e,n,o,i){var s=t.duplicate();s.collapse(n);var l=s.parentElement();if(r.isOrIsAncestorOf(e,l)||(l=e),!l.canHaveHTML){var u=new a(l.parentNode,r.getNodeIndex(l));return{boundaryPosition:u,nodeInfo:{nodeIndex:u.offset,containerElement:u.node}}}var d=r.getDocument(l).createElement("span");d.parentNode&&r.removeNode(d);for(var p,h,f,g,v,y=n?"StartToStart":"StartToEnd",m=i&&i.containerElement==l?i.nodeIndex:0,b=l.childNodes.length,_=b,x=_;x==b?l.appendChild(d):l.insertBefore(d,l.childNodes[x]),s.moveToElementText(d),0!=(p=s.compareEndPoints(y,t))&&m!=_;){if(-1==p){if(_==m+1)break;m=x}else _=_==m+1?m:x;x=Math.floor((m+_)/2),l.removeChild(d)}if(v=d.nextSibling,-1==p&&v&&c(v)){var E;if(s.setEndPoint(n?"EndToStart":"EndToEnd",t),/[\r\n]/.test(v.data)){var w=s.duplicate(),S=w.text.replace(/\r\n/g,"\r").length;for(E=w.moveStart("character",S);-1==(p=w.compareEndPoints("StartToEnd",w));)E++,w.moveStart("character",1)}else E=s.text.length;g=new a(v,E)}else h=(o||!n)&&d.previousSibling,g=(f=(o||n)&&d.nextSibling)&&c(f)?new a(f,0):h&&c(h)?new a(h,h.data.length):new a(l,r.getNodeIndex(d));return r.removeNode(d),{boundaryPosition:g,nodeInfo:{nodeIndex:x,containerElement:l}}},f=function(t,e){var n,o,i,a,s=t.offset,u=r.getDocument(t.node),d=l(u).createTextRange(),p=c(t.node);return p?o=(n=t.node).parentNode:(n=s<(a=t.node.childNodes).length?a[s]:null,o=t.node),(i=u.createElement("span")).innerHTML="&#feff;",n?o.insertBefore(i,n):o.appendChild(i),d.moveToElementText(i),d.collapse(!e),o.removeChild(i),p&&d[e?"moveStart":"moveEnd"]("character",s),d};(o=function(t){this.textRange=t,this.refresh()}).prototype=new s(document),o.prototype.refresh=function(){var t,e,n,o=d(this.textRange);p(this.textRange)?e=t=h(this.textRange,o,!0,!0).boundaryPosition:(t=(n=h(this.textRange,o,!0,!1)).boundaryPosition,e=h(this.textRange,o,!1,!1,n.nodeInfo).boundaryPosition),this.setStart(t.node,t.offset),this.setEnd(e.node,e.offset)},o.prototype.getName=function(){return"WrappedTextRange"},s.copyComparisonConstants(o);var g=function(t){if(t.collapsed)return f(new a(t.startContainer,t.startOffset),!0);var e=f(new a(t.startContainer,t.startOffset),!0),n=f(new a(t.endContainer,t.endOffset),!1),o=l(s.getRangeDocument(t)).createTextRange();return o.setEndPoint("StartToStart",e),o.setEndPoint("EndToEnd",n),o};if(o.rangeToTextRange=g,o.prototype.toTextRange=function(){return g(this)},t.WrappedTextRange=o,!t.features.implementsDomRange||t.config.preferTextRange){var v=Function("return this;")();void 0===v.Range&&(v.Range=o),t.createNativeRange=function(t){return t=u(t,e,"createNativeRange"),l(t).createTextRange()},t.WrappedRange=o}}t.createRange=function(n){return n=u(n,e,"createRange"),new t.WrappedRange(t.createNativeRange(n))},t.createRangyRange=function(t){return t=u(t,e,"createRangyRange"),new s(t)},i.createAliasForDeprecatedMethod(t,"createIframeRange","createRange"),i.createAliasForDeprecatedMethod(t,"createIframeRangyRange","createRangyRange"),t.addShimListener((function(e){var n=e.document;void 0===n.createRange&&(n.createRange=function(){return t.createRange(n)}),n=e=null}))})),E.createCoreModule("WrappedSelection",["DomRange","WrappedRange"],(function(t,e){t.config.checkSelectionRanges=!0;var n,o,r="boolean",i="number",a=t.dom,s=t.util,l=s.isHostMethod,u=t.DomRange,c=t.WrappedRange,d=t.DOMException,p=a.DomPosition,h=t.features,f="Control",g=a.getDocument,v=a.getBody,y=u.rangesEqual;function m(t){return"string"==typeof t?/^backward(s)?$/i.test(t):!!t}function b(t,n){if(t){if(a.isWindow(t))return t;if(t instanceof Z)return t.win;var o=a.getContentDocument(t,e,n);return a.getWindow(o)}return window}function _(t){return b(t,"getWinSelection").getSelection()}function x(t){return b(t,"getDocSelection").document.selection}function E(t){var e=!1;return t.anchorNode&&(e=1==a.comparePoints(t.anchorNode,t.anchorOffset,t.focusNode,t.focusOffset)),e}var w=l(window,"getSelection"),S=s.isHostObject(document,"selection");h.implementsWinGetSelection=w,h.implementsDocSelection=S;var C=S&&(!w||t.config.preferTextRange);if(C)n=x,t.isSelectionValid=function(t){var e=b(t,"isSelectionValid").document,n=e.selection;return"None"!=n.type||g(n.createRange().parentElement())==e};else{if(!w)return e.fail("Neither document.selection or window.getSelection() detected."),!1;n=_,t.isSelectionValid=function(){return!0}}t.getNativeSelection=n;var M=n();if(!M)return e.fail("Native selection was null (possibly issue 138?)"),!1;var O=t.createNativeRange(document),T=v(document),N=s.areHostProperties(M,["anchorNode","focusNode","anchorOffset","focusOffset"]);h.selectionHasAnchorAndFocus=N;var A=l(M,"extend");h.selectionHasExtend=A;var P=l(M,"setBaseAndExtent");h.selectionHasSetBaseAndExtent=P;var D=typeof M.rangeCount==i;h.selectionHasRangeCount=D;var k=!1,R=!0,I=A?function(e,n){var o=u.getRangeDocument(n),r=t.createRange(o);r.collapseToPoint(n.endContainer,n.endOffset),e.addRange(G(r)),e.extend(n.startContainer,n.startOffset)}:null;s.areHostMethods(M,["addRange","getRangeAt","removeAllRanges"])&&typeof M.rangeCount==i&&h.implementsDomRange&&function(){var e=window.getSelection();if(e){for(var n=e.rangeCount,o=n>1,r=[],i=E(e),s=0;s<n;++s)r[s]=e.getRangeAt(s);var l=a.createTestElement(document,"",!1),u=l.appendChild(document.createTextNode(" ")),c=document.createRange();if(c.setStart(u,1),c.collapse(!0),e.removeAllRanges(),e.addRange(c),R=1==e.rangeCount,e.removeAllRanges(),!o){var d=window.navigator.appVersion.match(/Chrome\/(.*?) /);if(d&&parseInt(d[1])>=36)k=!1;else{var p=c.cloneRange();c.setStart(u,0),p.setEnd(u,3),p.setStart(u,2),e.addRange(c),e.addRange(p),k=2==e.rangeCount}}for(a.removeNode(l),e.removeAllRanges(),s=0;s<n;++s)0==s&&i?I?I(e,r[s]):(t.warn("Rangy initialization: original selection was backwards but selection has been restored forwards because the browser does not support Selection.extend"),e.addRange(r[s])):e.addRange(r[s])}}(),h.selectionSupportsMultipleRanges=k,h.collapsedNonEditableSelectionsSupported=R;var L,j,B=!1;function H(t,e,n){var o=n?"end":"start",r=n?"start":"end";t.anchorNode=e[o+"Container"],t.anchorOffset=e[o+"Offset"],t.focusNode=e[r+"Container"],t.focusOffset=e[r+"Offset"]}function z(t){var e=t.nativeSelection;t.anchorNode=e.anchorNode,t.anchorOffset=e.anchorOffset,t.focusNode=e.focusNode,t.focusOffset=e.focusOffset}function F(t){t.anchorNode=t.focusNode=null,t.anchorOffset=t.focusOffset=0,t.rangeCount=0,t.isCollapsed=!0,t._ranges.length=0,W(t)}function W(t){t.type=0==t.rangeCount?"None":o(t)?"Caret":"Range"}function G(e){var n;return e instanceof u?((n=t.createNativeRange(e.getDocument())).setEnd(e.endContainer,e.endOffset),n.setStart(e.startContainer,e.startOffset)):e instanceof c?n=e.nativeRange:h.implementsDomRange&&e instanceof a.getWindow(e.startContainer).Range&&(n=e),n}function X(t){if(!t.length||1!=t[0].nodeType)return!1;for(var e=1,n=t.length;e<n;++e)if(!a.isAncestorOf(t[0],t[e]))return!1;return!0}function U(t){var n=t.getNodes();if(!X(n))throw e.createError("getSingleElementFromRange: range "+t.inspect()+" did not consist of a single element");return n[0]}function Y(t){return!!t&&void 0!==t.text}function V(t,e){var n=new c(e);t._ranges=[n],H(t,n,!1),t.rangeCount=1,t.isCollapsed=n.collapsed,W(t)}function K(e){if(e._ranges.length=0,"None"==e.docSelection.type)F(e);else{var n=e.docSelection.createRange();if(Y(n))V(e,n);else{e.rangeCount=n.length;for(var o,r=g(n.item(0)),i=0;i<e.rangeCount;++i)(o=t.createRange(r)).selectNode(n.item(i)),e._ranges.push(o);e.isCollapsed=1==e.rangeCount&&e._ranges[0].collapsed,H(e,e._ranges[e.rangeCount-1],!1),W(e)}}}function q(t,n){for(var o=t.docSelection.createRange(),r=U(n),i=g(o.item(0)),a=v(i).createControlRange(),s=0,l=o.length;s<l;++s)a.add(o.item(s));try{a.add(r)}catch(t){throw e.createError("addRange(): Element within the specified Range could not be added to control selection (does it have layout?)")}a.select(),K(t)}function Z(t,e,n){this.nativeSelection=t,this.docSelection=e,this._ranges=[],this.win=n,this.refresh()}function $(t){t.win=t.anchorNode=t.focusNode=t._ranges=null,t.rangeCount=t.anchorOffset=t.focusOffset=0,t.detached=!0,W(t)}T&&l(T,"createControlRange")&&(L=T.createControlRange(),s.areHostProperties(L,["item","add"])&&(B=!0)),h.implementsControlRange=B,o=N?function(t){return t.anchorNode===t.focusNode&&t.anchorOffset===t.focusOffset}:function(t){return!!t.rangeCount&&t.getRangeAt(t.rangeCount-1).collapsed},l(M,"getRangeAt")?j=function(t,e){try{return t.getRangeAt(e)}catch(t){return null}}:N&&(j=function(e){var n=g(e.anchorNode),o=t.createRange(n);return o.setStartAndEnd(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset),o.collapsed!==this.isCollapsed&&o.setStartAndEnd(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset),o}),Z.prototype=t.selectionPrototype;var J=[];function Q(t,e){for(var n,o,r=J.length;r--;)if(o=(n=J[r]).selection,"deleteAll"==e)$(o);else if(n.win==t)return"delete"==e?(J.splice(r,1),!0):o;return"deleteAll"==e&&(J.length=0),null}var tt=function(t){if(t&&t instanceof Z)return t.refresh(),t;var e=Q(t=b(t,"getNativeSelection")),o=n(t),r=S?x(t):null;return e?(e.nativeSelection=o,e.docSelection=r,e.refresh()):(e=new Z(o,r,t),J.push({win:t,selection:e})),e};t.getSelection=tt,s.createAliasForDeprecatedMethod(t,"getIframeSelection","getSelection");var et,nt=Z.prototype;function ot(t,n){for(var o,r=g(n[0].startContainer),i=v(r).createControlRange(),a=0,s=n.length;a<s;++a){o=U(n[a]);try{i.add(o)}catch(t){throw e.createError("setRanges(): Element within one of the specified Ranges could not be added to control selection (does it have layout?)")}}i.select(),K(t)}if(!C&&N&&s.areHostMethods(M,["removeAllRanges","addRange"])){nt.removeAllRanges=function(){this.nativeSelection.removeAllRanges(),F(this)};var rt=function(t,e){I(t.nativeSelection,e),t.refresh()};nt.addRange=D?function(e,n){if(B&&S&&this.docSelection.type==f)q(this,e);else if(m(n)&&A)rt(this,e);else{var r;k?r=this.rangeCount:(this.removeAllRanges(),r=0);var i=G(e).cloneRange();try{this.nativeSelection.addRange(i)}catch(t){}if(this.rangeCount=this.nativeSelection.rangeCount,this.rangeCount==r+1){if(t.config.checkSelectionRanges){var a=j(this.nativeSelection,this.rangeCount-1);a&&!y(a,e)&&(e=new c(a))}this._ranges[this.rangeCount-1]=e,H(this,e,it(this.nativeSelection)),this.isCollapsed=o(this),W(this)}else this.refresh()}}:function(t,e){m(e)&&A?rt(this,t):(this.nativeSelection.addRange(G(t)),this.refresh())},nt.setRanges=function(t){if(B&&S&&t.length>1)ot(this,t);else{this.removeAllRanges();for(var e=0,n=t.length;e<n;++e)this.addRange(t[e])}}}else{if(!(l(M,"empty")&&l(O,"select")&&B&&C))return e.fail("No means of selecting a Range or TextRange was found"),!1;nt.removeAllRanges=function(){try{if(this.docSelection.empty(),"None"!=this.docSelection.type){var t;if(this.anchorNode)t=g(this.anchorNode);else if(this.docSelection.type==f){var e=this.docSelection.createRange();e.length&&(t=g(e.item(0)))}t&&(v(t).createTextRange().select(),this.docSelection.empty())}}catch(t){}F(this)},nt.addRange=function(e){this.docSelection.type==f?q(this,e):(t.WrappedTextRange.rangeToTextRange(e).select(),this._ranges[0]=e,this.rangeCount=1,this.isCollapsed=this._ranges[0].collapsed,H(this,e,!1),W(this))},nt.setRanges=function(t){this.removeAllRanges();var e=t.length;e>1?ot(this,t):e&&this.addRange(t[0])}}if(nt.getRangeAt=function(t){if(t<0||t>=this.rangeCount)throw new d("INDEX_SIZE_ERR");return this._ranges[t].cloneRange()},C)et=function(e){var n;t.isSelectionValid(e.win)?n=e.docSelection.createRange():(n=v(e.win.document).createTextRange()).collapse(!0),e.docSelection.type==f?K(e):Y(n)?V(e,n):F(e)};else if(l(M,"getRangeAt")&&typeof M.rangeCount==i)et=function(e){if(B&&S&&e.docSelection.type==f)K(e);else if(e._ranges.length=e.rangeCount=e.nativeSelection.rangeCount,e.rangeCount){for(var n=0,r=e.rangeCount;n<r;++n)e._ranges[n]=new t.WrappedRange(e.nativeSelection.getRangeAt(n));H(e,e._ranges[e.rangeCount-1],it(e.nativeSelection)),e.isCollapsed=o(e),W(e)}else F(e)};else{if(!N||typeof M.isCollapsed!=r||typeof O.collapsed!=r||!h.implementsDomRange)return e.fail("No means of obtaining a Range or TextRange from the user's selection was found"),!1;et=function(t){var e,n=t.nativeSelection;n.anchorNode?(e=j(n,0),t._ranges=[e],t.rangeCount=1,z(t),t.isCollapsed=o(t),W(t)):F(t)}}nt.refresh=function(t){var e=t?this._ranges.slice(0):null,n=this.anchorNode,o=this.anchorOffset;if(et(this),t){var r=e.length;if(r!=this._ranges.length)return!0;if(this.anchorNode!=n||this.anchorOffset!=o)return!0;for(;r--;)if(!y(e[r],this._ranges[r]))return!0;return!1}};var it,at=function(t,e){var n=t.getAllRanges();t.removeAllRanges();for(var o=0,r=n.length;o<r;++o)y(e,n[o])||t.addRange(n[o]);t.rangeCount||F(t)};function st(t,e){if(t.win.document!=g(e))throw new d("WRONG_DOCUMENT_ERR")}function lt(t,e){if(e<0||e>(a.isCharacterDataNode(t)?t.length:t.childNodes.length))throw new d("INDEX_SIZE_ERR")}function ut(e){return function(n,o){var r;this.rangeCount?(r=this.getRangeAt(0))["set"+(e?"Start":"End")](n,o):(r=t.createRange(this.win.document)).setStartAndEnd(n,o),this.setSingleRange(r,this.isBackward())}}function ct(t){var e=[],n=new p(t.anchorNode,t.anchorOffset),o=new p(t.focusNode,t.focusOffset),r="function"==typeof t.getName?t.getName():"Selection";if(void 0!==t.rangeCount)for(var i=0,a=t.rangeCount;i<a;++i)e[i]=u.inspect(t.getRangeAt(i));return"["+r+"(Ranges: "+e.join(", ")+")(anchor: "+n.inspect()+", focus: "+o.inspect()+"]"}nt.removeRange=B&&S?function(t){if(this.docSelection.type==f){for(var e=this.docSelection.createRange(),n=U(t),o=g(e.item(0)),r=v(o).createControlRange(),i=!1,a=0,s=e.length;a<s;++a)e.item(a)!==n||i?r.add(e.item(a)):i=!0;r.select(),K(this)}else at(this,t)}:function(t){at(this,t)},!C&&N&&h.implementsDomRange?(it=E,nt.isBackward=function(){return it(this)}):it=nt.isBackward=function(){return!1},nt.isBackwards=nt.isBackward,nt.toString=function(){for(var t=[],e=0,n=this.rangeCount;e<n;++e)t[e]=""+this._ranges[e];return t.join("")},nt.collapse=function(e,n){st(this,e);var o=t.createRange(e);o.collapseToPoint(e,n),this.setSingleRange(o),this.isCollapsed=!0},nt.collapseToStart=function(){if(!this.rangeCount)throw new d("INVALID_STATE_ERR");var t=this._ranges[0];this.collapse(t.startContainer,t.startOffset)},nt.collapseToEnd=function(){if(!this.rangeCount)throw new d("INVALID_STATE_ERR");var t=this._ranges[this.rangeCount-1];this.collapse(t.endContainer,t.endOffset)},nt.selectAllChildren=function(e){st(this,e);var n=t.createRange(e);n.selectNodeContents(e),this.setSingleRange(n)},P?nt.setBaseAndExtent=function(t,e,n,o){this.nativeSelection.setBaseAndExtent(t,e,n,o),this.refresh()}:A&&(nt.setBaseAndExtent=function(e,n,o,r){lt(e,n),lt(o,r),st(this,e),st(this,o);var i=t.createRange(node),s=-1==a.comparePoints(e,n,o,r);s?i.setStartAndEnd(o,r,e,n):i.setStartAndEnd(e,n,o,r),this.setSingleRange(i,s)}),nt.deleteFromDocument=function(){if(B&&S&&this.docSelection.type==f){for(var t,e=this.docSelection.createRange();e.length;)t=e.item(0),e.remove(t),a.removeNode(t);this.refresh()}else if(this.rangeCount){var n=this.getAllRanges();if(n.length){this.removeAllRanges();for(var o=0,r=n.length;o<r;++o)n[o].deleteContents();this.addRange(n[r-1])}}},nt.eachRange=function(t,e){for(var n=0,o=this._ranges.length;n<o;++n)if(t(this.getRangeAt(n)))return e},nt.getAllRanges=function(){var t=[];return this.eachRange((function(e){t.push(e)})),t},nt.setSingleRange=function(t,e){this.removeAllRanges(),this.addRange(t,e)},nt.callMethodOnEachRange=function(t,e){var n=[];return this.eachRange((function(o){n.push(o[t].apply(o,e||[]))})),n},nt.setStart=ut(!0),nt.setEnd=ut(!1),t.rangePrototype.select=function(t){tt(this.getDocument()).setSingleRange(this,t)},nt.changeEachRange=function(t){var e=[],n=this.isBackward();this.eachRange((function(n){t(n),e.push(n)})),this.removeAllRanges(),n&&1==e.length?this.addRange(e[0],"backward"):this.setRanges(e)},nt.containsNode=function(t,e){return this.eachRange((function(n){return n.containsNode(t,e)}),!0)||!1},nt.getBookmark=function(t){return{backward:this.isBackward(),rangeBookmarks:this.callMethodOnEachRange("getBookmark",[t])}},nt.moveToBookmark=function(e){for(var n,o,r=[],i=0;n=e.rangeBookmarks[i++];)(o=t.createRange(this.win)).moveToBookmark(n),r.push(o);e.backward?this.setSingleRange(r[0],"backward"):this.setRanges(r)},nt.saveRanges=function(){return{backward:this.isBackward(),ranges:this.callMethodOnEachRange("cloneRange")}},nt.restoreRanges=function(t){this.removeAllRanges();for(var e,n=0;e=t.ranges[n];++n)this.addRange(e,t.backward&&0==n)},nt.toHtml=function(){var t=[];return this.eachRange((function(e){t.push(u.toHtml(e))})),t.join("")},h.implementsTextRange&&(nt.getNativeTextRange=function(){var n;if(n=this.docSelection){var o=n.createRange();if(Y(o))return o;throw e.createError("getNativeTextRange: selection is a control selection")}if(this.rangeCount>0)return t.WrappedTextRange.rangeToTextRange(this.getRangeAt(0));throw e.createError("getNativeTextRange: selection contains no range")}),nt.getName=function(){return"WrappedSelection"},nt.inspect=function(){return ct(this)},nt.detach=function(){Q(this.win,"delete"),$(this)},Z.detachAll=function(){Q(null,"deleteAll")},Z.inspect=ct,Z.isDirectionBackward=m,t.Selection=Z,t.selectionPrototype=nt,t.addShimListener((function(t){void 0===t.getSelection&&(t.getSelection=function(){return tt(t)}),t=null}))}));var B=!1,H=function(t){B||(B=!0,!E.initialized&&E.config.autoInitialize&&N())};return _&&("complete"==document.readyState?H():(s(document,"addEventListener")&&document.addEventListener("DOMContentLoaded",H,!1),y(window,"load",H))),E}()}(PT);var DT=AT,kT={toolbar:{allowMultiParagraphSelection:!0,buttons:["bold","colorpicker","italic","underline","strikethrough","quote","justifyLeft","justifyCenter","justifyRight","justifyFull","superscript","subscript","orderedlist","unorderedlist","pre","removeFormat","outdent","indent","h2","h3"],standardizeSelectionStart:!1,updateOnEmptySelection:!1},placeholder:{text:"请输入内容",hideOnClick:!0},disableEditing:!0},RT=hT.extensions.button.extend({name:"colorpicker",tagNames:["mark"],contentDefault:"<b>Color</b>",aria:"Color Picker",action:"colorPicker",init:function(){var t=this;DT.init(),hT.extensions.button.prototype.init.call(this),this.colorPicker=new TT({parent:this.button,color:"#000",onDone:function(e){t.coloredText&&t.coloredText.isAppliedToSelection()&&t.coloredText.undoToSelection(),t.coloredText=DT.createClassApplier("colored",{elementTagName:"span",elementProperties:{style:{color:e.hex}},normalize:!0}),t.coloredText.toggleSelection(),t.base.checkContentChanged(),t.setInactive()}})},getButton:function(){return this.button},handleClick:function(){this.setActive(),this.colorPicker.show()},isAlreadyApplied:function(t){return"mark"===t.nodeName.toLowerCase()},isActive:function(){return this.button.classList.contains("medium-editor-button-active")},setInactive:function(){this.button.classList.remove("medium-editor-button-active")},setActive:function(){this.button.classList.add("medium-editor-button-active")}}),IT=function(t){function e(e){var n=t.call(this,e)||this;n.labelMap=new Map;var o=e.lf,r=e.graphModel;return n.lf=o,n.graphModel=r,n.state={tick:0},n}return h(e,t),e.prototype.componentDidMount=function(){var t=this,e=this.props.graphModel;this.editor=new hT(".lf-label-editor",ag(kT,{autoLink:!0,extensions:{colorPicker:new RT}})),e.eventCenter.on("text:update,node:mousemove,node:resize,node:rotate,node:drag,label:drop,node:drop",(function(){})),e.eventCenter.on("node:properties-change,node:properties-delete",(function(){t.setState({tick:t.state.tick+1})}))},e.prototype.componentDidUpdate=function(){var t;this.editor&&this.editor.elements.length>0?this.editor.addElements(".lf-label-editor"):(null===(t=this.editor)||void 0===t||t.destroy(),this.editor=new hT(".lf-label-editor",ag(kT,{autoLink:!0,extensions:{colorPicker:new RT}})))},e.prototype.componentWillUnmount=function(){var t;null===(t=this.editor)||void 0===t||t.destroy()},e.prototype.getLabels=function(){var t=this,e=this.props,n=e.lf.extension,o=e.graphModel,r=x(x([],_(o.nodes),!1),_(o.edges),!1);if(n.Label){var i=[];return oh(r,(function(e){var n,r;oh(null!==(r=null===(n=e.getData().properties)||void 0===n?void 0:n._label)&&void 0!==r?r:[],(function(n){var r=t.labelMap,a=new cT(n,e,o);r.set(a.id,a),i.push(xr(lT,{label:a,element:e,graphModel:o},a.id))}))})),i}return null},e.prototype.render=function(){return xr("foreignObject",{id:"lf-label-overlay",class:"lf-label-overlay",children:this.getLabels()})},e.toolName="label-edit-tool",e=v([yC],e)}(ho);var LT=function(){function t(t){var e,n,o,r=t.lf,i=t.options;this.labelInitPositionMap=new Map,this.lf=r,this.options=null!=i?i:{},this.textOverflowMode=null!==(e=i.textOverflowMode)&&void 0!==e?e:"default",this.isMultiple=null===(n=i.isMultiple)||void 0===n||n,this.labelWidth=i.labelWidth,this.maxCount=null!==(o=i.maxCount)&&void 0!==o?o:1/0,r.graphModel.editConfigModel.updateTextMode(Am.LABEL),this.addEventListeners(),r.tool.registerTool(IT.toolName,IT),r.tool.disableTool("text-edit-tool")}return t.prototype.formatConfig=function(t,e){var n=t.editConfigModel,o=n.nodeTextEdit,r=n.edgeTextEdit,i=n.nodeTextDraggable,a=n.edgeTextDraggable,s=this,l=s.textOverflowMode,u=s.isMultiple,c=s.maxCount,d=s.labelWidth,p=e.text,h=e.zIndex,g=e.properties,v=g._label,y=g._labelOption,m=v,b=void 0===y?{}:y,_=b.isMultiple,x=b.maxCount,E=[];if(Fr(m)){var w=null!=x?x:c;E=u&&_?m.length>w?m.slice(0,w):m:[m[0]]}else if(Jr(m))E=[m];else if("string"==typeof m||!m){var S=f(f({},p),{content:m||p.value,draggable:"edge"===e.BaseType?a:i});E=S.value?[S]:[]}return"edge"===e.BaseType&&(E=Ih(E,(function(t){var e=t.x,n=t.y;return console.log("x, y ---\x3e>>",e,n),t}))),Ih(E,(function(t){t.id||(t.id=g_());var n=t.value,s=t.content,u=t.vertical,c=t.editable,p=t.draggable,g=t.textOverflowMode,v="node"===e.BaseType?o:r,y="node"===e.BaseType?i:a;return f(f({},t),{zIndex:h,labelWidth:d,content:null!=s?s:n,vertical:null!=u&&u,editable:v&&c,draggable:y&&p,textOverflowMode:null!=g?g:l})}))},t.prototype.setupLabels=function(t){var e=this;oh(t.sortElements,(function(n){e.rewriteInnerMethods(n);var o=e.formatConfig(t,n);n.setProperty("_label",o)}))},t.prototype.addLabel=function(t,e){var n,o,r,i=this.maxCount,a=t.properties,s=null!==(n=a._label)&&void 0!==n?n:[],l=null!==(o=a._labelOption)&&void 0!==o?o:{},u=s.length,c={id:g_(),x:e.x,y:e.y,content:"Label".concat(u+1),value:"Label".concat(u+1),style:{},draggable:!0,editable:!0,vertical:!1};u>=(null!==(r=null==l?void 0:l.maxCount)&&void 0!==r?r:i)||(s.push(c),t.setProperty("_label",s))},t.prototype.addEventListeners=function(){var t=this,e=this.lf.graphModel,n=e.eventCenter,o=e.editConfigModel;n.on("graph:rendered",(function(e){var n=e.graphModel;t.setupLabels(n)})),n.on("node:dbclick,edge:dbclick",(function(n){var r=n.e,i=n.data,a=e.getElement(i.id),s=e.getPointByClient({x:r.clientX,y:r.clientY}).canvasOverlayPosition,l={x:s.x,y:s.y};a&&o.textMode===Am.LABEL&&t.addLabel(a,l)})),n.on("node:resize",(function(t){var e,n,o=t.preData,r=t.data,i=t.model,a=null!==(e=o.properties)&&void 0!==e?e:{},s=a.width,l=a.height,u=a._label,c=void 0===u?[]:u,d=null!==(n=r.properties)&&void 0!==n?n:{},p=d.width,h=d.height;if(s&&l&&p&&h){var g={x:o.x,y:o.y,width:s,height:l},v={x:r.x,y:r.y,width:p,height:h},y=Ih(c,(function(t){var e,n,o,r,i,a,s,l,u,c,d,p=t.x,h=t.y,y=(n=v,o={x:p,y:h},r=(e=g).x,i=e.y,a=e.width,s=e.height,l=n.x,u=n.y,c=n.width,d=n.height,{x:l+(o.x-r)/a*c,y:u+(o.y-i)/s*d});return f(f({},t),y)}));i.setProperty("_label",y)}})),n.on("node:rotate",(function(e){var n=e.model,o=n.x,r=n.y,i=n.rotate,a=n.properties._label,s={x:o,y:r},l=Ih(void 0===a?[]:a,(function(e){if(!e.id)return e;var n={x:e.x,y:e.y};t.labelInitPositionMap.has(e.id)?n=t.labelInitPositionMap.get(e.id):t.labelInitPositionMap.set(e.id,n);var o=i*(180/Math.PI);o<0&&(o+=360);var r=o*(Math.PI/180),a=function(t,e,n){var o=e.x,r=e.y,i=t.x-o,a=t.y-r;return{x:i*Math.cos(n)-a*Math.sin(n)+o,y:i*Math.sin(n)+a*Math.cos(n)+r}}(n,s,r);return f(f(f({},e),a),{rotate:o})}));n.setProperty("_label",l)}))},t.prototype.rewriteInnerMethods=function(t){t.moveText=function(e,n){if(t.text){var o=t.text,r=o.x,i=o.y,a=o.value,s=o.draggable,l=o.editable;t.text={value:a,editable:l,draggable:s,x:r+e,y:i+n};var u=_d(t.getProperties());if(Fr(u._label)){var c=Ih(u._label,(function(t){return f(f({},t),{x:t.x+e,y:t.y+n})}));null==t||t.setProperty("_label",c)}}}},t.prototype.updateTextMode=function(t){var e=this.lf.graphModel.editConfigModel;t!==e.textMode&&(e.updateTextMode(t),t===Am.LABEL?(this.lf.tool.enableTool(IT.toolName),this.lf.tool.disableTool("text-edit-tool")):t===Am.TEXT&&(this.lf.tool.enableTool("text-edit-tool"),this.lf.tool.disableTool(IT.toolName)))},t.prototype.render=function(){},t.prototype.destroy=function(){},t.pluginName="Label",t}(),jT={};function BT(t){return t.startsWith("data:text/plain")}function HT(t){return y(this,void 0,void 0,(function(){return m(this,(function(e){return jT[t]?[2,jT[t]]:[2,new Promise((function(e,n){try{fetch(t).then((function(t){return t.blob()})).then((function(o){var r=new FileReader;r.onloadend=function(){e(jT[t]=r.result)},r.onerror=n,r.readAsDataURL(o)})).catch((function(){e(jT[t]=t)}))}catch(e){return jT[t]=t}}))]}))}))}function zT(t,e){return y(this,void 0,void 0,(function(){var n,o,r;return m(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),(n=t.getAttribute(e)||"").startsWith("data:")?[2]:[4,HT(n)];case 1:return BT(o=i.sent())?[2]:(t.setAttribute(e,o),[3,3]);case 2:return r=i.sent(),console.error(r),[3,3];case 3:return[2]}}))}))}function FT(t,e){return y(this,void 0,void 0,(function(){var n,o;return m(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e.startsWith("data:")?[2]:[4,HT(e)];case 1:return BT(n=r.sent())?[2]:(t.style.backgroundImage="url(".concat(n,")"),[3,3]);case 2:return o=r.sent(),console.error(o),[3,3];case 3:return[2]}}))}))}function WT(t){return y(this,void 0,void 0,(function(){var e,n,o,r,i,a,s,l,u;return m(this,(function(c){switch(c.label){case 0:for(e=[t],o=[];e.length;)(n=e.shift()).children.length&&e.push.apply(e,x([],_(n.children),!1)),n instanceof HTMLElement&&(r=n.style,i=r.background,a=r.backgroundImage,(s=i.match(/url\(["']?(.*?)["']?\)/))&&s[1]&&(u=s[1],o.push(FT(n,u))),(l=a.match(/url\(["']?(.*?)["']?\)/))&&l[1]&&(u=l[1],o.push(FT(n,u)))),n instanceof HTMLImageElement?o.push(zT(n,"src")):n instanceof SVGImageElement&&o.push(zT(n,"href"));return[4,Promise.all(o)];case 1:return c.sent(),[2]}}))}))}function GT(t,e,n){var o=document.createElement("canvas");o.width=e,o.height=n;var r=o.getContext("2d");return r&&r.drawImage(t,0,0,t.width,t.height,0,0,e,n),o}var XT=function(){function t(t){var e=t.lf,n=this;this.lf=e,this.customCssRules="",this.useGlobalRules=!0,e.getSnapshot=function(t,e){return y(n,void 0,void 0,(function(){return m(this,(function(n){switch(n.label){case 0:return[4,this.getSnapshot(t,e)];case 1:return[2,n.sent()]}}))}))},e.getSnapshotBlob=function(t,e){return y(n,void 0,void 0,(function(){return m(this,(function(n){switch(n.label){case 0:return[4,this.getSnapshotBlob(t,e)];case 1:return[2,n.sent()]}}))}))},e.getSnapshotBase64=function(t,e){return y(n,void 0,void 0,(function(){return m(this,(function(n){switch(n.label){case 0:return[4,this.getSnapshotBase64(t,e)];case 1:return[2,n.sent()]}}))}))}}return t.prototype.getSvgRootElement=function(t){return t.container.querySelector(".lf-canvas-overlay")},t.prototype.triggerDownload=function(t){var e=new MouseEvent("click",{view:document.defaultView,bubbles:!1,cancelable:!0}),n=document.createElement("a");n.setAttribute("download",this.fileName),n.setAttribute("href",t),n.setAttribute("target","_blank"),n.dispatchEvent(e)},t.prototype.removeAnchor=function(t){for(var e=t.childNodes,n=t.childNodes&&t.childNodes.length,o=0;o<n;o++){var r=e[o];(r.classList&&Array.from(r.classList)||[]).indexOf("lf-anchor")>-1&&(t.removeChild(t.childNodes[o]),n--,o--)}},t.prototype.removeRotateControl=function(t){for(var e=t.childNodes,n=t.childNodes&&t.childNodes.length,o=0;o<n;o++){var r=e[o];(r.classList&&Array.from(r.classList)||[]).indexOf("lf-rotate-control")>-1&&(t.removeChild(t.childNodes[o]),n--,o--)}},t.prototype.getSnapshot=function(t,e){return y(this,void 0,void 0,(function(){var n,o,r,i,a=this;return m(this,(function(s){switch(s.label){case 0:return n=this.lf.graphModel.getPartial(),o=(null!=e?e:{}).partial,r=void 0===o?n:o,i=this.lf.getEditConfig(),this.lf.updateEditConfig({isSilentMode:!0,stopScrollGraph:!0,stopMoveGraph:!0}),n===r?[3,1]:(this.lf.graphModel.setPartial(r),this.lf.graphModel.eventCenter.once("graph:updated",(function(){return y(a,void 0,void 0,(function(){return m(this,(function(o){switch(o.label){case 0:return[4,this.snapshot(t,e)];case 1:return o.sent(),this.lf.graphModel.setPartial(n),[2]}}))}))})),[3,3]);case 1:return[4,this.snapshot(t,e)];case 2:s.sent(),s.label=3;case 3:return this.lf.updateEditConfig(i),[2]}}))}))},t.prototype.snapshot=function(t,e){return y(this,void 0,void 0,(function(){var n,o,r,i,a,s,l,u,c,d=this;return m(this,(function(p){switch(p.label){case 0:return o=(n=null!=e?e:{}).fileType,r=void 0===o?"png":o,i=n.quality,this.fileName="".concat(null!=t?t:"logic-flow.".concat(Date.now()),".").concat(r),[4,WT(a=this.getSvgRootElement(this.lf))];case 1:return p.sent(),"svg"===r?(s=this.cloneSvg(a),l=(new XMLSerializer).serializeToString(s),u=new Blob([l],{type:"image/svg+xml;charset=utf-8"}),c=URL.createObjectURL(u),this.triggerDownload(c)):this.getCanvasData(a,null!=e?e:{}).then((function(t){var e=t.toDataURL("image/".concat(r),i).replace("image/".concat(r),"image/octet-stream");d.triggerDownload(e)})),[2]}}))}))},t.prototype.getSnapshotBase64=function(t,e){return y(this,void 0,void 0,(function(){var n,o=this;return m(this,(function(r){switch(r.label){case 0:return[4,WT(n=this.getSvgRootElement(this.lf))];case 1:return r.sent(),[2,new Promise((function(r){o.getCanvasData(n,{backgroundColor:t}).then((function(t){var n=t.toDataURL("image/".concat(null!=e?e:"png"));r({data:n,width:t.width,height:t.height})}))}))]}}))}))},t.prototype.getSnapshotBlob=function(t,e){return y(this,void 0,void 0,(function(){var n,o=this;return m(this,(function(r){switch(r.label){case 0:return[4,WT(n=this.getSvgRootElement(this.lf))];case 1:return r.sent(),[2,new Promise((function(r){o.getCanvasData(n,{backgroundColor:t}).then((function(t){t.toBlob((function(e){r({data:e,width:t.width,height:t.height})}),"image/".concat(null!=e?e:"png"))}))}))]}}))}))},t.prototype.getClassRules=function(){var t="";if(this.useGlobalRules)for(var e=document.styleSheets,n=0;n<e.length;n++){var o=e[n];try{for(var r=0;r<o.cssRules.length;r++)t+=o.cssRules[r].cssText}catch(t){console.log("CSS scripts from different sources have been filtered out")}}return this.customCssRules&&(t+=this.customCssRules),t},t.prototype.getCanvasData=function(t,e){return y(this,void 0,void 0,(function(){var n,o,r,i,a,s,l,u,c,d,p,h,f,g,v,y,b,_,x,E,w,S,C,M,O,T;return m(this,(function(m){return n=e.width,o=e.height,r=e.backgroundColor,i=e.padding,a=void 0===i?40:i,s=this.cloneSvg(t,!1),(l=window.devicePixelRatio||1)<1&&(l=1),u=this.lf.graphModel.rootEl.querySelector(".lf-base"),c=u.getBoundingClientRect(),d=this.lf.container.querySelector(".lf-canvas-overlay"),p=d.getBoundingClientRect(),h=c.x-p.x,f=c.y-p.y,g=this.lf.graphModel,v=g.transformModel,y=v.SCALE_X,b=v.SCALE_Y,_=v.TRANSLATE_X,x=v.TRANSLATE_Y,s.lastChild.style.transform="matrix(1, 0, 0, 1, ".concat((-h+_)*(1/y),", ").concat((-f+x)*(1/b),")"),E=Math.ceil(c.width/y),w=Math.ceil(c.height/b),(S=document.createElement("canvas")).style.width="".concat(E,"px"),S.style.height="".concat(w,"px"),S.width=E*l+2*a,S.height=w*l+2*a,(C=S.getContext("2d"))&&(C.clearRect(0,0,S.width,S.height),C.scale(l,l),r?(C.fillStyle=r,C.fillRect(0,0,S.width,S.height)):C.clearRect(0,0,S.width,S.height)),M=new Image,(O=document.createElement("style")).innerHTML=this.getClassRules(),(T=document.createElement("foreignObject")).appendChild(O),s.appendChild(T),[2,new Promise((function(t){M.onload=function(){var e=navigator.userAgent.indexOf("Firefox")>-1;try{e?createImageBitmap(M,{resizeWidth:n&&o?GT(S,n,o).width:S.width,resizeHeight:n&&o?GT(S,n,o).height:S.height}).then((function(e){null==C||C.drawImage(e,a/l,a/l),t(n&&o?GT(S,n,o):S)})):(null==C||C.drawImage(M,a/l,a/l),t(n&&o?GT(S,n,o):S))}catch(e){null==C||C.drawImage(M,a/l,a/l),t(n&&o?GT(S,n,o):S)}};var e="data:image/svg+xml;charset=utf-8,".concat((new XMLSerializer).serializeToString(s)).replace(/\n/g,"").replace(/\t/g,"").replace(/#/g,"%23");M.src=e}))]}))}))},t.prototype.cloneSvg=function(t,e){var n,o=this;void 0===e&&(e=!0);var r=t.cloneNode(!0),i=r.lastChild,a=null===(n=null==i?void 0:i.childNodes)||void 0===n?void 0:n.length;if(a)for(var s=0;s<a;s++){var l=null==i?void 0:i.childNodes[s],u=l.classList&&Array.from(l.classList);if(u&&u.indexOf("lf-base")<0)null==i||i.removeChild(i.childNodes[s]),a--,s--;else{var c=null==i?void 0:i.childNodes[s];c&&c.childNodes.forEach((function(t){var e=t;o.removeAnchor(e.firstChild),o.removeRotateControl(e.firstChild)}))}}if(e){var d=document.createElement("style");d.innerHTML=this.getClassRules();var p=document.createElement("foreignObject");p.appendChild(d),r.appendChild(p)}return r},t.pluginName="snapshot",t}(),UT=function(){function t(t){var e=t.lf,n=this;this.lf=e,this.paths=[],e.getPathes=function(){if(!n.startNodeType)throw new Error("需要预先指定开始节点类型");return n.getPathes()},e.setRawPaths=function(t){n.setPathes(t)},e.getRawPathes=function(){return n.paths},e.setStartNodeType=function(t){n.startNodeType=t}}return t.prototype.setPathes=function(t){this.paths=t.map((function(t){return{routeId:t.routeId,name:t.name,elements:t.elements,type:t.type,similarElement:null,weight:0}}))},t.prototype.getPathes=function(){var t=this,e=this.lf.getGraphRawData(),n=new Map,o=[];e.nodes.forEach((function(e){n.set(e.id,{id:e.id,data:e,nextNodes:[]}),e.type===t.startNodeType&&o.push(e.id)})),e.edges.forEach((function(t){var e=n.get(t.sourceNodeId);null==e||e.nextNodes.push(t.targetNodeId)}));var r=[];return o.forEach((function(e){var o=n.get(e);o&&(r=r.concat(t.findPathElements(o,n,[])))})),this.getNewPathes(r)},t.prototype.findPathElements=function(t,e,n){void 0===n&&(n=[]);var o=x([],_(n),!1);if(o.push(t.id),0===t.nextNodes.length)return[o];for(var r=[],i=0;i<t.nextNodes.length;i++){var a=e.get(t.nextNodes[i]),s=void 0;if(a){var l=o.indexOf(a.id);s=-1!==l?[x(x([],_(o.slice(l)),!1),[a.id],!1)]:this.findPathElements(a,e,x([],_(o),!1)),r=r.concat(s)}}return r},t.prototype.getNewPathes=function(t){var e=this,n=[],o=new Set;t.forEach((function(t){var r=e.getNewId("path"),i=e.getNewId("路径"),a=e.isLoopPath(t),s=t.join(",");o.has(s)||(o.add(s),n.push({routeId:r,name:i,elements:t,type:a,weight:0,similarElement:""}))}));var r=JSON.parse(JSON.stringify(this.paths));return n.forEach((function(t){for(var n=0;n<r.length;n++){var o=r[n],i=e.similar2Path(x([],_(t.elements),!1),x([],_(o.elements),!1));i>t.weight&&o.weight<=i&&(t.weight=i,t.similarElement=o,i===o.weight&&o.similarElement?(o.similarElement.similarElement=null,o.similarElement.weight=0,o.similarElement=null,o.weight=0):(o.similarElement=t,o.weight=i))}})),n.forEach((function(t){t.similarElement&&t.similarElement.similarElement===t&&(t.routeId=t.similarElement.routeId,t.name=t.similarElement.name),delete t.similarElement,delete t.weight})),this.setPathes(n),n},t.prototype.similar2Path=function(t,e){var n=0,o=t.length+e.length;t.sort(),e.sort();for(var r=t.shift(),i=e.shift();void 0!==r&&void 0!==i;)r===i?(n++,r=t.shift(),i=e.shift()):r<i?r=t.shift():r>i&&(i=e.shift());return n/o*200},t.prototype.getNewId=function(t){return"".concat(t,"_").concat(_C())},t.prototype.isLoopPath=function(t){var e=t.length;return t.indexOf(t[e-1])!==e-1?1:0},t.pluginName="flowPath",t}(),YT=-1,VT=0,KT=1,qT=function(){function t(t){var e=t.lf,n=this;this.levelHeight=[],this.newNodeMap=new Map,this.lf=e,this.trunk=[],e.layout=function(t){var e=n.lf.getGraphRawData();n.lf.setStartNodeType(t);var o=n.lf.getPathes();return n.levelHeight=[],n.newNodeMap=new Map,n.layout(e,o)}}return t.prototype.layout=function(t,e){var n=this,o=[];e.forEach((function(t){var e=t.elements;e.length>o.length?o=e:e.length===o.length&&JSON.stringify(e)===JSON.stringify(n.trunk)&&(o=n.trunk)})),this.trunk=o;for(var r=this.formatData(t),i={nodes:[],edges:[]},a=o.length-1;a>=0;a--)this.setNodePosition(o[a],r,i,a,1);this.lf.graphModel.graphDataToModel(i)},t.prototype.setNodePosition=function(t,e,n,o,r){var i=this,a=e[t],s=a.text,l=a.type,u=a.next,c=a.properties,d=160*o+40,p=120*r,h={id:t,x:d,text:s,y:p,type:l,properties:c};return s&&"object"==typeof s&&(h.text=f(f({},s),{x:d+s.x,y:p+s.y})),this.newNodeMap.set(h.id,{x:h.x,y:h.y,type:l}),n.nodes.push(h),a.isFixed=!0,this.addLevelHeight(o,1),u&&u.length>0&&u.forEach((function(r){if(!e[r.nodeId].isFixed){var a=i.getLevelHeight(o+1);i.addLevelHeight(o,1),i.setNodePosition(r.nodeId,e,n,o+1,a+1)}n.edges.push(f({id:r.edgeId,type:r.edgeType,sourceNodeId:t,targetNodeId:r.nodeId,properties:r.properties,text:r.text},i.getEdgeDataPoints(t,r.nodeId)))})),h},t.prototype.getEdgeDataPoints=function(t,e){var n=this.newNodeMap.get(t),o=this.newNodeMap.get(e),r=this.getShape(t),i=r.width,a=r.height,s=this.getShape(e),l=s.width,u=s.height,c=this.getRelativePosition(n,o),d={x:n.x,y:n.y},p={x:o.x,y:o.y};switch(c){case VT:d.x=n.x+i/2,p.x=o.x-l/2;break;case YT:d.y=n.y+a/2,p.x=o.x-l/2;break;case KT:d.x=n.x+i/2,p.y=o.y+u/2}return{startPoint:d,endPoint:p}},t.prototype.getRelativePosition=function(t,e){var n=t.y,o=e.y;return n<o?-1:n===o?0:1},t.prototype.getShape=function(t){var e,n,o=this.lf.getNodeModelById(t);return{height:null!==(e=null==o?void 0:o.height)&&void 0!==e?e:0,width:null!==(n=null==o?void 0:o.width)&&void 0!==n?n:0}},t.prototype.formatData=function(t){var e=t.nodes.reduce((function(t,e){var n=e.type,o=e.properties,r=e.text,i=e.x,a=e.y;return r&&"object"==typeof r&&(r.x=r.x-i,r.y=r.y-a),t[e.id]={type:n,properties:o,text:r,prev:[],next:[]},t}),{});return t.edges.forEach((function(t){var n=t.sourceNodeId,o=t.targetNodeId,r=t.id,i=t.properties,a=t.text,s=a;"object"==typeof a&&(s=a.value),e[n].next.push({edgeId:r,nodeId:o,edgeType:t.type,properties:i,text:s}),e[o].prev.push({edgeId:r,nodeId:n,properties:i,text:s})})),e},t.prototype.addLevelHeight=function(t,e,n){void 0===e&&(e=1),void 0===n&&(n=!1);var o=this.levelHeight[t];o||(o={positiveHeight:0,negativeHeight:0},this.levelHeight[t]=o),n?o.negativeHeight-=e:o.positiveHeight+=e},t.prototype.getLevelHeight=function(t,e){void 0===e&&(e=!1);var n=this.levelHeight[t];return n?e?n.negativeHeight:n.positiveHeight:0},t.pluginName="AutoLayout",t}(),ZT=function(){function t(t){var e=t.lf,n=this;this.controlItems=[{key:"zoom-out",iconClass:"lf-control-zoomOut",title:"缩小流程图",text:"缩小",onClick:function(){n.lf.zoom(!1)}},{key:"zoom-in",iconClass:"lf-control-zoomIn",title:"放大流程图",text:"放大",onClick:function(){n.lf.zoom(!0)}},{key:"reset",iconClass:"lf-control-fit",title:"恢复流程原有尺寸",text:"适应",onClick:function(){n.lf.resetZoom()}},{key:"undo",iconClass:"lf-control-undo",title:"回到上一步",text:"上一步",onClick:function(){n.lf.undo()}},{key:"redo",iconClass:"lf-control-redo",title:"移到下一步",text:"下一步",onClick:function(){n.lf.redo()}}],this.lf=e}return t.prototype.render=function(t,e){this.destroy();var n=this.getControlTool();this.toolEl=n,e.appendChild(n),this.domContainer=e},t.prototype.destroy=function(){this.domContainer&&this.toolEl&&this.domContainer.contains(this.toolEl)&&this.domContainer.removeChild(this.toolEl)},t.prototype.addItem=function(t){this.controlItems.push(t)},t.prototype.removeItem=function(t){var e=this.controlItems.findIndex((function(e){return e.key===t}));return-1==e?null:this.controlItems.splice(e,1)[0]},t.prototype.getControlTool=function(){var t=this,e="lf-control-item",n="lf-control-item disabled",o=document.createElement("div"),r=[];return o.className="lf-control",this.controlItems.forEach((function(o){var i=document.createElement("div"),a=document.createElement("i"),s=document.createElement("span");switch(i.className=n,o.onClick&&(i.onclick=o.onClick.bind(null,t.lf)),o.onMouseEnter&&(i.onmouseenter=o.onMouseEnter.bind(null,t.lf)),o.onMouseLeave&&(i.onmouseleave=o.onMouseLeave.bind(null,t.lf)),a.className=o.iconClass,s.className="lf-control-text",s.title=o.title,s.innerText=o.text,i.append(a,s),o.text){case"上一步":t.lf.on("history:change",(function(t){var o=t.data.undoAble;i.className=o?e:n}));break;case"下一步":t.lf.on("history:change",(function(t){var o=t.data.redoAble;i.className=o?e:n}));break;default:i.className=e}r.push(i)})),o.append.apply(o,x([],_(r),!1)),o},t.pluginName="control",t}(),$T="lf:defaultNodeMenu",JT="lf:defaultEdgeMenu",QT="lf:defaultGraphMenu",tN="lf:defaultSelectionMenu",eN=function(){function t(t){var e=t.lf,n=this;this.__currentData=null,this.lf=e,e.options.isSilentMode||(this.__menuDOM=document.createElement("ul"),this.menuTypeMap=new Map,this.init(),this.lf.setMenuConfig=function(t){n.setMenuConfig(t)},this.lf.addMenuConfig=function(t){n.addMenuConfig(t)},this.lf.setMenuByType=function(t){n.setMenuByType(t)})}return t.prototype.init=function(){var t,e,n,o,r=this,i=[{text:"删除",callback:function(t){r.lf.deleteNode(t.id)}},{text:"编辑文本",callback:function(t){r.lf.graphModel.editText(t.id)}},{text:"复制",callback:function(t){r.lf.cloneNode(t.id)}}];null===(t=this.menuTypeMap)||void 0===t||t.set($T,i);var a=[{text:"删除",callback:function(t){r.lf.deleteEdge(t.id)}},{text:"编辑文本",callback:function(t){r.lf.graphModel.editText(t.id)}}];null===(e=this.menuTypeMap)||void 0===e||e.set(JT,a),null===(n=this.menuTypeMap)||void 0===n||n.set(QT,[]);var s=[{text:"删除",callback:function(t){r.lf.clearSelectElements(),t.edges.forEach((function(t){return r.lf.deleteEdge(t.id)})),t.nodes.forEach((function(t){return r.lf.deleteNode(t.id)}))}}];null===(o=this.menuTypeMap)||void 0===o||o.set(tN,s)},t.prototype.render=function(t,e){var n=this;t.options.isSilentMode||(this.__container=e,this.__currentData=null,this.__menuDOM&&(this.__menuDOM.className="lf-menu",e.appendChild(this.__menuDOM),this.__menuDOM.addEventListener("click",(function(t){t.stopPropagation();for(var e=t.target;-1===Array.from(e.classList).indexOf("lf-menu-item")&&-1===Array.from(e.classList).indexOf("lf-menu");)e=null==e?void 0:e.parentElement;Array.from(e.classList).indexOf("lf-menu-item")>-1?(e.onclickCallback(n.__currentData),n.__menuDOM&&(n.__menuDOM.style.display="none"),n.__currentData=null):console.warn("点击区域不在菜单项内,请检查代码!")}),!0)),this.lf.on("node:contextmenu",(function(t){var e,o,r=t.data,i=t.position,a=t.e,s=i.domOverlayPosition,l=s.x,u=s.y,c=r.id,d=n.lf.graphModel.getNodeModelById(c);if(d){var p=[],h=null===(e=n.menuTypeMap)||void 0===e?void 0:e.get(d.type);p=d&&d.menu&&Array.isArray(d.menu)?d.menu:h||(null===(o=n.menuTypeMap)||void 0===o?void 0:o.get($T)),n.__currentData=r,n.showMenu(l,u,p,{width:d.width,height:d.height,clientX:a.clientX,clientY:a.clientY})}})),this.lf.on("edge:contextmenu",(function(t){var e,o,r,i=t.data,a=t.position,s=t.e,l=a.domOverlayPosition,u=l.x,c=l.y,d=i.id,p=n.lf.graphModel.getEdgeModelById(d);if(p){var h=[],f=null===(e=n.menuTypeMap)||void 0===e?void 0:e.get(p.type);h=p&&p.menu&&Array.isArray(p.menu)?p.menu:f||(null!==(r=null===(o=n.menuTypeMap)||void 0===o?void 0:o.get(JT))&&void 0!==r?r:[]),n.__currentData=i,n.showMenu(u,c,h,{width:p.width,height:p.height,clientX:s.clientX,clientY:s.clientY})}})),this.lf.on("blank:contextmenu",(function(t){var e,o,r=t.position,i=null!==(o=null===(e=n.menuTypeMap)||void 0===e?void 0:e.get(QT))&&void 0!==o?o:[],a=r.domOverlayPosition,s=a.x,l=a.y;n.showMenu(s,l,i)})),this.lf.on("selection:contextmenu",(function(t){var e,o=t.data,r=t.position,i=null===(e=n.menuTypeMap)||void 0===e?void 0:e.get(tN),a=r.domOverlayPosition,s=a.x,l=a.y;n.__currentData=o,n.showMenu(s,l,i)})),this.lf.on("node:mousedown",(function(){n.__menuDOM.style.display="none"})),this.lf.on("edge:click",(function(){n.__menuDOM.style.display="none"})),this.lf.on("blank:click",(function(){n.__menuDOM.style.display="none"})))},t.prototype.destroy=function(){var t;this.__menuDOM&&(null===(t=null==this?void 0:this.__container)||void 0===t||t.removeChild(this.__menuDOM),this.__menuDOM=void 0)},t.prototype.showMenu=function(t,e,n,o){if(n&&n.length){var r=this.__menuDOM;if(r){if(r.innerHTML="",r.append.apply(r,x([],_(this.__getMenuDom(n)),!1)),!r.children.length)return;if(r.style.display="block",!o)return r.style.top="".concat(e,"px"),void(r.style.left="".concat(t,"px"));var i=o.width,a=o.height,s=o.clientX,l=o.clientY,u=this.lf.graphModel,c=r.offsetWidth,d=!0,p=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,h=p-s,f=u.rootEl.getBoundingClientRect(),g=f.left+f.width;g<p&&(h=g-s),h<c&&(d=!1),r.style.left="".concat(d?t:t-i,"px");var v=r.offsetHeight,y=!0,m=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,b=m-l,E=f.top+f.height;E<m&&(b=E-l),b<v&&(y=!1),r.style.top="".concat(y?e:e-a,"px")}}},t.prototype.setMenuByType=function(t){var e;t.type&&t.menu&&(null===(e=this.menuTypeMap)||void 0===e||e.set(t.type,t.menu))},t.prototype.__getMenuDom=function(t){var e=[];return t&&t.length>0&&t.forEach((function(t){var n=document.createElement("li");if(t.className?n.className="lf-menu-item ".concat(t.className):n.className="lf-menu-item",!0===t.icon){var o=document.createElement("span");o.className="lf-menu-item-icon",n.appendChild(o)}var r=document.createElement("span");r.className="lf-menu-item-text",t.text&&(r.innerText=t.text),n.appendChild(r),n.onclickCallback=t.callback,e.push(n)})),e},t.prototype.setMenuConfig=function(t){var e,n,o;t&&(void 0!==t.nodeMenu&&(null===(e=this.menuTypeMap)||void 0===e||e.set($T,t.nodeMenu?t.nodeMenu:[])),void 0!==t.edgeMenu&&(null===(n=this.menuTypeMap)||void 0===n||n.set(JT,t.edgeMenu?t.edgeMenu:[])),void 0!==t.graphMenu&&(null===(o=this.menuTypeMap)||void 0===o||o.set(QT,t.graphMenu?t.graphMenu:[])))},t.prototype.addMenuConfig=function(t){var e,n,o,r,i,a,s,l,u;if(t){if(Array.isArray(t.nodeMenu)){var c=null!==(n=null===(e=this.menuTypeMap)||void 0===e?void 0:e.get($T))&&void 0!==n?n:[];null===(o=this.menuTypeMap)||void 0===o||o.set($T,c.concat(t.nodeMenu))}if(Array.isArray(t.edgeMenu)){c=null!==(i=null===(r=this.menuTypeMap)||void 0===r?void 0:r.get(JT))&&void 0!==i?i:[];null===(a=this.menuTypeMap)||void 0===a||a.set(JT,c.concat(t.edgeMenu))}if(Array.isArray(t.graphMenu)){c=null!==(l=null===(s=this.menuTypeMap)||void 0===s?void 0:s.get(QT))&&void 0!==l?l:[];null===(u=this.menuTypeMap)||void 0===u||u.set(QT,c.concat(t.graphMenu))}}},t.prototype.changeMenuItem=function(t,e){if("add"===t)this.addMenuConfig(e);else{if("reset"!==t)throw new Error("The first parameter of changeMenuConfig should be 'add' or 'reset'");this.setMenuConfig(e)}},t.pluginName="menu",t}(),nN="menu-common",oN=function(){function t(t){var e=t.lf,n=this;this.menuTypeMap=new Map,this.listenDelete=function(){n.hideContextMenu()},this.lf=e,this.__menuDOM=document.createElement("div"),this.__menuDOM.className="lf-inner-context",this.menuTypeMap.set(nN,[]),this.lf.setContextMenuByType=function(t,e){n.setContextMenuByType(t,e)},this.lf.setContextMenuItems=function(t){n.setContextMenuItems(t)},this.lf.showContextMenu=function(t){n.showContextMenu(t)},this.lf.hideContextMenu=function(){n.hideContextMenu()}}return t.prototype.render=function(t,e){var n=this;this.container=e,t.on("node:click",(function(t){var e=t.data;n._activeData=e,n.createContextMenu()})),t.on("edge:click",(function(t){var e=t.data;n._activeData=e,n.createContextMenu()})),t.on("blank:click",(function(){n.hideContextMenu()}))},t.prototype.setContextMenuByType=function(t,e){this.menuTypeMap.set(t,e)},t.prototype.hideContextMenu=function(){this.__menuDOM.innerHTML="",this.__menuDOM.style.display="none",this.isShow&&this.container.removeChild(this.__menuDOM),this.lf.off("node:delete,edge:delete,node:drag,graph:transform",this.listenDelete),this.isShow=!1},t.prototype.showContextMenu=function(t){t&&t.id?(this._activeData=t,this.createContextMenu()):console.warn("请检查传入的参数")},t.prototype.setContextMenuItems=function(t){this.menuTypeMap.set(nN,t)},t.prototype.getContextMenuPosition=function(){var t=this._activeData,e=this.lf.graphModel.getElement(t.id);if(e){var n,o;if("edge"===e.BaseType){n=Number.MIN_SAFE_INTEGER,o=Number.MAX_SAFE_INTEGER;var r=e.getData();n=Math.max(r.startPoint.x,n),o=Math.min(r.startPoint.y,o),n=Math.max(r.endPoint.x,n),o=Math.min(r.endPoint.y,o),r.pointsList&&r.pointsList.forEach((function(t){n=Math.max(t.x,n),o=Math.min(t.y,o)}))}return"node"===e.BaseType&&(n=t.x+e.width/2,o=t.y-e.height/2),this.lf.graphModel.transformModel.CanvasPointToHtmlPoint([n,o])}},t.prototype.createContextMenu=function(){var t=this;if(!this.lf.options.isSilentMode){var e=x(x([],_(this.menuTypeMap.get(this._activeData.type)||[]),!1),_(this.menuTypeMap.get(nN)||[]),!1),n=document.createDocumentFragment();e.forEach((function(e){var o=document.createElement("div");o.className="lf-context-item";var r=document.createElement("img");r.src=e.icon,r.className="lf-context-img",e.className&&(o.className="".concat(o.className," ").concat(e.className)),r.addEventListener("click",(function(){t.hideContextMenu(),e.callback?e.callback(t._activeData):t.addNode({sourceId:t._activeData.id,x:t._activeData.x,y:t._activeData.y,properties:e.properties,type:e.type})})),o.appendChild(r),n.appendChild(o)})),this.__menuDOM.innerHTML="",this.__menuDOM.appendChild(n),this.showMenu()}},t.prototype.addNode=function(t,e){var n=void 0!==e;void 0===e&&(e=t.y);var o=this.lf.getNodeModelById(t.sourceId);if(o){var r=t.x-o.width+200,i=e-t.y/2-20,a=t.x+o.width+200,s=e+t.y/2+20;if(this.lf.getAreaElement([r,i],[a,s]).length)return e+=100,void this.addNode(t,e);if(t.type){var l=this.lf.addNode({type:t.type,x:t.x+200,y:e,properties:t.properties}),u=void 0,c=void 0;n&&(u={x:t.x,y:t.y+o.height/2},c={x:l.x-l.width/2,y:l.y}),this.lf.addEdge({sourceNodeId:t.sourceId,targetNodeId:l.id,startPoint:u,endPoint:c})}}},t.prototype.showMenu=function(){var t=this.getContextMenuPosition();if(t){var e=_(t,2),n=e[0],o=e[1];this.__menuDOM.style.display="flex",this.__menuDOM.style.top="".concat(o,"px"),this.__menuDOM.style.left="".concat(n+10,"px"),this.container.appendChild(this.__menuDOM),!this.isShow&&this.lf.on("node:delete,edge:delete,node:drag,graph:transform",this.listenDelete),this.isShow=!0}},t.pluginName="contextMenu",t}(),rN=function(){function t(t){var e=t.lf,n=this;this.lf=e,this.lf.setPatternItems=function(t){n.setPatternItems(t)}}return t.prototype.render=function(t,e){var n=this;this.destroy(),this.shapeList&&0!==this.shapeList.length?(this.panelEl=document.createElement("div"),this.panelEl.className="lf-dndpanel",this.shapeList.forEach((function(t){var e;null===(e=n.panelEl)||void 0===e||e.appendChild(n.createDndItem(t))})),e.appendChild(this.panelEl),this.domContainer=e):this.domContainer=e},t.prototype.destroy=function(){this.domContainer&&this.panelEl&&this.domContainer.contains(this.panelEl)&&this.domContainer.removeChild(this.panelEl)},t.prototype.setPatternItems=function(t){this.shapeList=t,this.domContainer&&this.render(this.lf,this.domContainer)},t.prototype.createDndItem=function(t){var e=this,n=document.createElement("div");n.className=t.className?"lf-dnd-item ".concat(t.className):"lf-dnd-item";var o=document.createElement("div");if(o.className="lf-dnd-shape",t.icon&&(o.style.backgroundImage="url(".concat(t.icon,")")),n.appendChild(o),t.label){var r=document.createElement("div");r.innerText=t.label,r.className="lf-dnd-text",n.appendChild(r)}return t.disabled?(n.classList.add("disabled"),n.onmousedown=function(){t.callback&&t.callback(e.lf,e.domContainer)},n):(n.onmousedown=function(){t.type&&e.lf.dnd.startDrag({type:t.type,properties:t.properties,text:t.text}),t.callback&&t.callback(e.lf,e.domContainer)},n.ondblclick=function(n){e.lf.graphModel.eventCenter.emit("dnd:panel-dbclick",{e:n,data:t})},n.onclick=function(n){e.lf.graphModel.eventCenter.emit("dnd:panel-click",{e:n,data:t})},n.oncontextmenu=function(n){e.lf.graphModel.eventCenter.emit("dnd:panel-contextmenu",{e:n,data:t})},n)},t.pluginName="dndPanel",t}(),iN=function(){function t(t){var e=t.lf,n=t.LogicFlow,o=t.options,r=this;this.width=200,this.height=150,this.scale=1,this.translateX=0,this.translateY=0,this.showEdge=!1,this.viewPortTop=0,this.viewPortLeft=0,this.viewPortWidth=150,this.viewPortHeight=75,this.isShow=!1,this.isShowHeader=!1,this.isShowCloseIcon=!1,this.headerTitle="导航",this.disabledPlugins=["miniMap","control","selectionSelect"],this.render=function(t,e){r.container=e,r.lf.on("history:change",(function(){r.isShow&&r.setView()})),r.lf.on("graph:transform",(function(){r.isShow&&r.setView(!1)}))},this.show=function(t,e){r.isShow||(r.createMiniMap(t,e),r.setView()),r.isShow=!0},this.hide=function(){r.isShow&&(r.removeMiniMap(),r.lf.emit("miniMap:close",{})),r.isShow=!1},this.updatePosition=function(t){if("object"==typeof t)void 0===t.left&&void 0===t.right||(r.leftPosition=t.left,r.rightPosition=t.right),void 0===t.top&&void 0===t.bottom||(r.topPosition=t.top,r.bottomPosition=t.bottom);else switch(t){case"left-top":r.leftPosition=0,r.rightPosition=void 0,r.topPosition=0,r.bottomPosition=void 0;break;case"right-top":r.leftPosition=void 0,r.rightPosition=0,r.topPosition=0,r.bottomPosition=void 0;break;case"left-bottom":r.leftPosition=0,r.rightPosition=void 0,r.topPosition=void 0,r.bottomPosition=0;break;case"right-bottom":r.leftPosition=void 0,r.rightPosition=0,r.topPosition=void 0,r.bottomPosition=0}r.updateMiniMapPosition()},this.reset=function(){r.lf.resetTranslate(),r.lf.resetZoom()},this.setShowEdge=function(t){r.showEdge!==t&&(r.showEdge=t,r.setView())},this.startDrag=function(t){document.addEventListener("mousemove",r.drag),document.addEventListener("mouseup",r.drop);var e=t.x,n=t.y;r.startPosition={x:e,y:n}},this.drag=function(t){var e=t.x,n=t.y,o=(e-r.startPosition.x)/r.scale,i=(n-r.startPosition.y)/r.scale,a=r.viewPortLeft+o+r.viewPortWidth/r.scale/2,s=r.viewPortTop+i+r.viewPortHeight/r.scale/2;r.startPosition={x:e,y:n},r.lf.focusOn({coordinate:{x:a,y:s}})},this.drop=function(){document.removeEventListener("mousemove",r.drag),document.removeEventListener("mouseup",r.drop)},this.mapClick=function(t){var e=t.offsetX,n=t.offsetY,o=r.translateX+e/r.scale,i=r.translateY+n/r.scale;r.lf.focusOn({coordinate:{x:o,y:i}})},this.lf=e,this.LFCtor=n,o&&this.setOption(o),this.viewPortWidth=e.graphModel.width,this.viewPortHeight=e.graphModel.height;var i={left:0,right:this.viewPortWidth,top:0,bottom:this.viewPortHeight};this.bounds=i,this.elementAreaBounds=i,this.viewPortBounds=i,this.initMiniMap()}return t.prototype.setOption=function(t){var e=t.width,n=void 0===e?150:e,o=t.height,r=void 0===o?220:o,i=t.showEdge,a=void 0!==i&&i,s=t.isShowHeader,l=void 0!==s&&s,u=t.isShowCloseIcon,c=void 0!==u&&u,d=t.leftPosition,p=t.topPosition,h=t.rightPosition,f=void 0===h?0:h,g=t.bottomPosition,v=void 0===g?0:g,y=t.headerTitle,m=void 0===y?"导航":y;this.width=n,this.height=r,this.showEdge=a,this.isShowHeader=l,this.isShowCloseIcon=c,this.leftPosition=d,this.rightPosition=void 0!==d?void 0:f,this.topPosition=p,this.bottomPosition=void 0!==p?void 0:v,this.headerTitle=m},t.prototype.initMiniMap=function(){var t=document.createElement("div");t.className="lf-mini-map-graph",t.style.width="".concat(this.width,"px"),t.style.height="".concat(this.height,"px"),this.lfMap=new this.LFCtor({container:t,grid:!1,isSilentMode:!0,stopZoomGraph:!0,stopScrollGraph:!0,stopMoveGraph:!1,history:!1,snapline:!1,disabledPlugins:this.disabledPlugins}),this.miniMapWrap=t,this.createViewPort(),t.addEventListener("click",this.mapClick)},t.prototype.createMiniMap=function(t,e){var n,o=document.createElement("div");this.miniMapContainer=o,o.appendChild(this.miniMapWrap),o.style.position="absolute",void 0===t&&void 0===e||(this.leftPosition=t||0,this.topPosition=e||0,this.rightPosition=void 0,this.bottomPosition=void 0),this.updateMiniMapPosition(),o.className="lf-mini-map",this.isShowCloseIcon||o.classList.add("lf-mini-map-no-close-icon"),this.isShowHeader||o.classList.add("lf-mini-map-no-header"),null===(n=this.container)||void 0===n||n.appendChild(o),this.miniMapWrap.appendChild(this.viewport);var r=document.createElement("div");r.className="lf-mini-map-header",r.innerText=this.headerTitle,o.appendChild(r);var i=document.createElement("span");i.className="lf-mini-map-close",i.addEventListener("click",this.hide),o.appendChild(i)},t.prototype.updateMiniMapPosition=function(){if(this.miniMapContainer){var t=this.miniMapContainer.style;void 0!==this.rightPosition?(t.right="".concat(this.rightPosition,"px"),t.left=""):(t.left="".concat(this.leftPosition,"px"),t.right=""),void 0!==this.bottomPosition?(t.bottom="".concat(this.bottomPosition,"px"),t.top=""):(t.top="".concat(this.topPosition,"px"),t.bottom="")}},t.prototype.removeMiniMap=function(){var t;this.miniMapContainer&&(null===(t=this.container)||void 0===t||t.removeChild(this.miniMapContainer))},t.prototype.updateBounds=function(t){t&&this.updateElementAreaBounds(t),this.updateViewPortBounds(),this.bounds={left:Math.min(this.elementAreaBounds.left,this.viewPortBounds.left),right:Math.max(this.elementAreaBounds.right,this.viewPortBounds.right),top:Math.min(this.elementAreaBounds.top,this.viewPortBounds.top),bottom:Math.max(this.elementAreaBounds.bottom,this.viewPortBounds.bottom)}},t.prototype.updateElementAreaBounds=function(t){var e={left:0,right:0,top:0,bottom:0},n=t.nodes;n&&n.length>0&&n.forEach((function(t){var n,o,r=t.x,i=t.y,a=null!==(n=t.width)&&void 0!==n?n:200,s=null!==(o=t.height)&&void 0!==o?o:200,l=r-a/2,u=r+a/2,c=i-s/2,d=i+s/2;e.left=Math.min(l,e.left),e.right=Math.max(u,e.right),e.top=Math.min(c,e.top),e.bottom=Math.max(d,e.bottom)})),this.elementAreaBounds=e},t.prototype.updateViewPortBounds=function(){var t=this.lf.getTransform(),e=t.TRANSLATE_X,n=t.TRANSLATE_Y,o=t.SCALE_X,r=t.SCALE_Y,i=this.lf.graphModel,a=i.width,s=i.height;this.viewPortBounds={left:-e/o,right:(-e+a)/o,top:-n/r,bottom:(-n+s)/r}},t.prototype.resetData=function(t){var e=t.nodes,n=t.edges;return e.forEach((function(t){t.text=void 0})),this.showEdge&&n.forEach((function(t){t.text=void 0})),{nodes:e,edges:this.showEdge?n:[]}},t.prototype.setView=function(t){var e,n;if(void 0===t&&(t=!0),t){var o=this.lf.getGraphRawData(),r=this.resetData(o),i=this.lf.viewMap,a=this.lf.graphModel.modelMap,s=this.lfMap.viewMap;try{for(var l=b(i.keys()),u=l.next();!u.done;u=l.next()){var c=u.value;s.has(c)||this.lfMap.register({type:c,view:i.get(c),model:a.get(c)})}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=l.return)&&n.call(l)}finally{if(e)throw e.error}}this.lfMap.render(r),this.updateBounds(r)}else this.updateBounds();var d=this.bounds,p=d.left,h=d.top,f=d.right-p,g=d.bottom-h,v=this.width/f,y=this.height/g,m=Math.min(v,y);this.scale=m;var _=p-(this.width/m-f)/2,x=h-(this.height/m-g)/2;if(this.lfMap.graphModel.transformModel.translate(-_+this.translateX,-x+this.translateY),this.translateX=_,this.translateY=x,this.miniMapWrap.firstChild){var E=this.miniMapWrap.firstChild.style;E.pointerEvents="none",E.transform="matrix(".concat(m,", 0, 0, ").concat(m,", 0, 0)"),E.transformOrigin="left top",E.height="".concat(this.height/m,"px"),E.width="".concat(this.width/m,"px"),this.updateViewPort()}},t.prototype.updateViewPort=function(){var t=this.viewport.style,e=this.lf.getTransform(),n=e.TRANSLATE_X,o=e.TRANSLATE_Y,r=e.SCALE_X,i=e.SCALE_Y,a=this.lf.graphModel,s=a.width,l=a.height;this.viewPortLeft=-n/r,this.viewPortTop=-o/i,this.viewPortWidth=s/r*this.scale,this.viewPortHeight=l/i*this.scale,t.width="".concat(this.viewPortWidth,"px"),t.height="".concat(this.viewPortHeight,"px"),t.left="".concat((this.viewPortLeft-this.translateX)*this.scale,"px"),t.top="".concat((this.viewPortTop-this.translateY)*this.scale,"px")},t.prototype.createViewPort=function(){var t=document.createElement("div");t.className="lf-minimap-viewport",t.addEventListener("mousedown",this.startDrag),t.addEventListener("click",(function(t){t.stopPropagation()})),this.viewport=t},t.pluginName="miniMap",t}(),aN=function(){function t(t){var e=t.lf,n=this;this.disabled=!0,this.isDefaultStopMoveGraph=!1,this.isWholeNode=!0,this.isWholeEdge=!0,this.draw=function(t){var e=n.lf.getPointByClient(t.clientX,t.clientY).domOverlayPosition,o=e.x,r=e.y;if(n.endPoint={x:o,y:r},n.startPoint){var i=n.startPoint,a=i.x,s=i.y,l=a,u=s,c=o-a,d=r-s;o<a&&(l=o,c=a-o),r<s&&(u=r,d=s-r),n.wrapper&&(n.wrapper.style.left="".concat(l,"px"),n.wrapper.style.top="".concat(u,"px"),n.wrapper.style.width="".concat(c,"px"),n.wrapper.style.height="".concat(d,"px"))}},this.drawOff=function(){var t;if(document.removeEventListener("mousemove",n.draw),document.removeEventListener("mouseup",n.drawOff),n.wrapper&&(n.wrapper.oncontextmenu=null,null===(t=n.container)||void 0===t||t.removeChild(n.wrapper)),n.startPoint&&n.endPoint){var e=n.startPoint,o=e.x,r=e.y,i=n.endPoint,a=i.x,s=i.y,l=[Math.min(o,a),Math.min(r,s)],u=[Math.max(o,a),Math.max(r,s)];if(n.lf.emit("selection:selected-area",{topLeft:l,bottomRight:u}),Math.abs(a-o)<10&&Math.abs(s-r)<10)return;var c=n.lf.graphModel.getAreaElement(l,u,n.isWholeEdge,n.isWholeNode,!0),d=n.lf.graphModel.group;c.forEach((function(t){d&&d.getNodeGroup(t.id)||n.lf.selectElementById(t.id,!0)})),n.lf.emit("selection:selected",c)}},this.lf=e;var o=e.getEditConfig().stopMoveGraph;this.isDefaultStopMoveGraph=o,e.openSelectionSelect=function(){n.openSelectionSelect()},e.closeSelectionSelect=function(){n.closeSelectionSelect()}}return t.prototype.render=function(t,e){var n=this;this.container=e,t.on("blank:mousedown",(function(o){var r=o.e;if(t.getEditConfig().stopMoveGraph&&!n.disabled&&!(2===r.button)){var i=t.getPointByClient(r.clientX,r.clientY).domOverlayPosition,a=i.x,s=i.y;n.startPoint={x:a,y:s},n.endPoint={x:a,y:s};var l=document.createElement("div");l.className="lf-selection-select",l.oncontextmenu=function(t){t.preventDefault()},l.style.top="".concat(n.startPoint.y,"px"),l.style.left="".concat(n.startPoint.x,"px"),e.appendChild(l),n.wrapper=l,document.addEventListener("mousemove",n.draw),document.addEventListener("mouseup",n.drawOff)}}))},t.prototype.setSelectionSense=function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!0),this.isWholeEdge=t,this.isWholeNode=e},t.prototype.openSelectionSelect=function(){this.lf.getEditConfig().stopMoveGraph||(this.isDefaultStopMoveGraph=!1,this.lf.updateEditConfig({stopMoveGraph:!0})),this.open()},t.prototype.closeSelectionSelect=function(){this.isDefaultStopMoveGraph||this.lf.updateEditConfig({stopMoveGraph:!1}),this.close()},t.prototype.open=function(){this.disabled=!1},t.prototype.close=function(){this.disabled=!0},t.pluginName="selectionSelect",t}(),sN=function(t,e){var n=[],o=[],r=function(t,o,i){i&&o.unshift.apply(o,x([],_(e.getEdgeModels({sourceNodeId:t.id,targetNodeId:null==i?void 0:i.id}).map((function(t){return t.id}))),!1)),o.includes(t.id)?n.push(o):(o.unshift(t.id),t.incoming.nodes.length?t.incoming.nodes.forEach((function(e){r(e,o.slice(),t)})):n.push(o))},i=function(t,n,r){r&&n.push.apply(n,x([],_(e.getEdgeModels({sourceNodeId:null==r?void 0:r.id,targetNodeId:t.id}).map((function(t){return t.id}))),!1)),n.includes(t.id)?o.push(n):(n.push(t.id),t.outgoing.nodes.length?t.outgoing.nodes.forEach((function(e){i(e,n.slice(),t)})):o.push(n))};return r(t,[]),i(t,[]),x([],_(new Set(x(x([],_(n.flat()),!1),_(o.flat()),!1))),!1)},lN=function(){function t(t){var e=t.lf;this.mode="path",this.manual=!1,this.tempStyles={},this.lf=e}return t.prototype.setMode=function(t){this.mode=t},t.prototype.setManual=function(t){this.manual=t},t.prototype.highlightSingle=function(t){var e=this.lf.getModelById(t);"node"===(null==e?void 0:e.BaseType)?e.updateStyles(this.tempStyles[t]):"edge"===(null==e?void 0:e.BaseType)&&(e.updateStyles(this.tempStyles[t]),e.sourceNode.updateStyles(this.tempStyles[e.sourceNode.id]),e.targetNode.updateStyles(this.tempStyles[e.targetNode.id]))},t.prototype.highlightPath=function(t){var e=this,n=function(t,e){var n=e.getModelById(t);return sN("node"===(null==n?void 0:n.BaseType)?n:null==n?void 0:n.targetNode,e)}(t,this.lf);n.forEach((function(t){var n;null===(n=e.lf.getModelById(t))||void 0===n||n.updateStyles(e.tempStyles[t])}))},t.prototype.highlight=function(t,e){var n=this;(void 0===e&&(e=this.mode),this.manual)||(Object.keys(this.tempStyles).length&&this.restoreHighlight(),Object.values(this.lf.graphModel.modelsMap).forEach((function(t){var e="node"===t.BaseType?t.getNodeStyle():t.getEdgeStyle();n.tempStyles[t.id]=f({},e),t.setStyles({opacity:.1})})),{single:this.highlightSingle.bind(this),path:this.highlightPath.bind(this)}[e](t))},t.prototype.restoreHighlight=function(){var t=this;Object.keys(this.tempStyles).length&&(Object.values(this.lf.graphModel.modelsMap).forEach((function(e){var n,o=null!==(n=t.tempStyles[e.id])&&void 0!==n?n:{};e.updateStyles(f({},o))})),this.tempStyles={})},t.prototype.render=function(){var t=this;this.lf.on("node:mouseenter",(function(e){var n=e.data;return t.highlight(n.id)})),this.lf.on("edge:mouseenter",(function(e){var n=e.data;return t.highlight(n.id)})),this.lf.on("node:mouseleave",this.restoreHighlight.bind(this)),this.lf.on("edge:mouseleave",this.restoreHighlight.bind(this)),this.lf.on("history:change",this.restoreHighlight.bind(this))},t.prototype.destroy=function(){},t.pluginName="highlight",t}(),uN={tr:"tl",lb:"tl",tl:"tr",rb:"tr",br:"bl",lt:"bl",bl:"br",rt:"br"};function cN(t,e,n,o){var r,i="",a="";t[0]===e[0]?i=t[1]>e[1]?"t":"b":t[1]===e[1]&&(i=t[0]>e[0]?"l":"r"),e[0]===n[0]?a=e[1]>n[1]?"t":"b":e[1]===n[1]&&(a=e[0]>n[0]?"l":"r");var s=Math.min(Math.hypot(e[0]-t[0],e[1]-t[1])/2,Math.hypot(n[0]-e[0],n[1]-e[1])/2,o)||.2*o,l="".concat(i).concat(a),u=uN[l]||"-",c="L ".concat(t[0]," ").concat(t[1]);if("-"===u)c+="L ".concat(e[0]," ").concat(e[1]," L ").concat(n[0]," ").concat(n[1]);else{var d=_(function(t,e,n,o){var r=[t[0],t[1]],i=[t[0],t[1]];switch(n){case"tl":return"tr"===e?(r[1]+=o,i[0]+=o):"lb"===e&&(r[0]+=o,i[1]+=o),[r,i];case"tr":return"tl"===e?(r[1]+=o,i[0]-=o):"rb"===e&&(r[0]-=o,i[1]+=o),[r,i];case"bl":return"br"===e?(r[1]-=o,i[0]+=o):"lt"===e&&(r[0]+=o,i[1]-=o),[r,i];case"br":return"bl"===e?(r[1]-=o,i[0]-=o):"rt"===e&&(r[0]-=o,i[1]-=o),[r,i];default:return[]}}(e,l,u,s),2),p=d[0],h=d[1];p&&h&&(c+="L ".concat(p[0]," ").concat(p[1]," Q ").concat(e[0]," ").concat(e[1]," ").concat(h[0]," ").concat(h[1]),r=_(h,2),e[0]=r[0],e[1]=r[1])}return c}function dN(t,e){var n=0,o="";if(2===t.length)o+="M".concat(t[n][0]," ").concat(t[n++][1]," L ").concat(t[n][0]," ").concat(t[n][1]);else{for(o+="M".concat(t[n][0]," ").concat(t[n++][1]);n+1<t.length;){o+=cN(t[n-1],t[n],t[1+n++],e)}o+="L ".concat(t[n][0]," ").concat(t[n][1])}return o}var pN=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return h(e,t),e.prototype.getEdge=function(){var t=this.props.model,e=t.points,n=t.isAnimation,o=t.arrowConfig,r=t.radius,i=void 0===r?5:r,a=t.getEdgeStyle(),s=t.getEdgeAnimationStyle(),l=function(t){for(var e=t,n=1;n<e.length-1;){var o=_(e[n-1],2),r=o[0],i=o[1],a=_(e[n],2),s=a[0],l=a[1],u=_(e[n+1],2),c=u[0],d=u[1];r===s&&s===c||i===l&&l===d?e.splice(n,1):n++}return e}(e.split(" ").map((function(t){return t.split(",").map((function(t){return+t}))}))),u=dN(l,i),c=f(f(f({style:n?s:{}},a),o),{fill:"none"});return uo("path",f({d:u},c))},e}(xS),hN=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return h(e,t),e}(Cx),fN=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return h(e,t),e.prototype.getLabelShape=function(){var t=this.props.model,e=t.id,n=t.x,o=t.y,r=t.width,i=t.height,a=t.properties,s=this.props.model.getNodeStyle();return uo("svg",{x:n-r/2,y:o-i/2,width:50,height:24,style:"z-index: 0; background: none; overflow: auto;"},[a.labelText?uo("text",{x:0,y:-5,fontSize:"16px",fill:s.stroke},a.labelText):"",a.disabledDelete?"":uo("text",{x:a.labelText?50:0,y:-5,fontSize:"24px",cursor:"pointer",fill:s.stroke,onclick:this.handleCustomDeleteIconClick.bind(this,e)},"x")])},e.prototype.getShape=function(){var t=this.props.model,e=t.x,n=t.y,o=t.width,r=t.height,i=t.id,a=this.props.model.getNodeStyle();return uo("g",{},[uo("rect",f(f({},a),{x:e-o/2,y:n-r/2,width:o,height:r,id:i})),this.getLabelShape()])},e.prototype.toFront=function(){},e.prototype.handleCustomDeleteIconClick=function(t){this.props.graphModel.deleteNode(t)},e}(Hw),gN=function(t){function e(){var e=t.apply(this,x([],_(arguments),!1))||this;return e.d=10,e}return h(e,t),e.prototype.initNodeData=function(e){e.text={value:"",x:e.x,y:e.y,draggable:!1,editable:!1},t.prototype.initNodeData.call(this,e),this.zIndex=0,this.draggable=!0},e.prototype.setAttributes=function(){var t,e=this;this.points=[],(null===(t=this.properties)||void 0===t?void 0:t.node_selection_ids).length>1&&setTimeout((function(){var t;e.updatePointsByNodes((null===(t=e.properties)||void 0===t?void 0:t.node_selection_ids)||[])}))},e.prototype.getNodeStyle=function(){var e=t.prototype.getNodeStyle.call(this);return e.stroke=this.properties.strokeColor||"#008000",e.strokeDasharray="10 5",e},e.prototype.getDefaultAnchor=function(){return[]},e.prototype.updatePoints=function(t){this.points=t},e.prototype.updateCoordinate=function(t){var e=t.x,n=t.y;this.x=e,this.y=n},e.prototype.updatePointsByNodes=function(t){var e=this,n=[],o=1/0,r=1/0,i=-1/0,a=-1/0;t.forEach((function(t){var n=e.graphModel.getNodeModelById(t);if(n){var s=n.width,l=n.height,u=n.x,c=n.y;o=Math.min(o,u-s/2-e.d),r=Math.min(r,c-l/2-e.d),i=Math.max(i,u+s/2+e.d),a=Math.max(a,c+l/2+e.d)}})),n.push([o,r],[i,r],[i,a],[o,a]),[o,r,i,a].some((function(t){return Math.abs(t)===1/0}))||(this.updatePoints(n),this.updateCoordinate({x:(i+o)/2,y:(a+r)/2}))},e}(Kx),vN=function(){function t(t){var e=t.lf;this.selectNodes=[],this.d=10,e.register({type:"node-selection",view:fN,model:gN})}return Object.defineProperty(t.prototype,"selectNodesIds",{get:function(){return this.selectNodes.map((function(t){return t.id}))},enumerable:!1,configurable:!0}),t.prototype.addNodeSelection=function(){this.lf.addNode({type:"node-selection",text:"",properties:{node_selection_ids:this.selectNodesIds}}).updatePointsByNodes(this.selectNodesIds)},t.prototype.updateNodeSelection=function(){var t=this.getNodeSelection();t&&(this.lf.setProperties(t.id,{node_selection_ids:this.selectNodesIds}),this.lf.getNodeModelById(t.id).updatePointsByNodes(this.selectNodesIds))},t.prototype.getNodeSelection=function(){var t=this,e=this.selectNodesIds,n=this.lf.getGraphRawData(),o=e.filter((function(e){return e!==t.currentClickNode.id}));return n.nodes.find((function(t){if("node-selection"===t.type){var e=El(t,"properties.node_selection_ids",[]);return o.every((function(t){return e.includes(t)}))}return!1}))},t.prototype.render=function(t){var e=this;this.lf=t,t.on("node:click",(function(n){if(n.e.shiftKey&&"node-selection"!==n.data.type){e.currentClickNode=n.data;var o=!1;e.selectNodesIds.includes(n.data.id)&&(e.lf.getNodeModelById(n.data.id).setSelected(!1),o=!0);var r=t.getSelectElements(!0).nodes;e.selectNodes=r,1===e.selectNodes.length?o?e.updateNodeSelection():e.addNodeSelection():e.selectNodes.length>1&&e.updateNodeSelection()}})),t.graphModel.addNodeMoveRules((function(e,n,o){if("node-selection"===e.type){var r=e.properties.node_selection_ids;return t.graphModel.moveNodes(r,n,o,!0),!0}return!0}))},t.pluginName="node-selection",t}();t.AutoLayout=qT,t.BPMNAdapter=UO,t.BPMNBaseAdapter=XO,t.BPMNElements=rO,t.BoundaryEventFactory=gM,t.BpmnAdapter=iM,t.BpmnElement=HC,t.BpmnXmlAdapter=aM,t.ContextMenu=oN,t.Control=ZT,t.CurvedEdge=pN,t.CurvedEdgeModel=hN,t.DiamondResize=HM,t.DiamondResizeModel=jM,t.DiamondResizeView=BM,t.DndPanel=rN,t.DynamicGroup=tT,t.DynamicGroupNode=qO,t.DynamicGroupNodeModel=ZO,t.EllipseResize=LM,t.EllipseResizeModel=RM,t.EllipseResizeView=IM,t.EndEventFactory=pM,t.EndEventModel=SC,t.EndEventView=CC,t.ExclusiveGatewayModel=AC,t.ExclusiveGatewayView=PC,t.FlowPath=UT,t.GatewayNodeFactory=TM,t.Group=$M,t.GroupNode=KM,t.GroupNodeModel=VM,t.Highlight=lN,t.HtmlResize=WM,t.HtmlResizeModel=zM,t.HtmlResizeView=FM,t.InsertNodeInPolyline=sT,t.IntermediateCatchEventFactory=hM,t.IntermediateThrowEventFactory=vM,t.Label=LT,t.Menu=eN,t.MiniMap=iN,t.NodeResize=YM,t.NodeSelection=vN,t.RectResize=UM,t.RectResizeModel=GM,t.RectResizeView=XM,t.SelectionSelect=aN,t.SequenceFlowModel=OC,t.SequenceFlowView=TC,t.ServiceTaskModel=kC,t.ServiceTaskView=RC,t.Snapshot=XT,t.StartEventFactory=fM,t.StartEventModel=xC,t.StartEventView=EC,t.SubProcessFactory=JM,t.TaskNodeFactory=AM,t.UserTaskModel=LC,t.UserTaskView=jC,t.bpmnUtils=dM,t.convertNormalToXml=jO,t.convertXmlToNormal=BO,t.dynamicGroup=JO,t.gateway={exclusive:0,inclusive:1,parallel:2},t.gatewayComposable=[[1,1,0],[0,0,1],[0,1,1]],t.getCurvedEdgePath=dN,t.handleAttributes=XC,t.icons=OM,t.lfJson2Xml=VC,t.lfXml2Json=ZC,t.multiInstanceIcon=NM,t.sequenceFlowFactory=tO,t.toLogicflowData=function(t){var e={nodes:[],edges:[]},n=t.flowElementList;return n&&n.length>0&&n.forEach((function(t){if(t.type===YO.SEQUENCE_FLOW){var n=function(t){var e=t.incoming,n=t.outgoing,o=t.properties,r=t.key,i=t.type,a=o.text,s=o.name,l=o.startPoint,u=o.endPoint,c=o.pointsList,d={id:r,type:VO[i],sourceNodeId:e[0],targetNodeId:n[0],text:a||s,properties:{}};l&&(d.startPoint=JSON.parse(l)),u&&(d.endPoint=JSON.parse(u)),c&&(d.pointsList=JSON.parse(c));var p=["startPoint","endPoint","pointsList","text"];return Object.keys(t.properties).forEach((function(e){-1===p.indexOf(e)&&(d.properties[e]=t.properties[e])})),d}(t);e.edges.push(n)}else{var o=function(t){var e=t.properties,n=t.key,o=t.type,r=t.bounds,i=e.x,a=e.y,s=e.text;if(void 0===i){var l=_(r,2),u=l[0],c=u.x,d=u.y,p=l[1];i=(c+p.x)/2,a=(d+p.y)/2}var h={id:n,type:VO[o],x:i,y:a,text:s,properties:{}},f=["x","y","text"];return Object.keys(t.properties).forEach((function(e){-1===f.indexOf(e)&&(h.properties[e]=t.properties[e])})),h}(t);e.nodes.push(o)}})),e},t.toNormalJson=tM,t.toTurboData=function(t){var e=new Map,n={flowElementList:[]};return t.nodes.forEach((function(t){var o=function(t){var e=t.id,n=t.type,o=t.x,r=t.y,i=t.text,a=void 0===i?"":i,s=t.properties;return{incoming:[],outgoing:[],dockers:[],type:KO(n),properties:f(f({},s),{name:a&&a.value||"",x:o,y:r,text:a}),key:e}}(t);n.flowElementList.push(o),e.set(t.id,o)})),t.edges.forEach((function(t){var o=function(t){var e=t.id,n=t.type,o=t.sourceNodeId,r=t.targetNodeId,i=t.startPoint,a=t.endPoint,s=t.pointsList,l=t.text,u=void 0===l?"":l,c=t.properties;return{incoming:[o],outgoing:[r],type:KO(n),dockers:[],properties:f(f({},c),{name:u&&u.value||"",text:u,startPoint:JSON.stringify(i),endPoint:JSON.stringify(a),pointsList:JSON.stringify(s)}),key:e}}(t);e.get(t.sourceNodeId).outgoing.push(o.key),e.get(t.targetNodeId).incoming.push(o.key),n.flowElementList.push(o)})),n},t.toXmlJson=QC,t.useDefinition=oO}));
|
|
41
|
+
*/String.prototype.startsWith=String.prototype.startsWith||function(t){return 0===this.indexOf(t)},String.prototype.padStart=String.prototype.padStart||function(t,e){for(var n=this;n.length<t;)n=e+n;return n};var yT={cb:"0f8ff",tqw:"aebd7",q:"-ffff",qmrn:"7fffd4",zr:"0ffff",bg:"5f5dc",bsq:"e4c4",bck:"---",nch:"ebcd",b:"--ff",bvt:"8a2be2",brwn:"a52a2a",brw:"deb887",ctb:"5f9ea0",hrt:"7fff-",chcT:"d2691e",cr:"7f50",rnw:"6495ed",crns:"8dc",crms:"dc143c",cn:"-ffff",Db:"--8b",Dcn:"-8b8b",Dgnr:"b8860b",Dgr:"a9a9a9",Dgrn:"-64-",Dkhk:"bdb76b",Dmgn:"8b-8b",Dvgr:"556b2f",Drng:"8c-",Drch:"9932cc",Dr:"8b--",Dsmn:"e9967a",Dsgr:"8fbc8f",DsTb:"483d8b",DsTg:"2f4f4f",Dtrq:"-ced1",Dvt:"94-d3",ppnk:"1493",pskb:"-bfff",mgr:"696969",grb:"1e90ff",rbrc:"b22222",rwht:"af0",stg:"228b22",chs:"-ff",gnsb:"dcdcdc",st:"8f8ff",g:"d7-",gnr:"daa520",gr:"808080",grn:"-8-0",grnw:"adff2f",hnw:"0fff0",htpn:"69b4",nnr:"cd5c5c",ng:"4b-82",vr:"0",khk:"0e68c",vnr:"e6e6fa",nrb:"0f5",wngr:"7cfc-",mnch:"acd",Lb:"add8e6",Lcr:"08080",Lcn:"e0ffff",Lgnr:"afad2",Lgr:"d3d3d3",Lgrn:"90ee90",Lpnk:"b6c1",Lsmn:"a07a",Lsgr:"20b2aa",Lskb:"87cefa",LsTg:"778899",Lstb:"b0c4de",Lw:"e0",m:"-ff-",mgrn:"32cd32",nn:"af0e6",mgnt:"-ff",mrn:"8--0",mqm:"66cdaa",mmb:"--cd",mmrc:"ba55d3",mmpr:"9370db",msg:"3cb371",mmsT:"7b68ee","":"-fa9a",mtr:"48d1cc",mmvt:"c71585",mnLb:"191970",ntc:"5fffa",mstr:"e4e1",mccs:"e4b5",vjw:"dead",nv:"--80",c:"df5e6",v:"808-0",vrb:"6b8e23",rng:"a5-",rngr:"45-",rch:"da70d6",pgnr:"eee8aa",pgrn:"98fb98",ptrq:"afeeee",pvtr:"db7093",ppwh:"efd5",pchp:"dab9",pr:"cd853f",pnk:"c0cb",pm:"dda0dd",pwrb:"b0e0e6",prp:"8-080",cc:"663399",r:"--",sbr:"bc8f8f",rb:"4169e1",sbrw:"8b4513",smn:"a8072",nbr:"4a460",sgrn:"2e8b57",ssh:"5ee",snn:"a0522d",svr:"c0c0c0",skb:"87ceeb",sTb:"6a5acd",sTgr:"708090",snw:"afa",n:"-ff7f",stb:"4682b4",tn:"d2b48c",t:"-8080",thst:"d8bfd8",tmT:"6347",trqs:"40e0d0",vt:"ee82ee",whT:"5deb3",wht:"",hts:"5f5f5",w:"-",wgrn:"9acd32"};function mT(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1;return(e>0?t.toFixed(e).replace(/0+$/,"").replace(/\.$/,""):t.toString())||"0"}var bT=function(){function t(e,n,o,r){fT(this,t);var i=this;if(void 0===e);else if(Array.isArray(e))this.rgba=e;else if(void 0===o){var a=e&&""+e;a&&function(e){if(e.startsWith("hsl")){var n=e.match(/([\-\d\.e]+)/g).map(Number),o=vT(n,4),r=o[0],a=o[1],s=o[2],l=o[3];void 0===l&&(l=1),r/=360,a/=100,s/=100,i.hsla=[r,a,s,l]}else if(e.startsWith("rgb")){var u=e.match(/([\-\d\.e]+)/g).map(Number),c=vT(u,4),d=c[0],p=c[1],h=c[2],f=c[3];void 0===f&&(f=1),i.rgba=[d,p,h,f]}else e.startsWith("#")?i.rgba=t.hexToRgb(e):i.rgba=t.nameToRgb(e)||t.hexToRgb(e)}(a.toLowerCase())}else this.rgba=[e,n,o,void 0===r?1:r]}return gT(t,[{key:"printRGB",value:function(t){var e=(t?this.rgba:this.rgba.slice(0,3)).map((function(t,e){return mT(t,3===e?3:0)}));return t?"rgba("+e+")":"rgb("+e+")"}},{key:"printHSL",value:function(t){var e=[360,100,100,1],n=["","%","%",""],o=(t?this.hsla:this.hsla.slice(0,3)).map((function(t,o){return mT(t*e[o],3===o?3:1)+n[o]}));return t?"hsla("+o+")":"hsl("+o+")"}},{key:"printHex",value:function(t){var e=this.hex;return t?e:e.substring(0,7)}},{key:"rgba",get:function(){if(this._rgba)return this._rgba;if(!this._hsla)throw new Error("No color is set");return this._rgba=t.hslToRgb(this._hsla)},set:function(t){3===t.length&&(t[3]=1),this._rgba=t,this._hsla=null}},{key:"rgbString",get:function(){return this.printRGB()}},{key:"rgbaString",get:function(){return this.printRGB(!0)}},{key:"hsla",get:function(){if(this._hsla)return this._hsla;if(!this._rgba)throw new Error("No color is set");return this._hsla=t.rgbToHsl(this._rgba)},set:function(t){3===t.length&&(t[3]=1),this._hsla=t,this._rgba=null}},{key:"hslString",get:function(){return this.printHSL()}},{key:"hslaString",get:function(){return this.printHSL(!0)}},{key:"hex",get:function(){var t=this.rgba.map((function(t,e){return e<3?t.toString(16):Math.round(255*t).toString(16)}));return"#"+t.map((function(t){return t.padStart(2,"0")})).join("")},set:function(e){this.rgba=t.hexToRgb(e)}}],[{key:"hexToRgb",value:function(t){var e=(t.startsWith("#")?t.slice(1):t).replace(/^(\w{3})$/,"$1F").replace(/^(\w)(\w)(\w)(\w)$/,"$1$1$2$2$3$3$4$4").replace(/^(\w{6})$/,"$1FF");if(!e.match(/^([0-9a-fA-F]{8})$/))throw new Error("Unknown hex color; "+t);var n=e.match(/^(\w\w)(\w\w)(\w\w)(\w\w)$/).slice(1).map((function(t){return parseInt(t,16)}));return n[3]=n[3]/255,n}},{key:"nameToRgb",value:function(e){var n=e.toLowerCase().replace("at","T").replace(/[aeiouyldf]/g,"").replace("ght","L").replace("rk","D").slice(-5,4),o=yT[n];return void 0===o?o:t.hexToRgb(o.replace(/\-/g,"00").padStart(6,"f"))}},{key:"rgbToHsl",value:function(t){var e=vT(t,4),n=e[0],o=e[1],r=e[2],i=e[3];n/=255,o/=255,r/=255;var a=Math.max(n,o,r),s=Math.min(n,o,r),l=void 0,u=void 0,c=(a+s)/2;if(a===s)l=u=0;else{var d=a-s;switch(u=c>.5?d/(2-a-s):d/(a+s),a){case n:l=(o-r)/d+(o<r?6:0);break;case o:l=(r-n)/d+2;break;case r:l=(n-o)/d+4}l/=6}return[l,u,c,i]}},{key:"hslToRgb",value:function(t){var e=vT(t,4),n=e[0],o=e[1],r=e[2],i=e[3],a=void 0,s=void 0,l=void 0;if(0===o)a=s=l=r;else{var u=function(t,e,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?t+6*(e-t)*n:n<.5?e:n<2/3?t+(e-t)*(2/3-n)*6:t},c=r<.5?r*(1+o):r+o-r*o,d=2*r-c;a=u(d,c,n+1/3),s=u(d,c,n),l=u(d,c,n-1/3)}var p=[255*a,255*s,255*l].map(Math.round);return p[3]=i,p}}]),t}(),_T=function(){function t(){fT(this,t),this._events=[]}return gT(t,[{key:"add",value:function(t,e,n){t.addEventListener(e,n,!1),this._events.push({target:t,type:e,handler:n})}},{key:"remove",value:function(e,n,o){this._events=this._events.filter((function(r){var i=!0;return e&&e!==r.target&&(i=!1),n&&n!==r.type&&(i=!1),o&&o!==r.handler&&(i=!1),i&&t._doRemove(r.target,r.type,r.handler),!i}))}},{key:"destroy",value:function(){this._events.forEach((function(e){return t._doRemove(e.target,e.type,e.handler)})),this._events=[]}}],[{key:"_doRemove",value:function(t,e,n){t.removeEventListener(e,n,!1)}}]),t}();function xT(t,e,n){var o=!1;function r(t,e,n){return Math.max(e,Math.min(t,n))}function i(t,i,a){if(a&&(o=!0),o){t.preventDefault();var s=e.getBoundingClientRect(),l=s.width,u=s.height,c=i.clientX,d=i.clientY,p=r(c-s.left,0,l),h=r(d-s.top,0,u);n(p/l,h/u)}}function a(t,e){1===(void 0===t.buttons?t.which:t.buttons)?i(t,t,e):o=!1}function s(t,e){1===t.touches.length?i(t,t.touches[0],e):o=!1}t.add(e,"mousedown",(function(t){a(t,!0)})),t.add(e,"touchstart",(function(t){s(t,!0)})),t.add(window,"mousemove",a),t.add(e,"touchmove",s),t.add(window,"mouseup",(function(t){o=!1})),t.add(e,"touchend",(function(t){o=!1})),t.add(e,"touchcancel",(function(t){o=!1}))}var ET="keydown",wT="mousedown",ST="focusin";function CT(t,e){return(e||document).querySelector(t)}function MT(t){t.preventDefault(),t.stopPropagation()}function OT(t,e,n,o,r){t.add(e,ET,(function(t){n.indexOf(t.key)>=0&&(r&&MT(t),o(t))}))}var TT=function(){function t(e){fT(this,t),this.settings={popup:"right",layout:"default",alpha:!0,editor:!0,editorFormat:"hex",cancelButton:!1,defaultColor:"#0cf"},this._events=new _T,this.onChange=null,this.onDone=null,this.onOpen=null,this.onClose=null,this.setOptions(e)}return gT(t,[{key:"setOptions",value:function(t){var e=this;if(t){var n=this.settings;if(t instanceof HTMLElement)n.parent=t;else{n.parent&&t.parent&&n.parent!==t.parent&&(this._events.remove(n.parent),this._popupInited=!1),function(t,e,n){for(var o in t)n&&n.indexOf(o)>=0||(e[o]=t[o])}(t,n),t.onChange&&(this.onChange=t.onChange),t.onDone&&(this.onDone=t.onDone),t.onOpen&&(this.onOpen=t.onOpen),t.onClose&&(this.onClose=t.onClose);var o=t.color||t.colour;o&&this._setColor(o)}var r=n.parent;if(r&&n.popup&&!this._popupInited){var i=function(t){return e.openHandler(t)};this._events.add(r,"click",i),OT(this._events,r,[" ","Spacebar","Enter"],i),this._popupInited=!0}else t.parent&&!n.popup&&this.show()}}},{key:"openHandler",value:function(t){if(this.show()){t&&t.preventDefault(),this.settings.parent.style.pointerEvents="none";var e=t&&t.type===ET?this._domEdit:this.domElement;setTimeout((function(){return e.focus()}),100),this.onOpen&&this.onOpen(this.colour)}}},{key:"closeHandler",value:function(t){var e=t&&t.type,n=!1;if(t)if(e===wT||e===ST){var o=(this.__containedEvent||0)+100;t.timeStamp>o&&(n=!0)}else MT(t),n=!0;else n=!0;n&&this.hide()&&(this.settings.parent.style.pointerEvents="",e!==wT&&this.settings.parent.focus(),this.onClose&&this.onClose(this.colour))}},{key:"movePopup",value:function(t,e){this.closeHandler(),this.setOptions(t),e&&this.openHandler()}},{key:"setColor",value:function(t,e){this._setColor(t,{silent:e})}},{key:"_setColor",value:function(t,e){if("string"==typeof t&&(t=t.trim()),t){e=e||{};var n=void 0;try{n=new bT(t)}catch(t){if(e.failSilently)return;throw t}if(!this.settings.alpha){var o=n.hsla;o[3]=1,n.hsla=o}this.colour=this.color=n,this._setHSLA(null,null,null,null,e)}}},{key:"setColour",value:function(t,e){this.setColor(t,e)}},{key:"show",value:function(){if(!this.settings.parent)return!1;if(this.domElement){var t=this._toggleDOM(!0);return this._setPosition(),t}var e,n,o=this.settings.template||'<div class="picker_wrapper" tabindex="-1"><div class="picker_arrow"></div><div class="picker_hue picker_slider"><div class="picker_selector"></div></div><div class="picker_sl"><div class="picker_selector"></div></div><div class="picker_alpha picker_slider"><div class="picker_selector"></div></div><div class="picker_editor"><input aria-label="Type a color name or hex value"/></div><div class="picker_sample"></div><div class="picker_done"><button>Ok</button></div><div class="picker_cancel"><button>Cancel</button></div></div>',r=(e=o,(n=document.createElement("div")).innerHTML=e,n.firstElementChild);return this.domElement=r,this._domH=CT(".picker_hue",r),this._domSL=CT(".picker_sl",r),this._domA=CT(".picker_alpha",r),this._domEdit=CT(".picker_editor input",r),this._domSample=CT(".picker_sample",r),this._domOkay=CT(".picker_done button",r),this._domCancel=CT(".picker_cancel button",r),r.classList.add("layout_"+this.settings.layout),this.settings.alpha||r.classList.add("no_alpha"),this.settings.editor||r.classList.add("no_editor"),this.settings.cancelButton||r.classList.add("no_cancel"),this._ifPopup((function(){return r.classList.add("popup")})),this._setPosition(),this.colour?this._updateUI():this._setColor(this.settings.defaultColor),this._bindEvents(),!0}},{key:"hide",value:function(){return this._toggleDOM(!1)}},{key:"destroy",value:function(){this._events.destroy(),this.domElement&&this.settings.parent.removeChild(this.domElement)}},{key:"_bindEvents",value:function(){var t=this,e=this,n=this.domElement,o=this._events;function r(t,e,n){o.add(t,e,n)}r(n,"click",(function(t){return t.preventDefault()})),xT(o,this._domH,(function(t,n){return e._setHSLA(t)})),xT(o,this._domSL,(function(t,n){return e._setHSLA(null,t,1-n)})),this.settings.alpha&&xT(o,this._domA,(function(t,n){return e._setHSLA(null,null,null,1-n)}));var i=this._domEdit;r(i,"input",(function(t){e._setColor(this.value,{fromEditor:!0,failSilently:!0})})),r(i,"focus",(function(t){var e=this;e.selectionStart===e.selectionEnd&&e.select()})),this._ifPopup((function(){var e=function(e){return t.closeHandler(e)};r(window,wT,e),r(window,ST,e),OT(o,n,["Esc","Escape"],e);var i=function(e){t.__containedEvent=e.timeStamp};r(n,wT,i),r(n,ST,i),r(t._domCancel,"click",e)}));var a=function(e){t._ifPopup((function(){return t.closeHandler(e)})),t.onDone&&t.onDone(t.colour)};r(this._domOkay,"click",a),OT(o,n,["Enter"],a)}},{key:"_setPosition",value:function(){var t=this.settings.parent,e=this.domElement;t!==e.parentNode&&t.appendChild(e),this._ifPopup((function(n){"static"===getComputedStyle(t).position&&(t.style.position="relative");var o=!0===n?"popup_right":"popup_"+n;["popup_top","popup_bottom","popup_left","popup_right"].forEach((function(t){t===o?e.classList.add(t):e.classList.remove(t)})),e.classList.add(o)}))}},{key:"_setHSLA",value:function(t,e,n,o,r){r=r||{};var i=this.colour,a=i.hsla;[t,e,n,o].forEach((function(t,e){(t||0===t)&&(a[e]=t)})),i.hsla=a,this._updateUI(r),this.onChange&&!r.silent&&this.onChange(i)}},{key:"_updateUI",value:function(t){if(this.domElement){t=t||{};var e=this.colour,n=e.hsla,o="hsl("+360*n[0]+", 100%, 50%)",r=e.hslString,i=e.hslaString,a=this._domH,s=this._domSL,l=this._domA,u=CT(".picker_selector",a),c=CT(".picker_selector",s),d=CT(".picker_selector",l);m(0,u,n[0]),this._domSL.style.backgroundColor=this._domH.style.color=o,m(0,c,n[1]),b(0,c,1-n[2]),s.style.color=r,b(0,d,1-n[3]);var p=r,h=p.replace("hsl","hsla").replace(")",", 0)"),f="linear-gradient("+[p,h]+")";if(this._domA.style.background=f+", linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0 / 2em 2em,\n linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em / 2em 2em",!t.fromEditor){var g=this.settings.editorFormat,v=this.settings.alpha,y=void 0;switch(g){case"rgb":y=e.printRGB(v);break;case"hsl":y=e.printHSL(v);break;default:y=e.printHex(v)}this._domEdit.value=y}this._domSample.style.color=i}function m(t,e,n){e.style.left=100*n+"%"}function b(t,e,n){e.style.top=100*n+"%"}}},{key:"_ifPopup",value:function(t,e){this.settings.parent&&this.settings.popup?t&&t(this.settings.popup):e&&e()}},{key:"_toggleDOM",value:function(t){var e=this.domElement;if(!e)return!1;var n=t?"":"none",o=e.style.display!==n;return o&&(e.style.display=n),o}}]),t}(),NT=document.createElement("style");NT.textContent='.picker_wrapper.no_alpha .picker_alpha{display:none}.picker_wrapper.no_editor .picker_editor{position:absolute;z-index:-1;opacity:0}.picker_wrapper.no_cancel .picker_cancel{display:none}.layout_default.picker_wrapper{display:flex;flex-flow:row wrap;justify-content:space-between;align-items:stretch;font-size:10px;width:25em;padding:.5em}.layout_default.picker_wrapper input,.layout_default.picker_wrapper button{font-size:1rem}.layout_default.picker_wrapper>*{margin:.5em}.layout_default.picker_wrapper::before{content:"";display:block;width:100%;height:0;order:1}.layout_default .picker_slider,.layout_default .picker_selector{padding:1em}.layout_default .picker_hue{width:100%}.layout_default .picker_sl{flex:1 1 auto}.layout_default .picker_sl::before{content:"";display:block;padding-bottom:100%}.layout_default .picker_editor{order:1;width:6.5rem}.layout_default .picker_editor input{width:100%;height:100%}.layout_default .picker_sample{order:1;flex:1 1 auto}.layout_default .picker_done,.layout_default .picker_cancel{order:1}.picker_wrapper{box-sizing:border-box;background:#f2f2f2;box-shadow:0 0 0 1px silver;cursor:default;font-family:sans-serif;color:#444;pointer-events:auto}.picker_wrapper:focus{outline:none}.picker_wrapper button,.picker_wrapper input{box-sizing:border-box;border:none;box-shadow:0 0 0 1px silver;outline:none}.picker_wrapper button:focus,.picker_wrapper button:active,.picker_wrapper input:focus,.picker_wrapper input:active{box-shadow:0 0 2px 1px #1e90ff}.picker_wrapper button{padding:.4em .6em;cursor:pointer;background-color:#f5f5f5;background-image:linear-gradient(0deg, gainsboro, transparent)}.picker_wrapper button:active{background-image:linear-gradient(0deg, transparent, gainsboro)}.picker_wrapper button:hover{background-color:#fff}.picker_selector{position:absolute;z-index:1;display:block;-webkit-transform:translate(-50%, -50%);transform:translate(-50%, -50%);border:2px solid #fff;border-radius:100%;box-shadow:0 0 3px 1px #67b9ff;background:currentColor;cursor:pointer}.picker_slider .picker_selector{border-radius:2px}.picker_hue{position:relative;background-image:linear-gradient(90deg, red, yellow, lime, cyan, blue, magenta, red);box-shadow:0 0 0 1px silver}.picker_sl{position:relative;box-shadow:0 0 0 1px silver;background-image:linear-gradient(180deg, white, rgba(255, 255, 255, 0) 50%),linear-gradient(0deg, black, rgba(0, 0, 0, 0) 50%),linear-gradient(90deg, #808080, rgba(128, 128, 128, 0))}.picker_alpha,.picker_sample{position:relative;background:linear-gradient(45deg, lightgrey 25%, transparent 25%, transparent 75%, lightgrey 75%) 0 0/2em 2em,linear-gradient(45deg, lightgrey 25%, white 25%, white 75%, lightgrey 75%) 1em 1em/2em 2em;box-shadow:0 0 0 1px silver}.picker_alpha .picker_selector,.picker_sample .picker_selector{background:none}.picker_editor input{font-family:monospace;padding:.2em .4em}.picker_sample::before{content:"";position:absolute;display:block;width:100%;height:100%;background:currentColor}.picker_arrow{position:absolute;z-index:-1}.picker_wrapper.popup{position:absolute;z-index:2;margin:1.5em}.picker_wrapper.popup,.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{background:#f2f2f2;box-shadow:0 0 10px 1px rgba(0,0,0,.4)}.picker_wrapper.popup .picker_arrow{width:3em;height:3em;margin:0}.picker_wrapper.popup .picker_arrow::before,.picker_wrapper.popup .picker_arrow::after{content:"";display:block;position:absolute;top:0;left:0;z-index:-99}.picker_wrapper.popup .picker_arrow::before{width:100%;height:100%;-webkit-transform:skew(45deg);transform:skew(45deg);-webkit-transform-origin:0 100%;transform-origin:0 100%}.picker_wrapper.popup .picker_arrow::after{width:150%;height:150%;box-shadow:none}.popup.popup_top{bottom:100%;left:0}.popup.popup_top .picker_arrow{bottom:0;left:0;-webkit-transform:rotate(-90deg);transform:rotate(-90deg)}.popup.popup_bottom{top:100%;left:0}.popup.popup_bottom .picker_arrow{top:0;left:0;-webkit-transform:rotate(90deg) scale(1, -1);transform:rotate(90deg) scale(1, -1)}.popup.popup_left{top:0;right:100%}.popup.popup_left .picker_arrow{top:0;right:0;-webkit-transform:scale(-1, 1);transform:scale(-1, 1)}.popup.popup_right{top:0;left:100%}.popup.popup_right .picker_arrow{top:0;left:0}',document.documentElement.firstElementChild.appendChild(NT),TT.StyleElement=NT;var AT={},PT={get exports(){return AT},set exports(t){AT=t}};!function(t){t.exports=function(){var t="object",e="function",n="undefined",o=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],r=["setStart","setStartBefore","setStartAfter","setEnd","setEndBefore","setEndAfter","collapse","selectNode","selectNodeContents","compareBoundaryPoints","deleteContents","extractContents","cloneContents","insertNode","surroundContents","cloneRange","toString","detach"],i=["boundingHeight","boundingLeft","boundingTop","boundingWidth","htmlText","text"],a=["collapse","compareEndPoints","duplicate","moveToElementText","parentElement","select","setEndPoint","getBoundingClientRect"];function s(n,o){var r=typeof n[o];return r==e||!(r!=t||!n[o])||"unknown"==r}function l(e,n){return!(typeof e[n]!=t||!e[n])}function u(t,e){return typeof t[e]!=n}function c(t){return function(e,n){for(var o=n.length;o--;)if(!t(e,n[o]))return!1;return!0}}var d=c(s),p=c(l),h=c(u);function f(t){return t&&d(t,a)&&h(t,i)}function g(t){return l(t,"body")?t.body:t.getElementsByTagName("body")[0]}var v,y,m=[].forEach?function(t,e){t.forEach(e)}:function(t,e){for(var n=0,o=t.length;n<o;++n)e(t[n],n)},b={},_=typeof window!=n&&typeof document!=n,x={isHostMethod:s,isHostObject:l,isHostProperty:u,areHostMethods:d,areHostObjects:p,areHostProperties:h,isTextRange:f,getBody:g,forEach:m},E={version:"1.3.1",initialized:!1,isBrowser:_,supported:!0,util:x,features:{},modules:b,config:{alertOnFail:!1,alertOnWarn:!1,preferTextRange:!1,autoInitialize:typeof rangyAutoInitialize==n||rangyAutoInitialize}};function w(t){typeof console!=n&&s(console,"log")&&console.log(t)}function S(t,e){_&&e?alert(t):w(t)}function C(t){E.initialized=!0,E.supported=!1,S("Rangy is not supported in this environment. Reason: "+t,E.config.alertOnFail)}function M(t){S("Rangy warning: "+t,E.config.alertOnWarn)}E.fail=C,E.warn=M,{}.hasOwnProperty?(x.extend=v=function(t,e,n){var o,r;for(var i in e)e.hasOwnProperty(i)&&(o=t[i],r=e[i],n&&null!==o&&"object"==typeof o&&null!==r&&"object"==typeof r&&v(o,r,!0),t[i]=r);return e.hasOwnProperty("toString")&&(t.toString=e.toString),t},x.createOptions=function(t,e){var n={};return v(n,e),t&&v(n,t),n}):C("hasOwnProperty not supported"),_||C("Rangy can only run in a browser"),function(){var t;if(_){var e=document.createElement("div");e.appendChild(document.createElement("span"));var n=[].slice;try{1==n.call(e.childNodes,0)[0].nodeType&&(t=function(t){return n.call(t,0)})}catch(t){}}t||(t=function(t){for(var e=[],n=0,o=t.length;n<o;++n)e[n]=t[n];return e}),x.toArray=t}(),_&&(s(document,"addEventListener")?y=function(t,e,n){t.addEventListener(e,n,!1)}:s(document,"attachEvent")?y=function(t,e,n){t.attachEvent("on"+e,n)}:C("Document does not have required addEventListener or attachEvent method"),x.addListener=y);var O=[];function T(t){return t.message||t.description||String(t)}function N(){if(_&&!E.initialized){var t,e=!1,n=!1;s(document,"createRange")&&(t=document.createRange(),d(t,r)&&h(t,o)&&(e=!0));var i=g(document);if(i&&"body"==i.nodeName.toLowerCase())if(i&&s(i,"createTextRange")&&f(t=i.createTextRange())&&(n=!0),e||n){var a;for(var l in E.initialized=!0,E.features={implementsDomRange:e,implementsTextRange:n},b)(a=b[l])instanceof R&&a.init(a,E);for(var u=0,c=O.length;u<c;++u)try{O[u](E)}catch(t){w("Rangy init listener threw an exception. Continuing. Detail: "+T(t))}}else C("Neither Range nor TextRange are available");else C("No body element found")}}function A(t,e,n){n&&(t+=" in module "+n.name),E.warn("DEPRECATED: "+t+" is deprecated. Please use "+e+" instead.")}function P(t,e,n,o){t[e]=function(){return A(e,n,o),t[n].apply(t,x.toArray(arguments))}}x.deprecationNotice=A,x.createAliasForDeprecatedMethod=P,E.init=N,E.addInitListener=function(t){E.initialized?t(E):O.push(t)};var D=[];function k(t){t=t||window,N();for(var e=0,n=D.length;e<n;++e)D[e](t)}function R(t,e,n){this.name=t,this.dependencies=e,this.initialized=!1,this.supported=!1,this.initializer=n}function I(t,e,n){var o=new R(t,e,(function(e){if(!e.initialized){e.initialized=!0;try{n(E,e),e.supported=!0}catch(e){w("Module '"+t+"' failed to load: "+T(e)),e.stack&&w(e.stack)}}}));return b[t]=o,o}function L(){}function j(){}E.addShimListener=function(t){D.push(t)},_&&(E.shim=E.createMissingNativeApi=k,P(E,"createMissingNativeApi","shim")),R.prototype={init:function(){for(var t,e,n=this.dependencies||[],o=0,r=n.length;o<r;++o){if(e=n[o],!((t=b[e])&&t instanceof R))throw new Error("required module '"+e+"' not found");if(t.init(),!t.supported)throw new Error("required module '"+e+"' not supported")}this.initializer(this)},fail:function(t){throw this.initialized=!0,this.supported=!1,new Error(t)},warn:function(t){E.warn("Module "+this.name+": "+t)},deprecationNotice:function(t,e){E.warn("DEPRECATED: "+t+" in module "+this.name+" is deprecated. Please use "+e+" instead")},createError:function(t){return new Error("Error in Rangy "+this.name+" module: "+t)}},E.createModule=function(t){var e,n;2==arguments.length?(e=arguments[1],n=[]):(e=arguments[2],n=arguments[1]);var o=I(t,n,e);E.initialized&&E.supported&&o.init()},E.createCoreModule=function(t,e,n){I(t,e,n)},E.RangePrototype=L,E.rangePrototype=new L,E.selectionPrototype=new j,E.createCoreModule("DomUtil",[],(function(t,e){var n="undefined",o=t.util,r=o.getBody;o.areHostMethods(document,["createDocumentFragment","createElement","createTextNode"])||e.fail("document missing a Node creation method"),o.isHostMethod(document,"getElementsByTagName")||e.fail("document missing getElementsByTagName method");var i=document.createElement("div");o.areHostMethods(i,["insertBefore","appendChild","cloneNode"]||!o.areHostObjects(i,["previousSibling","nextSibling","childNodes","parentNode"]))||e.fail("Incomplete Element implementation"),o.isHostProperty(i,"innerHTML")||e.fail("Element is missing innerHTML property");var a=document.createTextNode("test");o.areHostMethods(a,["splitText","deleteData","insertData","appendData","cloneNode"]||!o.areHostObjects(i,["previousSibling","nextSibling","childNodes","parentNode"])||!o.areHostProperties(a,["data"]))||e.fail("Incomplete Text Node implementation");var s=function(t,e){for(var n=t.length;n--;)if(t[n]===e)return!0;return!1};function l(t){var e;return typeof t.namespaceURI==n||null===(e=t.namespaceURI)||"http://www.w3.org/1999/xhtml"==e}function u(t){var e=t.parentNode;return 1==e.nodeType?e:null}function c(t){for(var e=0;t=t.previousSibling;)++e;return e}function d(t){switch(t.nodeType){case 7:case 10:return 0;case 3:case 8:return t.length;default:return t.childNodes.length}}function p(t,e){var n,o=[];for(n=t;n;n=n.parentNode)o.push(n);for(n=e;n;n=n.parentNode)if(s(o,n))return n;return null}function h(t,e,n){for(var o=n?e:e.parentNode;o;){if(o===t)return!0;o=o.parentNode}return!1}function f(t,e){return h(t,e,!0)}function g(t,e,n){for(var o,r=n?t:t.parentNode;r;){if((o=r.parentNode)===e)return r;r=o}return null}function v(t){var e=t.nodeType;return 3==e||4==e||8==e}function y(t){if(!t)return!1;var e=t.nodeType;return 3==e||8==e}function m(t,e){var n=e.nextSibling,o=e.parentNode;return n?o.insertBefore(t,n):o.appendChild(t),t}function b(t,e,n){var o=t.cloneNode(!1);if(o.deleteData(0,e),t.deleteData(e,t.length-e),m(o,t),n)for(var r,i=0;r=n[i++];)r.node==t&&r.offset>e?(r.node=o,r.offset-=e):r.node==t.parentNode&&r.offset>c(t)&&++r.offset;return o}function _(t){if(9==t.nodeType)return t;if(typeof t.ownerDocument!=n)return t.ownerDocument;if(typeof t.document!=n)return t.document;if(t.parentNode)return _(t.parentNode);throw e.createError("getDocument: no document found for node")}function x(t){var o=_(t);if(typeof o.defaultView!=n)return o.defaultView;if(typeof o.parentWindow!=n)return o.parentWindow;throw e.createError("Cannot get a window object for node")}function E(t){if(typeof t.contentDocument!=n)return t.contentDocument;if(typeof t.contentWindow!=n)return t.contentWindow.document;throw e.createError("getIframeDocument: No Document object found for iframe element")}function w(t){if(typeof t.contentWindow!=n)return t.contentWindow;if(typeof t.contentDocument!=n)return t.contentDocument.defaultView;throw e.createError("getIframeWindow: No Window object found for iframe element")}function S(t){return t&&o.isHostMethod(t,"setTimeout")&&o.isHostObject(t,"document")}function C(t,e,n){var r;if(t?o.isHostProperty(t,"nodeType")?r=1==t.nodeType&&"iframe"==t.tagName.toLowerCase()?E(t):_(t):S(t)&&(r=t.document):r=document,!r)throw e.createError(n+"(): Parameter must be a Window object or DOM node");return r}function M(t){for(var e;e=t.parentNode;)t=e;return t}function O(t,n,o,r){var i,a,s,l,u;if(t==o)return n===r?0:n<r?-1:1;if(i=g(o,t,!0))return n<=c(i)?-1:1;if(i=g(t,o,!0))return c(i)<r?-1:1;if(!(a=p(t,o)))throw new Error("comparePoints error: nodes have no common ancestor");if((s=t===a?a:g(t,a,!0))===(l=o===a?a:g(o,a,!0)))throw e.createError("comparePoints got to case 4 and childA and childB are the same!");for(u=a.firstChild;u;){if(u===s)return-1;if(u===l)return 1;u=u.nextSibling}}var T,N=!1;function A(t){try{return t.parentNode,!1}catch(t){return!0}}function P(t){if(!t)return"[No node]";if(N&&A(t))return"[Broken node]";if(v(t))return'"'+t.data+'"';if(1==t.nodeType){var e=t.id?' id="'+t.id+'"':"";return"<"+t.nodeName+e+">[index:"+c(t)+",length:"+t.childNodes.length+"]["+(t.innerHTML||"[innerHTML not supported]").slice(0,25)+"]"}return t.nodeName}function D(t){for(var e,n=_(t).createDocumentFragment();e=t.firstChild;)n.appendChild(e);return n}function k(t,e,n){var o=r(t),i=t.createElement("div");i.contentEditable=""+!!n,e&&(i.innerHTML=e);var a=o.firstChild;return a?o.insertBefore(i,a):o.appendChild(i),i}function R(t){return t.parentNode.removeChild(t)}function I(t){this.root=t,this._next=t}function L(t){return new I(t)}function j(t,e){this.node=t,this.offset=e}function B(t){this.code=this[t],this.codeName=t,this.message="DOMException: "+this.codeName}!function(){var e=document.createElement("b");e.innerHTML="1";var n=e.firstChild;e.innerHTML="<br />",N=A(n),t.features.crashyTextNodes=N}(),typeof window.getComputedStyle!=n?T=function(t,e){return x(t).getComputedStyle(t,null)[e]}:typeof document.documentElement.currentStyle!=n?T=function(t,e){return t.currentStyle?t.currentStyle[e]:""}:e.fail("No means of obtaining computed style properties found"),I.prototype={_current:null,hasNext:function(){return!!this._next},next:function(){var t,e,n=this._current=this._next;if(this._current)if(t=n.firstChild)this._next=t;else{for(e=null;n!==this.root&&!(e=n.nextSibling);)n=n.parentNode;this._next=e}return this._current},detach:function(){this._current=this._next=this.root=null}},j.prototype={equals:function(t){return!!t&&this.node===t.node&&this.offset==t.offset},inspect:function(){return"[DomPosition("+P(this.node)+":"+this.offset+")]"},toString:function(){return this.inspect()}},B.prototype={INDEX_SIZE_ERR:1,HIERARCHY_REQUEST_ERR:3,WRONG_DOCUMENT_ERR:4,NO_MODIFICATION_ALLOWED_ERR:7,NOT_FOUND_ERR:8,NOT_SUPPORTED_ERR:9,INVALID_STATE_ERR:11,INVALID_NODE_TYPE_ERR:24},B.prototype.toString=function(){return this.message},t.dom={arrayContains:s,isHtmlNamespace:l,parentElement:u,getNodeIndex:c,getNodeLength:d,getCommonAncestor:p,isAncestorOf:h,isOrIsAncestorOf:f,getClosestAncestorIn:g,isCharacterDataNode:v,isTextOrCommentNode:y,insertAfter:m,splitDataNode:b,getDocument:_,getWindow:x,getIframeWindow:w,getIframeDocument:E,getBody:r,isWindow:S,getContentDocument:C,getRootContainer:M,comparePoints:O,isBrokenNode:A,inspectNode:P,getComputedStyleProperty:T,createTestElement:k,removeNode:R,fragmentFromNodeChildren:D,createIterator:L,DomPosition:j},t.DOMException=B})),E.createCoreModule("DomRange",["DomUtil"],(function(t,e){var n=t.dom,o=t.util,r=n.DomPosition,i=t.DOMException,a=n.isCharacterDataNode,s=n.getNodeIndex,l=n.isOrIsAncestorOf,u=n.getDocument,c=n.comparePoints,d=n.splitDataNode,p=n.getClosestAncestorIn,h=n.getNodeLength,f=n.arrayContains,g=n.getRootContainer,v=t.features.crashyTextNodes,y=n.removeNode;function m(t,e){return 3!=t.nodeType&&(l(t,e.startContainer)||l(t,e.endContainer))}function b(t){return t.document||u(t.startContainer)}function _(t){return g(t.startContainer)}function x(t){return new r(t.parentNode,s(t))}function E(t){return new r(t.parentNode,s(t)+1)}function w(t,e,o){var r=11==t.nodeType?t.firstChild:t;return a(e)?o==e.length?n.insertAfter(t,e):e.parentNode.insertBefore(t,0==o?e:d(e,o)):o>=e.childNodes.length?e.appendChild(t):e.insertBefore(t,e.childNodes[o]),r}function S(t,e,n){if(Z(t),Z(e),b(e)!=b(t))throw new i("WRONG_DOCUMENT_ERR");var o=c(t.startContainer,t.startOffset,e.endContainer,e.endOffset),r=c(t.endContainer,t.endOffset,e.startContainer,e.startOffset);return n?o<=0&&r>=0:o<0&&r>0}function C(t){for(var e,n,o,r=b(t.range).createDocumentFragment();n=t.next();){if(e=t.isPartiallySelectedSubtree(),n=n.cloneNode(!e),e&&(o=t.getSubtreeIterator(),n.appendChild(C(o)),o.detach()),10==n.nodeType)throw new i("HIERARCHY_REQUEST_ERR");r.appendChild(n)}return r}function M(t,e,o){var r,i,a,s;for(o=o||{stop:!1};a=t.next();)if(t.isPartiallySelectedSubtree()){if(!1===e(a))return void(o.stop=!0);if(M(s=t.getSubtreeIterator(),e,o),s.detach(),o.stop)return}else for(r=n.createIterator(a);i=r.next();)if(!1===e(i))return void(o.stop=!0)}function O(t){for(var e;t.next();)t.isPartiallySelectedSubtree()?(O(e=t.getSubtreeIterator()),e.detach()):t.remove()}function T(t){for(var e,n,o=b(t.range).createDocumentFragment();e=t.next();){if(t.isPartiallySelectedSubtree()?(e=e.cloneNode(!1),n=t.getSubtreeIterator(),e.appendChild(T(n)),n.detach()):t.remove(),10==e.nodeType)throw new i("HIERARCHY_REQUEST_ERR");o.appendChild(e)}return o}function N(t,e,n){var o,r=!(!e||!e.length),i=!!n;r&&(o=new RegExp("^("+e.join("|")+")$"));var s=[];return M(new P(t,!1),(function(e){if((!r||o.test(e.nodeType))&&(!i||n(e))){var l=t.startContainer;if(e!=l||!a(l)||t.startOffset!=l.length){var u=t.endContainer;e==u&&a(u)&&0==t.endOffset||s.push(e)}}})),s}function A(t){return"["+(void 0===t.getName?"Range":t.getName())+"("+n.inspectNode(t.startContainer)+":"+t.startOffset+", "+n.inspectNode(t.endContainer)+":"+t.endOffset+")]"}function P(t,e){if(this.range=t,this.clonePartiallySelectedTextNodes=e,!t.collapsed){this.sc=t.startContainer,this.so=t.startOffset,this.ec=t.endContainer,this.eo=t.endOffset;var n=t.commonAncestorContainer;this.sc===this.ec&&a(this.sc)?(this.isSingleCharacterDataNode=!0,this._first=this._last=this._next=this.sc):(this._first=this._next=this.sc!==n||a(this.sc)?p(this.sc,n,!0):this.sc.childNodes[this.so],this._last=this.ec!==n||a(this.ec)?p(this.ec,n,!0):this.ec.childNodes[this.eo-1])}}P.prototype={_current:null,_next:null,_first:null,_last:null,isSingleCharacterDataNode:!1,reset:function(){this._current=null,this._next=this._first},hasNext:function(){return!!this._next},next:function(){var t=this._current=this._next;return t&&(this._next=t!==this._last?t.nextSibling:null,a(t)&&this.clonePartiallySelectedTextNodes&&(t===this.ec&&(t=t.cloneNode(!0)).deleteData(this.eo,t.length-this.eo),this._current===this.sc&&(t=t.cloneNode(!0)).deleteData(0,this.so))),t},remove:function(){var t,e,n=this._current;!a(n)||n!==this.sc&&n!==this.ec?n.parentNode&&y(n):(t=n===this.sc?this.so:0)!=(e=n===this.ec?this.eo:n.length)&&n.deleteData(t,e-t)},isPartiallySelectedSubtree:function(){return m(this._current,this.range)},getSubtreeIterator:function(){var t;if(this.isSingleCharacterDataNode)(t=this.range.cloneRange()).collapse(!1);else{t=new yt(b(this.range));var e=this._current,n=e,o=0,r=e,i=h(e);l(e,this.sc)&&(n=this.sc,o=this.so),l(e,this.ec)&&(r=this.ec,i=this.eo),vt(t,n,o,r,i)}return new P(t,this.clonePartiallySelectedTextNodes)},detach:function(){this.range=this._current=this._next=this._first=this._last=this.sc=this.so=this.ec=this.eo=null}};var D=[1,3,4,5,7,8,10],k=[2,9,11],R=[5,6,10,12],I=[1,3,4,5,7,8,10,11],L=[1,3,4,5,7,8];function j(t){return function(e,n){for(var o,r=n?e:e.parentNode;r;){if(o=r.nodeType,f(t,o))return r;r=r.parentNode}return null}}var B=j([9,11]),H=j(R),z=j([6,10,12]),F=j([1]);function W(t,e){if(z(t,e))throw new i("INVALID_NODE_TYPE_ERR")}function G(t,e){if(!f(e,t.nodeType))throw new i("INVALID_NODE_TYPE_ERR")}function X(t,e){if(e<0||e>(a(t)?t.length:t.childNodes.length))throw new i("INDEX_SIZE_ERR")}function U(t,e){if(B(t,!0)!==B(e,!0))throw new i("WRONG_DOCUMENT_ERR")}function Y(t){if(H(t,!0))throw new i("NO_MODIFICATION_ALLOWED_ERR")}function V(t,e){if(!t)throw new i(e)}function K(t,e){return e<=(a(t)?t.length:t.childNodes.length)}function q(t){return!!t.startContainer&&!!t.endContainer&&!(v&&(n.isBrokenNode(t.startContainer)||n.isBrokenNode(t.endContainer)))&&g(t.startContainer)==g(t.endContainer)&&K(t.startContainer,t.startOffset)&&K(t.endContainer,t.endOffset)}function Z(t){if(!q(t))throw new Error("Range error: Range is not valid. This usually happens after DOM mutation. Range: ("+t.inspect()+")")}var $=document.createElement("style"),J=!1;try{$.innerHTML="<b>x</b>",J=3==$.firstChild.nodeType}catch(t){}t.features.htmlParsingConforms=J;var Q=J?function(t){var e=this.startContainer,o=u(e);if(!e)throw new i("INVALID_STATE_ERR");var r=null;return 1==e.nodeType?r=e:a(e)&&(r=n.parentElement(e)),(r=null===r||"HTML"==r.nodeName&&n.isHtmlNamespace(u(r).documentElement)&&n.isHtmlNamespace(r)?o.createElement("body"):r.cloneNode(!1)).innerHTML=t,n.fragmentFromNodeChildren(r)}:function(t){var e=b(this).createElement("body");return e.innerHTML=t,n.fragmentFromNodeChildren(e)};function tt(t,e){Z(t);var n=t.startContainer,o=t.startOffset,r=t.endContainer,i=t.endOffset,l=n===r;a(r)&&i>0&&i<r.length&&d(r,i,e),a(n)&&o>0&&o<n.length&&(n=d(n,o,e),l?(i-=o,r=n):r==n.parentNode&&i>=s(n)&&i++,o=0),t.setStartAndEnd(n,o,r,i)}function et(t){Z(t);var e=t.commonAncestorContainer.parentNode.cloneNode(!1);return e.appendChild(t.cloneContents()),e.innerHTML}var nt=["startContainer","startOffset","endContainer","endOffset","collapsed","commonAncestorContainer"],ot=0,rt=1,it=2,at=3,st=0,lt=1,ut=2,ct=3;function dt(t){t.START_TO_START=ot,t.START_TO_END=rt,t.END_TO_END=it,t.END_TO_START=at,t.NODE_BEFORE=st,t.NODE_AFTER=lt,t.NODE_BEFORE_AND_AFTER=ut,t.NODE_INSIDE=ct}function pt(t){dt(t),dt(t.prototype)}function ht(t,e){return function(){Z(this);var n,o=this.startContainer,r=this.startOffset,i=this.commonAncestorContainer,a=new P(this,!0);o!==i&&(o=(n=E(p(o,i,!0))).node,r=n.offset),M(a,Y),a.reset();var s=t(a);return a.detach(),e(this,o,r,o,r),s}}function ft(e,n){function r(t,e){return function(n){G(n,D),G(g(n),k);var o=(t?x:E)(n);(e?i:l)(this,o.node,o.offset)}}function i(t,e,o){var r=t.endContainer,i=t.endOffset;e===t.startContainer&&o===t.startOffset||(g(e)==g(r)&&1!=c(e,o,r,i)||(r=e,i=o),n(t,e,o,r,i))}function l(t,e,o){var r=t.startContainer,i=t.startOffset;e===t.endContainer&&o===t.endOffset||(g(e)==g(r)&&-1!=c(e,o,r,i)||(r=e,i=o),n(t,r,i,e,o))}var u=function(){};u.prototype=t.rangePrototype,e.prototype=new u,o.extend(e.prototype,{setStart:function(t,e){W(t,!0),X(t,e),i(this,t,e)},setEnd:function(t,e){W(t,!0),X(t,e),l(this,t,e)},setStartAndEnd:function(){var t=arguments,e=t[0],o=t[1],r=e,i=o;switch(t.length){case 3:i=t[2];break;case 4:r=t[2],i=t[3]}W(e,!0),X(e,o),W(r,!0),X(r,i),n(this,e,o,r,i)},setBoundary:function(t,e,n){this["set"+(n?"Start":"End")](t,e)},setStartBefore:r(!0,!0),setStartAfter:r(!1,!0),setEndBefore:r(!0,!1),setEndAfter:r(!1,!1),collapse:function(t){Z(this),t?n(this,this.startContainer,this.startOffset,this.startContainer,this.startOffset):n(this,this.endContainer,this.endOffset,this.endContainer,this.endOffset)},selectNodeContents:function(t){W(t,!0),n(this,t,0,t,h(t))},selectNode:function(t){W(t,!1),G(t,D);var e=x(t),o=E(t);n(this,e.node,e.offset,o.node,o.offset)},extractContents:ht(T,n),deleteContents:ht(O,n),canSurroundContents:function(){Z(this),Y(this.startContainer),Y(this.endContainer);var t=new P(this,!0),e=t._first&&m(t._first,this)||t._last&&m(t._last,this);return t.detach(),!e},splitBoundaries:function(){tt(this)},splitBoundariesPreservingPositions:function(t){tt(this,t)},normalizeBoundaries:function(){Z(this);var t,e=this.startContainer,o=this.startOffset,r=this.endContainer,i=this.endOffset,l=function(t){var e=t.nextSibling;e&&e.nodeType==t.nodeType&&(r=t,i=t.length,t.appendData(e.data),y(e))},u=function(t){var n=t.previousSibling;if(n&&n.nodeType==t.nodeType){e=t;var a=t.length;if(o=n.length,t.insertData(0,n.data),y(n),e==r)i+=o,r=e;else if(r==t.parentNode){var l=s(t);i==l?(r=t,i=a):i>l&&i--}}},c=!0;if(a(r))i==r.length?l(r):0==i&&(t=r.previousSibling)&&t.nodeType==r.nodeType&&(i=t.length,e==r&&(c=!1),t.appendData(r.data),y(r),r=t);else{if(i>0){var d=r.childNodes[i-1];d&&a(d)&&l(d)}c=!this.collapsed}if(c){if(a(e))0==o?u(e):o==e.length&&(t=e.nextSibling)&&t.nodeType==e.nodeType&&(r==t&&(r=e,i+=e.length),e.appendData(t.data),y(t));else if(o<e.childNodes.length){var p=e.childNodes[o];p&&a(p)&&u(p)}}else e=r,o=i;n(this,e,o,r,i)},collapseToPoint:function(t,e){W(t,!0),X(t,e),this.setStartAndEnd(t,e)},parentElement:function(){return Z(this),this.commonAncestorContainer?F(this.commonAncestorContainer,!0):null}}),pt(e)}function gt(t){t.collapsed=t.startContainer===t.endContainer&&t.startOffset===t.endOffset,t.commonAncestorContainer=t.collapsed?t.startContainer:n.getCommonAncestor(t.startContainer,t.endContainer)}function vt(t,e,o,r,i){t.startContainer=e,t.startOffset=o,t.endContainer=r,t.endOffset=i,t.document=n.getDocument(e),gt(t)}function yt(t){vt(this,t,0,t,0)}o.extend(t.rangePrototype,{compareBoundaryPoints:function(t,e){var n,o,r,i;Z(this),U(this.startContainer,e.startContainer);var a=t==at||t==ot?"start":"end",s=t==rt||t==ot?"start":"end";return n=this[a+"Container"],o=this[a+"Offset"],r=e[s+"Container"],i=e[s+"Offset"],c(n,o,r,i)},insertNode:function(t){if(Z(this),G(t,I),Y(this.startContainer),l(t,this.startContainer))throw new i("HIERARCHY_REQUEST_ERR");var e=w(t,this.startContainer,this.startOffset);this.setStartBefore(e)},cloneContents:function(){var t,e;if(Z(this),this.collapsed)return b(this).createDocumentFragment();if(this.startContainer===this.endContainer&&a(this.startContainer))return(t=this.startContainer.cloneNode(!0)).data=t.data.slice(this.startOffset,this.endOffset),(e=b(this).createDocumentFragment()).appendChild(t),e;var n=new P(this,!0);return t=C(n),n.detach(),t},canSurroundContents:function(){Z(this),Y(this.startContainer),Y(this.endContainer);var t=new P(this,!0),e=t._first&&m(t._first,this)||t._last&&m(t._last,this);return t.detach(),!e},surroundContents:function(t){if(G(t,L),!this.canSurroundContents())throw new i("INVALID_STATE_ERR");var e=this.extractContents();if(t.hasChildNodes())for(;t.lastChild;)t.removeChild(t.lastChild);w(t,this.startContainer,this.startOffset),t.appendChild(e),this.selectNode(t)},cloneRange:function(){Z(this);for(var t,e=new yt(b(this)),n=nt.length;n--;)e[t=nt[n]]=this[t];return e},toString:function(){Z(this);var t=this.startContainer;if(t===this.endContainer&&a(t))return 3==t.nodeType||4==t.nodeType?t.data.slice(this.startOffset,this.endOffset):"";var e=[],n=new P(this,!0);return M(n,(function(t){3!=t.nodeType&&4!=t.nodeType||e.push(t.data)})),n.detach(),e.join("")},compareNode:function(t){Z(this);var e=t.parentNode,n=s(t);if(!e)throw new i("NOT_FOUND_ERR");var o=this.comparePoint(e,n),r=this.comparePoint(e,n+1);return o<0?r>0?ut:st:r>0?lt:ct},comparePoint:function(t,e){return Z(this),V(t,"HIERARCHY_REQUEST_ERR"),U(t,this.startContainer),c(t,e,this.startContainer,this.startOffset)<0?-1:c(t,e,this.endContainer,this.endOffset)>0?1:0},createContextualFragment:Q,toHtml:function(){return et(this)},intersectsNode:function(t,e){if(Z(this),g(t)!=_(this))return!1;var n=t.parentNode,o=s(t);if(!n)return!0;var r=c(n,o,this.endContainer,this.endOffset),i=c(n,o+1,this.startContainer,this.startOffset);return e?r<=0&&i>=0:r<0&&i>0},isPointInRange:function(t,e){return Z(this),V(t,"HIERARCHY_REQUEST_ERR"),U(t,this.startContainer),c(t,e,this.startContainer,this.startOffset)>=0&&c(t,e,this.endContainer,this.endOffset)<=0},intersectsRange:function(t){return S(this,t,!1)},intersectsOrTouchesRange:function(t){return S(this,t,!0)},intersection:function(t){if(this.intersectsRange(t)){var e=c(this.startContainer,this.startOffset,t.startContainer,t.startOffset),n=c(this.endContainer,this.endOffset,t.endContainer,t.endOffset),o=this.cloneRange();return-1==e&&o.setStart(t.startContainer,t.startOffset),1==n&&o.setEnd(t.endContainer,t.endOffset),o}return null},union:function(t){if(this.intersectsOrTouchesRange(t)){var e=this.cloneRange();return-1==c(t.startContainer,t.startOffset,this.startContainer,this.startOffset)&&e.setStart(t.startContainer,t.startOffset),1==c(t.endContainer,t.endOffset,this.endContainer,this.endOffset)&&e.setEnd(t.endContainer,t.endOffset),e}throw new i("Ranges do not intersect")},containsNode:function(t,e){return e?this.intersectsNode(t,!1):this.compareNode(t)==ct},containsNodeContents:function(t){return this.comparePoint(t,0)>=0&&this.comparePoint(t,h(t))<=0},containsRange:function(t){var e=this.intersection(t);return null!==e&&t.equals(e)},containsNodeText:function(t){var e=this.cloneRange();e.selectNode(t);var n=e.getNodes([3]);if(n.length>0){e.setStart(n[0],0);var o=n.pop();return e.setEnd(o,o.length),this.containsRange(e)}return this.containsNodeContents(t)},getNodes:function(t,e){return Z(this),N(this,t,e)},getDocument:function(){return b(this)},collapseBefore:function(t){this.setEndBefore(t),this.collapse(!1)},collapseAfter:function(t){this.setStartAfter(t),this.collapse(!0)},getBookmark:function(e){var o=b(this),r=t.createRange(o);e=e||n.getBody(o),r.selectNodeContents(e);var i=this.intersection(r),a=0,s=0;return i&&(r.setEnd(i.startContainer,i.startOffset),s=(a=r.toString().length)+i.toString().length),{start:a,end:s,containerNode:e}},moveToBookmark:function(t){var e=t.containerNode,n=0;this.setStart(e,0),this.collapse(!0);for(var o,r,i,a,s=[e],l=!1,u=!1;!u&&(o=s.pop());)if(3==o.nodeType)r=n+o.length,!l&&t.start>=n&&t.start<=r&&(this.setStart(o,t.start-n),l=!0),l&&t.end>=n&&t.end<=r&&(this.setEnd(o,t.end-n),u=!0),n=r;else for(i=(a=o.childNodes).length;i--;)s.push(a[i])},getName:function(){return"DomRange"},equals:function(t){return yt.rangesEqual(this,t)},isValid:function(){return q(this)},inspect:function(){return A(this)},detach:function(){}}),ft(yt,vt),o.extend(yt,{rangeProperties:nt,RangeIterator:P,copyComparisonConstants:pt,createPrototypeRange:ft,inspect:A,toHtml:et,getRangeDocument:b,rangesEqual:function(t,e){return t.startContainer===e.startContainer&&t.startOffset===e.startOffset&&t.endContainer===e.endContainer&&t.endOffset===e.endOffset}}),t.DomRange=yt})),E.createCoreModule("WrappedRange",["DomRange"],(function(t,e){var n,o,r=t.dom,i=t.util,a=r.DomPosition,s=t.DomRange,l=r.getBody,u=r.getContentDocument,c=r.isCharacterDataNode;if(t.features.implementsDomRange&&function(){var o,a,c=s.rangeProperties;function d(t){for(var e,n=c.length;n--;)t[e=c[n]]=t.nativeRange[e];t.collapsed=t.startContainer===t.endContainer&&t.startOffset===t.endOffset}function p(t,e,n,o,r){var i=t.startContainer!==e||t.startOffset!=n,a=t.endContainer!==o||t.endOffset!=r,s=!t.equals(t.nativeRange);(i||a||s)&&(t.setEnd(o,r),t.setStart(e,n))}n=function(t){if(!t)throw e.createError("WrappedRange: Range must be specified");this.nativeRange=t,d(this)},s.createPrototypeRange(n,p),(o=n.prototype).selectNode=function(t){this.nativeRange.selectNode(t),d(this)},o.cloneContents=function(){return this.nativeRange.cloneContents()},o.surroundContents=function(t){this.nativeRange.surroundContents(t),d(this)},o.collapse=function(t){this.nativeRange.collapse(t),d(this)},o.cloneRange=function(){return new n(this.nativeRange.cloneRange())},o.refresh=function(){d(this)},o.toString=function(){return this.nativeRange.toString()};var h=document.createTextNode("test");l(document).appendChild(h);var f=document.createRange();f.setStart(h,0),f.setEnd(h,0);try{f.setStart(h,1),o.setStart=function(t,e){this.nativeRange.setStart(t,e),d(this)},o.setEnd=function(t,e){this.nativeRange.setEnd(t,e),d(this)},a=function(t){return function(e){this.nativeRange[t](e),d(this)}}}catch(t){o.setStart=function(t,e){try{this.nativeRange.setStart(t,e)}catch(n){this.nativeRange.setEnd(t,e),this.nativeRange.setStart(t,e)}d(this)},o.setEnd=function(t,e){try{this.nativeRange.setEnd(t,e)}catch(n){this.nativeRange.setStart(t,e),this.nativeRange.setEnd(t,e)}d(this)},a=function(t,e){return function(n){try{this.nativeRange[t](n)}catch(o){this.nativeRange[e](n),this.nativeRange[t](n)}d(this)}}}o.setStartBefore=a("setStartBefore","setEndBefore"),o.setStartAfter=a("setStartAfter","setEndAfter"),o.setEndBefore=a("setEndBefore","setStartBefore"),o.setEndAfter=a("setEndAfter","setStartAfter"),o.selectNodeContents=function(t){this.setStartAndEnd(t,0,r.getNodeLength(t))},f.selectNodeContents(h),f.setEnd(h,3);var g=document.createRange();g.selectNodeContents(h),g.setEnd(h,4),g.setStart(h,2),-1==f.compareBoundaryPoints(f.START_TO_END,g)&&1==f.compareBoundaryPoints(f.END_TO_START,g)?o.compareBoundaryPoints=function(t,e){return t==(e=e.nativeRange||e).START_TO_END?t=e.END_TO_START:t==e.END_TO_START&&(t=e.START_TO_END),this.nativeRange.compareBoundaryPoints(t,e)}:o.compareBoundaryPoints=function(t,e){return this.nativeRange.compareBoundaryPoints(t,e.nativeRange||e)};var v=document.createElement("div");v.innerHTML="123";var y=v.firstChild,m=l(document);m.appendChild(v),f.setStart(y,1),f.setEnd(y,2),f.deleteContents(),"13"==y.data&&(o.deleteContents=function(){this.nativeRange.deleteContents(),d(this)},o.extractContents=function(){var t=this.nativeRange.extractContents();return d(this),t}),m.removeChild(v),m=null,i.isHostMethod(f,"createContextualFragment")&&(o.createContextualFragment=function(t){return this.nativeRange.createContextualFragment(t)}),l(document).removeChild(h),o.getName=function(){return"WrappedRange"},t.WrappedRange=n,t.createNativeRange=function(t){return(t=u(t,e,"createNativeRange")).createRange()}}(),t.features.implementsTextRange){var d=function(t){var e=t.parentElement(),n=t.duplicate();n.collapse(!0);var o=n.parentElement();(n=t.duplicate()).collapse(!1);var i=n.parentElement(),a=o==i?o:r.getCommonAncestor(o,i);return a==e?a:r.getCommonAncestor(e,a)},p=function(t){return 0==t.compareEndPoints("StartToEnd",t)},h=function(t,e,n,o,i){var s=t.duplicate();s.collapse(n);var l=s.parentElement();if(r.isOrIsAncestorOf(e,l)||(l=e),!l.canHaveHTML){var u=new a(l.parentNode,r.getNodeIndex(l));return{boundaryPosition:u,nodeInfo:{nodeIndex:u.offset,containerElement:u.node}}}var d=r.getDocument(l).createElement("span");d.parentNode&&r.removeNode(d);for(var p,h,f,g,v,y=n?"StartToStart":"StartToEnd",m=i&&i.containerElement==l?i.nodeIndex:0,b=l.childNodes.length,_=b,x=_;x==b?l.appendChild(d):l.insertBefore(d,l.childNodes[x]),s.moveToElementText(d),0!=(p=s.compareEndPoints(y,t))&&m!=_;){if(-1==p){if(_==m+1)break;m=x}else _=_==m+1?m:x;x=Math.floor((m+_)/2),l.removeChild(d)}if(v=d.nextSibling,-1==p&&v&&c(v)){var E;if(s.setEndPoint(n?"EndToStart":"EndToEnd",t),/[\r\n]/.test(v.data)){var w=s.duplicate(),S=w.text.replace(/\r\n/g,"\r").length;for(E=w.moveStart("character",S);-1==(p=w.compareEndPoints("StartToEnd",w));)E++,w.moveStart("character",1)}else E=s.text.length;g=new a(v,E)}else h=(o||!n)&&d.previousSibling,g=(f=(o||n)&&d.nextSibling)&&c(f)?new a(f,0):h&&c(h)?new a(h,h.data.length):new a(l,r.getNodeIndex(d));return r.removeNode(d),{boundaryPosition:g,nodeInfo:{nodeIndex:x,containerElement:l}}},f=function(t,e){var n,o,i,a,s=t.offset,u=r.getDocument(t.node),d=l(u).createTextRange(),p=c(t.node);return p?o=(n=t.node).parentNode:(n=s<(a=t.node.childNodes).length?a[s]:null,o=t.node),(i=u.createElement("span")).innerHTML="&#feff;",n?o.insertBefore(i,n):o.appendChild(i),d.moveToElementText(i),d.collapse(!e),o.removeChild(i),p&&d[e?"moveStart":"moveEnd"]("character",s),d};(o=function(t){this.textRange=t,this.refresh()}).prototype=new s(document),o.prototype.refresh=function(){var t,e,n,o=d(this.textRange);p(this.textRange)?e=t=h(this.textRange,o,!0,!0).boundaryPosition:(t=(n=h(this.textRange,o,!0,!1)).boundaryPosition,e=h(this.textRange,o,!1,!1,n.nodeInfo).boundaryPosition),this.setStart(t.node,t.offset),this.setEnd(e.node,e.offset)},o.prototype.getName=function(){return"WrappedTextRange"},s.copyComparisonConstants(o);var g=function(t){if(t.collapsed)return f(new a(t.startContainer,t.startOffset),!0);var e=f(new a(t.startContainer,t.startOffset),!0),n=f(new a(t.endContainer,t.endOffset),!1),o=l(s.getRangeDocument(t)).createTextRange();return o.setEndPoint("StartToStart",e),o.setEndPoint("EndToEnd",n),o};if(o.rangeToTextRange=g,o.prototype.toTextRange=function(){return g(this)},t.WrappedTextRange=o,!t.features.implementsDomRange||t.config.preferTextRange){var v=Function("return this;")();void 0===v.Range&&(v.Range=o),t.createNativeRange=function(t){return t=u(t,e,"createNativeRange"),l(t).createTextRange()},t.WrappedRange=o}}t.createRange=function(n){return n=u(n,e,"createRange"),new t.WrappedRange(t.createNativeRange(n))},t.createRangyRange=function(t){return t=u(t,e,"createRangyRange"),new s(t)},i.createAliasForDeprecatedMethod(t,"createIframeRange","createRange"),i.createAliasForDeprecatedMethod(t,"createIframeRangyRange","createRangyRange"),t.addShimListener((function(e){var n=e.document;void 0===n.createRange&&(n.createRange=function(){return t.createRange(n)}),n=e=null}))})),E.createCoreModule("WrappedSelection",["DomRange","WrappedRange"],(function(t,e){t.config.checkSelectionRanges=!0;var n,o,r="boolean",i="number",a=t.dom,s=t.util,l=s.isHostMethod,u=t.DomRange,c=t.WrappedRange,d=t.DOMException,p=a.DomPosition,h=t.features,f="Control",g=a.getDocument,v=a.getBody,y=u.rangesEqual;function m(t){return"string"==typeof t?/^backward(s)?$/i.test(t):!!t}function b(t,n){if(t){if(a.isWindow(t))return t;if(t instanceof Z)return t.win;var o=a.getContentDocument(t,e,n);return a.getWindow(o)}return window}function _(t){return b(t,"getWinSelection").getSelection()}function x(t){return b(t,"getDocSelection").document.selection}function E(t){var e=!1;return t.anchorNode&&(e=1==a.comparePoints(t.anchorNode,t.anchorOffset,t.focusNode,t.focusOffset)),e}var w=l(window,"getSelection"),S=s.isHostObject(document,"selection");h.implementsWinGetSelection=w,h.implementsDocSelection=S;var C=S&&(!w||t.config.preferTextRange);if(C)n=x,t.isSelectionValid=function(t){var e=b(t,"isSelectionValid").document,n=e.selection;return"None"!=n.type||g(n.createRange().parentElement())==e};else{if(!w)return e.fail("Neither document.selection or window.getSelection() detected."),!1;n=_,t.isSelectionValid=function(){return!0}}t.getNativeSelection=n;var M=n();if(!M)return e.fail("Native selection was null (possibly issue 138?)"),!1;var O=t.createNativeRange(document),T=v(document),N=s.areHostProperties(M,["anchorNode","focusNode","anchorOffset","focusOffset"]);h.selectionHasAnchorAndFocus=N;var A=l(M,"extend");h.selectionHasExtend=A;var P=l(M,"setBaseAndExtent");h.selectionHasSetBaseAndExtent=P;var D=typeof M.rangeCount==i;h.selectionHasRangeCount=D;var k=!1,R=!0,I=A?function(e,n){var o=u.getRangeDocument(n),r=t.createRange(o);r.collapseToPoint(n.endContainer,n.endOffset),e.addRange(G(r)),e.extend(n.startContainer,n.startOffset)}:null;s.areHostMethods(M,["addRange","getRangeAt","removeAllRanges"])&&typeof M.rangeCount==i&&h.implementsDomRange&&function(){var e=window.getSelection();if(e){for(var n=e.rangeCount,o=n>1,r=[],i=E(e),s=0;s<n;++s)r[s]=e.getRangeAt(s);var l=a.createTestElement(document,"",!1),u=l.appendChild(document.createTextNode(" ")),c=document.createRange();if(c.setStart(u,1),c.collapse(!0),e.removeAllRanges(),e.addRange(c),R=1==e.rangeCount,e.removeAllRanges(),!o){var d=window.navigator.appVersion.match(/Chrome\/(.*?) /);if(d&&parseInt(d[1])>=36)k=!1;else{var p=c.cloneRange();c.setStart(u,0),p.setEnd(u,3),p.setStart(u,2),e.addRange(c),e.addRange(p),k=2==e.rangeCount}}for(a.removeNode(l),e.removeAllRanges(),s=0;s<n;++s)0==s&&i?I?I(e,r[s]):(t.warn("Rangy initialization: original selection was backwards but selection has been restored forwards because the browser does not support Selection.extend"),e.addRange(r[s])):e.addRange(r[s])}}(),h.selectionSupportsMultipleRanges=k,h.collapsedNonEditableSelectionsSupported=R;var L,j,B=!1;function H(t,e,n){var o=n?"end":"start",r=n?"start":"end";t.anchorNode=e[o+"Container"],t.anchorOffset=e[o+"Offset"],t.focusNode=e[r+"Container"],t.focusOffset=e[r+"Offset"]}function z(t){var e=t.nativeSelection;t.anchorNode=e.anchorNode,t.anchorOffset=e.anchorOffset,t.focusNode=e.focusNode,t.focusOffset=e.focusOffset}function F(t){t.anchorNode=t.focusNode=null,t.anchorOffset=t.focusOffset=0,t.rangeCount=0,t.isCollapsed=!0,t._ranges.length=0,W(t)}function W(t){t.type=0==t.rangeCount?"None":o(t)?"Caret":"Range"}function G(e){var n;return e instanceof u?((n=t.createNativeRange(e.getDocument())).setEnd(e.endContainer,e.endOffset),n.setStart(e.startContainer,e.startOffset)):e instanceof c?n=e.nativeRange:h.implementsDomRange&&e instanceof a.getWindow(e.startContainer).Range&&(n=e),n}function X(t){if(!t.length||1!=t[0].nodeType)return!1;for(var e=1,n=t.length;e<n;++e)if(!a.isAncestorOf(t[0],t[e]))return!1;return!0}function U(t){var n=t.getNodes();if(!X(n))throw e.createError("getSingleElementFromRange: range "+t.inspect()+" did not consist of a single element");return n[0]}function Y(t){return!!t&&void 0!==t.text}function V(t,e){var n=new c(e);t._ranges=[n],H(t,n,!1),t.rangeCount=1,t.isCollapsed=n.collapsed,W(t)}function K(e){if(e._ranges.length=0,"None"==e.docSelection.type)F(e);else{var n=e.docSelection.createRange();if(Y(n))V(e,n);else{e.rangeCount=n.length;for(var o,r=g(n.item(0)),i=0;i<e.rangeCount;++i)(o=t.createRange(r)).selectNode(n.item(i)),e._ranges.push(o);e.isCollapsed=1==e.rangeCount&&e._ranges[0].collapsed,H(e,e._ranges[e.rangeCount-1],!1),W(e)}}}function q(t,n){for(var o=t.docSelection.createRange(),r=U(n),i=g(o.item(0)),a=v(i).createControlRange(),s=0,l=o.length;s<l;++s)a.add(o.item(s));try{a.add(r)}catch(t){throw e.createError("addRange(): Element within the specified Range could not be added to control selection (does it have layout?)")}a.select(),K(t)}function Z(t,e,n){this.nativeSelection=t,this.docSelection=e,this._ranges=[],this.win=n,this.refresh()}function $(t){t.win=t.anchorNode=t.focusNode=t._ranges=null,t.rangeCount=t.anchorOffset=t.focusOffset=0,t.detached=!0,W(t)}T&&l(T,"createControlRange")&&(L=T.createControlRange(),s.areHostProperties(L,["item","add"])&&(B=!0)),h.implementsControlRange=B,o=N?function(t){return t.anchorNode===t.focusNode&&t.anchorOffset===t.focusOffset}:function(t){return!!t.rangeCount&&t.getRangeAt(t.rangeCount-1).collapsed},l(M,"getRangeAt")?j=function(t,e){try{return t.getRangeAt(e)}catch(t){return null}}:N&&(j=function(e){var n=g(e.anchorNode),o=t.createRange(n);return o.setStartAndEnd(e.anchorNode,e.anchorOffset,e.focusNode,e.focusOffset),o.collapsed!==this.isCollapsed&&o.setStartAndEnd(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset),o}),Z.prototype=t.selectionPrototype;var J=[];function Q(t,e){for(var n,o,r=J.length;r--;)if(o=(n=J[r]).selection,"deleteAll"==e)$(o);else if(n.win==t)return"delete"==e?(J.splice(r,1),!0):o;return"deleteAll"==e&&(J.length=0),null}var tt=function(t){if(t&&t instanceof Z)return t.refresh(),t;var e=Q(t=b(t,"getNativeSelection")),o=n(t),r=S?x(t):null;return e?(e.nativeSelection=o,e.docSelection=r,e.refresh()):(e=new Z(o,r,t),J.push({win:t,selection:e})),e};t.getSelection=tt,s.createAliasForDeprecatedMethod(t,"getIframeSelection","getSelection");var et,nt=Z.prototype;function ot(t,n){for(var o,r=g(n[0].startContainer),i=v(r).createControlRange(),a=0,s=n.length;a<s;++a){o=U(n[a]);try{i.add(o)}catch(t){throw e.createError("setRanges(): Element within one of the specified Ranges could not be added to control selection (does it have layout?)")}}i.select(),K(t)}if(!C&&N&&s.areHostMethods(M,["removeAllRanges","addRange"])){nt.removeAllRanges=function(){this.nativeSelection.removeAllRanges(),F(this)};var rt=function(t,e){I(t.nativeSelection,e),t.refresh()};nt.addRange=D?function(e,n){if(B&&S&&this.docSelection.type==f)q(this,e);else if(m(n)&&A)rt(this,e);else{var r;k?r=this.rangeCount:(this.removeAllRanges(),r=0);var i=G(e).cloneRange();try{this.nativeSelection.addRange(i)}catch(t){}if(this.rangeCount=this.nativeSelection.rangeCount,this.rangeCount==r+1){if(t.config.checkSelectionRanges){var a=j(this.nativeSelection,this.rangeCount-1);a&&!y(a,e)&&(e=new c(a))}this._ranges[this.rangeCount-1]=e,H(this,e,it(this.nativeSelection)),this.isCollapsed=o(this),W(this)}else this.refresh()}}:function(t,e){m(e)&&A?rt(this,t):(this.nativeSelection.addRange(G(t)),this.refresh())},nt.setRanges=function(t){if(B&&S&&t.length>1)ot(this,t);else{this.removeAllRanges();for(var e=0,n=t.length;e<n;++e)this.addRange(t[e])}}}else{if(!(l(M,"empty")&&l(O,"select")&&B&&C))return e.fail("No means of selecting a Range or TextRange was found"),!1;nt.removeAllRanges=function(){try{if(this.docSelection.empty(),"None"!=this.docSelection.type){var t;if(this.anchorNode)t=g(this.anchorNode);else if(this.docSelection.type==f){var e=this.docSelection.createRange();e.length&&(t=g(e.item(0)))}t&&(v(t).createTextRange().select(),this.docSelection.empty())}}catch(t){}F(this)},nt.addRange=function(e){this.docSelection.type==f?q(this,e):(t.WrappedTextRange.rangeToTextRange(e).select(),this._ranges[0]=e,this.rangeCount=1,this.isCollapsed=this._ranges[0].collapsed,H(this,e,!1),W(this))},nt.setRanges=function(t){this.removeAllRanges();var e=t.length;e>1?ot(this,t):e&&this.addRange(t[0])}}if(nt.getRangeAt=function(t){if(t<0||t>=this.rangeCount)throw new d("INDEX_SIZE_ERR");return this._ranges[t].cloneRange()},C)et=function(e){var n;t.isSelectionValid(e.win)?n=e.docSelection.createRange():(n=v(e.win.document).createTextRange()).collapse(!0),e.docSelection.type==f?K(e):Y(n)?V(e,n):F(e)};else if(l(M,"getRangeAt")&&typeof M.rangeCount==i)et=function(e){if(B&&S&&e.docSelection.type==f)K(e);else if(e._ranges.length=e.rangeCount=e.nativeSelection.rangeCount,e.rangeCount){for(var n=0,r=e.rangeCount;n<r;++n)e._ranges[n]=new t.WrappedRange(e.nativeSelection.getRangeAt(n));H(e,e._ranges[e.rangeCount-1],it(e.nativeSelection)),e.isCollapsed=o(e),W(e)}else F(e)};else{if(!N||typeof M.isCollapsed!=r||typeof O.collapsed!=r||!h.implementsDomRange)return e.fail("No means of obtaining a Range or TextRange from the user's selection was found"),!1;et=function(t){var e,n=t.nativeSelection;n.anchorNode?(e=j(n,0),t._ranges=[e],t.rangeCount=1,z(t),t.isCollapsed=o(t),W(t)):F(t)}}nt.refresh=function(t){var e=t?this._ranges.slice(0):null,n=this.anchorNode,o=this.anchorOffset;if(et(this),t){var r=e.length;if(r!=this._ranges.length)return!0;if(this.anchorNode!=n||this.anchorOffset!=o)return!0;for(;r--;)if(!y(e[r],this._ranges[r]))return!0;return!1}};var it,at=function(t,e){var n=t.getAllRanges();t.removeAllRanges();for(var o=0,r=n.length;o<r;++o)y(e,n[o])||t.addRange(n[o]);t.rangeCount||F(t)};function st(t,e){if(t.win.document!=g(e))throw new d("WRONG_DOCUMENT_ERR")}function lt(t,e){if(e<0||e>(a.isCharacterDataNode(t)?t.length:t.childNodes.length))throw new d("INDEX_SIZE_ERR")}function ut(e){return function(n,o){var r;this.rangeCount?(r=this.getRangeAt(0))["set"+(e?"Start":"End")](n,o):(r=t.createRange(this.win.document)).setStartAndEnd(n,o),this.setSingleRange(r,this.isBackward())}}function ct(t){var e=[],n=new p(t.anchorNode,t.anchorOffset),o=new p(t.focusNode,t.focusOffset),r="function"==typeof t.getName?t.getName():"Selection";if(void 0!==t.rangeCount)for(var i=0,a=t.rangeCount;i<a;++i)e[i]=u.inspect(t.getRangeAt(i));return"["+r+"(Ranges: "+e.join(", ")+")(anchor: "+n.inspect()+", focus: "+o.inspect()+"]"}nt.removeRange=B&&S?function(t){if(this.docSelection.type==f){for(var e=this.docSelection.createRange(),n=U(t),o=g(e.item(0)),r=v(o).createControlRange(),i=!1,a=0,s=e.length;a<s;++a)e.item(a)!==n||i?r.add(e.item(a)):i=!0;r.select(),K(this)}else at(this,t)}:function(t){at(this,t)},!C&&N&&h.implementsDomRange?(it=E,nt.isBackward=function(){return it(this)}):it=nt.isBackward=function(){return!1},nt.isBackwards=nt.isBackward,nt.toString=function(){for(var t=[],e=0,n=this.rangeCount;e<n;++e)t[e]=""+this._ranges[e];return t.join("")},nt.collapse=function(e,n){st(this,e);var o=t.createRange(e);o.collapseToPoint(e,n),this.setSingleRange(o),this.isCollapsed=!0},nt.collapseToStart=function(){if(!this.rangeCount)throw new d("INVALID_STATE_ERR");var t=this._ranges[0];this.collapse(t.startContainer,t.startOffset)},nt.collapseToEnd=function(){if(!this.rangeCount)throw new d("INVALID_STATE_ERR");var t=this._ranges[this.rangeCount-1];this.collapse(t.endContainer,t.endOffset)},nt.selectAllChildren=function(e){st(this,e);var n=t.createRange(e);n.selectNodeContents(e),this.setSingleRange(n)},P?nt.setBaseAndExtent=function(t,e,n,o){this.nativeSelection.setBaseAndExtent(t,e,n,o),this.refresh()}:A&&(nt.setBaseAndExtent=function(e,n,o,r){lt(e,n),lt(o,r),st(this,e),st(this,o);var i=t.createRange(node),s=-1==a.comparePoints(e,n,o,r);s?i.setStartAndEnd(o,r,e,n):i.setStartAndEnd(e,n,o,r),this.setSingleRange(i,s)}),nt.deleteFromDocument=function(){if(B&&S&&this.docSelection.type==f){for(var t,e=this.docSelection.createRange();e.length;)t=e.item(0),e.remove(t),a.removeNode(t);this.refresh()}else if(this.rangeCount){var n=this.getAllRanges();if(n.length){this.removeAllRanges();for(var o=0,r=n.length;o<r;++o)n[o].deleteContents();this.addRange(n[r-1])}}},nt.eachRange=function(t,e){for(var n=0,o=this._ranges.length;n<o;++n)if(t(this.getRangeAt(n)))return e},nt.getAllRanges=function(){var t=[];return this.eachRange((function(e){t.push(e)})),t},nt.setSingleRange=function(t,e){this.removeAllRanges(),this.addRange(t,e)},nt.callMethodOnEachRange=function(t,e){var n=[];return this.eachRange((function(o){n.push(o[t].apply(o,e||[]))})),n},nt.setStart=ut(!0),nt.setEnd=ut(!1),t.rangePrototype.select=function(t){tt(this.getDocument()).setSingleRange(this,t)},nt.changeEachRange=function(t){var e=[],n=this.isBackward();this.eachRange((function(n){t(n),e.push(n)})),this.removeAllRanges(),n&&1==e.length?this.addRange(e[0],"backward"):this.setRanges(e)},nt.containsNode=function(t,e){return this.eachRange((function(n){return n.containsNode(t,e)}),!0)||!1},nt.getBookmark=function(t){return{backward:this.isBackward(),rangeBookmarks:this.callMethodOnEachRange("getBookmark",[t])}},nt.moveToBookmark=function(e){for(var n,o,r=[],i=0;n=e.rangeBookmarks[i++];)(o=t.createRange(this.win)).moveToBookmark(n),r.push(o);e.backward?this.setSingleRange(r[0],"backward"):this.setRanges(r)},nt.saveRanges=function(){return{backward:this.isBackward(),ranges:this.callMethodOnEachRange("cloneRange")}},nt.restoreRanges=function(t){this.removeAllRanges();for(var e,n=0;e=t.ranges[n];++n)this.addRange(e,t.backward&&0==n)},nt.toHtml=function(){var t=[];return this.eachRange((function(e){t.push(u.toHtml(e))})),t.join("")},h.implementsTextRange&&(nt.getNativeTextRange=function(){var n;if(n=this.docSelection){var o=n.createRange();if(Y(o))return o;throw e.createError("getNativeTextRange: selection is a control selection")}if(this.rangeCount>0)return t.WrappedTextRange.rangeToTextRange(this.getRangeAt(0));throw e.createError("getNativeTextRange: selection contains no range")}),nt.getName=function(){return"WrappedSelection"},nt.inspect=function(){return ct(this)},nt.detach=function(){Q(this.win,"delete"),$(this)},Z.detachAll=function(){Q(null,"deleteAll")},Z.inspect=ct,Z.isDirectionBackward=m,t.Selection=Z,t.selectionPrototype=nt,t.addShimListener((function(t){void 0===t.getSelection&&(t.getSelection=function(){return tt(t)}),t=null}))}));var B=!1,H=function(t){B||(B=!0,!E.initialized&&E.config.autoInitialize&&N())};return _&&("complete"==document.readyState?H():(s(document,"addEventListener")&&document.addEventListener("DOMContentLoaded",H,!1),y(window,"load",H))),E}()}(PT);var DT=AT,kT={toolbar:{allowMultiParagraphSelection:!0,buttons:["bold","colorpicker","italic","underline","strikethrough","quote","justifyLeft","justifyCenter","justifyRight","justifyFull","superscript","subscript","orderedlist","unorderedlist","pre","removeFormat","outdent","indent","h2","h3"],standardizeSelectionStart:!1,updateOnEmptySelection:!1},placeholder:{text:"请输入内容",hideOnClick:!0},disableEditing:!0},RT=hT.extensions.button.extend({name:"colorpicker",tagNames:["mark"],contentDefault:"<b>Color</b>",aria:"Color Picker",action:"colorPicker",init:function(){var t=this;DT.init(),hT.extensions.button.prototype.init.call(this),this.colorPicker=new TT({parent:this.button,color:"#000",onDone:function(e){t.coloredText&&t.coloredText.isAppliedToSelection()&&t.coloredText.undoToSelection(),t.coloredText=DT.createClassApplier("colored",{elementTagName:"span",elementProperties:{style:{color:e.hex}},normalize:!0}),t.coloredText.toggleSelection(),t.base.checkContentChanged(),t.setInactive()}})},getButton:function(){return this.button},handleClick:function(){this.setActive(),this.colorPicker.show()},isAlreadyApplied:function(t){return"mark"===t.nodeName.toLowerCase()},isActive:function(){return this.button.classList.contains("medium-editor-button-active")},setInactive:function(){this.button.classList.remove("medium-editor-button-active")},setActive:function(){this.button.classList.add("medium-editor-button-active")}}),IT=function(t){function e(e){var n=t.call(this,e)||this;n.labelMap=new Map;var o=e.lf,r=e.graphModel;return n.lf=o,n.graphModel=r,n.state={tick:0},n}return h(e,t),e.prototype.componentDidMount=function(){var t=this,e=this.props.graphModel;this.editor=new hT(".lf-label-editor",ag(kT,{autoLink:!0,extensions:{colorPicker:new RT}})),e.eventCenter.on("text:update,node:mousemove,node:resize,node:rotate,node:drag,label:drop,node:drop",(function(){})),e.eventCenter.on("node:properties-change,node:properties-delete",(function(){t.setState({tick:t.state.tick+1})}))},e.prototype.componentDidUpdate=function(){var t;this.editor&&this.editor.elements.length>0?this.editor.addElements(".lf-label-editor"):(null===(t=this.editor)||void 0===t||t.destroy(),this.editor=new hT(".lf-label-editor",ag(kT,{autoLink:!0,extensions:{colorPicker:new RT}})))},e.prototype.componentWillUnmount=function(){var t;null===(t=this.editor)||void 0===t||t.destroy()},e.prototype.getLabels=function(){var t=this,e=this.props,n=e.lf.extension,o=e.graphModel,r=x(x([],_(o.nodes),!1),_(o.edges),!1);if(n.label){var i=[];return oh(r,(function(e){var n,r;oh(null!==(r=null===(n=e.getData().properties)||void 0===n?void 0:n._label)&&void 0!==r?r:[],(function(n){var r=t.labelMap,a=new cT(n,e,o);r.set(a.id,a),i.push(xr(lT,{label:a,element:e,graphModel:o},a.id))}))})),i}return null},e.prototype.render=function(){return xr("foreignObject",{id:"lf-label-overlay",class:"lf-label-overlay",children:this.getLabels()})},e.toolName="label-edit-tool",e=v([yC],e)}(ho);var LT=function(){function t(t){var e,n,o,r=t.lf,i=t.options;this.labelInitPositionMap=new Map,this.lf=r,this.options=null!=i?i:{},this.textOverflowMode=null!==(e=i.textOverflowMode)&&void 0!==e?e:"default",this.isMultiple=null===(n=i.isMultiple)||void 0===n||n,this.labelWidth=i.labelWidth,this.maxCount=null!==(o=i.maxCount)&&void 0!==o?o:1/0,r.graphModel.editConfigModel.updateTextMode(Am.LABEL),this.addEventListeners(),r.tool.registerTool(IT.toolName,IT),r.tool.disableTool("text-edit-tool")}return t.prototype.formatConfig=function(t,e){var n=t.editConfigModel,o=n.nodeTextEdit,r=n.edgeTextEdit,i=n.nodeTextDraggable,a=n.edgeTextDraggable,s=this,l=s.textOverflowMode,u=s.isMultiple,c=s.maxCount,d=s.labelWidth,p=e.text,h=e.zIndex,g=e.properties,v=g._label,y=g._labelOption,m=v,b=void 0===y?{}:y,_=b.isMultiple,x=b.maxCount,E=[];if(Fr(m)){var w=null!=x?x:c;E=u&&_?m.length>w?m.slice(0,w):m:[m[0]]}else if(Jr(m))E=[m];else if("string"==typeof m||!m){var S=f(f({},p),{content:m||p.value,draggable:"edge"===e.BaseType?a:i});E=S.value?[S]:[]}return"edge"===e.BaseType&&(E=Ih(E,(function(t){var e=t.x,n=t.y;return console.log("x, y ---\x3e>>",e,n),t}))),Ih(E,(function(t){t.id||(t.id=g_());var n=t.value,s=t.content,u=t.vertical,c=t.editable,p=t.draggable,g=t.textOverflowMode,v="node"===e.BaseType?o:r,y="node"===e.BaseType?i:a;return f(f({},t),{zIndex:h,labelWidth:d,content:null!=s?s:n,vertical:null!=u&&u,editable:v&&c,draggable:y&&p,textOverflowMode:null!=g?g:l})}))},t.prototype.setupLabels=function(t){var e=this;oh(t.sortElements,(function(n){e.rewriteInnerMethods(n);var o=e.formatConfig(t,n);n.setProperty("_label",o)}))},t.prototype.addLabel=function(t,e){var n,o,r,i=this.maxCount,a=t.properties,s=null!==(n=a._label)&&void 0!==n?n:[],l=null!==(o=a._labelOption)&&void 0!==o?o:{},u=s.length,c={id:g_(),x:e.x,y:e.y,content:"Label".concat(u+1),value:"Label".concat(u+1),style:{},draggable:!0,editable:!0,vertical:!1};u>=(null!==(r=null==l?void 0:l.maxCount)&&void 0!==r?r:i)||(s.push(c),t.setProperty("_label",s))},t.prototype.addEventListeners=function(){var t=this,e=this.lf.graphModel,n=e.eventCenter,o=e.editConfigModel;n.on("graph:rendered",(function(e){var n=e.graphModel;t.setupLabels(n)})),n.on("node:dbclick,edge:dbclick",(function(n){var r=n.e,i=n.data,a=e.getElement(i.id),s=e.getPointByClient({x:r.clientX,y:r.clientY}).canvasOverlayPosition,l={x:s.x,y:s.y};a&&o.textMode===Am.LABEL&&t.addLabel(a,l)})),n.on("node:resize",(function(t){var e,n,o=t.preData,r=t.data,i=t.model,a=null!==(e=o.properties)&&void 0!==e?e:{},s=a.width,l=a.height,u=a._label,c=void 0===u?[]:u,d=null!==(n=r.properties)&&void 0!==n?n:{},p=d.width,h=d.height;if(s&&l&&p&&h){var g={x:o.x,y:o.y,width:s,height:l},v={x:r.x,y:r.y,width:p,height:h},y=Ih(c,(function(t){var e,n,o,r,i,a,s,l,u,c,d,p=t.x,h=t.y,y=(n=v,o={x:p,y:h},r=(e=g).x,i=e.y,a=e.width,s=e.height,l=n.x,u=n.y,c=n.width,d=n.height,{x:l+(o.x-r)/a*c,y:u+(o.y-i)/s*d});return f(f({},t),y)}));i.setProperty("_label",y)}})),n.on("node:rotate",(function(e){var n=e.model,o=n.x,r=n.y,i=n.rotate,a=n.properties._label,s={x:o,y:r},l=Ih(void 0===a?[]:a,(function(e){if(!e.id)return e;var n={x:e.x,y:e.y};t.labelInitPositionMap.has(e.id)?n=t.labelInitPositionMap.get(e.id):t.labelInitPositionMap.set(e.id,n);var o=i*(180/Math.PI);o<0&&(o+=360);var r=o*(Math.PI/180),a=function(t,e,n){var o=e.x,r=e.y,i=t.x-o,a=t.y-r;return{x:i*Math.cos(n)-a*Math.sin(n)+o,y:i*Math.sin(n)+a*Math.cos(n)+r}}(n,s,r);return f(f(f({},e),a),{rotate:o})}));n.setProperty("_label",l)}))},t.prototype.rewriteInnerMethods=function(t){t.moveText=function(e,n){if(t.text){var o=t.text,r=o.x,i=o.y,a=o.value,s=o.draggable,l=o.editable;t.text={value:a,editable:l,draggable:s,x:r+e,y:i+n};var u=_d(t.getProperties());if(Fr(u._label)){var c=Ih(u._label,(function(t){return f(f({},t),{x:t.x+e,y:t.y+n})}));null==t||t.setProperty("_label",c)}}}},t.prototype.updateTextMode=function(t){var e=this.lf.graphModel.editConfigModel;t!==e.textMode&&(e.updateTextMode(t),t===Am.LABEL?(this.lf.tool.enableTool(IT.toolName),this.lf.tool.disableTool("text-edit-tool")):t===Am.TEXT&&(this.lf.tool.enableTool("text-edit-tool"),this.lf.tool.disableTool(IT.toolName)))},t.prototype.render=function(){},t.prototype.destroy=function(){},t.pluginName="label",t}(),jT={};function BT(t){return t.startsWith("data:text/plain")}function HT(t){return y(this,void 0,void 0,(function(){return m(this,(function(e){return jT[t]?[2,jT[t]]:[2,new Promise((function(e,n){try{fetch(t).then((function(t){return t.blob()})).then((function(o){var r=new FileReader;r.onloadend=function(){e(jT[t]=r.result)},r.onerror=n,r.readAsDataURL(o)})).catch((function(){e(jT[t]=t)}))}catch(e){return jT[t]=t}}))]}))}))}function zT(t,e){return y(this,void 0,void 0,(function(){var n,o,r;return m(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),(n=t.getAttribute(e)||"").startsWith("data:")?[2]:[4,HT(n)];case 1:return BT(o=i.sent())?[2]:(t.setAttribute(e,o),[3,3]);case 2:return r=i.sent(),console.error(r),[3,3];case 3:return[2]}}))}))}function FT(t,e){return y(this,void 0,void 0,(function(){var n,o;return m(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),e.startsWith("data:")?[2]:[4,HT(e)];case 1:return BT(n=r.sent())?[2]:(t.style.backgroundImage="url(".concat(n,")"),[3,3]);case 2:return o=r.sent(),console.error(o),[3,3];case 3:return[2]}}))}))}function WT(t){return y(this,void 0,void 0,(function(){var e,n,o,r,i,a,s,l,u;return m(this,(function(c){switch(c.label){case 0:for(e=[t],o=[];e.length;)(n=e.shift()).children.length&&e.push.apply(e,x([],_(n.children),!1)),n instanceof HTMLElement&&(r=n.style,i=r.background,a=r.backgroundImage,(s=i.match(/url\(["']?(.*?)["']?\)/))&&s[1]&&(u=s[1],o.push(FT(n,u))),(l=a.match(/url\(["']?(.*?)["']?\)/))&&l[1]&&(u=l[1],o.push(FT(n,u)))),n instanceof HTMLImageElement?o.push(zT(n,"src")):n instanceof SVGImageElement&&o.push(zT(n,"href"));return[4,Promise.all(o)];case 1:return c.sent(),[2]}}))}))}function GT(t,e,n){var o=document.createElement("canvas");o.width=e,o.height=n;var r=o.getContext("2d");return r&&r.drawImage(t,0,0,t.width,t.height,0,0,e,n),o}var XT=function(){function t(t){var e=t.lf,n=this;this.lf=e,this.customCssRules="",this.useGlobalRules=!0,e.getSnapshot=function(t,e){return y(n,void 0,void 0,(function(){return m(this,(function(n){switch(n.label){case 0:return[4,this.getSnapshot(t,e)];case 1:return[2,n.sent()]}}))}))},e.getSnapshotBlob=function(t,e){return y(n,void 0,void 0,(function(){return m(this,(function(n){switch(n.label){case 0:return[4,this.getSnapshotBlob(t,e)];case 1:return[2,n.sent()]}}))}))},e.getSnapshotBase64=function(t,e){return y(n,void 0,void 0,(function(){return m(this,(function(n){switch(n.label){case 0:return[4,this.getSnapshotBase64(t,e)];case 1:return[2,n.sent()]}}))}))}}return t.prototype.getSvgRootElement=function(t){return t.container.querySelector(".lf-canvas-overlay")},t.prototype.triggerDownload=function(t){var e=new MouseEvent("click",{view:document.defaultView,bubbles:!1,cancelable:!0}),n=document.createElement("a");n.setAttribute("download",this.fileName),n.setAttribute("href",t),n.setAttribute("target","_blank"),n.dispatchEvent(e)},t.prototype.removeAnchor=function(t){for(var e=t.childNodes,n=t.childNodes&&t.childNodes.length,o=0;o<n;o++){var r=e[o];(r.classList&&Array.from(r.classList)||[]).indexOf("lf-anchor")>-1&&(t.removeChild(t.childNodes[o]),n--,o--)}},t.prototype.removeRotateControl=function(t){for(var e=t.childNodes,n=t.childNodes&&t.childNodes.length,o=0;o<n;o++){var r=e[o];(r.classList&&Array.from(r.classList)||[]).indexOf("lf-rotate-control")>-1&&(t.removeChild(t.childNodes[o]),n--,o--)}},t.prototype.getSnapshot=function(t,e){return y(this,void 0,void 0,(function(){var n,o,r,i,a=this;return m(this,(function(s){switch(s.label){case 0:return n=this.lf.graphModel.getPartial(),o=(null!=e?e:{}).partial,r=void 0===o?n:o,i=this.lf.getEditConfig(),this.lf.updateEditConfig({isSilentMode:!0,stopScrollGraph:!0,stopMoveGraph:!0}),n===r?[3,1]:(this.lf.graphModel.setPartial(r),this.lf.graphModel.eventCenter.once("graph:updated",(function(){return y(a,void 0,void 0,(function(){return m(this,(function(o){switch(o.label){case 0:return[4,this.snapshot(t,e)];case 1:return o.sent(),this.lf.graphModel.setPartial(n),[2]}}))}))})),[3,3]);case 1:return[4,this.snapshot(t,e)];case 2:s.sent(),s.label=3;case 3:return this.lf.updateEditConfig(i),[2]}}))}))},t.prototype.snapshot=function(t,e){return y(this,void 0,void 0,(function(){var n,o,r,i,a,s,l,u,c,d=this;return m(this,(function(p){switch(p.label){case 0:return o=(n=null!=e?e:{}).fileType,r=void 0===o?"png":o,i=n.quality,this.fileName="".concat(null!=t?t:"logic-flow.".concat(Date.now()),".").concat(r),[4,WT(a=this.getSvgRootElement(this.lf))];case 1:return p.sent(),"svg"===r?(s=this.cloneSvg(a),l=(new XMLSerializer).serializeToString(s),u=new Blob([l],{type:"image/svg+xml;charset=utf-8"}),c=URL.createObjectURL(u),this.triggerDownload(c)):this.getCanvasData(a,null!=e?e:{}).then((function(t){var e=t.toDataURL("image/".concat(r),i).replace("image/".concat(r),"image/octet-stream");d.triggerDownload(e)})),[2]}}))}))},t.prototype.getSnapshotBase64=function(t,e){return y(this,void 0,void 0,(function(){var n,o=this;return m(this,(function(r){switch(r.label){case 0:return[4,WT(n=this.getSvgRootElement(this.lf))];case 1:return r.sent(),[2,new Promise((function(r){o.getCanvasData(n,{backgroundColor:t}).then((function(t){var n=t.toDataURL("image/".concat(null!=e?e:"png"));r({data:n,width:t.width,height:t.height})}))}))]}}))}))},t.prototype.getSnapshotBlob=function(t,e){return y(this,void 0,void 0,(function(){var n,o=this;return m(this,(function(r){switch(r.label){case 0:return[4,WT(n=this.getSvgRootElement(this.lf))];case 1:return r.sent(),[2,new Promise((function(r){o.getCanvasData(n,{backgroundColor:t}).then((function(t){t.toBlob((function(e){r({data:e,width:t.width,height:t.height})}),"image/".concat(null!=e?e:"png"))}))}))]}}))}))},t.prototype.getClassRules=function(){var t="";if(this.useGlobalRules)for(var e=document.styleSheets,n=0;n<e.length;n++){var o=e[n];try{for(var r=0;r<o.cssRules.length;r++)t+=o.cssRules[r].cssText}catch(t){console.log("CSS scripts from different sources have been filtered out")}}return this.customCssRules&&(t+=this.customCssRules),t},t.prototype.getCanvasData=function(t,e){return y(this,void 0,void 0,(function(){var n,o,r,i,a,s,l,u,c,d,p,h,f,g,v,y,b,_,x,E,w,S,C,M,O,T;return m(this,(function(m){return n=e.width,o=e.height,r=e.backgroundColor,i=e.padding,a=void 0===i?40:i,s=this.cloneSvg(t,!1),(l=window.devicePixelRatio||1)<1&&(l=1),u=this.lf.graphModel.rootEl.querySelector(".lf-base"),c=u.getBoundingClientRect(),d=this.lf.container.querySelector(".lf-canvas-overlay"),p=d.getBoundingClientRect(),h=c.x-p.x,f=c.y-p.y,g=this.lf.graphModel,v=g.transformModel,y=v.SCALE_X,b=v.SCALE_Y,_=v.TRANSLATE_X,x=v.TRANSLATE_Y,s.lastChild.style.transform="matrix(1, 0, 0, 1, ".concat((-h+_)*(1/y),", ").concat((-f+x)*(1/b),")"),E=Math.ceil(c.width/y),w=Math.ceil(c.height/b),(S=document.createElement("canvas")).style.width="".concat(E,"px"),S.style.height="".concat(w,"px"),S.width=E*l+2*a,S.height=w*l+2*a,(C=S.getContext("2d"))&&(C.clearRect(0,0,S.width,S.height),C.scale(l,l),r?(C.fillStyle=r,C.fillRect(0,0,S.width,S.height)):C.clearRect(0,0,S.width,S.height)),M=new Image,(O=document.createElement("style")).innerHTML=this.getClassRules(),(T=document.createElement("foreignObject")).appendChild(O),s.appendChild(T),[2,new Promise((function(t){M.onload=function(){var e=navigator.userAgent.indexOf("Firefox")>-1;try{e?createImageBitmap(M,{resizeWidth:n&&o?GT(S,n,o).width:S.width,resizeHeight:n&&o?GT(S,n,o).height:S.height}).then((function(e){null==C||C.drawImage(e,a/l,a/l),t(n&&o?GT(S,n,o):S)})):(null==C||C.drawImage(M,a/l,a/l),t(n&&o?GT(S,n,o):S))}catch(e){null==C||C.drawImage(M,a/l,a/l),t(n&&o?GT(S,n,o):S)}};var e="data:image/svg+xml;charset=utf-8,".concat((new XMLSerializer).serializeToString(s)).replace(/\n/g,"").replace(/\t/g,"").replace(/#/g,"%23");M.src=e}))]}))}))},t.prototype.cloneSvg=function(t,e){var n,o=this;void 0===e&&(e=!0);var r=t.cloneNode(!0),i=r.lastChild,a=null===(n=null==i?void 0:i.childNodes)||void 0===n?void 0:n.length;if(a)for(var s=0;s<a;s++){var l=null==i?void 0:i.childNodes[s],u=l.classList&&Array.from(l.classList);if(u&&u.indexOf("lf-base")<0)null==i||i.removeChild(i.childNodes[s]),a--,s--;else{var c=null==i?void 0:i.childNodes[s];c&&c.childNodes.forEach((function(t){var e=t;o.removeAnchor(e.firstChild),o.removeRotateControl(e.firstChild)}))}}if(e){var d=document.createElement("style");d.innerHTML=this.getClassRules();var p=document.createElement("foreignObject");p.appendChild(d),r.appendChild(p)}return r},t.pluginName="snapshot",t}(),UT=function(){function t(t){var e=t.lf,n=this;this.lf=e,this.paths=[],e.getPathes=function(){if(!n.startNodeType)throw new Error("需要预先指定开始节点类型");return n.getPathes()},e.setRawPaths=function(t){n.setPathes(t)},e.getRawPathes=function(){return n.paths},e.setStartNodeType=function(t){n.startNodeType=t}}return t.prototype.setPathes=function(t){this.paths=t.map((function(t){return{routeId:t.routeId,name:t.name,elements:t.elements,type:t.type,similarElement:null,weight:0}}))},t.prototype.getPathes=function(){var t=this,e=this.lf.getGraphRawData(),n=new Map,o=[];e.nodes.forEach((function(e){n.set(e.id,{id:e.id,data:e,nextNodes:[]}),e.type===t.startNodeType&&o.push(e.id)})),e.edges.forEach((function(t){var e=n.get(t.sourceNodeId);null==e||e.nextNodes.push(t.targetNodeId)}));var r=[];return o.forEach((function(e){var o=n.get(e);o&&(r=r.concat(t.findPathElements(o,n,[])))})),this.getNewPathes(r)},t.prototype.findPathElements=function(t,e,n){void 0===n&&(n=[]);var o=x([],_(n),!1);if(o.push(t.id),0===t.nextNodes.length)return[o];for(var r=[],i=0;i<t.nextNodes.length;i++){var a=e.get(t.nextNodes[i]),s=void 0;if(a){var l=o.indexOf(a.id);s=-1!==l?[x(x([],_(o.slice(l)),!1),[a.id],!1)]:this.findPathElements(a,e,x([],_(o),!1)),r=r.concat(s)}}return r},t.prototype.getNewPathes=function(t){var e=this,n=[],o=new Set;t.forEach((function(t){var r=e.getNewId("path"),i=e.getNewId("路径"),a=e.isLoopPath(t),s=t.join(",");o.has(s)||(o.add(s),n.push({routeId:r,name:i,elements:t,type:a,weight:0,similarElement:""}))}));var r=JSON.parse(JSON.stringify(this.paths));return n.forEach((function(t){for(var n=0;n<r.length;n++){var o=r[n],i=e.similar2Path(x([],_(t.elements),!1),x([],_(o.elements),!1));i>t.weight&&o.weight<=i&&(t.weight=i,t.similarElement=o,i===o.weight&&o.similarElement?(o.similarElement.similarElement=null,o.similarElement.weight=0,o.similarElement=null,o.weight=0):(o.similarElement=t,o.weight=i))}})),n.forEach((function(t){t.similarElement&&t.similarElement.similarElement===t&&(t.routeId=t.similarElement.routeId,t.name=t.similarElement.name),delete t.similarElement,delete t.weight})),this.setPathes(n),n},t.prototype.similar2Path=function(t,e){var n=0,o=t.length+e.length;t.sort(),e.sort();for(var r=t.shift(),i=e.shift();void 0!==r&&void 0!==i;)r===i?(n++,r=t.shift(),i=e.shift()):r<i?r=t.shift():r>i&&(i=e.shift());return n/o*200},t.prototype.getNewId=function(t){return"".concat(t,"_").concat(_C())},t.prototype.isLoopPath=function(t){var e=t.length;return t.indexOf(t[e-1])!==e-1?1:0},t.pluginName="flowPath",t}(),YT=-1,VT=0,KT=1,qT=function(){function t(t){var e=t.lf,n=this;this.levelHeight=[],this.newNodeMap=new Map,this.lf=e,this.trunk=[],e.layout=function(t){var e=n.lf.getGraphRawData();n.lf.setStartNodeType(t);var o=n.lf.getPathes();return n.levelHeight=[],n.newNodeMap=new Map,n.layout(e,o)}}return t.prototype.layout=function(t,e){var n=this,o=[];e.forEach((function(t){var e=t.elements;e.length>o.length?o=e:e.length===o.length&&JSON.stringify(e)===JSON.stringify(n.trunk)&&(o=n.trunk)})),this.trunk=o;for(var r=this.formatData(t),i={nodes:[],edges:[]},a=o.length-1;a>=0;a--)this.setNodePosition(o[a],r,i,a,1);this.lf.graphModel.graphDataToModel(i)},t.prototype.setNodePosition=function(t,e,n,o,r){var i=this,a=e[t],s=a.text,l=a.type,u=a.next,c=a.properties,d=160*o+40,p=120*r,h={id:t,x:d,text:s,y:p,type:l,properties:c};return s&&"object"==typeof s&&(h.text=f(f({},s),{x:d+s.x,y:p+s.y})),this.newNodeMap.set(h.id,{x:h.x,y:h.y,type:l}),n.nodes.push(h),a.isFixed=!0,this.addLevelHeight(o,1),u&&u.length>0&&u.forEach((function(r){if(!e[r.nodeId].isFixed){var a=i.getLevelHeight(o+1);i.addLevelHeight(o,1),i.setNodePosition(r.nodeId,e,n,o+1,a+1)}n.edges.push(f({id:r.edgeId,type:r.edgeType,sourceNodeId:t,targetNodeId:r.nodeId,properties:r.properties,text:r.text},i.getEdgeDataPoints(t,r.nodeId)))})),h},t.prototype.getEdgeDataPoints=function(t,e){var n=this.newNodeMap.get(t),o=this.newNodeMap.get(e),r=this.getShape(t),i=r.width,a=r.height,s=this.getShape(e),l=s.width,u=s.height,c=this.getRelativePosition(n,o),d={x:n.x,y:n.y},p={x:o.x,y:o.y};switch(c){case VT:d.x=n.x+i/2,p.x=o.x-l/2;break;case YT:d.y=n.y+a/2,p.x=o.x-l/2;break;case KT:d.x=n.x+i/2,p.y=o.y+u/2}return{startPoint:d,endPoint:p}},t.prototype.getRelativePosition=function(t,e){var n=t.y,o=e.y;return n<o?-1:n===o?0:1},t.prototype.getShape=function(t){var e,n,o=this.lf.getNodeModelById(t);return{height:null!==(e=null==o?void 0:o.height)&&void 0!==e?e:0,width:null!==(n=null==o?void 0:o.width)&&void 0!==n?n:0}},t.prototype.formatData=function(t){var e=t.nodes.reduce((function(t,e){var n=e.type,o=e.properties,r=e.text,i=e.x,a=e.y;return r&&"object"==typeof r&&(r.x=r.x-i,r.y=r.y-a),t[e.id]={type:n,properties:o,text:r,prev:[],next:[]},t}),{});return t.edges.forEach((function(t){var n=t.sourceNodeId,o=t.targetNodeId,r=t.id,i=t.properties,a=t.text,s=a;"object"==typeof a&&(s=a.value),e[n].next.push({edgeId:r,nodeId:o,edgeType:t.type,properties:i,text:s}),e[o].prev.push({edgeId:r,nodeId:n,properties:i,text:s})})),e},t.prototype.addLevelHeight=function(t,e,n){void 0===e&&(e=1),void 0===n&&(n=!1);var o=this.levelHeight[t];o||(o={positiveHeight:0,negativeHeight:0},this.levelHeight[t]=o),n?o.negativeHeight-=e:o.positiveHeight+=e},t.prototype.getLevelHeight=function(t,e){void 0===e&&(e=!1);var n=this.levelHeight[t];return n?e?n.negativeHeight:n.positiveHeight:0},t.pluginName="AutoLayout",t}(),ZT=function(){function t(t){var e=t.lf,n=this;this.controlItems=[{key:"zoom-out",iconClass:"lf-control-zoomOut",title:"缩小流程图",text:"缩小",onClick:function(){n.lf.zoom(!1)}},{key:"zoom-in",iconClass:"lf-control-zoomIn",title:"放大流程图",text:"放大",onClick:function(){n.lf.zoom(!0)}},{key:"reset",iconClass:"lf-control-fit",title:"恢复流程原有尺寸",text:"适应",onClick:function(){n.lf.resetZoom()}},{key:"undo",iconClass:"lf-control-undo",title:"回到上一步",text:"上一步",onClick:function(){n.lf.undo()}},{key:"redo",iconClass:"lf-control-redo",title:"移到下一步",text:"下一步",onClick:function(){n.lf.redo()}}],this.lf=e}return t.prototype.render=function(t,e){this.destroy();var n=this.getControlTool();this.toolEl=n,e.appendChild(n),this.domContainer=e},t.prototype.destroy=function(){this.domContainer&&this.toolEl&&this.domContainer.contains(this.toolEl)&&this.domContainer.removeChild(this.toolEl)},t.prototype.addItem=function(t){this.controlItems.push(t)},t.prototype.removeItem=function(t){var e=this.controlItems.findIndex((function(e){return e.key===t}));return-1==e?null:this.controlItems.splice(e,1)[0]},t.prototype.getControlTool=function(){var t=this,e="lf-control-item",n="lf-control-item disabled",o=document.createElement("div"),r=[];return o.className="lf-control",this.controlItems.forEach((function(o){var i=document.createElement("div"),a=document.createElement("i"),s=document.createElement("span");switch(i.className=n,o.onClick&&(i.onclick=o.onClick.bind(null,t.lf)),o.onMouseEnter&&(i.onmouseenter=o.onMouseEnter.bind(null,t.lf)),o.onMouseLeave&&(i.onmouseleave=o.onMouseLeave.bind(null,t.lf)),a.className=o.iconClass,s.className="lf-control-text",s.title=o.title,s.innerText=o.text,i.append(a,s),o.text){case"上一步":t.lf.on("history:change",(function(t){var o=t.data.undoAble;i.className=o?e:n}));break;case"下一步":t.lf.on("history:change",(function(t){var o=t.data.redoAble;i.className=o?e:n}));break;default:i.className=e}r.push(i)})),o.append.apply(o,x([],_(r),!1)),o},t.pluginName="control",t}(),$T="lf:defaultNodeMenu",JT="lf:defaultEdgeMenu",QT="lf:defaultGraphMenu",tN="lf:defaultSelectionMenu",eN=function(){function t(t){var e=t.lf,n=this;this.__currentData=null,this.lf=e,e.options.isSilentMode||(this.__menuDOM=document.createElement("ul"),this.menuTypeMap=new Map,this.init(),this.lf.setMenuConfig=function(t){n.setMenuConfig(t)},this.lf.addMenuConfig=function(t){n.addMenuConfig(t)},this.lf.setMenuByType=function(t){n.setMenuByType(t)})}return t.prototype.init=function(){var t,e,n,o,r=this,i=[{text:"删除",callback:function(t){r.lf.deleteNode(t.id)}},{text:"编辑文本",callback:function(t){r.lf.graphModel.editText(t.id)}},{text:"复制",callback:function(t){r.lf.cloneNode(t.id)}}];null===(t=this.menuTypeMap)||void 0===t||t.set($T,i);var a=[{text:"删除",callback:function(t){r.lf.deleteEdge(t.id)}},{text:"编辑文本",callback:function(t){r.lf.graphModel.editText(t.id)}}];null===(e=this.menuTypeMap)||void 0===e||e.set(JT,a),null===(n=this.menuTypeMap)||void 0===n||n.set(QT,[]);var s=[{text:"删除",callback:function(t){r.lf.clearSelectElements(),t.edges.forEach((function(t){return r.lf.deleteEdge(t.id)})),t.nodes.forEach((function(t){return r.lf.deleteNode(t.id)}))}}];null===(o=this.menuTypeMap)||void 0===o||o.set(tN,s)},t.prototype.render=function(t,e){var n=this;t.options.isSilentMode||(this.__container=e,this.__currentData=null,this.__menuDOM&&(this.__menuDOM.className="lf-menu",e.appendChild(this.__menuDOM),this.__menuDOM.addEventListener("click",(function(t){t.stopPropagation();for(var e=t.target;-1===Array.from(e.classList).indexOf("lf-menu-item")&&-1===Array.from(e.classList).indexOf("lf-menu");)e=null==e?void 0:e.parentElement;Array.from(e.classList).indexOf("lf-menu-item")>-1?(e.onclickCallback(n.__currentData),n.__menuDOM&&(n.__menuDOM.style.display="none"),n.__currentData=null):console.warn("点击区域不在菜单项内,请检查代码!")}),!0)),this.lf.on("node:contextmenu",(function(t){var e,o,r=t.data,i=t.position,a=t.e,s=i.domOverlayPosition,l=s.x,u=s.y,c=r.id,d=n.lf.graphModel.getNodeModelById(c);if(d){var p=[],h=null===(e=n.menuTypeMap)||void 0===e?void 0:e.get(d.type);p=d&&d.menu&&Array.isArray(d.menu)?d.menu:h||(null===(o=n.menuTypeMap)||void 0===o?void 0:o.get($T)),n.__currentData=r,n.showMenu(l,u,p,{width:d.width,height:d.height,clientX:a.clientX,clientY:a.clientY})}})),this.lf.on("edge:contextmenu",(function(t){var e,o,r,i=t.data,a=t.position,s=t.e,l=a.domOverlayPosition,u=l.x,c=l.y,d=i.id,p=n.lf.graphModel.getEdgeModelById(d);if(p){var h=[],f=null===(e=n.menuTypeMap)||void 0===e?void 0:e.get(p.type);h=p&&p.menu&&Array.isArray(p.menu)?p.menu:f||(null!==(r=null===(o=n.menuTypeMap)||void 0===o?void 0:o.get(JT))&&void 0!==r?r:[]),n.__currentData=i,n.showMenu(u,c,h,{width:p.width,height:p.height,clientX:s.clientX,clientY:s.clientY})}})),this.lf.on("blank:contextmenu",(function(t){var e,o,r=t.position,i=null!==(o=null===(e=n.menuTypeMap)||void 0===e?void 0:e.get(QT))&&void 0!==o?o:[],a=r.domOverlayPosition,s=a.x,l=a.y;n.showMenu(s,l,i)})),this.lf.on("selection:contextmenu",(function(t){var e,o=t.data,r=t.position,i=null===(e=n.menuTypeMap)||void 0===e?void 0:e.get(tN),a=r.domOverlayPosition,s=a.x,l=a.y;n.__currentData=o,n.showMenu(s,l,i)})),this.lf.on("node:mousedown",(function(){n.__menuDOM.style.display="none"})),this.lf.on("edge:click",(function(){n.__menuDOM.style.display="none"})),this.lf.on("blank:click",(function(){n.__menuDOM.style.display="none"})))},t.prototype.destroy=function(){var t;this.__menuDOM&&(null===(t=null==this?void 0:this.__container)||void 0===t||t.removeChild(this.__menuDOM),this.__menuDOM=void 0)},t.prototype.showMenu=function(t,e,n,o){if(n&&n.length){var r=this.__menuDOM;if(r){if(r.innerHTML="",r.append.apply(r,x([],_(this.__getMenuDom(n)),!1)),!r.children.length)return;if(r.style.display="block",!o)return r.style.top="".concat(e,"px"),void(r.style.left="".concat(t,"px"));var i=o.width,a=o.height,s=o.clientX,l=o.clientY,u=this.lf.graphModel,c=r.offsetWidth,d=!0,p=window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth,h=p-s,f=u.rootEl.getBoundingClientRect(),g=f.left+f.width;g<p&&(h=g-s),h<c&&(d=!1),r.style.left="".concat(d?t:t-i,"px");var v=r.offsetHeight,y=!0,m=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight,b=m-l,E=f.top+f.height;E<m&&(b=E-l),b<v&&(y=!1),r.style.top="".concat(y?e:e-a,"px")}}},t.prototype.setMenuByType=function(t){var e;t.type&&t.menu&&(null===(e=this.menuTypeMap)||void 0===e||e.set(t.type,t.menu))},t.prototype.__getMenuDom=function(t){var e=[];return t&&t.length>0&&t.forEach((function(t){var n=document.createElement("li");if(t.className?n.className="lf-menu-item ".concat(t.className):n.className="lf-menu-item",!0===t.icon){var o=document.createElement("span");o.className="lf-menu-item-icon",n.appendChild(o)}var r=document.createElement("span");r.className="lf-menu-item-text",t.text&&(r.innerText=t.text),n.appendChild(r),n.onclickCallback=t.callback,e.push(n)})),e},t.prototype.setMenuConfig=function(t){var e,n,o;t&&(void 0!==t.nodeMenu&&(null===(e=this.menuTypeMap)||void 0===e||e.set($T,t.nodeMenu?t.nodeMenu:[])),void 0!==t.edgeMenu&&(null===(n=this.menuTypeMap)||void 0===n||n.set(JT,t.edgeMenu?t.edgeMenu:[])),void 0!==t.graphMenu&&(null===(o=this.menuTypeMap)||void 0===o||o.set(QT,t.graphMenu?t.graphMenu:[])))},t.prototype.addMenuConfig=function(t){var e,n,o,r,i,a,s,l,u;if(t){if(Array.isArray(t.nodeMenu)){var c=null!==(n=null===(e=this.menuTypeMap)||void 0===e?void 0:e.get($T))&&void 0!==n?n:[];null===(o=this.menuTypeMap)||void 0===o||o.set($T,c.concat(t.nodeMenu))}if(Array.isArray(t.edgeMenu)){c=null!==(i=null===(r=this.menuTypeMap)||void 0===r?void 0:r.get(JT))&&void 0!==i?i:[];null===(a=this.menuTypeMap)||void 0===a||a.set(JT,c.concat(t.edgeMenu))}if(Array.isArray(t.graphMenu)){c=null!==(l=null===(s=this.menuTypeMap)||void 0===s?void 0:s.get(QT))&&void 0!==l?l:[];null===(u=this.menuTypeMap)||void 0===u||u.set(QT,c.concat(t.graphMenu))}}},t.prototype.changeMenuItem=function(t,e){if("add"===t)this.addMenuConfig(e);else{if("reset"!==t)throw new Error("The first parameter of changeMenuConfig should be 'add' or 'reset'");this.setMenuConfig(e)}},t.pluginName="menu",t}(),nN="menu-common",oN=function(){function t(t){var e=t.lf,n=this;this.menuTypeMap=new Map,this.listenDelete=function(){n.hideContextMenu()},this.lf=e,this.__menuDOM=document.createElement("div"),this.__menuDOM.className="lf-inner-context",this.menuTypeMap.set(nN,[]),this.lf.setContextMenuByType=function(t,e){n.setContextMenuByType(t,e)},this.lf.setContextMenuItems=function(t){n.setContextMenuItems(t)},this.lf.showContextMenu=function(t){n.showContextMenu(t)},this.lf.hideContextMenu=function(){n.hideContextMenu()}}return t.prototype.render=function(t,e){var n=this;this.container=e,t.on("node:click",(function(t){var e=t.data;n._activeData=e,n.createContextMenu()})),t.on("edge:click",(function(t){var e=t.data;n._activeData=e,n.createContextMenu()})),t.on("blank:click",(function(){n.hideContextMenu()}))},t.prototype.setContextMenuByType=function(t,e){this.menuTypeMap.set(t,e)},t.prototype.hideContextMenu=function(){this.__menuDOM.innerHTML="",this.__menuDOM.style.display="none",this.isShow&&this.container.removeChild(this.__menuDOM),this.lf.off("node:delete,edge:delete,node:drag,graph:transform",this.listenDelete),this.isShow=!1},t.prototype.showContextMenu=function(t){t&&t.id?(this._activeData=t,this.createContextMenu()):console.warn("请检查传入的参数")},t.prototype.setContextMenuItems=function(t){this.menuTypeMap.set(nN,t)},t.prototype.getContextMenuPosition=function(){var t=this._activeData,e=this.lf.graphModel.getElement(t.id);if(e){var n,o;if("edge"===e.BaseType){n=Number.MIN_SAFE_INTEGER,o=Number.MAX_SAFE_INTEGER;var r=e.getData();n=Math.max(r.startPoint.x,n),o=Math.min(r.startPoint.y,o),n=Math.max(r.endPoint.x,n),o=Math.min(r.endPoint.y,o),r.pointsList&&r.pointsList.forEach((function(t){n=Math.max(t.x,n),o=Math.min(t.y,o)}))}return"node"===e.BaseType&&(n=t.x+e.width/2,o=t.y-e.height/2),this.lf.graphModel.transformModel.CanvasPointToHtmlPoint([n,o])}},t.prototype.createContextMenu=function(){var t=this;if(!this.lf.options.isSilentMode){var e=x(x([],_(this.menuTypeMap.get(this._activeData.type)||[]),!1),_(this.menuTypeMap.get(nN)||[]),!1),n=document.createDocumentFragment();e.forEach((function(e){var o=document.createElement("div");o.className="lf-context-item";var r=document.createElement("img");r.src=e.icon,r.className="lf-context-img",e.className&&(o.className="".concat(o.className," ").concat(e.className)),r.addEventListener("click",(function(){t.hideContextMenu(),e.callback?e.callback(t._activeData):t.addNode({sourceId:t._activeData.id,x:t._activeData.x,y:t._activeData.y,properties:e.properties,type:e.type})})),o.appendChild(r),n.appendChild(o)})),this.__menuDOM.innerHTML="",this.__menuDOM.appendChild(n),this.showMenu()}},t.prototype.addNode=function(t,e){var n=void 0!==e;void 0===e&&(e=t.y);var o=this.lf.getNodeModelById(t.sourceId);if(o){var r=t.x-o.width+200,i=e-t.y/2-20,a=t.x+o.width+200,s=e+t.y/2+20;if(this.lf.getAreaElement([r,i],[a,s]).length)return e+=100,void this.addNode(t,e);if(t.type){var l=this.lf.addNode({type:t.type,x:t.x+200,y:e,properties:t.properties}),u=void 0,c=void 0;n&&(u={x:t.x,y:t.y+o.height/2},c={x:l.x-l.width/2,y:l.y}),this.lf.addEdge({sourceNodeId:t.sourceId,targetNodeId:l.id,startPoint:u,endPoint:c})}}},t.prototype.showMenu=function(){var t=this.getContextMenuPosition();if(t){var e=_(t,2),n=e[0],o=e[1];this.__menuDOM.style.display="flex",this.__menuDOM.style.top="".concat(o,"px"),this.__menuDOM.style.left="".concat(n+10,"px"),this.container.appendChild(this.__menuDOM),!this.isShow&&this.lf.on("node:delete,edge:delete,node:drag,graph:transform",this.listenDelete),this.isShow=!0}},t.pluginName="contextMenu",t}(),rN=function(){function t(t){var e=t.lf,n=this;this.lf=e,this.lf.setPatternItems=function(t){n.setPatternItems(t)}}return t.prototype.render=function(t,e){var n=this;this.destroy(),this.shapeList&&0!==this.shapeList.length?(this.panelEl=document.createElement("div"),this.panelEl.className="lf-dndpanel",this.shapeList.forEach((function(t){var e;null===(e=n.panelEl)||void 0===e||e.appendChild(n.createDndItem(t))})),e.appendChild(this.panelEl),this.domContainer=e):this.domContainer=e},t.prototype.destroy=function(){this.domContainer&&this.panelEl&&this.domContainer.contains(this.panelEl)&&this.domContainer.removeChild(this.panelEl)},t.prototype.setPatternItems=function(t){this.shapeList=t,this.domContainer&&this.render(this.lf,this.domContainer)},t.prototype.createDndItem=function(t){var e=this,n=document.createElement("div");n.className=t.className?"lf-dnd-item ".concat(t.className):"lf-dnd-item";var o=document.createElement("div");if(o.className="lf-dnd-shape",t.icon&&(o.style.backgroundImage="url(".concat(t.icon,")")),n.appendChild(o),t.label){var r=document.createElement("div");r.innerText=t.label,r.className="lf-dnd-text",n.appendChild(r)}return t.disabled?(n.classList.add("disabled"),n.onmousedown=function(){t.callback&&t.callback(e.lf,e.domContainer)},n):(n.onmousedown=function(){t.type&&e.lf.dnd.startDrag({type:t.type,properties:t.properties,text:t.text}),t.callback&&t.callback(e.lf,e.domContainer)},n.ondblclick=function(n){e.lf.graphModel.eventCenter.emit("dnd:panel-dbclick",{e:n,data:t})},n.onclick=function(n){e.lf.graphModel.eventCenter.emit("dnd:panel-click",{e:n,data:t})},n.oncontextmenu=function(n){e.lf.graphModel.eventCenter.emit("dnd:panel-contextmenu",{e:n,data:t})},n)},t.pluginName="dndPanel",t}(),iN=function(){function t(t){var e=t.lf,n=t.LogicFlow,o=t.options,r=this;this.width=200,this.height=150,this.scale=1,this.translateX=0,this.translateY=0,this.showEdge=!1,this.viewPortTop=0,this.viewPortLeft=0,this.viewPortWidth=150,this.viewPortHeight=75,this.isShow=!1,this.isShowHeader=!1,this.isShowCloseIcon=!1,this.headerTitle="导航",this.disabledPlugins=["miniMap","control","selectionSelect"],this.render=function(t,e){r.container=e,r.lf.on("history:change",(function(){r.isShow&&r.setView()})),r.lf.on("graph:transform",(function(){r.isShow&&r.setView(!1)}))},this.show=function(t,e){r.isShow||(r.createMiniMap(t,e),r.setView()),r.isShow=!0},this.hide=function(){r.isShow&&(r.removeMiniMap(),r.lf.emit("miniMap:close",{})),r.isShow=!1},this.updatePosition=function(t){if("object"==typeof t)void 0===t.left&&void 0===t.right||(r.leftPosition=t.left,r.rightPosition=t.right),void 0===t.top&&void 0===t.bottom||(r.topPosition=t.top,r.bottomPosition=t.bottom);else switch(t){case"left-top":r.leftPosition=0,r.rightPosition=void 0,r.topPosition=0,r.bottomPosition=void 0;break;case"right-top":r.leftPosition=void 0,r.rightPosition=0,r.topPosition=0,r.bottomPosition=void 0;break;case"left-bottom":r.leftPosition=0,r.rightPosition=void 0,r.topPosition=void 0,r.bottomPosition=0;break;case"right-bottom":r.leftPosition=void 0,r.rightPosition=0,r.topPosition=void 0,r.bottomPosition=0}r.updateMiniMapPosition()},this.reset=function(){r.lf.resetTranslate(),r.lf.resetZoom()},this.setShowEdge=function(t){r.showEdge!==t&&(r.showEdge=t,r.setView())},this.startDrag=function(t){document.addEventListener("mousemove",r.drag),document.addEventListener("mouseup",r.drop);var e=t.x,n=t.y;r.startPosition={x:e,y:n}},this.drag=function(t){var e=t.x,n=t.y,o=(e-r.startPosition.x)/r.scale,i=(n-r.startPosition.y)/r.scale,a=r.viewPortLeft+o+r.viewPortWidth/r.scale/2,s=r.viewPortTop+i+r.viewPortHeight/r.scale/2;r.startPosition={x:e,y:n},r.lf.focusOn({coordinate:{x:a,y:s}})},this.drop=function(){document.removeEventListener("mousemove",r.drag),document.removeEventListener("mouseup",r.drop)},this.mapClick=function(t){var e=t.offsetX,n=t.offsetY,o=r.translateX+e/r.scale,i=r.translateY+n/r.scale;r.lf.focusOn({coordinate:{x:o,y:i}})},this.lf=e,this.LFCtor=n,o&&this.setOption(o),this.viewPortWidth=e.graphModel.width,this.viewPortHeight=e.graphModel.height;var i={left:0,right:this.viewPortWidth,top:0,bottom:this.viewPortHeight};this.bounds=i,this.elementAreaBounds=i,this.viewPortBounds=i,this.initMiniMap()}return t.prototype.setOption=function(t){var e=t.width,n=void 0===e?150:e,o=t.height,r=void 0===o?220:o,i=t.showEdge,a=void 0!==i&&i,s=t.isShowHeader,l=void 0!==s&&s,u=t.isShowCloseIcon,c=void 0!==u&&u,d=t.leftPosition,p=t.topPosition,h=t.rightPosition,f=void 0===h?0:h,g=t.bottomPosition,v=void 0===g?0:g,y=t.headerTitle,m=void 0===y?"导航":y;this.width=n,this.height=r,this.showEdge=a,this.isShowHeader=l,this.isShowCloseIcon=c,this.leftPosition=d,this.rightPosition=void 0!==d?void 0:f,this.topPosition=p,this.bottomPosition=void 0!==p?void 0:v,this.headerTitle=m},t.prototype.initMiniMap=function(){var t=document.createElement("div");t.className="lf-mini-map-graph",t.style.width="".concat(this.width,"px"),t.style.height="".concat(this.height,"px"),this.lfMap=new this.LFCtor({container:t,grid:!1,isSilentMode:!0,stopZoomGraph:!0,stopScrollGraph:!0,stopMoveGraph:!1,history:!1,snapline:!1,disabledPlugins:this.disabledPlugins}),this.miniMapWrap=t,this.createViewPort(),t.addEventListener("click",this.mapClick)},t.prototype.createMiniMap=function(t,e){var n,o=document.createElement("div");this.miniMapContainer=o,o.appendChild(this.miniMapWrap),o.style.position="absolute",void 0===t&&void 0===e||(this.leftPosition=t||0,this.topPosition=e||0,this.rightPosition=void 0,this.bottomPosition=void 0),this.updateMiniMapPosition(),o.className="lf-mini-map",this.isShowCloseIcon||o.classList.add("lf-mini-map-no-close-icon"),this.isShowHeader||o.classList.add("lf-mini-map-no-header"),null===(n=this.container)||void 0===n||n.appendChild(o),this.miniMapWrap.appendChild(this.viewport);var r=document.createElement("div");r.className="lf-mini-map-header",r.innerText=this.headerTitle,o.appendChild(r);var i=document.createElement("span");i.className="lf-mini-map-close",i.addEventListener("click",this.hide),o.appendChild(i)},t.prototype.updateMiniMapPosition=function(){if(this.miniMapContainer){var t=this.miniMapContainer.style;void 0!==this.rightPosition?(t.right="".concat(this.rightPosition,"px"),t.left=""):(t.left="".concat(this.leftPosition,"px"),t.right=""),void 0!==this.bottomPosition?(t.bottom="".concat(this.bottomPosition,"px"),t.top=""):(t.top="".concat(this.topPosition,"px"),t.bottom="")}},t.prototype.removeMiniMap=function(){var t;this.miniMapContainer&&(null===(t=this.container)||void 0===t||t.removeChild(this.miniMapContainer))},t.prototype.updateBounds=function(t){t&&this.updateElementAreaBounds(t),this.updateViewPortBounds(),this.bounds={left:Math.min(this.elementAreaBounds.left,this.viewPortBounds.left),right:Math.max(this.elementAreaBounds.right,this.viewPortBounds.right),top:Math.min(this.elementAreaBounds.top,this.viewPortBounds.top),bottom:Math.max(this.elementAreaBounds.bottom,this.viewPortBounds.bottom)}},t.prototype.updateElementAreaBounds=function(t){var e={left:0,right:0,top:0,bottom:0},n=t.nodes;n&&n.length>0&&n.forEach((function(t){var n,o,r=t.x,i=t.y,a=null!==(n=t.width)&&void 0!==n?n:200,s=null!==(o=t.height)&&void 0!==o?o:200,l=r-a/2,u=r+a/2,c=i-s/2,d=i+s/2;e.left=Math.min(l,e.left),e.right=Math.max(u,e.right),e.top=Math.min(c,e.top),e.bottom=Math.max(d,e.bottom)})),this.elementAreaBounds=e},t.prototype.updateViewPortBounds=function(){var t=this.lf.getTransform(),e=t.TRANSLATE_X,n=t.TRANSLATE_Y,o=t.SCALE_X,r=t.SCALE_Y,i=this.lf.graphModel,a=i.width,s=i.height;this.viewPortBounds={left:-e/o,right:(-e+a)/o,top:-n/r,bottom:(-n+s)/r}},t.prototype.resetData=function(t){var e=t.nodes,n=t.edges;return e.forEach((function(t){t.text=void 0})),this.showEdge&&n.forEach((function(t){t.text=void 0})),{nodes:e,edges:this.showEdge?n:[]}},t.prototype.setView=function(t){var e,n;if(void 0===t&&(t=!0),t){var o=this.lf.getGraphRawData(),r=this.resetData(o),i=this.lf.viewMap,a=this.lf.graphModel.modelMap,s=this.lfMap.viewMap;try{for(var l=b(i.keys()),u=l.next();!u.done;u=l.next()){var c=u.value;s.has(c)||this.lfMap.register({type:c,view:i.get(c),model:a.get(c)})}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=l.return)&&n.call(l)}finally{if(e)throw e.error}}this.lfMap.render(r),this.updateBounds(r)}else this.updateBounds();var d=this.bounds,p=d.left,h=d.top,f=d.right-p,g=d.bottom-h,v=this.width/f,y=this.height/g,m=Math.min(v,y);this.scale=m;var _=p-(this.width/m-f)/2,x=h-(this.height/m-g)/2;if(this.lfMap.graphModel.transformModel.translate(-_+this.translateX,-x+this.translateY),this.translateX=_,this.translateY=x,this.miniMapWrap.firstChild){var E=this.miniMapWrap.firstChild.style;E.pointerEvents="none",E.transform="matrix(".concat(m,", 0, 0, ").concat(m,", 0, 0)"),E.transformOrigin="left top",E.height="".concat(this.height/m,"px"),E.width="".concat(this.width/m,"px"),this.updateViewPort()}},t.prototype.updateViewPort=function(){var t=this.viewport.style,e=this.lf.getTransform(),n=e.TRANSLATE_X,o=e.TRANSLATE_Y,r=e.SCALE_X,i=e.SCALE_Y,a=this.lf.graphModel,s=a.width,l=a.height;this.viewPortLeft=-n/r,this.viewPortTop=-o/i,this.viewPortWidth=s/r*this.scale,this.viewPortHeight=l/i*this.scale,t.width="".concat(this.viewPortWidth,"px"),t.height="".concat(this.viewPortHeight,"px"),t.left="".concat((this.viewPortLeft-this.translateX)*this.scale,"px"),t.top="".concat((this.viewPortTop-this.translateY)*this.scale,"px")},t.prototype.createViewPort=function(){var t=document.createElement("div");t.className="lf-minimap-viewport",t.addEventListener("mousedown",this.startDrag),t.addEventListener("click",(function(t){t.stopPropagation()})),this.viewport=t},t.pluginName="miniMap",t}(),aN=function(){function t(t){var e=t.lf,n=this;this.disabled=!0,this.isDefaultStopMoveGraph=!1,this.isWholeNode=!0,this.isWholeEdge=!0,this.draw=function(t){var e=n.lf.getPointByClient(t.clientX,t.clientY).domOverlayPosition,o=e.x,r=e.y;if(n.endPoint={x:o,y:r},n.startPoint){var i=n.startPoint,a=i.x,s=i.y,l=a,u=s,c=o-a,d=r-s;o<a&&(l=o,c=a-o),r<s&&(u=r,d=s-r),n.wrapper&&(n.wrapper.style.left="".concat(l,"px"),n.wrapper.style.top="".concat(u,"px"),n.wrapper.style.width="".concat(c,"px"),n.wrapper.style.height="".concat(d,"px"))}},this.drawOff=function(){var t;if(document.removeEventListener("mousemove",n.draw),document.removeEventListener("mouseup",n.drawOff),n.wrapper&&(n.wrapper.oncontextmenu=null,null===(t=n.container)||void 0===t||t.removeChild(n.wrapper)),n.startPoint&&n.endPoint){var e=n.startPoint,o=e.x,r=e.y,i=n.endPoint,a=i.x,s=i.y,l=[Math.min(o,a),Math.min(r,s)],u=[Math.max(o,a),Math.max(r,s)];if(n.lf.emit("selection:selected-area",{topLeft:l,bottomRight:u}),Math.abs(a-o)<10&&Math.abs(s-r)<10)return;var c=n.lf.graphModel.getAreaElement(l,u,n.isWholeEdge,n.isWholeNode,!0),d=n.lf.graphModel.group;c.forEach((function(t){d&&d.getNodeGroup(t.id)||n.lf.selectElementById(t.id,!0)})),n.lf.emit("selection:selected",c)}},this.lf=e;var o=e.getEditConfig().stopMoveGraph;this.isDefaultStopMoveGraph=o,e.openSelectionSelect=function(){n.openSelectionSelect()},e.closeSelectionSelect=function(){n.closeSelectionSelect()}}return t.prototype.render=function(t,e){var n=this;this.container=e,t.on("blank:mousedown",(function(o){var r=o.e;if(t.getEditConfig().stopMoveGraph&&!n.disabled&&!(2===r.button)){var i=t.getPointByClient(r.clientX,r.clientY).domOverlayPosition,a=i.x,s=i.y;n.startPoint={x:a,y:s},n.endPoint={x:a,y:s};var l=document.createElement("div");l.className="lf-selection-select",l.oncontextmenu=function(t){t.preventDefault()},l.style.top="".concat(n.startPoint.y,"px"),l.style.left="".concat(n.startPoint.x,"px"),e.appendChild(l),n.wrapper=l,document.addEventListener("mousemove",n.draw),document.addEventListener("mouseup",n.drawOff)}}))},t.prototype.setSelectionSense=function(t,e){void 0===t&&(t=!0),void 0===e&&(e=!0),this.isWholeEdge=t,this.isWholeNode=e},t.prototype.openSelectionSelect=function(){this.lf.getEditConfig().stopMoveGraph||(this.isDefaultStopMoveGraph=!1,this.lf.updateEditConfig({stopMoveGraph:!0})),this.open()},t.prototype.closeSelectionSelect=function(){this.isDefaultStopMoveGraph||this.lf.updateEditConfig({stopMoveGraph:!1}),this.close()},t.prototype.open=function(){this.disabled=!1},t.prototype.close=function(){this.disabled=!0},t.pluginName="selectionSelect",t}(),sN=function(t,e){var n=[],o=[],r=function(t,o,i){i&&o.unshift.apply(o,x([],_(e.getEdgeModels({sourceNodeId:t.id,targetNodeId:null==i?void 0:i.id}).map((function(t){return t.id}))),!1)),o.includes(t.id)?n.push(o):(o.unshift(t.id),t.incoming.nodes.length?t.incoming.nodes.forEach((function(e){r(e,o.slice(),t)})):n.push(o))},i=function(t,n,r){r&&n.push.apply(n,x([],_(e.getEdgeModels({sourceNodeId:null==r?void 0:r.id,targetNodeId:t.id}).map((function(t){return t.id}))),!1)),n.includes(t.id)?o.push(n):(n.push(t.id),t.outgoing.nodes.length?t.outgoing.nodes.forEach((function(e){i(e,n.slice(),t)})):o.push(n))};return r(t,[]),i(t,[]),x([],_(new Set(x(x([],_(n.flat()),!1),_(o.flat()),!1))),!1)},lN=function(){function t(t){var e=t.lf;this.mode="path",this.manual=!1,this.tempStyles={},this.lf=e}return t.prototype.setMode=function(t){this.mode=t},t.prototype.setManual=function(t){this.manual=t},t.prototype.highlightSingle=function(t){var e=this.lf.getModelById(t);"node"===(null==e?void 0:e.BaseType)?e.updateStyles(this.tempStyles[t]):"edge"===(null==e?void 0:e.BaseType)&&(e.updateStyles(this.tempStyles[t]),e.sourceNode.updateStyles(this.tempStyles[e.sourceNode.id]),e.targetNode.updateStyles(this.tempStyles[e.targetNode.id]))},t.prototype.highlightPath=function(t){var e=this,n=function(t,e){var n=e.getModelById(t);return sN("node"===(null==n?void 0:n.BaseType)?n:null==n?void 0:n.targetNode,e)}(t,this.lf);n.forEach((function(t){var n;null===(n=e.lf.getModelById(t))||void 0===n||n.updateStyles(e.tempStyles[t])}))},t.prototype.highlight=function(t,e){var n=this;(void 0===e&&(e=this.mode),this.manual)||(Object.keys(this.tempStyles).length&&this.restoreHighlight(),Object.values(this.lf.graphModel.modelsMap).forEach((function(t){var e="node"===t.BaseType?t.getNodeStyle():t.getEdgeStyle();n.tempStyles[t.id]=f({},e),t.setStyles({opacity:.1})})),{single:this.highlightSingle.bind(this),path:this.highlightPath.bind(this)}[e](t))},t.prototype.restoreHighlight=function(){var t=this;Object.keys(this.tempStyles).length&&(Object.values(this.lf.graphModel.modelsMap).forEach((function(e){var n,o=null!==(n=t.tempStyles[e.id])&&void 0!==n?n:{};e.updateStyles(f({},o))})),this.tempStyles={})},t.prototype.render=function(){var t=this;this.lf.on("node:mouseenter",(function(e){var n=e.data;return t.highlight(n.id)})),this.lf.on("edge:mouseenter",(function(e){var n=e.data;return t.highlight(n.id)})),this.lf.on("node:mouseleave",this.restoreHighlight.bind(this)),this.lf.on("edge:mouseleave",this.restoreHighlight.bind(this)),this.lf.on("history:change",this.restoreHighlight.bind(this))},t.prototype.destroy=function(){},t.pluginName="highlight",t}(),uN={tr:"tl",lb:"tl",tl:"tr",rb:"tr",br:"bl",lt:"bl",bl:"br",rt:"br"};function cN(t,e,n,o){var r,i="",a="";t[0]===e[0]?i=t[1]>e[1]?"t":"b":t[1]===e[1]&&(i=t[0]>e[0]?"l":"r"),e[0]===n[0]?a=e[1]>n[1]?"t":"b":e[1]===n[1]&&(a=e[0]>n[0]?"l":"r");var s=Math.min(Math.hypot(e[0]-t[0],e[1]-t[1])/2,Math.hypot(n[0]-e[0],n[1]-e[1])/2,o)||.2*o,l="".concat(i).concat(a),u=uN[l]||"-",c="L ".concat(t[0]," ").concat(t[1]);if("-"===u)c+="L ".concat(e[0]," ").concat(e[1]," L ").concat(n[0]," ").concat(n[1]);else{var d=_(function(t,e,n,o){var r=[t[0],t[1]],i=[t[0],t[1]];switch(n){case"tl":return"tr"===e?(r[1]+=o,i[0]+=o):"lb"===e&&(r[0]+=o,i[1]+=o),[r,i];case"tr":return"tl"===e?(r[1]+=o,i[0]-=o):"rb"===e&&(r[0]-=o,i[1]+=o),[r,i];case"bl":return"br"===e?(r[1]-=o,i[0]+=o):"lt"===e&&(r[0]+=o,i[1]-=o),[r,i];case"br":return"bl"===e?(r[1]-=o,i[0]-=o):"rt"===e&&(r[0]-=o,i[1]-=o),[r,i];default:return[]}}(e,l,u,s),2),p=d[0],h=d[1];p&&h&&(c+="L ".concat(p[0]," ").concat(p[1]," Q ").concat(e[0]," ").concat(e[1]," ").concat(h[0]," ").concat(h[1]),r=_(h,2),e[0]=r[0],e[1]=r[1])}return c}function dN(t,e){var n=0,o="";if(2===t.length)o+="M".concat(t[n][0]," ").concat(t[n++][1]," L ").concat(t[n][0]," ").concat(t[n][1]);else{for(o+="M".concat(t[n][0]," ").concat(t[n++][1]);n+1<t.length;){o+=cN(t[n-1],t[n],t[1+n++],e)}o+="L ".concat(t[n][0]," ").concat(t[n][1])}return o}var pN=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return h(e,t),e.prototype.getEdge=function(){var t=this.props.model,e=t.points,n=t.isAnimation,o=t.arrowConfig,r=t.radius,i=void 0===r?5:r,a=t.getEdgeStyle(),s=t.getEdgeAnimationStyle(),l=function(t){for(var e=t,n=1;n<e.length-1;){var o=_(e[n-1],2),r=o[0],i=o[1],a=_(e[n],2),s=a[0],l=a[1],u=_(e[n+1],2),c=u[0],d=u[1];r===s&&s===c||i===l&&l===d?e.splice(n,1):n++}return e}(e.split(" ").map((function(t){return t.split(",").map((function(t){return+t}))}))),u=dN(l,i),c=f(f(f({style:n?s:{}},a),o),{fill:"none"});return uo("path",f({d:u},c))},e}(xS),hN=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return h(e,t),e}(Cx),fN=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return h(e,t),e.prototype.getLabelShape=function(){var t=this.props.model,e=t.id,n=t.x,o=t.y,r=t.width,i=t.height,a=t.properties,s=this.props.model.getNodeStyle();return uo("svg",{x:n-r/2,y:o-i/2,width:50,height:24,style:"z-index: 0; background: none; overflow: auto;"},[a.labelText?uo("text",{x:0,y:-5,fontSize:"16px",fill:s.stroke},a.labelText):"",a.disabledDelete?"":uo("text",{x:a.labelText?50:0,y:-5,fontSize:"24px",cursor:"pointer",fill:s.stroke,onclick:this.handleCustomDeleteIconClick.bind(this,e)},"x")])},e.prototype.getShape=function(){var t=this.props.model,e=t.x,n=t.y,o=t.width,r=t.height,i=t.id,a=this.props.model.getNodeStyle();return uo("g",{},[uo("rect",f(f({},a),{x:e-o/2,y:n-r/2,width:o,height:r,id:i})),this.getLabelShape()])},e.prototype.toFront=function(){},e.prototype.handleCustomDeleteIconClick=function(t){this.props.graphModel.deleteNode(t)},e}(Hw),gN=function(t){function e(){var e=t.apply(this,x([],_(arguments),!1))||this;return e.d=10,e}return h(e,t),e.prototype.initNodeData=function(e){e.text={value:"",x:e.x,y:e.y,draggable:!1,editable:!1},t.prototype.initNodeData.call(this,e),this.zIndex=0,this.draggable=!0},e.prototype.setAttributes=function(){var t,e=this;this.points=[],(null===(t=this.properties)||void 0===t?void 0:t.node_selection_ids).length>1&&setTimeout((function(){var t;e.updatePointsByNodes((null===(t=e.properties)||void 0===t?void 0:t.node_selection_ids)||[])}))},e.prototype.getNodeStyle=function(){var e=t.prototype.getNodeStyle.call(this);return e.stroke=this.properties.strokeColor||"#008000",e.strokeDasharray="10 5",e},e.prototype.getDefaultAnchor=function(){return[]},e.prototype.updatePoints=function(t){this.points=t},e.prototype.updateCoordinate=function(t){var e=t.x,n=t.y;this.x=e,this.y=n},e.prototype.updatePointsByNodes=function(t){var e=this,n=[],o=1/0,r=1/0,i=-1/0,a=-1/0;t.forEach((function(t){var n=e.graphModel.getNodeModelById(t);if(n){var s=n.width,l=n.height,u=n.x,c=n.y;o=Math.min(o,u-s/2-e.d),r=Math.min(r,c-l/2-e.d),i=Math.max(i,u+s/2+e.d),a=Math.max(a,c+l/2+e.d)}})),n.push([o,r],[i,r],[i,a],[o,a]),[o,r,i,a].some((function(t){return Math.abs(t)===1/0}))||(this.updatePoints(n),this.updateCoordinate({x:(i+o)/2,y:(a+r)/2}))},e}(Kx),vN=function(){function t(t){var e=t.lf;this.selectNodes=[],this.d=10,e.register({type:"node-selection",view:fN,model:gN})}return Object.defineProperty(t.prototype,"selectNodesIds",{get:function(){return this.selectNodes.map((function(t){return t.id}))},enumerable:!1,configurable:!0}),t.prototype.addNodeSelection=function(){this.lf.addNode({type:"node-selection",text:"",properties:{node_selection_ids:this.selectNodesIds}}).updatePointsByNodes(this.selectNodesIds)},t.prototype.updateNodeSelection=function(){var t=this.getNodeSelection();t&&(this.lf.setProperties(t.id,{node_selection_ids:this.selectNodesIds}),this.lf.getNodeModelById(t.id).updatePointsByNodes(this.selectNodesIds))},t.prototype.getNodeSelection=function(){var t=this,e=this.selectNodesIds,n=this.lf.getGraphRawData(),o=e.filter((function(e){return e!==t.currentClickNode.id}));return n.nodes.find((function(t){if("node-selection"===t.type){var e=El(t,"properties.node_selection_ids",[]);return o.every((function(t){return e.includes(t)}))}return!1}))},t.prototype.render=function(t){var e=this;this.lf=t,t.on("node:click",(function(n){if(n.e.shiftKey&&"node-selection"!==n.data.type){e.currentClickNode=n.data;var o=!1;e.selectNodesIds.includes(n.data.id)&&(e.lf.getNodeModelById(n.data.id).setSelected(!1),o=!0);var r=t.getSelectElements(!0).nodes;e.selectNodes=r,1===e.selectNodes.length?o?e.updateNodeSelection():e.addNodeSelection():e.selectNodes.length>1&&e.updateNodeSelection()}})),t.graphModel.addNodeMoveRules((function(e,n,o){if("node-selection"===e.type){var r=e.properties.node_selection_ids;return t.graphModel.moveNodes(r,n,o,!0),!0}return!0}))},t.pluginName="node-selection",t}();t.AutoLayout=qT,t.BPMNAdapter=UO,t.BPMNBaseAdapter=XO,t.BPMNElements=rO,t.BoundaryEventFactory=gM,t.BpmnAdapter=iM,t.BpmnElement=HC,t.BpmnXmlAdapter=aM,t.ContextMenu=oN,t.Control=ZT,t.CurvedEdge=pN,t.CurvedEdgeModel=hN,t.DiamondResize=HM,t.DiamondResizeModel=jM,t.DiamondResizeView=BM,t.DndPanel=rN,t.DynamicGroup=tT,t.DynamicGroupNode=qO,t.DynamicGroupNodeModel=ZO,t.EllipseResize=LM,t.EllipseResizeModel=RM,t.EllipseResizeView=IM,t.EndEventFactory=pM,t.EndEventModel=SC,t.EndEventView=CC,t.ExclusiveGatewayModel=AC,t.ExclusiveGatewayView=PC,t.FlowPath=UT,t.GatewayNodeFactory=TM,t.Group=$M,t.GroupNode=KM,t.GroupNodeModel=VM,t.Highlight=lN,t.HtmlResize=WM,t.HtmlResizeModel=zM,t.HtmlResizeView=FM,t.InsertNodeInPolyline=sT,t.IntermediateCatchEventFactory=hM,t.IntermediateThrowEventFactory=vM,t.Label=LT,t.Menu=eN,t.MiniMap=iN,t.NodeResize=YM,t.NodeSelection=vN,t.RectResize=UM,t.RectResizeModel=GM,t.RectResizeView=XM,t.SelectionSelect=aN,t.SequenceFlowModel=OC,t.SequenceFlowView=TC,t.ServiceTaskModel=kC,t.ServiceTaskView=RC,t.Snapshot=XT,t.StartEventFactory=fM,t.StartEventModel=xC,t.StartEventView=EC,t.SubProcessFactory=JM,t.TaskNodeFactory=AM,t.UserTaskModel=LC,t.UserTaskView=jC,t.bpmnUtils=dM,t.convertNormalToXml=jO,t.convertXmlToNormal=BO,t.dynamicGroup=JO,t.gateway={exclusive:0,inclusive:1,parallel:2},t.gatewayComposable=[[1,1,0],[0,0,1],[0,1,1]],t.getCurvedEdgePath=dN,t.handleAttributes=XC,t.icons=OM,t.lfJson2Xml=VC,t.lfXml2Json=ZC,t.multiInstanceIcon=NM,t.sequenceFlowFactory=tO,t.toLogicflowData=function(t){var e={nodes:[],edges:[]},n=t.flowElementList;return n&&n.length>0&&n.forEach((function(t){if(t.type===YO.SEQUENCE_FLOW){var n=function(t){var e=t.incoming,n=t.outgoing,o=t.properties,r=t.key,i=t.type,a=o.text,s=o.name,l=o.startPoint,u=o.endPoint,c=o.pointsList,d={id:r,type:VO[i],sourceNodeId:e[0],targetNodeId:n[0],text:a||s,properties:{}};l&&(d.startPoint=JSON.parse(l)),u&&(d.endPoint=JSON.parse(u)),c&&(d.pointsList=JSON.parse(c));var p=["startPoint","endPoint","pointsList","text"];return Object.keys(t.properties).forEach((function(e){-1===p.indexOf(e)&&(d.properties[e]=t.properties[e])})),d}(t);e.edges.push(n)}else{var o=function(t){var e=t.properties,n=t.key,o=t.type,r=t.bounds,i=e.x,a=e.y,s=e.text;if(void 0===i){var l=_(r,2),u=l[0],c=u.x,d=u.y,p=l[1];i=(c+p.x)/2,a=(d+p.y)/2}var h={id:n,type:VO[o],x:i,y:a,text:s,properties:{}},f=["x","y","text"];return Object.keys(t.properties).forEach((function(e){-1===f.indexOf(e)&&(h.properties[e]=t.properties[e])})),h}(t);e.nodes.push(o)}})),e},t.toNormalJson=tM,t.toTurboData=function(t){var e=new Map,n={flowElementList:[]};return t.nodes.forEach((function(t){var o=function(t){var e=t.id,n=t.type,o=t.x,r=t.y,i=t.text,a=void 0===i?"":i,s=t.properties;return{incoming:[],outgoing:[],dockers:[],type:KO(n),properties:f(f({},s),{name:a&&a.value||"",x:o,y:r,text:a}),key:e}}(t);n.flowElementList.push(o),e.set(t.id,o)})),t.edges.forEach((function(t){var o=function(t){var e=t.id,n=t.type,o=t.sourceNodeId,r=t.targetNodeId,i=t.startPoint,a=t.endPoint,s=t.pointsList,l=t.text,u=void 0===l?"":l,c=t.properties;return{incoming:[o],outgoing:[r],type:KO(n),dockers:[],properties:f(f({},c),{name:u&&u.value||"",text:u,startPoint:JSON.stringify(i),endPoint:JSON.stringify(a),pointsList:JSON.stringify(s)}),key:e}}(t);e.get(t.sourceNodeId).outgoing.push(o.key),e.get(t.targetNodeId).incoming.push(o.key),n.flowElementList.push(o)})),n},t.toXmlJson=QC,t.useDefinition=oO}));
|
|
42
42
|
//# sourceMappingURL=index.min.js.map
|