@interopio/workspaces-api 3.4.4 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/changelog.md CHANGED
@@ -1,3 +1,7 @@
1
+ 3.5.1
2
+ chore: Added the defaults in the WorkspaceConfig interface
3
+ 3.5.0
4
+ chore: io.CB 3.5 bump
1
5
  3.4.3
2
6
  feat: Enable Workspaces API for Node.js
3
7
  3.4.0
@@ -4902,7 +4902,7 @@ class IoC {
4902
4902
  }
4903
4903
  }
4904
4904
 
4905
- var version = "3.4.4";
4905
+ var version = "3.5.1";
4906
4906
 
4907
4907
  const composeAPI = (glue, ioc) => {
4908
4908
  const controller = ioc.controller;
@@ -4908,7 +4908,7 @@
4908
4908
  }
4909
4909
  }
4910
4910
 
4911
- var version = "3.4.4";
4911
+ var version = "3.5.1";
4912
4912
 
4913
4913
  const composeAPI = (glue, ioc) => {
4914
4914
  const controller = ioc.controller;
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).workspaces=e.workspaces||{},e.workspaces.min=t())}(this,(function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function t(e){if(e&&e.errorHandling&&"function"!=typeof e.errorHandling&&"log"!==e.errorHandling&&"silent"!==e.errorHandling&&"throw"!==e.errorHandling)throw new Error('Invalid options passed to createRegistry. Prop errorHandling should be ["log" | "silent" | "throw" | (err) => void], but '+typeof e.errorHandling+" was passed");var t=e&&"function"==typeof e.errorHandling&&e.errorHandling,r={};function o(r,o){var n=r instanceof Error?r:new Error(r);if(t)t(n);else{var i='[ERROR] callback-registry: User callback for key "'+o+'" failed: '+n.stack;if(e)switch(e.errorHandling){case"log":return console.error(i);case"silent":return;case"throw":throw new Error(i)}console.error(i)}}return{add:function(e,t,n){var i=r[e];return i||(i=[],r[e]=i),i.push(t),n&&setTimeout((function(){n.forEach((function(n){var i;if(null===(i=r[e])||void 0===i?void 0:i.includes(t))try{Array.isArray(n)?t.apply(void 0,n):t.apply(void 0,[n])}catch(t){o(t,e)}}))}),0),function(){var o=r[e];o&&(0===(o=o.reduce((function(e,r,o){return r===t&&e.length===o||e.push(r),e}),[])).length?delete r[e]:r[e]=o)}},execute:function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var i=r[e];if(!i||0===i.length)return[];var a=[];return i.forEach((function(r){try{var n=r.apply(void 0,t);a.push(n)}catch(t){a.push(void 0),o(t,e)}})),a},clear:function(){r={}},clearKey:function(e){r[e]&&delete r[e]}}}t.default=t;var r=e(t),o=function(e){return{ok:!0,result:e}},n=function(e){return{ok:!1,error:e}},i=function(e,t,r){return!1===t.ok?t:!1===r.ok?r:o(e(t.result,r.result))},a=function(e,t){return!0===t.ok?t:n(e(t.error))},s=function(){return s=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},s.apply(this,arguments)};function c(e,t){if(e===t)return!0;if(null===e&&null===t)return!0;if(typeof e!=typeof t)return!1;if("object"==typeof e){if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!c(e[r],t[r]))return!1;return!0}var o=Object.keys(e);if(o.length!==Object.keys(t).length)return!1;for(r=0;r<o.length;r++){if(!t.hasOwnProperty(o[r]))return!1;if(!c(e[o[r]],t[o[r]]))return!1}return!0}}var d=function(e){return Array.isArray(e)},l=function(e){return"object"==typeof e&&null!==e&&!d(e)},h=function(e,t){return"expected "+e+", got "+function(e){switch(typeof e){case"string":return"a string";case"number":return"a number";case"boolean":return"a boolean";case"undefined":return"undefined";case"object":return e instanceof Array?"an array":null===e?"null":"an object";default:return JSON.stringify(e)}}(t)},u=function(e){return e.map((function(e){return"string"==typeof e?"."+e:"["+e+"]"})).join("")},p=function(e,t){var r=t.at,o=function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r}(t,["at"]);return s({at:e+(r||"")},o)},w=function(){function e(t){var r=this;this.decode=t,this.run=function(e){return a((function(t){return{kind:"DecoderError",input:e,at:"input"+(t.at||""),message:t.message||""}}),r.decode(e))},this.runPromise=function(e){return!0===(t=r.run(e)).ok?Promise.resolve(t.result):Promise.reject(t.error);var t},this.runWithException=function(e){return function(e){if(!0===e.ok)return e.result;throw e.error}(r.run(e))},this.map=function(t){return new e((function(e){return function(e,t){return!0===t.ok?o(e(t.result)):t}(t,r.decode(e))}))},this.andThen=function(t){return new e((function(e){return function(e,t){return!0===t.ok?e(t.result):t}((function(r){return t(r).decode(e)}),r.decode(e))}))},this.where=function(t,o){return r.andThen((function(r){return t(r)?e.succeed(r):e.fail(o)}))}}return e.string=function(){return new e((function(e){return"string"==typeof e?o(e):n({message:h("a string",e)})}))},e.number=function(){return new e((function(e){return"number"==typeof e?o(e):n({message:h("a number",e)})}))},e.boolean=function(){return new e((function(e){return"boolean"==typeof e?o(e):n({message:h("a boolean",e)})}))},e.constant=function(t){return new e((function(e){return c(e,t)?o(t):n({message:"expected "+JSON.stringify(t)+", got "+JSON.stringify(e)})}))},e.object=function(t){return new e((function(e){if(l(e)&&t){var r={};for(var i in t)if(t.hasOwnProperty(i)){var a=t[i].decode(e[i]);if(!0!==a.ok)return void 0===e[i]?n({message:"the key '"+i+"' is required but was not present"}):n(p("."+i,a.error));void 0!==a.result&&(r[i]=a.result)}return o(r)}return l(e)?o(e):n({message:h("an object",e)})}))},e.array=function(t){return new e((function(e){if(d(e)&&t){return e.reduce((function(e,r,o){return i((function(e,t){return e.concat([t])}),e,function(e,r){return a((function(e){return p("["+r+"]",e)}),t.decode(e))}(r,o))}),o([]))}return d(e)?o(e):n({message:h("an array",e)})}))},e.tuple=function(t){return new e((function(e){if(d(e)){if(e.length!==t.length)return n({message:"expected a tuple of length "+t.length+", got one of length "+e.length});for(var r=[],i=0;i<t.length;i++){var a=t[i].decode(e[i]);if(!a.ok)return n(p("["+i+"]",a.error));r[i]=a.result}return o(r)}return n({message:h("a tuple of length "+t.length,e)})}))},e.union=function(t,r){for(var o=[],n=2;n<arguments.length;n++)o[n-2]=arguments[n];return e.oneOf.apply(e,[t,r].concat(o))},e.intersection=function(t,r){for(var n=[],a=2;a<arguments.length;a++)n[a-2]=arguments[a];return new e((function(e){return[t,r].concat(n).reduce((function(t,r){return i(Object.assign,t,r.decode(e))}),o({}))}))},e.anyJson=function(){return new e((function(e){return o(e)}))},e.unknownJson=function(){return new e((function(e){return o(e)}))},e.dict=function(t){return new e((function(e){if(l(e)){var r={};for(var i in e)if(e.hasOwnProperty(i)){var a=t.decode(e[i]);if(!0!==a.ok)return n(p("."+i,a.error));r[i]=a.result}return o(r)}return n({message:h("an object",e)})}))},e.optional=function(t){return new e((function(e){return null==e?o(void 0):t.decode(e)}))},e.oneOf=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return new e((function(e){for(var r=[],o=0;o<t.length;o++){var i=t[o].decode(e);if(!0===i.ok)return i;r[o]=i.error}var a=r.map((function(e){return"at error"+(e.at||"")+": "+e.message})).join('", "');return n({message:'expected a value matching one of the decoders, got the errors ["'+a+'"]'})}))},e.withDefault=function(t,r){return new e((function(e){return o(function(e,t){return!0===t.ok?t.result:e}(t,r.decode(e)))}))},e.valueAt=function(t,r){return new e((function(e){for(var o=e,i=0;i<t.length;i++){if(void 0===o)return n({at:u(t.slice(0,i+1)),message:"path does not exist"});if("string"==typeof t[i]&&!l(o))return n({at:u(t.slice(0,i+1)),message:h("an object",o)});if("number"==typeof t[i]&&!d(o))return n({at:u(t.slice(0,i+1)),message:h("an array",o)});o=o[t[i]]}return a((function(e){return void 0===o?{at:u(t),message:"path does not exist"}:p(u(t),e)}),r.decode(o))}))},e.succeed=function(t){return new e((function(e){return o(t)}))},e.fail=function(t){return new e((function(e){return n({message:t})}))},e.lazy=function(t){return new e((function(e){return t().decode(e)}))},e}(),m=w.string,g=w.number,f=w.boolean,y=w.anyJson;w.unknownJson;var k=w.constant,b=w.object,W=w.array;w.tuple,w.dict;var I=w.optional,x=w.oneOf;w.union;var S=w.intersection;w.withDefault,w.valueAt,w.succeed,w.fail;var D=w.lazy;const v=m().where((e=>e.length>0),"Expected a non-empty string"),C=g().where((e=>e>=0),"Expected a non-negative number"),E=g().where((e=>e>0),"Expected a positive number"),B=b({inWorkspace:f()}),T=x(k("workspace"),k("row"),k("column"),k("group")),M=x(k("row"),k("column"),k("group")),R=x(k("maximized"),k("minimized"),k("normal")),A=x(k("workspace")),L=(e,t)=>{const r=typeof e;if(t&&"function"!==r&&"undefined"!==r)throw new Error(`Provided argument must be either undefined or of type function, provided: ${r}`);if(!t&&"function"!==r)throw new Error(`Provided argument must be of type function, provided: ${r}`)},P=I(b({saveLayout:I(f())})),F=b({name:v}),z=b({minWidth:I(g()),maxWidth:I(g()),minHeight:I(g()),maxHeight:I(g()),allowExtract:I(f()),allowReorder:I(f()),showCloseButton:I(f())}),H=b({minWidth:I(g()),maxWidth:I(g()),minHeight:I(g()),maxHeight:I(g()),allowExtract:I(f()),allowReorder:I(f()),allowDrop:I(f()),allowDropHeader:I(f()),allowDropLeft:I(f()),allowDropRight:I(f()),allowDropTop:I(f()),allowDropBottom:I(f()),showMaximizeButton:I(f()),showEjectButton:I(f()),showAddWindowButton:I(f())}),$=b({minHeight:I(g()),maxHeight:I(g()),allowDrop:I(f()),allowSplitters:I(f()),isPinned:I(f()),maximizationBoundary:I(f())}),O=b({minWidth:I(g()),maxWidth:I(g()),allowDrop:I(f()),allowSplitters:I(f()),isPinned:I(f()),maximizationBoundary:I(f())}),_=b({type:I(k("window")),appName:I(v),windowId:I(v),context:I(y()),config:I(z)}),j=b({type:k("window"),appName:I(v),windowId:I(v),context:I(y()),config:I(z)}),G=I(b({type:I(M),children:I(D((()=>W(x(_,G))))),config:I(y())})),N=b({type:k("column"),children:I(D((()=>W(x(j,K))))),config:I(O)}),J=b({type:k("row"),children:I(D((()=>W(x(j,K))))),config:I($)}),U=b({type:k("group"),children:I(D((()=>W(x(j,K))))),config:I(H)}),K=x(U,N,J);x(m().where((e=>"maximized"===e.toLowerCase()),"Expected a case insensitive variation of 'maximized'"),m().where((e=>"normal"===e.toLowerCase()),"Expected a case insensitive variation of 'normal'"));const q=b({bounds:I(b({left:I(g()),top:I(g()),width:I(C),height:I(C)})),frameId:I(v)}),Q=x(k("direct"),k("delayed"),k("lazy")),V=I(b({app:I(v),context:I(y()),loadingStrategy:I(Q),title:I(v),reuseWorkspaceId:I(v),frameId:I(v),applicationName:I(v),lockdown:I(f()),activateFrame:I(f()),newFrame:I(x(q,f())),noTabHeader:I(f()),inMemoryLayout:I(f()),icon:I(v),isPinned:I(f()),isSelected:I(f()),positionIndex:I(C),allowSystemHibernation:I(f())})),X=b({name:v,restoreOptions:I(V)}),Y=b({children:I(W(x(_,K))),context:I(y()),config:I(b({title:I(v),position:I(C),isFocused:I(f()),noTabHeader:I(f()),reuseWorkspaceId:I(v),loadingStrategy:I(Q),allowDrop:I(f()),allowDropLeft:I(f()),allowDropTop:I(f()),allowDropRight:I(f()),allowDropBottom:I(f()),allowSystemHibernation:I(f()),allowExtract:I(f()),allowWindowReorder:I(f()),showSaveButton:I(f()),allowWorkspaceTabReorder:I(f()),allowWorkspaceTabExtract:I(f()),showCloseButton:I(f()),allowSplitters:I(f()),showWindowCloseButtons:I(f()),showEjectButtons:I(f()),showAddWindowButtons:I(f()),icon:I(v),isPinned:I(f()),isSelected:I(f()),positionIndex:I(C)})),frame:I(b({activate:I(f()),reuseFrameId:I(v),applicationName:I(v),newFrame:I(x(f(),q))}))}),Z=b({workspaceId:v}),ee=b({name:v,restoreOptions:I(V)}),te=I(b({applicationName:I(m()),frameConfig:I(q),context:I(b()),layoutComponentId:I(v)})),re=b({workspaces:W(x(I(Y),I(ee)))}),oe=b({frameId:v,workspaces:W(x(Y,ee))}),ne=b({type:T,definition:I(x(Y,G))}),ie=S(Y,b({saveConfig:I(b({saveLayout:I(f())}))})),ae=b({itemId:v}),se=b({context:I(b())}),ce=b({id:v,isFocused:I(f()),isInitialized:I(f()),initializationContext:I(se)});b({type:M,id:v,frameId:v,workspaceId:v,positionIndex:g()});const de=x(k("frame"),k("workspace"),k("container"),k("window")),le=b({type:de,branch:v}),he=x(k("opened"),k("closing"),k("closed"),k("focus"),k("added"),k("loaded"),k("removed"),k("childrenUpdate"),k("containerChange"),k("maximized"),k("restored"),k("minimized"),k("normal"),k("selected"),k("lock-configuration-changed"),k("hibernated"),k("resumed")),ue=b({frameId:v,title:v,positionIndex:C,name:v,layoutName:I(v),isHibernated:I(f()),isSelected:I(f()),allowDrop:I(f()),allowSystemHibernation:I(f()),allowExtract:I(f()),allowWindowReorder:I(f()),allowSplitters:I(f()),showCloseButton:I(f()),showSaveButton:I(f()),allowWorkspaceTabReorder:I(f()),allowWorkspaceTabExtract:I(f()),allowDropLeft:I(f()),allowDropTop:I(f()),allowDropRight:I(f()),allowDropBottom:I(f()),minWidth:I(g()),maxWidth:I(g()),minHeight:I(g()),maxHeight:I(g()),showAddWindowButtons:I(f()),showEjectButtons:I(f()),showWindowCloseButtons:I(f()),widthInPx:I(g()),heightInPx:I(g()),isPinned:I(f())}),pe=b({frameId:v,workspaceId:v,positionIndex:g(),minWidth:I(g()),maxWidth:I(g()),minHeight:I(g()),maxHeight:I(g())}),we=y(),me=S(pe,b({windowId:I(v),isMaximized:I(f()),isFocused:f(),isSelected:I(f()),title:I(m()),appName:I(v),allowExtract:I(f()),allowReorder:I(f()),showCloseButton:I(f()),minWidth:I(g()),minHeight:I(g()),maxWidth:I(g()),maxHeight:I(g()),widthInPx:I(g()),heightInPx:I(g()),context:I(y())})),ge=b({id:I(v),config:we,children:I(D((()=>W(ye)))),type:x(k("row"),k("column"),k("group"))}),fe=b({id:I(v),config:me,type:k("window")}),ye=x(fe,ge),ke=b({id:v,config:ue,children:W(ye),frameSummary:ce,context:I(y())}),be=b({type:k("window"),config:b({appName:v,windowId:I(v),context:I(y()),url:I(v),title:I(m()),allowExtract:I(f()),allowReorder:I(f()),showCloseButton:I(f()),minWidth:I(g()),minHeight:I(g()),maxWidth:I(g()),maxHeight:I(g()),isMaximized:I(f())})}),We=b({type:k("group"),config:y(),children:W(x(be))}),Ie=b({type:k("column"),config:y(),children:W(x(We,be,D((()=>Ie)),D((()=>xe))))}),xe=b({type:k("row"),config:y(),children:W(x(Ie,We,be,D((()=>xe))))}),Se=b({name:v,type:k("Workspace"),metadata:I(y()),components:W(b({type:k("Workspace"),application:I(m()),state:b({config:y(),context:y(),children:W(x(xe,Ie,We,be))})}))}),De=b({layout:Se,mode:x(k("replace"),k("merge"))}),ve=b({layouts:W(Se),mode:x(k("replace"),k("merge"))}),Ce=b({layouts:W(Se)}),Ee=b({id:v,isFocused:I(f()),isInitialized:I(f()),initializationContext:I(se)}),Be=b({summaries:W(Ee)}),Te=b({id:v,config:ue}),Me=b({summaries:W(Te)}),Re=b({id:v,config:y(),workspaces:W(ke)}),Ae=b({name:v,applicationName:I(m())}),Le=b({summaries:W(Ae)}),Pe=b({windowId:v}),Fe=y(),ze=b({state:R}),He=b({top:g(),left:g(),width:C,height:C}),$e=b({bounds:He}),Oe=b({icon:I(v)}),_e=b({id:I(v)}),je=b({isSupported:f()}),Ge=b({width:I(E),height:I(E),relative:I(f())}),Ne=b({top:I(g()),left:I(g()),relative:I(f())}),Je=b({itemId:v}),Ue=b({itemId:v,excludeIds:I(f())}),Ke=b({frameId:v,requestedState:R}),qe=b({itemId:v,title:v}),Qe=b({itemId:v,containerId:v}),Ve=S(Je,Ge),Xe=b({itemId:v,enabled:f()}),Ye=S(Je,Ne);b({id:v,type:M});const Ze=b({definition:_,parentId:v,parentType:T}),et=b({definition:K,parentId:v,parentType:T}),tt=b({itemId:v,windowId:I(v)}),rt=b({live:f()}),ot=b({type:x(k("row"),k("column")),workspaceId:v}),nt=b({type:x(k("row"),k("column")),itemId:v}),it=b({itemId:v,config:we}),at=b({frameSummary:ce,frameBounds:I(He)}),st=b({workspaceSummary:Te,frameSummary:ce,workspaceSnapshot:I(ke),frameBounds:I(He)}),ct=b({containerSummary:it}),dt=b({windowSummary:b({itemId:v,parentId:v,config:me})}),lt=b({name:v,workspaceId:v,saveContext:I(f()),metadata:I(b())}),ht=b({allowDrop:I(f()),allowDropLeft:I(f()),allowDropTop:I(f()),allowDropRight:I(f()),allowDropBottom:I(f()),allowSystemHibernation:I(f()),allowExtract:I(f()),allowWindowReorder:I(f()),allowSplitters:I(f()),showCloseButton:I(f()),showSaveButton:I(f()),allowWorkspaceTabReorder:I(f()),allowWorkspaceTabExtract:I(f()),showWindowCloseButtons:I(f()),showAddWindowButtons:I(f()),showEjectButtons:I(f())}),ut=b({workspaceId:v,config:I(ht)}),pt=b({allowExtract:I(f()),allowReorder:I(f()),showCloseButton:I(f())}),wt=b({width:I(C),height:I(C)}),mt=b({windowPlacementId:v,config:I(pt)}),gt=b({allowDrop:I(f()),allowSplitters:I(f())}),ft=b({allowDrop:I(f()),allowSplitters:I(f())}),yt=b({allowExtract:I(f()),allowReorder:I(f()),allowDrop:I(f()),allowDropLeft:I(f()),allowDropRight:I(f()),allowDropTop:I(f()),allowDropBottom:I(f()),allowDropHeader:I(f()),showMaximizeButton:I(f()),showEjectButton:I(f()),showAddWindowButton:I(f())}),kt=b({itemId:v,type:k("row"),config:I(gt)}),bt=b({itemId:v,type:k("column"),config:I(ft)}),Wt=b({itemId:v,type:k("group"),config:I(yt)}),It=x(kt,bt,Wt),xt=b({workspaceId:v,icon:I(v)}),St=b({workspaceId:v,icon:I(v)}),Dt=I(b({icon:I(v)})),vt=b({shortcut:v,frameId:v}),Ct=b({shortcut:v,frameId:v}),Et=b({enabled:f()}),Bt=b({itemId:v,type:A}),Tt=b({operation:v}),Mt="T42.Web.Platform.Control",Rt="T42.Web.Platform.WSP.Stream",At={control:{name:"T42.Workspaces.Control",isStream:!1},frameStream:{name:"T42.Workspaces.Stream.Frame",isStream:!0},workspaceStream:{name:"T42.Workspaces.Stream.Workspace",isStream:!0},containerStream:{name:"T42.Workspaces.Stream.Container",isStream:!0},windowStream:{name:"T42.Workspaces.Stream.Window",isStream:!0}},Lt={control:{name:"T42.Workspaces.Client.Control",isStream:!1}},Pt={frame:{name:"T42.Workspaces.Stream.Frame",payloadDecoder:at},workspace:{name:"T42.Workspaces.Stream.Workspace",payloadDecoder:st},container:{name:"T42.Workspaces.Stream.Container",payloadDecoder:ct},window:{name:"T42.Workspaces.Stream.Window",payloadDecoder:dt}},Ft={shortcutClicked:{name:"shortcutClicked",argsDecoder:Ct,resultDecoder:Fe}},zt={ping:{name:"ping",resultDecoder:rt},isWindowInWorkspace:{name:"isWindowInWorkspace",argsDecoder:Je,resultDecoder:B},createWorkspace:{name:"createWorkspace",resultDecoder:ke,argsDecoder:ie},createFrame:{name:"createFrame",resultDecoder:Ee,argsDecoder:te},initFrame:{name:"initFrame",resultDecoder:Fe,argsDecoder:oe},getAllFramesSummaries:{name:"getAllFramesSummaries",resultDecoder:Be},getFrameSummary:{name:"getFrameSummary",resultDecoder:ce,argsDecoder:ae},getAllWorkspacesSummaries:{name:"getAllWorkspacesSummaries",resultDecoder:Me},getWorkspaceSnapshot:{name:"getWorkspaceSnapshot",resultDecoder:ke,argsDecoder:Je},getAllLayoutsSummaries:{name:"getAllLayoutsSummaries",resultDecoder:Le},openWorkspace:{name:"openWorkspace",argsDecoder:X,resultDecoder:ke},deleteLayout:{name:"deleteLayout",resultDecoder:Fe,argsDecoder:F},saveLayout:{name:"saveLayout",resultDecoder:Se,argsDecoder:lt},importLayout:{name:"importLayout",resultDecoder:Fe,argsDecoder:De},importLayouts:{name:"importLayouts",resultDecoder:Fe,argsDecoder:ve},exportAllLayouts:{name:"exportAllLayouts",resultDecoder:Ce},restoreItem:{name:"restoreItem",argsDecoder:Je,resultDecoder:Fe},maximizeItem:{name:"maximizeItem",argsDecoder:Je,resultDecoder:Fe},focusItem:{name:"focusItem",argsDecoder:Je,resultDecoder:Fe},closeItem:{name:"closeItem",argsDecoder:Je,resultDecoder:Fe},resizeItem:{name:"resizeItem",argsDecoder:Ve,resultDecoder:Fe},setMaximizationBoundary:{name:"setMaximizationBoundary",argsDecoder:Xe,resultDecoder:Fe},changeFrameState:{name:"changeFrameState",argsDecoder:Ke,resultDecoder:Fe},getFrameState:{name:"getFrameState",argsDecoder:Je,resultDecoder:ze},getFrameBounds:{name:"getFrameBounds",argsDecoder:Je,resultDecoder:$e},moveFrame:{name:"moveFrame",argsDecoder:Ye,resultDecoder:Fe},getFrameSnapshot:{name:"getFrameSnapshot",argsDecoder:Ue,resultDecoder:Re},forceLoadWindow:{name:"forceLoadWindow",argsDecoder:Je,resultDecoder:Pe},ejectWindow:{name:"ejectWindow",argsDecoder:Je,resultDecoder:Pe},setItemTitle:{name:"setItemTitle",argsDecoder:qe,resultDecoder:Fe},moveWindowTo:{name:"moveWindowTo",argsDecoder:Qe,resultDecoder:Fe},addWindow:{name:"addWindow",argsDecoder:Ze,resultDecoder:tt},addContainer:{name:"addContainer",argsDecoder:et,resultDecoder:tt},bundleWorkspace:{name:"bundleWorkspace",argsDecoder:ot,resultDecoder:Fe},bundleItem:{name:"bundleItem",argsDecoder:nt,resultDecoder:Fe},hibernateWorkspace:{name:"hibernateWorkspace",argsDecoder:Z,resultDecoder:Fe},resumeWorkspace:{name:"resumeWorkspace",argsDecoder:Z,resultDecoder:Fe},lockWorkspace:{name:"lockWorkspace",argsDecoder:ut,resultDecoder:Fe},lockWindow:{name:"lockWindow",argsDecoder:mt,resultDecoder:Fe},lockContainer:{name:"lockContainer",argsDecoder:It,resultDecoder:Fe},pinWorkspace:{name:"pinWorkspace",argsDecoder:xt,resultDecoder:Fe},unpinWorkspace:{name:"unpinWorkspace",argsDecoder:Z,resultDecoder:Fe},getWorkspaceIcon:{name:"getWorkspaceIcon",argsDecoder:Z,resultDecoder:Oe},setWorkspaceIcon:{name:"setWorkspaceIcon",argsDecoder:St,resultDecoder:Fe},registerShortcut:{name:"registerShortcut",argsDecoder:vt,resultDecoder:Fe},unregisterShortcut:{name:"unregisterShortcut",argsDecoder:vt,resultDecoder:Fe},showLoadingAnimation:{name:"showLoadingAnimation",argsDecoder:Bt,resultDecoder:Fe},hideLoadingAnimation:{name:"hideLoadingAnimation",argsDecoder:Bt,resultDecoder:Fe},getPlatformFrameId:{name:"getPlatformFrameId",resultDecoder:_e},operationCheck:{name:"operationCheck",argsDecoder:Tt,resultDecoder:je}};class Ht{resolve;reject;promise;constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class $t{transport;registry;activeSubscriptions=[];pendingSubScriptions=[];constructor(e,t){this.transport=e,this.registry=t}async createCoreEventSubscription(){await this.transport.coreSubscriptionReady(this.handleCoreEvent.bind(this))}handleCoreSubscription(e){const t=`${e.eventType}-${e.action}`,r=e.scope,o=e.scopeId;return this.registry.add(t,(t=>{const n={type:r,id:o},i={frame:t.frameSummary?.id||t.windowSummary?.config.frameId,workspace:t.workspaceSummary?.id||t.windowSummary?.config.workspaceId,container:t.containerSummary?.itemId,window:t.windowSummary?.itemId};this.checkScopeMatch(n,i)&&e.callback(t)}))}async send(e,t){const r=Object.values(zt).find((t=>t.name===e));if(!r)throw new Error(`Cannot find definition for operation name: ${e}`);if(r.argsDecoder)try{r.argsDecoder.runWithException(t)}catch(t){throw new Error(`Unexpected internal outgoing validation error: ${t.message}, for input: ${JSON.stringify(t.input)}, for operation ${e}`)}try{const e=await this.transport.transmitControl(r.name,t);return r.resultDecoder.runWithException(e),e}catch(t){if(t.kind)throw new Error(`Unexpected internal incoming validation error: ${t.message}, for input: ${JSON.stringify(t.input)}, for operation ${e}`);throw new Error(t.message)}}async subscribe(e){const t=this.getPendingSubscription(e);t&&await t.promise;let r=this.getActiveSubscription(e);const o=this.getRegistryKey(e);if(!r){const t=new Ht,o={streamType:e.eventType,level:e.scope,levelId:e.scopeId,promise:t.promise};this.pendingSubScriptions.push(o);try{const o=Pt[e.eventType],n=await this.transport.subscribe(o.name,this.getBranchKey(e),e.eventType);n.onData((e=>{const t=e.data,r=le.run(e.requestArguments),o=he.run(t.action);if(!r.ok||!o.ok)return;const n=r.result.type,i=`${n}-${r.result.branch}-${o.result}`,a=Pt[n].payloadDecoder.run(t.payload);a.ok&&this.registry.execute(i,a.result)})),r={streamType:e.eventType,level:e.scope,levelId:e.scopeId,callbacksCount:0,gdSub:n},this.activeSubscriptions.push(r),t.resolve()}catch(e){throw t.reject(e),e}finally{this.removePendingSubscription(o)}}const n=this.registry.add(o,e.callback);return++r.callbacksCount,()=>{n(),--r.callbacksCount,0===r.callbacksCount&&(r.gdSub.close(),this.activeSubscriptions.splice(this.activeSubscriptions.indexOf(r),1))}}onOperation(e){return this.transport.onInternalMethodInvoked("control",((t,r)=>{const o=t.operation,n=t.data,i=Object.values(Ft).find((e=>e.name===o));if(!i)throw new Error(`Cannot find definition for operation name: ${o}`);if(i.argsDecoder)try{i.argsDecoder.runWithException(n)}catch(e){throw new Error(`Unexpected internal outgoing validation error: ${e.message}, for input: ${JSON.stringify(e.input)}, for operation ${o}`)}e(t,r)}))}checkScopeMatch(e,t){return"global"===e.type||("frame"===e.type&&e.id===t.frame||("workspace"===e.type&&e.id===t.workspace||("container"===e.type&&e.id===t.container||"window"===e.type&&e.id===t.window)))}handleCoreEvent(e){const t=e.data;try{const e=he.runWithException(t.action),r=de.runWithException(t.type),o=Pt[r].payloadDecoder.runWithException(t.payload),n=`${r}-${e}`;this.registry.execute(n,o)}catch(e){console.warn(`Cannot handle event with data ${JSON.stringify(t)}, because of validation error: ${e.message}`)}}getBranchKey(e){return"global"===e.scope?e.scope:`${e.scope}_${e.scopeId}`}getRegistryKey(e){return`${e.eventType}-${this.getBranchKey(e)}-${e.action}`}getActiveSubscription(e){return this.activeSubscriptions.find((t=>t.streamType===e.eventType&&t.level===e.scope&&t.levelId===e.scopeId))}getPendingSubscription(e){return this.pendingSubScriptions.find((t=>t.streamType===e.eventType&&t.level===e.scope&&t.levelId===e.scopeId))}removePendingSubscription(e){const t=this.pendingSubScriptions.indexOf(e);t>=0&&this.pendingSubScriptions.splice(t,1)}}const Ot=()=>"undefined"==typeof window||(window.glue42gd||window.iodesktop),_t=()=>"undefined"==typeof window?null:window.glue42core||window.iobrowser;class jt{agm;registry;defaultTransportTimeout=3e4;coreEventMethodInitiated=!1;corePlatformSubPromise;constructor(e,t){this.agm=e,this.registry=t}async initiate(e){if(Ot())return await Promise.all(Object.values(At).map((e=>this.verifyMethodLive(e.name)))),void await Promise.all(Object.keys(Lt).map((e=>this.registerMethod(e))));const t=_t().communicationId;await Promise.all([this.verifyMethodLive(Mt,t),this.verifyMethodLive(Rt,t)]),await this.transmitControl("frameHello",{windowId:e})}coreSubscriptionReady(e){return this.coreEventMethodInitiated||this.subscribePlatform(e),this.corePlatformSubPromise}subscribePlatform(e){this.coreEventMethodInitiated=!0;const t=_t().communicationId;this.corePlatformSubPromise=this.agm.subscribe(Rt,t?{target:{instance:t}}:void 0),this.corePlatformSubPromise.then((t=>{t.onData((t=>e(t.data)))}))}async subscribe(e,t,r){const o={branch:t,type:r};let n;try{n=await this.agm.subscribe(e,{arguments:o})}catch(r){const o=`Internal subscription error! Error details: stream - ${e}, branch: ${t}. Internal message: ${r.message}`;throw new Error(o)}return n}async transmitControl(e,t){const r=Ot()?{operation:e,operationArguments:t}:{operation:e,domain:"workspaces",data:t},o=Ot()?At.control.name:Mt,n=Ot()?void 0:_t().communicationId;let i;const a=`Internal Workspaces Communication Error. Attempted operation: ${JSON.stringify(r)}. `;try{if(i=await this.agm.invoke(o,r,n?{instance:n}:"best",{methodResponseTimeoutMs:this.defaultTransportTimeout}),!i)throw new Error("Received unsupported result from GD - empty result");if(!Array.isArray(i.all_return_values)||0===i.all_return_values.length)throw new Error("Received unsupported result from GD - empty values collection")}catch(e){if(e&&e.all_errors&&e.all_errors.length){const t=e.all_errors[0].message;throw new Error(`${a} -> Inner message: ${t}`)}throw new Error(`${a} -> Inner message: ${e.message}`)}return i.all_return_values[0].returned}onInternalMethodInvoked(e,t){return this.registry.add(e,t)}verifyMethodLive(e,t){return r=()=>new Promise((r=>{if(this.agm.methods().some((r=>{const o=r.name===e,n=!t||r.getServers().some((e=>e.instance===t));return o&&n})))return void r();const o=this.agm.serverMethodAdded((n=>{const i=n.method,a=n.server,s=!t||a.instance===t;i.name===e&&s&&(o(),r())}))})),o=15e3,n="Timeout waiting for the Workspaces communication channels",new Promise(((e,t)=>{let i=!0;const a=setTimeout((()=>{i&&(i=!1,t(n))}),o);r().then((t=>{i&&(i=!1,clearTimeout(a),e(t))})).catch((e=>{i&&(i=!1,clearTimeout(a),t(e))}))}));var r,o,n}registerMethod(e){const t=Lt[e];return this.agm.register(t.name,((t,r)=>{this.registry.execute(e,t,r)}))}}const Gt=new WeakMap;class Nt{constructor(e,t){const r=t.wrapChildren(e.children);delete e.children,Gt.set(this,{base:t,children:r,definition:e})}get type(){return Gt.get(this).definition.type}addColumn(e){return Gt.get(this).base.add("column",Gt.get(this).children,e)}addRow(e){return Gt.get(this).base.add("row",Gt.get(this).children,e)}addGroup(e){return Gt.get(this).base.add("group",Gt.get(this).children,e)}addWindow(e){return Gt.get(this).base.addWindow(Gt.get(this).children,e),this}serialize(){const e=Gt.get(this).definition;return e.children=Gt.get(this).base.serializeChildren(Gt.get(this).children),e}}class Jt{getBuilder;constructor(e){this.getBuilder=e}wrapChildren(e){return e.map((e=>"window"===e.type?e:this.getBuilder({type:e.type,definition:e})))}add(e,t,r){const o=G.runWithException(r),n=this.getBuilder({type:e,definition:o});return t.push(n),n}addWindow(e,t){const r=_.runWithException(t);r.type="window",e.push(r)}serializeChildren(e){return e.map((e=>e instanceof Nt?e.serialize():e))}}const Ut=new WeakMap;class Kt{constructor(e,t,r){const o=t.wrapChildren(e.children);delete e.children,Ut.set(this,{base:t,children:o,definition:e,controller:r})}addColumn(e){const t=Ut.get(this).children;if(!t.every((e=>e instanceof Nt&&"column"===e.type)))throw new Error("Cannot add a column to this workspace, because there are already children of another type");return Ut.get(this).base.add("column",t,e)}addRow(e){const t=Ut.get(this).children;if(!t.every((e=>e instanceof Nt&&"row"===e.type)))throw new Error("Cannot add a row to this workspace, because there are already children of another type");return Ut.get(this).base.add("row",t,e)}addGroup(e){const t=Ut.get(this).children;if(0!==t.length)throw new Error("Cannot add a group to this workspace, because there are already defined children.");return Ut.get(this).base.add("group",t,e)}addWindow(e){const t=Ut.get(this).children;if(0!==t.length)throw new Error("Cannot add a window to this workspace, because there are already defined children.");return Ut.get(this).base.addWindow(t,e),this}getChildAt(e){C.runWithException(e);return Ut.get(this).children[e]}async create(e){const t=P.runWithException(e),r=Ut.get(this).definition;r.children=Ut.get(this).base.serializeChildren(Ut.get(this).children);return Ut.get(this).controller.createWorkspace(r,t)}}const qt=new WeakMap,Qt=e=>qt.get(e).base;class Vt{constructor(e){qt.set(this,{base:e})}get type(){return"row"}get id(){return Qt(this).getId(this)}get frameId(){return Qt(this).getFrameId(this)}get workspaceId(){return Qt(this).getWorkspaceId(this)}get positionIndex(){return Qt(this).getPositionIndex(this)}get children(){return Qt(this).getAllChildren(this)}get parent(){return Qt(this).getMyParent(this)}get frame(){return Qt(this).getMyFrame(this)}get workspace(){return Qt(this).getMyWorkspace(this)}get allowDrop(){return Qt(this).getAllowDrop(this)}get allowSplitters(){return Qt(this).getAllowSplitters(this)}get minWidth(){return Qt(this).getMinWidth(this)}get minHeight(){return Qt(this).getMinHeight(this)}get maxWidth(){return Qt(this).getMaxWidth(this)}get maxHeight(){return Qt(this).getMaxHeight(this)}get width(){return Qt(this).getWidthInPx(this)}get height(){return Qt(this).getHeightInPx(this)}get isPinned(){return Qt(this).getIsPinned(this)}get isMaximized(){return Qt(this).getIsMaximized(this)}get maximizationBoundary(){return Qt(this).getMaximizationBoundary(this)}addWindow(e){return Qt(this).addWindow(this,e,"row")}async addGroup(e){if(e?.type&&"group"!==e.type)throw new Error(`Expected a group definition, but received ${e.type}`);return Qt(this).addParent(this,"group","row",e)}async addColumn(e){if(e?.type&&"column"!==e.type)throw new Error(`Expected a column definition, but received ${e.type}`);return Qt(this).addParent(this,"column","row",e)}async addRow(){throw new Error("Adding rows as row children is not supported")}removeChild(e){return Qt(this).removeChild(this,e)}maximize(){return Qt(this).maximize(this)}restore(){return Qt(this).restore(this)}close(){return Qt(this).close(this)}lock(e){let t;if("function"==typeof e){t=e({allowDrop:this.allowDrop,allowSplitters:this.allowSplitters})}else t=e;const r=void 0===t?void 0:gt.runWithException(t);return Qt(this).lockContainer(this,r)}async setHeight(e){return C.runWithException(e),Qt(this).setHeight(this,e)}async onLockConfigurationChanged(e){L(e);const t={callback:async()=>{await this.workspace.refreshReference(),e({allowDrop:this.allowDrop,allowSplitters:this.allowSplitters})},action:"lock-configuration-changed",eventType:"container",scope:"container"};return await Qt(this).processLocalSubscription(this,t)}async setMaximizationBoundary(e){const t=Et.runWithException(e);return Qt(this).setMaximizationBoundary(this,t)}}const Xt=new WeakMap,Yt=e=>Xt.get(e).base;class Zt{constructor(e){Xt.set(this,{base:e})}get type(){return"column"}get id(){return Yt(this).getId(this)}get frameId(){return Yt(this).getFrameId(this)}get workspaceId(){return Yt(this).getWorkspaceId(this)}get positionIndex(){return Yt(this).getPositionIndex(this)}get children(){return Yt(this).getAllChildren(this)}get parent(){return Yt(this).getMyParent(this)}get frame(){return Yt(this).getMyFrame(this)}get workspace(){return Yt(this).getMyWorkspace(this)}get allowDrop(){return Yt(this).getAllowDrop(this)}get allowSplitters(){return Yt(this).getAllowSplitters(this)}get minWidth(){return Yt(this).getMinWidth(this)}get minHeight(){return Yt(this).getMinHeight(this)}get maxWidth(){return Yt(this).getMaxWidth(this)}get maxHeight(){return Yt(this).getMaxHeight(this)}get width(){return Yt(this).getWidthInPx(this)}get height(){return Yt(this).getHeightInPx(this)}get isPinned(){return Yt(this).getIsPinned(this)}get isMaximized(){return Yt(this).getIsMaximized(this)}get maximizationBoundary(){return Yt(this).getMaximizationBoundary(this)}addWindow(e){return Yt(this).addWindow(this,e,"column")}async addGroup(e){if(e?.type&&"group"!==e.type)throw new Error(`Expected a group definition, but received ${e.type}`);return Yt(this).addParent(this,"group","column",e)}async addColumn(){throw new Error("Adding columns as column children is not supported")}async addRow(e){if(e?.type&&"row"!==e.type)throw new Error(`Expected a row definition, but received ${e.type}`);return Yt(this).addParent(this,"row","column",e)}removeChild(e){return Yt(this).removeChild(this,e)}maximize(){return Yt(this).maximize(this)}restore(){return Yt(this).restore(this)}close(){return Yt(this).close(this)}lock(e){let t;if("function"==typeof e){t=e({allowDrop:this.allowDrop,allowSplitters:this.allowSplitters})}else t=e;const r=void 0===t?void 0:ft.runWithException(t);return Yt(this).lockContainer(this,r)}async setWidth(e){return C.runWithException(e),Yt(this).setWidth(this,e)}async onLockConfigurationChanged(e){L(e);const t={callback:async()=>{await this.workspace.refreshReference(),e({allowDrop:this.allowDrop,allowSplitters:this.allowSplitters})},action:"lock-configuration-changed",eventType:"container",scope:"container"};return await Yt(this).processLocalSubscription(this,t)}async setMaximizationBoundary(e){const t=Et.runWithException(e);return Yt(this).setMaximizationBoundary(this,t)}}const er=new WeakMap,tr=e=>er.get(e).base;class rr{constructor(e){er.set(this,{base:e})}get type(){return"group"}get id(){return tr(this).getId(this)}get frameId(){return tr(this).getFrameId(this)}get workspaceId(){return tr(this).getWorkspaceId(this)}get positionIndex(){return tr(this).getPositionIndex(this)}get children(){return tr(this).getAllChildren(this)}get parent(){return tr(this).getMyParent(this)}get frame(){return tr(this).getMyFrame(this)}get workspace(){return tr(this).getMyWorkspace(this)}get allowExtract(){return tr(this).getAllowExtract(this)}get allowReorder(){return tr(this).getAllowReorder(this)}get allowDropLeft(){return tr(this).getAllowDropLeft(this)}get allowDropRight(){return tr(this).getAllowDropRight(this)}get allowDropTop(){return tr(this).getAllowDropTop(this)}get allowDropBottom(){return tr(this).getAllowDropBottom(this)}get allowDropHeader(){return tr(this).getAllowDropHeader(this)}get allowDrop(){return tr(this).getAllowDrop(this)}get showMaximizeButton(){return tr(this).getShowMaximizeButton(this)}get showEjectButton(){return tr(this).getShowEjectButton(this)}get showAddWindowButton(){return tr(this).getShowAddWindowButton(this)}get minWidth(){return tr(this).getMinWidth(this)}get minHeight(){return tr(this).getMinHeight(this)}get maxWidth(){return tr(this).getMaxWidth(this)}get maxHeight(){return tr(this).getMaxHeight(this)}get width(){return tr(this).getWidthInPx(this)}get height(){return tr(this).getHeightInPx(this)}get isMaximized(){return tr(this).getIsMaximized(this)}addWindow(e){return tr(this).addWindow(this,e,"group")}async addGroup(){throw new Error("Adding groups as group child is not supported")}async addColumn(){throw new Error("Adding columns as group child is not supported")}async addRow(){throw new Error("Adding rows as group child is not supported")}removeChild(e){return tr(this).removeChild(this,e)}maximize(){return tr(this).maximize(this)}restore(){return tr(this).restore(this)}close(){return tr(this).close(this)}lock(e){let t;if("function"==typeof e){t=e({allowDrop:this.allowDrop,allowDropHeader:this.allowDropHeader,allowDropLeft:this.allowDropLeft,allowDropRight:this.allowDropRight,allowDropTop:this.allowDropTop,allowDropBottom:this.allowDropBottom,allowExtract:this.allowExtract,allowReorder:this.allowReorder,showAddWindowButton:this.showAddWindowButton,showEjectButton:this.showEjectButton,showMaximizeButton:this.showMaximizeButton})}else t=e;const r=void 0===t?void 0:yt.runWithException(t);return tr(this).lockContainer(this,r)}async setSize(e){const t=wt.runWithException(e);if(!t.width&&!t.height)throw new Error("Expected either width or height to be passed.");return tr(this).setSize(this,e.width,e.height)}async bundleToRow(){await tr(this).bundleTo(this,"row"),await this.workspace.refreshReference()}async bundleToColumn(){await tr(this).bundleTo(this,"column"),await this.workspace.refreshReference()}async onLockConfigurationChanged(e){L(e);const t={callback:async()=>{await this.workspace.refreshReference(),e({allowDrop:this.allowDrop,allowDropHeader:this.allowDropHeader,allowDropLeft:this.allowDropLeft,allowDropTop:this.allowDropTop,allowDropRight:this.allowDropRight,allowDropBottom:this.allowDropBottom,allowExtract:this.allowExtract,allowReorder:this.allowReorder,showAddWindowButton:this.showAddWindowButton,showEjectButton:this.showEjectButton,showMaximizeButton:this.showMaximizeButton})},action:"lock-configuration-changed",eventType:"container",scope:"container"};return await tr(this).processLocalSubscription(this,t)}}const or=new WeakMap,nr=e=>or.get(e).manager.getWorkspaceData(e),ir=e=>or.get(e).manager;class ar{constructor(e){or.set(this,{manager:e})}get id(){return nr(this).id}get frameId(){return nr(this).config.frameId}get positionIndex(){return nr(this).config.positionIndex}get title(){return nr(this).config.title}get layoutName(){return nr(this).config.layoutName}get isHibernated(){return nr(this).config.isHibernated}get isSelected(){return nr(this).config.isSelected}get children(){return nr(this).children}get frame(){return nr(this).frame}get allowSplitters(){return nr(this).config.allowSplitters}get allowSystemHibernation(){return nr(this).config.allowSystemHibernation}get allowDrop(){return nr(this).config.allowDrop}get allowDropLeft(){return nr(this).config.allowDropLeft}get allowDropTop(){return nr(this).config.allowDropTop}get allowDropRight(){return nr(this).config.allowDropRight}get allowDropBottom(){return nr(this).config.allowDropBottom}get allowExtract(){return nr(this).config.allowExtract}get allowWindowReorder(){return nr(this).config.allowWindowReorder}get showCloseButton(){return nr(this).config.showCloseButton}get showSaveButton(){return nr(this).config.showSaveButton}get allowWorkspaceTabReorder(){return nr(this).config.allowWorkspaceTabReorder}get allowWorkspaceTabExtract(){return nr(this).config.allowWorkspaceTabExtract}get minWidth(){return nr(this).config.minWidth}get minHeight(){return nr(this).config.minHeight}get maxWidth(){return nr(this).config.maxWidth}get maxHeight(){return nr(this).config.maxHeight}get width(){return nr(this).config.widthInPx}get height(){return nr(this).config.heightInPx}get showWindowCloseButtons(){return nr(this).config.showWindowCloseButtons}get showEjectButtons(){return nr(this).config.showEjectButtons}get showAddWindowButtons(){return nr(this).config.showAddWindowButtons}get isPinned(){return nr(this).config.isPinned}async removeChild(e){L(e);const t=this.children.find(e);t&&(await t.close(),await this.refreshReference())}async remove(e){L(e);const t=nr(this).controller.iterateFindChild(this.children,e);await t.close(),await this.refreshReference()}async focus(){await nr(this).controller.focusItem(this.id),await this.refreshReference()}async close(){const e=nr(this).controller,t=await nr(this).frame.workspaces(),r=(await e.getPlatformFrameId()).id;if(1===t.length&&t.every((e=>e.id===this.id))&&r!==this.frame.id)return this.frame.close();await e.closeItem(this.id)}snapshot(){return nr(this).controller.getSnapshot(this.id,"workspace")}async saveLayout(e,t){v.runWithException(e),await nr(this).controller.saveLayout({name:e,workspaceId:this.id,saveContext:t?.saveContext,metadata:t?.metadata})}async setTitle(e){v.runWithException(e);const t=nr(this).controller;await t.setItemTitle(this.id,e),await this.refreshReference()}getContext(){return nr(this).controller.getWorkspaceContext(this.id)}setContext(e){return nr(this).controller.setWorkspaceContext(this.id,e)}updateContext(e){return nr(this).controller.updateWorkspaceContext(this.id,e)}onContextUpdated(e){return nr(this).controller.subscribeWorkspaceContextUpdated(this.id,e)}async refreshReference(){const e=await nr(this).controller.getSnapshot(this.id,"workspace"),t=nr(this).controller.flatChildren(nr(this).children),r=nr(this).controller.refreshChildren({existingChildren:t,workspace:this,parent:this,children:e.children}),o=this.frame;let n;if(o.id===e.config.frameId)ir(this).remapFrame(o,e.frameSummary),n=o;else{const t={summary:e.frameSummary};n=nr(this).ioc.getModel("frame",t)}ir(this).remapWorkspace(this,{config:e.config,children:r,frame:n})}async getIcon(){return nr(this).controller.getWorkspaceIcon(this.id)}async setIcon(e){return nr(this).controller.setWorkspaceIcon(this.id,e)}getBox(e){L(e);const t=nr(this).children;return nr(this).controller.iterateFindChild(t,(t=>"window"!==t.type&&e(t)))}getAllBoxes(e){L(e,!0);const t=nr(this).children,r=nr(this).controller.iterateFilterChildren(t,(e=>"window"!==e.type));return e?r.filter(e):r}getRow(e){return L(e),this.getBox((t=>"row"===t.type&&e(t)))}getAllRows(e){return L(e,!0),e?this.getAllBoxes((t=>"row"===t.type&&e(t))):this.getAllBoxes((e=>"row"===e.type))}getColumn(e){return L(e),this.getBox((t=>"column"===t.type&&e(t)))}getAllColumns(e){return L(e,!0),e?this.getAllBoxes((t=>"column"===t.type&&e(t))):this.getAllBoxes((e=>"column"===e.type))}getGroup(e){return L(e),this.getBox((t=>"group"===t.type&&e(t)))}getAllGroups(e){return L(e,!0),e?this.getAllBoxes((t=>"group"===t.type&&e(t))):this.getAllBoxes((e=>"group"===e.type))}getWindow(e){L(e);const t=nr(this).children;return nr(this).controller.iterateFindChild(t,(t=>"window"===t.type&&e(t)))}getAllWindows(e){L(e,!0);const t=nr(this).children,r=nr(this).controller.iterateFilterChildren(t,(e=>"window"===e.type));return e?r.filter(e):r}addRow(e){return nr(this).base.addParent(this,"row","workspace",e)}addColumn(e){return nr(this).base.addParent(this,"column","workspace",e)}addGroup(e){return nr(this).base.addParent(this,"group","workspace",e)}addWindow(e){return nr(this).base.addWindow(this,e,"workspace")}async bundleToRow(){await nr(this).controller.bundleWorkspaceTo("row",this.id),await this.refreshReference()}async bundleToColumn(){await nr(this).controller.bundleWorkspaceTo("column",this.id),await this.refreshReference()}async hibernate(){await nr(this).controller.hibernateWorkspace(this.id),await this.refreshReference()}async resume(){await nr(this).controller.resumeWorkspace(this.id),await this.refreshReference()}async lock(e){let t;if("function"==typeof e){t=e({allowDrop:this.allowDrop,allowDropLeft:this.allowDropLeft,allowDropTop:this.allowDropTop,allowDropRight:this.allowDropRight,allowDropBottom:this.allowDropBottom,allowSystemHibernation:this.allowSystemHibernation,allowExtract:this.allowExtract,allowWindowReorder:this.allowWindowReorder,allowSplitters:this.allowSplitters,showCloseButton:this.showCloseButton,showSaveButton:this.showSaveButton,allowWorkspaceTabReorder:this.allowWorkspaceTabReorder,allowWorkspaceTabExtract:this.allowWorkspaceTabExtract,showAddWindowButtons:this.showAddWindowButtons,showEjectButtons:this.showEjectButtons,showWindowCloseButtons:this.showWindowCloseButtons})}else t=e;const r=void 0===t?void 0:ht.runWithException(t);await nr(this).controller.lockWorkspace(this.id,r),await this.refreshReference()}async pin(e){Dt.runWithException(e),await nr(this).controller.pinWorkspace(this.id,e?.icon),await this.refreshReference()}async unpin(){await nr(this).controller.unpinWorkspace(this.id),await this.refreshReference()}async showLoadingAnimation(){if(!Ot())throw new Error("Not supported in IO Connect Browser");await nr(this).controller.showWorkspaceLoadingAnimation(this.id)}async hideLoadingAnimation(){if(!Ot())throw new Error("Not supported in IO Connect Browser");await nr(this).controller.hideWorkspaceLoadingAnimation(this.id)}async onClosed(e){L(e);const t=nr(this).id,r={action:"closed",eventType:"workspace",scope:"workspace",scopeId:t,callback:async t=>{e({frameId:t.frameSummary.id,workspaceId:t.workspaceSummary.id,frameBounds:t.frameBounds})}};return await nr(this).controller.processLocalSubscription(r,t)}async onHibernated(e){L(e);const t=nr(this).id,r={action:"hibernated",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await nr(this).controller.processLocalSubscription(r,t)}async onResumed(e){L(e);const t=nr(this).id,r={action:"resumed",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await nr(this).controller.processLocalSubscription(r,t)}async onWindowAdded(e){L(e);const t=nr(this).id,r={action:"added",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const r=this.getBox((e=>e.id===t.windowSummary.parentId)).children.find((e=>"window"===e.type&&e.elementId===t.windowSummary.itemId));e(r)}};return await nr(this).controller.processLocalSubscription(r,t)}async onWindowRemoved(e){L(e);const t=nr(this).id,r={action:"removed",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const{windowId:r,workspaceId:o,frameId:n}=t.windowSummary.config;e({windowId:r,workspaceId:o,frameId:n})}};return await nr(this).controller.processLocalSubscription(r,t)}async onWindowLoaded(e){L(e);const t=nr(this).id,r={action:"loaded",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const r=this.getWindow((e=>e.id&&e.id===t.windowSummary.config.windowId));e(r)}};return await nr(this).controller.processLocalSubscription(r,t)}async onWindowMaximized(e){L(e);const t=nr(this).id,r={action:"maximized",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const r=this.getBox((e=>e.id===t.windowSummary.parentId)).children.find((e=>"window"===e.type&&e.elementId===t.windowSummary.itemId));e(r)}};return await nr(this).controller.processLocalSubscription(r,t)}async onWindowRestored(e){L(e);const t=nr(this).id,r={action:"restored",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const r=this.getBox((e=>e.id===t.windowSummary.parentId)).children.find((e=>"window"===e.type&&e.elementId===t.windowSummary.itemId));e(r)}};return await nr(this).controller.processLocalSubscription(r,t)}async onWindowSelected(e){L(e);const t=nr(this).id,r={action:"selected",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const r=this.getBox((e=>e.id===t.windowSummary.parentId)).children.find((e=>"window"===e.type&&e.elementId===t.windowSummary.itemId));e(r)}};return await nr(this).controller.processLocalSubscription(r,t)}async onLockConfigurationChanged(e){L(e);const t=nr(this).id,r={action:"lock-configuration-changed",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e({allowDrop:this.allowDrop,allowDropLeft:this.allowDropLeft,allowDropTop:this.allowDropTop,allowDropRight:this.allowDropRight,allowDropBottom:this.allowDropBottom,allowSystemHibernation:this.allowSystemHibernation,allowExtract:this.allowExtract,allowSplitters:this.allowSplitters,allowWindowReorder:this.allowWindowReorder,allowWorkspaceTabExtract:this.allowWorkspaceTabExtract,allowWorkspaceTabReorder:this.allowWorkspaceTabReorder,showAddWindowButtons:this.showAddWindowButtons,showCloseButton:this.showCloseButton,showEjectButtons:this.showEjectButtons,showSaveButton:this.showSaveButton,showWindowCloseButtons:this.showWindowCloseButtons})}};return await nr(this).controller.processLocalSubscription(r,t)}}const sr=new WeakMap,cr=e=>sr.get(e).manager.getWindowData(e);class dr{constructor(e){sr.set(this,{manager:e})}get id(){return cr(this).config.windowId}get elementId(){return cr(this).id}get type(){return"window"}get frameId(){return cr(this).frame.id}get workspaceId(){return cr(this).workspace.id}get positionIndex(){return cr(this).config.positionIndex}get isMaximized(){return cr(this).config.isMaximized}get isLoaded(){return cr(this).controller.checkIsWindowLoaded(this.id)}get isSelected(){return cr(this).config.isSelected}get focused(){return this.getGdWindow().isFocused}get title(){return cr(this).config.title}get allowExtract(){return cr(this).config.allowExtract}get allowReorder(){return cr(this).config.allowReorder}get showCloseButton(){return cr(this).config.showCloseButton}get width(){return cr(this).config.widthInPx}get height(){return cr(this).config.heightInPx}get minWidth(){return cr(this).config.minWidth}get minHeight(){return cr(this).config.minHeight}get maxWidth(){return cr(this).config.maxWidth}get maxHeight(){return cr(this).config.maxHeight}get workspace(){return cr(this).workspace}get frame(){return cr(this).frame}get parent(){return cr(this).parent}get appName(){return cr(this).config.appName}async forceLoad(){if(this.isLoaded)return;const e=cr(this).controller,t=cr(this).id,r=await e.forceLoadWindow(t);cr(this).config.windowId=r,await this.workspace.refreshReference()}async focus(){const e=cr(this).id,t=cr(this).controller;await t.focusItem(e),await this.workspace.refreshReference()}async close(){const e=cr(this).id,t=cr(this).controller;await t.closeItem(e),await cr(this).parent.removeChild((t=>t.id===e)),await this.workspace.refreshReference()}async setTitle(e){v.runWithException(e);const t=cr(this).id,r=cr(this).controller;await r.setItemTitle(t,e),await this.workspace.refreshReference()}async maximize(){const e=cr(this).id,t=cr(this).controller;await t.maximizeItem(e),await this.workspace.refreshReference()}async restore(){const e=cr(this).id,t=cr(this).controller;await t.restoreItem(e),await this.workspace.refreshReference()}async eject(){if(!this.isLoaded)throw new Error("Cannot eject this window, because it is not loaded yet");const e=cr(this).id,t=await cr(this).controller.ejectWindow(e);return cr(this).config.windowId=t,await this.workspace.refreshReference(),this.getGdWindow()}getGdWindow(){if(!this.isLoaded)throw new Error("Cannot fetch this GD window, because the window is not yet loaded");const e=cr(this).config.windowId;return cr(this).controller.getGDWindow(e)}async moveTo(e){if(!(e instanceof Vt||e instanceof Zt||e instanceof rr))throw new Error("Cannot add to the provided parent, because the provided parent is not an instance of Row, Column or Group");const t=cr(this).id,r=cr(this).controller;if(!await r.getParent((t=>t.id===e.id)))throw new Error("Cannot move the window to the selected parent, because this parent does not exist.");await r.moveWindowTo(t,e.id),await this.workspace.refreshReference()}async lock(e){let t;if("function"==typeof e){t=e({allowExtract:this.allowExtract,allowReorder:this.allowReorder,showCloseButton:this.showCloseButton})}else t=e;const r=void 0===t?void 0:pt.runWithException(t),o=cr(this).id;await cr(this).controller.lockWindow(o,r),await this.workspace.refreshReference()}async setSize(e){const t=wt.runWithException(e);if(!t.width&&!t.height)throw new Error("Expected either width or height to be passed.");const r=cr(this).id,o=cr(this).controller;await o.resizeItem(r,{height:t.height,width:t.width,relative:!1}),await this.workspace.refreshReference()}async onRemoved(e){L(e);const t=cr(this).id,r={callback:async()=>{await this.workspace.refreshReference(),e()},action:"removed",eventType:"window",scope:"window"};return await cr(this).controller.processLocalSubscription(r,t)}async onLockConfigurationChanged(e){L(e);const t=cr(this).id,r={callback:async()=>{await this.workspace.refreshReference(),e({allowExtract:this.allowExtract,allowReorder:this.allowReorder,showCloseButton:this.showCloseButton})},action:"lock-configuration-changed",eventType:"window",scope:"window"};return await cr(this).controller.processLocalSubscription(r,t)}}const lr=new WeakMap,hr=e=>lr.get(e).manager.getFrameData(e);class ur{constructor(e){lr.set(this,{manager:e})}async registerShortcut(e,t){v.runWithException(e),L(t);const r=hr(this).summary.id;return await hr(this).controller.registerShortcut(e,r,t)}get id(){return hr(this).summary.id}get isInitialized(){return hr(this).summary.isInitialized}getBounds(){const e=hr(this).summary.id;return hr(this).controller.getFrameBounds(e)}async resize(e){const t=Ge.runWithException(e),r=hr(this).summary.id;return hr(this).controller.resizeItem(r,t)}async move(e){const t=Ne.runWithException(e),r=hr(this).summary.id;return hr(this).controller.moveFrame(r,t)}focus(){const e=hr(this).summary.id;return hr(this).controller.focusItem(e)}async state(){if(!Ot())throw new Error("State operations are not supported in IO Connect Browser");const e=hr(this).summary.id;return hr(this).controller.getFrameState(e)}async minimize(){if(!Ot())throw new Error("State operations are not supported in IO Connect Browser");const e=hr(this).summary.id;return hr(this).controller.changeFrameState(e,"minimized")}async maximize(){if(!Ot())throw new Error("State operations are not supported in IO Connect Browser");const e=hr(this).summary.id;return hr(this).controller.changeFrameState(e,"maximized")}async restore(){if(!Ot())throw new Error("State operations are not supported in IO Connect Browser");const e=hr(this).summary.id;return hr(this).controller.changeFrameState(e,"normal")}close(){const e=hr(this).summary.id;return hr(this).controller.closeItem(e)}snapshot(){const e=hr(this).summary.id;return hr(this).controller.getSnapshot(e,"frame")}async workspaces(){return hr(this).controller.getWorkspacesByFrameId(this.id)}async getConstraints(){const e=hr(this).controller,t=hr(this).summary.id;return e.getFrameConstraints(t)}async restoreWorkspace(e,t){v.runWithException(e);const r=V.runWithException(t);return hr(this).controller.restoreWorkspace(e,r)}createWorkspace(e,t){const r=Y.runWithException(e),o=P.runWithException(t);return hr(this).controller.createWorkspace(r,o)}async init(e){if(re.runWithException(e),hr(this).summary.isInitialized)throw new Error("The frame has already been initialized");return hr(this).controller.initFrame(this.id,e)}async onClosed(e){L(e);const t=hr(this).summary.id,r={callback:t=>{e({frameId:t.frameSummary.id,frameBounds:t.frameBounds})},action:"closed",eventType:"frame",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onMaximized(e){L(e);const t=hr(this).summary.id,r={callback:()=>{e()},action:"maximized",eventType:"frame",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onMinimized(e){L(e);const t=hr(this).summary.id,r={callback:()=>{e()},action:"minimized",eventType:"frame",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onNormal(e){L(e);const t=hr(this).summary.id,r={callback:()=>{e()},action:"normal",eventType:"frame",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onWorkspaceOpened(e){L(e);const t=hr(this).summary.id,r={callback:async t=>{const r=await hr(this).controller.transformStreamPayloadToWorkspace(t);e(r)},action:"opened",eventType:"workspace",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onWorkspaceSelected(e){L(e);const t=hr(this).summary.id,r={callback:async t=>{const r=await hr(this).controller.getWorkspaceById(t.workspaceSummary.id);e(r)},action:"selected",eventType:"workspace",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onWorkspaceClosed(e){L(e);const t=hr(this).summary.id,r={callback:t=>{e({frameId:t.frameSummary.id,workspaceId:t.workspaceSummary.id,frameBounds:t.frameBounds})},action:"closed",eventType:"workspace",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onWindowAdded(e){L(e);const t=hr(this).summary.id,r={callback:async t=>{const r=(await hr(this).controller.getParent((e=>e.id===t.windowSummary.parentId))).children.find((e=>"window"===e.type&&e.positionIndex===t.windowSummary.config.positionIndex));e(r)},action:"added",eventType:"window",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onWindowRemoved(e){L(e);const t=hr(this).summary.id,r={callback:t=>{const{windowId:r,workspaceId:o,frameId:n}=t.windowSummary.config;e({windowId:r,workspaceId:o,frameId:n})},action:"removed",eventType:"window",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onWindowLoaded(e){L(e);const t=hr(this).summary.id,r={callback:async t=>{const r=(await hr(this).controller.getParent((e=>e.id===t.windowSummary.parentId))).children.find((e=>"window"===e.type&&e.positionIndex===t.windowSummary.config.positionIndex));e(r)},action:"loaded",eventType:"window",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onInitializationRequested(e){return L(e),this.isInitialized||e(hr(this).summary.initializationContext),()=>{}}async onFocusChanged(e){L(e);const t=hr(this),{id:r}=t.summary,o={callback:t=>{e({isFocused:t.frameSummary.isFocused})},action:"focus",eventType:"frame",scope:"frame"};return await t.controller.processLocalSubscription(o,r)}}class pr{parentsData=new WeakMap;workspacesData=new WeakMap;windowsData=new WeakMap;framesData=new WeakMap;deleteData(e){e instanceof dr&&this.windowsData.delete(e),e instanceof ar&&this.workspacesData.delete(e),(e instanceof Vt||e instanceof Zt||e instanceof rr)&&this.parentsData.delete(e),e instanceof ur&&this.framesData.delete(e)}setWindowData(e,t){this.windowsData.set(e,t)}setWorkspaceData(e,t){this.workspacesData.set(e,t)}setParentData(e,t){this.parentsData.set(e,t)}setFrameData(e,t){this.framesData.set(e,t)}getWindowData(e){return this.windowsData.get(e)}getWorkspaceData(e){return this.workspacesData.get(e)}getParentData(e){return this.parentsData.get(e)}getFrameData(e){return this.framesData.get(e)}remapChild(e,t){if(e instanceof dr){const r=this.windowsData.get(e);r.parent=t.parent||r.parent,r.config=t.config||r.config}if(e instanceof Vt||e instanceof Zt||e instanceof rr){const r=this.parentsData.get(e);r.parent=t.parent||r.parent,r.config=t.config||r.config,r.children=t.children||r.children}}remapFrame(e,t){this.framesData.get(e).summary=t}remapWorkspace(e,t){const r=this.workspacesData.get(e);r.frame=t.frame||r.frame,r.config=t.config||r.config,r.children=t.children||r.children}}const wr=new WeakMap,mr=(e,t)=>{const r=wr.get(e).manager;return t instanceof ar?r.getWorkspaceData(t):wr.get(e).manager.getParentData(t)};class gr{frameId;workspaceId;positionIndex;constructor(e){wr.set(this,{manager:e})}getId(e){return mr(this,e).id}getPositionIndex(e){return mr(this,e).config.positionIndex}getWorkspaceId(e){const t=mr(this,e);return t.config.workspaceId||t.workspace.id}getFrameId(e){return mr(this,e).frame.id}getAllChildren(e,t){L(t,!0);const r=mr(this,e).children;return void 0===t?r:r.filter(t)}getMyParent(e){return e instanceof ar?e:mr(this,e).parent}getMyFrame(e){return mr(this,e).frame}getMyWorkspace(e){return e instanceof ar?e:mr(this,e).workspace}async addWindow(e,t,r){if(!t.appName&&!t.windowId)throw new Error("The window definition should contain either an appName or a windowId");const o=_.runWithException(t),n=mr(this,e).controller,i=await n.add("window",mr(this,e).id,r,o);if(e instanceof ar)return await e.refreshReference(),e.getWindow((e=>e.elementId===i.itemId));const a=this.getMyWorkspace(e);return await a.refreshReference(),a.getWindow((e=>e.elementId===i.itemId))}async addParent(e,t,r,o){const n=this.transformDefinition(t,o),i=mr(this,e).controller,a=(await i.add("container",mr(this,e).id,r,n)).itemId;if(e instanceof ar)return await e.refreshReference(),e.getBox((e=>e.id===a));const s=this.getMyWorkspace(e);return await s.refreshReference(),s.getBox((e=>e.id===a))}async removeChild(e,t){L(t);const r=this.getAllChildren(e).find(t);r&&(await r.close(),e instanceof ar?await e.refreshReference():await this.getMyWorkspace(e).refreshReference())}async maximize(e){const{controller:t,id:r}=mr(this,e);await t.maximizeItem(r),await this.getMyWorkspace(e.parent).refreshReference()}async restore(e){const{controller:t,id:r}=mr(this,e);await t.restoreItem(r),await this.getMyWorkspace(e.parent).refreshReference()}async close(e){const t=mr(this,e),r=mr(this,e).controller;await r.closeItem(t.id),await this.getMyWorkspace(t.parent).refreshReference()}async lockContainer(e,t){const r=mr(this,e),o=mr(this,e).controller;await o.lockContainer(r.id,e.type,t),await this.getMyWorkspace(r.parent).refreshReference()}getAllowDrop(e){return mr(this,e).config.allowDrop}getAllowDropLeft(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Property allowDropLeft is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropLeft}getAllowDropRight(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Property allowDropRight is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropRight}getAllowDropTop(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Property allowDropTop is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropTop}getAllowDropBottom(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Property allowDropBottom is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropBottom}getAllowDropHeader(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Property allowDropHeader is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropHeader}getAllowSplitters(e){const t=mr(this,e);if("group"===t.type)throw new Error(`Cannot get allow splitters from private data ${t.type}`);return t.config.allowSplitters}getAllowExtract(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Cannot get allow extract from private data ${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.allowExtract}getAllowReorder(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Cannot get allow extract from private data ${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.allowReorder}getShowMaximizeButton(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Cannot get show maximize button from private data${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.showMaximizeButton}getShowEjectButton(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Cannot get show eject button from private data${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.showEjectButton}getShowAddWindowButton(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Cannot get add window button from private data${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.showAddWindowButton}getMinWidth(e){return mr(this,e).config.minWidth}getMaxWidth(e){return mr(this,e).config.maxWidth}getMinHeight(e){return mr(this,e).config.minHeight}getMaxHeight(e){return mr(this,e).config.maxHeight}getWidthInPx(e){return mr(this,e).config.widthInPx}getHeightInPx(e){return mr(this,e).config.heightInPx}getIsPinned(e){return mr(this,e).config.isPinned}getIsMaximized(e){return mr(this,e).config.isMaximized}getMaximizationBoundary(e){return mr(this,e).config.maximizationBoundary}async setHeight(e,t){const r=mr(this,e),{controller:o,id:n}=r;await o.resizeItem(n,{height:t}),await this.getMyWorkspace(r.parent).refreshReference()}async setWidth(e,t){const r=mr(this,e),{controller:o,id:n}=r;await o.resizeItem(n,{width:t}),await this.getMyWorkspace(r.parent).refreshReference()}async setSize(e,t,r){const o=mr(this,e),{controller:n,id:i}=o;await n.resizeItem(i,{width:t,height:r}),await this.getMyWorkspace(o.parent).refreshReference()}async setMaximizationBoundary(e,t){const r=mr(this,e),{controller:o,id:n}=r;await o.setMaximizationBoundary(n,t),await this.getMyWorkspace(r.parent).refreshReference()}async bundleTo(e,t){const r=mr(this,e),{controller:o,id:n}=r;await o.bundleItemTo(t,n)}async processLocalSubscription(e,t){return mr(this,e).controller.processLocalSubscription(t,this.getId(e))}transformDefinition(e,t){let r;return void 0===t?r={type:e,children:[]}:t instanceof Nt?r=t.serialize():(void 0===t.type&&(t.type=e),r=K.runWithException(t),r.children=r.children||[]),r}}class fr{ioc;windows;contexts;layouts;constructor(e,t,r,o){this.ioc=e,this.windows=t,this.contexts=r,this.layouts=o}get bridge(){return this.ioc.bridge}get privateDataManager(){return this.ioc.privateDataManager}checkIsWindowLoaded(e){return!!e&&this.windows.list().some((t=>t.id===e))}async createWorkspace(e){const t=await this.bridge.send(zt.createWorkspace.name,e),r={summary:t.frameSummary},o={frame:this.ioc.getModel("frame",r),snapshot:t};return this.ioc.getModel("workspace",o)}async createEmptyFrame(e){const t={summary:await this.bridge.send(zt.createFrame.name,e)};return this.ioc.getModel("frame",t)}async initFrame(e,t){await this.bridge.send(zt.initFrame.name,{frameId:e,...t})}async restoreWorkspace(e,t){const r=await this.bridge.send(zt.openWorkspace.name,{name:e,restoreOptions:t}),o={summary:await this.bridge.send(zt.getFrameSummary.name,{itemId:r.config.frameId})},n={frame:this.ioc.getModel("frame",o),snapshot:r};return this.ioc.getModel("workspace",n)}async add(e,t,r,o){let n;const i={definition:o,parentId:t,parentType:r};if("window"===e)n=zt.addWindow.name;else{if("container"!==e)throw new Error(`Unrecognized add type: ${e}`);n=zt.addContainer.name}return await this.bridge.send(n,i)}async getFrame(e){const t={summary:await this.bridge.send(zt.getFrameSummary.name,{itemId:e})};return this.ioc.getModel("frame",t)}getFrames(e,t){return e.reduce(((e,r)=>{const o={summary:r},n=this.ioc.getModel("frame",o);return t&&!t(n)||e.push(n),e}),[])}getAllWorkspaceSummaries(...e){return e.reduce(((e,t)=>(e.push(...t.summaries),e)),[]).map((e=>Object.assign({},{id:e.id,width:e.config.widthInPx,height:e.config.heightInPx},e.config)))}handleOnSaved(e){const t=t=>{"Workspace"===t.type&&e(t)},r=this.layouts.onAdded(t),o=this.layouts.onChanged(t);return()=>{r(),o()}}handleOnRemoved(e){return this.layouts.onRemoved((t=>{"Workspace"===t.type&&e(t)}))}async importLayouts(e,t){await this.layouts.import(e,t)}async transformStreamPayloadToWorkspace(e){const t={summary:e.frameSummary},r={frame:this.ioc.getModel("frame",t),snapshot:e.workspaceSnapshot||await this.bridge.send(zt.getWorkspaceSnapshot.name,{itemId:e.workspaceSummary.id})};return this.ioc.getModel("workspace",r)}async fetchWorkspace(e){const t=await this.bridge.send(zt.getWorkspaceSnapshot.name,{itemId:e}),r={summary:t.frameSummary},o={frame:this.ioc.getModel("frame",r),snapshot:t};return this.ioc.getModel("workspace",o)}async bundleWorkspaceTo(e,t){await this.bridge.send(zt.bundleWorkspace.name,{type:e,workspaceId:t})}async bundleItemTo(e,t){if(!await this.isOperationSupported(zt.bundleItem.name))throw new Error(`Operation ${zt.bundleItem.name} is not supported. Ensure that you are running the latest version of all packages`);await this.bridge.send(zt.bundleItem.name,{type:e,itemId:t})}getWorkspaceContext(e){const t=`___workspace___${e}`;return this.contexts.get(t)}setWorkspaceContext(e,t){const r=`___workspace___${e}`;return this.contexts.set(r,t)}updateWorkspaceContext(e,t){const r=`___workspace___${e}`;return this.contexts.update(r,t)}subscribeWorkspaceContextUpdated(e,t){const r=`___workspace___${e}`;return this.contexts.subscribe(r,t)}async restoreItem(e){await this.bridge.send(zt.restoreItem.name,{itemId:e})}async maximizeItem(e){await this.bridge.send(zt.maximizeItem.name,{itemId:e})}async focusItem(e){await this.bridge.send(zt.focusItem.name,{itemId:e})}async closeItem(e){await this.bridge.send(zt.closeItem.name,{itemId:e})}async resizeItem(e,t){await this.bridge.send(zt.resizeItem.name,Object.assign({},{itemId:e},t))}async setMaximizationBoundary(e,t){await this.bridge.send(zt.setMaximizationBoundary.name,Object.assign({},{itemId:e},t))}async showWorkspaceLoadingAnimation(e){await this.bridge.send(zt.showLoadingAnimation.name,{itemId:e,type:"workspace"})}async hideWorkspaceLoadingAnimation(e){await this.bridge.send(zt.hideLoadingAnimation.name,{itemId:e,type:"workspace"})}async moveFrame(e,t){await this.bridge.send(zt.moveFrame.name,Object.assign({},{itemId:e},t))}getGDWindow(e){return this.windows.list().find((t=>t.id===e))}async forceLoadWindow(e){return(await this.bridge.send(zt.forceLoadWindow.name,{itemId:e})).windowId}async ejectWindow(e){return await this.bridge.send(zt.ejectWindow.name,{itemId:e})}async moveWindowTo(e,t){await this.bridge.send(zt.moveWindowTo.name,{itemId:e,containerId:t})}async getSnapshot(e,t){let r;return"workspace"===t?r=await this.bridge.send(zt.getWorkspaceSnapshot.name,{itemId:e}):"frame"===t&&(r=await this.bridge.send(zt.getFrameSnapshot.name,{itemId:e})),r}async setItemTitle(e,t){await this.bridge.send(zt.setItemTitle.name,{itemId:e,title:t})}refreshChildren(e){const{parent:t,children:r,existingChildren:o,workspace:n}=e;if(t instanceof dr||"window"===t.type)return;const i=r.map((e=>{let r=o.find((t=>"window"===t.type?t.elementId===e.id:t.id===e.id));if(r)this.privateDataManager.remapChild(r,{parent:t,children:[],config:e.config});else{let o;o="window"===e.type?{id:e.id,parent:t,frame:n.frame,workspace:n,config:e.config}:{id:e.id,parent:t,frame:n.frame,workspace:n,config:e.config,children:[]},r=this.ioc.getModel(e.type,o)}return"window"!==e.type&&this.refreshChildren({workspace:n,existingChildren:o,children:e.children,parent:r}),r}));return t instanceof ar||this.privateDataManager.remapChild(t,{children:i}),i}iterateFindChild(e,t){let r=e.find((e=>t(e)));return r||(e.some((e=>!(e instanceof dr)&&(r=this.iterateFindChild(e.children,t),!!r||void 0))),r)}iterateFilterChildren(e,t){const r=e.filter((e=>t(e))),o=e.reduce(((e,r)=>(r instanceof dr||e.push(...this.iterateFilterChildren(r.children,t)),e)),[]);return r.push(...o),r}notifyWindowAdded(e){return new Promise((t=>{if(this.windows.list().some((t=>t.id===e)))return t();const r=this.windows.onWindowAdded((o=>{o.id===e&&(r&&r(),t())}))}))}async hibernateWorkspace(e){await this.bridge.send(zt.hibernateWorkspace.name,{workspaceId:e})}async resumeWorkspace(e){await this.bridge.send(zt.resumeWorkspace.name,{workspaceId:e})}async lockWorkspace(e,t){await this.bridge.send(zt.lockWorkspace.name,{workspaceId:e,config:t})}async lockWindow(e,t){await this.bridge.send(zt.lockWindow.name,{windowPlacementId:e,config:t})}async lockContainer(e,t,r){await this.bridge.send(zt.lockContainer.name,{itemId:e,type:t,config:r})}async pinWorkspace(e,t){await this.bridge.send(zt.pinWorkspace.name,{workspaceId:e,icon:t})}async unpinWorkspace(e){await this.bridge.send(zt.unpinWorkspace.name,{workspaceId:e})}async getWorkspaceIcon(e){return(await this.bridge.send(zt.getWorkspaceIcon.name,{workspaceId:e})).icon}setWorkspaceIcon(e,t){return this.bridge.send(zt.setWorkspaceIcon.name,{workspaceId:e,icon:t})}async getPlatformFrameId(){try{return await this.bridge.send(zt.getPlatformFrameId.name,{})}catch(e){return{}}}async isOperationSupported(e){return Ot()?{isSupported:!0}:await this.bridge.send(zt.operationCheck.name,{operation:e})}}class yr{bridge;base;shortcutsController;constructor(e,t,r){this.bridge=e,this.base=t,this.shortcutsController=r}checkIsWindowLoaded(e){return this.base.checkIsWindowLoaded(e)}async checkIsInSwimlane(e){return(await this.bridge.send(zt.isWindowInWorkspace.name,{itemId:e})).inWorkspace}async createWorkspace(e,t){const r=Object.assign({},e,{saveConfig:t});return await this.base.createWorkspace(r)}async createEmptyFrame(e){return await this.base.createEmptyFrame(e)}async initFrame(e,t){return this.base.initFrame(e,t)}async restoreWorkspace(e,t){if(!(await this.getLayoutSummaries()).some((t=>t.name===e)))throw new Error(`This layout: ${e} cannot be restored, because it doesn't exist.`);if(t?.frameId){if(!(await this.bridge.send(zt.getAllFramesSummaries.name)).summaries.some((e=>e.id===t.frameId)))throw new Error(`Cannot reuse the frame with id: ${t.frameId}, because there is no frame with that ID found`)}return await this.base.restoreWorkspace(e,t)}async add(e,t,r,o){return await this.base.add(e,t,r,o)}processLocalSubscription(e,t){return Ot()?this.handleEnterpriseLocalSubscription(e,t):this.handleCoreLocalSubscription(e,t)}processGlobalSubscription(e,t,r){return Ot()?this.handleEnterpriseGlobalSubscription(e,t,r):this.handleCoreGlobalSubscription(e,t,r)}async getFrame(e){if(e.windowId)return await this.base.getFrame(e.windowId);if(e.predicate)return(await this.getFrames(e.predicate))[0];throw new Error(`The provided selector is not valid: ${JSON.stringify(e)}`)}async getFrames(e){const t=await this.bridge.send(zt.getAllFramesSummaries.name);return this.base.getFrames(t.summaries,e)}getWorkspaceById(e){return this.base.fetchWorkspace(e)}async getWorkspaceByWindowId(e){return Ot()?this.base.fetchWorkspace(e):(await this.getWorkspaces((t=>!!t.getWindow((t=>t.id===e)))))[0]}transformStreamPayloadToWorkspace(e){return this.base.transformStreamPayloadToWorkspace(e)}async getWorkspace(e){let t;return await this.iterateWorkspaces(((r,o)=>{e(r)&&(t=r,o())})),t}async getWorkspaces(e){const t=[];return await this.iterateWorkspaces((r=>{e&&!e(r)||t.push(r)})),t}async getWorkspacesByFrameId(e){const t=(await this.getAllWorkspaceSummaries()).filter((t=>t.frameId===e));return await Promise.all(t.map((e=>this.base.fetchWorkspace(e.id))))}async getAllWorkspaceSummaries(){const e=await this.bridge.send(zt.getAllWorkspacesSummaries.name,{});return this.base.getAllWorkspaceSummaries(e)}async getWindow(e){let t;return await this.iterateWorkspaces(((r,o)=>{const n=r.getWindow(e);n&&(t=n,o())})),t}async getParent(e){let t;return await this.iterateWorkspaces(((r,o)=>{const n=r.getBox(e);n&&(t=n,o())})),t}async getLayoutSummaries(){return(await this.bridge.send(zt.getAllLayoutsSummaries.name)).summaries}async deleteLayout(e){await this.bridge.send(zt.deleteLayout.name,{name:e})}async exportLayout(e){return(await this.bridge.send(zt.exportAllLayouts.name)).layouts.reduce(((t,r)=>(e&&!e(r)||t.push(r),t)),[])}async saveLayout(e){return await this.bridge.send(zt.saveLayout.name,e)}async importLayouts(e,t){if(Ot())try{await this.bridge.send(zt.importLayouts.name,{layouts:e,mode:t})}catch(r){await Promise.all(e.map((e=>this.bridge.send(zt.importLayout.name,{layout:e,mode:t}))))}else await this.base.importLayouts(e,t)}handleOnSaved(e){return this.base.handleOnSaved(e)}handleOnRemoved(e){return this.base.handleOnRemoved(e)}async bundleWorkspaceTo(e,t){return await this.base.bundleWorkspaceTo(e,t)}async bundleItemTo(e,t){return await this.base.bundleItemTo(e,t)}getWorkspaceContext(e){return this.base.getWorkspaceContext(e)}setWorkspaceContext(e,t){return this.base.setWorkspaceContext(e,t)}updateWorkspaceContext(e,t){return this.base.updateWorkspaceContext(e,t)}subscribeWorkspaceContextUpdated(e,t){return this.base.subscribeWorkspaceContextUpdated(e,t)}async restoreItem(e){return await this.base.restoreItem(e)}async maximizeItem(e){return await this.base.maximizeItem(e)}async focusItem(e){return await this.base.focusItem(e)}async changeFrameState(e,t){await this.bridge.send(zt.changeFrameState.name,{frameId:e,requestedState:t})}async getFrameBounds(e){return(await this.bridge.send(zt.getFrameBounds.name,{itemId:e})).bounds}async getFrameState(e){return(await this.bridge.send(zt.getFrameState.name,{itemId:e})).state}async closeItem(e){return await this.base.closeItem(e)}async resizeItem(e,t){return await this.base.resizeItem(e,t)}async setMaximizationBoundary(e,t){return await this.base.setMaximizationBoundary(e,t)}async showWorkspaceLoadingAnimation(e){return await this.base.showWorkspaceLoadingAnimation(e)}async hideWorkspaceLoadingAnimation(e){return await this.base.hideWorkspaceLoadingAnimation(e)}async moveFrame(e,t){return await this.base.moveFrame(e,t)}getGDWindow(e){return this.base.getGDWindow(e)}async forceLoadWindow(e){const t=await this.base.forceLoadWindow(e);return await this.base.notifyWindowAdded(t),t}async ejectWindow(e){const t=(await this.base.ejectWindow(e)).windowId;return await this.base.notifyWindowAdded(t),t}async moveWindowTo(e,t){return await this.base.moveWindowTo(e,t)}async getSnapshot(e,t){return await this.base.getSnapshot(e,t)}async setItemTitle(e,t){return await this.base.setItemTitle(e,t)}flatChildren(e){return e.reduce(((e,t)=>(e.push(t),"window"!==t.type&&e.push(...this.flatChildren(t.children)),e)),[])}refreshChildren(e){return this.base.refreshChildren(e)}iterateFindChild(e,t){return this.base.iterateFindChild(e,t)}iterateFilterChildren(e,t){return this.base.iterateFilterChildren(e,t)}hibernateWorkspace(e){return this.base.hibernateWorkspace(e)}resumeWorkspace(e){return this.base.resumeWorkspace(e)}lockWorkspace(e,t){return this.base.lockWorkspace(e,t)}lockWindow(e,t){return this.base.lockWindow(e,t)}lockContainer(e,t,r){return this.base.lockContainer(e,t,r)}pinWorkspace(e,t){return this.base.pinWorkspace(e,t)}unpinWorkspace(e){return this.base.unpinWorkspace(e)}getWorkspaceIcon(e){return this.base.getWorkspaceIcon(e)}setWorkspaceIcon(e,t){return this.base.setWorkspaceIcon(e,t)}async getFrameConstraints(e){const t=await this.getSnapshot(e,"frame");return{minWidth:t.config.minWidth,maxWidth:t.config.maxWidth,minHeight:t.config.minHeight,maxHeight:t.config.maxHeight}}registerShortcut(e,t,r){return this.shortcutsController.registerShortcut(e,t,r)}getPlatformFrameId(){return this.base.getPlatformFrameId()}async handleCoreLocalSubscription(e,t){if(await this.bridge.createCoreEventSubscription(),e.scopeId=e.scopeId||t,"window"===e.eventType&&"loaded"===e.action){const t=e.callback,r=async e=>{await this.base.notifyWindowAdded(e.windowSummary.config.windowId),t(e)};e.callback=r}return this.bridge.handleCoreSubscription(e)}handleEnterpriseLocalSubscription(e,t){if(e.scopeId=e.scopeId||t,"window"===e.eventType&&"loaded"===e.action){const t=e.callback,r=async e=>{await this.base.notifyWindowAdded(e.windowSummary.config.windowId),t(e)};e.callback=r}return this.bridge.subscribe(e)}async handleCoreGlobalSubscription(e,t,r){await this.bridge.createCoreEventSubscription();const o={eventType:t,callback:e,action:r,scope:"global"};if("window"===t&&"loaded"===r){const t=async t=>{await this.base.notifyWindowAdded(t.windowSummary.config.windowId),e(t)};o.callback=t}return this.bridge.handleCoreSubscription(o)}handleEnterpriseGlobalSubscription(e,t,r){const o={eventType:t,callback:e,action:r,scope:"global"};if("window"===t&&"loaded"===r){const t=async t=>{await this.base.notifyWindowAdded(t.windowSummary.config.windowId),e(t)};o.callback=t}return this.bridge.subscribe(o)}async iterateWorkspaces(e){let t=!1;const r=()=>{t=!0},o=await this.getAllWorkspaceSummaries();for(const n of o){if(t)return;e(await this.base.fetchWorkspace(n.id),r)}}}class kr{bridge;_shortcuts=r();constructor(e){this.bridge=e,this.bridge.onOperation(((e,t)=>{if(e.operation===Ft.shortcutClicked.name){const t=e.data;this._shortcuts.execute(`${t.frameId}-${t.shortcut}`)}}))}async registerShortcut(e,t,r){await this.bridge.send(zt.registerShortcut.name,{shortcut:e,frameId:t});const o=this._shortcuts.add(`${t}-${e}`,r);return()=>{o(),this.bridge.send(zt.unregisterShortcut.name,{shortcut:e,frameId:t})}}}class br{agm;windows;layouts;contexts;_controllerInstance;_bridgeInstance;_transportInstance;_privateDataManagerInstance;_parentBaseInstance;_baseController;_shortcutsController;constructor(e,t,r,o){this.agm=e,this.windows=t,this.layouts=r,this.contexts=o}get baseController(){return this._baseController||(this._baseController=new fr(this,this.windows,this.contexts,this.layouts)),this._baseController}get controller(){return this._controllerInstance||(this._controllerInstance=new yr(this.bridge,this.baseController,this.shortcutsController)),this._controllerInstance}get shortcutsController(){return this._shortcutsController||(this._shortcutsController=new kr(this.bridge)),this._shortcutsController}get bridge(){return this._bridgeInstance||(this._bridgeInstance=new $t(this.transport,r())),this._bridgeInstance}get transport(){return this._transportInstance||(this._transportInstance=new jt(this.agm,r())),this._transportInstance}get privateDataManager(){return this._privateDataManagerInstance||(this._privateDataManagerInstance=new pr),this._privateDataManagerInstance}get parentBase(){return this._parentBaseInstance||(this._parentBaseInstance=new gr(this.privateDataManager)),this._parentBaseInstance}async initiate(e){await this.transport.initiate(e)}getModel(e,t){switch(e){case"frame":{const e=new ur(this.privateDataManager),{summary:r}=t,o={summary:r,controller:this.controller};return this.privateDataManager.setFrameData(e,o),e}case"window":{const{id:e,parent:r,frame:o,workspace:n,config:i}=t,a={type:"window",controller:this.controller,config:i,id:e,parent:r,frame:o,workspace:n},s=new dr(this.privateDataManager);return this.privateDataManager.setWindowData(s,a),s}case"row":case"column":case"group":{const{id:r,children:o,parent:n,frame:i,workspace:a,config:s}=t,c="column"===e?new Zt(this.parentBase):"row"===e?new Vt(this.parentBase):new rr(this.parentBase),d=this.buildChildren(o,i,a,c),l={id:r,parent:n,frame:i,workspace:a,config:s,type:e,controller:this.controller,children:d};return this.privateDataManager.setParentData(c,l),c}case"workspace":{const{snapshot:e,frame:r}=t,o=new ar(this.privateDataManager),n=this.buildChildren(e.children,r,o,o),i={id:e.id,type:"workspace",config:e.config,base:this.parentBase,controller:this.controller,children:n,frame:r,ioc:this};return this.privateDataManager.setWorkspaceData(o,i),o}default:throw new Error(`Unrecognized type: ${e}`)}}getBuilder(e){e.definition=e.definition||{},Array.isArray(e.definition.children)||(e.definition.children=[]);const t=new Jt(this.getBuilder.bind(this));switch(e.type){case"workspace":return new Kt(e.definition,t,this.controller);case"row":case"column":case"group":return e.definition.type=e.type,new Nt(e.definition,t);default:throw new Error(`Unexpected Builder creation error, provided config: ${JSON.stringify(e)}`)}}buildChildren(e,t,r,o){return e.map((e=>{switch(e.type){case"window":return this.getModel("window",{id:e.id,config:e.config,frame:t,workspace:r,parent:o});case"column":case"row":case"group":return this.getModel(e.type,{id:e.id,config:e.config,children:e.children,frame:t,workspace:r,parent:o});default:throw new Error(`Unsupported child type: ${e.type}`)}}))}}const Wr=async e=>{const t=new br(e.agm,e.windows,e.layouts,e.contexts),r=e.interop.instance.windowId;await t.initiate(r),e.workspaces=((e,t)=>{const r=t.controller,o=async e=>(L(e,!0),r.getFrames(e)),n=async e=>(L(e),await r.processGlobalSubscription((r=>{const o={summary:r.frameSummary},n=t.getModel("frame",o);e(n)}),"frame","opened"));return{inWorkspace:()=>{const t=e.windows.my().id;if(!t)throw new Error("Cannot get my frame, because my id is undefined.");return r.checkIsInSwimlane(t)},getBuilder:e=>{const r=ne.runWithException(e);return t.getBuilder(r)},getMyFrame:async()=>{const t=e.windows.my().id;if(!t)throw new Error("Cannot get my frame, because my id is undefined.");if(!await r.checkIsInSwimlane(t))throw new Error("Cannot fetch your frame, because this window is not in a workspace");return r.getFrame({windowId:t})},getFrame:async e=>(L(e),r.getFrame({predicate:e})),getAllFrames:o,getAllWorkspacesSummaries:()=>r.getAllWorkspaceSummaries(),getMyWorkspace:async()=>{const t=e.windows.my().id;if(!t)throw new Error("Cannot get my workspace, because my id is undefined.");if(!await r.checkIsInSwimlane(t))throw new Error("Cannot fetch your workspace, because this window is not in a workspace");return await r.getWorkspaceByWindowId(t)},getWorkspace:async e=>(L(e),(await r.getWorkspaces(e))[0]),getWorkspaceById:async e=>(v.runWithException(e),r.getWorkspaceById(e)),getAllWorkspaces:e=>(L(e,!0),r.getWorkspaces(e)),getWindow:async e=>(L(e),r.getWindow(e)),getBox:async e=>(L(e),r.getParent(e)),restoreWorkspace:async(e,t)=>{v.runWithException(e);const o=V.runWithException(t);return r.restoreWorkspace(e,o)},createWorkspace:async(e,t)=>{const o=Y.runWithException(e),n=P.runWithException(t);return r.createWorkspace(o,n)},createEmptyFrame:async e=>{const t=te.runWithException(e);return r.createEmptyFrame(t??{})},waitForFrame:async e=>(v.runWithException(e),new Promise(((t,r)=>{let i=()=>{};n((r=>{r.id===e&&(t(r),i())})).then((e=>(i=e,o()))).then((r=>{const o=r.find((t=>t.id===e));o&&(t(o),i())})).catch(r)}))),layouts:{getSummaries:()=>r.getLayoutSummaries(),delete:async e=>(v.runWithException(e),r.deleteLayout(e)),export:async e=>(L(e,!0),r.exportLayout(e)),import:async(e,t="replace")=>{if(!Array.isArray(e))throw new Error(`The provided layouts argument is not an array: ${JSON.stringify(e)}`);return e.forEach((e=>Se.runWithException(e))),r.importLayouts(e,t)},save:async e=>{const t=lt.runWithException(e);return r.saveLayout(t)},onSaved:async e=>(L(e),r.handleOnSaved(e)),onRemoved:async e=>(L(e),r.handleOnRemoved(e))},onFrameOpened:n,onFrameClosed:async e=>(L(e),await r.processGlobalSubscription((t=>{e({frameId:t.frameSummary.id,frameBounds:t.frameBounds})}),"frame","closed")),onWorkspaceOpened:async e=>(L(e),await r.processGlobalSubscription((async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)}),"workspace","opened")),onWorkspaceClosed:async e=>(L(e),await r.processGlobalSubscription((t=>{e({frameId:t.frameSummary.id,workspaceId:t.workspaceSummary.id,frameBounds:t.frameBounds})}),"workspace","closed")),onWorkspaceHibernated:async e=>(L(e),await r.processGlobalSubscription((async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)}),"workspace","hibernated")),onWorkspaceResumed:async e=>(L(e),await r.processGlobalSubscription((async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)}),"workspace","resumed")),onWindowAdded:async e=>(L(e),await r.processGlobalSubscription((async o=>{const n=await r.getSnapshot(o.windowSummary.config.workspaceId,"workspace"),i={summary:n.frameSummary},a={frame:t.getModel("frame",i),snapshot:n},s=t.getModel("workspace",a).getBox((e=>e.id===o.windowSummary.parentId)).children.find((e=>"window"===e.type&&e.elementId===o.windowSummary.itemId));e(s)}),"window","added")),onWindowLoaded:async e=>(L(e),await r.processGlobalSubscription((async o=>{const n=await r.getSnapshot(o.windowSummary.config.workspaceId,"workspace"),i={summary:n.frameSummary},a={frame:t.getModel("frame",i),snapshot:n},s=t.getModel("workspace",a).getWindow((e=>e.id&&e.id===o.windowSummary.config.windowId));e(s)}),"window","loaded")),onWindowRemoved:async e=>(L(e),await r.processGlobalSubscription((t=>{const{windowId:r,workspaceId:o,frameId:n}=t.windowSummary.config;e({windowId:r,workspaceId:o,frameId:n})}),"window","removed")),onWindowMaximized:async e=>(L(e),await r.processGlobalSubscription((async o=>{const n=await r.getSnapshot(o.windowSummary.config.workspaceId,"workspace"),i={summary:n.frameSummary},a={frame:t.getModel("frame",i),snapshot:n},s=t.getModel("workspace",a).getBox((e=>e.id===o.windowSummary.parentId)).children.find((e=>"window"===e.type&&e.elementId===o.windowSummary.itemId));e(s)}),"window","maximized")),onWindowRestored:async e=>(L(e),await r.processGlobalSubscription((async o=>{const n=await r.getSnapshot(o.windowSummary.config.workspaceId,"workspace"),i={summary:n.frameSummary},a={frame:t.getModel("frame",i),snapshot:n},s=t.getModel("workspace",a).getBox((e=>e.id===o.windowSummary.parentId)).children.find((e=>"window"===e.type&&e.elementId===o.windowSummary.itemId));e(s)}),"window","restored")),onWindowSelected:async e=>(L(e),await r.processGlobalSubscription((async o=>{const n=await r.getSnapshot(o.windowSummary.config.workspaceId,"workspace"),i={summary:n.frameSummary},a={frame:t.getModel("frame",i),snapshot:n},s=t.getModel("workspace",a).getBox((e=>e.id===o.windowSummary.parentId)).children.find((e=>"window"===e.type&&e.elementId===o.windowSummary.itemId));e(s)}),"window","selected")),version:"3.4.4"}})(e,t)};return"undefined"!=typeof window&&(window.IOWorkspaces=Wr),Wr}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).workspaces=e.workspaces||{},e.workspaces.min=t())}(this,(function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function t(e){if(e&&e.errorHandling&&"function"!=typeof e.errorHandling&&"log"!==e.errorHandling&&"silent"!==e.errorHandling&&"throw"!==e.errorHandling)throw new Error('Invalid options passed to createRegistry. Prop errorHandling should be ["log" | "silent" | "throw" | (err) => void], but '+typeof e.errorHandling+" was passed");var t=e&&"function"==typeof e.errorHandling&&e.errorHandling,r={};function o(r,o){var n=r instanceof Error?r:new Error(r);if(t)t(n);else{var i='[ERROR] callback-registry: User callback for key "'+o+'" failed: '+n.stack;if(e)switch(e.errorHandling){case"log":return console.error(i);case"silent":return;case"throw":throw new Error(i)}console.error(i)}}return{add:function(e,t,n){var i=r[e];return i||(i=[],r[e]=i),i.push(t),n&&setTimeout((function(){n.forEach((function(n){var i;if(null===(i=r[e])||void 0===i?void 0:i.includes(t))try{Array.isArray(n)?t.apply(void 0,n):t.apply(void 0,[n])}catch(t){o(t,e)}}))}),0),function(){var o=r[e];o&&(0===(o=o.reduce((function(e,r,o){return r===t&&e.length===o||e.push(r),e}),[])).length?delete r[e]:r[e]=o)}},execute:function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var i=r[e];if(!i||0===i.length)return[];var a=[];return i.forEach((function(r){try{var n=r.apply(void 0,t);a.push(n)}catch(t){a.push(void 0),o(t,e)}})),a},clear:function(){r={}},clearKey:function(e){r[e]&&delete r[e]}}}t.default=t;var r=e(t),o=function(e){return{ok:!0,result:e}},n=function(e){return{ok:!1,error:e}},i=function(e,t,r){return!1===t.ok?t:!1===r.ok?r:o(e(t.result,r.result))},a=function(e,t){return!0===t.ok?t:n(e(t.error))},s=function(){return s=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},s.apply(this,arguments)};function c(e,t){if(e===t)return!0;if(null===e&&null===t)return!0;if(typeof e!=typeof t)return!1;if("object"==typeof e){if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!c(e[r],t[r]))return!1;return!0}var o=Object.keys(e);if(o.length!==Object.keys(t).length)return!1;for(r=0;r<o.length;r++){if(!t.hasOwnProperty(o[r]))return!1;if(!c(e[o[r]],t[o[r]]))return!1}return!0}}var d=function(e){return Array.isArray(e)},l=function(e){return"object"==typeof e&&null!==e&&!d(e)},h=function(e,t){return"expected "+e+", got "+function(e){switch(typeof e){case"string":return"a string";case"number":return"a number";case"boolean":return"a boolean";case"undefined":return"undefined";case"object":return e instanceof Array?"an array":null===e?"null":"an object";default:return JSON.stringify(e)}}(t)},u=function(e){return e.map((function(e){return"string"==typeof e?"."+e:"["+e+"]"})).join("")},p=function(e,t){var r=t.at,o=function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r}(t,["at"]);return s({at:e+(r||"")},o)},w=function(){function e(t){var r=this;this.decode=t,this.run=function(e){return a((function(t){return{kind:"DecoderError",input:e,at:"input"+(t.at||""),message:t.message||""}}),r.decode(e))},this.runPromise=function(e){return!0===(t=r.run(e)).ok?Promise.resolve(t.result):Promise.reject(t.error);var t},this.runWithException=function(e){return function(e){if(!0===e.ok)return e.result;throw e.error}(r.run(e))},this.map=function(t){return new e((function(e){return function(e,t){return!0===t.ok?o(e(t.result)):t}(t,r.decode(e))}))},this.andThen=function(t){return new e((function(e){return function(e,t){return!0===t.ok?e(t.result):t}((function(r){return t(r).decode(e)}),r.decode(e))}))},this.where=function(t,o){return r.andThen((function(r){return t(r)?e.succeed(r):e.fail(o)}))}}return e.string=function(){return new e((function(e){return"string"==typeof e?o(e):n({message:h("a string",e)})}))},e.number=function(){return new e((function(e){return"number"==typeof e?o(e):n({message:h("a number",e)})}))},e.boolean=function(){return new e((function(e){return"boolean"==typeof e?o(e):n({message:h("a boolean",e)})}))},e.constant=function(t){return new e((function(e){return c(e,t)?o(t):n({message:"expected "+JSON.stringify(t)+", got "+JSON.stringify(e)})}))},e.object=function(t){return new e((function(e){if(l(e)&&t){var r={};for(var i in t)if(t.hasOwnProperty(i)){var a=t[i].decode(e[i]);if(!0!==a.ok)return void 0===e[i]?n({message:"the key '"+i+"' is required but was not present"}):n(p("."+i,a.error));void 0!==a.result&&(r[i]=a.result)}return o(r)}return l(e)?o(e):n({message:h("an object",e)})}))},e.array=function(t){return new e((function(e){if(d(e)&&t){return e.reduce((function(e,r,o){return i((function(e,t){return e.concat([t])}),e,function(e,r){return a((function(e){return p("["+r+"]",e)}),t.decode(e))}(r,o))}),o([]))}return d(e)?o(e):n({message:h("an array",e)})}))},e.tuple=function(t){return new e((function(e){if(d(e)){if(e.length!==t.length)return n({message:"expected a tuple of length "+t.length+", got one of length "+e.length});for(var r=[],i=0;i<t.length;i++){var a=t[i].decode(e[i]);if(!a.ok)return n(p("["+i+"]",a.error));r[i]=a.result}return o(r)}return n({message:h("a tuple of length "+t.length,e)})}))},e.union=function(t,r){for(var o=[],n=2;n<arguments.length;n++)o[n-2]=arguments[n];return e.oneOf.apply(e,[t,r].concat(o))},e.intersection=function(t,r){for(var n=[],a=2;a<arguments.length;a++)n[a-2]=arguments[a];return new e((function(e){return[t,r].concat(n).reduce((function(t,r){return i(Object.assign,t,r.decode(e))}),o({}))}))},e.anyJson=function(){return new e((function(e){return o(e)}))},e.unknownJson=function(){return new e((function(e){return o(e)}))},e.dict=function(t){return new e((function(e){if(l(e)){var r={};for(var i in e)if(e.hasOwnProperty(i)){var a=t.decode(e[i]);if(!0!==a.ok)return n(p("."+i,a.error));r[i]=a.result}return o(r)}return n({message:h("an object",e)})}))},e.optional=function(t){return new e((function(e){return null==e?o(void 0):t.decode(e)}))},e.oneOf=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return new e((function(e){for(var r=[],o=0;o<t.length;o++){var i=t[o].decode(e);if(!0===i.ok)return i;r[o]=i.error}var a=r.map((function(e){return"at error"+(e.at||"")+": "+e.message})).join('", "');return n({message:'expected a value matching one of the decoders, got the errors ["'+a+'"]'})}))},e.withDefault=function(t,r){return new e((function(e){return o(function(e,t){return!0===t.ok?t.result:e}(t,r.decode(e)))}))},e.valueAt=function(t,r){return new e((function(e){for(var o=e,i=0;i<t.length;i++){if(void 0===o)return n({at:u(t.slice(0,i+1)),message:"path does not exist"});if("string"==typeof t[i]&&!l(o))return n({at:u(t.slice(0,i+1)),message:h("an object",o)});if("number"==typeof t[i]&&!d(o))return n({at:u(t.slice(0,i+1)),message:h("an array",o)});o=o[t[i]]}return a((function(e){return void 0===o?{at:u(t),message:"path does not exist"}:p(u(t),e)}),r.decode(o))}))},e.succeed=function(t){return new e((function(e){return o(t)}))},e.fail=function(t){return new e((function(e){return n({message:t})}))},e.lazy=function(t){return new e((function(e){return t().decode(e)}))},e}(),m=w.string,g=w.number,f=w.boolean,y=w.anyJson;w.unknownJson;var k=w.constant,b=w.object,W=w.array;w.tuple,w.dict;var I=w.optional,x=w.oneOf;w.union;var S=w.intersection;w.withDefault,w.valueAt,w.succeed,w.fail;var D=w.lazy;const v=m().where((e=>e.length>0),"Expected a non-empty string"),C=g().where((e=>e>=0),"Expected a non-negative number"),E=g().where((e=>e>0),"Expected a positive number"),B=b({inWorkspace:f()}),T=x(k("workspace"),k("row"),k("column"),k("group")),M=x(k("row"),k("column"),k("group")),R=x(k("maximized"),k("minimized"),k("normal")),A=x(k("workspace")),L=(e,t)=>{const r=typeof e;if(t&&"function"!==r&&"undefined"!==r)throw new Error(`Provided argument must be either undefined or of type function, provided: ${r}`);if(!t&&"function"!==r)throw new Error(`Provided argument must be of type function, provided: ${r}`)},P=I(b({saveLayout:I(f())})),F=b({name:v}),z=b({minWidth:I(g()),maxWidth:I(g()),minHeight:I(g()),maxHeight:I(g()),allowExtract:I(f()),allowReorder:I(f()),showCloseButton:I(f())}),H=b({minWidth:I(g()),maxWidth:I(g()),minHeight:I(g()),maxHeight:I(g()),allowExtract:I(f()),allowReorder:I(f()),allowDrop:I(f()),allowDropHeader:I(f()),allowDropLeft:I(f()),allowDropRight:I(f()),allowDropTop:I(f()),allowDropBottom:I(f()),showMaximizeButton:I(f()),showEjectButton:I(f()),showAddWindowButton:I(f())}),$=b({minHeight:I(g()),maxHeight:I(g()),allowDrop:I(f()),allowSplitters:I(f()),isPinned:I(f()),maximizationBoundary:I(f())}),O=b({minWidth:I(g()),maxWidth:I(g()),allowDrop:I(f()),allowSplitters:I(f()),isPinned:I(f()),maximizationBoundary:I(f())}),_=b({type:I(k("window")),appName:I(v),windowId:I(v),context:I(y()),config:I(z)}),j=b({type:k("window"),appName:I(v),windowId:I(v),context:I(y()),config:I(z)}),G=I(b({type:I(M),children:I(D((()=>W(x(_,G))))),config:I(y())})),N=b({type:k("column"),children:I(D((()=>W(x(j,K))))),config:I(O)}),J=b({type:k("row"),children:I(D((()=>W(x(j,K))))),config:I($)}),U=b({type:k("group"),children:I(D((()=>W(x(j,K))))),config:I(H)}),K=x(U,N,J);x(m().where((e=>"maximized"===e.toLowerCase()),"Expected a case insensitive variation of 'maximized'"),m().where((e=>"normal"===e.toLowerCase()),"Expected a case insensitive variation of 'normal'"));const q=b({bounds:I(b({left:I(g()),top:I(g()),width:I(C),height:I(C)})),frameId:I(v)}),Q=x(k("direct"),k("delayed"),k("lazy")),V=I(b({app:I(v),context:I(y()),loadingStrategy:I(Q),title:I(v),reuseWorkspaceId:I(v),frameId:I(v),applicationName:I(v),lockdown:I(f()),activateFrame:I(f()),newFrame:I(x(q,f())),noTabHeader:I(f()),inMemoryLayout:I(f()),icon:I(v),isPinned:I(f()),isSelected:I(f()),positionIndex:I(C),allowSystemHibernation:I(f())})),X=b({name:v,restoreOptions:I(V)}),Y=b({children:I(W(x(_,K))),context:I(y()),config:I(b({title:I(v),position:I(C),isFocused:I(f()),noTabHeader:I(f()),reuseWorkspaceId:I(v),loadingStrategy:I(Q),allowDrop:I(f()),allowDropLeft:I(f()),allowDropTop:I(f()),allowDropRight:I(f()),allowDropBottom:I(f()),allowSystemHibernation:I(f()),allowExtract:I(f()),allowWindowReorder:I(f()),showSaveButton:I(f()),allowWorkspaceTabReorder:I(f()),allowWorkspaceTabExtract:I(f()),showCloseButton:I(f()),allowSplitters:I(f()),showWindowCloseButtons:I(f()),showEjectButtons:I(f()),showAddWindowButtons:I(f()),icon:I(v),isPinned:I(f()),isSelected:I(f()),positionIndex:I(C)})),frame:I(b({activate:I(f()),reuseFrameId:I(v),applicationName:I(v),newFrame:I(x(f(),q))}))}),Z=b({workspaceId:v}),ee=b({name:v,restoreOptions:I(V)}),te=I(b({applicationName:I(m()),frameConfig:I(q),context:I(b()),layoutComponentId:I(v)})),re=b({workspaces:W(x(I(Y),I(ee)))}),oe=b({frameId:v,workspaces:W(x(Y,ee))}),ne=b({type:T,definition:I(x(Y,G))}),ie=S(Y,b({saveConfig:I(b({saveLayout:I(f())}))})),ae=b({itemId:v}),se=b({context:I(b())}),ce=b({id:v,isFocused:I(f()),isInitialized:I(f()),initializationContext:I(se)});b({type:M,id:v,frameId:v,workspaceId:v,positionIndex:g()});const de=x(k("frame"),k("workspace"),k("container"),k("window")),le=b({type:de,branch:v}),he=x(k("opened"),k("closing"),k("closed"),k("focus"),k("added"),k("loaded"),k("removed"),k("childrenUpdate"),k("containerChange"),k("maximized"),k("restored"),k("minimized"),k("normal"),k("selected"),k("lock-configuration-changed"),k("hibernated"),k("resumed")),ue=b({frameId:v,title:v,positionIndex:C,name:v,layoutName:I(v),isHibernated:I(f()),isSelected:I(f()),allowDrop:I(f()),allowSystemHibernation:I(f()),allowExtract:I(f()),allowWindowReorder:I(f()),allowSplitters:I(f()),showCloseButton:I(f()),showSaveButton:I(f()),allowWorkspaceTabReorder:I(f()),allowWorkspaceTabExtract:I(f()),allowDropLeft:I(f()),allowDropTop:I(f()),allowDropRight:I(f()),allowDropBottom:I(f()),minWidth:I(g()),maxWidth:I(g()),minHeight:I(g()),maxHeight:I(g()),showAddWindowButtons:I(f()),showEjectButtons:I(f()),showWindowCloseButtons:I(f()),widthInPx:I(g()),heightInPx:I(g()),isPinned:I(f())}),pe=b({frameId:v,workspaceId:v,positionIndex:g(),minWidth:I(g()),maxWidth:I(g()),minHeight:I(g()),maxHeight:I(g())}),we=y(),me=S(pe,b({windowId:I(v),isMaximized:I(f()),isFocused:f(),isSelected:I(f()),title:I(m()),appName:I(v),allowExtract:I(f()),allowReorder:I(f()),showCloseButton:I(f()),minWidth:I(g()),minHeight:I(g()),maxWidth:I(g()),maxHeight:I(g()),widthInPx:I(g()),heightInPx:I(g()),context:I(y())})),ge=b({id:I(v),config:we,children:I(D((()=>W(ye)))),type:x(k("row"),k("column"),k("group"))}),fe=b({id:I(v),config:me,type:k("window")}),ye=x(fe,ge),ke=b({id:v,config:ue,children:W(ye),frameSummary:ce,context:I(y())}),be=b({type:k("window"),config:b({appName:v,windowId:I(v),context:I(y()),url:I(v),title:I(m()),allowExtract:I(f()),allowReorder:I(f()),showCloseButton:I(f()),minWidth:I(g()),minHeight:I(g()),maxWidth:I(g()),maxHeight:I(g()),isMaximized:I(f())})}),We=b({type:k("group"),config:y(),children:W(x(be))}),Ie=b({type:k("column"),config:y(),children:W(x(We,be,D((()=>Ie)),D((()=>xe))))}),xe=b({type:k("row"),config:y(),children:W(x(Ie,We,be,D((()=>xe))))}),Se=b({name:v,type:k("Workspace"),metadata:I(y()),components:W(b({type:k("Workspace"),application:I(m()),state:b({config:y(),context:y(),children:W(x(xe,Ie,We,be))})}))}),De=b({layout:Se,mode:x(k("replace"),k("merge"))}),ve=b({layouts:W(Se),mode:x(k("replace"),k("merge"))}),Ce=b({layouts:W(Se)}),Ee=b({id:v,isFocused:I(f()),isInitialized:I(f()),initializationContext:I(se)}),Be=b({summaries:W(Ee)}),Te=b({id:v,config:ue}),Me=b({summaries:W(Te)}),Re=b({id:v,config:y(),workspaces:W(ke)}),Ae=b({name:v,applicationName:I(m())}),Le=b({summaries:W(Ae)}),Pe=b({windowId:v}),Fe=y(),ze=b({state:R}),He=b({top:g(),left:g(),width:C,height:C}),$e=b({bounds:He}),Oe=b({icon:I(v)}),_e=b({id:I(v)}),je=b({isSupported:f()}),Ge=b({width:I(E),height:I(E),relative:I(f())}),Ne=b({top:I(g()),left:I(g()),relative:I(f())}),Je=b({itemId:v}),Ue=b({itemId:v,excludeIds:I(f())}),Ke=b({frameId:v,requestedState:R}),qe=b({itemId:v,title:v}),Qe=b({itemId:v,containerId:v}),Ve=S(Je,Ge),Xe=b({itemId:v,enabled:f()}),Ye=S(Je,Ne);b({id:v,type:M});const Ze=b({definition:_,parentId:v,parentType:T}),et=b({definition:K,parentId:v,parentType:T}),tt=b({itemId:v,windowId:I(v)}),rt=b({live:f()}),ot=b({type:x(k("row"),k("column")),workspaceId:v}),nt=b({type:x(k("row"),k("column")),itemId:v}),it=b({itemId:v,config:we}),at=b({frameSummary:ce,frameBounds:I(He)}),st=b({workspaceSummary:Te,frameSummary:ce,workspaceSnapshot:I(ke),frameBounds:I(He)}),ct=b({containerSummary:it}),dt=b({windowSummary:b({itemId:v,parentId:v,config:me})}),lt=b({name:v,workspaceId:v,saveContext:I(f()),metadata:I(b())}),ht=b({allowDrop:I(f()),allowDropLeft:I(f()),allowDropTop:I(f()),allowDropRight:I(f()),allowDropBottom:I(f()),allowSystemHibernation:I(f()),allowExtract:I(f()),allowWindowReorder:I(f()),allowSplitters:I(f()),showCloseButton:I(f()),showSaveButton:I(f()),allowWorkspaceTabReorder:I(f()),allowWorkspaceTabExtract:I(f()),showWindowCloseButtons:I(f()),showAddWindowButtons:I(f()),showEjectButtons:I(f())}),ut=b({workspaceId:v,config:I(ht)}),pt=b({allowExtract:I(f()),allowReorder:I(f()),showCloseButton:I(f())}),wt=b({width:I(C),height:I(C)}),mt=b({windowPlacementId:v,config:I(pt)}),gt=b({allowDrop:I(f()),allowSplitters:I(f())}),ft=b({allowDrop:I(f()),allowSplitters:I(f())}),yt=b({allowExtract:I(f()),allowReorder:I(f()),allowDrop:I(f()),allowDropLeft:I(f()),allowDropRight:I(f()),allowDropTop:I(f()),allowDropBottom:I(f()),allowDropHeader:I(f()),showMaximizeButton:I(f()),showEjectButton:I(f()),showAddWindowButton:I(f())}),kt=b({itemId:v,type:k("row"),config:I(gt)}),bt=b({itemId:v,type:k("column"),config:I(ft)}),Wt=b({itemId:v,type:k("group"),config:I(yt)}),It=x(kt,bt,Wt),xt=b({workspaceId:v,icon:I(v)}),St=b({workspaceId:v,icon:I(v)}),Dt=I(b({icon:I(v)})),vt=b({shortcut:v,frameId:v}),Ct=b({shortcut:v,frameId:v}),Et=b({enabled:f()}),Bt=b({itemId:v,type:A}),Tt=b({operation:v}),Mt="T42.Web.Platform.Control",Rt="T42.Web.Platform.WSP.Stream",At={control:{name:"T42.Workspaces.Control",isStream:!1},frameStream:{name:"T42.Workspaces.Stream.Frame",isStream:!0},workspaceStream:{name:"T42.Workspaces.Stream.Workspace",isStream:!0},containerStream:{name:"T42.Workspaces.Stream.Container",isStream:!0},windowStream:{name:"T42.Workspaces.Stream.Window",isStream:!0}},Lt={control:{name:"T42.Workspaces.Client.Control",isStream:!1}},Pt={frame:{name:"T42.Workspaces.Stream.Frame",payloadDecoder:at},workspace:{name:"T42.Workspaces.Stream.Workspace",payloadDecoder:st},container:{name:"T42.Workspaces.Stream.Container",payloadDecoder:ct},window:{name:"T42.Workspaces.Stream.Window",payloadDecoder:dt}},Ft={shortcutClicked:{name:"shortcutClicked",argsDecoder:Ct,resultDecoder:Fe}},zt={ping:{name:"ping",resultDecoder:rt},isWindowInWorkspace:{name:"isWindowInWorkspace",argsDecoder:Je,resultDecoder:B},createWorkspace:{name:"createWorkspace",resultDecoder:ke,argsDecoder:ie},createFrame:{name:"createFrame",resultDecoder:Ee,argsDecoder:te},initFrame:{name:"initFrame",resultDecoder:Fe,argsDecoder:oe},getAllFramesSummaries:{name:"getAllFramesSummaries",resultDecoder:Be},getFrameSummary:{name:"getFrameSummary",resultDecoder:ce,argsDecoder:ae},getAllWorkspacesSummaries:{name:"getAllWorkspacesSummaries",resultDecoder:Me},getWorkspaceSnapshot:{name:"getWorkspaceSnapshot",resultDecoder:ke,argsDecoder:Je},getAllLayoutsSummaries:{name:"getAllLayoutsSummaries",resultDecoder:Le},openWorkspace:{name:"openWorkspace",argsDecoder:X,resultDecoder:ke},deleteLayout:{name:"deleteLayout",resultDecoder:Fe,argsDecoder:F},saveLayout:{name:"saveLayout",resultDecoder:Se,argsDecoder:lt},importLayout:{name:"importLayout",resultDecoder:Fe,argsDecoder:De},importLayouts:{name:"importLayouts",resultDecoder:Fe,argsDecoder:ve},exportAllLayouts:{name:"exportAllLayouts",resultDecoder:Ce},restoreItem:{name:"restoreItem",argsDecoder:Je,resultDecoder:Fe},maximizeItem:{name:"maximizeItem",argsDecoder:Je,resultDecoder:Fe},focusItem:{name:"focusItem",argsDecoder:Je,resultDecoder:Fe},closeItem:{name:"closeItem",argsDecoder:Je,resultDecoder:Fe},resizeItem:{name:"resizeItem",argsDecoder:Ve,resultDecoder:Fe},setMaximizationBoundary:{name:"setMaximizationBoundary",argsDecoder:Xe,resultDecoder:Fe},changeFrameState:{name:"changeFrameState",argsDecoder:Ke,resultDecoder:Fe},getFrameState:{name:"getFrameState",argsDecoder:Je,resultDecoder:ze},getFrameBounds:{name:"getFrameBounds",argsDecoder:Je,resultDecoder:$e},moveFrame:{name:"moveFrame",argsDecoder:Ye,resultDecoder:Fe},getFrameSnapshot:{name:"getFrameSnapshot",argsDecoder:Ue,resultDecoder:Re},forceLoadWindow:{name:"forceLoadWindow",argsDecoder:Je,resultDecoder:Pe},ejectWindow:{name:"ejectWindow",argsDecoder:Je,resultDecoder:Pe},setItemTitle:{name:"setItemTitle",argsDecoder:qe,resultDecoder:Fe},moveWindowTo:{name:"moveWindowTo",argsDecoder:Qe,resultDecoder:Fe},addWindow:{name:"addWindow",argsDecoder:Ze,resultDecoder:tt},addContainer:{name:"addContainer",argsDecoder:et,resultDecoder:tt},bundleWorkspace:{name:"bundleWorkspace",argsDecoder:ot,resultDecoder:Fe},bundleItem:{name:"bundleItem",argsDecoder:nt,resultDecoder:Fe},hibernateWorkspace:{name:"hibernateWorkspace",argsDecoder:Z,resultDecoder:Fe},resumeWorkspace:{name:"resumeWorkspace",argsDecoder:Z,resultDecoder:Fe},lockWorkspace:{name:"lockWorkspace",argsDecoder:ut,resultDecoder:Fe},lockWindow:{name:"lockWindow",argsDecoder:mt,resultDecoder:Fe},lockContainer:{name:"lockContainer",argsDecoder:It,resultDecoder:Fe},pinWorkspace:{name:"pinWorkspace",argsDecoder:xt,resultDecoder:Fe},unpinWorkspace:{name:"unpinWorkspace",argsDecoder:Z,resultDecoder:Fe},getWorkspaceIcon:{name:"getWorkspaceIcon",argsDecoder:Z,resultDecoder:Oe},setWorkspaceIcon:{name:"setWorkspaceIcon",argsDecoder:St,resultDecoder:Fe},registerShortcut:{name:"registerShortcut",argsDecoder:vt,resultDecoder:Fe},unregisterShortcut:{name:"unregisterShortcut",argsDecoder:vt,resultDecoder:Fe},showLoadingAnimation:{name:"showLoadingAnimation",argsDecoder:Bt,resultDecoder:Fe},hideLoadingAnimation:{name:"hideLoadingAnimation",argsDecoder:Bt,resultDecoder:Fe},getPlatformFrameId:{name:"getPlatformFrameId",resultDecoder:_e},operationCheck:{name:"operationCheck",argsDecoder:Tt,resultDecoder:je}};class Ht{resolve;reject;promise;constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class $t{transport;registry;activeSubscriptions=[];pendingSubScriptions=[];constructor(e,t){this.transport=e,this.registry=t}async createCoreEventSubscription(){await this.transport.coreSubscriptionReady(this.handleCoreEvent.bind(this))}handleCoreSubscription(e){const t=`${e.eventType}-${e.action}`,r=e.scope,o=e.scopeId;return this.registry.add(t,(t=>{const n={type:r,id:o},i={frame:t.frameSummary?.id||t.windowSummary?.config.frameId,workspace:t.workspaceSummary?.id||t.windowSummary?.config.workspaceId,container:t.containerSummary?.itemId,window:t.windowSummary?.itemId};this.checkScopeMatch(n,i)&&e.callback(t)}))}async send(e,t){const r=Object.values(zt).find((t=>t.name===e));if(!r)throw new Error(`Cannot find definition for operation name: ${e}`);if(r.argsDecoder)try{r.argsDecoder.runWithException(t)}catch(t){throw new Error(`Unexpected internal outgoing validation error: ${t.message}, for input: ${JSON.stringify(t.input)}, for operation ${e}`)}try{const e=await this.transport.transmitControl(r.name,t);return r.resultDecoder.runWithException(e),e}catch(t){if(t.kind)throw new Error(`Unexpected internal incoming validation error: ${t.message}, for input: ${JSON.stringify(t.input)}, for operation ${e}`);throw new Error(t.message)}}async subscribe(e){const t=this.getPendingSubscription(e);t&&await t.promise;let r=this.getActiveSubscription(e);const o=this.getRegistryKey(e);if(!r){const t=new Ht,o={streamType:e.eventType,level:e.scope,levelId:e.scopeId,promise:t.promise};this.pendingSubScriptions.push(o);try{const o=Pt[e.eventType],n=await this.transport.subscribe(o.name,this.getBranchKey(e),e.eventType);n.onData((e=>{const t=e.data,r=le.run(e.requestArguments),o=he.run(t.action);if(!r.ok||!o.ok)return;const n=r.result.type,i=`${n}-${r.result.branch}-${o.result}`,a=Pt[n].payloadDecoder.run(t.payload);a.ok&&this.registry.execute(i,a.result)})),r={streamType:e.eventType,level:e.scope,levelId:e.scopeId,callbacksCount:0,gdSub:n},this.activeSubscriptions.push(r),t.resolve()}catch(e){throw t.reject(e),e}finally{this.removePendingSubscription(o)}}const n=this.registry.add(o,e.callback);return++r.callbacksCount,()=>{n(),--r.callbacksCount,0===r.callbacksCount&&(r.gdSub.close(),this.activeSubscriptions.splice(this.activeSubscriptions.indexOf(r),1))}}onOperation(e){return this.transport.onInternalMethodInvoked("control",((t,r)=>{const o=t.operation,n=t.data,i=Object.values(Ft).find((e=>e.name===o));if(!i)throw new Error(`Cannot find definition for operation name: ${o}`);if(i.argsDecoder)try{i.argsDecoder.runWithException(n)}catch(e){throw new Error(`Unexpected internal outgoing validation error: ${e.message}, for input: ${JSON.stringify(e.input)}, for operation ${o}`)}e(t,r)}))}checkScopeMatch(e,t){return"global"===e.type||("frame"===e.type&&e.id===t.frame||("workspace"===e.type&&e.id===t.workspace||("container"===e.type&&e.id===t.container||"window"===e.type&&e.id===t.window)))}handleCoreEvent(e){const t=e.data;try{const e=he.runWithException(t.action),r=de.runWithException(t.type),o=Pt[r].payloadDecoder.runWithException(t.payload),n=`${r}-${e}`;this.registry.execute(n,o)}catch(e){console.warn(`Cannot handle event with data ${JSON.stringify(t)}, because of validation error: ${e.message}`)}}getBranchKey(e){return"global"===e.scope?e.scope:`${e.scope}_${e.scopeId}`}getRegistryKey(e){return`${e.eventType}-${this.getBranchKey(e)}-${e.action}`}getActiveSubscription(e){return this.activeSubscriptions.find((t=>t.streamType===e.eventType&&t.level===e.scope&&t.levelId===e.scopeId))}getPendingSubscription(e){return this.pendingSubScriptions.find((t=>t.streamType===e.eventType&&t.level===e.scope&&t.levelId===e.scopeId))}removePendingSubscription(e){const t=this.pendingSubScriptions.indexOf(e);t>=0&&this.pendingSubScriptions.splice(t,1)}}const Ot=()=>"undefined"==typeof window||(window.glue42gd||window.iodesktop),_t=()=>"undefined"==typeof window?null:window.glue42core||window.iobrowser;class jt{agm;registry;defaultTransportTimeout=3e4;coreEventMethodInitiated=!1;corePlatformSubPromise;constructor(e,t){this.agm=e,this.registry=t}async initiate(e){if(Ot())return await Promise.all(Object.values(At).map((e=>this.verifyMethodLive(e.name)))),void await Promise.all(Object.keys(Lt).map((e=>this.registerMethod(e))));const t=_t().communicationId;await Promise.all([this.verifyMethodLive(Mt,t),this.verifyMethodLive(Rt,t)]),await this.transmitControl("frameHello",{windowId:e})}coreSubscriptionReady(e){return this.coreEventMethodInitiated||this.subscribePlatform(e),this.corePlatformSubPromise}subscribePlatform(e){this.coreEventMethodInitiated=!0;const t=_t().communicationId;this.corePlatformSubPromise=this.agm.subscribe(Rt,t?{target:{instance:t}}:void 0),this.corePlatformSubPromise.then((t=>{t.onData((t=>e(t.data)))}))}async subscribe(e,t,r){const o={branch:t,type:r};let n;try{n=await this.agm.subscribe(e,{arguments:o})}catch(r){const o=`Internal subscription error! Error details: stream - ${e}, branch: ${t}. Internal message: ${r.message}`;throw new Error(o)}return n}async transmitControl(e,t){const r=Ot()?{operation:e,operationArguments:t}:{operation:e,domain:"workspaces",data:t},o=Ot()?At.control.name:Mt,n=Ot()?void 0:_t().communicationId;let i;const a=`Internal Workspaces Communication Error. Attempted operation: ${JSON.stringify(r)}. `;try{if(i=await this.agm.invoke(o,r,n?{instance:n}:"best",{methodResponseTimeoutMs:this.defaultTransportTimeout}),!i)throw new Error("Received unsupported result from GD - empty result");if(!Array.isArray(i.all_return_values)||0===i.all_return_values.length)throw new Error("Received unsupported result from GD - empty values collection")}catch(e){if(e&&e.all_errors&&e.all_errors.length){const t=e.all_errors[0].message;throw new Error(`${a} -> Inner message: ${t}`)}throw new Error(`${a} -> Inner message: ${e.message}`)}return i.all_return_values[0].returned}onInternalMethodInvoked(e,t){return this.registry.add(e,t)}verifyMethodLive(e,t){return r=()=>new Promise((r=>{if(this.agm.methods().some((r=>{const o=r.name===e,n=!t||r.getServers().some((e=>e.instance===t));return o&&n})))return void r();const o=this.agm.serverMethodAdded((n=>{const i=n.method,a=n.server,s=!t||a.instance===t;i.name===e&&s&&(o(),r())}))})),o=15e3,n="Timeout waiting for the Workspaces communication channels",new Promise(((e,t)=>{let i=!0;const a=setTimeout((()=>{i&&(i=!1,t(n))}),o);r().then((t=>{i&&(i=!1,clearTimeout(a),e(t))})).catch((e=>{i&&(i=!1,clearTimeout(a),t(e))}))}));var r,o,n}registerMethod(e){const t=Lt[e];return this.agm.register(t.name,((t,r)=>{this.registry.execute(e,t,r)}))}}const Gt=new WeakMap;class Nt{constructor(e,t){const r=t.wrapChildren(e.children);delete e.children,Gt.set(this,{base:t,children:r,definition:e})}get type(){return Gt.get(this).definition.type}addColumn(e){return Gt.get(this).base.add("column",Gt.get(this).children,e)}addRow(e){return Gt.get(this).base.add("row",Gt.get(this).children,e)}addGroup(e){return Gt.get(this).base.add("group",Gt.get(this).children,e)}addWindow(e){return Gt.get(this).base.addWindow(Gt.get(this).children,e),this}serialize(){const e=Gt.get(this).definition;return e.children=Gt.get(this).base.serializeChildren(Gt.get(this).children),e}}class Jt{getBuilder;constructor(e){this.getBuilder=e}wrapChildren(e){return e.map((e=>"window"===e.type?e:this.getBuilder({type:e.type,definition:e})))}add(e,t,r){const o=G.runWithException(r),n=this.getBuilder({type:e,definition:o});return t.push(n),n}addWindow(e,t){const r=_.runWithException(t);r.type="window",e.push(r)}serializeChildren(e){return e.map((e=>e instanceof Nt?e.serialize():e))}}const Ut=new WeakMap;class Kt{constructor(e,t,r){const o=t.wrapChildren(e.children);delete e.children,Ut.set(this,{base:t,children:o,definition:e,controller:r})}addColumn(e){const t=Ut.get(this).children;if(!t.every((e=>e instanceof Nt&&"column"===e.type)))throw new Error("Cannot add a column to this workspace, because there are already children of another type");return Ut.get(this).base.add("column",t,e)}addRow(e){const t=Ut.get(this).children;if(!t.every((e=>e instanceof Nt&&"row"===e.type)))throw new Error("Cannot add a row to this workspace, because there are already children of another type");return Ut.get(this).base.add("row",t,e)}addGroup(e){const t=Ut.get(this).children;if(0!==t.length)throw new Error("Cannot add a group to this workspace, because there are already defined children.");return Ut.get(this).base.add("group",t,e)}addWindow(e){const t=Ut.get(this).children;if(0!==t.length)throw new Error("Cannot add a window to this workspace, because there are already defined children.");return Ut.get(this).base.addWindow(t,e),this}getChildAt(e){C.runWithException(e);return Ut.get(this).children[e]}async create(e){const t=P.runWithException(e),r=Ut.get(this).definition;r.children=Ut.get(this).base.serializeChildren(Ut.get(this).children);return Ut.get(this).controller.createWorkspace(r,t)}}const qt=new WeakMap,Qt=e=>qt.get(e).base;class Vt{constructor(e){qt.set(this,{base:e})}get type(){return"row"}get id(){return Qt(this).getId(this)}get frameId(){return Qt(this).getFrameId(this)}get workspaceId(){return Qt(this).getWorkspaceId(this)}get positionIndex(){return Qt(this).getPositionIndex(this)}get children(){return Qt(this).getAllChildren(this)}get parent(){return Qt(this).getMyParent(this)}get frame(){return Qt(this).getMyFrame(this)}get workspace(){return Qt(this).getMyWorkspace(this)}get allowDrop(){return Qt(this).getAllowDrop(this)}get allowSplitters(){return Qt(this).getAllowSplitters(this)}get minWidth(){return Qt(this).getMinWidth(this)}get minHeight(){return Qt(this).getMinHeight(this)}get maxWidth(){return Qt(this).getMaxWidth(this)}get maxHeight(){return Qt(this).getMaxHeight(this)}get width(){return Qt(this).getWidthInPx(this)}get height(){return Qt(this).getHeightInPx(this)}get isPinned(){return Qt(this).getIsPinned(this)}get isMaximized(){return Qt(this).getIsMaximized(this)}get maximizationBoundary(){return Qt(this).getMaximizationBoundary(this)}addWindow(e){return Qt(this).addWindow(this,e,"row")}async addGroup(e){if(e?.type&&"group"!==e.type)throw new Error(`Expected a group definition, but received ${e.type}`);return Qt(this).addParent(this,"group","row",e)}async addColumn(e){if(e?.type&&"column"!==e.type)throw new Error(`Expected a column definition, but received ${e.type}`);return Qt(this).addParent(this,"column","row",e)}async addRow(){throw new Error("Adding rows as row children is not supported")}removeChild(e){return Qt(this).removeChild(this,e)}maximize(){return Qt(this).maximize(this)}restore(){return Qt(this).restore(this)}close(){return Qt(this).close(this)}lock(e){let t;if("function"==typeof e){t=e({allowDrop:this.allowDrop,allowSplitters:this.allowSplitters})}else t=e;const r=void 0===t?void 0:gt.runWithException(t);return Qt(this).lockContainer(this,r)}async setHeight(e){return C.runWithException(e),Qt(this).setHeight(this,e)}async onLockConfigurationChanged(e){L(e);const t={callback:async()=>{await this.workspace.refreshReference(),e({allowDrop:this.allowDrop,allowSplitters:this.allowSplitters})},action:"lock-configuration-changed",eventType:"container",scope:"container"};return await Qt(this).processLocalSubscription(this,t)}async setMaximizationBoundary(e){const t=Et.runWithException(e);return Qt(this).setMaximizationBoundary(this,t)}}const Xt=new WeakMap,Yt=e=>Xt.get(e).base;class Zt{constructor(e){Xt.set(this,{base:e})}get type(){return"column"}get id(){return Yt(this).getId(this)}get frameId(){return Yt(this).getFrameId(this)}get workspaceId(){return Yt(this).getWorkspaceId(this)}get positionIndex(){return Yt(this).getPositionIndex(this)}get children(){return Yt(this).getAllChildren(this)}get parent(){return Yt(this).getMyParent(this)}get frame(){return Yt(this).getMyFrame(this)}get workspace(){return Yt(this).getMyWorkspace(this)}get allowDrop(){return Yt(this).getAllowDrop(this)}get allowSplitters(){return Yt(this).getAllowSplitters(this)}get minWidth(){return Yt(this).getMinWidth(this)}get minHeight(){return Yt(this).getMinHeight(this)}get maxWidth(){return Yt(this).getMaxWidth(this)}get maxHeight(){return Yt(this).getMaxHeight(this)}get width(){return Yt(this).getWidthInPx(this)}get height(){return Yt(this).getHeightInPx(this)}get isPinned(){return Yt(this).getIsPinned(this)}get isMaximized(){return Yt(this).getIsMaximized(this)}get maximizationBoundary(){return Yt(this).getMaximizationBoundary(this)}addWindow(e){return Yt(this).addWindow(this,e,"column")}async addGroup(e){if(e?.type&&"group"!==e.type)throw new Error(`Expected a group definition, but received ${e.type}`);return Yt(this).addParent(this,"group","column",e)}async addColumn(){throw new Error("Adding columns as column children is not supported")}async addRow(e){if(e?.type&&"row"!==e.type)throw new Error(`Expected a row definition, but received ${e.type}`);return Yt(this).addParent(this,"row","column",e)}removeChild(e){return Yt(this).removeChild(this,e)}maximize(){return Yt(this).maximize(this)}restore(){return Yt(this).restore(this)}close(){return Yt(this).close(this)}lock(e){let t;if("function"==typeof e){t=e({allowDrop:this.allowDrop,allowSplitters:this.allowSplitters})}else t=e;const r=void 0===t?void 0:ft.runWithException(t);return Yt(this).lockContainer(this,r)}async setWidth(e){return C.runWithException(e),Yt(this).setWidth(this,e)}async onLockConfigurationChanged(e){L(e);const t={callback:async()=>{await this.workspace.refreshReference(),e({allowDrop:this.allowDrop,allowSplitters:this.allowSplitters})},action:"lock-configuration-changed",eventType:"container",scope:"container"};return await Yt(this).processLocalSubscription(this,t)}async setMaximizationBoundary(e){const t=Et.runWithException(e);return Yt(this).setMaximizationBoundary(this,t)}}const er=new WeakMap,tr=e=>er.get(e).base;class rr{constructor(e){er.set(this,{base:e})}get type(){return"group"}get id(){return tr(this).getId(this)}get frameId(){return tr(this).getFrameId(this)}get workspaceId(){return tr(this).getWorkspaceId(this)}get positionIndex(){return tr(this).getPositionIndex(this)}get children(){return tr(this).getAllChildren(this)}get parent(){return tr(this).getMyParent(this)}get frame(){return tr(this).getMyFrame(this)}get workspace(){return tr(this).getMyWorkspace(this)}get allowExtract(){return tr(this).getAllowExtract(this)}get allowReorder(){return tr(this).getAllowReorder(this)}get allowDropLeft(){return tr(this).getAllowDropLeft(this)}get allowDropRight(){return tr(this).getAllowDropRight(this)}get allowDropTop(){return tr(this).getAllowDropTop(this)}get allowDropBottom(){return tr(this).getAllowDropBottom(this)}get allowDropHeader(){return tr(this).getAllowDropHeader(this)}get allowDrop(){return tr(this).getAllowDrop(this)}get showMaximizeButton(){return tr(this).getShowMaximizeButton(this)}get showEjectButton(){return tr(this).getShowEjectButton(this)}get showAddWindowButton(){return tr(this).getShowAddWindowButton(this)}get minWidth(){return tr(this).getMinWidth(this)}get minHeight(){return tr(this).getMinHeight(this)}get maxWidth(){return tr(this).getMaxWidth(this)}get maxHeight(){return tr(this).getMaxHeight(this)}get width(){return tr(this).getWidthInPx(this)}get height(){return tr(this).getHeightInPx(this)}get isMaximized(){return tr(this).getIsMaximized(this)}addWindow(e){return tr(this).addWindow(this,e,"group")}async addGroup(){throw new Error("Adding groups as group child is not supported")}async addColumn(){throw new Error("Adding columns as group child is not supported")}async addRow(){throw new Error("Adding rows as group child is not supported")}removeChild(e){return tr(this).removeChild(this,e)}maximize(){return tr(this).maximize(this)}restore(){return tr(this).restore(this)}close(){return tr(this).close(this)}lock(e){let t;if("function"==typeof e){t=e({allowDrop:this.allowDrop,allowDropHeader:this.allowDropHeader,allowDropLeft:this.allowDropLeft,allowDropRight:this.allowDropRight,allowDropTop:this.allowDropTop,allowDropBottom:this.allowDropBottom,allowExtract:this.allowExtract,allowReorder:this.allowReorder,showAddWindowButton:this.showAddWindowButton,showEjectButton:this.showEjectButton,showMaximizeButton:this.showMaximizeButton})}else t=e;const r=void 0===t?void 0:yt.runWithException(t);return tr(this).lockContainer(this,r)}async setSize(e){const t=wt.runWithException(e);if(!t.width&&!t.height)throw new Error("Expected either width or height to be passed.");return tr(this).setSize(this,e.width,e.height)}async bundleToRow(){await tr(this).bundleTo(this,"row"),await this.workspace.refreshReference()}async bundleToColumn(){await tr(this).bundleTo(this,"column"),await this.workspace.refreshReference()}async onLockConfigurationChanged(e){L(e);const t={callback:async()=>{await this.workspace.refreshReference(),e({allowDrop:this.allowDrop,allowDropHeader:this.allowDropHeader,allowDropLeft:this.allowDropLeft,allowDropTop:this.allowDropTop,allowDropRight:this.allowDropRight,allowDropBottom:this.allowDropBottom,allowExtract:this.allowExtract,allowReorder:this.allowReorder,showAddWindowButton:this.showAddWindowButton,showEjectButton:this.showEjectButton,showMaximizeButton:this.showMaximizeButton})},action:"lock-configuration-changed",eventType:"container",scope:"container"};return await tr(this).processLocalSubscription(this,t)}}const or=new WeakMap,nr=e=>or.get(e).manager.getWorkspaceData(e),ir=e=>or.get(e).manager;class ar{constructor(e){or.set(this,{manager:e})}get id(){return nr(this).id}get frameId(){return nr(this).config.frameId}get positionIndex(){return nr(this).config.positionIndex}get title(){return nr(this).config.title}get layoutName(){return nr(this).config.layoutName}get isHibernated(){return nr(this).config.isHibernated}get isSelected(){return nr(this).config.isSelected}get children(){return nr(this).children}get frame(){return nr(this).frame}get allowSplitters(){return nr(this).config.allowSplitters}get allowSystemHibernation(){return nr(this).config.allowSystemHibernation}get allowDrop(){return nr(this).config.allowDrop}get allowDropLeft(){return nr(this).config.allowDropLeft}get allowDropTop(){return nr(this).config.allowDropTop}get allowDropRight(){return nr(this).config.allowDropRight}get allowDropBottom(){return nr(this).config.allowDropBottom}get allowExtract(){return nr(this).config.allowExtract}get allowWindowReorder(){return nr(this).config.allowWindowReorder}get showCloseButton(){return nr(this).config.showCloseButton}get showSaveButton(){return nr(this).config.showSaveButton}get allowWorkspaceTabReorder(){return nr(this).config.allowWorkspaceTabReorder}get allowWorkspaceTabExtract(){return nr(this).config.allowWorkspaceTabExtract}get minWidth(){return nr(this).config.minWidth}get minHeight(){return nr(this).config.minHeight}get maxWidth(){return nr(this).config.maxWidth}get maxHeight(){return nr(this).config.maxHeight}get width(){return nr(this).config.widthInPx}get height(){return nr(this).config.heightInPx}get showWindowCloseButtons(){return nr(this).config.showWindowCloseButtons}get showEjectButtons(){return nr(this).config.showEjectButtons}get showAddWindowButtons(){return nr(this).config.showAddWindowButtons}get isPinned(){return nr(this).config.isPinned}async removeChild(e){L(e);const t=this.children.find(e);t&&(await t.close(),await this.refreshReference())}async remove(e){L(e);const t=nr(this).controller.iterateFindChild(this.children,e);await t.close(),await this.refreshReference()}async focus(){await nr(this).controller.focusItem(this.id),await this.refreshReference()}async close(){const e=nr(this).controller,t=await nr(this).frame.workspaces(),r=(await e.getPlatformFrameId()).id;if(1===t.length&&t.every((e=>e.id===this.id))&&r!==this.frame.id)return this.frame.close();await e.closeItem(this.id)}snapshot(){return nr(this).controller.getSnapshot(this.id,"workspace")}async saveLayout(e,t){v.runWithException(e),await nr(this).controller.saveLayout({name:e,workspaceId:this.id,saveContext:t?.saveContext,metadata:t?.metadata})}async setTitle(e){v.runWithException(e);const t=nr(this).controller;await t.setItemTitle(this.id,e),await this.refreshReference()}getContext(){return nr(this).controller.getWorkspaceContext(this.id)}setContext(e){return nr(this).controller.setWorkspaceContext(this.id,e)}updateContext(e){return nr(this).controller.updateWorkspaceContext(this.id,e)}onContextUpdated(e){return nr(this).controller.subscribeWorkspaceContextUpdated(this.id,e)}async refreshReference(){const e=await nr(this).controller.getSnapshot(this.id,"workspace"),t=nr(this).controller.flatChildren(nr(this).children),r=nr(this).controller.refreshChildren({existingChildren:t,workspace:this,parent:this,children:e.children}),o=this.frame;let n;if(o.id===e.config.frameId)ir(this).remapFrame(o,e.frameSummary),n=o;else{const t={summary:e.frameSummary};n=nr(this).ioc.getModel("frame",t)}ir(this).remapWorkspace(this,{config:e.config,children:r,frame:n})}async getIcon(){return nr(this).controller.getWorkspaceIcon(this.id)}async setIcon(e){return nr(this).controller.setWorkspaceIcon(this.id,e)}getBox(e){L(e);const t=nr(this).children;return nr(this).controller.iterateFindChild(t,(t=>"window"!==t.type&&e(t)))}getAllBoxes(e){L(e,!0);const t=nr(this).children,r=nr(this).controller.iterateFilterChildren(t,(e=>"window"!==e.type));return e?r.filter(e):r}getRow(e){return L(e),this.getBox((t=>"row"===t.type&&e(t)))}getAllRows(e){return L(e,!0),e?this.getAllBoxes((t=>"row"===t.type&&e(t))):this.getAllBoxes((e=>"row"===e.type))}getColumn(e){return L(e),this.getBox((t=>"column"===t.type&&e(t)))}getAllColumns(e){return L(e,!0),e?this.getAllBoxes((t=>"column"===t.type&&e(t))):this.getAllBoxes((e=>"column"===e.type))}getGroup(e){return L(e),this.getBox((t=>"group"===t.type&&e(t)))}getAllGroups(e){return L(e,!0),e?this.getAllBoxes((t=>"group"===t.type&&e(t))):this.getAllBoxes((e=>"group"===e.type))}getWindow(e){L(e);const t=nr(this).children;return nr(this).controller.iterateFindChild(t,(t=>"window"===t.type&&e(t)))}getAllWindows(e){L(e,!0);const t=nr(this).children,r=nr(this).controller.iterateFilterChildren(t,(e=>"window"===e.type));return e?r.filter(e):r}addRow(e){return nr(this).base.addParent(this,"row","workspace",e)}addColumn(e){return nr(this).base.addParent(this,"column","workspace",e)}addGroup(e){return nr(this).base.addParent(this,"group","workspace",e)}addWindow(e){return nr(this).base.addWindow(this,e,"workspace")}async bundleToRow(){await nr(this).controller.bundleWorkspaceTo("row",this.id),await this.refreshReference()}async bundleToColumn(){await nr(this).controller.bundleWorkspaceTo("column",this.id),await this.refreshReference()}async hibernate(){await nr(this).controller.hibernateWorkspace(this.id),await this.refreshReference()}async resume(){await nr(this).controller.resumeWorkspace(this.id),await this.refreshReference()}async lock(e){let t;if("function"==typeof e){t=e({allowDrop:this.allowDrop,allowDropLeft:this.allowDropLeft,allowDropTop:this.allowDropTop,allowDropRight:this.allowDropRight,allowDropBottom:this.allowDropBottom,allowSystemHibernation:this.allowSystemHibernation,allowExtract:this.allowExtract,allowWindowReorder:this.allowWindowReorder,allowSplitters:this.allowSplitters,showCloseButton:this.showCloseButton,showSaveButton:this.showSaveButton,allowWorkspaceTabReorder:this.allowWorkspaceTabReorder,allowWorkspaceTabExtract:this.allowWorkspaceTabExtract,showAddWindowButtons:this.showAddWindowButtons,showEjectButtons:this.showEjectButtons,showWindowCloseButtons:this.showWindowCloseButtons})}else t=e;const r=void 0===t?void 0:ht.runWithException(t);await nr(this).controller.lockWorkspace(this.id,r),await this.refreshReference()}async pin(e){Dt.runWithException(e),await nr(this).controller.pinWorkspace(this.id,e?.icon),await this.refreshReference()}async unpin(){await nr(this).controller.unpinWorkspace(this.id),await this.refreshReference()}async showLoadingAnimation(){if(!Ot())throw new Error("Not supported in IO Connect Browser");await nr(this).controller.showWorkspaceLoadingAnimation(this.id)}async hideLoadingAnimation(){if(!Ot())throw new Error("Not supported in IO Connect Browser");await nr(this).controller.hideWorkspaceLoadingAnimation(this.id)}async onClosed(e){L(e);const t=nr(this).id,r={action:"closed",eventType:"workspace",scope:"workspace",scopeId:t,callback:async t=>{e({frameId:t.frameSummary.id,workspaceId:t.workspaceSummary.id,frameBounds:t.frameBounds})}};return await nr(this).controller.processLocalSubscription(r,t)}async onHibernated(e){L(e);const t=nr(this).id,r={action:"hibernated",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await nr(this).controller.processLocalSubscription(r,t)}async onResumed(e){L(e);const t=nr(this).id,r={action:"resumed",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await nr(this).controller.processLocalSubscription(r,t)}async onWindowAdded(e){L(e);const t=nr(this).id,r={action:"added",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const r=this.getBox((e=>e.id===t.windowSummary.parentId)).children.find((e=>"window"===e.type&&e.elementId===t.windowSummary.itemId));e(r)}};return await nr(this).controller.processLocalSubscription(r,t)}async onWindowRemoved(e){L(e);const t=nr(this).id,r={action:"removed",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const{windowId:r,workspaceId:o,frameId:n}=t.windowSummary.config;e({windowId:r,workspaceId:o,frameId:n})}};return await nr(this).controller.processLocalSubscription(r,t)}async onWindowLoaded(e){L(e);const t=nr(this).id,r={action:"loaded",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const r=this.getWindow((e=>e.id&&e.id===t.windowSummary.config.windowId));e(r)}};return await nr(this).controller.processLocalSubscription(r,t)}async onWindowMaximized(e){L(e);const t=nr(this).id,r={action:"maximized",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const r=this.getBox((e=>e.id===t.windowSummary.parentId)).children.find((e=>"window"===e.type&&e.elementId===t.windowSummary.itemId));e(r)}};return await nr(this).controller.processLocalSubscription(r,t)}async onWindowRestored(e){L(e);const t=nr(this).id,r={action:"restored",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const r=this.getBox((e=>e.id===t.windowSummary.parentId)).children.find((e=>"window"===e.type&&e.elementId===t.windowSummary.itemId));e(r)}};return await nr(this).controller.processLocalSubscription(r,t)}async onWindowSelected(e){L(e);const t=nr(this).id,r={action:"selected",eventType:"window",scope:"workspace",scopeId:t,callback:async t=>{await this.refreshReference();const r=this.getBox((e=>e.id===t.windowSummary.parentId)).children.find((e=>"window"===e.type&&e.elementId===t.windowSummary.itemId));e(r)}};return await nr(this).controller.processLocalSubscription(r,t)}async onLockConfigurationChanged(e){L(e);const t=nr(this).id,r={action:"lock-configuration-changed",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e({allowDrop:this.allowDrop,allowDropLeft:this.allowDropLeft,allowDropTop:this.allowDropTop,allowDropRight:this.allowDropRight,allowDropBottom:this.allowDropBottom,allowSystemHibernation:this.allowSystemHibernation,allowExtract:this.allowExtract,allowSplitters:this.allowSplitters,allowWindowReorder:this.allowWindowReorder,allowWorkspaceTabExtract:this.allowWorkspaceTabExtract,allowWorkspaceTabReorder:this.allowWorkspaceTabReorder,showAddWindowButtons:this.showAddWindowButtons,showCloseButton:this.showCloseButton,showEjectButtons:this.showEjectButtons,showSaveButton:this.showSaveButton,showWindowCloseButtons:this.showWindowCloseButtons})}};return await nr(this).controller.processLocalSubscription(r,t)}}const sr=new WeakMap,cr=e=>sr.get(e).manager.getWindowData(e);class dr{constructor(e){sr.set(this,{manager:e})}get id(){return cr(this).config.windowId}get elementId(){return cr(this).id}get type(){return"window"}get frameId(){return cr(this).frame.id}get workspaceId(){return cr(this).workspace.id}get positionIndex(){return cr(this).config.positionIndex}get isMaximized(){return cr(this).config.isMaximized}get isLoaded(){return cr(this).controller.checkIsWindowLoaded(this.id)}get isSelected(){return cr(this).config.isSelected}get focused(){return this.getGdWindow().isFocused}get title(){return cr(this).config.title}get allowExtract(){return cr(this).config.allowExtract}get allowReorder(){return cr(this).config.allowReorder}get showCloseButton(){return cr(this).config.showCloseButton}get width(){return cr(this).config.widthInPx}get height(){return cr(this).config.heightInPx}get minWidth(){return cr(this).config.minWidth}get minHeight(){return cr(this).config.minHeight}get maxWidth(){return cr(this).config.maxWidth}get maxHeight(){return cr(this).config.maxHeight}get workspace(){return cr(this).workspace}get frame(){return cr(this).frame}get parent(){return cr(this).parent}get appName(){return cr(this).config.appName}async forceLoad(){if(this.isLoaded)return;const e=cr(this).controller,t=cr(this).id,r=await e.forceLoadWindow(t);cr(this).config.windowId=r,await this.workspace.refreshReference()}async focus(){const e=cr(this).id,t=cr(this).controller;await t.focusItem(e),await this.workspace.refreshReference()}async close(){const e=cr(this).id,t=cr(this).controller;await t.closeItem(e),await cr(this).parent.removeChild((t=>t.id===e)),await this.workspace.refreshReference()}async setTitle(e){v.runWithException(e);const t=cr(this).id,r=cr(this).controller;await r.setItemTitle(t,e),await this.workspace.refreshReference()}async maximize(){const e=cr(this).id,t=cr(this).controller;await t.maximizeItem(e),await this.workspace.refreshReference()}async restore(){const e=cr(this).id,t=cr(this).controller;await t.restoreItem(e),await this.workspace.refreshReference()}async eject(){if(!this.isLoaded)throw new Error("Cannot eject this window, because it is not loaded yet");const e=cr(this).id,t=await cr(this).controller.ejectWindow(e);return cr(this).config.windowId=t,await this.workspace.refreshReference(),this.getGdWindow()}getGdWindow(){if(!this.isLoaded)throw new Error("Cannot fetch this GD window, because the window is not yet loaded");const e=cr(this).config.windowId;return cr(this).controller.getGDWindow(e)}async moveTo(e){if(!(e instanceof Vt||e instanceof Zt||e instanceof rr))throw new Error("Cannot add to the provided parent, because the provided parent is not an instance of Row, Column or Group");const t=cr(this).id,r=cr(this).controller;if(!await r.getParent((t=>t.id===e.id)))throw new Error("Cannot move the window to the selected parent, because this parent does not exist.");await r.moveWindowTo(t,e.id),await this.workspace.refreshReference()}async lock(e){let t;if("function"==typeof e){t=e({allowExtract:this.allowExtract,allowReorder:this.allowReorder,showCloseButton:this.showCloseButton})}else t=e;const r=void 0===t?void 0:pt.runWithException(t),o=cr(this).id;await cr(this).controller.lockWindow(o,r),await this.workspace.refreshReference()}async setSize(e){const t=wt.runWithException(e);if(!t.width&&!t.height)throw new Error("Expected either width or height to be passed.");const r=cr(this).id,o=cr(this).controller;await o.resizeItem(r,{height:t.height,width:t.width,relative:!1}),await this.workspace.refreshReference()}async onRemoved(e){L(e);const t=cr(this).id,r={callback:async()=>{await this.workspace.refreshReference(),e()},action:"removed",eventType:"window",scope:"window"};return await cr(this).controller.processLocalSubscription(r,t)}async onLockConfigurationChanged(e){L(e);const t=cr(this).id,r={callback:async()=>{await this.workspace.refreshReference(),e({allowExtract:this.allowExtract,allowReorder:this.allowReorder,showCloseButton:this.showCloseButton})},action:"lock-configuration-changed",eventType:"window",scope:"window"};return await cr(this).controller.processLocalSubscription(r,t)}}const lr=new WeakMap,hr=e=>lr.get(e).manager.getFrameData(e);class ur{constructor(e){lr.set(this,{manager:e})}async registerShortcut(e,t){v.runWithException(e),L(t);const r=hr(this).summary.id;return await hr(this).controller.registerShortcut(e,r,t)}get id(){return hr(this).summary.id}get isInitialized(){return hr(this).summary.isInitialized}getBounds(){const e=hr(this).summary.id;return hr(this).controller.getFrameBounds(e)}async resize(e){const t=Ge.runWithException(e),r=hr(this).summary.id;return hr(this).controller.resizeItem(r,t)}async move(e){const t=Ne.runWithException(e),r=hr(this).summary.id;return hr(this).controller.moveFrame(r,t)}focus(){const e=hr(this).summary.id;return hr(this).controller.focusItem(e)}async state(){if(!Ot())throw new Error("State operations are not supported in IO Connect Browser");const e=hr(this).summary.id;return hr(this).controller.getFrameState(e)}async minimize(){if(!Ot())throw new Error("State operations are not supported in IO Connect Browser");const e=hr(this).summary.id;return hr(this).controller.changeFrameState(e,"minimized")}async maximize(){if(!Ot())throw new Error("State operations are not supported in IO Connect Browser");const e=hr(this).summary.id;return hr(this).controller.changeFrameState(e,"maximized")}async restore(){if(!Ot())throw new Error("State operations are not supported in IO Connect Browser");const e=hr(this).summary.id;return hr(this).controller.changeFrameState(e,"normal")}close(){const e=hr(this).summary.id;return hr(this).controller.closeItem(e)}snapshot(){const e=hr(this).summary.id;return hr(this).controller.getSnapshot(e,"frame")}async workspaces(){return hr(this).controller.getWorkspacesByFrameId(this.id)}async getConstraints(){const e=hr(this).controller,t=hr(this).summary.id;return e.getFrameConstraints(t)}async restoreWorkspace(e,t){v.runWithException(e);const r=V.runWithException(t);return hr(this).controller.restoreWorkspace(e,r)}createWorkspace(e,t){const r=Y.runWithException(e),o=P.runWithException(t);return hr(this).controller.createWorkspace(r,o)}async init(e){if(re.runWithException(e),hr(this).summary.isInitialized)throw new Error("The frame has already been initialized");return hr(this).controller.initFrame(this.id,e)}async onClosed(e){L(e);const t=hr(this).summary.id,r={callback:t=>{e({frameId:t.frameSummary.id,frameBounds:t.frameBounds})},action:"closed",eventType:"frame",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onMaximized(e){L(e);const t=hr(this).summary.id,r={callback:()=>{e()},action:"maximized",eventType:"frame",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onMinimized(e){L(e);const t=hr(this).summary.id,r={callback:()=>{e()},action:"minimized",eventType:"frame",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onNormal(e){L(e);const t=hr(this).summary.id,r={callback:()=>{e()},action:"normal",eventType:"frame",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onWorkspaceOpened(e){L(e);const t=hr(this).summary.id,r={callback:async t=>{const r=await hr(this).controller.transformStreamPayloadToWorkspace(t);e(r)},action:"opened",eventType:"workspace",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onWorkspaceSelected(e){L(e);const t=hr(this).summary.id,r={callback:async t=>{const r=await hr(this).controller.getWorkspaceById(t.workspaceSummary.id);e(r)},action:"selected",eventType:"workspace",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onWorkspaceClosed(e){L(e);const t=hr(this).summary.id,r={callback:t=>{e({frameId:t.frameSummary.id,workspaceId:t.workspaceSummary.id,frameBounds:t.frameBounds})},action:"closed",eventType:"workspace",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onWindowAdded(e){L(e);const t=hr(this).summary.id,r={callback:async t=>{const r=(await hr(this).controller.getParent((e=>e.id===t.windowSummary.parentId))).children.find((e=>"window"===e.type&&e.positionIndex===t.windowSummary.config.positionIndex));e(r)},action:"added",eventType:"window",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onWindowRemoved(e){L(e);const t=hr(this).summary.id,r={callback:t=>{const{windowId:r,workspaceId:o,frameId:n}=t.windowSummary.config;e({windowId:r,workspaceId:o,frameId:n})},action:"removed",eventType:"window",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onWindowLoaded(e){L(e);const t=hr(this).summary.id,r={callback:async t=>{const r=(await hr(this).controller.getParent((e=>e.id===t.windowSummary.parentId))).children.find((e=>"window"===e.type&&e.positionIndex===t.windowSummary.config.positionIndex));e(r)},action:"loaded",eventType:"window",scope:"frame"};return await hr(this).controller.processLocalSubscription(r,t)}async onInitializationRequested(e){return L(e),this.isInitialized||e(hr(this).summary.initializationContext),()=>{}}async onFocusChanged(e){L(e);const t=hr(this),{id:r}=t.summary,o={callback:t=>{e({isFocused:t.frameSummary.isFocused})},action:"focus",eventType:"frame",scope:"frame"};return await t.controller.processLocalSubscription(o,r)}}class pr{parentsData=new WeakMap;workspacesData=new WeakMap;windowsData=new WeakMap;framesData=new WeakMap;deleteData(e){e instanceof dr&&this.windowsData.delete(e),e instanceof ar&&this.workspacesData.delete(e),(e instanceof Vt||e instanceof Zt||e instanceof rr)&&this.parentsData.delete(e),e instanceof ur&&this.framesData.delete(e)}setWindowData(e,t){this.windowsData.set(e,t)}setWorkspaceData(e,t){this.workspacesData.set(e,t)}setParentData(e,t){this.parentsData.set(e,t)}setFrameData(e,t){this.framesData.set(e,t)}getWindowData(e){return this.windowsData.get(e)}getWorkspaceData(e){return this.workspacesData.get(e)}getParentData(e){return this.parentsData.get(e)}getFrameData(e){return this.framesData.get(e)}remapChild(e,t){if(e instanceof dr){const r=this.windowsData.get(e);r.parent=t.parent||r.parent,r.config=t.config||r.config}if(e instanceof Vt||e instanceof Zt||e instanceof rr){const r=this.parentsData.get(e);r.parent=t.parent||r.parent,r.config=t.config||r.config,r.children=t.children||r.children}}remapFrame(e,t){this.framesData.get(e).summary=t}remapWorkspace(e,t){const r=this.workspacesData.get(e);r.frame=t.frame||r.frame,r.config=t.config||r.config,r.children=t.children||r.children}}const wr=new WeakMap,mr=(e,t)=>{const r=wr.get(e).manager;return t instanceof ar?r.getWorkspaceData(t):wr.get(e).manager.getParentData(t)};class gr{frameId;workspaceId;positionIndex;constructor(e){wr.set(this,{manager:e})}getId(e){return mr(this,e).id}getPositionIndex(e){return mr(this,e).config.positionIndex}getWorkspaceId(e){const t=mr(this,e);return t.config.workspaceId||t.workspace.id}getFrameId(e){return mr(this,e).frame.id}getAllChildren(e,t){L(t,!0);const r=mr(this,e).children;return void 0===t?r:r.filter(t)}getMyParent(e){return e instanceof ar?e:mr(this,e).parent}getMyFrame(e){return mr(this,e).frame}getMyWorkspace(e){return e instanceof ar?e:mr(this,e).workspace}async addWindow(e,t,r){if(!t.appName&&!t.windowId)throw new Error("The window definition should contain either an appName or a windowId");const o=_.runWithException(t),n=mr(this,e).controller,i=await n.add("window",mr(this,e).id,r,o);if(e instanceof ar)return await e.refreshReference(),e.getWindow((e=>e.elementId===i.itemId));const a=this.getMyWorkspace(e);return await a.refreshReference(),a.getWindow((e=>e.elementId===i.itemId))}async addParent(e,t,r,o){const n=this.transformDefinition(t,o),i=mr(this,e).controller,a=(await i.add("container",mr(this,e).id,r,n)).itemId;if(e instanceof ar)return await e.refreshReference(),e.getBox((e=>e.id===a));const s=this.getMyWorkspace(e);return await s.refreshReference(),s.getBox((e=>e.id===a))}async removeChild(e,t){L(t);const r=this.getAllChildren(e).find(t);r&&(await r.close(),e instanceof ar?await e.refreshReference():await this.getMyWorkspace(e).refreshReference())}async maximize(e){const{controller:t,id:r}=mr(this,e);await t.maximizeItem(r),await this.getMyWorkspace(e.parent).refreshReference()}async restore(e){const{controller:t,id:r}=mr(this,e);await t.restoreItem(r),await this.getMyWorkspace(e.parent).refreshReference()}async close(e){const t=mr(this,e),r=mr(this,e).controller;await r.closeItem(t.id),await this.getMyWorkspace(t.parent).refreshReference()}async lockContainer(e,t){const r=mr(this,e),o=mr(this,e).controller;await o.lockContainer(r.id,e.type,t),await this.getMyWorkspace(r.parent).refreshReference()}getAllowDrop(e){return mr(this,e).config.allowDrop}getAllowDropLeft(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Property allowDropLeft is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropLeft}getAllowDropRight(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Property allowDropRight is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropRight}getAllowDropTop(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Property allowDropTop is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropTop}getAllowDropBottom(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Property allowDropBottom is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropBottom}getAllowDropHeader(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Property allowDropHeader is available only for groups and not on ${e.type} ${e.id}`);return t.config.allowDropHeader}getAllowSplitters(e){const t=mr(this,e);if("group"===t.type)throw new Error(`Cannot get allow splitters from private data ${t.type}`);return t.config.allowSplitters}getAllowExtract(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Cannot get allow extract from private data ${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.allowExtract}getAllowReorder(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Cannot get allow extract from private data ${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.allowReorder}getShowMaximizeButton(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Cannot get show maximize button from private data${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.showMaximizeButton}getShowEjectButton(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Cannot get show eject button from private data${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.showEjectButton}getShowAddWindowButton(e){const t=mr(this,e);if("group"!==t.type)throw new Error(`Cannot get add window button from private data${t.type} with config ${"workspace"!==t.type?t.config.type:""}`);return t.config.showAddWindowButton}getMinWidth(e){return mr(this,e).config.minWidth}getMaxWidth(e){return mr(this,e).config.maxWidth}getMinHeight(e){return mr(this,e).config.minHeight}getMaxHeight(e){return mr(this,e).config.maxHeight}getWidthInPx(e){return mr(this,e).config.widthInPx}getHeightInPx(e){return mr(this,e).config.heightInPx}getIsPinned(e){return mr(this,e).config.isPinned}getIsMaximized(e){return mr(this,e).config.isMaximized}getMaximizationBoundary(e){return mr(this,e).config.maximizationBoundary}async setHeight(e,t){const r=mr(this,e),{controller:o,id:n}=r;await o.resizeItem(n,{height:t}),await this.getMyWorkspace(r.parent).refreshReference()}async setWidth(e,t){const r=mr(this,e),{controller:o,id:n}=r;await o.resizeItem(n,{width:t}),await this.getMyWorkspace(r.parent).refreshReference()}async setSize(e,t,r){const o=mr(this,e),{controller:n,id:i}=o;await n.resizeItem(i,{width:t,height:r}),await this.getMyWorkspace(o.parent).refreshReference()}async setMaximizationBoundary(e,t){const r=mr(this,e),{controller:o,id:n}=r;await o.setMaximizationBoundary(n,t),await this.getMyWorkspace(r.parent).refreshReference()}async bundleTo(e,t){const r=mr(this,e),{controller:o,id:n}=r;await o.bundleItemTo(t,n)}async processLocalSubscription(e,t){return mr(this,e).controller.processLocalSubscription(t,this.getId(e))}transformDefinition(e,t){let r;return void 0===t?r={type:e,children:[]}:t instanceof Nt?r=t.serialize():(void 0===t.type&&(t.type=e),r=K.runWithException(t),r.children=r.children||[]),r}}class fr{ioc;windows;contexts;layouts;constructor(e,t,r,o){this.ioc=e,this.windows=t,this.contexts=r,this.layouts=o}get bridge(){return this.ioc.bridge}get privateDataManager(){return this.ioc.privateDataManager}checkIsWindowLoaded(e){return!!e&&this.windows.list().some((t=>t.id===e))}async createWorkspace(e){const t=await this.bridge.send(zt.createWorkspace.name,e),r={summary:t.frameSummary},o={frame:this.ioc.getModel("frame",r),snapshot:t};return this.ioc.getModel("workspace",o)}async createEmptyFrame(e){const t={summary:await this.bridge.send(zt.createFrame.name,e)};return this.ioc.getModel("frame",t)}async initFrame(e,t){await this.bridge.send(zt.initFrame.name,{frameId:e,...t})}async restoreWorkspace(e,t){const r=await this.bridge.send(zt.openWorkspace.name,{name:e,restoreOptions:t}),o={summary:await this.bridge.send(zt.getFrameSummary.name,{itemId:r.config.frameId})},n={frame:this.ioc.getModel("frame",o),snapshot:r};return this.ioc.getModel("workspace",n)}async add(e,t,r,o){let n;const i={definition:o,parentId:t,parentType:r};if("window"===e)n=zt.addWindow.name;else{if("container"!==e)throw new Error(`Unrecognized add type: ${e}`);n=zt.addContainer.name}return await this.bridge.send(n,i)}async getFrame(e){const t={summary:await this.bridge.send(zt.getFrameSummary.name,{itemId:e})};return this.ioc.getModel("frame",t)}getFrames(e,t){return e.reduce(((e,r)=>{const o={summary:r},n=this.ioc.getModel("frame",o);return t&&!t(n)||e.push(n),e}),[])}getAllWorkspaceSummaries(...e){return e.reduce(((e,t)=>(e.push(...t.summaries),e)),[]).map((e=>Object.assign({},{id:e.id,width:e.config.widthInPx,height:e.config.heightInPx},e.config)))}handleOnSaved(e){const t=t=>{"Workspace"===t.type&&e(t)},r=this.layouts.onAdded(t),o=this.layouts.onChanged(t);return()=>{r(),o()}}handleOnRemoved(e){return this.layouts.onRemoved((t=>{"Workspace"===t.type&&e(t)}))}async importLayouts(e,t){await this.layouts.import(e,t)}async transformStreamPayloadToWorkspace(e){const t={summary:e.frameSummary},r={frame:this.ioc.getModel("frame",t),snapshot:e.workspaceSnapshot||await this.bridge.send(zt.getWorkspaceSnapshot.name,{itemId:e.workspaceSummary.id})};return this.ioc.getModel("workspace",r)}async fetchWorkspace(e){const t=await this.bridge.send(zt.getWorkspaceSnapshot.name,{itemId:e}),r={summary:t.frameSummary},o={frame:this.ioc.getModel("frame",r),snapshot:t};return this.ioc.getModel("workspace",o)}async bundleWorkspaceTo(e,t){await this.bridge.send(zt.bundleWorkspace.name,{type:e,workspaceId:t})}async bundleItemTo(e,t){if(!await this.isOperationSupported(zt.bundleItem.name))throw new Error(`Operation ${zt.bundleItem.name} is not supported. Ensure that you are running the latest version of all packages`);await this.bridge.send(zt.bundleItem.name,{type:e,itemId:t})}getWorkspaceContext(e){const t=`___workspace___${e}`;return this.contexts.get(t)}setWorkspaceContext(e,t){const r=`___workspace___${e}`;return this.contexts.set(r,t)}updateWorkspaceContext(e,t){const r=`___workspace___${e}`;return this.contexts.update(r,t)}subscribeWorkspaceContextUpdated(e,t){const r=`___workspace___${e}`;return this.contexts.subscribe(r,t)}async restoreItem(e){await this.bridge.send(zt.restoreItem.name,{itemId:e})}async maximizeItem(e){await this.bridge.send(zt.maximizeItem.name,{itemId:e})}async focusItem(e){await this.bridge.send(zt.focusItem.name,{itemId:e})}async closeItem(e){await this.bridge.send(zt.closeItem.name,{itemId:e})}async resizeItem(e,t){await this.bridge.send(zt.resizeItem.name,Object.assign({},{itemId:e},t))}async setMaximizationBoundary(e,t){await this.bridge.send(zt.setMaximizationBoundary.name,Object.assign({},{itemId:e},t))}async showWorkspaceLoadingAnimation(e){await this.bridge.send(zt.showLoadingAnimation.name,{itemId:e,type:"workspace"})}async hideWorkspaceLoadingAnimation(e){await this.bridge.send(zt.hideLoadingAnimation.name,{itemId:e,type:"workspace"})}async moveFrame(e,t){await this.bridge.send(zt.moveFrame.name,Object.assign({},{itemId:e},t))}getGDWindow(e){return this.windows.list().find((t=>t.id===e))}async forceLoadWindow(e){return(await this.bridge.send(zt.forceLoadWindow.name,{itemId:e})).windowId}async ejectWindow(e){return await this.bridge.send(zt.ejectWindow.name,{itemId:e})}async moveWindowTo(e,t){await this.bridge.send(zt.moveWindowTo.name,{itemId:e,containerId:t})}async getSnapshot(e,t){let r;return"workspace"===t?r=await this.bridge.send(zt.getWorkspaceSnapshot.name,{itemId:e}):"frame"===t&&(r=await this.bridge.send(zt.getFrameSnapshot.name,{itemId:e})),r}async setItemTitle(e,t){await this.bridge.send(zt.setItemTitle.name,{itemId:e,title:t})}refreshChildren(e){const{parent:t,children:r,existingChildren:o,workspace:n}=e;if(t instanceof dr||"window"===t.type)return;const i=r.map((e=>{let r=o.find((t=>"window"===t.type?t.elementId===e.id:t.id===e.id));if(r)this.privateDataManager.remapChild(r,{parent:t,children:[],config:e.config});else{let o;o="window"===e.type?{id:e.id,parent:t,frame:n.frame,workspace:n,config:e.config}:{id:e.id,parent:t,frame:n.frame,workspace:n,config:e.config,children:[]},r=this.ioc.getModel(e.type,o)}return"window"!==e.type&&this.refreshChildren({workspace:n,existingChildren:o,children:e.children,parent:r}),r}));return t instanceof ar||this.privateDataManager.remapChild(t,{children:i}),i}iterateFindChild(e,t){let r=e.find((e=>t(e)));return r||(e.some((e=>!(e instanceof dr)&&(r=this.iterateFindChild(e.children,t),!!r||void 0))),r)}iterateFilterChildren(e,t){const r=e.filter((e=>t(e))),o=e.reduce(((e,r)=>(r instanceof dr||e.push(...this.iterateFilterChildren(r.children,t)),e)),[]);return r.push(...o),r}notifyWindowAdded(e){return new Promise((t=>{if(this.windows.list().some((t=>t.id===e)))return t();const r=this.windows.onWindowAdded((o=>{o.id===e&&(r&&r(),t())}))}))}async hibernateWorkspace(e){await this.bridge.send(zt.hibernateWorkspace.name,{workspaceId:e})}async resumeWorkspace(e){await this.bridge.send(zt.resumeWorkspace.name,{workspaceId:e})}async lockWorkspace(e,t){await this.bridge.send(zt.lockWorkspace.name,{workspaceId:e,config:t})}async lockWindow(e,t){await this.bridge.send(zt.lockWindow.name,{windowPlacementId:e,config:t})}async lockContainer(e,t,r){await this.bridge.send(zt.lockContainer.name,{itemId:e,type:t,config:r})}async pinWorkspace(e,t){await this.bridge.send(zt.pinWorkspace.name,{workspaceId:e,icon:t})}async unpinWorkspace(e){await this.bridge.send(zt.unpinWorkspace.name,{workspaceId:e})}async getWorkspaceIcon(e){return(await this.bridge.send(zt.getWorkspaceIcon.name,{workspaceId:e})).icon}setWorkspaceIcon(e,t){return this.bridge.send(zt.setWorkspaceIcon.name,{workspaceId:e,icon:t})}async getPlatformFrameId(){try{return await this.bridge.send(zt.getPlatformFrameId.name,{})}catch(e){return{}}}async isOperationSupported(e){return Ot()?{isSupported:!0}:await this.bridge.send(zt.operationCheck.name,{operation:e})}}class yr{bridge;base;shortcutsController;constructor(e,t,r){this.bridge=e,this.base=t,this.shortcutsController=r}checkIsWindowLoaded(e){return this.base.checkIsWindowLoaded(e)}async checkIsInSwimlane(e){return(await this.bridge.send(zt.isWindowInWorkspace.name,{itemId:e})).inWorkspace}async createWorkspace(e,t){const r=Object.assign({},e,{saveConfig:t});return await this.base.createWorkspace(r)}async createEmptyFrame(e){return await this.base.createEmptyFrame(e)}async initFrame(e,t){return this.base.initFrame(e,t)}async restoreWorkspace(e,t){if(!(await this.getLayoutSummaries()).some((t=>t.name===e)))throw new Error(`This layout: ${e} cannot be restored, because it doesn't exist.`);if(t?.frameId){if(!(await this.bridge.send(zt.getAllFramesSummaries.name)).summaries.some((e=>e.id===t.frameId)))throw new Error(`Cannot reuse the frame with id: ${t.frameId}, because there is no frame with that ID found`)}return await this.base.restoreWorkspace(e,t)}async add(e,t,r,o){return await this.base.add(e,t,r,o)}processLocalSubscription(e,t){return Ot()?this.handleEnterpriseLocalSubscription(e,t):this.handleCoreLocalSubscription(e,t)}processGlobalSubscription(e,t,r){return Ot()?this.handleEnterpriseGlobalSubscription(e,t,r):this.handleCoreGlobalSubscription(e,t,r)}async getFrame(e){if(e.windowId)return await this.base.getFrame(e.windowId);if(e.predicate)return(await this.getFrames(e.predicate))[0];throw new Error(`The provided selector is not valid: ${JSON.stringify(e)}`)}async getFrames(e){const t=await this.bridge.send(zt.getAllFramesSummaries.name);return this.base.getFrames(t.summaries,e)}getWorkspaceById(e){return this.base.fetchWorkspace(e)}async getWorkspaceByWindowId(e){return Ot()?this.base.fetchWorkspace(e):(await this.getWorkspaces((t=>!!t.getWindow((t=>t.id===e)))))[0]}transformStreamPayloadToWorkspace(e){return this.base.transformStreamPayloadToWorkspace(e)}async getWorkspace(e){let t;return await this.iterateWorkspaces(((r,o)=>{e(r)&&(t=r,o())})),t}async getWorkspaces(e){const t=[];return await this.iterateWorkspaces((r=>{e&&!e(r)||t.push(r)})),t}async getWorkspacesByFrameId(e){const t=(await this.getAllWorkspaceSummaries()).filter((t=>t.frameId===e));return await Promise.all(t.map((e=>this.base.fetchWorkspace(e.id))))}async getAllWorkspaceSummaries(){const e=await this.bridge.send(zt.getAllWorkspacesSummaries.name,{});return this.base.getAllWorkspaceSummaries(e)}async getWindow(e){let t;return await this.iterateWorkspaces(((r,o)=>{const n=r.getWindow(e);n&&(t=n,o())})),t}async getParent(e){let t;return await this.iterateWorkspaces(((r,o)=>{const n=r.getBox(e);n&&(t=n,o())})),t}async getLayoutSummaries(){return(await this.bridge.send(zt.getAllLayoutsSummaries.name)).summaries}async deleteLayout(e){await this.bridge.send(zt.deleteLayout.name,{name:e})}async exportLayout(e){return(await this.bridge.send(zt.exportAllLayouts.name)).layouts.reduce(((t,r)=>(e&&!e(r)||t.push(r),t)),[])}async saveLayout(e){return await this.bridge.send(zt.saveLayout.name,e)}async importLayouts(e,t){if(Ot())try{await this.bridge.send(zt.importLayouts.name,{layouts:e,mode:t})}catch(r){await Promise.all(e.map((e=>this.bridge.send(zt.importLayout.name,{layout:e,mode:t}))))}else await this.base.importLayouts(e,t)}handleOnSaved(e){return this.base.handleOnSaved(e)}handleOnRemoved(e){return this.base.handleOnRemoved(e)}async bundleWorkspaceTo(e,t){return await this.base.bundleWorkspaceTo(e,t)}async bundleItemTo(e,t){return await this.base.bundleItemTo(e,t)}getWorkspaceContext(e){return this.base.getWorkspaceContext(e)}setWorkspaceContext(e,t){return this.base.setWorkspaceContext(e,t)}updateWorkspaceContext(e,t){return this.base.updateWorkspaceContext(e,t)}subscribeWorkspaceContextUpdated(e,t){return this.base.subscribeWorkspaceContextUpdated(e,t)}async restoreItem(e){return await this.base.restoreItem(e)}async maximizeItem(e){return await this.base.maximizeItem(e)}async focusItem(e){return await this.base.focusItem(e)}async changeFrameState(e,t){await this.bridge.send(zt.changeFrameState.name,{frameId:e,requestedState:t})}async getFrameBounds(e){return(await this.bridge.send(zt.getFrameBounds.name,{itemId:e})).bounds}async getFrameState(e){return(await this.bridge.send(zt.getFrameState.name,{itemId:e})).state}async closeItem(e){return await this.base.closeItem(e)}async resizeItem(e,t){return await this.base.resizeItem(e,t)}async setMaximizationBoundary(e,t){return await this.base.setMaximizationBoundary(e,t)}async showWorkspaceLoadingAnimation(e){return await this.base.showWorkspaceLoadingAnimation(e)}async hideWorkspaceLoadingAnimation(e){return await this.base.hideWorkspaceLoadingAnimation(e)}async moveFrame(e,t){return await this.base.moveFrame(e,t)}getGDWindow(e){return this.base.getGDWindow(e)}async forceLoadWindow(e){const t=await this.base.forceLoadWindow(e);return await this.base.notifyWindowAdded(t),t}async ejectWindow(e){const t=(await this.base.ejectWindow(e)).windowId;return await this.base.notifyWindowAdded(t),t}async moveWindowTo(e,t){return await this.base.moveWindowTo(e,t)}async getSnapshot(e,t){return await this.base.getSnapshot(e,t)}async setItemTitle(e,t){return await this.base.setItemTitle(e,t)}flatChildren(e){return e.reduce(((e,t)=>(e.push(t),"window"!==t.type&&e.push(...this.flatChildren(t.children)),e)),[])}refreshChildren(e){return this.base.refreshChildren(e)}iterateFindChild(e,t){return this.base.iterateFindChild(e,t)}iterateFilterChildren(e,t){return this.base.iterateFilterChildren(e,t)}hibernateWorkspace(e){return this.base.hibernateWorkspace(e)}resumeWorkspace(e){return this.base.resumeWorkspace(e)}lockWorkspace(e,t){return this.base.lockWorkspace(e,t)}lockWindow(e,t){return this.base.lockWindow(e,t)}lockContainer(e,t,r){return this.base.lockContainer(e,t,r)}pinWorkspace(e,t){return this.base.pinWorkspace(e,t)}unpinWorkspace(e){return this.base.unpinWorkspace(e)}getWorkspaceIcon(e){return this.base.getWorkspaceIcon(e)}setWorkspaceIcon(e,t){return this.base.setWorkspaceIcon(e,t)}async getFrameConstraints(e){const t=await this.getSnapshot(e,"frame");return{minWidth:t.config.minWidth,maxWidth:t.config.maxWidth,minHeight:t.config.minHeight,maxHeight:t.config.maxHeight}}registerShortcut(e,t,r){return this.shortcutsController.registerShortcut(e,t,r)}getPlatformFrameId(){return this.base.getPlatformFrameId()}async handleCoreLocalSubscription(e,t){if(await this.bridge.createCoreEventSubscription(),e.scopeId=e.scopeId||t,"window"===e.eventType&&"loaded"===e.action){const t=e.callback,r=async e=>{await this.base.notifyWindowAdded(e.windowSummary.config.windowId),t(e)};e.callback=r}return this.bridge.handleCoreSubscription(e)}handleEnterpriseLocalSubscription(e,t){if(e.scopeId=e.scopeId||t,"window"===e.eventType&&"loaded"===e.action){const t=e.callback,r=async e=>{await this.base.notifyWindowAdded(e.windowSummary.config.windowId),t(e)};e.callback=r}return this.bridge.subscribe(e)}async handleCoreGlobalSubscription(e,t,r){await this.bridge.createCoreEventSubscription();const o={eventType:t,callback:e,action:r,scope:"global"};if("window"===t&&"loaded"===r){const t=async t=>{await this.base.notifyWindowAdded(t.windowSummary.config.windowId),e(t)};o.callback=t}return this.bridge.handleCoreSubscription(o)}handleEnterpriseGlobalSubscription(e,t,r){const o={eventType:t,callback:e,action:r,scope:"global"};if("window"===t&&"loaded"===r){const t=async t=>{await this.base.notifyWindowAdded(t.windowSummary.config.windowId),e(t)};o.callback=t}return this.bridge.subscribe(o)}async iterateWorkspaces(e){let t=!1;const r=()=>{t=!0},o=await this.getAllWorkspaceSummaries();for(const n of o){if(t)return;e(await this.base.fetchWorkspace(n.id),r)}}}class kr{bridge;_shortcuts=r();constructor(e){this.bridge=e,this.bridge.onOperation(((e,t)=>{if(e.operation===Ft.shortcutClicked.name){const t=e.data;this._shortcuts.execute(`${t.frameId}-${t.shortcut}`)}}))}async registerShortcut(e,t,r){await this.bridge.send(zt.registerShortcut.name,{shortcut:e,frameId:t});const o=this._shortcuts.add(`${t}-${e}`,r);return()=>{o(),this.bridge.send(zt.unregisterShortcut.name,{shortcut:e,frameId:t})}}}class br{agm;windows;layouts;contexts;_controllerInstance;_bridgeInstance;_transportInstance;_privateDataManagerInstance;_parentBaseInstance;_baseController;_shortcutsController;constructor(e,t,r,o){this.agm=e,this.windows=t,this.layouts=r,this.contexts=o}get baseController(){return this._baseController||(this._baseController=new fr(this,this.windows,this.contexts,this.layouts)),this._baseController}get controller(){return this._controllerInstance||(this._controllerInstance=new yr(this.bridge,this.baseController,this.shortcutsController)),this._controllerInstance}get shortcutsController(){return this._shortcutsController||(this._shortcutsController=new kr(this.bridge)),this._shortcutsController}get bridge(){return this._bridgeInstance||(this._bridgeInstance=new $t(this.transport,r())),this._bridgeInstance}get transport(){return this._transportInstance||(this._transportInstance=new jt(this.agm,r())),this._transportInstance}get privateDataManager(){return this._privateDataManagerInstance||(this._privateDataManagerInstance=new pr),this._privateDataManagerInstance}get parentBase(){return this._parentBaseInstance||(this._parentBaseInstance=new gr(this.privateDataManager)),this._parentBaseInstance}async initiate(e){await this.transport.initiate(e)}getModel(e,t){switch(e){case"frame":{const e=new ur(this.privateDataManager),{summary:r}=t,o={summary:r,controller:this.controller};return this.privateDataManager.setFrameData(e,o),e}case"window":{const{id:e,parent:r,frame:o,workspace:n,config:i}=t,a={type:"window",controller:this.controller,config:i,id:e,parent:r,frame:o,workspace:n},s=new dr(this.privateDataManager);return this.privateDataManager.setWindowData(s,a),s}case"row":case"column":case"group":{const{id:r,children:o,parent:n,frame:i,workspace:a,config:s}=t,c="column"===e?new Zt(this.parentBase):"row"===e?new Vt(this.parentBase):new rr(this.parentBase),d=this.buildChildren(o,i,a,c),l={id:r,parent:n,frame:i,workspace:a,config:s,type:e,controller:this.controller,children:d};return this.privateDataManager.setParentData(c,l),c}case"workspace":{const{snapshot:e,frame:r}=t,o=new ar(this.privateDataManager),n=this.buildChildren(e.children,r,o,o),i={id:e.id,type:"workspace",config:e.config,base:this.parentBase,controller:this.controller,children:n,frame:r,ioc:this};return this.privateDataManager.setWorkspaceData(o,i),o}default:throw new Error(`Unrecognized type: ${e}`)}}getBuilder(e){e.definition=e.definition||{},Array.isArray(e.definition.children)||(e.definition.children=[]);const t=new Jt(this.getBuilder.bind(this));switch(e.type){case"workspace":return new Kt(e.definition,t,this.controller);case"row":case"column":case"group":return e.definition.type=e.type,new Nt(e.definition,t);default:throw new Error(`Unexpected Builder creation error, provided config: ${JSON.stringify(e)}`)}}buildChildren(e,t,r,o){return e.map((e=>{switch(e.type){case"window":return this.getModel("window",{id:e.id,config:e.config,frame:t,workspace:r,parent:o});case"column":case"row":case"group":return this.getModel(e.type,{id:e.id,config:e.config,children:e.children,frame:t,workspace:r,parent:o});default:throw new Error(`Unsupported child type: ${e.type}`)}}))}}const Wr=async e=>{const t=new br(e.agm,e.windows,e.layouts,e.contexts),r=e.interop.instance.windowId;await t.initiate(r),e.workspaces=((e,t)=>{const r=t.controller,o=async e=>(L(e,!0),r.getFrames(e)),n=async e=>(L(e),await r.processGlobalSubscription((r=>{const o={summary:r.frameSummary},n=t.getModel("frame",o);e(n)}),"frame","opened"));return{inWorkspace:()=>{const t=e.windows.my().id;if(!t)throw new Error("Cannot get my frame, because my id is undefined.");return r.checkIsInSwimlane(t)},getBuilder:e=>{const r=ne.runWithException(e);return t.getBuilder(r)},getMyFrame:async()=>{const t=e.windows.my().id;if(!t)throw new Error("Cannot get my frame, because my id is undefined.");if(!await r.checkIsInSwimlane(t))throw new Error("Cannot fetch your frame, because this window is not in a workspace");return r.getFrame({windowId:t})},getFrame:async e=>(L(e),r.getFrame({predicate:e})),getAllFrames:o,getAllWorkspacesSummaries:()=>r.getAllWorkspaceSummaries(),getMyWorkspace:async()=>{const t=e.windows.my().id;if(!t)throw new Error("Cannot get my workspace, because my id is undefined.");if(!await r.checkIsInSwimlane(t))throw new Error("Cannot fetch your workspace, because this window is not in a workspace");return await r.getWorkspaceByWindowId(t)},getWorkspace:async e=>(L(e),(await r.getWorkspaces(e))[0]),getWorkspaceById:async e=>(v.runWithException(e),r.getWorkspaceById(e)),getAllWorkspaces:e=>(L(e,!0),r.getWorkspaces(e)),getWindow:async e=>(L(e),r.getWindow(e)),getBox:async e=>(L(e),r.getParent(e)),restoreWorkspace:async(e,t)=>{v.runWithException(e);const o=V.runWithException(t);return r.restoreWorkspace(e,o)},createWorkspace:async(e,t)=>{const o=Y.runWithException(e),n=P.runWithException(t);return r.createWorkspace(o,n)},createEmptyFrame:async e=>{const t=te.runWithException(e);return r.createEmptyFrame(t??{})},waitForFrame:async e=>(v.runWithException(e),new Promise(((t,r)=>{let i=()=>{};n((r=>{r.id===e&&(t(r),i())})).then((e=>(i=e,o()))).then((r=>{const o=r.find((t=>t.id===e));o&&(t(o),i())})).catch(r)}))),layouts:{getSummaries:()=>r.getLayoutSummaries(),delete:async e=>(v.runWithException(e),r.deleteLayout(e)),export:async e=>(L(e,!0),r.exportLayout(e)),import:async(e,t="replace")=>{if(!Array.isArray(e))throw new Error(`The provided layouts argument is not an array: ${JSON.stringify(e)}`);return e.forEach((e=>Se.runWithException(e))),r.importLayouts(e,t)},save:async e=>{const t=lt.runWithException(e);return r.saveLayout(t)},onSaved:async e=>(L(e),r.handleOnSaved(e)),onRemoved:async e=>(L(e),r.handleOnRemoved(e))},onFrameOpened:n,onFrameClosed:async e=>(L(e),await r.processGlobalSubscription((t=>{e({frameId:t.frameSummary.id,frameBounds:t.frameBounds})}),"frame","closed")),onWorkspaceOpened:async e=>(L(e),await r.processGlobalSubscription((async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)}),"workspace","opened")),onWorkspaceClosed:async e=>(L(e),await r.processGlobalSubscription((t=>{e({frameId:t.frameSummary.id,workspaceId:t.workspaceSummary.id,frameBounds:t.frameBounds})}),"workspace","closed")),onWorkspaceHibernated:async e=>(L(e),await r.processGlobalSubscription((async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)}),"workspace","hibernated")),onWorkspaceResumed:async e=>(L(e),await r.processGlobalSubscription((async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)}),"workspace","resumed")),onWindowAdded:async e=>(L(e),await r.processGlobalSubscription((async o=>{const n=await r.getSnapshot(o.windowSummary.config.workspaceId,"workspace"),i={summary:n.frameSummary},a={frame:t.getModel("frame",i),snapshot:n},s=t.getModel("workspace",a).getBox((e=>e.id===o.windowSummary.parentId)).children.find((e=>"window"===e.type&&e.elementId===o.windowSummary.itemId));e(s)}),"window","added")),onWindowLoaded:async e=>(L(e),await r.processGlobalSubscription((async o=>{const n=await r.getSnapshot(o.windowSummary.config.workspaceId,"workspace"),i={summary:n.frameSummary},a={frame:t.getModel("frame",i),snapshot:n},s=t.getModel("workspace",a).getWindow((e=>e.id&&e.id===o.windowSummary.config.windowId));e(s)}),"window","loaded")),onWindowRemoved:async e=>(L(e),await r.processGlobalSubscription((t=>{const{windowId:r,workspaceId:o,frameId:n}=t.windowSummary.config;e({windowId:r,workspaceId:o,frameId:n})}),"window","removed")),onWindowMaximized:async e=>(L(e),await r.processGlobalSubscription((async o=>{const n=await r.getSnapshot(o.windowSummary.config.workspaceId,"workspace"),i={summary:n.frameSummary},a={frame:t.getModel("frame",i),snapshot:n},s=t.getModel("workspace",a).getBox((e=>e.id===o.windowSummary.parentId)).children.find((e=>"window"===e.type&&e.elementId===o.windowSummary.itemId));e(s)}),"window","maximized")),onWindowRestored:async e=>(L(e),await r.processGlobalSubscription((async o=>{const n=await r.getSnapshot(o.windowSummary.config.workspaceId,"workspace"),i={summary:n.frameSummary},a={frame:t.getModel("frame",i),snapshot:n},s=t.getModel("workspace",a).getBox((e=>e.id===o.windowSummary.parentId)).children.find((e=>"window"===e.type&&e.elementId===o.windowSummary.itemId));e(s)}),"window","restored")),onWindowSelected:async e=>(L(e),await r.processGlobalSubscription((async o=>{const n=await r.getSnapshot(o.windowSummary.config.workspaceId,"workspace"),i={summary:n.frameSummary},a={frame:t.getModel("frame",i),snapshot:n},s=t.getModel("workspace",a).getBox((e=>e.id===o.windowSummary.parentId)).children.find((e=>"window"===e.type&&e.elementId===o.windowSummary.itemId));e(s)}),"window","selected")),version:"3.5.1"}})(e,t)};return"undefined"!=typeof window&&(window.IOWorkspaces=Wr),Wr}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interopio/workspaces-api",
3
- "version": "3.4.4",
3
+ "version": "3.5.1",
4
4
  "description": "IOConnect Workspaces API",
5
5
  "main": "dist/workspaces.umd.js",
6
6
  "module": "dist/workspaces.es.js",
@@ -33,7 +33,7 @@
33
33
  "access": "public"
34
34
  },
35
35
  "devDependencies": {
36
- "@interopio/core": "^6.4.3"
36
+ "@interopio/core": "^6.5.0"
37
37
  },
38
- "gitHead": "2512354dbb6e215a85d9a2e2394fbc2438448e52"
38
+ "gitHead": "f0377dc3f5d20d70981c8c8c28f85be00b359152"
39
39
  }
package/workspaces.d.ts CHANGED
@@ -252,7 +252,10 @@ export namespace IOConnectWorkspaces {
252
252
  /** Position of the workspace in relation to it's siblings in the frame. */
253
253
  position?: number;
254
254
 
255
- /** Provides the opportunity to open a workspace with no tab header */
255
+ /**
256
+ * Provides the opportunity to open a workspace with no tab header
257
+ * @default false
258
+ */
256
259
  noTabHeader?: boolean;
257
260
 
258
261
  /** Used for replacing the specified workspace instead of creating a new one */
@@ -261,53 +264,99 @@ export namespace IOConnectWorkspaces {
261
264
  /** Controls when the windows inside this workspace should load when the workspace is created or restored */
262
265
  loadStrategy?: LoadingStrategy;
263
266
 
264
- /** Controls the users ability to drop outside windows in the workspace */
267
+ /**
268
+ * Controls the users ability to drop outside windows in the workspace
269
+ * @default true
270
+ */
265
271
  allowDrop?: boolean;
266
272
 
267
- /** Controls the users ability to drop windows in the left-most zone of the workspace */
273
+ /**
274
+ * Controls the users ability to drop windows in the left-most zone of the workspace
275
+ * @default true
276
+ */
268
277
  allowDropLeft?: boolean;
269
278
 
270
- /** Controls the users ability to drop windows in the top-most zone of the workspace */
279
+ /**
280
+ * Controls the users ability to drop windows in the top-most zone of the workspace
281
+ * @default true
282
+ */
271
283
  allowDropTop?: boolean;
272
284
 
273
- /** Controls the users ability to drop windows in the right-most zone of the workspace */
285
+ /**
286
+ * Controls the users ability to drop windows in the right-most zone of the workspace
287
+ * @default true
288
+ */
274
289
  allowDropRight?: boolean;
275
290
 
276
- /** Controls the users ability to drop windows in the bottom-most zone of the workspace */
291
+ /**
292
+ * Controls the users ability to drop windows in the bottom-most zone of the workspace
293
+ * @default true
294
+ */
277
295
  allowDropBottom?: boolean;
278
296
 
279
- /** Controls the users ability to extract windows from the workspace */
297
+ /**
298
+ * Controls the users ability to extract windows from the workspace
299
+ * @default true
300
+ */
280
301
  allowExtract?: boolean;
281
302
 
282
- /** Control the users ability to reorder windows in the workspace */
303
+ /**
304
+ * Control the users ability to reorder windows in the workspace
305
+ * @default true
306
+ */
283
307
  allowWindowReorder?: boolean;
284
308
 
285
- /** Controls the visibility of the save workspace button located in the workspace tab */
309
+ /**
310
+ * Controls the visibility of the save workspace button located in the workspace tab
311
+ * @default true
312
+ */
286
313
  showSaveButton?: boolean;
287
314
 
288
- /** Controls whether a workspace tab can be reordered in the frame */
315
+ /**
316
+ * Controls whether a workspace tab can be reordered in the frame
317
+ * @default true
318
+ */
289
319
  allowWorkspaceTabReorder?: boolean;
290
320
 
291
- /** Controls whether a workspace tab can be extracted from the frame (available only for **io.Connect Desktop**). */
321
+ /**
322
+ * Controls whether a workspace tab can be extracted from the frame (available only for **io.Connect Desktop**).
323
+ * @default true
324
+ */
292
325
  allowWorkspaceTabExtract?: boolean;
293
326
 
294
- /** Controls the visibility of the close button located in the workspaces tab */
327
+ /**
328
+ * Controls the visibility of the close button located in the workspaces tab
329
+ * @default true
330
+ */
295
331
  showCloseButton?: boolean;
296
332
 
297
- /** Prevents the splitters for being draggable, so the windows cannot be resized */
333
+ /**
334
+ * Prevents the splitters for being draggable, so the windows cannot be resized
335
+ * @default true
336
+ */
298
337
  allowSplitters?: boolean;
299
338
 
300
- /** Controls the visibility of all close button located in the windows' tab elements */
339
+ /**
340
+ * Controls the visibility of all close button located in the windows' tab elements
341
+ * @default true
342
+ */
301
343
  showWindowCloseButtons?: boolean;
302
344
 
303
- /** Controls the visibility of all eject buttons located in the groups' headers */
345
+ /**
346
+ * Controls the visibility of all eject buttons located in the groups' headers
347
+ * @default true
348
+ */
304
349
  showEjectButtons?: boolean;
305
350
 
306
- /** Controls the visibility of all the add window buttons (the ones with the plus icon) located in the group headers */
351
+ /**
352
+ * Controls the visibility of all the add window buttons (the ones with the plus icon) located in the group headers
353
+ * @default true
354
+ */
307
355
  showAddWindowButtons?: boolean;
308
356
 
309
357
  /**
310
358
  * Controls whether the workspace will be opened in a pinned or in a normal state
359
+ * @default false
311
360
  */
312
361
  isPinned?: boolean;
313
362
 
@@ -318,6 +367,7 @@ export namespace IOConnectWorkspaces {
318
367
 
319
368
  /**
320
369
  * Controls whether the workspace will be focused or not in the frame when opened
370
+ * @default true
321
371
  */
322
372
  isSelected?: boolean;
323
373