UNPKG

@zklogic/draw.io

Version:

Draw.IO - Graph Editor integration in Angular-cli

1 lines 218 kB
!function(){EditorUi.VERSION="@DRAWIO-VERSION@",EditorUi.compactUi="atlas"!=uiTheme,Editor.isDarkMode()&&(mxGraphView.prototype.gridColor=mxGraphView.prototype.defaultDarkGridColor),EditorUi.enableLogging="1"!=urlParams.stealth&&"1"!=urlParams.lockdown&&(/.*\.draw\.io$/.test(window.location.hostname)||/.*\.diagrams\.net$/.test(window.location.hostname))&&"support.draw.io"!=window.location.hostname,EditorUi.drawHost=window.DRAWIO_BASE_URL,EditorUi.lightboxHost=window.DRAWIO_LIGHTBOX_URL,EditorUi.lastErrorMessage=null,EditorUi.ignoredAnonymizedChars="\n\t`~!@#$%^&*()_+{}|:\"<>?-=[];'./,\n\t",EditorUi.templateFile=TEMPLATE_PATH+"/index.xml",EditorUi.cacheUrl="1"==urlParams.dev?"/cache":window.REALTIME_URL,null==EditorUi.cacheUrl&&"undefined"!=typeof DrawioFile&&(DrawioFile.SYNC="none"),Editor.cacheTimeout=1e4,EditorUi.enablePlantUml=EditorUi.enableLogging,EditorUi.isElectronApp=null!=window&&null!=window.process&&null!=window.process.versions&&null!=window.process.versions.electron,EditorUi.nativeFileSupport=!mxClient.IS_OP&&!EditorUi.isElectronApp&&"1"!=urlParams.extAuth&&"showSaveFilePicker"in window&&"showOpenFilePicker"in window,EditorUi.enableDrafts=!mxClient.IS_CHROMEAPP&&!EditorUi.isElectronApp&&isLocalStorage&&"0"!=urlParams.drafts,EditorUi.scratchpadHelpLink="https://www.diagrams.net/doc/faq/scratchpad",EditorUi.defaultMermaidConfig={theme:"neutral",arrowMarkerAbsolute:!1,flowchart:{htmlLabels:!1},sequence:{diagramMarginX:50,diagramMarginY:10,actorMargin:50,width:150,height:65,boxMargin:10,boxTextMargin:5,noteMargin:10,messageMargin:35,mirrorActors:!0,bottomMarginAdj:1,useMaxWidth:!0,rightAngles:!1,showSequenceNumbers:!1},gantt:{titleTopMargin:25,barHeight:20,barGap:4,topPadding:50,leftPadding:75,gridLineStartPadding:35,fontSize:11,fontFamily:'"Open-Sans", "sans-serif"',numberSectionStyles:4,axisFormat:"%Y-%m-%d"}},EditorUi.logError=function(e,t,i,n,r,l,s){if(l=null!=l?l:e.indexOf("NetworkError")>=0||e.indexOf("SecurityError")>=0||e.indexOf("NS_ERROR_FAILURE")>=0||e.indexOf("out of memory")>=0?"CONFIG":"SEVERE",EditorUi.enableLogging&&"1"!=urlParams.dev)try{if(e==EditorUi.lastErrorMessage||null!=e&&null!=t&&(-1!=e.indexOf("Script error")||-1!=e.indexOf("extension")));else if(null!=e&&e.indexOf("DocumentClosedError")<0){EditorUi.lastErrorMessage=e;var o=null!=window.DRAWIO_LOG_URL?window.DRAWIO_LOG_URL:"";r=null!=r?r:new Error(e),(new Image).src=o+"/log?severity="+l+"&v="+encodeURIComponent(EditorUi.VERSION)+"&msg=clientError:"+encodeURIComponent(e)+":url:"+encodeURIComponent(window.location.href)+":lnum:"+encodeURIComponent(i)+(null!=n?":colno:"+encodeURIComponent(n):"")+(null!=r&&null!=r.stack?"&stack="+encodeURIComponent(r.stack):"")}}catch(e){}try{s||null==window.console||console.error(l,e,t,i,n,r)}catch(e){}},EditorUi.logEvent=function(e){if("1"==urlParams.dev)EditorUi.debug("logEvent",e);else if(EditorUi.enableLogging)try{var t=null!=window.DRAWIO_LOG_URL?window.DRAWIO_LOG_URL:"";(new Image).src=t+"/images/1x1.png?v="+encodeURIComponent(EditorUi.VERSION)+(null!=e?"&data="+encodeURIComponent(JSON.stringify(e)):"")}catch(e){}},EditorUi.sendReport=function(e,t){if("1"==urlParams.dev)EditorUi.debug("sendReport",e);else if(EditorUi.enableLogging)try{t=null!=t?t:5e4,e.length>t&&(e=e.substring(0,t)+"\n...[SHORTENED]"),mxUtils.post("/email","version="+encodeURIComponent(EditorUi.VERSION)+"&url="+encodeURIComponent(window.location.href)+"&data="+encodeURIComponent(e))}catch(e){}},EditorUi.debug=function(){try{if(null!=window.console&&"1"==urlParams.test){for(var e=[(new Date).toISOString()],t=0;t<arguments.length;t++)null!=arguments[t]&&e.push(arguments[t]);console.log.apply(console,e)}}catch(e){}},EditorUi.parsePng=function(e,t,i){var n=0;function r(e,t){var i=n;return n+=t,e.substring(i,n)}if(r(e,8)==String.fromCharCode(137)+"PNG"+String.fromCharCode(13,10,26,10))if(r(e,4),"IHDR"==r(e,4)){r(e,17);do{var l=(o=void 0,(o=r(e,4)).charCodeAt(3)+(o.charCodeAt(2)<<8)+(o.charCodeAt(1)<<16)+(o.charCodeAt(0)<<24)),s=r(e,4);if(null!=t&&t(n-8,s,l))break;if(value=r(e,l),r(e,4),"IEND"==s)break}while(l);var o}else null!=i&&i();else null!=i&&i()},EditorUi.removeChildNodes=function(e){for(;null!=e.firstChild;)e.removeChild(e.firstChild)},EditorUi.prototype.emptyDiagramXml='<mxGraphModel><root><mxCell id="0"/><mxCell id="1" parent="0"/></root></mxGraphModel>',EditorUi.prototype.emptyLibraryXml="<mxlibrary>[]</mxlibrary>",EditorUi.prototype.mode=null,EditorUi.prototype.timeout=Editor.prototype.timeout,EditorUi.prototype.sidebarFooterHeight=38,EditorUi.prototype.defaultCustomShapeStyle="shape=stencil(tZRtTsQgEEBPw1+DJR7AoN6DbWftpAgE0Ortd/jYRGq72R+YNE2YgTePloEJGWblgA18ZuKFDcMj5/Sm8boZq+BgjCX4pTyqk6ZlKROitwusOMXKQDODx5iy4pXxZ5qTHiFHawxB0JrQZH7lCabQ0Fr+XWC1/E8zcsT/gAi+Subo2/3Mh6d/oJb5nU1b5tW7r2knautaa3T+U32o7f7vZwpJkaNDLORJjcu7t59m2jXxqX9un+tt022acsfmoKaQZ+vhhswZtS6Ne/ThQGt0IV0N3Yyv6P3CeT9/tHO0XFI5cAE=);whiteSpace=wrap;html=1;",EditorUi.prototype.maxBackgroundSize=1600,EditorUi.prototype.maxImageSize=520,EditorUi.prototype.maxTextWidth=520,EditorUi.prototype.resampleThreshold=1e5,EditorUi.prototype.maxImageBytes=1e6,EditorUi.prototype.maxBackgroundBytes=25e5,EditorUi.prototype.maxTextBytes=5e5,EditorUi.prototype.currentFile=null,EditorUi.prototype.printPdfExport=!1,EditorUi.prototype.pdfPageExport=!0,EditorUi.prototype.formatEnabled="0"!=urlParams.format,EditorUi.prototype.insertTemplateEnabled=!0,EditorUi.prototype.closableScratchpad=!0,EditorUi.prototype.embedExportBorder=8,EditorUi.prototype.embedExportBackground=null,function(){EditorUi.prototype.useCanvasForExport=!1,EditorUi.prototype.jpgSupported=!1;try{var e=document.createElement("canvas");EditorUi.prototype.canvasSupported=!(!e.getContext||!e.getContext("2d"))}catch(e){}try{var t=document.createElement("canvas"),i=new Image;i.onload=function(){try{t.getContext("2d").drawImage(i,0,0);var e=t.toDataURL("image/png");EditorUi.prototype.useCanvasForExport=null!=e&&e.length>6}catch(e){}},i.src="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1px" height="1px" version="1.1"><foreignObject pointer-events="all" width="1" height="1"><div xmlns="http://www.w3.org/1999/xhtml"></div></foreignObject></svg>')))}catch(e){}try{(t=document.createElement("canvas")).width=t.height=1;var n=t.toDataURL("image/jpeg");EditorUi.prototype.jpgSupported=null!==n.match("image/jpeg")}catch(e){}}(),EditorUi.prototype.openLink=function(e,t,i){return this.editor.graph.openLink(e,t,i)},EditorUi.prototype.showSplash=function(e){},EditorUi.prototype.getLocalData=function(e,t){t(localStorage.getItem(e))},EditorUi.prototype.setLocalData=function(e,t,i){localStorage.setItem(e,t),null!=i&&i()},EditorUi.prototype.removeLocalData=function(e,t){localStorage.removeItem(e),t()},EditorUi.prototype.setMathEnabled=function(e){this.editor.graph.mathEnabled=e,this.editor.updateGraphComponents(),this.editor.graph.refresh(),this.editor.graph.defaultMathEnabled=e,this.fireEvent(new mxEventObject("mathEnabledChanged"))},EditorUi.prototype.isMathEnabled=function(e){return this.editor.graph.mathEnabled},EditorUi.prototype.isOfflineApp=function(){return"1"==urlParams.offline},EditorUi.prototype.isOffline=function(e){return this.isOfflineApp()||!navigator.onLine||!e&&("1"==urlParams.stealth||"1"==urlParams.lockdown)},EditorUi.prototype.createSpinner=function(e,t,i){var n=null==e||null==t;i=null!=i?i:24;var r=new Spinner({lines:12,length:i,width:Math.round(i/3),radius:Math.round(i/2),rotate:0,color:Editor.isDarkMode()?"#c0c0c0":"#000",speed:1.5,trail:60,shadow:!1,hwaccel:!1,zIndex:2e9}),l=r.spin;r.spin=function(i,s){var o=!1;if(!this.active){if(l.call(this,i),this.active=!0,null!=s){n&&(t=Math.max(document.body.clientHeight||0,document.documentElement.clientHeight||0)/2,e=document.body.clientWidth/2-2);var a=document.createElement("div");a.style.position="absolute",a.style.whiteSpace="nowrap",a.style.background="#4B4243",a.style.color="white",a.style.fontFamily=Editor.defaultHtmlFont,a.style.fontSize="9pt",a.style.padding="6px",a.style.paddingLeft="10px",a.style.paddingRight="10px",a.style.zIndex=2e9,a.style.left=Math.max(0,e)+"px",a.style.top=Math.max(0,t+70)+"px",mxUtils.setPrefixedStyle(a.style,"borderRadius","6px"),mxUtils.setPrefixedStyle(a.style,"transform","translate(-50%,-50%)"),Editor.isDarkMode()||mxUtils.setPrefixedStyle(a.style,"boxShadow","2px 2px 3px 0px #ddd"),"..."!=s.substring(s.length-3,s.length)&&"!"!=s.charAt(s.length-1)&&(s+="..."),a.innerHTML=s,i.appendChild(a),r.status=a}this.pause=mxUtils.bind(this,(function(){var e=function(){};return this.active&&(e=mxUtils.bind(this,(function(){this.spin(i,s)}))),this.stop(),e})),o=!0}return o};var s=r.stop;return r.stop=function(){s.call(this),this.active=!1,null!=r.status&&null!=r.status.parentNode&&r.status.parentNode.removeChild(r.status),r.status=null},r.pause=function(){return function(){}},r},EditorUi.prototype.isCompatibleString=function(e){try{var t=mxUtils.parseXml(e),i=this.editor.extractGraphModel(t.documentElement,!0);return null!=i&&0==i.getElementsByTagName("parsererror").length}catch(e){}return!1},EditorUi.prototype.isVisioData=function(e){return e.length>8&&(208==e.charCodeAt(0)&&207==e.charCodeAt(1)&&17==e.charCodeAt(2)&&224==e.charCodeAt(3)&&161==e.charCodeAt(4)&&177==e.charCodeAt(5)&&26==e.charCodeAt(6)&&225==e.charCodeAt(7)||80==e.charCodeAt(0)&&75==e.charCodeAt(1)&&3==e.charCodeAt(2)&&4==e.charCodeAt(3)||80==e.charCodeAt(0)&&75==e.charCodeAt(1)&&3==e.charCodeAt(2)&&6==e.charCodeAt(3))},EditorUi.prototype.isRemoteVisioData=function(e){return e.length>8&&(208==e.charCodeAt(0)&&207==e.charCodeAt(1)&&17==e.charCodeAt(2)&&224==e.charCodeAt(3)&&161==e.charCodeAt(4)&&177==e.charCodeAt(5)&&26==e.charCodeAt(6)&&225==e.charCodeAt(7)||60==e.charCodeAt(0)&&63==e.charCodeAt(1)&&120==e.charCodeAt(2)&&109==e.charCodeAt(3)&&108==e.charCodeAt(3))},EditorUi.prototype.isPngData=function(e){return e.length>8&&137==e.charCodeAt(0)&&80==e.charCodeAt(1)&&78==e.charCodeAt(2)&&71==e.charCodeAt(3)&&13==e.charCodeAt(4)&&10==e.charCodeAt(5)&&26==e.charCodeAt(6)&&10==e.charCodeAt(7)};var e=EditorUi.prototype.createKeyHandler;EditorUi.prototype.createKeyHandler=function(t){var i=e.apply(this,arguments);if(!this.editor.chromeless||this.editor.editable){var n=i.getFunction,r=this.editor.graph,l=this;i.getFunction=function(e){if(r.isSelectionEmpty()&&null!=l.pages&&l.pages.length>0){var t=l.getSelectedPageIndex();if(mxEvent.isShiftDown(e)){if(37==e.keyCode)return function(){t>0&&l.movePage(t,t-1)};if(38==e.keyCode)return function(){t>0&&l.movePage(t,0)};if(39==e.keyCode)return function(){t<l.pages.length-1&&l.movePage(t,t+1)};if(40==e.keyCode)return function(){t<l.pages.length-1&&l.movePage(t,l.pages.length-1)}}else if(mxEvent.isControlDown(e)||mxClient.IS_MAC&&mxEvent.isMetaDown(e)){if(37==e.keyCode)return function(){t>0&&l.selectNextPage(!1)};if(38==e.keyCode)return function(){t>0&&l.selectPage(l.pages[0])};if(39==e.keyCode)return function(){t<l.pages.length-1&&l.selectNextPage(!0)};if(40==e.keyCode)return function(){t<l.pages.length-1&&l.selectPage(l.pages[l.pages.length-1])}}}return n.apply(this,arguments)}}return i};var t=EditorUi.prototype.extractGraphModelFromHtml;EditorUi.prototype.extractGraphModelFromHtml=function(e){var i=t.apply(this,arguments);if(null==i)try{var n=e.indexOf("&lt;mxfile ");if(n>=0){var r=e.lastIndexOf("&lt;/mxfile&gt;");r>n&&(i=e.substring(n,r+15).replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/\\&quot;/g,'"').replace(/\n/g,""))}else{var l=mxUtils.parseXml(e),s=this.editor.extractGraphModel(l.documentElement,null!=this.pages||"hidden"==this.diagramContainer.style.visibility);i=null!=s?mxUtils.getXml(s):""}}catch(e){}return i},EditorUi.prototype.validateFileData=function(e){if(null!=e&&e.length>0){var t=e.indexOf('<meta charset="utf-8">');if(t>=0){var i='<meta charset="utf-8"/>',n=i.length;e=e.slice(0,t)+i+e.slice(t+n-1,e.length)}e=Graph.zapGremlins(e)}return e},EditorUi.prototype.replaceFileData=function(e){var t=null!=(e=this.validateFileData(e))&&e.length>0?mxUtils.parseXml(e).documentElement:null,i=null!=t?this.editor.extractGraphModel(t,!0):null;if(null!=i&&(t=i),null!=t){var n=this.editor.graph;n.model.beginUpdate();try{var r=null!=this.pages?this.pages.slice():null,l=t.getElementsByTagName("diagram");if("0"!=urlParams.pages||l.length>1||1==l.length&&l[0].hasAttribute("name")){this.fileNode=t,this.pages=null!=this.pages?this.pages:[];for(var s=l.length-1;s>=0;s--){var o=this.updatePageRoot(new DiagramPage(l[s]));null==o.getName()&&o.setName(mxResources.get("pageWithNumber",[s+1])),n.model.execute(new ChangePage(this,o,0==s?o:null,0))}}else"0"!=urlParams.pages&&null==this.fileNode&&(this.fileNode=t.ownerDocument.createElement("mxfile"),this.currentPage=new DiagramPage(t.ownerDocument.createElement("diagram")),this.currentPage.setName(mxResources.get("pageWithNumber",[1])),n.model.execute(new ChangePage(this,this.currentPage,this.currentPage,0))),this.editor.setGraphXml(t),null!=this.currentPage&&(this.currentPage.root=this.editor.graph.model.root);if(null!=r)for(s=0;s<r.length;s++)n.model.execute(new ChangePage(this,r[s],null))}finally{n.model.endUpdate()}}},EditorUi.prototype.createFileData=function(e,t,i,n,r,l,s,o,a,d,u){t=null!=t?t:this.editor.graph,r=null!=r&&r,a=null==a||a;var h=null,m=null;if(null==i||i.getMode()==App.MODE_DEVICE||i.getMode()==App.MODE_BROWSER?h="_blank":m=h=n,null==e)return"";var g=e;if("mxfile"!=g.nodeName.toLowerCase())if(u)(c=e.ownerDocument.createElement("diagram")).setAttribute("id",Editor.guid()),c.appendChild(e),(g=e.ownerDocument.createElement("mxfile")).appendChild(c);else{var c,p=Graph.zapGremlins(mxUtils.getXml(e)),f=Graph.compress(p);if(Graph.decompress(f)!=p)return p;(c=e.ownerDocument.createElement("diagram")).setAttribute("id",Editor.guid()),mxUtils.setTextContent(c,f),(g=e.ownerDocument.createElement("mxfile")).appendChild(c)}if(d)(g=g.cloneNode(!0)).removeAttribute("modified"),g.removeAttribute("host"),g.removeAttribute("agent"),g.removeAttribute("etag"),g.removeAttribute("userAgent"),g.removeAttribute("version"),g.removeAttribute("editor"),g.removeAttribute("type");else{g.removeAttribute("userAgent"),g.removeAttribute("version"),g.removeAttribute("editor"),g.removeAttribute("pages"),g.removeAttribute("type"),mxClient.IS_CHROMEAPP?g.setAttribute("host","Chrome"):EditorUi.isElectronApp?g.setAttribute("host","Electron"):g.setAttribute("host",window.location.hostname),g.setAttribute("modified",(new Date).toISOString()),g.setAttribute("agent",navigator.appVersion),g.setAttribute("version",EditorUi.VERSION),g.setAttribute("etag",Editor.guid());var x=null!=i?i.getMode():this.mode;null!=x&&g.setAttribute("type",x),g.getElementsByTagName("diagram").length>1&&null!=this.pages&&g.setAttribute("pages",this.pages.length)}var v=u?mxUtils.getPrettyXml(g):mxUtils.getXml(g);return l||r||!(s||null!=i&&/(\.html)$/i.test(i.getTitle()))?(l||!r&&null!=i&&/(\.svg)$/i.test(i.getTitle()))&&(null==i||i.getMode()!=App.MODE_DEVICE&&i.getMode()!=App.MODE_BROWSER||(n=null),v=this.getEmbeddedSvg(v,t,n,null,o,a,m)):v=this.getHtml2(mxUtils.getXml(g),t,null!=i?i.getTitle():null,h,m),v},EditorUi.prototype.getXmlFileData=function(e,t,i,n){e=null==e||e,t=null!=t&&t,i=null!=i?i:!Editor.compressXml;var r=this.editor.getGraphXml(e,n);if(e&&null!=this.fileNode&&null!=this.currentPage){function l(e){var t=e.getElementsByTagName("mxGraphModel"),n=t.length>0?t[0]:null,l=e;if(null==n&&i){var s=mxUtils.trim(mxUtils.getTextContent(e));if(l=e.cloneNode(!1),s.length>0){var o=Graph.decompress(s);null!=o&&o.length>0&&l.appendChild(mxUtils.parseXml(o).documentElement)}}else null==n||i?l=e.cloneNode(!0):(l=e.cloneNode(!1),mxUtils.setTextContent(l,Graph.compressNode(n)));r.appendChild(l)}if(EditorUi.removeChildNodes(this.currentPage.node),mxUtils.setTextContent(this.currentPage.node,Graph.compressNode(r)),r=this.fileNode.cloneNode(!1),t)l(this.currentPage.node);else for(var s=0;s<this.pages.length;s++){var o=this.pages[s],a=o.node;if(o!=this.currentPage)if(o.needsUpdate){var d=new mxCodec(mxUtils.createXmlDocument()).encode(new mxGraphModel(o.root));this.editor.graph.saveViewState(o.viewState,d,null,n),EditorUi.removeChildNodes(a),mxUtils.setTextContent(a,Graph.compressNode(d)),delete o.needsUpdate}else n&&(this.updatePageRoot(o),null!=o.viewState.backgroundImage&&(null!=o.viewState.backgroundImage.originalSrc?o.viewState.backgroundImage=this.createImageForPageLink(o.viewState.backgroundImage.originalSrc,o):Graph.isPageLink(o.viewState.backgroundImage.src)&&(o.viewState.backgroundImage=this.createImageForPageLink(o.viewState.backgroundImage.src,o))),null!=o.viewState.backgroundImage&&null!=o.viewState.backgroundImage.originalSrc)&&(d=new mxCodec(mxUtils.createXmlDocument()).encode(new mxGraphModel(o.root)),this.editor.graph.saveViewState(o.viewState,d,null,n),a=a.cloneNode(!1),mxUtils.setTextContent(a,Graph.compressNode(d)));l(a)}}return r},EditorUi.prototype.anonymizeString=function(e,t){for(var i=[],n=0;n<e.length;n++){var r=e.charAt(n);EditorUi.ignoredAnonymizedChars.indexOf(r)>=0?i.push(r):isNaN(parseInt(r))?r.toLowerCase()!=r?i.push(String.fromCharCode(65+Math.round(25*Math.random()))):r.toUpperCase()!=r?i.push(String.fromCharCode(97+Math.round(25*Math.random()))):/\s/.test(r)?i.push(" "):i.push("?"):i.push(t?"0":Math.round(9*Math.random()))}return i.join("")},EditorUi.prototype.anonymizePatch=function(e){if(null!=e[EditorUi.DIFF_INSERT])for(var t=0;t<e[EditorUi.DIFF_INSERT].length;t++)try{var i=e[EditorUi.DIFF_INSERT][t].data,n=mxUtils.parseXml(i).documentElement.cloneNode(!1);null!=n.getAttribute("name")&&n.setAttribute("name",this.anonymizeString(n.getAttribute("name"))),e[EditorUi.DIFF_INSERT][t].data=mxUtils.getXml(n)}catch(i){e[EditorUi.DIFF_INSERT][t].data=i.message}if(null!=e[EditorUi.DIFF_UPDATE]){for(var r in e[EditorUi.DIFF_UPDATE]){var l=e[EditorUi.DIFF_UPDATE][r];if(null!=l.name&&(l.name=this.anonymizeString(l.name)),null!=l.cells){var s=mxUtils.bind(this,(function(e){var t=l.cells[e];if(null!=t){for(var i in t)null!=t[i].value&&(t[i].value="["+t[i].value.length+"]"),null!=t[i].xmlValue&&(t[i].xmlValue="["+t[i].xmlValue.length+"]"),null!=t[i].style&&(t[i].style="["+t[i].style.length+"]"),0==Object.keys(t[i]).length&&delete t[i];0==Object.keys(t).length&&delete l.cells[e]}}));s(EditorUi.DIFF_INSERT),s(EditorUi.DIFF_UPDATE),0==Object.keys(l.cells).length&&delete l.cells}0==Object.keys(l).length&&delete e[EditorUi.DIFF_UPDATE][r]}0==Object.keys(e[EditorUi.DIFF_UPDATE]).length&&delete e[EditorUi.DIFF_UPDATE]}return e},EditorUi.prototype.anonymizeAttributes=function(e,t){if(null!=e.attributes)for(var i=0;i<e.attributes.length;i++)"as"!=e.attributes[i].name&&e.setAttribute(e.attributes[i].name,this.anonymizeString(e.attributes[i].value,t));if(null!=e.childNodes)for(i=0;i<e.childNodes.length;i++)this.anonymizeAttributes(e.childNodes[i],t)},EditorUi.prototype.anonymizeNode=function(e,t){for(var i=e.getElementsByTagName("mxCell"),n=0;n<i.length;n++)null!=i[n].getAttribute("value")&&i[n].setAttribute("value","["+i[n].getAttribute("value").length+"]"),null!=i[n].getAttribute("xmlValue")&&i[n].setAttribute("xmlValue","["+i[n].getAttribute("xmlValue").length+"]"),null!=i[n].getAttribute("style")&&i[n].setAttribute("style","["+i[n].getAttribute("style").length+"]"),null!=i[n].parentNode&&"root"!=i[n].parentNode.nodeName&&null!=i[n].parentNode.parentNode&&(i[n].setAttribute("id",i[n].parentNode.getAttribute("id")),i[n].parentNode.parentNode.replaceChild(i[n],i[n].parentNode));return e},EditorUi.prototype.synchronizeCurrentFile=function(e){var t=this.getCurrentFile();null!=t&&(t.savingFile?this.handleError({message:mxResources.get("busy")}):!e&&t.invalidChecksum?t.handleFileError(null,!0):this.spinner.spin(document.body,mxResources.get("updatingDocument"))&&(t.clearAutosave(),this.editor.setStatus(""),e?t.reloadFile(mxUtils.bind(this,(function(){t.handleFileSuccess("manual"==DrawioFile.SYNC)})),mxUtils.bind(this,(function(e){t.handleFileError(e,!0)}))):t.synchronizeFile(mxUtils.bind(this,(function(){t.handleFileSuccess("manual"==DrawioFile.SYNC)})),mxUtils.bind(this,(function(e){t.handleFileError(e,!0)})))))},EditorUi.prototype.getFileData=function(e,t,i,n,r,l,s,o,a,d,u){r=null==r||r,l=null!=l&&l;var h=this.editor.graph;if(t||!e&&null!=a&&/(\.svg)$/i.test(a.getTitle())){var m=null!=h.themes&&"darkTheme"==h.defaultThemeName;if(d=!1,m||null!=this.pages&&this.currentPage!=this.pages[0]){var g=h.getGlobalVariable;(h=this.createTemporaryGraph(m?h.getDefaultStylesheet():h.getStylesheet())).setBackgroundImage=this.editor.graph.setBackgroundImage;var c=this.pages[0];this.currentPage==c?h.setBackgroundImage(this.editor.graph.backgroundImage):null!=c.viewState&&null!=c.viewState&&h.setBackgroundImage(c.viewState.backgroundImage),h.getGlobalVariable=function(e){return"page"==e?c.getName():"pagenumber"==e?1:g.apply(this,arguments)},this.container.appendChild(h.container)||document.body.appendChild(h.container),h.model.setRoot(c.root)}}s=null!=s?s:this.getXmlFileData(r,l,d,u),a=null!=a?a:this.getCurrentFile();var p=this.createFileData(s,h,a,window.location.href,e,t,i,n,r,o,d);return h!=this.editor.graph&&h.container.parentNode.removeChild(h.container),p},EditorUi.prototype.getHtml=function(e,t,i,n,r,l){l=null==l||l;var s=null,o=EditorUi.drawHost+"/js/embed-static.min.js";if(null!=t){var a=l?t.getGraphBounds():t.getBoundingBox(t.getSelectionCells()),d=t.view.scale,u=Math.floor(a.x/d-t.view.translate.x),h=Math.floor(a.y/d-t.view.translate.y);if(s=t.background,null==r){var m=this.getBasenames().join(";");m.length>0&&(o=EditorUi.drawHost+"/embed.js?s="+m)}e.setAttribute("x0",u),e.setAttribute("y0",h)}null!=e&&(e.setAttribute("pan","1"),e.setAttribute("zoom","1"),e.setAttribute("resize","0"),e.setAttribute("fit","0"),e.setAttribute("border","20"),e.setAttribute("links","1"),null!=n&&e.setAttribute("edit",n)),null!=r&&(r=r.replace(/&/g,"&amp;"));var g=null!=e?Graph.zapGremlins(mxUtils.getXml(e)):"",c=Graph.compress(g);return Graph.decompress(c)!=g&&(c=encodeURIComponent(g)),(null==r?'\x3c!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=5,IE=9" ><![endif]--\x3e\n':"")+"<!DOCTYPE html>\n<html"+(null!=r?' xmlns="http://www.w3.org/1999/xhtml">':">")+"\n<head>\n"+(null==r?null!=i?"<title>"+mxUtils.htmlEntities(i)+"</title>\n":"":"<title>diagrams.net</title>\n")+(null!=r?'<meta http-equiv="refresh" content="0;URL=\''+r+"'\"/>\n":"")+"</head>\n<body"+(null==r&&null!=s&&s!=mxConstants.NONE?' style="background-color:'+s+';">':">")+'\n<div class="mxgraph" style="position:relative;overflow:auto;width:100%;">\n<div style="width:1px;height:1px;overflow:hidden;">'+c+"</div>\n</div>\n"+(null==r?'<script type="text/javascript" src="'+o+'"><\/script>':'<a style="position:absolute;top:50%;left:50%;margin-top:-128px;margin-left:-64px;" href="'+r+'" target="_blank"><img border="0" src="'+EditorUi.drawHost+'/images/drawlogo128.png"/></a>')+"\n</body>\n</html>\n"},EditorUi.prototype.getHtml2=function(e,t,i,n,r){var l=window.DRAWIO_VIEWER_URL||EditorUi.drawHost+"/js/viewer-static.min.js";null!=r&&(r=r.replace(/&/g,"&amp;"));var s={highlight:"#0000ff",nav:this.editor.graph.foldingEnabled,resize:!0,xml:Graph.zapGremlins(e),toolbar:"pages zoom layers lightbox"};return null!=this.pages&&null!=this.currentPage&&(s.page=mxUtils.indexOf(this.pages,this.currentPage)),(null==r?'\x3c!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=5,IE=9" ><![endif]--\x3e\n':"")+"<!DOCTYPE html>\n<html"+(null!=r?' xmlns="http://www.w3.org/1999/xhtml">':">")+"\n<head>\n"+(null==r?null!=i?"<title>"+mxUtils.htmlEntities(i)+"</title>\n":"":"<title>diagrams.net</title>\n")+(null!=r?'<meta http-equiv="refresh" content="0;URL=\''+r+"'\"/>\n":"")+'<meta charset="utf-8"/>\n</head>\n<body>\n<div class="mxgraph" style="max-width:100%;border:1px solid transparent;" data-mxgraph="'+mxUtils.htmlEntities(JSON.stringify(s))+'"></div>\n'+(null==r?'<script type="text/javascript" src="'+l+'"><\/script>':'<a style="position:absolute;top:50%;left:50%;margin-top:-128px;margin-left:-64px;" href="'+r+'" target="_blank"><img border="0" src="'+EditorUi.drawHost+'/images/drawlogo128.png"/></a>')+"\n</body>\n</html>\n"},EditorUi.prototype.setFileData=function(e){e=this.validateFileData(e),this.currentPage=null,this.fileNode=null,this.pages=null;var t=null!=e&&e.length>0?mxUtils.parseXml(e).documentElement:null,i=Editor.extractParserError(t,mxResources.get("invalidOrMissingFile"));if(i)throw new Error(mxResources.get("notADiagramFile")+" ("+i+")");var n=null!=t?this.editor.extractGraphModel(t,!0):null;if(null!=n&&(t=n),null!=t&&"mxfile"==t.nodeName){var r=t.getElementsByTagName("diagram");if("0"!=urlParams.pages||r.length>1||1==r.length&&r[0].hasAttribute("name")){var l=null;this.fileNode=t,this.pages=[];for(var s=0;s<r.length;s++){null==r[s].getAttribute("id")&&r[s].setAttribute("id",s);var o=new DiagramPage(r[s]);null==o.getName()&&o.setName(mxResources.get("pageWithNumber",[s+1])),this.pages.push(o),null!=urlParams["page-id"]&&o.getId()==urlParams["page-id"]&&(l=o)}this.currentPage=null!=l?l:this.pages[Math.max(0,Math.min(this.pages.length-1,urlParams.page||0))],t=this.currentPage.node}}if("0"!=urlParams.pages&&null==this.fileNode&&null!=t&&(this.fileNode=t.ownerDocument.createElement("mxfile"),this.currentPage=new DiagramPage(t.ownerDocument.createElement("diagram")),this.currentPage.setName(mxResources.get("pageWithNumber",[1])),this.pages=[this.currentPage]),this.editor.setGraphXml(t),null!=this.currentPage&&(this.currentPage.root=this.editor.graph.model.root),null!=urlParams["layer-ids"])try{var a=urlParams["layer-ids"].split(" "),d={};for(s=0;s<a.length;s++)d[a[s]]=!0;var u=this.editor.graph.getModel(),h=u.getChildren(u.root);for(s=0;s<h.length;s++){var m=h[s];u.setVisible(m,d[m.id]||!1)}}catch(e){}},EditorUi.prototype.getBaseFilename=function(e){var t=this.getCurrentFile(),i=null!=t&&null!=t.getTitle()?t.getTitle():this.defaultFilename;return(/(\.xml)$/i.test(i)||/(\.html)$/i.test(i)||/(\.svg)$/i.test(i)||/(\.png)$/i.test(i))&&(i=i.substring(0,i.lastIndexOf("."))),/(\.drawio)$/i.test(i)&&(i=i.substring(0,i.lastIndexOf("."))),!e&&null!=this.pages&&this.pages.length>1&&null!=this.currentPage&&null!=this.currentPage.node.getAttribute("name")&&this.currentPage.getName().length>0&&(i=i+"-"+this.currentPage.getName()),i},EditorUi.prototype.downloadFile=function(e,t,i,n,r,l,s,o,a,d,u,h){try{n=null!=n?n:this.editor.graph.isSelectionEmpty();var m=this.getBaseFilename(!r),g=m+("xml"==e||"pdf"==e&&u?".drawio":"")+"."+e;if("xml"==e){var c=Graph.xmlDeclaration+"\n"+this.getFileData(!0,null,null,null,n,r,null,null,null,t);this.saveData(g,e,c,"text/xml")}else if("html"==e)c=this.getHtml2(this.getFileData(!0),this.editor.graph,m),this.saveData(g,e,c,"text/html");else if("svg"!=e&&"xmlsvg"!=e||!this.spinner.spin(document.body,mxResources.get("export")))"xmlpng"==e?g=m+".png":"jpeg"==e&&(g=m+".jpg"),this.saveRequest(g,e,mxUtils.bind(this,(function(t,i){try{var m=this.editor.graph.pageVisible;null!=l&&(this.editor.graph.pageVisible=l);var g=this.createDownloadRequest(t,e,n,i,s,r,o,a,d,u,h);return this.editor.graph.pageVisible=m,g}catch(e){this.handleError(e)}})));else{var p=null,f=mxUtils.bind(this,(function(e){e.length<=MAX_REQUEST_SIZE?this.saveData(g,"svg",e,"image/svg+xml"):this.handleError({message:mxResources.get("drawingTooLarge")},mxResources.get("error"),mxUtils.bind(this,(function(){mxUtils.popup(p)})))}));if("svg"==e){var x=this.editor.graph.background;(s||x==mxConstants.NONE)&&(x=null);var v=this.editor.graph.getSvg(x,null,null,null,null,n);i&&this.editor.graph.addSvgShadow(v),this.editor.convertImages(v,mxUtils.bind(this,mxUtils.bind(this,(function(e){this.spinner.stop(),f(Graph.xmlDeclaration+"\n"+Graph.svgDoctype+"\n"+mxUtils.getXml(e))}))))}else g=m+".svg",p=this.getFileData(!1,!0,null,mxUtils.bind(this,(function(e){this.spinner.stop(),f(e)})),n)}}catch(e){this.handleError(e)}},EditorUi.prototype.createDownloadRequest=function(e,t,i,n,r,l,s,o,a,d,u){var h=this.editor.graph,m=h.getGraphBounds(),g=this.getFileData(!0,null,null,null,i,0!=l&&"xmlpng"!=t,null,null,null,!1,"pdf"==t),c="",p="";if(m.width*m.height>MAX_AREA||g.length>MAX_REQUEST_SIZE)throw{message:mxResources.get("drawingTooLarge")};var f=d?"1":"0";if("pdf"==t&&(null!=u?p="&from="+u.from+"&to="+u.to:0==l&&(p="&allPages=1")),"xmlpng"==t&&(f="1",t="png",null!=this.pages&&null!=this.currentPage))for(var x=0;x<this.pages.length;x++)if(this.pages[x]==this.currentPage){c="&from="+x;break}var v=h.background;"png"!=t&&"pdf"!=t||!r?r||null!=v&&v!=mxConstants.NONE||(v="#ffffff"):v=mxConstants.NONE;var b={globalVars:h.getExportVariables()};return a&&(b.grid={size:h.gridSize,steps:h.view.gridSteps,color:h.view.gridColor}),Graph.translateDiagram&&(b.diagramLanguage=Graph.diagramLanguage),new mxXmlRequest(EXPORT_URL,"format="+t+c+p+"&bg="+(null!=v?v:mxConstants.NONE)+"&base64="+n+"&embedXml="+f+"&xml="+encodeURIComponent(g)+(null!=e?"&filename="+encodeURIComponent(e):"")+"&extras="+encodeURIComponent(JSON.stringify(b))+(null!=s?"&scale="+s:"")+(null!=o?"&border="+o:""))},EditorUi.prototype.setMode=function(e,t){this.mode=e},EditorUi.prototype.loadDescriptor=function(e,t,i){var n=window.location.hash,r=mxUtils.bind(this,(function(i){var r=null!=e.data?e.data:"";null!=i&&i.length>0&&(r.length>0&&(r+="\n"),r+=i);var l="csv"!=e.format&&r.length>0?r:this.emptyDiagramXml,s=new LocalFile(this,l,null!=urlParams.title?decodeURIComponent(urlParams.title):this.defaultFilename,!0);if(s.getHash=function(){return n},this.fileLoaded(s),"csv"==e.format&&this.importCsv(r,mxUtils.bind(this,(function(e){this.editor.undoManager.clear(),this.editor.setModified(!1),this.editor.setStatus("")}))),null!=e.update){var o=null!=e.interval?parseInt(e.interval):6e4,a=null,d=mxUtils.bind(this,(function(){var t=this.currentPage;mxUtils.post(e.update,"xml="+encodeURIComponent(mxUtils.getXml(this.editor.getGraphXml())),mxUtils.bind(this,(function(e){t===this.currentPage&&(e.getStatus()>=200&&e.getStatus()<=300?(this.updateDiagram(e.getText()),u()):this.handleError({message:mxResources.get("error")+" "+e.getStatus()}))})),mxUtils.bind(this,(function(e){this.handleError(e)})))})),u=mxUtils.bind(this,(function(){window.clearTimeout(a),a=window.setTimeout(d,o)}));this.editor.addListener("pageSelected",mxUtils.bind(this,(function(){u(),d()}))),u(),d()}null!=t&&t()}));null!=e.url&&e.url.length>0?this.editor.loadUrl(e.url,mxUtils.bind(this,(function(e){r(e)})),mxUtils.bind(this,(function(e){null!=i&&i(e)}))):r("")},EditorUi.prototype.updateDiagram=function(e){var t=null,i=this;function n(e){var t=new mxCellOverlay(e.image||l.warningImage,e.tooltip,e.align,e.valign,e.offset);return t.addListener(mxEvent.CLICK,(function(t,n){i.alert(e.tooltip)})),t}if(null!=e&&e.length>0){var r=null!=(t=mxUtils.parseXml(e))?t.documentElement:null;if(null!=r&&"updates"==r.nodeName){var l=this.editor.graph,s=l.getModel();s.beginUpdate();var o=null;try{for(r=r.firstChild;null!=r;){if("update"==r.nodeName){var a=s.getCell(r.getAttribute("id"));if(null!=a){try{var d=r.getAttribute("value");if(null!=d){var u=mxUtils.parseXml(d).documentElement;if(null!=u)if("1"==u.getAttribute("replace-value"))s.setValue(a,u);else for(var h=u.attributes,m=0;m<h.length;m++)l.setAttributeForCell(a,h[m].nodeName,h[m].nodeValue.length>0?h[m].nodeValue:null)}}catch(e){null!=window.console&&console.log("Error in value for "+a.id+": "+e)}try{var g=r.getAttribute("style");null!=g&&l.model.setStyle(a,g)}catch(e){null!=window.console&&console.log("Error in style for "+a.id+": "+e)}try{var c=r.getAttribute("icon");if(null!=c){var p=c.length>0?JSON.parse(c):null;null!=p&&p.append||l.removeCellOverlays(a),null!=p&&l.addCellOverlay(a,n(p))}}catch(e){null!=window.console&&console.log("Error in icon for "+a.id+": "+e)}try{var f=r.getAttribute("geometry");if(null!=f){f=JSON.parse(f);var x=l.getCellGeometry(a);if(null!=x){for(key in x=x.clone(),f){var v=parseFloat(f[key]);"dx"==key?x.x+=v:"dy"==key?x.y+=v:"dw"==key?x.width+=v:"dh"==key?x.height+=v:x[key]=parseFloat(f[key])}l.model.setGeometry(a,x)}}}catch(e){null!=window.console&&console.log("Error in icon for "+a.id+": "+e)}}}else if("model"==r.nodeName){for(var b=r.firstChild;null!=b&&b.nodeType!=mxConstants.NODETYPE_ELEMENT;)b=b.nextSibling;null!=b&&new mxCodec(r.firstChild).decode(b,s)}else"view"==r.nodeName?(r.hasAttribute("scale")&&(l.view.scale=parseFloat(r.getAttribute("scale"))),(r.hasAttribute("dx")||r.hasAttribute("dy"))&&(l.view.translate=new mxPoint(parseFloat(r.getAttribute("dx")||0),parseFloat(r.getAttribute("dy")||0)))):"fit"==r.nodeName&&(o=r.hasAttribute("max-scale")?parseFloat(r.getAttribute("max-scale")):1);r=r.nextSibling}}finally{s.endUpdate()}null!=o&&this.chromelessResize&&this.chromelessResize(!0,o)}}return t},EditorUi.prototype.getCopyFilename=function(e,t){var i,n=null!=e&&null!=e.getTitle()?e.getTitle():this.defaultFilename,r="",l=n.lastIndexOf(".");return l>=0&&(r=n.substring(l),n=n.substring(0,l)),t&&(new Date,n+=" "+(i=new Date).getFullYear()+"-"+(i.getMonth()+1)+"-"+i.getDate()+"-"+i.getHours()+"-"+i.getMinutes()+"-"+i.getSeconds()),mxResources.get("copyOf",[n])+r},EditorUi.prototype.fileLoaded=function(e,t){var i=this.getCurrentFile();this.fileLoadedError=null,this.fileEditable=null,this.setCurrentFile(null);var n=!1;this.hideDialog(),null!=i&&(EditorUi.debug("File.closed",[i]),i.removeListener(this.descriptorChangedListener),i.close()),this.editor.graph.model.clear(),this.editor.undoManager.clear();var r=mxUtils.bind(this,(function(){this.setGraphEnabled(!1),this.setCurrentFile(null),null!=i&&this.updateDocumentTitle(),this.editor.graph.model.clear(),this.editor.undoManager.clear(),this.setBackgroundImage(null),!t&&null!=window.location.hash&&window.location.hash.length>0&&(window.location.hash=""),null!=this.fname&&(this.fnameWrapper.style.display="none",this.fname.innerHTML="",this.fname.setAttribute("title",mxResources.get("rename"))),this.editor.setStatus(""),this.updateUi(),t||this.showSplash()}));if(null!=e)try{if(mxClient.IS_SF&&"min"==uiTheme&&(this.diagramContainer.style.visibility=""),this.openingFile=!0,this.setCurrentFile(e),e.addListener("descriptorChanged",this.descriptorChangedListener),e.addListener("contentChanged",this.descriptorChangedListener),e.open(),delete this.openingFile,this.setGraphEnabled(!0),this.setMode(e.getMode()),this.editor.graph.model.prefix=Editor.guid()+"-",this.editor.undoManager.clear(),this.descriptorChanged(),this.updateUi(),e.isEditable()?e.isModified()?(e.addUnsavedStatus(),null!=e.backupPatch&&e.patch([e.backupPatch])):this.editor.setStatus(""):this.editor.setStatus('<span class="geStatusAlert">'+mxUtils.htmlEntities(mxResources.get("readOnly"))+"</span>"),!this.editor.isChromelessView()||this.editor.editable?(this.editor.graph.selectUnlockedLayer(),this.showLayersDialog(),this.restoreLibraries(),window.self!==window.top&&window.focus()):this.editor.graph.isLightboxView()&&this.lightboxFit(),this.chromelessResize&&this.chromelessResize(),this.editor.fireEvent(new mxEventObject("fileLoaded")),n=!0,this.isOffline()||null==e.getMode()||EditorUi.logEvent({category:e.getMode().toUpperCase()+"-OPEN-FILE-"+e.getHash(),action:"size_"+e.getSize(),label:"autosave_"+(this.editor.autosave?"on":"off")}),EditorUi.debug("File.opened",[e]),"1"==urlParams.viewerOnlyMsg&&this.showAlert(mxResources.get("viewerOnlyMsg")),this.editor.editable&&this.mode==e.getMode()&&e.getMode()!=App.MODE_DEVICE&&null!=e.getMode())try{this.addRecent({id:e.getHash(),title:e.getTitle(),mode:e.getMode()})}catch(e){}try{mxSettings.setOpenCounter(mxSettings.getOpenCounter()+1),mxSettings.save()}catch(e){}}catch(n){if(this.fileLoadedError=n,EditorUi.enableLogging&&!this.isOffline())try{EditorUi.logEvent({category:"ERROR-LOAD-FILE-"+(null!=e?e.getHash():"none"),action:"message_"+n.message,label:"stack_"+n.stack})}catch(e){}var l=mxUtils.bind(this,(function(){null!=urlParams.url&&this.spinner.spin(document.body,mxResources.get("reconnecting"))?window.location.search=this.getSearch(["url"]):null!=i?this.fileLoaded(i):r()}));t?l():this.handleError(n,mxResources.get("errorLoadingFile"),l,!0,null,null,!0)}else r();return n},EditorUi.prototype.getHashValueForPages=function(e,t){var i=0,n=new mxGraphModel,r=new mxCodec;null!=t&&(t.byteCount=0,t.attrCount=0,t.eltCount=0,t.nodeCount=0);for(var l=0;l<e.length;l++){this.updatePageRoot(e[l]);var s=e[l].node.cloneNode(!1);s.removeAttribute("name"),n.root=e[l].root;var o=r.encode(n);this.editor.graph.saveViewState(e[l].viewState,o,!0),o.removeAttribute("pageWidth"),o.removeAttribute("pageHeight"),s.appendChild(o),null!=t&&(t.eltCount+=s.getElementsByTagName("*").length,t.nodeCount+=s.getElementsByTagName("mxCell").length),i=(i<<5)-i+this.hashValue(s,(function(e,t,i,n){return!n||"mxGeometry"!=e.nodeName&&"mxPoint"!=e.nodeName||"x"!=t&&"y"!=t&&"width"!=t&&"height"!=t?n&&"mxCell"==e.nodeName&&"previous"==t?null:i:Math.round(i)}),t)<<0}return i},EditorUi.prototype.hashValue=function(e,t,i){var n=0;if(null!=e&&"object"==typeof e&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName&&"function"==typeof e.getAttribute){if(null!=e.nodeName&&(n^=this.hashValue(e.nodeName,t,i)),null!=e.attributes){null!=i&&(i.attrCount+=e.attributes.length);for(var r=0;r<e.attributes.length;r++){var l=e.attributes[r].name,s=null!=t?t(e,l,e.attributes[r].value,!0):e.attributes[r].value;null!=s&&(n^=this.hashValue(l,t,i)+this.hashValue(s,t,i))}}if(null!=e.childNodes)for(r=0;r<e.childNodes.length;r++)n=(n<<5)-n+this.hashValue(e.childNodes[r],t,i)<<0}else if(null!=e&&"function"!=typeof e){var o=String(e),a=0;for(null!=i&&(i.byteCount+=o.length),r=0;r<o.length;r++)a=(a<<5)-a+o.charCodeAt(r)<<0;n^=a}return n},EditorUi.prototype.descriptorChanged=function(){},EditorUi.prototype.restoreLibraries=function(){},EditorUi.prototype.saveLibrary=function(e,t,i,n,r,l,s){},EditorUi.prototype.isScratchpadEnabled=function(){return isLocalStorage||mxClient.IS_CHROMEAPP},EditorUi.prototype.toggleScratchpad=function(){this.isScratchpadEnabled()&&(null==this.scratchpad?StorageFile.getFileContent(this,".scratchpad",mxUtils.bind(this,(function(e){null==e&&(e=this.emptyLibraryXml),this.loadLibrary(new StorageLibrary(this,e,".scratchpad"))}))):this.closeLibrary(this.scratchpad))},EditorUi.prototype.createLibraryDataFromImages=function(e){var t=mxUtils.createXmlDocument(),i=t.createElement("mxlibrary");return mxUtils.setTextContent(i,JSON.stringify(e)),t.appendChild(i),mxUtils.getXml(t)},EditorUi.prototype.closeLibrary=function(e){null!=e&&(this.removeLibrarySidebar(e.getHash()),e.constructor!=LocalLibrary&&mxSettings.removeCustomLibrary(e.getHash()),".scratchpad"==e.title&&(this.scratchpad=null))},EditorUi.prototype.removeLibrarySidebar=function(e){var t=this.sidebar.palettes[e];if(null!=t){for(var i=0;i<t.length;i++)t[i].parentNode.removeChild(t[i]);delete this.sidebar.palettes[e]}},EditorUi.prototype.repositionLibrary=function(e){var t=this.sidebar.container;if(null==e){var i=this.sidebar.palettes["L.scratchpad"];null==i&&(i=this.sidebar.palettes.search),null!=i&&(e=i[i.length-1].nextSibling)}e=null!=e?e:t.firstChild.nextSibling.nextSibling;var n=t.lastChild,r=n.previousSibling;t.insertBefore(n,e),t.insertBefore(r,n)},EditorUi.prototype.loadLibrary=function(e,t){var i=mxUtils.parseXml(e.getData());if("mxlibrary"!=i.documentElement.nodeName)throw{message:mxResources.get("notALibraryFile")};var n=JSON.parse(mxUtils.getTextContent(i.documentElement));this.libraryLoaded(e,n,i.documentElement.getAttribute("title"),t)},EditorUi.prototype.getLibraryStorageHint=function(e){return""},EditorUi.prototype.libraryLoaded=function(e,t,i,n){if(null!=this.sidebar){e.constructor!=LocalLibrary&&mxSettings.addCustomLibrary(e.getHash()),".scratchpad"==e.title&&(this.scratchpad=e);var r=this.sidebar.palettes[e.getHash()],l=null!=r?r[r.length-1].nextSibling:null;this.removeLibrarySidebar(e.getHash());var s=null,o=mxUtils.bind(this,(function(t,i){0==t.length&&e.isEditable()?(null==s&&((s=document.createElement("div")).className="geDropTarget",mxUtils.write(s,mxResources.get("dragElementsHere"))),i.appendChild(s)):this.addLibraryEntries(t,i)}));null!=this.sidebar&&null!=t&&this.sidebar.addEntries(t);var a=null!=i&&i.length>0?i:e.getTitle(),d=this.sidebar.addPalette(e.getHash(),a,null==n||n,mxUtils.bind(this,(function(e){o(t,e)})));this.repositionLibrary(l);var u=d.parentNode.previousSibling,h=u.getAttribute("title");null!=h&&h.length>0&&".scratchpad"!=e.title&&u.setAttribute("title",this.getLibraryStorageHint(e)+"\n"+h);var m=document.createElement("div");m.style.position="absolute",m.style.right="0px",m.style.top="0px",m.style.padding="8px",m.style.backgroundColor="inherit",u.style.position="relative";var g=document.createElement("img");g.setAttribute("src",Editor.crossImage),g.setAttribute("title",mxResources.get("close")),g.setAttribute("valign","absmiddle"),g.setAttribute("border","0"),g.style.position="relative",g.style.top="2px",g.style.width="14px",g.style.cursor="pointer",g.style.margin="0 3px",Editor.isDarkMode()&&(g.style.filter="invert(100%)");var c=null;if((".scratchpad"!=e.title||this.closableScratchpad)&&(m.appendChild(g),mxEvent.addListener(g,"click",mxUtils.bind(this,(function(t){if(!mxEvent.isConsumed(t)){var i=mxUtils.bind(this,(function(){this.closeLibrary(e)}));null!=c?this.confirm(mxResources.get("allChangesLost"),null,i,mxResources.get("cancel"),mxResources.get("discardChanges")):i(),mxEvent.consume(t)}})))),e.isEditable()){var p=this.editor.graph,f=null,x=mxUtils.bind(this,(function(i){this.showLibraryDialog(e.getTitle(),d,t,e,e.getMode()),mxEvent.consume(i)})),v=mxUtils.bind(this,(function(i){e.setModified(!0),e.isAutosave()?(null!=f&&null!=f.parentNode&&f.parentNode.removeChild(f),(f=g.cloneNode(!1)).setAttribute("src",Editor.spinImage),f.setAttribute("title",mxResources.get("saving")),f.style.cursor="default",f.style.marginRight="2px",f.style.marginTop="-2px",m.insertBefore(f,m.firstChild),u.style.paddingRight=18*m.childNodes.length+"px",this.saveLibrary(e.getTitle(),t,e,e.getMode(),!0,!0,(function(){null!=f&&null!=f.parentNode&&(f.parentNode.removeChild(f),u.style.paddingRight=18*m.childNodes.length+"px")}))):null==c&&((c=g.cloneNode(!1)).setAttribute("src",Editor.saveImage),c.setAttribute("title",mxResources.get("save")),m.insertBefore(c,m.firstChild),mxEvent.addListener(c,"click",mxUtils.bind(this,(function(i){this.saveLibrary(e.getTitle(),t,e,e.getMode(),e.constructor==LocalLibrary,!0,(function(){null==c||e.isModified()||(u.style.paddingRight=18*m.childNodes.length+"px",c.parentNode.removeChild(c),c=null)})),mxEvent.consume(i)}))),u.style.paddingRight=18*m.childNodes.length+"px")})),b=mxUtils.bind(this,(function(e,i,n,r){e=p.cloneCells(mxUtils.sortCells(p.model.getTopmostCells(e)));for(var l=0;l<e.length;l++){var o=p.getCellGeometry(e[l]);null!=o&&o.translate(-i.x,-i.y)}d.appendChild(this.sidebar.createVertexTemplateFromCells(e,i.width,i.height,r||"",!0,!1,!1));var a={xml:Graph.compress(mxUtils.getXml(this.editor.graph.encodeCells(e))),w:i.width,h:i.height};null!=r&&(a.title=r),t.push(a),v(n),null!=s&&null!=s.parentNode&&t.length>0&&(s.parentNode.removeChild(s),s=null)})),y=mxUtils.bind(this,(function(e){if(p.isSelectionEmpty())p.getRubberband().isActive()?(p.getRubberband().execute(e),p.getRubberband().reset()):this.showError(mxResources.get("error"),mxResources.get("nothingIsSelected"),mxResources.get("ok"));else{var t=p.getSelectionCells(),i=p.view.getBounds(t),n=p.view.scale;i.x/=n,i.y/=n,i.width/=n,i.height/=n,i.x-=p.view.translate.x,i.y-=p.view.translate.y,b(t,i)}mxEvent.consume(e)}));mxEvent.addGestureListeners(d,(function(){}),mxUtils.bind(this,(function(e){p.isMouseDown&&null!=p.panningManager&&null!=p.graphHandler.first&&(p.graphHandler.suspend(),null!=p.graphHandler.hint&&(p.graphHandler.hint.style.visibility="hidden"),d.style.backgroundColor="#f1f3f4",d.style.cursor="copy",p.panningManager.stop(),p.autoScroll=!1,mxEvent.consume(e))})),mxUtils.bind(this,(function(e){p.isMouseDown&&null!=p.panningManager&&null!=p.graphHandler&&(d.style.backgroundColor="",d.style.cursor="default",this.sidebar.showTooltips=!0,p.panningManager.stop(),p.graphHandler.reset(),p.isMouseDown=!1,p.autoScroll=!0,y(e),mxEvent.consume(e))}))),mxEvent.addListener(d,"mouseleave",mxUtils.bind(this,(function(e){p.isMouseDown&&null!=p.graphHandler.first&&(p.graphHandler.resume(),null!=p.graphHandler.hint&&(p.graphHandler.hint.style.visibility="visible"),d.style.backgroundColor="",d.style.cursor="",p.autoScroll=!0)}))),Graph.fileSupport&&(mxEvent.addListener(d,"dragover",mxUtils.bind(this,(function(e){d.style.backgroundColor="#f1f3f4",e.dataTransfer.dropEffect="copy",d.style.cursor="copy",this.sidebar.hideTooltip(),e.stopPropagation(),e.preventDefault()}))),mxEvent.addListener(d,"drop",mxUtils.bind(this,(function(e){d.style.cursor="",d.style.backgroundColor="",e.dataTransfer.files.length>0&&this.importFiles(e.dataTransfer.files,0,0,this.maxImageSize,mxUtils.bind(this,(function(i,n,r,l,a,u,h,m,g){if(null!=i&&"image/"==n.substring(0,6)){var c="shape=image;verticalLabelPosition=bottom;verticalAlign=top;imageAspect=0;aspect=fixed;image="+this.convertDataUri(i),p=[new mxCell("",new mxGeometry(0,0,a,u),c)];p[0].vertex=!0,b(p,new mxRectangle(0,0,a,u),e,mxEvent.isAltDown(e)?null:h.substring(0,h.lastIndexOf(".")).replace(/_/g," ")),null!=s&&null!=s.parentNode&&t.length>0&&(s.parentNode.removeChild(s),s=null)}else{var f=!1,x=mxUtils.bind(this,(function(i,n){if(null!=i&&"application/pdf"==n){var r=Editor.extractGraphModelFromPdf(i);null!=r&&r.length>0&&(n="text/xml",i=r)}if(null!=i){var l=mxUtils.parseXml(i);if("mxlibrary"==l.documentElement.nodeName)try{var a=JSON.parse(mxUtils.getTextContent(l.documentElement));o(a,d),t=t.concat(a),v(e),this.spinner.stop(),f=!0}catch(e){}else if("mxfile"==l.documentElement.nodeName)try{for(var u=l.documentElement.getElementsByTagName("diagram"),h=0;h<u.length;h++){var m=this.stringToCells(Editor.getDiagramNodeXml(u[h])),g=this.editor.graph.getBoundingBoxFromGeometry(m);b(m,new mxRectangle(0,0,g.width,g.height),e)}f=!0}catch(e){null!=window.console&&console.log("error in drop handler:",e)}}f||(this.spinner.stop(),this.handleError({message:mxResources.get("errorLoadingFile")})),null!=s&&null!=s.parentNode&&t.length>0&&(s.parentNode.removeChild(s),s=null)}));null!=g&&null!=h&&(/(\.v(dx|sdx?))($|\?)/i.test(h)||/(\.vs(x|sx?))($|\?)/i.test(h))?this.importVisio(g,(function(e){x(e,"text/xml")}),null,h):!this.isOffline()&&(new XMLHttpRequest).upload&&this.isRemoteFileFormat(i,h)&&null!=g?this.parseFile(g,mxUtils.bind(this,(function(e){4==e.readyState&&(this.spinner.stop(),e.status>=200&&e.status<=299?x(e.responseText,"text/xml"):this.handleError({message:mxResources.get(413==e.status?"drawingTooLarge":"invalidOrMissingFile")},mxResources.get("errorLoadingFile")))}))):x(i,n)}}))),e.stopPropagation(),e.preventDefault()}))),mxEvent.addListener(d,"dragleave",(function(e){d.style.cursor="",d.style.backgroundColor="",e.stopPropagation(),e.preventDefault()}))),(g=g.cloneNode(!1)).setAttribute("src",Editor.editImage),g.setAttribute("title",mxResources.get("edit")),m.insertBefore(g,m.firstChild),mxEvent.addListener(g,"click",x),mxEvent.addListener(d,"dblclick",(function(e){mxEvent.getSource(e)==d&&x(e)}));var E=g.cloneNode(!1);if(E.setAttribute("src",Editor.plusImage),E.setAttribute("title",mxResources.get("add")),m.insertBefore(E,m.firstChild),mxEvent.addListener(E,"click",y),!this.isOffline()&&".scratchpad"==e.title&&null!=EditorUi.scratchpadHelpLink){var w=document.createElement("span");w.setAttribute("title",mxResources.get("help")),w.style.cssText="color:#a3a3a3;text-decoration:none;margin-right:2px;cursor:pointer;",mxUtils.write(w,"?"),mxEvent.addGestureListeners(w,mxUtils.bind(this,(function(e){this.openLink(EditorUi.scratchpadHelpLink),mxEvent.consume(e)}))),m.insertBefore(w,m.firstChild)}}u.appendChild(m),u.style.paddingRight=18*m.childNodes.length+"px"}},EditorUi.prototype.addLibraryEntries=function(e,t){for(var i=0;i<e.length;i++){var n=e[i],r=n.data;if(null!=r){r=this.convertDataUri(r);var l="shape=image;verticalLabelPosition=bottom;verticalAlign=top;imageAspect=0;";"fixed"==n.aspect&&(l+="aspect=fixed;"),t.appendChild(this.sidebar.createVertexTemplate(l+"image="+r,n.w,n.h,"",n.title||"",!1,!1,!0))}else if(null!=n.xml){var s=this.stringToCells(Graph.decompress(n.xml));s.length>0&&t.appendChild(this.sidebar.createVertexTemplateFromCells(s,n.w,n.h,n.title||"",!0,!1,!0))}}},EditorUi.prototype.getResource=function(e){return null!=e?e[mxLanguage]||e.main:null},EditorUi.prototype.footerHeight=0,"1"==urlParams.savesidebar&&(Sidebar.prototype.thumbWidth=64,Sidebar.prototype.thumbHeight=64),EditorUi.initTheme=function(){"atlas"==uiTheme?(mxClient.link("stylesheet",STYLE_PATH+"/atlas.css"),"undefined"!=typeof Toolbar&&(Toolbar.prototype.unselectedBackground="linear-gradient(rgb(255, 255, 255) 0px, rgb(242, 242, 242) 100%)",Toolbar.prototype.selectedBackground="rgb(242, 242, 242)"),Editor.prototype.initialTopSpacing=3,EditorUi.prototype.menubarHeight=41,EditorUi.prototype.toolbarHeight=38):Editor.isDarkMode()&&(mxClient.link("stylesheet",STYLE_PATH+"/dark.css"),Dialog.backdropColor=Editor.darkColor,Format.inactiveTabBackgroundColor="black",Graph.prototype.defaultThemeName="darkTheme",Graph.prototype.shapeBackgroundColor=Editor.darkColor,Graph.prototype.shapeForegroundColor=Editor.lightColor,Graph.prototype.defaultPageBackgroundColor=Editor.darkColor,Graph.prototype.defaultPageBorderColor="#505759",BaseFormatPanel.prototype.buttonBackgroundColor=Editor.darkColor,mxGraphHandler.prototype.previewColor="#cccccc",StyleFormatPanel.prototype.defaultStrokeColor="#cccccc",mxConstants.DROP_TARGET_COLOR="#00ff00"),Editor.sketchFontFamily="Architects Daughter",Editor.sketchFontSource="https%3A%2F%2Ffonts.googleapis.com%2Fcss%3Ffamily%3DArchitects%2BDaughter","1"==urlParams.sketch&&(Graph.prototype.defaultVertexStyle={hachureGap:"4"},Graph.prototype.defaultEdgeStyle={edgeStyle:"none",rounded:"0",curved:"1",jettySize:"auto",orthogonalLoop:"1",end