gogogojs
Version:
Interactive diagrams, charts, and graphs, such as trees, flowcharts, orgcharts, UML, BPMN, or business diagrams
8 lines • 53.3 kB
JavaScript
var gcs=function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=3)}([function(e,t,n){(function(t,r){/*!
* @overview es6-promise - a tiny implementation of Promises/A+.
* @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
* @license Licensed under MIT license
* See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
* @version 3.3.1
*/
!function(t,n){e.exports=n()}(0,function(){"use strict";function e(e){return"function"==typeof e||"object"==typeof e&&null!==e}function o(e){return"function"==typeof e}function i(e){W=e}function a(e){J=e}function c(){return function(){z(u)}}function s(){var e=setTimeout;return function(){return e(u,1)}}function u(){for(var e=0;e<q;e+=2){(0,Z[e])(Z[e+1]),Z[e]=void 0,Z[e+1]=void 0}q=0}function l(e,t){var n=arguments,r=this,o=new this.constructor(p);void 0===o[ee]&&O(o);var i=r._state;return i?function(){var e=n[i-1];J(function(){return C(i,o,e,r._result)})}():I(r,o,e,t),o}function d(e){var t=this;if(e&&"object"==typeof e&&e.constructor===t)return e;var n=new t(p);return _(n,e),n}function p(){}function f(){return new TypeError("You cannot resolve a promise with itself")}function m(){return new TypeError("A promises callback cannot return that same promise.")}function h(e){try{return e.then}catch(e){return oe.error=e,oe}}function v(e,t,n,r){try{e.call(t,n,r)}catch(e){return e}}function g(e,t,n){J(function(e){var r=!1,o=v(n,t,function(n){r||(r=!0,t!==n?_(e,n):P(e,n))},function(t){r||(r=!0,D(e,t))},"Settle: "+(e._label||" unknown promise"));!r&&o&&(r=!0,D(e,o))},e)}function y(e,t){t._state===ne?P(e,t._result):t._state===re?D(e,t._result):I(t,void 0,function(t){return _(e,t)},function(t){return D(e,t)})}function w(e,t,n){t.constructor===e.constructor&&n===l&&t.constructor.resolve===d?y(e,t):n===oe?D(e,oe.error):void 0===n?P(e,t):o(n)?g(e,t,n):P(e,t)}function _(t,n){t===n?D(t,f()):e(n)?w(t,n,h(n)):P(t,n)}function b(e){e._onerror&&e._onerror(e._result),S(e)}function P(e,t){e._state===te&&(e._result=t,e._state=ne,0!==e._subscribers.length&&J(S,e))}function D(e,t){e._state===te&&(e._state=re,e._result=t,J(b,e))}function I(e,t,n,r){var o=e._subscribers,i=o.length;e._onerror=null,o[i]=t,o[i+ne]=n,o[i+re]=r,0===i&&e._state&&J(S,e)}function S(e){var t=e._subscribers,n=e._state;if(0!==t.length){for(var r=void 0,o=void 0,i=e._result,a=0;a<t.length;a+=3)r=t[a],o=t[a+n],r?C(n,r,o,i):o(i);e._subscribers.length=0}}function E(){this.error=null}function k(e,t){try{return e(t)}catch(e){return ie.error=e,ie}}function C(e,t,n,r){var i=o(n),a=void 0,c=void 0,s=void 0,u=void 0;if(i){if(a=k(n,r),a===ie?(u=!0,c=a.error,a=null):s=!0,t===a)return void D(t,m())}else a=r,s=!0;t._state!==te||(i&&s?_(t,a):u?D(t,c):e===ne?P(t,a):e===re&&D(t,a))}function F(e,t){try{t(function(t){_(e,t)},function(t){D(e,t)})}catch(t){D(e,t)}}function T(){return ae++}function O(e){e[ee]=ae++,e._state=void 0,e._result=void 0,e._subscribers=[]}function x(e,t){this._instanceConstructor=e,this.promise=new e(p),this.promise[ee]||O(this.promise),H(t)?(this._input=t,this.length=t.length,this._remaining=t.length,this._result=new Array(this.length),0===this.length?P(this.promise,this._result):(this.length=this.length||0,this._enumerate(),0===this._remaining&&P(this.promise,this._result))):D(this.promise,M())}function M(){return new Error("Array Methods must be provided an Array")}function U(e){return new x(this,e).promise}function L(e){var t=this;return new t(H(e)?function(n,r){for(var o=e.length,i=0;i<o;i++)t.resolve(e[i]).then(n,r)}:function(e,t){return t(new TypeError("You must pass an array to race."))})}function A(e){var t=this,n=new t(p);return D(n,e),n}function N(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function G(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function B(e){this[ee]=T(),this._result=this._state=void 0,this._subscribers=[],p!==e&&("function"!=typeof e&&N(),this instanceof B?F(this,e):G())}function R(){var e=void 0;if(void 0!==r)e=r;else if("undefined"!=typeof self)e=self;else try{e=Function("return this")()}catch(e){throw new Error("polyfill failed because global object is unavailable in this environment")}var t=e.Promise;if(t){var n=null;try{n=Object.prototype.toString.call(t.resolve())}catch(e){}if("[object Promise]"===n&&!t.cast)return}e.Promise=B}var j=void 0;j=Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)};var H=j,q=0,z=void 0,W=void 0,J=function(e,t){Z[q]=e,Z[q+1]=t,2===(q+=2)&&(W?W(u):$())},X="undefined"!=typeof window?window:void 0,K=X||{},V=K.MutationObserver||K.WebKitMutationObserver,Y="undefined"==typeof self&&void 0!==t&&"[object process]"==={}.toString.call(t),Q="undefined"!=typeof Uint8ClampedArray&&"undefined"!=typeof importScripts&&"undefined"!=typeof MessageChannel,Z=new Array(1e3),$=void 0;$=Y?function(){return function(){return t.nextTick(u)}}():V?function(){var e=0,t=new V(u),n=document.createTextNode("");return t.observe(n,{characterData:!0}),function(){n.data=e=++e%2}}():Q?function(){var e=new MessageChannel;return e.port1.onmessage=u,function(){return e.port2.postMessage(0)}}():void 0===X?function(){try{var e=n(7);return z=e.runOnLoop||e.runOnContext,c()}catch(e){return s()}}():s();var ee=Math.random().toString(36).substring(16),te=void 0,ne=1,re=2,oe=new E,ie=new E,ae=0;return x.prototype._enumerate=function(){for(var e=this.length,t=this._input,n=0;this._state===te&&n<e;n++)this._eachEntry(t[n],n)},x.prototype._eachEntry=function(e,t){var n=this._instanceConstructor,r=n.resolve;if(r===d){var o=h(e);if(o===l&&e._state!==te)this._settledAt(e._state,t,e._result);else if("function"!=typeof o)this._remaining--,this._result[t]=e;else if(n===B){var i=new n(p);w(i,e,o),this._willSettleAt(i,t)}else this._willSettleAt(new n(function(t){return t(e)}),t)}else this._willSettleAt(r(e),t)},x.prototype._settledAt=function(e,t,n){var r=this.promise;r._state===te&&(this._remaining--,e===re?D(r,n):this._result[t]=n),0===this._remaining&&P(r,this._result)},x.prototype._willSettleAt=function(e,t){var n=this;I(e,void 0,function(e){return n._settledAt(ne,t,e)},function(e){return n._settledAt(re,t,e)})},B.all=U,B.race=L,B.resolve=d,B.reject=A,B._setScheduler=i,B._setAsap=a,B._asap=J,B.prototype={constructor:B,then:l,catch:function(e){return this.then(null,e)}},R(),B.polyfill=R,B.Promise=B,B})}).call(t,n(5),n(6))},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),o=n(0),i=function(){function e(e,t,n,o){function i(e){e.addModelChangedListener(function(e){e.isTransactionFinished&&s.isAutoSaving&&""!==e.oldValue&&s.currentDiagramFile.name&&s.save()})}e instanceof r.Diagram&&(e=[e]),this._managedDiagrams=e,this._currentDiagramFile={name:null,id:null,path:null},this._isAutoSaving=!0,t&&(this._defaultModel=t),n?this._clientId=n:n=null,this._iconsRelativeDirectory=o||"../goCloudStorageIcons/";var a=document.createElement("div");a.className="goCustomFilepicker",a.style.visibility="hidden",document.getElementsByTagName("body")[0].appendChild(a),this._ui=a,this._deferredPromise={promise:this.makeDeferredPromise()};var c=this.managedDiagrams,s=this;if(c instanceof r.Diagram)i(c);else for(var u=0;u<c.length;u++)i(c[u])}return Object.defineProperty(e.prototype,"managedDiagrams",{get:function(){return this._managedDiagrams},set:function(e){this._managedDiagrams=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"defaultModel",{get:function(){return this._defaultModel},set:function(e){this._defaultModel=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"iconsRelativeDirectory",{get:function(){return this._iconsRelativeDirectory},set:function(e){this._iconsRelativeDirectory=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"clientId",{get:function(){return this._clientId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentDiagramFile",{get:function(){return this._currentDiagramFile},set:function(e){this._currentDiagramFile=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isAutoSaving",{get:function(){return this._isAutoSaving},set:function(e){this._isAutoSaving=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"serviceName",{get:function(){return this._serviceName},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ui",{get:function(){return this._ui},enumerable:!0,configurable:!0}),e.prototype.authorize=function(e){return void 0===e&&(e=!1),new o.Promise(function(e,t){console.error("authorize not implemented"),t(!1)})},e.prototype.makeDeferredPromise=function(){var e,t,n=new o.Promise(function(n,r){e=n,t=r});return n.resolve=e,n.reject=t,n},e.prototype.getUserInfo=function(){return new o.Promise(function(e,t){t("getUserInfo not implemented")})},e.prototype.hideUI=function(e){void 0===e&&(e=!1);var t=this;if(t.ui.style.visibility="hidden",e){var n=document.getElementById("actionButton").innerHTML;t._deferredPromise.promise.resolve(n+" canceled by user"),t._deferredPromise.promise=t.makeDeferredPromise()}},e.prototype.checkFileExists=function(e){return new o.Promise(function(e,t){t("checkFileExists not implemented")})},e.prototype.getFile=function(e){return new o.Promise(function(e,t){throw Error("getFile not implemented")})},e.prototype.showUI=function(e){return new o.Promise(function(e,t){throw Error("showUI not implemented")})},e.prototype.create=function(e){var t=this;t.managedDiagrams;return new o.Promise(function(n,o){function i(e){t.defaultModel?e.model=r.Model.fromJson(JSON.parse(t.defaultModel)):e.model=new r.GraphLinksModel}if(t.currentDiagramFile={name:null,id:null,path:null},t.managedDiagrams instanceof r.Diagram)i(t.managedDiagrams);else for(var a=0;a<t.managedDiagrams.length;a++)i(t.managedDiagrams[a]);n(t.isAutoSaving?e?t.save(e):t.saveWithUI():"New diagram created.")})},e.prototype.makeSaveFile=function(){var e="{\n",t=this;if(0!=t.managedDiagrams.length){for(var n=0;n<t.managedDiagrams.length;n++){var r=t.managedDiagrams[n];e+='"'+r.div.id+'": '+r.model.toJson(),n+1!==t.managedDiagrams.length&&(e+=",\n")}return e+="\n}"}},e.prototype.loadFromFileContents=function(e){var t=JSON.parse(e);for(var n in t){var o=t[n],i=document.getElementById(n),a=r.Diagram.fromDiv(i);if(!a)throw Error("No Diagram on page is associated with a div with id "+n);a.model=r.Model.fromJson(JSON.stringify(o))}},e.prototype.saveWithUI=function(){return new o.Promise(function(e,t){t("saveWithUI not implemented")})},e.prototype.save=function(e){return new o.Promise(function(e,t){t("save not implemented")})},e.prototype.load=function(e){return new o.Promise(function(e,t){t("load not implemented")})},e.prototype.loadWithUI=function(){return new o.Promise(function(e,t){t("loadWithUI not implemented")})},e.prototype.remove=function(e){return new o.Promise(function(e,t){t("remove not implemented")})},e.prototype.removeWithUI=function(){return new o.Promise(function(e,t){t("removeWithUI not implemented")})},e}();t.GoCloudStorage=i},function(e,t){e.exports=go},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),e.exports={GoLocalStorage:n(4).GoLocalStorage,GoDropBox:n(8).GoDropBox,GoGoogleDrive:n(9).GoGoogleDrive,GoOneDrive:n(10).GoOneDrive,GoNetCore:n(11).GoNetCore,GoCloudStorageManager:n(12).GoCloudStorageManager}},function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=n(0),a=function(e){function t(t,n,r){var o=e.call(this,t,n)||this;return o._localStorage=window.localStorage,o.ui.id="goLocalStorageCustomFilepicker",o._serviceName="Local Storage",o}return r(t,e),Object.defineProperty(t.prototype,"localStorage",{get:function(){return this._localStorage},enumerable:!0,configurable:!0}),t.prototype.authorize=function(e){void 0===e&&(e=!1);var t=this;return new i.Promise(function(e,n){try{t.localStorage.setItem("item","item"),t.localStorage.removeItem("item"),e(!0)}catch(t){e(!1)}})},t.prototype.showUI=function(e,n){var r=this,o=r.ui;n||(n=0);var i=t._MIN_FILES_IN_UI+n;o.innerHTML="<img class='icons' src='"+r.iconsRelativeDirectory+"localStorage.png'></img>";var a=e+" Diagram File";o.innerHTML+="<strong>"+a+"</strong><hr></hr>",document.getElementsByTagName("body")[0].appendChild(o),o.style.visibility="visible";var c=document.createElement("div");c.id="fileOptions";var s=[],u=(t._MIN_FILES_IN_UI,0),l=!1;if(0!==r.localStorage.length){for(var d in r.localStorage)if(s.length<i){u++;var p=r.localStorage.getItem(d);if(p&&-1!==p.indexOf("GraphLinksModel")){var f={key:d,model:p};s.push(f)}u===r.localStorage.length&&(l=!0)}}else l=!0;if(0!==s.length)for(var m=0;m<s.length;m++){var h=s[m],f=h.key,v=f.replace(/ /g,"qwe45qw34");c.innerHTML+="Save"!==e?"<div class='fileOption'><input id="+v+" type='radio' name='localStorageFile' /><label id ="+v+"-label for='"+v+"'>"+f+"</label></div>":"<div class='fileOption'><label id ="+v+"-label for='"+v+"'>"+f+"</label></div>"}if(!l){var g=n+50;c.innerHTML+="<p>There may be more diagram files not shown. <a id='localStorageLoadMoreFiles'>Click here</a> to try loading more.</p>",document.getElementById("localStorageLoadMoreFiles").onclick=function(){r.showUI(e,g)}}if(o.appendChild(c),r.currentDiagramFile.id){var y=r.currentDiagramFile.id.replace(/ /g,"qwe45qw34"),w=document.getElementById(y+"-label");w&&(w.style.fontStyle="italic")}if("Save"===e){var _=document.createElement("div");_.id="userInputDiv",_.innerHTML+='<span>Save Diagram As </span><input id="userInput" placeholder="Enter filename"></input>',o.appendChild(_)}var b=document.createElement("div");b.id="submitDiv";var P=document.createElement("button");P.textContent=e,P.id="actionButton",P.onclick=function(){r.processUIResult(e)},b.appendChild(P),o.appendChild(b);var D=document.createElement("div"),I=document.createElement("button");return I.id="cancelButton",I.textContent="Cancel",I.onclick=function(){r.hideUI(!0)},D.appendChild(I),o.appendChild(D),r._deferredPromise.promise},t.prototype.processUIResult=function(e){var t=this,n=function(){for(var e=document.getElementsByName("localStorageFile"),t=null,n=0;n<e.length;n++)e[n].checked&&(t=e[n].id.replace(/qwe45qw34/g," "));return t||null}();switch(e){case"Save":var r=document.getElementById("userInput").value;r&&(r+=".diagram",t.save(r));break;case"Load":t.load(n);break;case"Delete":t.remove(n)}t.hideUI()},t.prototype.getFile=function(e){return-1===e.indexOf(".diagram")&&(e+=".diagram"),new i.Promise(function(t,n){var r=window.localStorage.getItem(e)?window.localStorage.getItem(e):null;t({name:e,content:r,path:e,id:e})})},t.prototype.checkFileExists=function(e){return-1===e.indexOf(".diagram")&&(e+=".diagram"),new i.Promise(function(t,n){t(!!window.localStorage.getItem(e))})},t.prototype.saveWithUI=function(){var e=this;return new i.Promise(function(t,n){t(e.showUI("Save"))})},t.prototype.save=function(e){var t=this;return new i.Promise(function(n,r){if(e){-1===e.indexOf(".diagram")&&(e+=".diagram");var o=t.makeSaveFile();t.localStorage.setItem(e,o);var i={name:e,id:e,path:e};t.currentDiagramFile=i,n(i),t._deferredPromise.promise.resolve(i),t._deferredPromise.promise=t.makeDeferredPromise()}else if(t.currentDiagramFile.path){var a=t.currentDiagramFile.path,i={name:a,path:a,id:a},o=t.makeSaveFile();t.localStorage.setItem(a,o),n(a)}else n(t.saveWithUI())})},t.prototype.loadWithUI=function(){var e=this;return new i.Promise(function(t,n){t(e.showUI("Load"))}).catch(function(e){throw Error(e)})},t.prototype.load=function(e){var t=this;return new i.Promise(function(n,r){if(!e)throw Error("Cannot load file from local storage with path "+e);var o=t.localStorage.getItem(e);if(!o)throw Error("Cannot load file from local storage with path "+e);t.loadFromFileContents(o);var i={name:e,id:e,path:e};t.currentDiagramFile=i,n(i),t._deferredPromise.promise.resolve(i),t._deferredPromise.promise=t.makeDeferredPromise()}).catch(function(e){throw Error(e)})},t.prototype.removeWithUI=function(){var e=this;return new i.Promise(function(t,n){t(e.showUI("Delete"))})},t.prototype.remove=function(e){var t=this;return new i.Promise(function(n,r){if(!e)throw Error("Cannot delete file from local storage with path "+e);var o={name:e,path:e,id:e};t.currentDiagramFile&&e===t.currentDiagramFile.name&&(t.currentDiagramFile={name:null,path:null,id:null}),t.localStorage.removeItem(e),n(o),t._deferredPromise.promise.resolve(o),t._deferredPromise.promise=t.makeDeferredPromise()})},t._MIN_FILES_IN_UI=100,t}(o.GoCloudStorage);t.GoLocalStorage=a},function(e,t){function n(){throw new Error("setTimeout has not been defined")}function r(){throw new Error("clearTimeout has not been defined")}function o(e){if(l===setTimeout)return setTimeout(e,0);if((l===n||!l)&&setTimeout)return l=setTimeout,setTimeout(e,0);try{return l(e,0)}catch(t){try{return l.call(null,e,0)}catch(t){return l.call(this,e,0)}}}function i(e){if(d===clearTimeout)return clearTimeout(e);if((d===r||!d)&&clearTimeout)return d=clearTimeout,clearTimeout(e);try{return d(e)}catch(t){try{return d.call(null,e)}catch(t){return d.call(this,e)}}}function a(){h&&f&&(h=!1,f.length?m=f.concat(m):v=-1,m.length&&c())}function c(){if(!h){var e=o(a);h=!0;for(var t=m.length;t;){for(f=m,m=[];++v<t;)f&&f[v].run();v=-1,t=m.length}f=null,h=!1,i(e)}}function s(e,t){this.fun=e,this.array=t}function u(){}var l,d,p=e.exports={};!function(){try{l="function"==typeof setTimeout?setTimeout:n}catch(e){l=n}try{d="function"==typeof clearTimeout?clearTimeout:r}catch(e){d=r}}();var f,m=[],h=!1,v=-1;p.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];m.push(new s(e,t)),1!==m.length||h||o(c)},s.prototype.run=function(){this.fun.apply(null,this.array)},p.title="browser",p.browser=!0,p.env={},p.argv=[],p.version="",p.versions={},p.on=u,p.addListener=u,p.once=u,p.off=u,p.removeListener=u,p.removeAllListeners=u,p.emit=u,p.prependListener=u,p.prependOnceListener=u,p.listeners=function(e){return[]},p.binding=function(e){throw new Error("process.binding is not supported")},p.cwd=function(){return"/"},p.chdir=function(e){throw new Error("process.chdir is not supported")},p.umask=function(){return 0}},function(e,t){var n;n=function(){return this}();try{n=n||Function("return this")()||(0,eval)("this")}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){},function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=n(0),a=function(e){function t(t,n,r,o){var i=e.call(this,t,r,n)||this;if(window.Dropbox){var a=window.Dropbox;i._dropbox=new a({clientId:n})}return i.menuPath="",i.ui.id="goDropBoxCustomFilepicker",i._serviceName="Dropbox",i}return r(t,e),Object.defineProperty(t.prototype,"dropbox",{get:function(){return this._dropbox},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"menuPath",{get:function(){return this._menuPath},set:function(e){this._menuPath=e},enumerable:!0,configurable:!0}),t.prototype.authorize=function(e){void 0===e&&(e=!1);var t=this;return new i.Promise(function(n,r){if(e){var o=t.dropbox.getAuthenticationUrl(window.location.href);window.location.href=o,n(!1)}else if(!t.dropbox.getAccessToken())if(-1!==window.location.hash.indexOf("access_token")&&-1!==window.location.hash.indexOf("id=dbid")){var i=window.location.hash.substring(window.location.hash.indexOf("=")+1,window.location.hash.indexOf("&"));t.dropbox.setAccessToken(i),n(!0)}else{var o=t.dropbox.getAuthenticationUrl(window.location.href);window.location.href=o,n(!1)}n(!0)})},t.prototype.getUserInfo=function(){var e=this;return new i.Promise(function(t,n){e.dropbox.getAccessToken()||-1!=window.location.hash.indexOf("access_token")?e.dropbox.getAccessToken()||1!=window.location.hash.indexOf("access_token")||e.authorize(!1):e.authorize(!0),e.dropbox.usersGetCurrentAccount(null).then(function(e){t(e)}).catch(function(t){400==t.status&&e.authorize(!0)})})},t.prototype.showUI=function(e,n,r){var o=this,i=o.ui;return n||(n=""),r||(r=0),o.dropbox.getAccessToken()||o.authorize(!0),o.dropbox.usersGetCurrentAccount(null).then(function(a){if(a){i.innerHTML="<img class='icons' src='"+o.iconsRelativeDirectory+"dropBox.png'></img>";var c=e+" Diagram File";i.innerHTML+="<strong>"+c+"</strong><hr></hr>",document.getElementsByTagName("body")[0].appendChild(i),i.style.visibility="visible";var s=document.createElement("div");s.id="fileOptions",o.dropbox.filesListFolder({path:n}).then(function(n){var c,u,l=n.entries,d=l[0].path_lower.split("/");if(d.length>2)for(var p=0;p<d.length-1;p++)0===p?(c="",u=""):p<d.length-2?(c+="/"+d[p],u+="/"+d[p]):u+="/"+d[p];o.menuPath=void 0===u?"":u;var f=void 0===u?"Root":u;document.getElementById("currentDirectory")||(i.innerHTML+="<span id='currentDirectory'>Current Directory: "+f+"</span>");for(var m=t._MIN_FILES_IN_UI+r,h=0,v=0,g=0,y=!1,p=0;p<l.length;p++)!function(t){var n=l[t];if("folder"==n[".tag"]){g++,h+g>=l.length&&(y=!0);var r=document.createElement("div");r.className="folderOption";var i=document.createElement("a");i.href="#",i.textContent=n.name,i.id=n.id,i.onclick=function(){o.showUI(e,n.path_lower,0)},r.appendChild(i),s.appendChild(r)}else if(v<m&&(h++,h+g>=l.length&&(y=!0),-1!==n.name.indexOf(".diagram")))if(v++,"Save"!==e){var a=document.createElement("div");a.className="fileOption";var c=document.createElement("input");c.id=n.id,c.type="radio",c.name="dropBoxFile",c.setAttribute("data",n.path_lower);var u=document.createElement("label");u.id=n.id+"-label",u.textContent=n.name,a.appendChild(c),a.appendChild(u),s.appendChild(a)}else{var a=document.createElement("div");a.className="fileOption";var u=document.createElement("label");u.id=n.id+"-label",u.textContent=n.name,a.appendChild(u),s.appendChild(a)}}(p);if(!y){var w=r+50;s.innerHTML+="<p>Observed "+(t._MIN_FILES_IN_UI+r)+" files. There may be more diagram files not shown. <a id='dropBoxLoadMoreFiles'>Click here</a> to search for more.</p>",document.getElementById("dropBoxLoadMoreFiles").onclick=function(){o.showUI(e,o.menuPath,w)}}if(void 0!==c){var _=void 0;_=c||"root";var b=document.createElement("div"),P=document.createElement("a");P.id="dropBoxReturnToParentDir",P.text="Back to "+_,P.onclick=function(){o.showUI(e,c,0)},b.appendChild(P),s.appendChild(b)}if(document.getElementById(s.id)||i.appendChild(s),o.currentDiagramFile.id){var D=document.getElementById(o.currentDiagramFile.id+"-label");D&&(D.style.fontStyle="italic")}if("Save"===e&&!document.getElementById("userInputDiv")){var I=document.createElement("div");I.id="userInputDiv",I.innerHTML='<span>Save Diagram As </span><input id="userInput" placeholder="Enter filename"></input>',i.appendChild(I)}if(!document.getElementById("userDataDiv")){var S=document.createElement("div");S.id="userDataDiv";var E=document.createElement("span");E.textContent=a.name.display_name+", "+a.email,S.appendChild(E);var k=document.createElement("a");k.href="#",k.id="dropBoxChangeAccount",k.textContent="Change Account",k.onclick=function(){o.authorize(!0)},S.appendChild(k),i.appendChild(S)}if(!document.getElementById("submitDiv")&&!document.getElementById("cancelDiv")){var C=document.createElement("div");C.id="submitDiv";var F=document.createElement("button");F.id="actionButton",F.textContent=e,F.onclick=function(){o.processUIResult(e)},C.appendChild(F),i.appendChild(C);var T=document.createElement("div");T.id="cancelDiv";var O=document.createElement("button");O.textContent="Cancel",O.id="cancelButton",O.onclick=function(){o.hideUI(!0)},T.appendChild(O),i.appendChild(T)}})}}).catch(function(e){400==e.status&&o.authorize(!0)}),o._deferredPromise.promise},t.prototype.hideUI=function(t){this.menuPath="",e.prototype.hideUI.call(this,t)},t.prototype.processUIResult=function(e){var t=this,n=function(){for(var e=document.getElementsByName("dropBoxFile"),t=null,n=0;n<e.length;n++)e[n].checked&&(t=e[n].getAttribute("data"));return t}();switch(e){case"Save":if(t.menuPath||""===t.menuPath){var r=document.getElementById("userInput").value;r?(-1===r.indexOf(".diagram")&&(r+=".diagram"),t.save(t.menuPath+"/"+r)):console.log("Proposed file name is not valid")}break;case"Load":t.load(n);break;case"Delete":t.remove(n)}t.hideUI()},t.prototype.checkFileExists=function(e){var t=this;return-1===e.indexOf(".diagram")&&(e+=".diagram"),new i.Promise(function(n,r){t.dropbox.filesGetMetadata({path:e}).then(function(e){e&&n(!0)}).catch(function(e){n(!1)})})},t.prototype.getFile=function(e){var t=this;return-1===e.indexOf(".diagram")&&(e+=".diagram"),t.dropbox.filesGetMetadata({path:e}).then(function(e){if(e)return e}).catch(function(e){return null})},t.prototype.saveWithUI=function(){var e=this;return new i.Promise(function(t,n){t(e.showUI("Save",""))})},t.prototype.save=function(e){var t=this;return new i.Promise(function(n,r){e?t.dropbox.filesUpload({contents:t.makeSaveFile(),path:e,autorename:!0,mode:{".tag":"add"},mute:!1}).then(function(e){var r={name:e.name,id:e.id,path:e.path_lower};t.currentDiagramFile=r,n(r),t._deferredPromise.promise.resolve(r),t._deferredPromise.promise=t.makeDeferredPromise()}).catch(function(e){400==e.status&&t.authorize(!0)}):t.currentDiagramFile.path?(e=t.currentDiagramFile.path,t.dropbox.filesUpload({contents:t.makeSaveFile(),path:e,autorename:!1,mode:{".tag":"overwrite"},mute:!0}).then(function(e){var t={name:e.name,id:e.id,path:e.path_lower};n(t)}).catch(function(e){400==e.status&&t.authorize(!0)})):n(t.saveWithUI())})},t.prototype.loadWithUI=function(){var e=this;return new i.Promise(function(t,n){t(e.showUI("Load",""))})},t.prototype.load=function(e){var t=this;return new i.Promise(function(n,r){if(!e)throw Error("Cannot load file from Dropbox with path "+e);t.dropbox.filesGetTemporaryLink({path:e}).then(function(r){var o=r.link;t.currentDiagramFile.name=r.metadata.name,t.currentDiagramFile.id=r.metadata.id,t.currentDiagramFile.path=e;var i=new XMLHttpRequest;i.open("GET",o,!0),i.setRequestHeader("Authorization","Bearer "+t.dropbox.getAccessToken()),i.onload=function(){if(4!=i.readyState||200!=i.status)throw Error("Cannot load file from Dropbox with path "+e);t.loadFromFileContents(i.response);var o={name:r.metadata.name,id:r.metadata.id,path:r.metadata.path_lower};n(o),t._deferredPromise.promise.resolve(o),t._deferredPromise.promise=t.makeDeferredPromise()},i.send()}).catch(function(e){400==e.status&&t.authorize(!0)})})},t.prototype.removeWithUI=function(){var e=this;return new i.Promise(function(t,n){t(e.showUI("Delete",""))})},t.prototype.remove=function(e){var t=this;return new i.Promise(function(n,r){if(!e)throw Error("Cannot delete file from Dropbox with path "+e);t.dropbox.filesDelete({path:e}).then(function(e){t.currentDiagramFile&&t.currentDiagramFile.id===e.id&&(t.currentDiagramFile={name:null,path:null,id:null});var r={name:e.name,id:e.id,path:e.path_lower};n(r),t._deferredPromise.promise.resolve(r),t._deferredPromise.promise=t.makeDeferredPromise()}).catch(function(e){400==e.status&&t.authorize(!0)})})},t._MIN_FILES_IN_UI=100,t}(o.GoCloudStorage);t.GoDropBox=a},function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=n(0),a=function(e){function t(t,n,r,o,i){var a=e.call(this,t,o,n)||this;return a._scope="https://www.googleapis.com/auth/drive",a._pickerApiKey=r,a._oauthToken=null,a._gapiClient=null,a._gapiPicker=null,a.ui.id="goGoogleDriveSavePrompt",a._serviceName="Google Drive",a}return r(t,e),Object.defineProperty(t.prototype,"pickerApiKey",{get:function(){return this._pickerApiKey},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scope",{get:function(){return this._scope},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"gapiClient",{get:function(){return this._gapiClient},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"gapiPicker",{get:function(){return this._gapiPicker},enumerable:!0,configurable:!0}),t.prototype.authorize=function(e){void 0===e&&(e=!1);var t=this,n=null;if(window.gapi){if(n=window.gapi,e){var r=document.location.href;document.location.href="https://www.google.com/accounts/Logout?continue=https://appengine.google.com/_ah/logout?continue="+r}return new i.Promise(function(e,r){function o(){n.auth.authorize({client_id:t.clientId,scope:t.scope,immediate:!1},function(r){r&&!r.error&&(t._oauthToken=r.access_token),t._gapiClient=n.client,window.google&&(t._gapiPicker=window.google.picker),e(!0)})}n.load("client:auth",o),n.load("picker",{})})}},t.prototype.createPicker=function(e){var t=this;if(t._oauthToken){var n=t.clientId.substring(0,this.clientId.indexOf("-")),r=new t.gapiPicker.View(t.gapiPicker.ViewId.DOCS);r.setMimeTypes("application/json"),r.setQuery("*.diagram");(new t.gapiPicker.PickerBuilder).enableFeature(t.gapiPicker.Feature.NAV_HIDDEN).enableFeature(t.gapiPicker.Feature.MULTISELECT_ENABLED).setAppId(n).setOrigin(window.location.protocol+"//"+window.location.host).setOAuthToken(t._oauthToken).addView(r).setDeveloperKey(t.pickerApiKey).setCallback(function(t){e(t)}).build().setVisible(!0)}},t.prototype.getUserInfo=function(){var e=this;return new i.Promise(function(t,n){e.gapiClient.request({path:"/drive/v3/about",method:"GET",params:{fields:"user"},callback:function(e){e?t(e.user):n(e)}})})},t.prototype.getFile=function(e){var t=this;return new i.Promise(function(n,r){t.gapiClient.request({path:"/drive/v3/files/"+e,method:"GET",callback:function(e){e.error?r(e.error):n(e)}})})},t.prototype.checkFileExists=function(e){var t=this;return new i.Promise(function(n,r){t.gapiClient.request({path:"/drive/v3/files/"+e,method:"GET",callback:function(e){n(!!e)}})})},t.prototype.showUI=function(){var e=this,t=e.ui;t.innerHTML="",t.style.visibility="visible",t.innerHTML="<img class='icons' src='"+e.iconsRelativeDirectory+"googleDrive.jpg'></img><strong>Save Diagram As</strong><hr></hr>";var n=document.createElement("div");n.id="userInputDiv",n.innerHTML+='<input id="userInput" placeholder="Enter filename"></input>',t.appendChild(n);var r=document.createElement("div");r.id="submitDiv";var o=document.createElement("button");o.id="actionButton",o.textContent="Save",o.onclick=function(){e.saveWithUI()},r.appendChild(o),t.appendChild(r);var i=document.createElement("div");i.id="cancelDiv";var a=document.createElement("button");return a.id="cancelButton",a.textContent="Cancel",a.onclick=function(){e.hideUI(!0)},i.appendChild(a),t.appendChild(i),e._deferredPromise.promise},t.prototype.saveWithUI=function(){var e=this,t=e.ui;return new i.Promise(function(n,r){if("hidden"===t.style.visibility)n(e.showUI());else{var o=document.getElementById("userInput").value;e.save(o),n(e.hideUI())}})},t.prototype.save=function(e){var t=this;return new i.Promise(function(n,r){if(e){-1===e.indexOf(".diagram")&&(e+=".diagram");var o=!1,i=null;t.gapiClient.request({path:"/drive/v3/files",method:"GET",params:{q:'trashed=false and name contains ".diagram" and mimeType = "application/json"'},callback:function(r){var a=r.files;if(a)for(var c=0;c<a.length;c++)a[c].name==e&&(o=!0,i=a[c]);var s="-------314159265358979323846",u="\r\n--"+s+"\r\n",l={name:e,mimeType:"application/json"},d=t.makeSaveFile(),p=u+"Content-Type: application/json\r\n\r\n"+JSON.stringify(l)+u+"Content-Type: application/json\r\n\r\n"+d+"\r\n---------314159265358979323846--";t.gapiClient.request({path:"/upload/drive/v3/files",method:"POST",params:{uploadType:"multipart"},headers:{"Content-Type":'multipart/related; boundary="'+s+'"'},body:p}).execute(function(e){var r={name:e.name,id:e.id,path:e.name};t.currentDiagramFile=r,n(r),t._deferredPromise.promise.resolve(r),t._deferredPromise.promise=t.makeDeferredPromise()})}})}else if(t.currentDiagramFile.path){var a=t.currentDiagramFile.id,c=t.makeSaveFile();t.gapiClient.request({path:"/upload/drive/v3/files/"+a,method:"PATCH",params:{uploadType:"media"},body:c,callback:function(e){if(e.error)401==e.error.code&&t.authorize(!0);else{var r={name:e.name,id:e.id,path:e.name};n(r)}}})}else n(t.saveWithUI())})},t.prototype.loadWithUI=function(){var e=this;return new i.Promise(function(t,n){var r=function(n){if("picked"===n.action){var r=n.docs[0];e.gapiClient.request({path:"/drive/v3/files/"+r.id+"?alt=media",method:"GET",callback:function(n){if(-1!==r.name.indexOf(".diagram")){var o={name:r.name,path:r.name,id:r.id};t(e.load(r.id)),e.currentDiagramFile=o}}})}};e.createPicker(r)})},t.prototype.load=function(e){var t=this;return new i.Promise(function(n,r){t.getFile(e).then(function(e){t.gapiClient.request({path:"/drive/v3/files/"+e.id+"?alt=media",method:"GET",callback:function(r){if(r&&-1!==e.name.indexOf(".diagram")){t.loadFromFileContents(JSON.stringify(r));var o={name:e.name,path:e.name,id:e.id};t.currentDiagramFile=o,n(o)}}})}).catch(function(e){r(e.message)})})},t.prototype.removeWithUI=function(){var e=this;return new i.Promise(function(t,n){var r=function(n){if("picked"===n.action){var r=n.docs[0];t(e.remove(r.id))}};e.createPicker(r)})},t.prototype.remove=function(e){var t=this;return new i.Promise(function(n,r){t.getFile(e).then(function(r){t.gapiClient.request({path:"drive/v3/files/"+e,method:"DELETE",callback:function(){t.currentDiagramFile&&e==t.currentDiagramFile.id&&(t.currentDiagramFile={name:null,path:null,id:null}),r.path=r.name,n(r)}})}).catch(function(e){r(e.message)})})},t}(o.GoCloudStorage);t.GoGoogleDrive=a},function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=n(0),a=function(e){function t(t,n,r,o){var i=e.call(this,t,r,n)||this;return i._oauthToken=null,i.ui.id="goOneDriveSavePrompt",window.OneDrive&&(i._oneDriveFilepicker=window.OneDrive),i.authorize(!1),i._serviceName="Microsoft OneDrive",i}return r(t,e),Object.defineProperty(t.prototype,"oauthToken",{get:function(){return this._oauthToken},set:function(e){this._oauthToken=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"oneDriveFilepicker",{get:function(){return this._oneDriveFilepicker},enumerable:!0,configurable:!0}),t.prototype.authorize=function(e){var t=this;return new i.Promise(function(n,r){if(e||-1===window.location.hash.indexOf("access_token")){if(e){var o="https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id="+t.clientId+"&scope=files.readwrite.all&response_type=token&redirect_uri="+window.location.href;window.location.href=o,n(!0)}}else{var i=window.location.hash.substring(window.location.hash.indexOf("=")+1,window.location.hash.indexOf("&"));t.oauthToken=i,n(!0)}})},t.prototype.getUserInfo=function(){var e=this;return new i.Promise(function(t,n){var r=new XMLHttpRequest;e.oauthToken?(r.open("GET","https://graph.microsoft.com/v1.0/me"),r.setRequestHeader("Authorization","Bearer "+e.oauthToken),r.onreadystatechange=function(){4==r.readyState&&200==r.status?t(JSON.parse(r.response)):401==r.status&&(e.authorize(!0),n(r.response))},r.send()):-1==window.location.hash.indexOf("access_token")?(n("No acessToken in current uri"),e.authorize(!0)):(n("oauthToken not set"),e.authorize(!1))})},t.prototype.checkFileExists=function(e){var t=this;return-1===e.indexOf(".diagram")&&(e+=".diagram"),new i.Promise(function(n,r){var o=new XMLHttpRequest;o.open("GET","https://graph.microsoft.com/v1.0"+e,!0),o.setRequestHeader("Authorization","Bearer "+t.oauthToken),o.onreadystatechange=function(){var e,i;4===o.readyState&&(200===o.status?e=!0:401===o.status?t.authorize(!0):404===o.status?e=!1:i=o.response,n(e),i&&r(i))},o.send()})},t.prototype.getFile=function(e,t){var n=this;return-1===e.indexOf(".diagram")&&(e+=".diagram"),new i.Promise(function(r,o){var i=new XMLHttpRequest;i.open("GET","https://graph.microsoft.com/v1.0"+e,!0);var a=t||n.oauthToken;i.setRequestHeader("Authorization","Bearer "+a),i.onreadystatechange=function(){if(4==i.readyState)if(200==i.status){var e=JSON.parse(i.response);r(e)}else 401==i.status?n.authorize(!0):o(i.response)},i.send()})},t.prototype.showUI=function(){var e=this,t=e.ui;t.innerHTML="",t.style.visibility="visible",t.innerHTML="<img class='icons' src='"+e.iconsRelativeDirectory+"oneDrive.png'></img><strong>Save Diagram As</strong><hr></hr>";var n=document.createElement("div");n.id="userInputDiv",n.innerHTML+='<input id="userInput" placeholder="Enter filename"></input>',t.appendChild(n);var r=document.createElement("div");r.id="submitDiv";var o=document.createElement("button");o.id="actionButton",o.textContent="Save",o.onclick=function(){e.saveWithUI()},r.appendChild(o),t.appendChild(r);var i=document.createElement("div");i.id="cancelDiv";var a=document.createElement("button");return a.id="cancelButton",a.textContent="Cancel",a.onclick=function(){e.hideUI(!0)},i.appendChild(a),t.appendChild(i),e._deferredPromise.promise},t.prototype.saveWithUI=function(){var e=this,t=e.ui;return new i.Promise(function(n,r){if("hidden"===t.style.visibility)n(e.showUI());else{var o=document.getElementById("userInput").value;o&&-1===o.indexOf(".diagram")&&(o+=".diagram");var i={clientId:e.clientId,action:"query",openInNewWindow:!0,success:function(t){var n=t.value[0],r=t.accessToken;e.currentDiagramFile={id:null,name:o,token:r,parentReference:{driveId:n.parentReference.driveId,id:n.id},path:"placeholder"},e.hideUI(),e.save()}};o&&""!==o&&void 0!==o?e.oneDriveFilepicker.save(i):r("Cannot save file to OneDrive with save name "+o)}})},t.prototype.save=function(e){var t=this;return new i.Promise(function(n,r){if(e){var o=new XMLHttpRequest;-1===e.indexOf(".diagram")&&(e+=".diagram");var i=t.makeSaveFile();o.open("PUT","https://graph.microsoft.com/v1.0"+e+":/content",!0),o.setRequestHeader("Authorization","Bearer "+t.oauthToken),o.setRequestHeader("Content-Type","application/json"),o.onreadystatechange=function(){if(4==o.readyState)if(o.status>=200&&o.status<300){var e=JSON.parse(o.response),r={name:e.name,id:e.id,path:e.parentReference.path+"/"+e.name,parentReference:e.parentReference};n(r)}else{if(401!=o.status)throw Error(o.response);t.authorize(!0)}},o.send(i)}else if(t.currentDiagramFile.path){var a=t.currentDiagramFile.token,c=t.generateGraphUrl(t.currentDiagramFile,!0,!0),i=t.makeSaveFile(),s=a?t.currentDiagramFile.token:t.oauthToken,u=new XMLHttpRequest;u.open("PUT",c,!0),u.setRequestHeader("Authorization","Bearer "+s),u.onload=function(){if(4!=u.readyState||200!=u.status&&201!=u.status)r(u.response);else{var e=JSON.parse(u.response),o={name:e.name,id:e.id,path:e.parentReference.path+"/"+e.name,token:a,parentReference:e.parentReference};t.currentDiagramFile=o,n(o),t._deferredPromise.promise.resolve(o),t._deferredPromise.promise=t.makeDeferredPromise()}},u.send(i)}else n(t.saveWithUI())})},t.prototype.loadWithUI=function(){var e=this;return new i.Promise(function(t,n){var r={clientId:e.clientId,action:"share",multiSelect:!1,advanced:{filter:".diagram"},success:function(n){var r=n.value[0],o=n.accessToken,i=r.parentReference.path+"/"+r.name;t(e.load(i,o))}};e.oneDriveFilepicker.open(r)})},t.prototype.load=function(e,t){var n=this;return new i.Promise(function(r,o){if(e){var i=t||n.oauthToken;n.getFile(e,i).then(function(e){var o=e["@microsoft.graph.downloadUrl"],i=new XMLHttpRequest;i.open("GET",o,!0),i.onreadystatechange=function(){if(4==i.readyState&&200==i.status){n.loadFromFileContents(i.response);var o={name:e.name,id:e.id,path:e.parentReference.path+"/"+e.name,token:t,parentReference:{id:e.parentReference.id,driveId:e.parentReference.driveId}};n.currentDiagramFile=o,r(o)}},i.send()})}else o("Cannot load file from OneDrive with path "+e)})},t.prototype.removeWithUI=function(){var e=this;return new i.Promise(function(t,n){var r={clientId:e.clientId,action:"share",openInNewWindow:!0,success:function(n){if(n){var r=n.value[0],o=n.accessToken,a=r.parentReference.path+"/"+r.name;t(new i.Promise(function(t,n){t(e.remove(a,o))}))}}};e.oneDriveFilepicker.open(r)})},t.prototype.remove=function(e,t){var n=this,r=t||n.oauthToken;return new i.Promise(function(t,o){n.getFile(e,r).then(function(i){var a={name:i.name,id:i.id,path:i.parentReference.path+"/"+i.name},c=new XMLHttpRequest;c.open("DELETE","https://graph.microsoft.com/v1.0"+e,!0),c.setRequestHeader("Authorization","Bearer"+r),c.onload=function(){4==c.readyState&&204==c.status?(n.currentDiagramFile&&e==n.currentDiagramFile.path&&(n.currentDiagramFile={id:null,path:null,name:null}),t(a)):401==c.status?n.authorize(!0):o(c.response)},c.send()}).catch(function(e){throw Error(e)})})},t.prototype.generateGraphUrl=function(e,t,n){var r="https://graph.microsoft.com/v1.0/";return r+=t?"drives/"+e.parentReference.driveId+"/items/"+e.parentReference.id+"/children/"+e.name:"drives/"+e.parentReference.driveId+"/items/"+e.id,n&&(r+="/content"),r},t}(o.GoCloudStorage);t.GoOneDrive=a},function(e,t,n){"use strict";var r=this&&this.__extends||function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])};return function(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),i=n(0),a=function(e){function t(t,n,r,o){var i=e.call(this,t,r)||this;return i._rootEndpoint=n,i.ui.id="goNetCoreCustomFilepicker",i._serviceName="Microsoft ASP .NET Core Web API",i}return r(t,e),Object.defineProperty(t.prototype,"rootEndpoint",{get:function(){return this._rootEndpoint},enumerable:!0,configurable:!0}),t.prototype.authorize=function(e){void 0===e&&(e=!1);return new i.Promise(function(e,t){e(!0)})},t.prototype.showUI=function(e,n){var r=this,o=r.ui;n||(n=0);var i=t._MIN_FILES_IN_UI+n;o.innerHTML="";var a=e+" Diagram File";o.innerHTML+="<strong>"+a+"</strong><hr></hr>",document.getElementsByTagName("body")[0].appendChild(o),o.style.visibility="visible";var c=document.createElement("div");c.id="fileOptions";var s=[],u=(t._MIN_FILES_IN_UI,0),l=!1;return r.getFiles().then(function(t){if(0!==t.length)for(var a in t){var d=t[a];if(s.length<i){u++;var p=d.file;if(p&&-1!==p.indexOf("GraphLinksModel")){var f={name:d.name,id:d.id};s.push(f)}u===t.length&&(l=!0)}}else l=!0;if(0!==s.length)for(var a=0;a<s.length;a++){var d=s[a],m=d.name,h=d.id;c.innerHTML+="Save"!==e?"<div class='fileOption'><input id="+h+" type='radio' name='localStorageFile' /><label id ="+h+"-label for='"+m+"'>"+m+"</label></div>":"<div class='fileOption'><label id ="+h+"-label for='"+h+"'>"+m+"</label></div>"}if(!l){var v=n+50;c.innerHTML+="<p>There may be more diagram files not shown. <a id='netCoreLoadMoreFiles'>Click here</a> to try loading more.</p>",document.getElementById("netCoreLoadMoreFiles").onclick=function(){r.showUI(e,v)}}if(o.appendChild(c),r.currentDiagramFile.id){var g=document.getElementById(r.currentDiagramFile.id+"-label");g&&(g.style.fontStyle="italic")}if("Save"===e){var y=document.createElement("div");y.id="userInputDiv",y.innerHTML+='<span>Save Diagram As </span><input id="userInput" placeholder="Enter filename"></input>',o.appendChild(y)}var w=document.createElement("div");w.id="submitDiv";var _=document.createElement("button");_.textContent=e,_.id="actionButton",_.onclick=function(){r.processUIResult(e)},w.appendChild(_),o.appendChild(w);var b=document.createElement("div"),P=document.createElement("button");P.id="cancelButton",P.textContent="Cancel",P.onclick=function(){r.hideUI(!0)},b.appendChild(P),o.appendChild(b)}),r._deferredPromise.promise},t.prototype.processUIResult=function(e){var t=this,n=function(){for(var e=document.getElementsByName("localStorageFile"),t=null,n=0;n<e.length;n++)e[n].checked&&(t=e[n].id.replace(/qwe45qw34/g," "));return t||null}();switch(e){case"Save":var r=document.getElementById("userInput").value;r&&(r+=".diagram",t.save(r));break;case"Load":t.load(n);break;case"Delete":t.remove(n)}t.hideUI()},t.prototype.getFile=function(e){var t=this,n=t.rootEndpoint+e;return new i.Promise(function(t,r){if(e){var o=new XMLHttpRequest;o.open("GET",n,!0),o.onreadystatechange=function(){4==o.readyState&&o.status>=200&&o.status<300&&t(JSON.parse(o.response))},o.send()}else r("Cannot get diagram file from ASP .NET Core Web API with id "+e)})},t.prototype.getFiles=function(){var e=this;return new i.Promise(function(t,n){var r=new XMLHttpRequest;r.open("GET",e.rootEndpoint,!0),r.onreadystatechange=function(){4==r.readyState&&(r.status>=200&&r.status<300?t(JSON.parse(r.response)):n(r.response))},r.send()})},t.prototype.checkFileExists=function(e){var t=this,n=t.rootEndpoint+e;return new i.Promise(function(e,t){var r=new XMLHttpRequest;r.open("GET",n,!0),r.onreadystatechange=function(){4==r.readyState&&e(r.status>=200&&r.status<300?!0:!1)},r.send()})},t.prototype.saveWithUI=function(){var e=this;return new i.Promise(function(t,n){t(e.showUI("Save"))})},t.prototype.save=function(e){var t=this;return new i.Promise(function(n,r){if(t.currentDiagramFile.id&&!e){var o=new XMLHttpRequest;t.getFile(t.currentDiagramFile.id).then(function(e){var i={id:t.currentDiagramFile.id,name:t.currentDiagramFile.name,file:t.makeSaveFile()},a={id:i.id,name:i.name,path:i.name};o.open("PUT",t.rootEndpoint+t.currentDiagramFile.id,!0),o.setRequestHeader("Content-Type","application/json; charset=utf-8"),o.onreadystatechange=function(){4==o.readyState&&(o.status>200&&o.status<300?n(a):r(o.responseText))},o.send(JSON.stringify(i))})}else{var i=new XMLHttpRequest,a={name:null!==e?e:"New diagram",file:t.makeSaveFile()};i.open("POST",t.rootEndpoint,!0),i.setRequestHeader("Content-Type","application/json; charset=utf-8"),i.onreadystatechange=function(){if(4==i.readyState)if(i.status>200&&i.status<300){var e=JSON.parse(i.response).id,o={id:e,name:a.name,path:a.name};t.currentDiagramFile=o,n(o),t._deferredPromise.promise.resolve(o),t._deferredPromise.promise=t.makeDeferredPromise()}else r(i.responseText)},i.send(JSON.stringify(a))}})},t.prototype.loadWithUI=function(){var e=this;return new i.Promise(function(t,n){t(e.showUI("Load"))}).catch(function(e){throw Error(e)})},t.prototype.load=function(e){var t=this;return new i.Promise(function(n,r){if(!e)throw Error("Cannot load file from .NET Core Web API with path "+e);var o=new XMLHttpRequest;o.open("GET",t.rootEndpoint+e,!0),o.onreadystatechange=function(){if(4==o.readyState)if(o.status>=200&&o.status<300){var e=JSON.parse(o.response);t.loadFromFileContents(e.file);var i={id:e.id,path:e.name,name:e.name};t.currentDiagramFile=i,n(i),t._deferredPromise.promise.resolve(i),t._deferredPromise.promise=t.makeDeferredPromise()}else r(o.responseText)},o.send()}).catch(function(e){throw Error(e)})},t.prototype.removeWithUI=function(){var e=this;return new i.Promise(function(t,n){t(e.showUI("Delete"))})},t.prototype.remove=function(e){var t=this;return new i.Promise(function(n,r){if(!e)throw Error("Cannot delete file from local storage with id "+e);t.getFile(e).then(function(o){var i={name:o.name,path:o.name,id:e};t.currentDiagramFile&&o.name===t.currentDiagramFile.name&&(t.currentDiagramFile={name:null,path:null,id:null});var a=new XMLHttpRequest;a.open("DELETE",t.rootEndpoint+e,!0),a.onreadystatechange=function(){4==a.readyState&&(a.status>=200&&a.status<300?(n(i),t._deferredPromise.promise.resolve(i),t._deferredPromise.promise=t.makeDeferredPromise()):r(a.responseText))},a.send()})})},t._MIN_FILES_IN_UI=100,t}(o.GoCloudStorage);t.GoNetCore=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),o=n(1),i=n(0),a=function(){function e(e,t){if(e instanceof Array){for(var n=new r.Set,i=0;i<e.length;i++){if(!(e[i]instanceof o.GoCloudStorage))throw Error("Cannot create GoCloudStorageManager; provided 'storages' parameter elements are not all of type GoCloudStorage");n.add(e[i])}e=n}if(!(e instanceof r.Set&&e))throw Error("Cannot create GoCloudStorageManager with provided 'storages' parameter");var a=this;a._storages=e,a._currentStorage=e.first();var c=document.createElement("div");c.id="goCloudStorageManagerMenu",a._menu=c,a._deferredPromise={promise:o.GoCloudStorage.prototype.makeDeferredPromise()},a._iconsRelativeDirectory=t||"../goCloudStorageIcons/",t&&a._storages.iterator.each(function(e){e.iconsRelativeDirectory=t}),-1!==window.location.href.indexOf("account_id=dbid")&&e.iterator.each(function(e){"GoDropBox"===e.constructor.name&&(a._currentStorage=e)})}return Object.def