Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@morgan-stanley/desktopjs

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@morgan-stanley/desktopjs - npm Package Compare versions

Comparing version 2.5.0 to 2.6.0

2

dist/desktop.min.js

@@ -1,2 +0,2 @@

"undefined"==typeof desktopJS&&function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):n.desktopJS=e()}(this,function(){"use strict";function c(n,e){for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);function o(){this.constructor=n}n.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var t,n,s=function(n,e,t){this.sender=n,this.name=e,this.innerEvent=t},i=function(){function r(){this.eventListeners=new Map,this.wrappedListeners=new Map}return r.prototype.addListener=function(n,e){return(this.eventListeners[n]=this.eventListeners[n]||[]).push(e),this},r.prototype.registerAndWrapListener=function(n,e){var t=this.wrapListener(n,e);return this.wrappedListeners.set(e,t),t},r.prototype.wrapListener=function(o,i){var r=this;return function(n){var e=new s(r,o,n);r.preProcessArgs(e);var t=i(e);return r.postProcessArgs(e),t}},r.prototype.preProcessArgs=function(n){},r.prototype.postProcessArgs=function(n){n&&void 0!==n.returnValue&&(n.innerEvent.returnValue=n.returnValue)},r.prototype.unwrapAndUnRegisterListener=function(n){var e=this.wrappedListeners.get(n);return e&&this.wrappedListeners.delete(n),e},r.prototype.removeListener=function(n,e){var t=this.listeners(n);if(t){var o=t.indexOf(e);0<=o&&t.splice(o,1)}return this},r.prototype.listeners=function(n){return this.eventListeners[n]||[]},r.prototype.emit=function(n,e){for(var t=0,o=this.listeners(n);t<o.length;t++){(0,o[t])(e)}},Object.defineProperty(r,"ipc",{set:function(n){n&&n.subscribe(r.staticEventName,function(n,e){r.emit(e.eventName,e.eventArgs)})},enumerable:!0,configurable:!0}),r.addListener=function(n,e){(this.staticEventListeners[n]=this.staticEventListeners[n]||[]).push(e)},r.removeListener=function(n,e){var t=r.listeners(n);if(t){var o=t.indexOf(e);0<=o&&t.splice(o,1)}},r.listeners=function(n){return this.staticEventListeners[n]||[]},r.emit=function(n,e,t){if(t&&t.publish)t.publish(r.staticEventName,{eventName:n,eventArgs:e});else for(var o=0,i=r.listeners(n);o<i.length;o++){(0,i[o])(e)}},r.staticEventListeners=new Map,r.staticEventName="desktopJS.static-event",r}(),m=function(){function n(){}return n.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var e=16*Math.random()|0;return("x"==n?e:3&e|8).toString(16)})},n}(),p=(function(n){function e(){return null!==n&&n.apply(this,arguments)||this}c(e,n)}(s),function(t){function o(){return null!==t&&t.apply(this,arguments)||this}return c(o,t),Object.defineProperty(o,"ipc",{get:function(){return o._ipc},set:function(n){i.ipc=o._ipc=n},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"ipc",{get:function(){return o.ipc},set:function(n){o.ipc=n},enumerable:!0,configurable:!0}),o.prototype.addListener=function(n,e){return t.prototype.addListener.call(this,n,e)},o.prototype.removeListener=function(n,e){return t.prototype.removeListener.call(this,n,e)},o.prototype.emit=function(n,e){t.prototype.emit.call(this,n,e)},o.addListener=function(n,e){i.addListener(o.staticEventScopePrefix+n,e)},o.removeListener=function(n,e){i.removeListener(o.staticEventScopePrefix+n,e)},o.emit=function(n,e){i.emit(o.staticEventScopePrefix+n,e,o.ipc)},o.listeners=function(n){return i.listeners(o.staticEventScopePrefix+n)},o.staticEventScopePrefix="container-",o.windowOptionsPropertyKey="desktopJS-options",o}(i)),e=function(e){function n(n){var t=e.call(this)||this;t.globalWindow=n||"undefined"!=typeof window&&window||null,t.linkHelper={href:"unknown"};try{t.linkHelper=t.globalWindow.top.document.createElement("a")}catch(n){}if(t.globalWindow){var o=t.globalWindow.open;t.globalWindow.open=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return t.onOpen.apply(t,[o].concat(n))}}return t}return c(n,e),n.prototype.onOpen=function(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];return n.apply(this.globalWindow,e)},n.prototype.ensureAbsoluteUrl=function(n){return this.linkHelper?(this.linkHelper.href=n,this.linkHelper.href):n},n}(function(e){function r(){var n=null!==e&&e.apply(this,arguments)||this;return n.uuid=m.newGuid(),n.storage="undefined"!=typeof window&&window?window.localStorage:void 0,n}return c(r,e),r.prototype.showNotification=function(n,e){throw new TypeError("Notifications not supported by this container")},r.prototype.addTrayIcon=function(n,e,t){throw new TypeError("Tray icons are not supported by this container.")},r.prototype.getLayoutFromStorage=function(n){return JSON.parse(this.storage.getItem(r.layoutsPropertyKey))[n]},r.prototype.saveLayoutToStorage=function(n,e){var t=JSON.parse(this.storage.getItem(r.layoutsPropertyKey))||{};e.name||(e.name=n),t[n]=e,this.storage.setItem(r.layoutsPropertyKey,JSON.stringify(t)),this.emit("layout-saved",{sender:this,name:"layout-saved",layout:e,layoutName:e.name}),p.emit("layout-saved",{name:"layout-saved",layout:e,layoutName:e.name})},r.prototype.loadLayout=function(u){var c=this;return new Promise(function(s,a){c.closeAllWindows(!0).then(function(){var r=c.getLayoutFromStorage(u);if(r&&r.windows){for(var n=[],e=0,t=r.windows;e<t.length;e++){var o=t[e],i=Object.assign(o.options||{},o.bounds);i.name=o.name,o.main?(c.getMainWindow().setBounds(o.bounds),n.push(Promise.resolve(c.getMainWindow()))):n.push(c.createWindow(o.url,i))}Promise.all(n).then(function(n){var i=new Map;n.forEach(function(t){var o=!1;if(i.forEach(function(n,e){!o&&0<=n.indexOf(t.id)&&(o=!0)}),!o){var n=r.windows.find(function(n){return n.name===t.name}),e=n?n.group:void 0;e&&0<e.length&&i.set(t,e.filter(function(n){return n!==t.id}))}}),i.forEach(function(n,t){n.forEach(function(e){c.getWindowByName(r.windows.find(function(n){return n.id===e}).name).then(function(n){n.joinGroup(t)})})})}),c.emit("layout-loaded",{sender:c,name:"layout-loaded",layout:r,layoutName:r.name}),p.emit("layout-loaded",{name:"layout-loaded",layout:r,layoutName:r.name}),s(r)}else a("Layout does not exist")})})},r.prototype.getLayouts=function(){var i=this;return new Promise(function(n,e){var t=i.storage.getItem(r.layoutsPropertyKey);if(t){var o=JSON.parse(t);n(Object.getOwnPropertyNames(o).map(function(n){return o[n]}))}n(void 0)})},r.prototype.log=function(t,o){return new Promise(function(n){var e;switch(t){case"debug":e=console.debug;break;case"warn":e=console.warn;break;case"error":e=console.error;break;default:e=console.log}e&&e(o),n()})},r.layoutsPropertyKey="desktopJS-layouts",r}(p)),f=function(){function n(n,e,t,o){this.x=n,this.y=e,this.width=t,this.height=o}return Object.defineProperty(n.prototype,"right",{get:function(){return n.getRight(this)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bottom",{get:function(){return n.getBottom(this)},enumerable:!0,configurable:!0}),n.getRight=function(n){return n.x+n.width},n.getBottom=function(n){return n.y+n.height},n}(),d=(function(n){function e(){return null!==n&&n.apply(this,arguments)||this}c(e,n)}(s),function(o){function t(n){var e=o.call(this)||this;return e.innerWindow=n,e}return c(t,o),Object.defineProperty(t.prototype,"allowGrouping",{get:function(){return!1},enumerable:!0,configurable:!0}),t.prototype.getGroup=function(){return Promise.resolve([])},t.prototype.joinGroup=function(n){return Promise.reject("Not supported")},t.prototype.leaveGroup=function(){return Promise.resolve()},Object.defineProperty(t.prototype,"nativeWindow",{get:function(){},enumerable:!0,configurable:!0}),t.prototype.addListener=function(n,e){var t=this.registerAndWrapListener(n,e);return this.attachListener(n,t),o.prototype.addListener.call(this,n,t)},t.prototype.removeListener=function(n,e){var t=this.unwrapAndUnRegisterListener(e)||e;return this.detachListener(n,t),o.prototype.removeListener.call(this,n,t)},t.addListener=function(n,e){i.addListener(t.staticEventScopePrefix+n,e)},t.removeListener=function(n,e){i.removeListener(t.staticEventScopePrefix+n,e)},t.emit=function(n,e){i.emit(t.staticEventScopePrefix+n,e,p.ipc)},t.listeners=function(n){return i.listeners(t.staticEventScopePrefix+n)},t.staticEventScopePrefix="containerwindow-",t}(i)),w=function(n){this.windows=[],this.name=n};(n=t||(t={}))[n.None=0]="None",n[n.Main=1]="Main",n[n.Group=2]="Group";var o,r=function(){function n(n,e){this.windowStateTracking=t.None,this.container=n,e&&"windowStateTracking"in e&&(this.windowStateTracking=e.windowStateTracking),this.attach()}return n.prototype.attach=function(n){var e=this;n?(n.addListener("undefined"!=typeof fin?"minimized":"minimize",function(n){e.windowStateTracking&t.Main&&e.container.getMainWindow().id===n.sender.id&&e.container.getAllWindows().then(function(n){n.forEach(function(n){return n.minimize()})}),e.windowStateTracking&t.Group&&n.sender.getGroup().then(function(n){n.forEach(function(n){return n.minimize()})})}),n.addListener("undefined"!=typeof fin?"restored":"restore",function(n){e.windowStateTracking&t.Main&&e.container.getMainWindow().id===n.sender.id&&e.container.getAllWindows().then(function(n){n.forEach(function(n){return n.restore()})}),e.windowStateTracking&t.Group&&n.sender.getGroup().then(function(n){n.forEach(function(n){return n.restore()})})})):(d.addListener("window-created",function(n){e.container&&e.container.getWindowById&&e.container.getWindowById(n.windowId).then(function(n){e.attach(n)})}),this.container&&this.container.getAllWindows().then(function(n){n.forEach(function(n){return e.attach(n)})}))},n}(),a=function(o){function n(n,e){var t=o.call(this,n,e)||this;return t.autoGrouping=!0,t.snapThreshold=15,t.snapOffset=15,t.targetGroup=new Map,e&&("snapThreshold"in e&&(t.snapThreshold=e.snapThreshold),"snapOffset"in e&&(t.snapOffset=e.snapOffset),"autoGrouping"in e&&(t.autoGrouping=e.autoGrouping)),t}return c(n,o),n.prototype.onAttached=function(n){var e=this;n.innerWindow&&n.innerWindow.disableFrame&&n.innerWindow.disableFrame(),"undefined"!=typeof fin?n.addListener("disabled-frame-bounds-changed",function(){return e.onMoved(n)}):n.innerWindow&&n.innerWindow.hookWindowMessage&&n.innerWindow.hookWindowMessage(562,function(){return e.onMoved(n)})},n.prototype.attach=function(e){var t=this;o.prototype.attach.call(this,e),e&&e.getOptions().then(function(n){n&&void 0!==n.snap&&!1===n.snap||(t.onAttached(e),e.addListener("undefined"!=typeof fin?"disabled-frame-bounds-changing":"move",function(n){return t.onMoving(n)}))})},n.prototype.onMoving=function(a){var u=this,t=a.sender.id;this.snappingWindow!==t&&a.sender.getOptions().then(function(n){n&&void 0!==n.snap&&!1===n.snap||a.sender.getGroup().then(function(n){("undefined"!=typeof fin?Promise.resolve(new f(a.innerEvent.left,a.innerEvent.top,a.innerEvent.width,a.innerEvent.height)):a.sender.getBounds()).then(function(s){if(0<n.length)"undefined"!=typeof fin&&u.moveWindow(a.sender,s);else{var e=[];u.container.getAllWindows().then(function(n){n.filter(function(n){return t!==n.id}).forEach(function(o){e.push(new Promise(function(t){o.getOptions().then(function(e){o.getBounds().then(function(n){return t({window:o,bounds:n,options:e})})})}))}),Promise.all(e).then(function(n){for(var e,t=!1,o=0,i=n.filter(function(n){return!(n.options&&void 0!==n.options.snap&&!1===n.options.snap)});o<i.length;o++){var r=i[o];(e=u.getSnapBounds(e||s,r.bounds))?(t=!0,u.showGroupingHint(r.window),u.moveWindow(a.sender,e)):u.hideGroupingHint(r.window)}t||"undefined"==typeof fin||u.moveWindow(a.sender,s)})})}})})})},n.prototype.moveWindow=function(n,e){var t=this;this.snappingWindow=n.id,n.setBounds(e).then(function(){return t.snappingWindow=void 0},function(){return t.snappingWindow=void 0})},n.prototype.onMoved=function(t){var e=this;if(this.autoGrouping){var n=[];this.targetGroup.forEach(function(t){return n.push(new Promise(function(e){t.getGroup().then(function(n){return e({window:t,isGrouped:0<n.length})})}))}),Promise.all(n).then(function(n){0<n.length&&t.joinGroup(n[0].window);for(var e=1;e<n.length;e++)n[e].isGrouped||n[e].window.joinGroup(t)})}this.targetGroup.forEach(function(n){return e.hideGroupingHint(n)}),this.targetGroup.clear()},n.prototype.showGroupingHint=function(n){n.innerWindow&&n.innerWindow.updateOptions&&n.innerWindow.updateOptions({opacity:.75}),this.targetGroup.set(n.id,n)},n.prototype.hideGroupingHint=function(n){n.innerWindow&&n.innerWindow.updateOptions&&n.innerWindow.updateOptions({opacity:1}),this.targetGroup.delete(n.id)},n.prototype.isHorizontallyAligned=function(n,e){return n.y>=e.y&&n.y<=e.bottom||n.bottom>=e.y&&n.bottom<=e.bottom||n.y<=e.y&&n.bottom>=e.bottom},n.prototype.isVerticallyAligned=function(n,e){return n.x>=e.x&&n.x<=e.right||n.right>=e.x&&n.right<=e.right||n.x<=e.x&&n.right>=e.right},n.prototype.getSnapBounds=function(n,e){var t,o,i,r,s,a,u,c;if(this.isHorizontallyAligned(n,e)&&(t=Math.abs(n.x-(e.right-this.snapOffset))<this.snapThreshold,o=Math.abs(n.x-e.x)<this.snapThreshold,i=Math.abs(n.right-this.snapOffset-e.x)<this.snapThreshold,r=Math.abs(n.right-e.right)<this.snapThreshold),this.isVerticallyAligned(n,e)&&(s=Math.abs(n.y-(e.bottom-this.snapOffset))<this.snapThreshold,a=Math.abs(n.y-e.y)<this.snapThreshold,u=Math.abs(n.bottom-this.snapOffset-e.y)<this.snapThreshold,c=Math.abs(n.bottom-e.bottom)<this.snapThreshold),t||i||s||u){var p=n.x,d=n.y;return t?p=e.x+e.width-this.snapOffset:o&&(p=e.x),i?p=e.x-n.width+this.snapOffset:r&&(p=e.x+e.width-n.width),s?d=e.y+e.height-Math.floor(this.snapOffset/2):a&&(d=e.y),u?d=e.y-n.height+Math.floor(this.snapOffset/2):c&&(d=e.y+e.height-n.height),new f(p,d,n.width,n.height)}},n}(r),u=function(){};(o||(o={})).transformProperties=function(n,e){var t={};if(n)for(var o in n)try{o in e?t[e[o].target]=e[o].convert?e[o].convert(n[o],n,t):n[o]:t[o]=n[o]}catch(n){console.error("Error transforming property '"+o+"'")}return t};var l,h=function(n,e,t){this.topic=n,this.listener=e,this.options=t},g=function(){},y={close:"unload"},v=function(e){function n(n){return e.call(this,n)||this}return c(n,e),Object.defineProperty(n.prototype,"id",{get:function(){return this.innerWindow[W.windowUuidPropertyKey]},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this.innerWindow[W.windowNamePropertyKey]},enumerable:!0,configurable:!0}),n.prototype.load=function(e,n){var t=this;return new Promise(function(n){t.innerWindow.location.replace(e),n()})},n.prototype.focus=function(){return this.innerWindow.focus(),Promise.resolve()},n.prototype.show=function(){return Promise.resolve()},n.prototype.hide=function(){return Promise.resolve()},n.prototype.close=function(){return this.innerWindow.close(),Promise.resolve()},n.prototype.minimize=function(){var e=this;return new Promise(function(n){e.innerWindow.minimize(),n()})},n.prototype.maximize=function(){var e=this;return new Promise(function(n){e.innerWindow.maximize(),n()})},n.prototype.restore=function(){var e=this;return new Promise(function(n){e.innerWindow.restore(),n()})},n.prototype.isShowing=function(){return Promise.resolve(!0)},n.prototype.getSnapshot=function(){return Promise.reject("getSnapshot requires an implementation.")},n.prototype.flash=function(n,e){return Promise.reject("Not supported")},n.prototype.getBounds=function(){var e=this;return new Promise(function(n){n(new f(e.innerWindow.screenX,e.innerWindow.screenY,e.innerWindow.outerWidth,e.innerWindow.outerHeight))})},n.prototype.setBounds=function(e){var t=this;return new Promise(function(n){t.innerWindow.moveTo(e.x,e.y),t.innerWindow.resizeTo(e.width,e.height),n()})},n.prototype.getOptions=function(){var t=this;return new Promise(function(n,e){n(t.innerWindow[p.windowOptionsPropertyKey])})},n.prototype.attachListener=function(n,e){this.innerWindow.addEventListener(y[n]||n,e)},n.prototype.detachListener=function(n,e){this.innerWindow.removeEventListener(y[n]||n,e)},Object.defineProperty(n.prototype,"nativeWindow",{get:function(){return this.innerWindow},enumerable:!0,configurable:!0}),n}(d),b=function(){function u(n){this.container=n}return u.prototype.subscribe=function(r,s,n){var a=this;return new Promise(function(n,e){var t=new h(r,function(n){if(n.origin===a.container.globalWindow.location.origin){var e=n.data,t=e.source,o=e.topic,i=e.message;t===u.messageSource&&r===o&&s({topic:r},i)}});a.container.globalWindow&&a.container.globalWindow.addEventListener&&a.container.globalWindow.addEventListener("message",t.listener),n(t)})},u.prototype.unsubscribe=function(n){return Promise.resolve(this.container.globalWindow.removeEventListener("message",n.listener))},u.prototype.publish=function(n,e,t){var o=this.container.globalWindow?this.container.globalWindow[W.windowsPropertyKey]||this.container.globalWindow.opener&&this.container.globalWindow.opener[W.windowsPropertyKey]:[];if(o)for(var i in o){var r=o[i];t&&t.name&&t.name!==r[W.windowNamePropertyKey]||r.location.origin===this.container.globalWindow.location.origin&&r.postMessage({source:u.messageSource,topic:n,message:e},this.container.globalWindow.location.origin)}return Promise.resolve()},u.messageSource="desktopJS",u}(),W=function(t){function u(n){var e=t.call(this,n)||this;return e.windowOptionsMap=u.defaultWindowOptionsMap,e.hostType="Default",e.ipc=e.createMessageBus(),!e.globalWindow||u.windowsPropertyKey in e.globalWindow||(e.globalWindow[u.windowsPropertyKey]={root:e.globalWindow}),e.screen=new P(e.globalWindow),e}return c(u,t),u.prototype.createMessageBus=function(){return new b(this)},u.prototype.getMainWindow=function(){return this.mainWindow||(this.mainWindow=new v(this.globalWindow)),this.mainWindow},u.prototype.getCurrentWindow=function(){return this.wrapWindow(this.globalWindow)},u.prototype.getWindowOptions=function(n){return o.transformProperties(n,this.windowOptionsMap)},u.prototype.wrapWindow=function(n){return new v(n)},u.prototype.onOpen=function(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];var o=n.apply(this.globalWindow,e),i=this.globalWindow[u.windowsPropertyKey],r=o[u.windowUuidPropertyKey]=m.newGuid();return(i[r]=o).addEventListener("beforeunload",function(){o.addEventListener("unload",function(){delete i[r]})}),o[u.windowsPropertyKey]=i,p.emit("window-created",{name:"window-created",windowId:r}),d.emit("window-created",{name:"window-created",windowId:r}),o},u.prototype.createWindow=function(n,e){var t,o="_blank",i=this.getWindowOptions(e);if(i){for(var r in i)t=(t||"")+r+"="+i[r]+",";i&&"target"in i&&(o=i.target)}var s=this.globalWindow.open(n,o,t);s[p.windowOptionsPropertyKey]=e,s[u.windowNamePropertyKey]=i.name;var a=this.wrapWindow(s);return this.emit("window-created",{sender:this,name:"window-created",window:a,windowId:a.id,windowName:i.name}),Promise.resolve(a)},u.prototype.showNotification=function(e,t){var o=this;"Notification"in this.globalWindow?this.globalWindow.Notification.requestPermission(function(n){"denied"===n?console.warn("Notifications not permitted"):"granted"===n&&new o.globalWindow.Notification(e,t)}):console.warn("Notifications not supported")},u.prototype.closeAllWindows=function(r){var s=this;return new Promise(function(n,e){var t=s.globalWindow[u.windowsPropertyKey];for(var o in t){var i=t[o];r&&s.globalWindow===i||i.close()}n()})},u.prototype.getAllWindows=function(){var r=this;return new Promise(function(n,e){var t=[],o=r.globalWindow[u.windowsPropertyKey];for(var i in o)t.push(o[i]);n(t)})},u.prototype.getWindowById=function(o){var i=this;return new Promise(function(n,e){var t=i.globalWindow[u.windowsPropertyKey][o];n(t?i.wrapWindow(t):null)})},u.prototype.getWindowByName=function(i){var r=this;return new Promise(function(n,e){var t=r.globalWindow[u.windowsPropertyKey];for(var o in t)if(t[o][u.windowNamePropertyKey]===i)return void n(r.wrapWindow(t[o]));n(null)})},u.prototype.saveLayout=function(r){var s=this,a=new w;return new Promise(function(n,e){var t=s.globalWindow[u.windowsPropertyKey];for(var o in t){var i=t[o];s.globalWindow!==i&&a.windows.push({name:i.name,url:i.location.toString(),bounds:{x:i.screenX,y:i.screenY,width:i.outerWidth,height:i.outerHeight},options:i[p.windowOptionsPropertyKey]})}s.saveLayoutToStorage(r,a),n(a)})},u.windowsPropertyKey="desktopJS-windows",u.windowUuidPropertyKey="desktopJS-uuid",u.windowNamePropertyKey="desktopJS-name",u.defaultWindowOptionsMap={x:{target:"left"},y:{target:"top"}},u}(e),P=function(){function n(n){this.window=n}return n.prototype.getPrimaryDisplay=function(){var t=this;return new Promise(function(n){var e=new u;e.scaleFactor=t.window.devicePixelRatio,e.id="Current",e.bounds=new f(t.window.screen.availLeft,t.window.screen.availTop,t.window.screen.width,t.window.screen.height),e.workArea=new f(t.window.screen.availLeft,t.window.screen.availTop,t.window.screen.availWidth,t.window.screen.availHeight),n(e)})},n.prototype.getAllDisplays=function(){var n=this;return new Promise(function(e){n.getPrimaryDisplay().then(function(n){return e([n])})})},n.prototype.getMousePosition=function(){var t=this;return new Promise(function(n,e){n({x:t.window.event.screenX,y:t.window.event.screenY})})},n}(),O=Object.freeze({DefaultContainerWindow:v,DefaultMessageBus:b,DefaultContainer:W}),x=new Map;function M(n,e){x[n]=e}function k(n,e){var t=!1,o=e;if("boolean"==typeof n?t=n:o=n,!t&&l)return l;for(var i in x)try{if(x[i].condition(o))return l=x[i].create(o)}catch(n){console.error("Error resolving container '"+i+"': "+n.toString())}return l=new W}var L=function(){function e(n,e){}return e.requestPermission=function(n){return n&&n(e.permission),Promise.resolve(e.permission)},e.permission="granted",e}();M("Electron",{condition:function(){try{return"undefined"!=typeof require&&(require("electron")||require("electron").remote)}catch(n){return!1}},create:function(n){return new G(null,null,null,n)}});var A=function(){function n(){}return n.initialize="desktopJS.window-initialize",n.getGroup="desktopJS.window-getGroup",n.joinGroup="desktopJS.window-joinGroup",n.leaveGroup="desktopJS.window-leaveGroup",n.getOptions="desktopJS.window-getOptions",n}(),S={},E=function(i){function n(n,e,t){var o=i.call(this,n)||this;return o.container=e,o.window=t,o}return c(n,i),Object.defineProperty(n.prototype,"isRemote",{get:function(){return this.container.internalIpc.send},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"id",{get:function(){return this.innerWindow.id||this.innerWindow.guestId},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!0,configurable:!0}),n.prototype.load=function(e,t){var o=this;return new Promise(function(n){t?o.innerWindow.loadURL(e,t):o.innerWindow.loadURL(e),n()})},n.prototype.focus=function(){return this.innerWindow.focus(),Promise.resolve()},n.prototype.show=function(){return this.innerWindow.show(),Promise.resolve()},n.prototype.hide=function(){return this.innerWindow.hide(),Promise.resolve()},n.prototype.close=function(){return this.innerWindow.close(),Promise.resolve()},n.prototype.maximize=function(){var e=this;return new Promise(function(n){e.innerWindow.maximize(),n()})},n.prototype.minimize=function(){var e=this;return new Promise(function(n){e.innerWindow.minimize(),n()})},n.prototype.restore=function(){var e=this;return new Promise(function(n){e.innerWindow.restore(),n()})},n.prototype.isShowing=function(){var t=this;return new Promise(function(n,e){n(t.innerWindow.isVisible())})},n.prototype.getSnapshot=function(){var t=this;return new Promise(function(e,n){t.innerWindow.capturePage(function(n){e("data:image/png;base64,"+n.toPNG().toString("base64"))})})},n.prototype.flash=function(n,e){return this.innerWindow.flashFrame(n),Promise.resolve()},n.prototype.getBounds=function(){var s=this;return new Promise(function(n){var e=s.innerWindow.getBounds(),t=e.x,o=e.y,i=e.width,r=e.height;n(new f(t,o,i,r))})},n.prototype.setBounds=function(e){var t=this;return new Promise(function(n){t.innerWindow.setBounds(e),n()})},Object.defineProperty(n.prototype,"allowGrouping",{get:function(){return!0},enumerable:!0,configurable:!0}),n.prototype.getGroup=function(){var e=this;return new Promise(function(n){n((e.isRemote?e.container.internalIpc.sendSync(A.getGroup,{source:e.id}):e.container.windowManager.getGroup(e.innerWindow)).map(function(n){return n===e.id?e:e.container.wrapWindow(e.container.browserWindow.fromId(n))}))})},n.prototype.joinGroup=function(n){return n&&n.id!==this.id&&(this.isRemote?this.container.internalIpc.send(A.joinGroup,{source:this.id,target:n.id}):this.container.windowManager.groupWindows(n.innerWindow,this.innerWindow)),Promise.resolve()},n.prototype.leaveGroup=function(){return this.isRemote?this.container.internalIpc.send(A.leaveGroup,{source:this.id}):this.container.windowManager.ungroupWindows(this.innerWindow),Promise.resolve()},n.prototype.getOptions=function(){var t=this;return new Promise(function(n,e){n(t.isRemote?t.container.internalIpc.sendSync(A.getOptions,{source:t.id}):t.innerWindow[p.windowOptionsPropertyKey])})},n.prototype.attachListener=function(n,e){if("beforeunload"===n){var t=this.window||window;if(!t||this.id!==this.container.getCurrentWindow().id)throw new Error("Event handler for 'beforeunload' can only be added on current window");t.addEventListener("beforeunload",e)}else this.innerWindow.addListener(S[n]||n,e)},n.prototype.detachListener=function(n,e){this.innerWindow.removeListener(S[n]||n,e)},Object.defineProperty(n.prototype,"nativeWindow",{get:function(){return this.window||window},enumerable:!0,configurable:!0}),n}(d),N=function(){function n(n,e){this.ipc=n,this.browserWindow=e}return n.prototype.subscribe=function(o,i,n){var r=this;return new Promise(function(n,e){var t=new h(o,function(n,e){i({topic:o},e)});r.ipc.on(o,t.listener),n(t)})},n.prototype.unsubscribe=function(n){var e=n.topic,t=n.listener;n.options;return Promise.resolve(this.ipc.removeListener(e,t))},n.prototype.publish=function(e,t,n){if(n&&n.name||(void 0!==this.ipc.send?this.ipc.send(e,t):this.ipc.listeners(e).forEach(function(n){return n({topic:e},t)})),this.browserWindow&&this.browserWindow.getAllWindows)for(var o=0,i=this.browserWindow.getAllWindows();o<i.length;o++){var r=i[o];n&&n.name?n.name===r.name&&r.webContents.send(e,t):r.webContents.send(e,t)}return Promise.resolve()},n}(),G=function(s){function a(n,e,t,o){var i=s.call(this,t)||this;i.isRemote=!0,i.windowOptionsMap=a.windowOptionsMap,i.hostType="Electron";try{n?i.electron=n:(i.electron=require("electron").remote,void 0===i.electron&&(i.electron=require("electron"),i.isRemote=!1)),i.app=i.electron.app,i.browserWindow=i.electron.BrowserWindow,i.tray=i.electron.Tray,i.menu=i.electron.Menu,i.internalIpc=e||(i.isRemote?require("electron").ipcRenderer:i.electron.ipcMain),i.ipc=i.createMessageBus(),(!i.isRemote||o&&void 0!==o.isRemote&&!o.isRemote)&&(i.windowManager=new B(i.app,i.internalIpc,i.browserWindow),i.app.on("browser-window-created",function(n,e){setImmediate(function(){p.emit("window-created",{name:"window-created",windowId:e.webContents.id}),d.emit("window-created",{name:"window-created",windowId:e.webContents.id})})}))}catch(n){console.error(n)}var r=a.replaceNotificationApi;return o&&void 0!==o.replaceNotificationApi&&(r=o.replaceNotificationApi),r&&i.registerNotificationsApi(),i.screen=new I(i.electron),i}return c(a,s),a.prototype.createMessageBus=function(){return new N(this.internalIpc,this.browserWindow)},a.prototype.registerNotificationsApi=function(){if(void 0!==this.globalWindow&&this.globalWindow){var i=this;this.globalWindow.Notification=function(o){function n(n,e){var t=o.call(this,n,e)||this;return e.notification=t,i.showNotification(n,e),t}return c(n,o),n}(L)}},a.prototype.getMainWindow=function(){for(var n=0,e=this.browserWindow.getAllWindows();n<e.length;n++){var t=e[n];if(t[p.windowOptionsPropertyKey]&&t[p.windowOptionsPropertyKey].main)return this.wrapWindow(t)}var o=this.browserWindow.fromId(1);return o?this.wrapWindow(o):void 0},a.prototype.getCurrentWindow=function(){return this.wrapWindow(this.electron.getCurrentWindow())},a.prototype.getWindowOptions=function(n){return o.transformProperties(n,this.windowOptionsMap)},a.prototype.wrapWindow=function(n){return new E(n,this)},a.prototype.createWindow=function(n,e){var t=this.getWindowOptions(e),o=new this.browserWindow(t),i=t.name||m.newGuid();this.isRemote?(o.name=this.internalIpc.sendSync(A.initialize,{id:o.id,name:i,options:t}),o[p.windowOptionsPropertyKey]=e):this.windowManager.initializeWindow(o,i,t),o.loadURL(this.ensureAbsoluteUrl(n));var r=this.wrapWindow(o);return this.emit("window-created",{sender:this,name:"window-created",window:r,windowId:o.id,windowName:i}),Promise.resolve(r)},a.prototype.showNotification=function(n,e){var t=new this.electron.Notification(Object.assign(e||{},{title:n}));e.onClick&&t.addListener("click",e.onClick),e.notification&&t.once("show",function(){return t.addListener("click",e.notification.onclick)}),t.show()},a.prototype.addTrayIcon=function(n,e,t){var o=new this.tray(n.icon);n.text&&o.setToolTip(n.text),t&&o.setContextMenu(this.menu.buildFromTemplate(t)),e&&o.on("click",e)},a.prototype.closeAllWindows=function(r){var s=this;return new Promise(function(n,e){for(var t=0,o=s.browserWindow.getAllWindows();t<o.length;t++){var i=o[t];r&&i===s.electron.getCurrentWindow()||i.close()}n()})},a.prototype.getAllWindows=function(){var e=this;return Promise.resolve(this.browserWindow.getAllWindows().map(function(n){return e.wrapWindow(n)}))},a.prototype.getWindowById=function(o){var i=this;return new Promise(function(n,e){var t=i.browserWindow.fromId(o);n(t?i.wrapWindow(t):null)})},a.prototype.getWindowByName=function(o){var i=this;return new Promise(function(n,e){var t=i.browserWindow.getAllWindows().find(function(n){return n.name===o});n(t?i.wrapWindow(t):null)})},a.prototype.saveLayout=function(t){var o=this,i=new w,r=this.getMainWindow().innerWindow,s=[];return new Promise(function(e,n){o.getAllWindows().then(function(n){n.forEach(function(t){s.push(new Promise(function(e,n){t.getGroup().then(function(n){i.windows.push({id:t.id,name:t.name,url:t.innerWindow.webContents.getURL(),main:r===t.innerWindow,options:t.innerWindow[p.windowOptionsPropertyKey],bounds:t.innerWindow.getBounds(),group:n.map(function(n){return n.id})}),e()})}))}),Promise.all(s).then(function(){o.saveLayoutToStorage(t,i),e(i)})})})},a.replaceNotificationApi=!0,a.windowOptionsMap={taskbar:{target:"skipTaskbar",convert:function(n,e,t){return!n}}},a}(e),B=function(){function n(n,e,t){var s=this;this.lastBounds=new Map,this.ignoredWindows=[],this.app=n||require("electron").app,this.ipc=e||require("electron").ipcMain,this.browserWindow=t||require("electron").BrowserWindow,this.ipc.on(A.initialize,function(n,e){var t=e.id,o=e.name,i=e.options,r=s.browserWindow.fromId(t);s.initializeWindow(r,o,i),n.returnValue=o}),this.ipc.on(A.joinGroup,function(n,e){var t=e.source,o=e.target,i=s.browserWindow.fromId(t),r=s.browserWindow.fromId(o);s.groupWindows(r,i)}),this.ipc.on(A.leaveGroup,function(n,e){var t=e.source;s.ungroupWindows(s.browserWindow.fromId(t))}),this.ipc.on(A.getGroup,function(n,e){var t=e.source;n.returnValue=s.getGroup(s.browserWindow.fromId(t))}),this.ipc.on(A.getOptions,function(n,e){var t=e.source;n.returnValue=s.browserWindow.fromId(t)[p.windowOptionsPropertyKey]})}return n.prototype.initializeWindow=function(n,e,t){var o=this;n.name=e,!(n[p.windowOptionsPropertyKey]=t)||!t.main||"quitOnClose"in t&&!t.quitOnClose||n.on("closed",function(){o.app.quit()})},n.prototype.registerWindowEvents=function(e){var t=this;e&&!e.moveHandler&&(this.lastBounds.set(e.id,e.getBounds()),e.moveHandler=function(n){return t.handleMove(e)},e.on("move",e.moveHandler))},n.prototype.unregisterWindowEvents=function(n){n&&n.moveHandler&&(this.lastBounds.delete(n.id),n.removeListener("move",n.moveHandler),delete n.moveHandler)},n.prototype.getGroup=function(e){return e.group?this.browserWindow.getAllWindows().filter(function(n){return n.group===e.group}).map(function(n){return n.id}):[]},n.prototype.groupWindows=function(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];for(var o=0,i=e;o<i.length;o++){var r=i[o];r.group=n.group||(n.group=m.newGuid()),this.registerWindowEvents(r)}this.registerWindowEvents(n)},n.prototype.ungroupWindows=function(){for(var i=this,n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var t=0,o=n;t<o.length;t++){var r=o[t];this.unregisterWindowEvents(r),r.group=null}this.groupBy(this.browserWindow.getAllWindows(),"group").filter(function(n){return n.key&&n.values&&1===n.values.length}).forEach(function(n){for(var e=0,t=n.values;e<t.length;e++){var o=t[e];i.unregisterWindowEvents(o),o.group=null}})},n.prototype.handleMove=function(e){var t=this,n=this.lastBounds.get(e.id),o=e.getBounds();if(this.lastBounds.set(e.id,o),n.width===o.width&&n.height===o.height&&!(0<=this.ignoredWindows.indexOf(e.id))&&e.group){var i=this.browserWindow.getAllWindows().filter(function(n){return n.group===e.group&&n.id!==e.id});if(i&&0<i.length){var r=n.x-o.x,s=n.y-o.y;i.forEach(function(n){var e=n.getBounds();t.ignoredWindows.push(n.id),n.setBounds({x:e.x-r,y:e.y-s,width:e.width,height:e.height},!0),t.ignoredWindows.splice(t.ignoredWindows.indexOf(n.id),1)})}}},n.prototype.groupBy=function(n,i){return n.reduce(function(n,e){var t=i instanceof Function?i(e):e[i],o=n.find(function(n){return n&&n.key===t});return o?o.values.push(e):n.push({key:t,values:[e]}),n},[])},n}(),I=function(){function n(n){this.electron=n}return n.prototype.createDisplay=function(n){var e=new u;return e.id=n.id,e.scaleFactor=n.scaleFactor,e.bounds=new f(n.bounds.x,n.bounds.y,n.bounds.width,n.bounds.height),e.workArea=new f(n.workArea.x,n.workArea.y,n.workArea.width,n.workArea.height),e},n.prototype.getPrimaryDisplay=function(){var t=this;return new Promise(function(n,e){n(t.createDisplay(t.electron.screen.getPrimaryDisplay()))})},n.prototype.getAllDisplays=function(){var t=this;return new Promise(function(n,e){n(t.electron.screen.getAllDisplays().map(t.createDisplay))})},n.prototype.getMousePosition=function(){var t=this;return new Promise(function(n,e){n(t.electron.screen.getCursorScreenPoint())})},n}(),T=Object.freeze({ElectronContainerWindow:E,ElectronMessageBus:N,ElectronContainer:G,ElectronWindowManager:B});M("OpenFin",{condition:function(){return"undefined"!=typeof window&&"fin"in window&&"desktop"in fin},create:function(n){return new z(null,null,n)}});var j={move:"bounds-changing",resize:"bounds-changing",close:"close-requested",focus:"focused",blur:"blurred",maximize:"maximized",minimize:"minimized",restore:"restored"},C=function(i){function o(n){return i.call(this,n)||this}return c(o,i),Object.defineProperty(o.prototype,"id",{get:function(){return this.name},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!0,configurable:!0}),o.prototype.load=function(t,n){var o=this;return new Promise(function(n,e){o.innerWindow.navigate(t,n,e)})},o.prototype.focus=function(){var t=this;return new Promise(function(n,e){t.innerWindow.focus(n,e)})},o.prototype.show=function(){var t=this;return new Promise(function(n,e){t.innerWindow.show(n,e)})},o.prototype.hide=function(){var t=this;return new Promise(function(n,e){t.innerWindow.hide(n,e)})},o.prototype.close=function(){var t=this;return new Promise(function(n,e){t.innerWindow.close(!1,n,e)})},o.prototype.minimize=function(){var t=this;return new Promise(function(n,e){t.innerWindow.minimize(n,e)})},o.prototype.maximize=function(){var t=this;return new Promise(function(n,e){t.innerWindow.maximize(n,e)})},o.prototype.restore=function(){var t=this;return new Promise(function(n,e){t.innerWindow.restore(n,e)})},o.prototype.isShowing=function(){var t=this;return new Promise(function(n,e){t.innerWindow.isShowing(n,e)})},o.prototype.getSnapshot=function(){var n=this;return new Promise(function(e,t){n.innerWindow.getSnapshot(function(n){return e("data:image/png;base64,"+n)},function(n){return t(n)})})},o.prototype.getBounds=function(){var t=this;return new Promise(function(e,n){t.innerWindow.getBounds(function(n){return e(new f(n.left,n.top,n.width,n.height))},n)})},o.prototype.flash=function(t,o){var i=this;return new Promise(function(n,e){t?i.innerWindow.flash(o,n,e):i.innerWindow.stopFlashing(n,e)})},o.prototype.setBounds=function(t){var o=this;return new Promise(function(n,e){o.innerWindow.setBounds(t.x,t.y,t.width,t.height,n,e)})},Object.defineProperty(o.prototype,"allowGrouping",{get:function(){return!0},enumerable:!0,configurable:!0}),o.prototype.getGroup=function(){var t=this;return new Promise(function(e,n){t.innerWindow.getGroup(function(n){e(n.map(function(n){return new o(n)}))},n)})},o.prototype.joinGroup=function(t){var o=this;return t&&t.id!==this.id?new Promise(function(n,e){o.innerWindow.joinGroup(t.innerWindow,n,e)}):Promise.resolve()},o.prototype.leaveGroup=function(){var t=this;return new Promise(function(n,e){t.innerWindow.leaveGroup(n,e)})},o.prototype.getOptions=function(){var t=this;return new Promise(function(e,n){t.innerWindow.getOptions(function(n){return e(n.customData?JSON.parse(n.customData):void 0)},n)})},o.prototype.attachListener=function(n,t){var o=this;"beforeunload"===n?this.innerWindow.addEventListener("close-requested",function(n){var e=new s(o,"beforeunload",n);t(e),void 0===e.returnValue&&o.innerWindow.close(!0)}):this.innerWindow.addEventListener(j[n]||n,t)},o.prototype.wrapListener=function(e,t){var o=this;return"resize"===e?function(n){1<=n.changeType&&t(new s(o,e,n))}:"move"===e?function(n){0===n.changeType&&t(new s(o,e,n))}:i.prototype.wrapListener.call(this,e,t)},o.prototype.detachListener=function(n,e){this.innerWindow.removeEventListener(j[n]||n,e)},Object.defineProperty(o.prototype,"nativeWindow",{get:function(){return this.innerWindow.getNativeWindow()},enumerable:!0,configurable:!0}),o}(d),R=function(){function n(n,e){this.bus=n,this.uuid=e}return n.prototype.subscribe=function(o,i,r){var s=this;return new Promise(function(n,e){var t=new h(o,function(n,e,t){i({topic:o},n)},r);s.bus.subscribe(r&&r.uuid||"*",r&&r.name||void 0,t.topic,t.listener,function(){return n(t)},e)})},n.prototype.unsubscribe=function(n){var t=this,o=n.topic,i=n.listener,r=n.options;return new Promise(function(n,e){t.bus.unsubscribe(r&&r.uuid||"*",r&&r.name||void 0,o,i,n,e)})},n.prototype.publish=function(t,o,i){var r=this;return new Promise(function(n,e){i&&i.uuid||i&&i.name?r.bus.send(i.uuid||r.uuid,i.name||void 0,t,o,n,e):r.bus.publish(t,o,n,e)})},n}(),z=function(r){function g(n,e,t){var o=r.call(this,e)||this;o.windowOptionsMap=g.windowOptionsMap,o.notificationOptionsMap=g.notificationOptionsMap,o.desktop=n||fin.desktop,o.hostType="OpenFin",t&&t.userName&&t.appName&&o.desktop.Application.getCurrent().registerUser(t.userName,t.appName),o.ipc=o.createMessageBus();var i=g.replaceNotificationApi;return t&&void 0!==t.replaceNotificationApi&&(i=t.replaceNotificationApi),i&&o.registerNotificationsApi(),o.desktop.Application.getCurrent().addEventListener("window-created",function(n){o.emit("window-created",{sender:o,name:"window-created",windowId:n.name,windowName:n.name}),p.emit("window-created",{name:"window-created",windowId:n.name,windowName:n.name}),d.emit("window-created",{name:"window-created",windowId:n.name,windowName:n.name})}),o.screen=new K(o.desktop),o}return c(g,r),g.prototype.createMessageBus=function(){return new R(this.desktop.InterApplicationBus,this.desktop.Application.getCurrent().uuid)},g.prototype.registerNotificationsApi=function(){if(void 0!==this.globalWindow&&this.globalWindow){var i=this;this.globalWindow.Notification=function(o){function n(n,e){var t=o.call(this,n,e)||this;return e.notification=t,e.onClick=function(n){t.onclick&&t.onclick(n)},e.onError=function(n){t.onerror&&t.onerror(n)},i.showNotification(n,e),t}return c(n,o),n}(L)}},g.prototype.log=function(t,o){var i=this;return new Promise(function(n,e){i.desktop.System.log(t,o,n,e)})},g.prototype.getMainWindow=function(){return this.mainWindow||(this.mainWindow=this.wrapWindow(this.desktop.Application.getCurrent().getWindow())),this.mainWindow},g.prototype.getCurrentWindow=function(){return this.wrapWindow(this.desktop.Window.getCurrent())},g.prototype.getWindowOptions=function(n){var e=o.transformProperties(n,this.windowOptionsMap);return e.customData=n?JSON.stringify(n):void 0,"autoShow"in e||(e.autoShow=!0),"saveWindowState"in e||!("defaultLeft"in e||"defaultTop"in e)||(e.saveWindowState=!1),"icon"in e&&(e.icon=this.ensureAbsoluteUrl(e.icon)),e},g.prototype.wrapWindow=function(n){return new C(n)},g.prototype.createWindow=function(n,e){var o=this,i=this.getWindowOptions(e);return i.url=n,"name"in i||(i.name=m.newGuid()),new Promise(function(e,n){var t=new o.desktop.Window(i,function(n){e(o.wrapWindow(t))},n)})},g.prototype.showNotification=function(n,e){new this.desktop.Notification(o.transformProperties(e,this.notificationOptionsMap))},g.prototype.getMenuHtml=function(){return g.menuHtml},g.prototype.getMenuItemHtml=function(n){var e=n.icon?'<span><img align="absmiddle" class="context-menu-image" src="'+this.ensureAbsoluteUrl(n.icon)+'" /></span>':"<span>&nbsp;</span>";return'<li class="context-menu-item" onclick="fin.desktop.InterApplicationBus.send(\''+this.desktop.Application.getCurrent().uuid+"', null, 'TrayIcon_ContextMenuClick_"+this.uuid+"', { id: '"+n.id+"' });this.close()\">"+e+n.label+"</li>"},g.prototype.showMenu=function(p,d,f,w){var l=this;this.menuItemRef=w;var h=new this.desktop.Window({name:"trayMenu"+m.newGuid(),saveWindowState:!1,autoShow:!1,defaultWidth:150,defaultHeight:100,showTaskbarIcon:!1,frame:!1,contextMenu:!0,resizable:!1,alwaysOnTop:!0,shadow:!0,smallWindow:!0},function(){var n=h.getNativeWindow();n.document.open("text/html","replace"),n.document.write(l.getMenuHtml()),n.document.close();for(var e="",t=0,o=w.filter(function(n){return n.label});t<o.length;t++){var i=o[t];i.id||(i.id=m.newGuid()),e+=l.getMenuItemHtml(i)}var r=n.document.getElementById("contextMenu");r.innerHTML=e;var s=r.offsetWidth,a=r.offsetHeight;h.resizeTo(s,a,"top-left");var u=p+s>f.primaryMonitor.monitorRect.right?p-s-g.trayIconMenuLeftOffset:p,c=d+a>f.primaryMonitor.monitorRect.bottom?d-a-g.trayIconMenuTopOffset:d;h.addEventListener("blurred",function(){return h.close()}),h.showAt(u,c,!1,function(){return h.focus()})})},g.prototype.addTrayIcon=function(n,e,t){var i=this;this.desktop.Application.getCurrent().setTrayIcon(this.ensureAbsoluteUrl(n.icon),function(n){0===n.button&&e?e():2===n.button&&i.showMenu(n.x+g.trayIconMenuLeftOffset,n.y+g.trayIconMenuTopOffset,n.monitorInfo,t)},function(){i.desktop.InterApplicationBus.subscribe(i.desktop.Application.getCurrent().uuid,"TrayIcon_ContextMenuClick_"+i.uuid,function(n,e){for(var t in i.menuItemRef){var o=i.menuItemRef[t];o.id===n.id&&o.click&&o.click(o)}})},function(n){console.error(n)})},g.prototype.closeAllWindows=function(){var t=this;return new Promise(function(e,n){var o=[];t.desktop.Application.getCurrent().getChildWindows(function(n){n.forEach(function(t){o.push(new Promise(function(n,e){return t.close(!0,n,e)}))}),Promise.all(o).then(function(){return e()})},n)})},g.prototype.getAllWindows=function(){var t=this;return new Promise(function(e,n){t.desktop.Application.getCurrent().getChildWindows(function(n){n.push(t.desktop.Application.getCurrent().getWindow()),e(n.map(function(n){return t.wrapWindow(n)}))},n)})},g.prototype.getWindowById=function(n){return this.getWindowByName(n)},g.prototype.getWindowByName=function(o){var i=this;return new Promise(function(t,n){i.desktop.Application.getCurrent().getChildWindows(function(n){n.push(i.desktop.Application.getCurrent().getWindow());var e=n.find(function(n){return n.name===o});t(e?i.wrapWindow(e):null)})})},g.prototype.saveLayout=function(i){var s=this,a=new w;return new Promise(function(t,o){s.desktop.Application.getCurrent().getChildWindows(function(n){var e=[],r=s.desktop.Application.getCurrent().getWindow();n.concat(r).filter(function(n){return"queueCounter"!==n.name&&!n.name.startsWith(g.notificationGuid)}).forEach(function(i){e.push(new Promise(function(o,n){i.getBounds(function(t){i.getOptions(function(e){delete e.show,i.getGroup(function(n){a.windows.push({name:i.name,id:i.name,url:i.getNativeWindow()?i.getNativeWindow().location.toString():e.url,main:r.name===i.name,options:e,bounds:{x:t.left,y:t.top,width:t.width,height:t.height},group:n.map(function(n){return n.name})}),o()},n)},n)},n)}))}),Promise.all(e).then(function(){s.saveLayoutToStorage(i,a),t(a)}).catch(function(n){return o(n)})})})},g.trayIconMenuLeftOffset=4,g.trayIconMenuTopOffset=23,g.notificationGuid="A21B62E0-16B1-4B10-8BE3-BBB6B489D862",g.replaceNotificationApi=!0,g.windowOptionsMap={x:{target:"defaultLeft"},y:{target:"defaultTop"},height:{target:"defaultHeight"},width:{target:"defaultWidth"},taskbar:{target:"showTaskbarIcon"},center:{target:"defaultCentered"},show:{target:"autoShow"}},g.notificationOptionsMap={body:{target:"message"}},g.menuHtml='<html>\n <head>\n <style>\n body:before, body:after {\n position: fixed;\n background: silver;\n }\n body {\n margin: 0px;\n overflow: hidden;\n }\n .context-menu {\n list-style: none;\n padding: 1px 0 1px 0;\n }\n .context-menu-item {\n display: block;\n cursor: default;\n font-family: Arial, Helvetica, sans-serif;\n font-size: 9pt;\n margin-bottom: 2px;\n padding: 4px 0 4px 4px;\n white-space: nowrap;\n }\n .context-menu-item span {\n display: inline-block;\n min-width: 20px;\n }\n .context-menu-item:last-child {\n margin-bottom: 0;\n } \n .context-menu-item:hover {\n color: #fff;\n background-color: #0066aa;\n }\n .context-menu-image {\n width: 16px;\n height: 16px;\n margin-top: -1px;\n margin-right: 4px;\n } \n </style>\n <script>\n document.addEventListener(\'keydown\', (event) => {\n if (event.keyCode == 27) {\n window.close();\n }\n }, false);\n <\/script>\n </head>\n <body>\n <ul class="context-menu" id="contextMenu"></ul>\n </body>\n </html>',g}(e),K=function(){function n(n){this.desktop=n}return n.prototype.createDisplay=function(n){var e=new u;return e.id=n.name,e.scaleFactor=n.deviceScaleFactor,e.bounds=new f(n.monitorRect.left,n.monitorRect.top,n.monitorRect.right-n.monitorRect.left,n.monitorRect.bottom-n.monitorRect.top),e.workArea=new f(n.availableRect.left,n.availableRect.top,n.availableRect.right-n.availableRect.left,n.availableRect.bottom-n.availableRect.top),e},n.prototype.getPrimaryDisplay=function(){var t=this;return new Promise(function(e,n){t.desktop.System.getMonitorInfo(function(n){e(t.createDisplay(n.primaryMonitor))},n)})},n.prototype.getAllDisplays=function(){var t=this;return new Promise(function(e,n){t.desktop.System.getMonitorInfo(function(n){e([n.primaryMonitor].concat(n.nonPrimaryMonitors).map(t.createDisplay))},n)})},n.prototype.getMousePosition=function(){var t=this;return new Promise(function(e,n){t.desktop.System.getMousePosition(function(n){e({x:n.left,y:n.top})},n)})},n}(),H=Object.freeze({OpenFinContainerWindow:C,OpenFinMessageBus:R,OpenFinContainer:z});return function(){function n(){}return Object.defineProperty(n,"version",{get:function(){return"2.5.0"},enumerable:!0,configurable:!0}),Object.defineProperty(n,"Container",{get:function(){return p},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ContainerWindow",{get:function(){return d},enumerable:!0,configurable:!0}),Object.defineProperty(n,"registerContainer",{get:function(){return M},enumerable:!0,configurable:!0}),Object.defineProperty(n,"resolveContainer",{get:function(){return k},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ContainerNotification",{get:function(){return L},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ObjectTransform",{get:function(){return o},enumerable:!0,configurable:!0}),Object.defineProperty(n,"Default",{get:function(){return O},enumerable:!0,configurable:!0}),Object.defineProperty(n,"Electron",{get:function(){return T},enumerable:!0,configurable:!0}),Object.defineProperty(n,"OpenFin",{get:function(){return H},enumerable:!0,configurable:!0}),Object.defineProperty(n,"WindowStateTracking",{get:function(){return t},enumerable:!0,configurable:!0}),Object.defineProperty(n,"GroupWindowManager",{get:function(){return r},enumerable:!0,configurable:!0}),Object.defineProperty(n,"SnapAssistWindowManager",{get:function(){return a},enumerable:!0,configurable:!0}),Object.defineProperty(n,"MessageBusSubscription",{get:function(){return h},enumerable:!0,configurable:!0}),Object.defineProperty(n,"MessageBusOptions",{get:function(){return g},enumerable:!0,configurable:!0}),n}()});
"undefined"==typeof desktopJS&&function(n,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):n.desktopJS=e()}(this,function(){"use strict";var o=function(n,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,e){n.__proto__=e}||function(n,e){for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t])})(n,e)};function c(n,e){function t(){this.constructor=n}o(n,e),n.prototype=null===e?Object.create(e):(t.prototype=e.prototype,new t)}function p(r,s,a,u){return new(a||(a=Promise))(function(n,e){function t(n){try{i(u.next(n))}catch(n){e(n)}}function o(n){try{i(u.throw(n))}catch(n){e(n)}}function i(e){e.done?n(e.value):new a(function(n){n(e.value)}).then(t,o)}i((u=u.apply(r,s||[])).next())})}function d(t,o){var i,r,s,n,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return n={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function e(e){return function(n){return function(e){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,r&&(s=2&e[0]?r.return:e[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,e[1])).done)return s;switch(r=0,s&&(e=[2&e[0],s.value]),e[0]){case 0:case 1:s=e;break;case 4:return a.label++,{value:e[1],done:!1};case 5:a.label++,r=e[1],e=[0];continue;case 7:e=a.ops.pop(),a.trys.pop();continue;default:if(!(s=0<(s=a.trys).length&&s[s.length-1])&&(6===e[0]||2===e[0])){a=0;continue}if(3===e[0]&&(!s||e[1]>s[0]&&e[1]<s[3])){a.label=e[1];break}if(6===e[0]&&a.label<s[1]){a.label=s[1],s=e;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(e);break}s[2]&&a.ops.pop(),a.trys.pop();continue}e=o.call(t,a)}catch(n){e=[6,n],r=0}finally{i=s=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}([e,n])}}}var t,n,s=function(n,e,t){this.sender=n,this.name=e,this.innerEvent=t},i=function(){function r(){this.eventListeners=new Map,this.wrappedListeners=new Map}return r.prototype.addListener=function(n,e){return(this.eventListeners[n]=this.eventListeners[n]||[]).push(e),this},r.prototype.registerAndWrapListener=function(n,e){var t=this.wrapListener(n,e);return this.wrappedListeners.set(e,t),t},r.prototype.wrapListener=function(o,i){var r=this;return function(n){var e=new s(r,o,n);r.preProcessArgs(e);var t=i(e);return r.postProcessArgs(e),t}},r.prototype.preProcessArgs=function(n){},r.prototype.postProcessArgs=function(n){n&&void 0!==n.returnValue&&(n.innerEvent.returnValue=n.returnValue)},r.prototype.unwrapAndUnRegisterListener=function(n){var e=this.wrappedListeners.get(n);return e&&this.wrappedListeners.delete(n),e},r.prototype.removeListener=function(n,e){var t=this.listeners(n);if(t){var o=t.indexOf(e);0<=o&&t.splice(o,1)}return this},r.prototype.listeners=function(n){return this.eventListeners[n]||[]},r.prototype.emit=function(n,e){for(var t=0,o=this.listeners(n);t<o.length;t++){(0,o[t])(e)}},Object.defineProperty(r,"ipc",{set:function(n){n&&n.subscribe(r.staticEventName,function(n,e){r.emit(e.eventName,e.eventArgs)})},enumerable:!0,configurable:!0}),r.addListener=function(n,e){(this.staticEventListeners[n]=this.staticEventListeners[n]||[]).push(e)},r.removeListener=function(n,e){var t=r.listeners(n);if(t){var o=t.indexOf(e);0<=o&&t.splice(o,1)}},r.listeners=function(n){return this.staticEventListeners[n]||[]},r.emit=function(n,e,t){if(t&&t.publish)t.publish(r.staticEventName,{eventName:n,eventArgs:e});else for(var o=0,i=r.listeners(n);o<i.length;o++){(0,i[o])(e)}},r.staticEventListeners=new Map,r.staticEventName="desktopJS.static-event",r}(),m=function(){function n(){}return n.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var e=16*Math.random()|0;return("x"==n?e:3&e|8).toString(16)})},n}(),f=(function(n){function e(){return null!==n&&n.apply(this,arguments)||this}c(e,n)}(s),function(t){function o(){return null!==t&&t.apply(this,arguments)||this}return c(o,t),Object.defineProperty(o,"ipc",{get:function(){return o._ipc},set:function(n){i.ipc=o._ipc=n},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"ipc",{get:function(){return o.ipc},set:function(n){o.ipc=n},enumerable:!0,configurable:!0}),o.prototype.addListener=function(n,e){return t.prototype.addListener.call(this,n,e)},o.prototype.removeListener=function(n,e){return t.prototype.removeListener.call(this,n,e)},o.prototype.emit=function(n,e){t.prototype.emit.call(this,n,e)},o.addListener=function(n,e){i.addListener(o.staticEventScopePrefix+n,e)},o.removeListener=function(n,e){i.removeListener(o.staticEventScopePrefix+n,e)},o.emit=function(n,e){i.emit(o.staticEventScopePrefix+n,e,o.ipc)},o.listeners=function(n){return i.listeners(o.staticEventScopePrefix+n)},o.staticEventScopePrefix="container-",o.windowOptionsPropertyKey="desktopJS-options",o}(i)),e=function(e){function n(n){var t=e.call(this)||this;t.globalWindow=n||"undefined"!=typeof window&&window||null,t.linkHelper={href:"unknown"};try{t.linkHelper=t.globalWindow.top.document.createElement("a")}catch(n){}if(t.globalWindow){var o=t.globalWindow.open;t.globalWindow.open=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return t.onOpen.apply(t,[o].concat(n))}}return t}return c(n,e),n.prototype.onOpen=function(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];return n.apply(this.globalWindow,e)},n.prototype.ensureAbsoluteUrl=function(n){return this.linkHelper?(this.linkHelper.href=n,this.linkHelper.href):n},n}(function(e){function r(){var n=null!==e&&e.apply(this,arguments)||this;return n.uuid=m.newGuid(),n.storage="undefined"!=typeof window&&window?window.localStorage:void 0,n}return c(r,e),r.prototype.showNotification=function(n,e){throw new TypeError("Notifications not supported by this container")},r.prototype.addTrayIcon=function(n,e,t){throw new TypeError("Tray icons are not supported by this container.")},r.prototype.getLayoutFromStorage=function(n){return JSON.parse(this.storage.getItem(r.layoutsPropertyKey))[n]},r.prototype.saveLayoutToStorage=function(n,e){var t=JSON.parse(this.storage.getItem(r.layoutsPropertyKey))||{};e.name||(e.name=n),t[n]=e,this.storage.setItem(r.layoutsPropertyKey,JSON.stringify(t)),this.emit("layout-saved",{sender:this,name:"layout-saved",layout:e,layoutName:e.name}),f.emit("layout-saved",{name:"layout-saved",layout:e,layoutName:e.name})},r.prototype.loadLayout=function(u){var c=this;return new Promise(function(s,a){c.closeAllWindows(!0).then(function(){var r=c.getLayoutFromStorage(u);if(r&&r.windows){for(var n=[],e=0,t=r.windows;e<t.length;e++){var o=t[e],i=Object.assign(o.options||{},o.bounds);i.name=o.name,o.main?(c.getMainWindow().setBounds(o.bounds),n.push(Promise.resolve(c.getMainWindow()))):n.push(c.createWindow(o.url,i))}Promise.all(n).then(function(n){var i=new Map;n.forEach(function(t){var n=r.windows.find(function(n){return n.name===t.name});n&&n.state&&t.setState&&t.setState(n.state).catch(function(n){return c.log("error","Error invoking setState: "+n)});var o=!1;if(i.forEach(function(n,e){!o&&0<=n.indexOf(t.id)&&(o=!0)}),!o){var e=n?n.group:void 0;e&&0<e.length&&i.set(t,e.filter(function(n){return n!==t.id}))}}),i.forEach(function(n,t){n.forEach(function(e){c.getWindowByName(r.windows.find(function(n){return n.id===e}).name).then(function(n){n.joinGroup(t)})})})}),c.emit("layout-loaded",{sender:c,name:"layout-loaded",layout:r,layoutName:r.name}),f.emit("layout-loaded",{name:"layout-loaded",layout:r,layoutName:r.name}),s(r)}else a("Layout does not exist")})})},r.prototype.getLayouts=function(){var i=this;return new Promise(function(n,e){var t=i.storage.getItem(r.layoutsPropertyKey);if(t){var o=JSON.parse(t);n(Object.getOwnPropertyNames(o).map(function(n){return o[n]}))}n(void 0)})},r.prototype.log=function(t,o){return new Promise(function(n){var e;switch(t){case"debug":e=console.debug;break;case"warn":e=console.warn;break;case"error":e=console.error;break;default:e=console.log}e&&e(o),n()})},r.layoutsPropertyKey="desktopJS-layouts",r}(f)),w=function(){function n(n,e,t,o){this.x=n,this.y=e,this.width=t,this.height=o}return Object.defineProperty(n.prototype,"right",{get:function(){return n.getRight(this)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"bottom",{get:function(){return n.getBottom(this)},enumerable:!0,configurable:!0}),n.getRight=function(n){return n.x+n.width},n.getBottom=function(n){return n.y+n.height},n}(),l=(function(n){function e(){return null!==n&&n.apply(this,arguments)||this}c(e,n)}(s),function(o){function t(n){var e=o.call(this)||this;return e.innerWindow=n,e}return c(t,o),Object.defineProperty(t.prototype,"allowGrouping",{get:function(){return!1},enumerable:!0,configurable:!0}),t.prototype.getGroup=function(){return Promise.resolve([])},t.prototype.joinGroup=function(n){return Promise.reject("Not supported")},t.prototype.leaveGroup=function(){return Promise.resolve()},t.prototype.getState=function(){return Promise.resolve(void 0)},t.prototype.setState=function(n){return Promise.resolve()},Object.defineProperty(t.prototype,"nativeWindow",{get:function(){},enumerable:!0,configurable:!0}),t.prototype.addListener=function(n,e){var t=this.registerAndWrapListener(n,e);return this.attachListener(n,t),o.prototype.addListener.call(this,n,t)},t.prototype.removeListener=function(n,e){var t=this.unwrapAndUnRegisterListener(e)||e;return this.detachListener(n,t),o.prototype.removeListener.call(this,n,t)},t.addListener=function(n,e){i.addListener(t.staticEventScopePrefix+n,e)},t.removeListener=function(n,e){i.removeListener(t.staticEventScopePrefix+n,e)},t.emit=function(n,e){i.emit(t.staticEventScopePrefix+n,e,f.ipc)},t.listeners=function(n){return i.listeners(t.staticEventScopePrefix+n)},t.staticEventScopePrefix="containerwindow-",t}(i)),h=function(n){this.windows=[],this.name=n};(n=t||(t={}))[n.None=0]="None",n[n.Main=1]="Main",n[n.Group=2]="Group";var y,r=function(){function n(n,e){this.windowStateTracking=t.None,this.container=n,e&&"windowStateTracking"in e&&(this.windowStateTracking=e.windowStateTracking),this.attach()}return n.prototype.attach=function(n){var e=this;n?(n.addListener("undefined"!=typeof fin?"minimized":"minimize",function(n){e.windowStateTracking&t.Main&&e.container.getMainWindow().id===n.sender.id&&e.container.getAllWindows().then(function(n){n.forEach(function(n){return n.minimize()})}),e.windowStateTracking&t.Group&&n.sender.getGroup().then(function(n){n.forEach(function(n){return n.minimize()})})}),n.addListener("undefined"!=typeof fin?"restored":"restore",function(n){e.windowStateTracking&t.Main&&e.container.getMainWindow().id===n.sender.id&&e.container.getAllWindows().then(function(n){n.forEach(function(n){return n.restore()})}),e.windowStateTracking&t.Group&&n.sender.getGroup().then(function(n){n.forEach(function(n){return n.restore()})})})):(l.addListener("window-created",function(n){e.container&&e.container.getWindowById&&e.container.getWindowById(n.windowId).then(function(n){e.attach(n)})}),this.container&&this.container.getAllWindows().then(function(n){n.forEach(function(n){return e.attach(n)})}))},n}(),a=function(o){function n(n,e){var t=o.call(this,n,e)||this;return t.autoGrouping=!0,t.snapThreshold=15,t.snapOffset=15,t.targetGroup=new Map,e&&("snapThreshold"in e&&(t.snapThreshold=e.snapThreshold),"snapOffset"in e&&(t.snapOffset=e.snapOffset),"autoGrouping"in e&&(t.autoGrouping=e.autoGrouping)),t}return c(n,o),n.prototype.onAttached=function(n){var e=this;n.innerWindow&&n.innerWindow.disableFrame&&n.innerWindow.disableFrame(),"undefined"!=typeof fin?n.addListener("disabled-frame-bounds-changed",function(){return e.onMoved(n)}):n.innerWindow&&n.innerWindow.hookWindowMessage&&n.innerWindow.hookWindowMessage(562,function(){return e.onMoved(n)})},n.prototype.attach=function(e){var t=this;o.prototype.attach.call(this,e),e&&e.getOptions().then(function(n){n&&void 0!==n.snap&&!1===n.snap||(t.onAttached(e),e.addListener("undefined"!=typeof fin?"disabled-frame-bounds-changing":"move",function(n){return t.onMoving(n)}))})},n.prototype.onMoving=function(a){var u=this,t=a.sender.id;this.snappingWindow!==t&&a.sender.getOptions().then(function(n){n&&void 0!==n.snap&&!1===n.snap||a.sender.getGroup().then(function(n){("undefined"!=typeof fin?Promise.resolve(new w(a.innerEvent.left,a.innerEvent.top,a.innerEvent.width,a.innerEvent.height)):a.sender.getBounds()).then(function(s){if(0<n.length)"undefined"!=typeof fin&&u.moveWindow(a.sender,s);else{var e=[];u.container.getAllWindows().then(function(n){n.filter(function(n){return t!==n.id}).forEach(function(o){e.push(new Promise(function(t){o.getOptions().then(function(e){o.getBounds().then(function(n){return t({window:o,bounds:n,options:e})})})}))}),Promise.all(e).then(function(n){for(var e,t=!1,o=0,i=n.filter(function(n){return!(n.options&&void 0!==n.options.snap&&!1===n.options.snap)});o<i.length;o++){var r=i[o];(e=u.getSnapBounds(e||s,r.bounds))?(t=!0,u.showGroupingHint(r.window),u.moveWindow(a.sender,e)):u.hideGroupingHint(r.window)}t||"undefined"==typeof fin||u.moveWindow(a.sender,s)})})}})})})},n.prototype.moveWindow=function(n,e){var t=this;this.snappingWindow=n.id,n.setBounds(e).then(function(){return t.snappingWindow=void 0},function(){return t.snappingWindow=void 0})},n.prototype.onMoved=function(t){var e=this;if(this.autoGrouping){var n=[];this.targetGroup.forEach(function(t){return n.push(new Promise(function(e){t.getGroup().then(function(n){return e({window:t,isGrouped:0<n.length})})}))}),Promise.all(n).then(function(n){0<n.length&&t.joinGroup(n[0].window);for(var e=1;e<n.length;e++)n[e].isGrouped||n[e].window.joinGroup(t)})}this.targetGroup.forEach(function(n){return e.hideGroupingHint(n)}),this.targetGroup.clear()},n.prototype.showGroupingHint=function(n){n.innerWindow&&n.innerWindow.updateOptions&&n.innerWindow.updateOptions({opacity:.75}),this.targetGroup.set(n.id,n)},n.prototype.hideGroupingHint=function(n){n.innerWindow&&n.innerWindow.updateOptions&&n.innerWindow.updateOptions({opacity:1}),this.targetGroup.delete(n.id)},n.prototype.isHorizontallyAligned=function(n,e){return n.y>=e.y&&n.y<=e.bottom||n.bottom>=e.y&&n.bottom<=e.bottom||n.y<=e.y&&n.bottom>=e.bottom},n.prototype.isVerticallyAligned=function(n,e){return n.x>=e.x&&n.x<=e.right||n.right>=e.x&&n.right<=e.right||n.x<=e.x&&n.right>=e.right},n.prototype.getSnapBounds=function(n,e){var t,o,i,r,s,a,u,c;if(this.isHorizontallyAligned(n,e)&&(t=Math.abs(n.x-(e.right-this.snapOffset))<this.snapThreshold,o=Math.abs(n.x-e.x)<this.snapThreshold,i=Math.abs(n.right-this.snapOffset-e.x)<this.snapThreshold,r=Math.abs(n.right-e.right)<this.snapThreshold),this.isVerticallyAligned(n,e)&&(s=Math.abs(n.y-(e.bottom-this.snapOffset))<this.snapThreshold,a=Math.abs(n.y-e.y)<this.snapThreshold,u=Math.abs(n.bottom-this.snapOffset-e.y)<this.snapThreshold,c=Math.abs(n.bottom-e.bottom)<this.snapThreshold),t||i||s||u){var p=n.x,d=n.y;return t?p=e.x+e.width-this.snapOffset:o&&(p=e.x),i?p=e.x-n.width+this.snapOffset:r&&(p=e.x+e.width-n.width),s?d=e.y+e.height-Math.floor(this.snapOffset/2):a&&(d=e.y),u?d=e.y-n.height+Math.floor(this.snapOffset/2):c&&(d=e.y+e.height-n.height),new w(p,d,n.width,n.height)}},n}(r),u=function(){};(y||(y={})).transformProperties=function(n,e){var t={};if(n)for(var o in n)try{o in e?t[e[o].target]=e[o].convert?e[o].convert(n[o],n,t):n[o]:t[o]=n[o]}catch(n){console.error("Error transforming property '"+o+"'")}return t};var g,v=function(n,e,t){this.topic=n,this.listener=e,this.options=t},b=function(){},W={close:"unload"},P=function(e){function n(n){return e.call(this,n)||this}return c(n,e),Object.defineProperty(n.prototype,"id",{get:function(){return this.innerWindow[x.windowUuidPropertyKey]},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this.innerWindow[x.windowNamePropertyKey]},enumerable:!0,configurable:!0}),n.prototype.load=function(e,n){var t=this;return new Promise(function(n){t.innerWindow.location.replace(e),n()})},n.prototype.focus=function(){return this.innerWindow.focus(),Promise.resolve()},n.prototype.show=function(){return Promise.resolve()},n.prototype.hide=function(){return Promise.resolve()},n.prototype.close=function(){return this.innerWindow.close(),Promise.resolve()},n.prototype.minimize=function(){var e=this;return new Promise(function(n){e.innerWindow.minimize(),n()})},n.prototype.maximize=function(){var e=this;return new Promise(function(n){e.innerWindow.maximize(),n()})},n.prototype.restore=function(){var e=this;return new Promise(function(n){e.innerWindow.restore(),n()})},n.prototype.isShowing=function(){return Promise.resolve(!0)},n.prototype.getSnapshot=function(){return Promise.reject("getSnapshot requires an implementation.")},n.prototype.flash=function(n,e){return Promise.reject("Not supported")},n.prototype.getBounds=function(){var e=this;return new Promise(function(n){n(new w(e.innerWindow.screenX,e.innerWindow.screenY,e.innerWindow.outerWidth,e.innerWindow.outerHeight))})},n.prototype.setBounds=function(e){var t=this;return new Promise(function(n){t.innerWindow.moveTo(e.x,e.y),t.innerWindow.resizeTo(e.width,e.height),n()})},n.prototype.getOptions=function(){var t=this;return new Promise(function(n,e){n(t.innerWindow[f.windowOptionsPropertyKey])})},n.prototype.getState=function(){var e=this;return new Promise(function(n){e.nativeWindow&&e.nativeWindow.getState?n(e.nativeWindow.getState()):n(void 0)})},n.prototype.setState=function(e){var t=this;return new Promise(function(n){t.nativeWindow&&t.nativeWindow.setState&&t.nativeWindow.setState(e),n()})},n.prototype.attachListener=function(n,e){this.innerWindow.addEventListener(W[n]||n,e)},n.prototype.detachListener=function(n,e){this.innerWindow.removeEventListener(W[n]||n,e)},Object.defineProperty(n.prototype,"nativeWindow",{get:function(){return this.innerWindow},enumerable:!0,configurable:!0}),n}(l),O=function(){function u(n){this.container=n}return u.prototype.subscribe=function(r,s,n){var a=this;return new Promise(function(n,e){var t=new v(r,function(n){if(n.origin===a.container.globalWindow.location.origin){var e=n.data,t=e.source,o=e.topic,i=e.message;t===u.messageSource&&r===o&&s({topic:r},i)}});a.container.globalWindow&&a.container.globalWindow.addEventListener&&a.container.globalWindow.addEventListener("message",t.listener),n(t)})},u.prototype.unsubscribe=function(n){return Promise.resolve(this.container.globalWindow.removeEventListener("message",n.listener))},u.prototype.publish=function(n,e,t){var o=this.container.globalWindow?this.container.globalWindow[x.windowsPropertyKey]||this.container.globalWindow.opener&&this.container.globalWindow.opener[x.windowsPropertyKey]:[];if(o)for(var i in o){var r=o[i];t&&t.name&&t.name!==r[x.windowNamePropertyKey]||r.location.origin===this.container.globalWindow.location.origin&&r.postMessage({source:u.messageSource,topic:n,message:e},this.container.globalWindow.location.origin)}return Promise.resolve()},u.messageSource="desktopJS",u}(),x=function(t){function u(n){var e=t.call(this,n)||this;return e.windowOptionsMap=u.defaultWindowOptionsMap,e.hostType="Default",e.ipc=e.createMessageBus(),!e.globalWindow||u.windowsPropertyKey in e.globalWindow||(e.globalWindow[u.windowsPropertyKey]={root:e.globalWindow}),e.screen=new S(e.globalWindow),e}return c(u,t),u.prototype.createMessageBus=function(){return new O(this)},u.prototype.getMainWindow=function(){return this.mainWindow||(this.mainWindow=new P(this.globalWindow)),this.mainWindow},u.prototype.getCurrentWindow=function(){return this.wrapWindow(this.globalWindow)},u.prototype.getWindowOptions=function(n){return y.transformProperties(n,this.windowOptionsMap)},u.prototype.wrapWindow=function(n){return new P(n)},u.prototype.onOpen=function(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];var o=n.apply(this.globalWindow,e),i=this.globalWindow[u.windowsPropertyKey],r=o[u.windowUuidPropertyKey]=m.newGuid();return(i[r]=o).addEventListener("beforeunload",function(){o.addEventListener("unload",function(){delete i[r]})}),o[u.windowsPropertyKey]=i,f.emit("window-created",{name:"window-created",windowId:r}),l.emit("window-created",{name:"window-created",windowId:r}),o},u.prototype.createWindow=function(n,e){var t,o="_blank",i=this.getWindowOptions(e);if(i){for(var r in i)t=(t||"")+r+"="+i[r]+",";i&&"target"in i&&(o=i.target)}var s=this.globalWindow.open(n,o,t);s[f.windowOptionsPropertyKey]=e,s[u.windowNamePropertyKey]=i.name;var a=this.wrapWindow(s);return this.emit("window-created",{sender:this,name:"window-created",window:a,windowId:a.id,windowName:i.name}),Promise.resolve(a)},u.prototype.showNotification=function(e,t){var o=this;"Notification"in this.globalWindow?this.globalWindow.Notification.requestPermission(function(n){"denied"===n?console.warn("Notifications not permitted"):"granted"===n&&new o.globalWindow.Notification(e,t)}):console.warn("Notifications not supported")},u.prototype.closeAllWindows=function(r){var s=this;return new Promise(function(n,e){var t=s.globalWindow[u.windowsPropertyKey];for(var o in t){var i=t[o];r&&s.globalWindow===i||i.close()}n()})},u.prototype.getAllWindows=function(){var r=this;return new Promise(function(n,e){var t=[],o=r.globalWindow[u.windowsPropertyKey];for(var i in o)t.push(r.wrapWindow(o[i]));n(t)})},u.prototype.getWindowById=function(o){var i=this;return new Promise(function(n,e){var t=i.globalWindow[u.windowsPropertyKey][o];n(t?i.wrapWindow(t):null)})},u.prototype.getWindowByName=function(i){var r=this;return new Promise(function(n,e){var t=r.globalWindow[u.windowsPropertyKey];for(var o in t)if(t[o][u.windowNamePropertyKey]===i)return void n(r.wrapWindow(t[o]));n(null)})},u.prototype.saveLayout=function(i){var a=this,u=new h;return new Promise(function(e,t){var o=[];a.getAllWindows().then(function(n){n.forEach(function(s){o.push(new Promise(function(r){return p(a,void 0,void 0,function(){var e,t,o,i;return d(this,function(n){switch(n.label){case 0:return e=s.nativeWindow,this.globalWindow===e?[3,2]:(o=(t=u.windows).push,i={name:s.name,url:e.location.toString(),id:s.id,bounds:{x:e.screenX,y:e.screenY,width:e.outerWidth,height:e.outerHeight},options:e[f.windowOptionsPropertyKey]},[4,s.getState()]);case 1:o.apply(t,[(i.state=n.sent(),i)]),n.label=2;case 2:return r(),[2]}})})}))}),Promise.all(o).then(function(){a.saveLayoutToStorage(i,u),e(u)}).catch(function(n){return t(n)})})})},u.windowsPropertyKey="desktopJS-windows",u.windowUuidPropertyKey="desktopJS-uuid",u.windowNamePropertyKey="desktopJS-name",u.defaultWindowOptionsMap={x:{target:"left"},y:{target:"top"}},u}(e),S=function(){function n(n){this.window=n}return n.prototype.getPrimaryDisplay=function(){var t=this;return new Promise(function(n){var e=new u;e.scaleFactor=t.window.devicePixelRatio,e.id="Current",e.bounds=new w(t.window.screen.availLeft,t.window.screen.availTop,t.window.screen.width,t.window.screen.height),e.workArea=new w(t.window.screen.availLeft,t.window.screen.availTop,t.window.screen.availWidth,t.window.screen.availHeight),n(e)})},n.prototype.getAllDisplays=function(){var n=this;return new Promise(function(e){n.getPrimaryDisplay().then(function(n){return e([n])})})},n.prototype.getMousePosition=function(){var t=this;return new Promise(function(n,e){n({x:t.window.event.screenX,y:t.window.event.screenY})})},n}(),M=Object.freeze({DefaultContainerWindow:P,DefaultMessageBus:O,DefaultContainer:x}),k=new Map;function L(n,e){k[n]=e}function A(n,e){var t=!1,o=e;if("boolean"==typeof n?t=n:o=n,!t&&g)return g;for(var i in k)try{if(k[i].condition(o))return g=k[i].create(o)}catch(n){console.error("Error resolving container '"+i+"': "+n.toString())}return g=new x}var E=function(){function e(n,e){}return e.requestPermission=function(n){return n&&n(e.permission),Promise.resolve(e.permission)},e.permission="granted",e}();L("Electron",{condition:function(){try{return"undefined"!=typeof require&&(require("electron")||require("electron").remote)}catch(n){return!1}},create:function(n){return new T(null,null,null,n)}});var N=function(){function n(){}return n.initialize="desktopJS.window-initialize",n.getGroup="desktopJS.window-getGroup",n.joinGroup="desktopJS.window-joinGroup",n.leaveGroup="desktopJS.window-leaveGroup",n.getOptions="desktopJS.window-getOptions",n}(),G={},B=function(i){function n(n,e,t){var o=i.call(this,n)||this;return o.container=e,o.window=t,o}return c(n,i),Object.defineProperty(n.prototype,"isRemote",{get:function(){return this.container.internalIpc.send},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"id",{get:function(){return this.innerWindow.id||this.innerWindow.guestId},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!0,configurable:!0}),n.prototype.load=function(e,t){var o=this;return new Promise(function(n){t?o.innerWindow.loadURL(e,t):o.innerWindow.loadURL(e),n()})},n.prototype.focus=function(){return this.innerWindow.focus(),Promise.resolve()},n.prototype.show=function(){return this.innerWindow.show(),Promise.resolve()},n.prototype.hide=function(){return this.innerWindow.hide(),Promise.resolve()},n.prototype.close=function(){return this.innerWindow.close(),Promise.resolve()},n.prototype.maximize=function(){var e=this;return new Promise(function(n){e.innerWindow.maximize(),n()})},n.prototype.minimize=function(){var e=this;return new Promise(function(n){e.innerWindow.minimize(),n()})},n.prototype.restore=function(){var e=this;return new Promise(function(n){e.innerWindow.restore(),n()})},n.prototype.isShowing=function(){var t=this;return new Promise(function(n,e){n(t.innerWindow.isVisible())})},n.prototype.getSnapshot=function(){var t=this;return new Promise(function(e,n){t.innerWindow.capturePage(function(n){e("data:image/png;base64,"+n.toPNG().toString("base64"))})})},n.prototype.flash=function(n,e){return this.innerWindow.flashFrame(n),Promise.resolve()},n.prototype.getBounds=function(){var s=this;return new Promise(function(n){var e=s.innerWindow.getBounds(),t=e.x,o=e.y,i=e.width,r=e.height;n(new w(t,o,i,r))})},n.prototype.setBounds=function(e){var t=this;return new Promise(function(n){t.innerWindow.setBounds(e),n()})},Object.defineProperty(n.prototype,"allowGrouping",{get:function(){return!0},enumerable:!0,configurable:!0}),n.prototype.getGroup=function(){var e=this;return new Promise(function(n){n((e.isRemote?e.container.internalIpc.sendSync(N.getGroup,{source:e.id}):e.container.windowManager.getGroup(e.innerWindow)).map(function(n){return n===e.id?e:e.container.wrapWindow(e.container.browserWindow.fromId(n))}))})},n.prototype.joinGroup=function(n){return n&&n.id!==this.id&&(this.isRemote?this.container.internalIpc.send(N.joinGroup,{source:this.id,target:n.id}):this.container.windowManager.groupWindows(n.innerWindow,this.innerWindow)),Promise.resolve()},n.prototype.leaveGroup=function(){return this.isRemote?this.container.internalIpc.send(N.leaveGroup,{source:this.id}):this.container.windowManager.ungroupWindows(this.innerWindow),Promise.resolve()},n.prototype.getOptions=function(){var t=this;return new Promise(function(n,e){n(t.isRemote?t.container.internalIpc.sendSync(N.getOptions,{source:t.id}):t.innerWindow[f.windowOptionsPropertyKey])})},n.prototype.getState=function(){return this.innerWindow&&this.innerWindow.webContents?this.innerWindow.webContents.executeJavaScript("window.getState ? window.getState() : undefined"):Promise.resolve(void 0)},n.prototype.setState=function(n){return this.innerWindow&&this.innerWindow.webContents?this.innerWindow.webContents.executeJavaScript("if (window.setState) { window.setState(JSON.parse(`"+JSON.stringify(n)+"`)); }"):Promise.resolve()},n.prototype.attachListener=function(n,e){if("beforeunload"===n){var t=this.window||window;if(!t||this.id!==this.container.getCurrentWindow().id)throw new Error("Event handler for 'beforeunload' can only be added on current window");t.addEventListener("beforeunload",e)}else this.innerWindow.addListener(G[n]||n,e)},n.prototype.detachListener=function(n,e){this.innerWindow.removeListener(G[n]||n,e)},Object.defineProperty(n.prototype,"nativeWindow",{get:function(){return this.window||window},enumerable:!0,configurable:!0}),n}(l),I=function(){function n(n,e){this.ipc=n,this.browserWindow=e}return n.prototype.subscribe=function(o,i,n){var r=this;return new Promise(function(n,e){var t=new v(o,function(n,e){i({topic:o},e)});r.ipc.on(o,t.listener),n(t)})},n.prototype.unsubscribe=function(n){var e=n.topic,t=n.listener;n.options;return Promise.resolve(this.ipc.removeListener(e,t))},n.prototype.publish=function(e,t,n){if(n&&n.name||(void 0!==this.ipc.send?this.ipc.send(e,t):this.ipc.listeners(e).forEach(function(n){return n({topic:e},t)})),this.browserWindow&&this.browserWindow.getAllWindows)for(var o=0,i=this.browserWindow.getAllWindows();o<i.length;o++){var r=i[o];n&&n.name?n.name===r.name&&r.webContents.send(e,t):r.webContents.send(e,t)}return Promise.resolve()},n}(),T=function(s){function a(n,e,t,o){var i=s.call(this,t)||this;i.isRemote=!0,i.windowOptionsMap=a.windowOptionsMap,i.hostType="Electron";try{n?i.electron=n:(i.electron=require("electron").remote,void 0===i.electron&&(i.electron=require("electron"),i.isRemote=!1)),i.app=i.electron.app,i.browserWindow=i.electron.BrowserWindow,i.tray=i.electron.Tray,i.menu=i.electron.Menu,i.internalIpc=e||(i.isRemote?require("electron").ipcRenderer:i.electron.ipcMain),i.ipc=i.createMessageBus(),(!i.isRemote||o&&void 0!==o.isRemote&&!o.isRemote)&&(i.windowManager=new j(i.app,i.internalIpc,i.browserWindow),i.app.on("browser-window-created",function(n,e){setImmediate(function(){f.emit("window-created",{name:"window-created",windowId:e.webContents.id}),l.emit("window-created",{name:"window-created",windowId:e.webContents.id})})}))}catch(n){console.error(n)}var r=a.replaceNotificationApi;return o&&void 0!==o.replaceNotificationApi&&(r=o.replaceNotificationApi),r&&i.registerNotificationsApi(),i.screen=new C(i.electron),i}return c(a,s),a.prototype.createMessageBus=function(){return new I(this.internalIpc,this.browserWindow)},a.prototype.registerNotificationsApi=function(){if(void 0!==this.globalWindow&&this.globalWindow){var i=this;this.globalWindow.Notification=function(o){function n(n,e){var t=o.call(this,n,e)||this;return e.notification=t,i.showNotification(n,e),t}return c(n,o),n}(E)}},a.prototype.getMainWindow=function(){for(var n=0,e=this.browserWindow.getAllWindows();n<e.length;n++){var t=e[n];if(t[f.windowOptionsPropertyKey]&&t[f.windowOptionsPropertyKey].main)return this.wrapWindow(t)}var o=this.browserWindow.fromId(1);return o?this.wrapWindow(o):void 0},a.prototype.getCurrentWindow=function(){return this.wrapWindow(this.electron.getCurrentWindow())},a.prototype.getWindowOptions=function(n){return y.transformProperties(n,this.windowOptionsMap)},a.prototype.wrapWindow=function(n){return new B(n,this)},a.prototype.createWindow=function(n,e){var t=this.getWindowOptions(e),o=new this.browserWindow(t),i=t.name||m.newGuid();this.isRemote?(o.name=this.internalIpc.sendSync(N.initialize,{id:o.id,name:i,options:t}),o[f.windowOptionsPropertyKey]=e):this.windowManager.initializeWindow(o,i,t),o.loadURL(this.ensureAbsoluteUrl(n));var r=this.wrapWindow(o);return this.emit("window-created",{sender:this,name:"window-created",window:r,windowId:o.id,windowName:i}),Promise.resolve(r)},a.prototype.showNotification=function(n,e){var t=new this.electron.Notification(Object.assign(e||{},{title:n}));e.onClick&&t.addListener("click",e.onClick),e.notification&&t.once("show",function(){return t.addListener("click",e.notification.onclick)}),t.show()},a.prototype.addTrayIcon=function(n,e,t){var o=new this.tray(n.icon);n.text&&o.setToolTip(n.text),t&&o.setContextMenu(this.menu.buildFromTemplate(t)),e&&o.on("click",e)},a.prototype.closeAllWindows=function(r){var s=this;return new Promise(function(n,e){for(var t=0,o=s.browserWindow.getAllWindows();t<o.length;t++){var i=o[t];r&&i===s.electron.getCurrentWindow()||i.close()}n()})},a.prototype.getAllWindows=function(){var e=this;return Promise.resolve(this.browserWindow.getAllWindows().map(function(n){return e.wrapWindow(n)}))},a.prototype.getWindowById=function(o){var i=this;return new Promise(function(n,e){var t=i.browserWindow.fromId(o);n(t?i.wrapWindow(t):null)})},a.prototype.getWindowByName=function(o){var i=this;return new Promise(function(n,e){var t=i.browserWindow.getAllWindows().find(function(n){return n.name===o});n(t?i.wrapWindow(t):null)})},a.prototype.saveLayout=function(t){var o=this,a=new h,u=this.getMainWindow().innerWindow,i=[];return new Promise(function(e,n){o.getAllWindows().then(function(n){n.forEach(function(s){i.push(new Promise(function(r,n){s.getGroup().then(function(i){return p(o,void 0,void 0,function(){var e,t,o;return d(this,function(n){switch(n.label){case 0:return t=(e=a.windows).push,o={id:s.id,name:s.name,url:s.innerWindow.webContents.getURL(),main:u===s.innerWindow},[4,s.getState()];case 1:return t.apply(e,[(o.state=n.sent(),o.options=s.innerWindow[f.windowOptionsPropertyKey],o.bounds=s.innerWindow.getBounds(),o.group=i.map(function(n){return n.id}),o)]),r(),[2]}})})})}))}),Promise.all(i).then(function(){o.saveLayoutToStorage(t,a),e(a)})})})},a.replaceNotificationApi=!0,a.windowOptionsMap={taskbar:{target:"skipTaskbar",convert:function(n,e,t){return!n}}},a}(e),j=function(){function n(n,e,t){var s=this;this.lastBounds=new Map,this.ignoredWindows=[],this.app=n||require("electron").app,this.ipc=e||require("electron").ipcMain,this.browserWindow=t||require("electron").BrowserWindow,this.ipc.on(N.initialize,function(n,e){var t=e.id,o=e.name,i=e.options,r=s.browserWindow.fromId(t);s.initializeWindow(r,o,i),n.returnValue=o}),this.ipc.on(N.joinGroup,function(n,e){var t=e.source,o=e.target,i=s.browserWindow.fromId(t),r=s.browserWindow.fromId(o);s.groupWindows(r,i)}),this.ipc.on(N.leaveGroup,function(n,e){var t=e.source;s.ungroupWindows(s.browserWindow.fromId(t))}),this.ipc.on(N.getGroup,function(n,e){var t=e.source;n.returnValue=s.getGroup(s.browserWindow.fromId(t))}),this.ipc.on(N.getOptions,function(n,e){var t=e.source;n.returnValue=s.browserWindow.fromId(t)[f.windowOptionsPropertyKey]})}return n.prototype.initializeWindow=function(n,e,t){var o=this;n.name=e,!(n[f.windowOptionsPropertyKey]=t)||!t.main||"quitOnClose"in t&&!t.quitOnClose||n.on("closed",function(){o.app.quit()})},n.prototype.registerWindowEvents=function(e){var t=this;e&&!e.moveHandler&&(this.lastBounds.set(e.id,e.getBounds()),e.moveHandler=function(n){return t.handleMove(e)},e.on("move",e.moveHandler))},n.prototype.unregisterWindowEvents=function(n){n&&n.moveHandler&&(this.lastBounds.delete(n.id),n.removeListener("move",n.moveHandler),delete n.moveHandler)},n.prototype.getGroup=function(e){return e.group?this.browserWindow.getAllWindows().filter(function(n){return n.group===e.group}).map(function(n){return n.id}):[]},n.prototype.groupWindows=function(n){for(var e=[],t=1;t<arguments.length;t++)e[t-1]=arguments[t];for(var o=0,i=e;o<i.length;o++){var r=i[o];r.group=n.group||(n.group=m.newGuid()),this.registerWindowEvents(r)}this.registerWindowEvents(n)},n.prototype.ungroupWindows=function(){for(var i=this,n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];for(var t=0,o=n;t<o.length;t++){var r=o[t];this.unregisterWindowEvents(r),r.group=null}this.groupBy(this.browserWindow.getAllWindows(),"group").filter(function(n){return n.key&&n.values&&1===n.values.length}).forEach(function(n){for(var e=0,t=n.values;e<t.length;e++){var o=t[e];i.unregisterWindowEvents(o),o.group=null}})},n.prototype.handleMove=function(e){var t=this,n=this.lastBounds.get(e.id),o=e.getBounds();if(this.lastBounds.set(e.id,o),n.width===o.width&&n.height===o.height&&!(0<=this.ignoredWindows.indexOf(e.id))&&e.group){var i=this.browserWindow.getAllWindows().filter(function(n){return n.group===e.group&&n.id!==e.id});if(i&&0<i.length){var r=n.x-o.x,s=n.y-o.y;i.forEach(function(n){var e=n.getBounds();t.ignoredWindows.push(n.id),n.setBounds({x:e.x-r,y:e.y-s,width:e.width,height:e.height},!0),t.ignoredWindows.splice(t.ignoredWindows.indexOf(n.id),1)})}}},n.prototype.groupBy=function(n,i){return n.reduce(function(n,e){var t=i instanceof Function?i(e):e[i],o=n.find(function(n){return n&&n.key===t});return o?o.values.push(e):n.push({key:t,values:[e]}),n},[])},n}(),C=function(){function n(n){this.electron=n}return n.prototype.createDisplay=function(n){var e=new u;return e.id=n.id,e.scaleFactor=n.scaleFactor,e.bounds=new w(n.bounds.x,n.bounds.y,n.bounds.width,n.bounds.height),e.workArea=new w(n.workArea.x,n.workArea.y,n.workArea.width,n.workArea.height),e},n.prototype.getPrimaryDisplay=function(){var t=this;return new Promise(function(n,e){n(t.createDisplay(t.electron.screen.getPrimaryDisplay()))})},n.prototype.getAllDisplays=function(){var t=this;return new Promise(function(n,e){n(t.electron.screen.getAllDisplays().map(t.createDisplay))})},n.prototype.getMousePosition=function(){var t=this;return new Promise(function(n,e){n(t.electron.screen.getCursorScreenPoint())})},n}(),R=Object.freeze({ElectronContainerWindow:B,ElectronMessageBus:I,ElectronContainer:T,ElectronWindowManager:j});L("OpenFin",{condition:function(){return"undefined"!=typeof window&&"fin"in window&&"desktop"in fin},create:function(n){return new D(null,null,n)}});var z={move:"bounds-changing",resize:"bounds-changing",close:"close-requested",focus:"focused",blur:"blurred",maximize:"maximized",minimize:"minimized",restore:"restored"},K=function(i){function o(n){return i.call(this,n)||this}return c(o,i),Object.defineProperty(o.prototype,"id",{get:function(){return this.name},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"name",{get:function(){return this.innerWindow.name},enumerable:!0,configurable:!0}),o.prototype.load=function(t,n){var o=this;return new Promise(function(n,e){o.innerWindow.navigate(t,n,e)})},o.prototype.focus=function(){var t=this;return new Promise(function(n,e){t.innerWindow.focus(n,e)})},o.prototype.show=function(){var t=this;return new Promise(function(n,e){t.innerWindow.show(n,e)})},o.prototype.hide=function(){var t=this;return new Promise(function(n,e){t.innerWindow.hide(n,e)})},o.prototype.close=function(){var t=this;return new Promise(function(n,e){t.innerWindow.close(!1,n,e)})},o.prototype.minimize=function(){var t=this;return new Promise(function(n,e){t.innerWindow.minimize(n,e)})},o.prototype.maximize=function(){var t=this;return new Promise(function(n,e){t.innerWindow.maximize(n,e)})},o.prototype.restore=function(){var t=this;return new Promise(function(n,e){t.innerWindow.restore(n,e)})},o.prototype.isShowing=function(){var t=this;return new Promise(function(n,e){t.innerWindow.isShowing(n,e)})},o.prototype.getSnapshot=function(){var n=this;return new Promise(function(e,t){n.innerWindow.getSnapshot(function(n){return e("data:image/png;base64,"+n)},function(n){return t(n)})})},o.prototype.getBounds=function(){var t=this;return new Promise(function(e,n){t.innerWindow.getBounds(function(n){return e(new w(n.left,n.top,n.width,n.height))},n)})},o.prototype.flash=function(t,o){var i=this;return new Promise(function(n,e){t?i.innerWindow.flash(o,n,e):i.innerWindow.stopFlashing(n,e)})},o.prototype.setBounds=function(t){var o=this;return new Promise(function(n,e){o.innerWindow.setBounds(t.x,t.y,t.width,t.height,n,e)})},Object.defineProperty(o.prototype,"allowGrouping",{get:function(){return!0},enumerable:!0,configurable:!0}),o.prototype.getGroup=function(){var t=this;return new Promise(function(e,n){t.innerWindow.getGroup(function(n){e(n.map(function(n){return new o(n)}))},n)})},o.prototype.joinGroup=function(t){var o=this;return t&&t.id!==this.id?new Promise(function(n,e){o.innerWindow.joinGroup(t.innerWindow,n,e)}):Promise.resolve()},o.prototype.leaveGroup=function(){var t=this;return new Promise(function(n,e){t.innerWindow.leaveGroup(n,e)})},o.prototype.getOptions=function(){var t=this;return new Promise(function(e,n){t.innerWindow.getOptions(function(n){return e(n.customData?JSON.parse(n.customData):void 0)},n)})},o.prototype.getState=function(){var e=this;return new Promise(function(n){e.nativeWindow&&e.nativeWindow.getState?n(e.nativeWindow.getState()):n(void 0)})},o.prototype.setState=function(e){var t=this;return new Promise(function(n){t.nativeWindow&&t.nativeWindow.setState&&t.nativeWindow.setState(e),n()})},o.prototype.attachListener=function(n,t){var o=this;"beforeunload"===n?this.innerWindow.addEventListener("close-requested",function(n){var e=new s(o,"beforeunload",n);t(e),void 0===e.returnValue&&o.innerWindow.close(!0)}):this.innerWindow.addEventListener(z[n]||n,t)},o.prototype.wrapListener=function(e,t){var o=this;return"resize"===e?function(n){1<=n.changeType&&t(new s(o,e,n))}:"move"===e?function(n){0===n.changeType&&t(new s(o,e,n))}:i.prototype.wrapListener.call(this,e,t)},o.prototype.detachListener=function(n,e){this.innerWindow.removeEventListener(z[n]||n,e)},Object.defineProperty(o.prototype,"nativeWindow",{get:function(){return this.innerWindow.getNativeWindow()},enumerable:!0,configurable:!0}),o}(l),H=function(){function n(n,e){this.bus=n,this.uuid=e}return n.prototype.subscribe=function(o,i,r){var s=this;return new Promise(function(n,e){var t=new v(o,function(n,e,t){i({topic:o},n)},r);s.bus.subscribe(r&&r.uuid||"*",r&&r.name||void 0,t.topic,t.listener,function(){return n(t)},e)})},n.prototype.unsubscribe=function(n){var t=this,o=n.topic,i=n.listener,r=n.options;return new Promise(function(n,e){t.bus.unsubscribe(r&&r.uuid||"*",r&&r.name||void 0,o,i,n,e)})},n.prototype.publish=function(t,o,i){var r=this;return new Promise(function(n,e){i&&i.uuid||i&&i.name?r.bus.send(i.uuid||r.uuid,i.name||void 0,t,o,n,e):r.bus.publish(t,o,n,e)})},n}(),D=function(r){function g(n,e,t){var o=r.call(this,e)||this;o.windowOptionsMap=g.windowOptionsMap,o.notificationOptionsMap=g.notificationOptionsMap,o.desktop=n||fin.desktop,o.hostType="OpenFin",t&&t.userName&&t.appName&&o.desktop.Application.getCurrent().registerUser(t.userName,t.appName),o.ipc=o.createMessageBus();var i=g.replaceNotificationApi;return t&&void 0!==t.replaceNotificationApi&&(i=t.replaceNotificationApi),i&&o.registerNotificationsApi(),o.desktop.Application.getCurrent().addEventListener("window-created",function(n){o.emit("window-created",{sender:o,name:"window-created",windowId:n.name,windowName:n.name}),f.emit("window-created",{name:"window-created",windowId:n.name,windowName:n.name}),l.emit("window-created",{name:"window-created",windowId:n.name,windowName:n.name})}),o.screen=new J(o.desktop),o}return c(g,r),g.prototype.createMessageBus=function(){return new H(this.desktop.InterApplicationBus,this.desktop.Application.getCurrent().uuid)},g.prototype.registerNotificationsApi=function(){if(void 0!==this.globalWindow&&this.globalWindow){var i=this;this.globalWindow.Notification=function(o){function n(n,e){var t=o.call(this,n,e)||this;return e.notification=t,e.onClick=function(n){t.onclick&&t.onclick(n)},e.onError=function(n){t.onerror&&t.onerror(n)},i.showNotification(n,e),t}return c(n,o),n}(E)}},g.prototype.log=function(t,o){var i=this;return new Promise(function(n,e){i.desktop.System.log(t,o,n,e)})},g.prototype.getMainWindow=function(){return this.mainWindow||(this.mainWindow=this.wrapWindow(this.desktop.Application.getCurrent().getWindow())),this.mainWindow},g.prototype.getCurrentWindow=function(){return this.wrapWindow(this.desktop.Window.getCurrent())},g.prototype.getWindowOptions=function(n){var e=y.transformProperties(n,this.windowOptionsMap);return e.customData=n?JSON.stringify(n):void 0,"autoShow"in e||(e.autoShow=!0),"saveWindowState"in e||!("defaultLeft"in e||"defaultTop"in e)||(e.saveWindowState=!1),"icon"in e&&(e.icon=this.ensureAbsoluteUrl(e.icon)),e},g.prototype.wrapWindow=function(n){return new K(n)},g.prototype.createWindow=function(n,e){var o=this,i=this.getWindowOptions(e);return i.url=n,"name"in i||(i.name=m.newGuid()),new Promise(function(e,n){var t=new o.desktop.Window(i,function(n){e(o.wrapWindow(t))},n)})},g.prototype.showNotification=function(n,e){new this.desktop.Notification(y.transformProperties(e,this.notificationOptionsMap))},g.prototype.getMenuHtml=function(){return g.menuHtml},g.prototype.getMenuItemHtml=function(n){var e=n.icon?'<span><img align="absmiddle" class="context-menu-image" src="'+this.ensureAbsoluteUrl(n.icon)+'" /></span>':"<span>&nbsp;</span>";return'<li class="context-menu-item" onclick="fin.desktop.InterApplicationBus.send(\''+this.desktop.Application.getCurrent().uuid+"', null, 'TrayIcon_ContextMenuClick_"+this.uuid+"', { id: '"+n.id+"' });this.close()\">"+e+n.label+"</li>"},g.prototype.showMenu=function(p,d,f,w){var l=this;this.menuItemRef=w;var h=new this.desktop.Window({name:"trayMenu"+m.newGuid(),saveWindowState:!1,autoShow:!1,defaultWidth:150,defaultHeight:100,showTaskbarIcon:!1,frame:!1,contextMenu:!0,resizable:!1,alwaysOnTop:!0,shadow:!0,smallWindow:!0},function(){var n=h.getNativeWindow();n.document.open("text/html","replace"),n.document.write(l.getMenuHtml()),n.document.close();for(var e="",t=0,o=w.filter(function(n){return n.label});t<o.length;t++){var i=o[t];i.id||(i.id=m.newGuid()),e+=l.getMenuItemHtml(i)}var r=n.document.getElementById("contextMenu");r.innerHTML=e;var s=r.offsetWidth,a=r.offsetHeight;h.resizeTo(s,a,"top-left");var u=p+s>f.primaryMonitor.monitorRect.right?p-s-g.trayIconMenuLeftOffset:p,c=d+a>f.primaryMonitor.monitorRect.bottom?d-a-g.trayIconMenuTopOffset:d;h.addEventListener("blurred",function(){return h.close()}),h.showAt(u,c,!1,function(){return h.focus()})})},g.prototype.addTrayIcon=function(n,e,t){var i=this;this.desktop.Application.getCurrent().setTrayIcon(this.ensureAbsoluteUrl(n.icon),function(n){0===n.button&&e?e():2===n.button&&i.showMenu(n.x+g.trayIconMenuLeftOffset,n.y+g.trayIconMenuTopOffset,n.monitorInfo,t)},function(){i.desktop.InterApplicationBus.subscribe(i.desktop.Application.getCurrent().uuid,"TrayIcon_ContextMenuClick_"+i.uuid,function(n,e){for(var t in i.menuItemRef){var o=i.menuItemRef[t];o.id===n.id&&o.click&&o.click(o)}})},function(n){console.error(n)})},g.prototype.closeAllWindows=function(){var t=this;return new Promise(function(e,n){var o=[];t.desktop.Application.getCurrent().getChildWindows(function(n){n.forEach(function(t){o.push(new Promise(function(n,e){return t.close(!0,n,e)}))}),Promise.all(o).then(function(){return e()})},n)})},g.prototype.getAllWindows=function(){var t=this;return new Promise(function(e,n){t.desktop.Application.getCurrent().getChildWindows(function(n){n.push(t.desktop.Application.getCurrent().getWindow()),e(n.map(function(n){return t.wrapWindow(n)}))},n)})},g.prototype.getWindowById=function(n){return this.getWindowByName(n)},g.prototype.getWindowByName=function(o){var i=this;return new Promise(function(t,n){i.desktop.Application.getCurrent().getChildWindows(function(n){n.push(i.desktop.Application.getCurrent().getWindow());var e=n.find(function(n){return n.name===o});t(e?i.wrapWindow(e):null)})})},g.prototype.saveLayout=function(s){var n=this,u=new h;return new Promise(function(i,r){return p(n,void 0,void 0,function(){var e,a,t,o=this;return d(this,function(n){switch(n.label){case 0:return[4,this.getAllWindows()];case 1:return e=n.sent(),a=this.getMainWindow(),t=[],e.filter(function(n){return"queueCounter"!==n.name&&!n.name.startsWith(g.notificationGuid)}).forEach(function(e){t.push(new Promise(function(r,s){return p(o,void 0,void 0,function(){var o,i;return d(this,function(n){switch(n.label){case 0:return[4,e.getState()];case 1:return o=n.sent(),(i=e.innerWindow).getBounds(function(t){i.getOptions(function(e){delete e.show,i.getGroup(function(n){u.windows.push({name:i.name,id:i.name,url:i.getNativeWindow()?i.getNativeWindow().location.toString():e.url,main:a&&a.name===i.name,options:e,state:o,bounds:{x:t.left,y:t.top,width:t.width,height:t.height},group:n.map(function(n){return n.name})}),r()},s)},s)},s),[2]}})})}))}),Promise.all(t).then(function(){o.saveLayoutToStorage(s,u),i(u)}).catch(function(n){return r(n)}),[2]}})})})},g.trayIconMenuLeftOffset=4,g.trayIconMenuTopOffset=23,g.notificationGuid="A21B62E0-16B1-4B10-8BE3-BBB6B489D862",g.replaceNotificationApi=!0,g.windowOptionsMap={x:{target:"defaultLeft"},y:{target:"defaultTop"},height:{target:"defaultHeight"},width:{target:"defaultWidth"},taskbar:{target:"showTaskbarIcon"},center:{target:"defaultCentered"},show:{target:"autoShow"}},g.notificationOptionsMap={body:{target:"message"}},g.menuHtml='<html>\n <head>\n <style>\n body:before, body:after {\n position: fixed;\n background: silver;\n }\n body {\n margin: 0px;\n overflow: hidden;\n }\n .context-menu {\n list-style: none;\n padding: 1px 0 1px 0;\n }\n .context-menu-item {\n display: block;\n cursor: default;\n font-family: Arial, Helvetica, sans-serif;\n font-size: 9pt;\n margin-bottom: 2px;\n padding: 4px 0 4px 4px;\n white-space: nowrap;\n }\n .context-menu-item span {\n display: inline-block;\n min-width: 20px;\n }\n .context-menu-item:last-child {\n margin-bottom: 0;\n } \n .context-menu-item:hover {\n color: #fff;\n background-color: #0066aa;\n }\n .context-menu-image {\n width: 16px;\n height: 16px;\n margin-top: -1px;\n margin-right: 4px;\n } \n </style>\n <script>\n document.addEventListener(\'keydown\', (event) => {\n if (event.keyCode == 27) {\n window.close();\n }\n }, false);\n <\/script>\n </head>\n <body>\n <ul class="context-menu" id="contextMenu"></ul>\n </body>\n </html>',g}(e),J=function(){function n(n){this.desktop=n}return n.prototype.createDisplay=function(n){var e=new u;return e.id=n.name,e.scaleFactor=n.deviceScaleFactor,e.bounds=new w(n.monitorRect.left,n.monitorRect.top,n.monitorRect.right-n.monitorRect.left,n.monitorRect.bottom-n.monitorRect.top),e.workArea=new w(n.availableRect.left,n.availableRect.top,n.availableRect.right-n.availableRect.left,n.availableRect.bottom-n.availableRect.top),e},n.prototype.getPrimaryDisplay=function(){var t=this;return new Promise(function(e,n){t.desktop.System.getMonitorInfo(function(n){e(t.createDisplay(n.primaryMonitor))},n)})},n.prototype.getAllDisplays=function(){var t=this;return new Promise(function(e,n){t.desktop.System.getMonitorInfo(function(n){e([n.primaryMonitor].concat(n.nonPrimaryMonitors).map(t.createDisplay))},n)})},n.prototype.getMousePosition=function(){var t=this;return new Promise(function(e,n){t.desktop.System.getMousePosition(function(n){e({x:n.left,y:n.top})},n)})},n}(),F=Object.freeze({OpenFinContainerWindow:K,OpenFinMessageBus:H,OpenFinContainer:D});return function(){function n(){}return Object.defineProperty(n,"version",{get:function(){return"2.6.0"},enumerable:!0,configurable:!0}),Object.defineProperty(n,"Container",{get:function(){return f},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ContainerWindow",{get:function(){return l},enumerable:!0,configurable:!0}),Object.defineProperty(n,"registerContainer",{get:function(){return L},enumerable:!0,configurable:!0}),Object.defineProperty(n,"resolveContainer",{get:function(){return A},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ContainerNotification",{get:function(){return E},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ObjectTransform",{get:function(){return y},enumerable:!0,configurable:!0}),Object.defineProperty(n,"Default",{get:function(){return M},enumerable:!0,configurable:!0}),Object.defineProperty(n,"Electron",{get:function(){return R},enumerable:!0,configurable:!0}),Object.defineProperty(n,"OpenFin",{get:function(){return F},enumerable:!0,configurable:!0}),Object.defineProperty(n,"WindowStateTracking",{get:function(){return t},enumerable:!0,configurable:!0}),Object.defineProperty(n,"GroupWindowManager",{get:function(){return r},enumerable:!0,configurable:!0}),Object.defineProperty(n,"SnapAssistWindowManager",{get:function(){return a},enumerable:!0,configurable:!0}),Object.defineProperty(n,"MessageBusSubscription",{get:function(){return v},enumerable:!0,configurable:!0}),Object.defineProperty(n,"MessageBusOptions",{get:function(){return b},enumerable:!0,configurable:!0}),n}()});
//# sourceMappingURL=desktop.min.js.map

@@ -282,2 +282,6 @@ // Generated by dts-bundle v0.7.3

abstract getOptions(): Promise<any>;
/** Retrieves custom window state from underlying native window by invoking 'window.getState()' if defined. */
getState(): Promise<any>;
/** Provide custom window state to underlying native window by invoking 'window.setState()' if defined */
setState(state: any): Promise<void>;
/** Gets the underlying native JavaScript window object. As some containers

@@ -368,2 +372,3 @@ * do not support native access, check for undefined.

options?: any;
state?: any;
url?: string;

@@ -473,2 +478,4 @@ main?: boolean;

getOptions(): Promise<any>;
getState(): Promise<any>;
setState(state: any): Promise<void>;
protected attachListener(eventName: string, listener: (...args: any[]) => void): void;

@@ -539,2 +546,4 @@ protected detachListener(eventName: string, listener: (...args: any[]) => void): void;

getOptions(): Promise<any>;
getState(): Promise<any>;
setState(state: any): Promise<void>;
protected attachListener(eventName: string, listener: (...args: any[]) => void): void;

@@ -624,2 +633,4 @@ protected detachListener(eventName: string, listener: (...args: any[]) => void): void;

getOptions(): Promise<any>;
getState(): Promise<any>;
setState(state: any): Promise<void>;
protected attachListener(eventName: string, listener: (...args: any[]) => void): void;

@@ -626,0 +637,0 @@ protected wrapListener(eventName: string, listener: (event: EventArgs) => void): (event: EventArgs) => void;

@@ -5,3 +5,3 @@ {

"description": "Library for abstracting common container hosting",
"version": "2.5.0",
"version": "2.6.0",
"publishConfig": {

@@ -57,3 +57,3 @@ "access": "public"

"rollup-plugin-replace": "^2.0.0",
"rollup-plugin-typescript": "^0.8.1",
"rollup-plugin-typescript": "^1.0.0",
"run-sequence": "^2.2.0",

@@ -64,3 +64,3 @@ "tslib": "^1.9.3",

"tsutils": "^3.0.0",
"typedoc": "^0.12.0",
"typedoc": "^0.13.0",
"typescript": "^3.0.1"

@@ -67,0 +67,0 @@ },

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc