@interopio/workspaces-api 3.5.5 → 3.5.7

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.
@@ -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("")},w=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)},p=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(w("."+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 w("["+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(w("["+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(w("."+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"}:w(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=p.string,g=p.number,f=p.boolean,y=p.anyJson;p.unknownJson;var k=p.constant,b=p.object,W=p.array;p.tuple,p.dict;var I=p.optional,x=p.oneOf;p.union;var S=p.intersection;p.withDefault,p.valueAt,p.succeed,p.fail;var D=p.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=x(k("keepInside"),k("autoEject")),M=b({inWorkspace:f()}),T=x(k("workspace"),k("row"),k("column"),k("group")),R=x(k("row"),k("column"),k("group")),A=x(k("maximized"),k("minimized"),k("normal")),L=x(k("workspace")),P=(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}`)},F=I(b({saveLayout:I(f())})),z=b({name:v}),H=b({minWidth:I(g()),maxWidth:I(g()),minHeight:I(g()),maxHeight:I(g()),allowExtract:I(f()),allowReorder:I(f()),showCloseButton:I(f())}),$=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())}),O=b({minHeight:I(g()),maxHeight:I(g()),allowDrop:I(f()),allowSplitters:I(f()),isPinned:I(f()),maximizationBoundary:I(f())}),_=b({minWidth:I(g()),maxWidth:I(g()),allowDrop:I(f()),allowSplitters:I(f()),isPinned:I(f()),maximizationBoundary:I(f())}),j=b({type:I(k("window")),appName:I(v),windowId:I(v),context:I(y()),config:I(H)}),G=b({type:k("window"),appName:I(v),windowId:I(v),context:I(y()),config:I(H)}),N=I(b({type:I(R),children:I(D((()=>W(x(j,N))))),config:I(y())})),J=b({type:k("column"),children:I(D((()=>W(x(G,q))))),config:I(_)}),U=b({type:k("row"),children:I(D((()=>W(x(G,q))))),config:I(O)}),K=b({type:k("group"),children:I(D((()=>W(x(G,q))))),config:I($)}),q=x(K,J,U);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)}),V=x(k("direct"),k("delayed"),k("lazy")),X=I(b({app:I(v),context:I(y()),loadingStrategy:I(V),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())})),Y=b({name:v,restoreOptions:I(X)}),Z=b({children:I(W(x(j,q))),context:I(y()),config:I(b({title:I(v),position:I(C),isFocused:I(f()),noTabHeader:I(f()),reuseWorkspaceId:I(v),loadingStrategy:I(V),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),windowDragMode:I(B)})),frame:I(b({activate:I(f()),reuseFrameId:I(v),applicationName:I(v),newFrame:I(x(f(),Q))}))}),ee=b({workspaceId:v}),te=b({name:v,restoreOptions:I(X)}),re=I(b({applicationName:I(m()),frameConfig:I(Q),context:I(b()),layoutComponentId:I(v)})),oe=b({workspaces:W(x(I(Z),I(te)))}),ne=b({frameId:v,workspaces:W(x(Z,te))}),ie=b({type:T,definition:I(x(Z,N))}),ae=S(Z,b({saveConfig:I(b({saveLayout:I(f())}))})),se=b({itemId:v}),ce=b({context:I(b())}),de=b({id:v,isFocused:I(f()),isInitialized:I(f()),initializationContext:I(ce)});b({type:R,id:v,frameId:v,workspaceId:v,positionIndex:g()});const le=x(k("frame"),k("workspace"),k("container"),k("window")),he=b({type:le,branch:v}),ue=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")),we=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()),windowDragMode:I(B)}),pe=b({frameId:v,workspaceId:v,positionIndex:g(),minWidth:I(g()),maxWidth:I(g()),minHeight:I(g()),maxHeight:I(g())}),me=y(),ge=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())})),fe=b({id:I(v),config:me,children:I(D((()=>W(ke)))),type:x(k("row"),k("column"),k("group"))}),ye=b({id:I(v),config:ge,type:k("window")}),ke=x(ye,fe),be=b({id:v,config:we,children:W(ke),frameSummary:de,context:I(y())}),We=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())})}),Ie=b({type:k("group"),config:y(),children:W(x(We))}),xe=b({type:k("column"),config:y(),children:W(x(Ie,We,D((()=>xe)),D((()=>Se))))}),Se=b({type:k("row"),config:y(),children:W(x(xe,Ie,We,D((()=>Se))))}),De=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(Se,xe,Ie,We))})}))}),ve=b({layout:De,mode:x(k("replace"),k("merge"))}),Ce=b({layouts:W(De),mode:x(k("replace"),k("merge"))}),Ee=b({layouts:W(De)}),Be=b({id:v,isFocused:I(f()),isInitialized:I(f()),initializationContext:I(ce)}),Me=b({summaries:W(Be)}),Te=b({id:v,config:we}),Re=b({summaries:W(Te)}),Ae=b({id:v,config:y(),workspaces:W(be)}),Le=b({name:v,applicationName:I(m())}),Pe=b({summaries:W(Le)}),Fe=b({windowId:v}),ze=y(),He=b({state:A}),$e=b({top:g(),left:g(),width:C,height:C}),Oe=b({bounds:$e}),_e=b({icon:I(v)}),je=b({id:I(v)}),Ge=b({isSupported:f()}),Ne=b({width:I(E),height:I(E),relative:I(f())}),Je=b({top:I(g()),left:I(g()),relative:I(f())}),Ue=b({itemId:v}),Ke=b({itemId:v,excludeIds:I(f())}),qe=b({frameId:v,requestedState:A}),Qe=b({itemId:v,title:v}),Ve=b({itemId:v,containerId:v}),Xe=S(Ue,Ne),Ye=b({itemId:v,enabled:f()}),Ze=S(Ue,Je);b({id:v,type:R});const et=b({definition:j,parentId:v,parentType:T}),tt=b({definition:q,parentId:v,parentType:T}),rt=b({itemId:v,windowId:I(v)}),ot=b({live:f()}),nt=b({type:x(k("row"),k("column")),workspaceId:v}),it=b({type:x(k("row"),k("column")),itemId:v}),at=b({itemId:v,config:me}),st=b({frameSummary:de,frameBounds:I($e)}),ct=b({workspaceSummary:Te,frameSummary:de,workspaceSnapshot:I(be),frameBounds:I($e)}),dt=b({containerSummary:at}),lt=b({windowSummary:b({itemId:v,parentId:v,config:ge})}),ht=b({name:v,workspaceId:v,saveContext:I(f()),allowMultiple:I(f()),metadata:I(b())}),ut=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())}),wt=b({workspaceId:v,config:I(ut)}),pt=b({allowExtract:I(f()),allowReorder:I(f()),showCloseButton:I(f())}),mt=b({width:I(C),height:I(C)}),gt=b({windowPlacementId:v,config:I(pt)}),ft=b({allowDrop:I(f()),allowSplitters:I(f())}),yt=b({allowDrop:I(f()),allowSplitters:I(f())}),kt=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())}),bt=b({itemId:v,type:k("row"),config:I(ft)}),Wt=b({itemId:v,type:k("column"),config:I(yt)}),It=b({itemId:v,type:k("group"),config:I(kt)}),xt=x(bt,Wt,It),St=b({workspaceId:v,icon:I(v)}),Dt=b({workspaceId:v,icon:I(v)}),vt=I(b({icon:I(v)})),Ct=b({shortcut:v,frameId:v}),Et=b({shortcut:v,frameId:v}),Bt=b({enabled:f()}),Mt=b({itemId:v,type:L}),Tt=b({operation:v}),Rt=b({itemId:v,dragMode:B}),At="T42.Web.Platform.Control",Lt="T42.Web.Platform.WSP.Stream",Pt={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}},Ft={control:{name:"T42.Workspaces.Client.Control",isStream:!1}},zt={frame:{name:"T42.Workspaces.Stream.Frame",payloadDecoder:st},workspace:{name:"T42.Workspaces.Stream.Workspace",payloadDecoder:ct},container:{name:"T42.Workspaces.Stream.Container",payloadDecoder:dt},window:{name:"T42.Workspaces.Stream.Window",payloadDecoder:lt}},Ht={shortcutClicked:{name:"shortcutClicked",argsDecoder:Et,resultDecoder:ze}},$t={ping:{name:"ping",resultDecoder:ot},isWindowInWorkspace:{name:"isWindowInWorkspace",argsDecoder:Ue,resultDecoder:M},createWorkspace:{name:"createWorkspace",resultDecoder:be,argsDecoder:ae},createFrame:{name:"createFrame",resultDecoder:Be,argsDecoder:re},initFrame:{name:"initFrame",resultDecoder:ze,argsDecoder:ne},getAllFramesSummaries:{name:"getAllFramesSummaries",resultDecoder:Me},getFrameSummary:{name:"getFrameSummary",resultDecoder:de,argsDecoder:se},getAllWorkspacesSummaries:{name:"getAllWorkspacesSummaries",resultDecoder:Re},getWorkspaceSnapshot:{name:"getWorkspaceSnapshot",resultDecoder:be,argsDecoder:Ue},getAllLayoutsSummaries:{name:"getAllLayoutsSummaries",resultDecoder:Pe},openWorkspace:{name:"openWorkspace",argsDecoder:Y,resultDecoder:be},deleteLayout:{name:"deleteLayout",resultDecoder:ze,argsDecoder:z},saveLayout:{name:"saveLayout",resultDecoder:De,argsDecoder:ht},importLayout:{name:"importLayout",resultDecoder:ze,argsDecoder:ve},importLayouts:{name:"importLayouts",resultDecoder:ze,argsDecoder:Ce},exportAllLayouts:{name:"exportAllLayouts",resultDecoder:Ee},restoreItem:{name:"restoreItem",argsDecoder:Ue,resultDecoder:ze},maximizeItem:{name:"maximizeItem",argsDecoder:Ue,resultDecoder:ze},focusItem:{name:"focusItem",argsDecoder:Ue,resultDecoder:ze},closeItem:{name:"closeItem",argsDecoder:Ue,resultDecoder:ze},resizeItem:{name:"resizeItem",argsDecoder:Xe,resultDecoder:ze},setMaximizationBoundary:{name:"setMaximizationBoundary",argsDecoder:Ye,resultDecoder:ze},changeFrameState:{name:"changeFrameState",argsDecoder:qe,resultDecoder:ze},getFrameState:{name:"getFrameState",argsDecoder:Ue,resultDecoder:He},getFrameBounds:{name:"getFrameBounds",argsDecoder:Ue,resultDecoder:Oe},moveFrame:{name:"moveFrame",argsDecoder:Ze,resultDecoder:ze},getFrameSnapshot:{name:"getFrameSnapshot",argsDecoder:Ke,resultDecoder:Ae},forceLoadWindow:{name:"forceLoadWindow",argsDecoder:Ue,resultDecoder:Fe},ejectWindow:{name:"ejectWindow",argsDecoder:Ue,resultDecoder:Fe},setItemTitle:{name:"setItemTitle",argsDecoder:Qe,resultDecoder:ze},moveWindowTo:{name:"moveWindowTo",argsDecoder:Ve,resultDecoder:ze},addWindow:{name:"addWindow",argsDecoder:et,resultDecoder:rt},addContainer:{name:"addContainer",argsDecoder:tt,resultDecoder:rt},bundleWorkspace:{name:"bundleWorkspace",argsDecoder:nt,resultDecoder:ze},bundleItem:{name:"bundleItem",argsDecoder:it,resultDecoder:ze},hibernateWorkspace:{name:"hibernateWorkspace",argsDecoder:ee,resultDecoder:ze},resumeWorkspace:{name:"resumeWorkspace",argsDecoder:ee,resultDecoder:ze},lockWorkspace:{name:"lockWorkspace",argsDecoder:wt,resultDecoder:ze},lockWindow:{name:"lockWindow",argsDecoder:gt,resultDecoder:ze},lockContainer:{name:"lockContainer",argsDecoder:xt,resultDecoder:ze},pinWorkspace:{name:"pinWorkspace",argsDecoder:St,resultDecoder:ze},unpinWorkspace:{name:"unpinWorkspace",argsDecoder:ee,resultDecoder:ze},getWorkspaceIcon:{name:"getWorkspaceIcon",argsDecoder:ee,resultDecoder:_e},setWorkspaceIcon:{name:"setWorkspaceIcon",argsDecoder:Dt,resultDecoder:ze},registerShortcut:{name:"registerShortcut",argsDecoder:Ct,resultDecoder:ze},unregisterShortcut:{name:"unregisterShortcut",argsDecoder:Ct,resultDecoder:ze},showLoadingAnimation:{name:"showLoadingAnimation",argsDecoder:Mt,resultDecoder:ze},hideLoadingAnimation:{name:"hideLoadingAnimation",argsDecoder:Mt,resultDecoder:ze},getPlatformFrameId:{name:"getPlatformFrameId",resultDecoder:je},operationCheck:{name:"operationCheck",argsDecoder:Tt,resultDecoder:Ge},setWindowDragMode:{name:"setWindowDragMode",argsDecoder:Rt,resultDecoder:ze}};class Ot{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($t).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 Ot,o={streamType:e.eventType,level:e.scope,levelId:e.scopeId,promise:t.promise};this.pendingSubScriptions.push(o);try{const o=zt[e.eventType],n=await this.transport.subscribe(o.name,this.getBranchKey(e),e.eventType);n.onData((e=>{const t=e.data,r=he.run(e.requestArguments),o=ue.run(t.action);if(!r.ok||!o.ok)return;const n=r.result.type,i=`${n}-${r.result.branch}-${o.result}`,a=zt[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(Ht).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=ue.runWithException(t.action),r=le.runWithException(t.type),o=zt[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 jt=()=>"undefined"==typeof window||(window.glue42gd||window.iodesktop),Gt=()=>"undefined"==typeof window?null:window.glue42core||window.iobrowser;class Nt{agm;registry;defaultTransportTimeout=12e4;coreEventMethodInitiated=!1;corePlatformSubPromise;constructor(e,t){this.agm=e,this.registry=t}async initiate(e){if(jt())return await Promise.all(Object.values(Pt).map((e=>this.verifyMethodLive(e.name)))),void await Promise.all(Object.keys(Ft).map((e=>this.registerMethod(e))));const t=Gt().communicationId;await Promise.all([this.verifyMethodLive(At,t),this.verifyMethodLive(Lt,t)]),await this.transmitControl("frameHello",{windowId:e})}coreSubscriptionReady(e){return this.coreEventMethodInitiated||this.subscribePlatform(e),this.corePlatformSubPromise}subscribePlatform(e){this.coreEventMethodInitiated=!0;const t=Gt().communicationId;this.corePlatformSubPromise=this.agm.subscribe(Lt,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=jt()?{operation:e,operationArguments:t}:{operation:e,domain:"workspaces",data:t},o=jt()?Pt.control.name:At,n=jt()?void 0:Gt().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=Ft[e];return this.agm.register(t.name,((t,r)=>{this.registry.execute(e,t,r)}))}}const Jt=new WeakMap;class Ut{constructor(e,t){const r=t.wrapChildren(e.children);delete e.children,Jt.set(this,{base:t,children:r,definition:e})}get type(){return Jt.get(this).definition.type}addColumn(e){return Jt.get(this).base.add("column",Jt.get(this).children,e)}addRow(e){return Jt.get(this).base.add("row",Jt.get(this).children,e)}addGroup(e){return Jt.get(this).base.add("group",Jt.get(this).children,e)}addWindow(e){return Jt.get(this).base.addWindow(Jt.get(this).children,e),this}serialize(){const e=Jt.get(this).definition;return e.children=Jt.get(this).base.serializeChildren(Jt.get(this).children),e}}class Kt{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=N.runWithException(r),n=this.getBuilder({type:e,definition:o});return t.push(n),n}addWindow(e,t){const r=j.runWithException(t);r.type="window",e.push(r)}serializeChildren(e){return e.map((e=>e instanceof Ut?e.serialize():e))}}const qt=new WeakMap;class Qt{constructor(e,t,r){const o=t.wrapChildren(e.children);delete e.children,qt.set(this,{base:t,children:o,definition:e,controller:r})}addColumn(e){const t=qt.get(this).children;if(!t.every((e=>e instanceof Ut&&"column"===e.type)))throw new Error("Cannot add a column to this workspace, because there are already children of another type");return qt.get(this).base.add("column",t,e)}addRow(e){const t=qt.get(this).children;if(!t.every((e=>e instanceof Ut&&"row"===e.type)))throw new Error("Cannot add a row to this workspace, because there are already children of another type");return qt.get(this).base.add("row",t,e)}addGroup(e){const t=qt.get(this).children;if(0!==t.length)throw new Error("Cannot add a group to this workspace, because there are already defined children.");return qt.get(this).base.add("group",t,e)}addWindow(e){const t=qt.get(this).children;if(0!==t.length)throw new Error("Cannot add a window to this workspace, because there are already defined children.");return qt.get(this).base.addWindow(t,e),this}getChildAt(e){C.runWithException(e);return qt.get(this).children[e]}async create(e){const t=F.runWithException(e),r=qt.get(this).definition;r.children=qt.get(this).base.serializeChildren(qt.get(this).children);return qt.get(this).controller.createWorkspace(r,t)}}const Vt=new WeakMap,Xt=e=>Vt.get(e).base;class Yt{constructor(e){Vt.set(this,{base:e})}get type(){return"row"}get id(){return Xt(this).getId(this)}get frameId(){return Xt(this).getFrameId(this)}get workspaceId(){return Xt(this).getWorkspaceId(this)}get positionIndex(){return Xt(this).getPositionIndex(this)}get children(){return Xt(this).getAllChildren(this)}get parent(){return Xt(this).getMyParent(this)}get frame(){return Xt(this).getMyFrame(this)}get workspace(){return Xt(this).getMyWorkspace(this)}get allowDrop(){return Xt(this).getAllowDrop(this)}get allowSplitters(){return Xt(this).getAllowSplitters(this)}get minWidth(){return Xt(this).getMinWidth(this)}get minHeight(){return Xt(this).getMinHeight(this)}get maxWidth(){return Xt(this).getMaxWidth(this)}get maxHeight(){return Xt(this).getMaxHeight(this)}get width(){return Xt(this).getWidthInPx(this)}get height(){return Xt(this).getHeightInPx(this)}get isPinned(){return Xt(this).getIsPinned(this)}get isMaximized(){return Xt(this).getIsMaximized(this)}get maximizationBoundary(){return Xt(this).getMaximizationBoundary(this)}addWindow(e){return Xt(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 Xt(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 Xt(this).addParent(this,"column","row",e)}async addRow(){throw new Error("Adding rows as row children is not supported")}removeChild(e){return Xt(this).removeChild(this,e)}maximize(){return Xt(this).maximize(this)}restore(){return Xt(this).restore(this)}close(){return Xt(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 Xt(this).lockContainer(this,r)}async setHeight(e){return C.runWithException(e),Xt(this).setHeight(this,e)}async onLockConfigurationChanged(e){P(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 Xt(this).processLocalSubscription(this,t)}async setMaximizationBoundary(e){const t=Bt.runWithException(e);return Xt(this).setMaximizationBoundary(this,t)}}const Zt=new WeakMap,er=e=>Zt.get(e).base;class tr{constructor(e){Zt.set(this,{base:e})}get type(){return"column"}get id(){return er(this).getId(this)}get frameId(){return er(this).getFrameId(this)}get workspaceId(){return er(this).getWorkspaceId(this)}get positionIndex(){return er(this).getPositionIndex(this)}get children(){return er(this).getAllChildren(this)}get parent(){return er(this).getMyParent(this)}get frame(){return er(this).getMyFrame(this)}get workspace(){return er(this).getMyWorkspace(this)}get allowDrop(){return er(this).getAllowDrop(this)}get allowSplitters(){return er(this).getAllowSplitters(this)}get minWidth(){return er(this).getMinWidth(this)}get minHeight(){return er(this).getMinHeight(this)}get maxWidth(){return er(this).getMaxWidth(this)}get maxHeight(){return er(this).getMaxHeight(this)}get width(){return er(this).getWidthInPx(this)}get height(){return er(this).getHeightInPx(this)}get isPinned(){return er(this).getIsPinned(this)}get isMaximized(){return er(this).getIsMaximized(this)}get maximizationBoundary(){return er(this).getMaximizationBoundary(this)}addWindow(e){return er(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 er(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 er(this).addParent(this,"row","column",e)}removeChild(e){return er(this).removeChild(this,e)}maximize(){return er(this).maximize(this)}restore(){return er(this).restore(this)}close(){return er(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:yt.runWithException(t);return er(this).lockContainer(this,r)}async setWidth(e){return C.runWithException(e),er(this).setWidth(this,e)}async onLockConfigurationChanged(e){P(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 er(this).processLocalSubscription(this,t)}async setMaximizationBoundary(e){const t=Bt.runWithException(e);return er(this).setMaximizationBoundary(this,t)}}const rr=new WeakMap,or=e=>rr.get(e).base;class nr{constructor(e){rr.set(this,{base:e})}get type(){return"group"}get id(){return or(this).getId(this)}get frameId(){return or(this).getFrameId(this)}get workspaceId(){return or(this).getWorkspaceId(this)}get positionIndex(){return or(this).getPositionIndex(this)}get children(){return or(this).getAllChildren(this)}get parent(){return or(this).getMyParent(this)}get frame(){return or(this).getMyFrame(this)}get workspace(){return or(this).getMyWorkspace(this)}get allowExtract(){return or(this).getAllowExtract(this)}get allowReorder(){return or(this).getAllowReorder(this)}get allowDropLeft(){return or(this).getAllowDropLeft(this)}get allowDropRight(){return or(this).getAllowDropRight(this)}get allowDropTop(){return or(this).getAllowDropTop(this)}get allowDropBottom(){return or(this).getAllowDropBottom(this)}get allowDropHeader(){return or(this).getAllowDropHeader(this)}get allowDrop(){return or(this).getAllowDrop(this)}get showMaximizeButton(){return or(this).getShowMaximizeButton(this)}get showEjectButton(){return or(this).getShowEjectButton(this)}get showAddWindowButton(){return or(this).getShowAddWindowButton(this)}get minWidth(){return or(this).getMinWidth(this)}get minHeight(){return or(this).getMinHeight(this)}get maxWidth(){return or(this).getMaxWidth(this)}get maxHeight(){return or(this).getMaxHeight(this)}get width(){return or(this).getWidthInPx(this)}get height(){return or(this).getHeightInPx(this)}get isMaximized(){return or(this).getIsMaximized(this)}addWindow(e){return or(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 or(this).removeChild(this,e)}maximize(){return or(this).maximize(this)}restore(){return or(this).restore(this)}close(){return or(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:kt.runWithException(t);return or(this).lockContainer(this,r)}async setSize(e){const t=mt.runWithException(e);if(!t.width&&!t.height)throw new Error("Expected either width or height to be passed.");return or(this).setSize(this,e.width,e.height)}async bundleToRow(){await or(this).bundleTo(this,"row"),await this.workspace.refreshReference()}async bundleToColumn(){await or(this).bundleTo(this,"column"),await this.workspace.refreshReference()}async onLockConfigurationChanged(e){P(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 or(this).processLocalSubscription(this,t)}}const ir=new WeakMap,ar=e=>ir.get(e).manager.getWorkspaceData(e),sr=e=>ir.get(e).manager;class cr{constructor(e){ir.set(this,{manager:e})}get id(){return ar(this).id}get frameId(){return ar(this).config.frameId}get positionIndex(){return ar(this).config.positionIndex}get title(){return ar(this).config.title}get layoutName(){return ar(this).config.layoutName}get isHibernated(){return ar(this).config.isHibernated}get isSelected(){return ar(this).config.isSelected}get children(){return ar(this).children}get frame(){return ar(this).frame}get allowSplitters(){return ar(this).config.allowSplitters}get allowSystemHibernation(){return ar(this).config.allowSystemHibernation}get allowDrop(){return ar(this).config.allowDrop}get allowDropLeft(){return ar(this).config.allowDropLeft}get allowDropTop(){return ar(this).config.allowDropTop}get allowDropRight(){return ar(this).config.allowDropRight}get allowDropBottom(){return ar(this).config.allowDropBottom}get allowExtract(){return ar(this).config.allowExtract}get allowWindowReorder(){return ar(this).config.allowWindowReorder}get showCloseButton(){return ar(this).config.showCloseButton}get showSaveButton(){return ar(this).config.showSaveButton}get allowWorkspaceTabReorder(){return ar(this).config.allowWorkspaceTabReorder}get allowWorkspaceTabExtract(){return ar(this).config.allowWorkspaceTabExtract}get minWidth(){return ar(this).config.minWidth}get minHeight(){return ar(this).config.minHeight}get maxWidth(){return ar(this).config.maxWidth}get maxHeight(){return ar(this).config.maxHeight}get width(){return ar(this).config.widthInPx}get height(){return ar(this).config.heightInPx}get showWindowCloseButtons(){return ar(this).config.showWindowCloseButtons}get showEjectButtons(){return ar(this).config.showEjectButtons}get showAddWindowButtons(){return ar(this).config.showAddWindowButtons}get isPinned(){return ar(this).config.isPinned}get windowDragMode(){return jt()?ar(this).config.windowDragMode:"keepInside"}async removeChild(e){P(e);const t=this.children.find(e);t&&(await t.close(),await this.refreshReference())}async remove(e){P(e);const t=ar(this).controller.iterateFindChild(this.children,e);await t.close(),await this.refreshReference()}async focus(){await ar(this).controller.focusItem(this.id),await this.refreshReference()}async close(){const e=ar(this).controller,t=await ar(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 ar(this).controller.getSnapshot(this.id,"workspace")}async saveLayout(e,t){v.runWithException(e),await ar(this).controller.saveLayout({name:e,workspaceId:this.id,saveContext:t?.saveContext,metadata:t?.metadata,allowMultiple:t?.allowMultiple})}async setTitle(e){v.runWithException(e);const t=ar(this).controller;await t.setItemTitle(this.id,e),await this.refreshReference()}getContext(){return ar(this).controller.getWorkspaceContext(this.id)}setContext(e){return ar(this).controller.setWorkspaceContext(this.id,e)}updateContext(e){return ar(this).controller.updateWorkspaceContext(this.id,e)}onContextUpdated(e){return ar(this).controller.subscribeWorkspaceContextUpdated(this.id,e)}async refreshReference(){const e=await ar(this).controller.getSnapshot(this.id,"workspace"),t=ar(this).controller.flatChildren(ar(this).children),r=ar(this).controller.refreshChildren({existingChildren:t,workspace:this,parent:this,children:e.children}),o=this.frame;let n;if(o.id===e.config.frameId)sr(this).remapFrame(o,e.frameSummary),n=o;else{const t={summary:e.frameSummary};n=ar(this).ioc.getModel("frame",t)}sr(this).remapWorkspace(this,{config:e.config,children:r,frame:n})}async getIcon(){return ar(this).controller.getWorkspaceIcon(this.id)}async setIcon(e){return ar(this).controller.setWorkspaceIcon(this.id,e)}getBox(e){P(e);const t=ar(this).children;return ar(this).controller.iterateFindChild(t,(t=>"window"!==t.type&&e(t)))}getAllBoxes(e){P(e,!0);const t=ar(this).children,r=ar(this).controller.iterateFilterChildren(t,(e=>"window"!==e.type));return e?r.filter(e):r}getRow(e){return P(e),this.getBox((t=>"row"===t.type&&e(t)))}getAllRows(e){return P(e,!0),e?this.getAllBoxes((t=>"row"===t.type&&e(t))):this.getAllBoxes((e=>"row"===e.type))}getColumn(e){return P(e),this.getBox((t=>"column"===t.type&&e(t)))}getAllColumns(e){return P(e,!0),e?this.getAllBoxes((t=>"column"===t.type&&e(t))):this.getAllBoxes((e=>"column"===e.type))}getGroup(e){return P(e),this.getBox((t=>"group"===t.type&&e(t)))}getAllGroups(e){return P(e,!0),e?this.getAllBoxes((t=>"group"===t.type&&e(t))):this.getAllBoxes((e=>"group"===e.type))}getWindow(e){P(e);const t=ar(this).children;return ar(this).controller.iterateFindChild(t,(t=>"window"===t.type&&e(t)))}getAllWindows(e){P(e,!0);const t=ar(this).children,r=ar(this).controller.iterateFilterChildren(t,(e=>"window"===e.type));return e?r.filter(e):r}addRow(e){return ar(this).base.addParent(this,"row","workspace",e)}addColumn(e){return ar(this).base.addParent(this,"column","workspace",e)}addGroup(e){return ar(this).base.addParent(this,"group","workspace",e)}addWindow(e){return ar(this).base.addWindow(this,e,"workspace")}async bundleToRow(){await ar(this).controller.bundleWorkspaceTo("row",this.id),await this.refreshReference()}async bundleToColumn(){await ar(this).controller.bundleWorkspaceTo("column",this.id),await this.refreshReference()}async hibernate(){await ar(this).controller.hibernateWorkspace(this.id),await this.refreshReference()}async resume(){await ar(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:ut.runWithException(t);await ar(this).controller.lockWorkspace(this.id,r),await this.refreshReference()}async pin(e){vt.runWithException(e),await ar(this).controller.pinWorkspace(this.id,e?.icon),await this.refreshReference()}async unpin(){await ar(this).controller.unpinWorkspace(this.id),await this.refreshReference()}async showLoadingAnimation(){if(!jt())throw new Error("Not supported in IO Connect Browser");await ar(this).controller.showWorkspaceLoadingAnimation(this.id)}async hideLoadingAnimation(){if(!jt())throw new Error("Not supported in IO Connect Browser");await ar(this).controller.hideWorkspaceLoadingAnimation(this.id)}async setWindowDragMode(e){if(!jt())throw new Error("Not supported in IO Connect Browser");B.runWithException(e),await ar(this).controller.setWindowDragMode(this.id,e),await this.refreshReference()}async onClosed(e){P(e);const t=ar(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 ar(this).controller.processLocalSubscription(r,t)}async onHibernated(e){P(e);const t=ar(this).id,r={action:"hibernated",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await ar(this).controller.processLocalSubscription(r,t)}async onResumed(e){P(e);const t=ar(this).id,r={action:"resumed",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await ar(this).controller.processLocalSubscription(r,t)}async onWindowAdded(e){P(e);const t=ar(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 ar(this).controller.processLocalSubscription(r,t)}async onWindowRemoved(e){P(e);const t=ar(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 ar(this).controller.processLocalSubscription(r,t)}async onWindowLoaded(e){P(e);const t=ar(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 ar(this).controller.processLocalSubscription(r,t)}async onWindowMaximized(e){P(e);const t=ar(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 ar(this).controller.processLocalSubscription(r,t)}async onWindowRestored(e){P(e);const t=ar(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 ar(this).controller.processLocalSubscription(r,t)}async onWindowSelected(e){P(e);const t=ar(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 ar(this).controller.processLocalSubscription(r,t)}async onLockConfigurationChanged(e){P(e);const t=ar(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 ar(this).controller.processLocalSubscription(r,t)}}const dr=new WeakMap,lr=e=>dr.get(e).manager.getWindowData(e);class hr{constructor(e){dr.set(this,{manager:e})}get id(){return lr(this).config.windowId}get elementId(){return lr(this).id}get type(){return"window"}get frameId(){return lr(this).frame.id}get workspaceId(){return lr(this).workspace.id}get positionIndex(){return lr(this).config.positionIndex}get isMaximized(){return lr(this).config.isMaximized}get isLoaded(){return lr(this).controller.checkIsWindowLoaded(this.id)}get isSelected(){return lr(this).config.isSelected}get focused(){return this.getGdWindow().isFocused}get title(){return lr(this).config.title}get allowExtract(){return lr(this).config.allowExtract}get allowReorder(){return lr(this).config.allowReorder}get showCloseButton(){return lr(this).config.showCloseButton}get width(){return lr(this).config.widthInPx}get height(){return lr(this).config.heightInPx}get minWidth(){return lr(this).config.minWidth}get minHeight(){return lr(this).config.minHeight}get maxWidth(){return lr(this).config.maxWidth}get maxHeight(){return lr(this).config.maxHeight}get workspace(){return lr(this).workspace}get frame(){return lr(this).frame}get parent(){return lr(this).parent}get appName(){return lr(this).config.appName}async forceLoad(){if(this.isLoaded)return;const e=lr(this).controller,t=lr(this).id,r=await e.forceLoadWindow(t);lr(this).config.windowId=r,await this.workspace.refreshReference()}async focus(){const e=lr(this).id,t=lr(this).controller;await t.focusItem(e),await this.workspace.refreshReference()}async close(){const e=lr(this).id,t=lr(this).controller;await t.closeItem(e),await lr(this).parent.removeChild((t=>t.id===e)),await this.workspace.refreshReference()}async setTitle(e){v.runWithException(e);const t=lr(this).id,r=lr(this).controller;await r.setItemTitle(t,e),await this.workspace.refreshReference()}async maximize(){const e=lr(this).id,t=lr(this).controller;await t.maximizeItem(e),await this.workspace.refreshReference()}async restore(){const e=lr(this).id,t=lr(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=lr(this).id,t=await lr(this).controller.ejectWindow(e);return lr(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=lr(this).config.windowId;return lr(this).controller.getGDWindow(e)}async moveTo(e){if(!(e instanceof Yt||e instanceof tr||e instanceof nr))throw new Error("Cannot add to the provided parent, because the provided parent is not an instance of Row, Column or Group");const t=lr(this).id,r=lr(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=lr(this).id;await lr(this).controller.lockWindow(o,r),await this.workspace.refreshReference()}async setSize(e){const t=mt.runWithException(e);if(!t.width&&!t.height)throw new Error("Expected either width or height to be passed.");const r=lr(this).id,o=lr(this).controller;await o.resizeItem(r,{height:t.height,width:t.width,relative:!1}),await this.workspace.refreshReference()}async onRemoved(e){P(e);const t=lr(this).id,r={callback:async()=>{await this.workspace.refreshReference(),e()},action:"removed",eventType:"window",scope:"window"};return await lr(this).controller.processLocalSubscription(r,t)}async onLockConfigurationChanged(e){P(e);const t=lr(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 lr(this).controller.processLocalSubscription(r,t)}}const ur=new WeakMap,wr=e=>ur.get(e).manager.getFrameData(e);class pr{constructor(e){ur.set(this,{manager:e})}async registerShortcut(e,t){v.runWithException(e),P(t);const r=wr(this).summary.id;return await wr(this).controller.registerShortcut(e,r,t)}get id(){return wr(this).summary.id}get isInitialized(){return wr(this).summary.isInitialized}getBounds(){const e=wr(this).summary.id;return wr(this).controller.getFrameBounds(e)}async resize(e){const t=Ne.runWithException(e),r=wr(this).summary.id;return wr(this).controller.resizeItem(r,t)}async move(e){const t=Je.runWithException(e),r=wr(this).summary.id;return wr(this).controller.moveFrame(r,t)}focus(){const e=wr(this).summary.id;return wr(this).controller.focusItem(e)}async state(){if(!jt())throw new Error("State operations are not supported in IO Connect Browser");const e=wr(this).summary.id;return wr(this).controller.getFrameState(e)}async minimize(){if(!jt())throw new Error("State operations are not supported in IO Connect Browser");const e=wr(this).summary.id;return wr(this).controller.changeFrameState(e,"minimized")}async maximize(){if(!jt())throw new Error("State operations are not supported in IO Connect Browser");const e=wr(this).summary.id;return wr(this).controller.changeFrameState(e,"maximized")}async restore(){if(!jt())throw new Error("State operations are not supported in IO Connect Browser");const e=wr(this).summary.id;return wr(this).controller.changeFrameState(e,"normal")}close(){const e=wr(this).summary.id;return wr(this).controller.closeItem(e)}snapshot(){const e=wr(this).summary.id;return wr(this).controller.getSnapshot(e,"frame")}async workspaces(){return wr(this).controller.getWorkspacesByFrameId(this.id)}async getConstraints(){const e=wr(this).controller,t=wr(this).summary.id;return e.getFrameConstraints(t)}async restoreWorkspace(e,t){v.runWithException(e);const r=X.runWithException(t);return wr(this).controller.restoreWorkspace(e,r)}createWorkspace(e,t){const r=Z.runWithException(e),o=F.runWithException(t);return wr(this).controller.createWorkspace(r,o)}async init(e){if(oe.runWithException(e),wr(this).summary.isInitialized)throw new Error("The frame has already been initialized");return wr(this).controller.initFrame(this.id,e)}async onClosed(e){P(e);const t=wr(this).summary.id,r={callback:t=>{e({frameId:t.frameSummary.id,frameBounds:t.frameBounds})},action:"closed",eventType:"frame",scope:"frame"};return await wr(this).controller.processLocalSubscription(r,t)}async onMaximized(e){P(e);const t=wr(this).summary.id,r={callback:()=>{e()},action:"maximized",eventType:"frame",scope:"frame"};return await wr(this).controller.processLocalSubscription(r,t)}async onMinimized(e){P(e);const t=wr(this).summary.id,r={callback:()=>{e()},action:"minimized",eventType:"frame",scope:"frame"};return await wr(this).controller.processLocalSubscription(r,t)}async onNormal(e){P(e);const t=wr(this).summary.id,r={callback:()=>{e()},action:"normal",eventType:"frame",scope:"frame"};return await wr(this).controller.processLocalSubscription(r,t)}async onWorkspaceOpened(e){P(e);const t=wr(this).summary.id,r={callback:async t=>{const r=await wr(this).controller.transformStreamPayloadToWorkspace(t);e(r)},action:"opened",eventType:"workspace",scope:"frame"};return await wr(this).controller.processLocalSubscription(r,t)}async onWorkspaceSelected(e){P(e);const t=wr(this).summary.id,r={callback:async t=>{const r=await wr(this).controller.getWorkspaceById(t.workspaceSummary.id);e(r)},action:"selected",eventType:"workspace",scope:"frame"};return await wr(this).controller.processLocalSubscription(r,t)}async onWorkspaceClosed(e){P(e);const t=wr(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 wr(this).controller.processLocalSubscription(r,t)}async onWindowAdded(e){P(e);const t=wr(this).summary.id,r={callback:async t=>{const r=(await wr(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 wr(this).controller.processLocalSubscription(r,t)}async onWindowRemoved(e){P(e);const t=wr(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 wr(this).controller.processLocalSubscription(r,t)}async onWindowLoaded(e){P(e);const t=wr(this).summary.id,r={callback:async t=>{const r=(await wr(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 wr(this).controller.processLocalSubscription(r,t)}async onInitializationRequested(e){return P(e),this.isInitialized||e(wr(this).summary.initializationContext),()=>{}}async onFocusChanged(e){P(e);const t=wr(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 mr{parentsData=new WeakMap;workspacesData=new WeakMap;windowsData=new WeakMap;framesData=new WeakMap;deleteData(e){e instanceof hr&&this.windowsData.delete(e),e instanceof cr&&this.workspacesData.delete(e),(e instanceof Yt||e instanceof tr||e instanceof nr)&&this.parentsData.delete(e),e instanceof pr&&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 hr){const r=this.windowsData.get(e);r.parent=t.parent||r.parent,r.config=t.config||r.config}if(e instanceof Yt||e instanceof tr||e instanceof nr){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 gr=new WeakMap,fr=(e,t)=>{const r=gr.get(e).manager;return t instanceof cr?r.getWorkspaceData(t):gr.get(e).manager.getParentData(t)};class yr{frameId;workspaceId;positionIndex;constructor(e){gr.set(this,{manager:e})}getId(e){return fr(this,e).id}getPositionIndex(e){return fr(this,e).config.positionIndex}getWorkspaceId(e){const t=fr(this,e);return t.config.workspaceId||t.workspace.id}getFrameId(e){return fr(this,e).frame.id}getAllChildren(e,t){P(t,!0);const r=fr(this,e).children;return void 0===t?r:r.filter(t)}getMyParent(e){return e instanceof cr?e:fr(this,e).parent}getMyFrame(e){return fr(this,e).frame}getMyWorkspace(e){return e instanceof cr?e:fr(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=j.runWithException(t),n=fr(this,e).controller,i=await n.add("window",fr(this,e).id,r,o);if(e instanceof cr)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=fr(this,e).controller,a=(await i.add("container",fr(this,e).id,r,n)).itemId;if(e instanceof cr)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){P(t);const r=this.getAllChildren(e).find(t);r&&(await r.close(),e instanceof cr?await e.refreshReference():await this.getMyWorkspace(e).refreshReference())}async maximize(e){const{controller:t,id:r}=fr(this,e);await t.maximizeItem(r),await this.getMyWorkspace(e.parent).refreshReference()}async restore(e){const{controller:t,id:r}=fr(this,e);await t.restoreItem(r),await this.getMyWorkspace(e.parent).refreshReference()}async close(e){const t=fr(this,e),r=fr(this,e).controller;await r.closeItem(t.id),await this.getMyWorkspace(t.parent).refreshReference()}async lockContainer(e,t){const r=fr(this,e),o=fr(this,e).controller;await o.lockContainer(r.id,e.type,t),await this.getMyWorkspace(r.parent).refreshReference()}getAllowDrop(e){return fr(this,e).config.allowDrop}getAllowDropLeft(e){const t=fr(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=fr(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=fr(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=fr(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=fr(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=fr(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=fr(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=fr(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=fr(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=fr(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=fr(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 fr(this,e).config.minWidth}getMaxWidth(e){return fr(this,e).config.maxWidth}getMinHeight(e){return fr(this,e).config.minHeight}getMaxHeight(e){return fr(this,e).config.maxHeight}getWidthInPx(e){return fr(this,e).config.widthInPx}getHeightInPx(e){return fr(this,e).config.heightInPx}getIsPinned(e){return fr(this,e).config.isPinned}getIsMaximized(e){return fr(this,e).config.isMaximized}getMaximizationBoundary(e){return fr(this,e).config.maximizationBoundary}async setHeight(e,t){const r=fr(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=fr(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=fr(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=fr(this,e),{controller:o,id:n}=r;await o.setMaximizationBoundary(n,t),await this.getMyWorkspace(r.parent).refreshReference()}async bundleTo(e,t){const r=fr(this,e),{controller:o,id:n}=r;await o.bundleItemTo(t,n)}async processLocalSubscription(e,t){return fr(this,e).controller.processLocalSubscription(t,this.getId(e))}transformDefinition(e,t){let r;return void 0===t?r={type:e,children:[]}:t instanceof Ut?r=t.serialize():(void 0===t.type&&(t.type=e),r=q.runWithException(t),r.children=r.children||[]),r}}class kr{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($t.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($t.createFrame.name,e)};return this.ioc.getModel("frame",t)}async initFrame(e,t){await this.bridge.send($t.initFrame.name,{frameId:e,...t})}async restoreWorkspace(e,t){const r=await this.bridge.send($t.openWorkspace.name,{name:e,restoreOptions:t}),o={summary:await this.bridge.send($t.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=$t.addWindow.name;else{if("container"!==e)throw new Error(`Unrecognized add type: ${e}`);n=$t.addContainer.name}return await this.bridge.send(n,i)}async getFrame(e){const t={summary:await this.bridge.send($t.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($t.getWorkspaceSnapshot.name,{itemId:e.workspaceSummary.id})};return this.ioc.getModel("workspace",r)}async fetchWorkspace(e){const t=await this.bridge.send($t.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($t.bundleWorkspace.name,{type:e,workspaceId:t})}async bundleItemTo(e,t){if(!await this.isOperationSupported($t.bundleItem.name))throw new Error(`Operation ${$t.bundleItem.name} is not supported. Ensure that you are running the latest version of all packages`);await this.bridge.send($t.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($t.restoreItem.name,{itemId:e})}async maximizeItem(e){await this.bridge.send($t.maximizeItem.name,{itemId:e})}async focusItem(e){await this.bridge.send($t.focusItem.name,{itemId:e})}async closeItem(e){await this.bridge.send($t.closeItem.name,{itemId:e})}async resizeItem(e,t){await this.bridge.send($t.resizeItem.name,Object.assign({},{itemId:e},t))}async setMaximizationBoundary(e,t){await this.bridge.send($t.setMaximizationBoundary.name,Object.assign({},{itemId:e},t))}async showWorkspaceLoadingAnimation(e){await this.bridge.send($t.showLoadingAnimation.name,{itemId:e,type:"workspace"})}async hideWorkspaceLoadingAnimation(e){await this.bridge.send($t.hideLoadingAnimation.name,{itemId:e,type:"workspace"})}async setWindowDragMode(e,t){await this.bridge.send($t.setWindowDragMode.name,{itemId:e,dragMode:t})}async moveFrame(e,t){await this.bridge.send($t.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($t.forceLoadWindow.name,{itemId:e})).windowId}async ejectWindow(e){return await this.bridge.send($t.ejectWindow.name,{itemId:e})}async moveWindowTo(e,t){await this.bridge.send($t.moveWindowTo.name,{itemId:e,containerId:t})}async getSnapshot(e,t){let r;return"workspace"===t?r=await this.bridge.send($t.getWorkspaceSnapshot.name,{itemId:e}):"frame"===t&&(r=await this.bridge.send($t.getFrameSnapshot.name,{itemId:e})),r}async setItemTitle(e,t){await this.bridge.send($t.setItemTitle.name,{itemId:e,title:t})}refreshChildren(e){const{parent:t,children:r,existingChildren:o,workspace:n}=e;if(t instanceof hr||"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 cr||this.privateDataManager.remapChild(t,{children:i}),i}iterateFindChild(e,t){let r=e.find((e=>t(e)));return r||(e.some((e=>!(e instanceof hr)&&(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 hr||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($t.hibernateWorkspace.name,{workspaceId:e})}async resumeWorkspace(e){await this.bridge.send($t.resumeWorkspace.name,{workspaceId:e})}async lockWorkspace(e,t){await this.bridge.send($t.lockWorkspace.name,{workspaceId:e,config:t})}async lockWindow(e,t){await this.bridge.send($t.lockWindow.name,{windowPlacementId:e,config:t})}async lockContainer(e,t,r){await this.bridge.send($t.lockContainer.name,{itemId:e,type:t,config:r})}async pinWorkspace(e,t){await this.bridge.send($t.pinWorkspace.name,{workspaceId:e,icon:t})}async unpinWorkspace(e){await this.bridge.send($t.unpinWorkspace.name,{workspaceId:e})}async getWorkspaceIcon(e){return(await this.bridge.send($t.getWorkspaceIcon.name,{workspaceId:e})).icon}setWorkspaceIcon(e,t){return this.bridge.send($t.setWorkspaceIcon.name,{workspaceId:e,icon:t})}async getPlatformFrameId(){try{return await this.bridge.send($t.getPlatformFrameId.name,{})}catch(e){return{}}}async isOperationSupported(e){return jt()?{isSupported:!0}:await this.bridge.send($t.operationCheck.name,{operation:e})}}class br{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($t.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($t.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 jt()?this.handleEnterpriseLocalSubscription(e,t):this.handleCoreLocalSubscription(e,t)}processGlobalSubscription(e,t,r){return jt()?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($t.getAllFramesSummaries.name);return this.base.getFrames(t.summaries,e)}getWorkspaceById(e){return this.base.fetchWorkspace(e)}async getWorkspaceByWindowId(e){return jt()?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($t.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($t.getAllLayoutsSummaries.name)).summaries}async deleteLayout(e){await this.bridge.send($t.deleteLayout.name,{name:e})}async exportLayout(e){return(await this.bridge.send($t.exportAllLayouts.name)).layouts.reduce(((t,r)=>(e&&!e(r)||t.push(r),t)),[])}async saveLayout(e){return await this.bridge.send($t.saveLayout.name,e)}async importLayouts(e,t){if(jt())try{await this.bridge.send($t.importLayouts.name,{layouts:e,mode:t})}catch(r){await Promise.all(e.map((e=>this.bridge.send($t.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($t.changeFrameState.name,{frameId:e,requestedState:t})}async getFrameBounds(e){return(await this.bridge.send($t.getFrameBounds.name,{itemId:e})).bounds}async getFrameState(e){return(await this.bridge.send($t.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 setWindowDragMode(e,t){return await this.base.setWindowDragMode(e,t)}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 Wr{bridge;_shortcuts=r();constructor(e){this.bridge=e,this.bridge.onOperation(((e,t)=>{if(e.operation===Ht.shortcutClicked.name){const t=e.data;this._shortcuts.execute(`${t.frameId}-${t.shortcut}`)}}))}async registerShortcut(e,t,r){await this.bridge.send($t.registerShortcut.name,{shortcut:e,frameId:t});const o=this._shortcuts.add(`${t}-${e}`,r);return()=>{o(),this.bridge.send($t.unregisterShortcut.name,{shortcut:e,frameId:t})}}}class Ir{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 kr(this,this.windows,this.contexts,this.layouts)),this._baseController}get controller(){return this._controllerInstance||(this._controllerInstance=new br(this.bridge,this.baseController,this.shortcutsController)),this._controllerInstance}get shortcutsController(){return this._shortcutsController||(this._shortcutsController=new Wr(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 Nt(this.agm,r())),this._transportInstance}get privateDataManager(){return this._privateDataManagerInstance||(this._privateDataManagerInstance=new mr),this._privateDataManagerInstance}get parentBase(){return this._parentBaseInstance||(this._parentBaseInstance=new yr(this.privateDataManager)),this._parentBaseInstance}async initiate(e){await this.transport.initiate(e)}getModel(e,t){switch(e){case"frame":{const e=new pr(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 hr(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 tr(this.parentBase):"row"===e?new Yt(this.parentBase):new nr(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 cr(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 Kt(this.getBuilder.bind(this));switch(e.type){case"workspace":return new Qt(e.definition,t,this.controller);case"row":case"column":case"group":return e.definition.type=e.type,new Ut(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 xr=async e=>{const t=new Ir(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=>(P(e,!0),r.getFrames(e)),n=async e=>(P(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=ie.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=>(P(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=>(P(e),(await r.getWorkspaces(e))[0]),getWorkspaceById:async e=>(v.runWithException(e),r.getWorkspaceById(e)),getAllWorkspaces:e=>(P(e,!0),r.getWorkspaces(e)),getWindow:async e=>(P(e),r.getWindow(e)),getBox:async e=>(P(e),r.getParent(e)),restoreWorkspace:async(e,t)=>{v.runWithException(e);const o=X.runWithException(t);return r.restoreWorkspace(e,o)},createWorkspace:async(e,t)=>{const o=Z.runWithException(e),n=F.runWithException(t);return r.createWorkspace(o,n)},createEmptyFrame:async e=>{const t=re.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=>(P(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=>De.runWithException(e))),r.importLayouts(e,t)},save:async e=>{const t=ht.runWithException(e);return r.saveLayout(t)},onSaved:async e=>(P(e),r.handleOnSaved(e)),onRemoved:async e=>(P(e),r.handleOnRemoved(e))},onFrameOpened:n,onFrameClosed:async e=>(P(e),await r.processGlobalSubscription((t=>{e({frameId:t.frameSummary.id,frameBounds:t.frameBounds})}),"frame","closed")),onWorkspaceOpened:async e=>(P(e),await r.processGlobalSubscription((async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)}),"workspace","opened")),onWorkspaceClosed:async e=>(P(e),await r.processGlobalSubscription((t=>{e({frameId:t.frameSummary.id,workspaceId:t.workspaceSummary.id,frameBounds:t.frameBounds})}),"workspace","closed")),onWorkspaceHibernated:async e=>(P(e),await r.processGlobalSubscription((async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)}),"workspace","hibernated")),onWorkspaceResumed:async e=>(P(e),await r.processGlobalSubscription((async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)}),"workspace","resumed")),onWindowAdded:async e=>(P(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=>(P(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=>(P(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=>(P(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=>(P(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=>(P(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.5"}})(e,t)};return"undefined"!=typeof window&&(window.IOWorkspaces=xr),xr}));
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("")},w=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)},p=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(w("."+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 w("["+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(w("["+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(w("."+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"}:w(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=p.string,g=p.number,f=p.boolean,y=p.anyJson;p.unknownJson;var k=p.constant,b=p.object,W=p.array;p.tuple,p.dict;var I=p.optional,S=p.oneOf;p.union;var x=p.intersection;p.withDefault,p.valueAt,p.succeed,p.fail;var D=p.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=S(k("keepInside"),k("autoEject")),T=b({inWorkspace:f()}),M=b({base64Image:v}),R=b({icon:M,frameId:v}),L=S(k("workspace"),k("row"),k("column"),k("group")),A=S(k("row"),k("column"),k("group")),F=S(k("maximized"),k("minimized"),k("normal")),P=S(k("workspace")),z=(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}`)},O=I(b({saveLayout:I(f())})),H=b({name:v}),$=b({minWidth:I(g()),maxWidth:I(g()),minHeight:I(g()),maxHeight:I(g()),allowExtract:I(f()),allowReorder:I(f()),showCloseButton:I(f())}),_=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())}),j=b({minHeight:I(g()),maxHeight:I(g()),allowDrop:I(f()),allowSplitters:I(f()),isPinned:I(f()),maximizationBoundary:I(f())}),G=b({minWidth:I(g()),maxWidth:I(g()),allowDrop:I(f()),allowSplitters:I(f()),isPinned:I(f()),maximizationBoundary:I(f())}),N=b({type:I(k("window")),appName:I(v),windowId:I(v),context:I(y()),config:I($)}),J=b({type:k("window"),appName:I(v),windowId:I(v),context:I(y()),config:I($)}),U=I(b({type:I(A),children:I(D((()=>W(S(N,U))))),config:I(y())})),K=b({type:k("column"),children:I(D((()=>W(S(J,V))))),config:I(G)}),q=b({type:k("row"),children:I(D((()=>W(S(J,V))))),config:I(j)}),Q=b({type:k("group"),children:I(D((()=>W(S(J,V))))),config:I(_)}),V=S(Q,K,q);S(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 X=b({bounds:I(b({left:I(g()),top:I(g()),width:I(C),height:I(C)})),frameId:I(v)}),Y=S(k("direct"),k("delayed"),k("lazy")),Z=I(b({app:I(v),context:I(y()),loadingStrategy:I(Y),title:I(v),reuseWorkspaceId:I(v),frameId:I(v),applicationName:I(v),lockdown:I(f()),activateFrame:I(f()),newFrame:I(S(X,f())),noTabHeader:I(f()),inMemoryLayout:I(f()),icon:I(v),isPinned:I(f()),isSelected:I(f()),positionIndex:I(C),allowSystemHibernation:I(f())})),ee=b({name:v,restoreOptions:I(Z)}),te=b({children:I(W(S(N,V))),context:I(y()),config:I(b({title:I(v),position:I(C),isFocused:I(f()),noTabHeader:I(f()),reuseWorkspaceId:I(v),loadingStrategy:I(Y),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),windowDragMode:I(B)})),frame:I(b({activate:I(f()),reuseFrameId:I(v),applicationName:I(v),newFrame:I(S(f(),X))}))}),re=b({workspaceId:v}),oe=b({name:v,restoreOptions:I(Z)}),ne=I(b({applicationName:I(m()),frameConfig:I(X),context:I(b()),layoutComponentId:I(v)})),ie=b({workspaces:W(S(I(te),I(oe)))}),ae=b({frameId:v,workspaces:W(S(te,oe))}),se=b({type:L,definition:I(S(te,U))}),ce=x(te,b({saveConfig:I(b({saveLayout:I(f())}))})),de=b({itemId:v}),le=b({context:I(b())}),he=b({id:v,isFocused:I(f()),isInitialized:I(f()),initializationContext:I(le)});b({type:A,id:v,frameId:v,workspaceId:v,positionIndex:g()});const ue=S(k("frame"),k("workspace"),k("container"),k("window")),we=b({type:ue,branch:v}),pe=S(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")),me=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()),windowDragMode:I(B),loadingStrategy:I(Y)}),ge=b({frameId:v,workspaceId:v,positionIndex:g(),minWidth:I(g()),maxWidth:I(g()),minHeight:I(g()),maxHeight:I(g())}),fe=y(),ye=x(ge,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())})),ke=b({id:I(v),config:fe,children:I(D((()=>W(We)))),type:S(k("row"),k("column"),k("group"))}),be=b({id:I(v),config:ye,type:k("window")}),We=S(be,ke),Ie=b({id:v,config:me,children:W(We),frameSummary:he,context:I(y())}),Se=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())})}),xe=b({type:k("group"),config:y(),children:W(S(Se))}),De=b({type:k("column"),config:y(),children:W(S(xe,Se,D((()=>De)),D((()=>ve))))}),ve=b({type:k("row"),config:y(),children:W(S(De,xe,Se,D((()=>ve))))}),Ce=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(S(ve,De,xe,Se))})}))}),Ee=b({layout:Ce,mode:S(k("replace"),k("merge"))}),Be=b({layouts:W(Ce),mode:S(k("replace"),k("merge"))}),Te=b({layouts:W(Ce)}),Me=b({id:v,isFocused:I(f()),isInitialized:I(f()),initializationContext:I(le)}),Re=b({summaries:W(Me)}),Le=b({id:v,config:me}),Ae=b({summaries:W(Le)}),Fe=b({id:v,config:y(),workspaces:W(Ie)}),Pe=b({name:v,applicationName:I(m())}),ze=b({summaries:W(Pe)}),Oe=b({windowId:v}),He=y(),$e=b({state:F}),_e=b({top:g(),left:g(),width:C,height:C}),je=b({bounds:_e}),Ge=b({icon:I(v)}),Ne=b({id:I(v)}),Je=b({isSupported:f()}),Ue=b({width:I(E),height:I(E),relative:I(f())}),Ke=b({top:I(g()),left:I(g()),relative:I(f())}),qe=b({itemId:v}),Qe=b({allowPrevent:I(f()),showDialog:I(f())}),Ve=b({itemId:v,closeOptions:I(Qe)}),Xe=b({itemId:v,excludeIds:I(f())}),Ye=b({frameId:v,requestedState:F}),Ze=b({itemId:v,title:v}),et=b({itemId:v,containerId:v}),tt=x(qe,Ue),rt=b({itemId:v,enabled:f()}),ot=x(qe,Ke);b({id:v,type:A});const nt=b({definition:N,parentId:v,parentType:L}),it=b({definition:V,parentId:v,parentType:L}),at=b({itemId:v,windowId:I(v)}),st=b({live:f()}),ct=b({type:S(k("row"),k("column")),workspaceId:v}),dt=b({type:S(k("row"),k("column")),itemId:v}),lt=b({itemId:v,config:fe}),ht=b({frameSummary:he,frameBounds:I(_e)}),ut=b({workspaceSummary:Le,frameSummary:he,workspaceSnapshot:I(Ie),frameBounds:I(_e)}),wt=b({containerSummary:lt}),pt=b({windowSummary:b({itemId:v,parentId:v,config:ye})}),mt=b({name:v,workspaceId:v,saveContext:I(f()),allowMultiple:I(f()),metadata:I(b())}),gt=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())}),ft=b({workspaceId:v,config:I(gt)}),yt=b({allowExtract:I(f()),allowReorder:I(f()),showCloseButton:I(f())}),kt=b({width:I(C),height:I(C)}),bt=b({windowPlacementId:v,config:I(yt)}),Wt=b({allowDrop:I(f()),allowSplitters:I(f())}),It=b({allowDrop:I(f()),allowSplitters:I(f())}),St=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())}),xt=b({itemId:v,type:k("row"),config:I(Wt)}),Dt=b({itemId:v,type:k("column"),config:I(It)}),vt=b({itemId:v,type:k("group"),config:I(St)}),Ct=S(xt,Dt,vt),Et=b({workspaceId:v,icon:I(v)}),Bt=b({workspaceId:v,icon:I(v)}),Tt=I(b({icon:I(v)})),Mt=b({shortcut:v,frameId:v}),Rt=b({shortcut:v,frameId:v}),Lt=b({frameId:v}),At=b({enabled:f()}),Ft=b({itemId:v,type:P}),Pt=b({operation:v}),zt=b({itemId:v,dragMode:B}),Ot=b({itemId:v,strategy:Y}),Ht=b({prevent:f()}),$t="T42.Web.Platform.Control",_t="T42.Web.Platform.WSP.Stream",jt={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}},Gt={control:{name:"T42.Workspaces.Client.Control",isStream:!1}},Nt={frame:{name:"T42.Workspaces.Stream.Frame",payloadDecoder:ht},workspace:{name:"T42.Workspaces.Stream.Workspace",payloadDecoder:ut},container:{name:"T42.Workspaces.Stream.Container",payloadDecoder:wt},window:{name:"T42.Workspaces.Stream.Window",payloadDecoder:pt}},Jt={shortcutClicked:{name:"shortcutClicked",argsDecoder:Rt,resultDecoder:He},frameClosing:{name:"frameClosing",argsDecoder:Lt,resultDecoder:Ht}},Ut={ping:{name:"ping",resultDecoder:st},isWindowInWorkspace:{name:"isWindowInWorkspace",argsDecoder:qe,resultDecoder:T},createWorkspace:{name:"createWorkspace",resultDecoder:Ie,argsDecoder:ce},createFrame:{name:"createFrame",resultDecoder:Me,argsDecoder:ne},initFrame:{name:"initFrame",resultDecoder:He,argsDecoder:ae},getAllFramesSummaries:{name:"getAllFramesSummaries",resultDecoder:Re},getFrameSummary:{name:"getFrameSummary",resultDecoder:he,argsDecoder:de},getAllWorkspacesSummaries:{name:"getAllWorkspacesSummaries",resultDecoder:Ae},getWorkspaceSnapshot:{name:"getWorkspaceSnapshot",resultDecoder:Ie,argsDecoder:qe},getAllLayoutsSummaries:{name:"getAllLayoutsSummaries",resultDecoder:ze},openWorkspace:{name:"openWorkspace",argsDecoder:ee,resultDecoder:Ie},deleteLayout:{name:"deleteLayout",resultDecoder:He,argsDecoder:H},saveLayout:{name:"saveLayout",resultDecoder:Ce,argsDecoder:mt},importLayout:{name:"importLayout",resultDecoder:He,argsDecoder:Ee},importLayouts:{name:"importLayouts",resultDecoder:He,argsDecoder:Be},exportAllLayouts:{name:"exportAllLayouts",resultDecoder:Te},restoreItem:{name:"restoreItem",argsDecoder:qe,resultDecoder:He},maximizeItem:{name:"maximizeItem",argsDecoder:qe,resultDecoder:He},focusItem:{name:"focusItem",argsDecoder:qe,resultDecoder:He},closeItem:{name:"closeItem",argsDecoder:Ve,resultDecoder:He},resizeItem:{name:"resizeItem",argsDecoder:tt,resultDecoder:He},setMaximizationBoundary:{name:"setMaximizationBoundary",argsDecoder:rt,resultDecoder:He},changeFrameState:{name:"changeFrameState",argsDecoder:Ye,resultDecoder:He},getFrameState:{name:"getFrameState",argsDecoder:qe,resultDecoder:$e},getFrameBounds:{name:"getFrameBounds",argsDecoder:qe,resultDecoder:je},moveFrame:{name:"moveFrame",argsDecoder:ot,resultDecoder:He},getFrameSnapshot:{name:"getFrameSnapshot",argsDecoder:Xe,resultDecoder:Fe},forceLoadWindow:{name:"forceLoadWindow",argsDecoder:qe,resultDecoder:Oe},ejectWindow:{name:"ejectWindow",argsDecoder:qe,resultDecoder:Oe},setItemTitle:{name:"setItemTitle",argsDecoder:Ze,resultDecoder:He},moveWindowTo:{name:"moveWindowTo",argsDecoder:et,resultDecoder:He},addWindow:{name:"addWindow",argsDecoder:nt,resultDecoder:at},addContainer:{name:"addContainer",argsDecoder:it,resultDecoder:at},bundleWorkspace:{name:"bundleWorkspace",argsDecoder:ct,resultDecoder:He},bundleItem:{name:"bundleItem",argsDecoder:dt,resultDecoder:He},hibernateWorkspace:{name:"hibernateWorkspace",argsDecoder:re,resultDecoder:He},resumeWorkspace:{name:"resumeWorkspace",argsDecoder:re,resultDecoder:He},lockWorkspace:{name:"lockWorkspace",argsDecoder:ft,resultDecoder:He},lockWindow:{name:"lockWindow",argsDecoder:bt,resultDecoder:He},lockContainer:{name:"lockContainer",argsDecoder:Ct,resultDecoder:He},pinWorkspace:{name:"pinWorkspace",argsDecoder:Et,resultDecoder:He},unpinWorkspace:{name:"unpinWorkspace",argsDecoder:re,resultDecoder:He},getWorkspaceIcon:{name:"getWorkspaceIcon",argsDecoder:re,resultDecoder:Ge},setWorkspaceIcon:{name:"setWorkspaceIcon",argsDecoder:Bt,resultDecoder:He},registerShortcut:{name:"registerShortcut",argsDecoder:Mt,resultDecoder:He},unregisterShortcut:{name:"unregisterShortcut",argsDecoder:Mt,resultDecoder:He},showLoadingAnimation:{name:"showLoadingAnimation",argsDecoder:Ft,resultDecoder:He},hideLoadingAnimation:{name:"hideLoadingAnimation",argsDecoder:Ft,resultDecoder:He},getPlatformFrameId:{name:"getPlatformFrameId",resultDecoder:Ne},operationCheck:{name:"operationCheck",argsDecoder:Pt,resultDecoder:Je},setWindowDragMode:{name:"setWindowDragMode",argsDecoder:zt,resultDecoder:He},setLoadingStrategy:{name:"setLoadingStrategy",argsDecoder:Ot,resultDecoder:He},getTaskbarIcon:{name:"getTaskbarIcon",resultDecoder:M},setTaskbarIcon:{name:"setTaskbarIcon",argsDecoder:R,resultDecoder:He},subscribeToFrameClosing:{name:"subscribeToFrameClosing",argsDecoder:qe,resultDecoder:He}};class Kt{resolve;reject;promise;constructor(){this.promise=new Promise(((e,t)=>{this.resolve=e,this.reject=t}))}}class qt{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(Ut).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 Kt,o={streamType:e.eventType,level:e.scope,levelId:e.scopeId,promise:t.promise};this.pendingSubScriptions.push(o);try{const o=Nt[e.eventType],n=await this.transport.subscribe(o.name,this.getBranchKey(e),e.eventType);n.onData((e=>{const t=e.data,r=we.run(e.requestArguments),o=pe.run(t.action);if(!r.ok||!o.ok)return;const n=r.result.type,i=`${n}-${r.result.branch}-${o.result}`,a=Nt[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(Jt).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)}))}onOperationWithResponse(e){return this.transport.onInternalMethodInvoked("control",(async(t,r)=>{const o=t.operation,n=t.data,i=Object.values(Jt).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}`)}const a=await e(t,r);if(i.resultDecoder)try{i.resultDecoder.runWithException(a)}catch(e){throw new Error(`Unexpected internal outgoing result validation error: ${e.message}, for input: ${JSON.stringify(e.input)}, for operation ${o}`)}return a}))}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=pe.runWithException(t.action),r=ue.runWithException(t.type),o=Nt[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 Qt=()=>"undefined"==typeof window||(window.glue42gd||window.iodesktop),Vt=()=>"undefined"==typeof window?null:window.glue42core||window.iobrowser;class Xt{agm;registry;defaultTransportTimeout=12e4;coreEventMethodInitiated=!1;corePlatformSubPromise;constructor(e,t){this.agm=e,this.registry=t}async initiate(e){if(Qt())return await Promise.all(Object.values(jt).map((e=>this.verifyMethodLive(e.name)))),void await Promise.all(Object.keys(Gt).map((e=>this.registerMethod(e))));const t=Vt().communicationId;await Promise.all([this.verifyMethodLive($t,t),this.verifyMethodLive(_t,t)]),await this.transmitControl("frameHello",{windowId:e})}coreSubscriptionReady(e){return this.coreEventMethodInitiated||this.subscribePlatform(e),this.corePlatformSubPromise}subscribePlatform(e){this.coreEventMethodInitiated=!0;const t=Vt().communicationId;this.corePlatformSubPromise=this.agm.subscribe(_t,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=Qt()?{operation:e,operationArguments:t}:{operation:e,domain:"workspaces",data:t},o=Qt()?jt.control.name:$t,n=Qt()?void 0:Vt().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=Gt[e];return this.agm.register(t.name,((t,r)=>Promise.all(this.registry.execute(e,t,r))))}}const Yt=new WeakMap;class Zt{constructor(e,t){const r=t.wrapChildren(e.children);delete e.children,Yt.set(this,{base:t,children:r,definition:e})}get type(){return Yt.get(this).definition.type}addColumn(e){return Yt.get(this).base.add("column",Yt.get(this).children,e)}addRow(e){return Yt.get(this).base.add("row",Yt.get(this).children,e)}addGroup(e){return Yt.get(this).base.add("group",Yt.get(this).children,e)}addWindow(e){return Yt.get(this).base.addWindow(Yt.get(this).children,e),this}serialize(){const e=Yt.get(this).definition;return e.children=Yt.get(this).base.serializeChildren(Yt.get(this).children),e}}class er{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=U.runWithException(r),n=this.getBuilder({type:e,definition:o});return t.push(n),n}addWindow(e,t){const r=N.runWithException(t);r.type="window",e.push(r)}serializeChildren(e){return e.map((e=>e instanceof Zt?e.serialize():e))}}const tr=new WeakMap;class rr{constructor(e,t,r){const o=t.wrapChildren(e.children);delete e.children,tr.set(this,{base:t,children:o,definition:e,controller:r})}addColumn(e){const t=tr.get(this).children;if(!t.every((e=>e instanceof Zt&&"column"===e.type)))throw new Error("Cannot add a column to this workspace, because there are already children of another type");return tr.get(this).base.add("column",t,e)}addRow(e){const t=tr.get(this).children;if(!t.every((e=>e instanceof Zt&&"row"===e.type)))throw new Error("Cannot add a row to this workspace, because there are already children of another type");return tr.get(this).base.add("row",t,e)}addGroup(e){const t=tr.get(this).children;if(0!==t.length)throw new Error("Cannot add a group to this workspace, because there are already defined children.");return tr.get(this).base.add("group",t,e)}addWindow(e){const t=tr.get(this).children;if(0!==t.length)throw new Error("Cannot add a window to this workspace, because there are already defined children.");return tr.get(this).base.addWindow(t,e),this}getChildAt(e){C.runWithException(e);return tr.get(this).children[e]}async create(e){const t=O.runWithException(e),r=tr.get(this).definition;r.children=tr.get(this).base.serializeChildren(tr.get(this).children);return tr.get(this).controller.createWorkspace(r,t)}}const or=new WeakMap,nr=e=>or.get(e).base;class ir{constructor(e){or.set(this,{base:e})}get type(){return"row"}get id(){return nr(this).getId(this)}get frameId(){return nr(this).getFrameId(this)}get workspaceId(){return nr(this).getWorkspaceId(this)}get positionIndex(){return nr(this).getPositionIndex(this)}get children(){return nr(this).getAllChildren(this)}get parent(){return nr(this).getMyParent(this)}get frame(){return nr(this).getMyFrame(this)}get workspace(){return nr(this).getMyWorkspace(this)}get allowDrop(){return nr(this).getAllowDrop(this)}get allowSplitters(){return nr(this).getAllowSplitters(this)}get minWidth(){return nr(this).getMinWidth(this)}get minHeight(){return nr(this).getMinHeight(this)}get maxWidth(){return nr(this).getMaxWidth(this)}get maxHeight(){return nr(this).getMaxHeight(this)}get width(){return nr(this).getWidthInPx(this)}get height(){return nr(this).getHeightInPx(this)}get isPinned(){return nr(this).getIsPinned(this)}get isMaximized(){return nr(this).getIsMaximized(this)}get maximizationBoundary(){return nr(this).getMaximizationBoundary(this)}addWindow(e){return nr(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 nr(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 nr(this).addParent(this,"column","row",e)}async addRow(){throw new Error("Adding rows as row children is not supported")}removeChild(e){return nr(this).removeChild(this,e)}maximize(){return nr(this).maximize(this)}restore(){return nr(this).restore(this)}close(){return nr(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:Wt.runWithException(t);return nr(this).lockContainer(this,r)}async setHeight(e){return C.runWithException(e),nr(this).setHeight(this,e)}async onLockConfigurationChanged(e){z(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 nr(this).processLocalSubscription(this,t)}async setMaximizationBoundary(e){const t=At.runWithException(e);return nr(this).setMaximizationBoundary(this,t)}}const ar=new WeakMap,sr=e=>ar.get(e).base;class cr{constructor(e){ar.set(this,{base:e})}get type(){return"column"}get id(){return sr(this).getId(this)}get frameId(){return sr(this).getFrameId(this)}get workspaceId(){return sr(this).getWorkspaceId(this)}get positionIndex(){return sr(this).getPositionIndex(this)}get children(){return sr(this).getAllChildren(this)}get parent(){return sr(this).getMyParent(this)}get frame(){return sr(this).getMyFrame(this)}get workspace(){return sr(this).getMyWorkspace(this)}get allowDrop(){return sr(this).getAllowDrop(this)}get allowSplitters(){return sr(this).getAllowSplitters(this)}get minWidth(){return sr(this).getMinWidth(this)}get minHeight(){return sr(this).getMinHeight(this)}get maxWidth(){return sr(this).getMaxWidth(this)}get maxHeight(){return sr(this).getMaxHeight(this)}get width(){return sr(this).getWidthInPx(this)}get height(){return sr(this).getHeightInPx(this)}get isPinned(){return sr(this).getIsPinned(this)}get isMaximized(){return sr(this).getIsMaximized(this)}get maximizationBoundary(){return sr(this).getMaximizationBoundary(this)}addWindow(e){return sr(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 sr(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 sr(this).addParent(this,"row","column",e)}removeChild(e){return sr(this).removeChild(this,e)}maximize(){return sr(this).maximize(this)}restore(){return sr(this).restore(this)}close(){return sr(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:It.runWithException(t);return sr(this).lockContainer(this,r)}async setWidth(e){return C.runWithException(e),sr(this).setWidth(this,e)}async onLockConfigurationChanged(e){z(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 sr(this).processLocalSubscription(this,t)}async setMaximizationBoundary(e){const t=At.runWithException(e);return sr(this).setMaximizationBoundary(this,t)}}const dr=new WeakMap,lr=e=>dr.get(e).base;class hr{constructor(e){dr.set(this,{base:e})}get type(){return"group"}get id(){return lr(this).getId(this)}get frameId(){return lr(this).getFrameId(this)}get workspaceId(){return lr(this).getWorkspaceId(this)}get positionIndex(){return lr(this).getPositionIndex(this)}get children(){return lr(this).getAllChildren(this)}get parent(){return lr(this).getMyParent(this)}get frame(){return lr(this).getMyFrame(this)}get workspace(){return lr(this).getMyWorkspace(this)}get allowExtract(){return lr(this).getAllowExtract(this)}get allowReorder(){return lr(this).getAllowReorder(this)}get allowDropLeft(){return lr(this).getAllowDropLeft(this)}get allowDropRight(){return lr(this).getAllowDropRight(this)}get allowDropTop(){return lr(this).getAllowDropTop(this)}get allowDropBottom(){return lr(this).getAllowDropBottom(this)}get allowDropHeader(){return lr(this).getAllowDropHeader(this)}get allowDrop(){return lr(this).getAllowDrop(this)}get showMaximizeButton(){return lr(this).getShowMaximizeButton(this)}get showEjectButton(){return lr(this).getShowEjectButton(this)}get showAddWindowButton(){return lr(this).getShowAddWindowButton(this)}get minWidth(){return lr(this).getMinWidth(this)}get minHeight(){return lr(this).getMinHeight(this)}get maxWidth(){return lr(this).getMaxWidth(this)}get maxHeight(){return lr(this).getMaxHeight(this)}get width(){return lr(this).getWidthInPx(this)}get height(){return lr(this).getHeightInPx(this)}get isMaximized(){return lr(this).getIsMaximized(this)}addWindow(e){return lr(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 lr(this).removeChild(this,e)}maximize(){return lr(this).maximize(this)}restore(){return lr(this).restore(this)}close(){return lr(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:St.runWithException(t);return lr(this).lockContainer(this,r)}async setSize(e){const t=kt.runWithException(e);if(!t.width&&!t.height)throw new Error("Expected either width or height to be passed.");return lr(this).setSize(this,e.width,e.height)}async bundleToRow(){await lr(this).bundleTo(this,"row"),await this.workspace.refreshReference()}async bundleToColumn(){await lr(this).bundleTo(this,"column"),await this.workspace.refreshReference()}async onLockConfigurationChanged(e){z(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 lr(this).processLocalSubscription(this,t)}}const ur=new WeakMap,wr=e=>ur.get(e).manager.getWorkspaceData(e),pr=e=>ur.get(e).manager;class mr{constructor(e){ur.set(this,{manager:e})}get id(){return wr(this).id}get frameId(){return wr(this).config.frameId}get positionIndex(){return wr(this).config.positionIndex}get title(){return wr(this).config.title}get layoutName(){return wr(this).config.layoutName}get isHibernated(){return wr(this).config.isHibernated}get isSelected(){return wr(this).config.isSelected}get children(){return wr(this).children}get frame(){return wr(this).frame}get allowSplitters(){return wr(this).config.allowSplitters}get allowSystemHibernation(){return wr(this).config.allowSystemHibernation}get allowDrop(){return wr(this).config.allowDrop}get allowDropLeft(){return wr(this).config.allowDropLeft}get allowDropTop(){return wr(this).config.allowDropTop}get allowDropRight(){return wr(this).config.allowDropRight}get allowDropBottom(){return wr(this).config.allowDropBottom}get allowExtract(){return wr(this).config.allowExtract}get allowWindowReorder(){return wr(this).config.allowWindowReorder}get showCloseButton(){return wr(this).config.showCloseButton}get showSaveButton(){return wr(this).config.showSaveButton}get allowWorkspaceTabReorder(){return wr(this).config.allowWorkspaceTabReorder}get allowWorkspaceTabExtract(){return wr(this).config.allowWorkspaceTabExtract}get minWidth(){return wr(this).config.minWidth}get minHeight(){return wr(this).config.minHeight}get maxWidth(){return wr(this).config.maxWidth}get maxHeight(){return wr(this).config.maxHeight}get width(){return wr(this).config.widthInPx}get height(){return wr(this).config.heightInPx}get showWindowCloseButtons(){return wr(this).config.showWindowCloseButtons}get showEjectButtons(){return wr(this).config.showEjectButtons}get showAddWindowButtons(){return wr(this).config.showAddWindowButtons}get isPinned(){return wr(this).config.isPinned}get windowDragMode(){return Qt()?wr(this).config.windowDragMode:"keepInside"}get loadingStrategy(){return Qt()||console.warn("The workspace.loadingStrategy property is not supported in IO Connect Browser"),wr(this).config.loadingStrategy}async setLoadingStrategy(e){if(!Qt())throw new Error("Not supported in IO Connect Browser");const t=wr(this).controller;await t.setLoadingStrategy(this.id,e),await this.refreshReference()}async removeChild(e){z(e);const t=this.children.find(e);t&&(await t.close(),await this.refreshReference())}async remove(e){z(e);const t=wr(this).controller.iterateFindChild(this.children,e);await t.close(),await this.refreshReference()}async focus(){await wr(this).controller.focusItem(this.id),await this.refreshReference()}async close(){const e=wr(this).controller,t=await wr(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 wr(this).controller.getSnapshot(this.id,"workspace")}async saveLayout(e,t){v.runWithException(e),await wr(this).controller.saveLayout({name:e,workspaceId:this.id,saveContext:t?.saveContext,metadata:t?.metadata,allowMultiple:t?.allowMultiple})}async setTitle(e){v.runWithException(e);const t=wr(this).controller;await t.setItemTitle(this.id,e),await this.refreshReference()}getContext(){return wr(this).controller.getWorkspaceContext(this.id)}setContext(e){return wr(this).controller.setWorkspaceContext(this.id,e)}updateContext(e){return wr(this).controller.updateWorkspaceContext(this.id,e)}onContextUpdated(e){return wr(this).controller.subscribeWorkspaceContextUpdated(this.id,e)}async refreshReference(){const e=await wr(this).controller.getSnapshot(this.id,"workspace"),t=wr(this).controller.flatChildren(wr(this).children),r=wr(this).controller.refreshChildren({existingChildren:t,workspace:this,parent:this,children:e.children}),o=this.frame;let n;if(o.id===e.config.frameId)pr(this).remapFrame(o,e.frameSummary),n=o;else{const t={summary:e.frameSummary};n=wr(this).ioc.getModel("frame",t)}pr(this).remapWorkspace(this,{config:e.config,children:r,frame:n})}async getIcon(){return wr(this).controller.getWorkspaceIcon(this.id)}async setIcon(e){return wr(this).controller.setWorkspaceIcon(this.id,e)}getBox(e){z(e);const t=wr(this).children;return wr(this).controller.iterateFindChild(t,(t=>"window"!==t.type&&e(t)))}getAllBoxes(e){z(e,!0);const t=wr(this).children,r=wr(this).controller.iterateFilterChildren(t,(e=>"window"!==e.type));return e?r.filter(e):r}getRow(e){return z(e),this.getBox((t=>"row"===t.type&&e(t)))}getAllRows(e){return z(e,!0),e?this.getAllBoxes((t=>"row"===t.type&&e(t))):this.getAllBoxes((e=>"row"===e.type))}getColumn(e){return z(e),this.getBox((t=>"column"===t.type&&e(t)))}getAllColumns(e){return z(e,!0),e?this.getAllBoxes((t=>"column"===t.type&&e(t))):this.getAllBoxes((e=>"column"===e.type))}getGroup(e){return z(e),this.getBox((t=>"group"===t.type&&e(t)))}getAllGroups(e){return z(e,!0),e?this.getAllBoxes((t=>"group"===t.type&&e(t))):this.getAllBoxes((e=>"group"===e.type))}getWindow(e){z(e);const t=wr(this).children;return wr(this).controller.iterateFindChild(t,(t=>"window"===t.type&&e(t)))}getAllWindows(e){z(e,!0);const t=wr(this).children,r=wr(this).controller.iterateFilterChildren(t,(e=>"window"===e.type));return e?r.filter(e):r}addRow(e){return wr(this).base.addParent(this,"row","workspace",e)}addColumn(e){return wr(this).base.addParent(this,"column","workspace",e)}addGroup(e){return wr(this).base.addParent(this,"group","workspace",e)}addWindow(e){return wr(this).base.addWindow(this,e,"workspace")}async bundleToRow(){await wr(this).controller.bundleWorkspaceTo("row",this.id),await this.refreshReference()}async bundleToColumn(){await wr(this).controller.bundleWorkspaceTo("column",this.id),await this.refreshReference()}async hibernate(){await wr(this).controller.hibernateWorkspace(this.id),await this.refreshReference()}async resume(){await wr(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:gt.runWithException(t);await wr(this).controller.lockWorkspace(this.id,r),await this.refreshReference()}async pin(e){Tt.runWithException(e),await wr(this).controller.pinWorkspace(this.id,e?.icon),await this.refreshReference()}async unpin(){await wr(this).controller.unpinWorkspace(this.id),await this.refreshReference()}async showLoadingAnimation(){if(!Qt())throw new Error("Not supported in IO Connect Browser");await wr(this).controller.showWorkspaceLoadingAnimation(this.id)}async hideLoadingAnimation(){if(!Qt())throw new Error("Not supported in IO Connect Browser");await wr(this).controller.hideWorkspaceLoadingAnimation(this.id)}async setWindowDragMode(e){if(!Qt())throw new Error("Not supported in IO Connect Browser");B.runWithException(e),await wr(this).controller.setWindowDragMode(this.id,e),await this.refreshReference()}async onClosed(e){z(e);const t=wr(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 wr(this).controller.processLocalSubscription(r,t)}async onHibernated(e){z(e);const t=wr(this).id,r={action:"hibernated",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await wr(this).controller.processLocalSubscription(r,t)}async onResumed(e){z(e);const t=wr(this).id,r={action:"resumed",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await wr(this).controller.processLocalSubscription(r,t)}async onWindowAdded(e){z(e);const t=wr(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 wr(this).controller.processLocalSubscription(r,t)}async onWindowRemoved(e){z(e);const t=wr(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 wr(this).controller.processLocalSubscription(r,t)}async onWindowLoaded(e){z(e);const t=wr(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 wr(this).controller.processLocalSubscription(r,t)}async onWindowMaximized(e){z(e);const t=wr(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 wr(this).controller.processLocalSubscription(r,t)}async onWindowRestored(e){z(e);const t=wr(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 wr(this).controller.processLocalSubscription(r,t)}async onWindowSelected(e){z(e);const t=wr(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 wr(this).controller.processLocalSubscription(r,t)}async onLockConfigurationChanged(e){z(e);const t=wr(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 wr(this).controller.processLocalSubscription(r,t)}}const gr=new WeakMap,fr=e=>gr.get(e).manager.getWindowData(e);class yr{constructor(e){gr.set(this,{manager:e})}get id(){return fr(this).config.windowId}get elementId(){return fr(this).id}get type(){return"window"}get frameId(){return fr(this).frame.id}get workspaceId(){return fr(this).workspace.id}get positionIndex(){return fr(this).config.positionIndex}get isMaximized(){return fr(this).config.isMaximized}get isLoaded(){return fr(this).controller.checkIsWindowLoaded(this.id)}get isSelected(){return fr(this).config.isSelected}get focused(){return this.getGdWindow().isFocused}get title(){return fr(this).config.title}get allowExtract(){return fr(this).config.allowExtract}get allowReorder(){return fr(this).config.allowReorder}get showCloseButton(){return fr(this).config.showCloseButton}get width(){return fr(this).config.widthInPx}get height(){return fr(this).config.heightInPx}get minWidth(){return fr(this).config.minWidth}get minHeight(){return fr(this).config.minHeight}get maxWidth(){return fr(this).config.maxWidth}get maxHeight(){return fr(this).config.maxHeight}get workspace(){return fr(this).workspace}get frame(){return fr(this).frame}get parent(){return fr(this).parent}get appName(){return fr(this).config.appName}async forceLoad(){if(this.isLoaded)return;const e=fr(this).controller,t=fr(this).id,r=await e.forceLoadWindow(t);fr(this).config.windowId=r,await this.workspace.refreshReference()}async focus(){const e=fr(this).id,t=fr(this).controller;await t.focusItem(e),await this.workspace.refreshReference()}async close(){const e=fr(this).id,t=fr(this).controller;await t.closeItem(e),await fr(this).parent.removeChild((t=>t.id===e)),await this.workspace.refreshReference()}async setTitle(e){v.runWithException(e);const t=fr(this).id,r=fr(this).controller;await r.setItemTitle(t,e),await this.workspace.refreshReference()}async maximize(){const e=fr(this).id,t=fr(this).controller;await t.maximizeItem(e),await this.workspace.refreshReference()}async restore(){const e=fr(this).id,t=fr(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=fr(this).id,t=await fr(this).controller.ejectWindow(e);return fr(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=fr(this).config.windowId;return fr(this).controller.getGDWindow(e)}async moveTo(e){if(!(e instanceof ir||e instanceof cr||e instanceof hr))throw new Error("Cannot add to the provided parent, because the provided parent is not an instance of Row, Column or Group");const t=fr(this).id,r=fr(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:yt.runWithException(t),o=fr(this).id;await fr(this).controller.lockWindow(o,r),await this.workspace.refreshReference()}async setSize(e){const t=kt.runWithException(e);if(!t.width&&!t.height)throw new Error("Expected either width or height to be passed.");const r=fr(this).id,o=fr(this).controller;await o.resizeItem(r,{height:t.height,width:t.width,relative:!1}),await this.workspace.refreshReference()}async onRemoved(e){z(e);const t=fr(this).id,r={callback:async()=>{await this.workspace.refreshReference(),e()},action:"removed",eventType:"window",scope:"window"};return await fr(this).controller.processLocalSubscription(r,t)}async onLockConfigurationChanged(e){z(e);const t=fr(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 fr(this).controller.processLocalSubscription(r,t)}}const kr=new WeakMap,br=e=>kr.get(e).manager.getFrameData(e);class Wr{constructor(e){kr.set(this,{manager:e})}async registerShortcut(e,t){v.runWithException(e),z(t);const r=br(this).summary.id;return await br(this).controller.registerShortcut(e,r,t)}get id(){return br(this).summary.id}get isInitialized(){return br(this).summary.isInitialized}getBounds(){const e=br(this).summary.id;return br(this).controller.getFrameBounds(e)}async resize(e){const t=Ue.runWithException(e),r=br(this).summary.id;return br(this).controller.resizeItem(r,t)}async move(e){const t=Ke.runWithException(e),r=br(this).summary.id;return br(this).controller.moveFrame(r,t)}focus(){const e=br(this).summary.id;return br(this).controller.focusItem(e)}async state(){if(!Qt())throw new Error("State operations are not supported in IO Connect Browser");const e=br(this).summary.id;return br(this).controller.getFrameState(e)}setIcon(e){if(!Qt())throw new Error("frame.setIcon() is not supported in IO Connect Browser");M.runWithException(e);const t=this.id;return br(this).controller.setTaskbarIcon(e,t)}getIcon(){if(!Qt())throw new Error("frame.getIcon() is not supported in IO Connect Browser");const e=this.id;return br(this).controller.getTaskbarIcon(e)}async minimize(){if(!Qt())throw new Error("State operations are not supported in IO Connect Browser");const e=br(this).summary.id;return br(this).controller.changeFrameState(e,"minimized")}async maximize(){if(!Qt())throw new Error("State operations are not supported in IO Connect Browser");const e=br(this).summary.id;return br(this).controller.changeFrameState(e,"maximized")}async restore(){if(!Qt())throw new Error("State operations are not supported in IO Connect Browser");const e=br(this).summary.id;return br(this).controller.changeFrameState(e,"normal")}close(e){const t=I(Qe).runWithException(e),r=br(this).summary.id;return br(this).controller.closeFrame(r,t)}snapshot(){const e=br(this).summary.id;return br(this).controller.getSnapshot(e,"frame")}async workspaces(){return br(this).controller.getWorkspacesByFrameId(this.id)}async getConstraints(){const e=br(this).controller,t=br(this).summary.id;return e.getFrameConstraints(t)}async restoreWorkspace(e,t){v.runWithException(e);const r=Z.runWithException(t);return br(this).controller.restoreWorkspace(e,r)}createWorkspace(e,t){const r=te.runWithException(e),o=O.runWithException(t);return br(this).controller.createWorkspace(r,o)}async init(e){if(ie.runWithException(e),br(this).summary.isInitialized)throw new Error("The frame has already been initialized");return br(this).controller.initFrame(this.id,e)}async onClosing(e){if(!Qt())throw new Error("Frame closing operations are not supported in io.Connect Browser");z(e);return await br(this).controller.registerFrameOnClosing(this.id,(async()=>{let t=!1;return await e({prevent:()=>t=!0}),{prevent:t}}))}async onClosed(e){z(e);const t=br(this).summary.id,r={callback:t=>{e({frameId:t.frameSummary.id,frameBounds:t.frameBounds})},action:"closed",eventType:"frame",scope:"frame"};return await br(this).controller.processLocalSubscription(r,t)}async onMaximized(e){z(e);const t=br(this).summary.id,r={callback:()=>{e()},action:"maximized",eventType:"frame",scope:"frame"};return await br(this).controller.processLocalSubscription(r,t)}async onMinimized(e){z(e);const t=br(this).summary.id,r={callback:()=>{e()},action:"minimized",eventType:"frame",scope:"frame"};return await br(this).controller.processLocalSubscription(r,t)}async onNormal(e){z(e);const t=br(this).summary.id,r={callback:()=>{e()},action:"normal",eventType:"frame",scope:"frame"};return await br(this).controller.processLocalSubscription(r,t)}async onWorkspaceOpened(e){z(e);const t=br(this).summary.id,r={callback:async t=>{const r=await br(this).controller.transformStreamPayloadToWorkspace(t);e(r)},action:"opened",eventType:"workspace",scope:"frame"};return await br(this).controller.processLocalSubscription(r,t)}async onWorkspaceSelected(e){z(e);const t=br(this).summary.id,r={callback:async t=>{const r=await br(this).controller.getWorkspaceById(t.workspaceSummary.id);e(r)},action:"selected",eventType:"workspace",scope:"frame"};return await br(this).controller.processLocalSubscription(r,t)}async onWorkspaceClosed(e){z(e);const t=br(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 br(this).controller.processLocalSubscription(r,t)}async onWindowAdded(e){z(e);const t=br(this).summary.id,r={callback:async t=>{const r=(await br(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 br(this).controller.processLocalSubscription(r,t)}async onWindowRemoved(e){z(e);const t=br(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 br(this).controller.processLocalSubscription(r,t)}async onWindowLoaded(e){z(e);const t=br(this).summary.id,r={callback:async t=>{const r=(await br(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 br(this).controller.processLocalSubscription(r,t)}async onInitializationRequested(e){return z(e),this.isInitialized||e(br(this).summary.initializationContext),()=>{}}async onFocusChanged(e){z(e);const t=br(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 Ir{parentsData=new WeakMap;workspacesData=new WeakMap;windowsData=new WeakMap;framesData=new WeakMap;deleteData(e){e instanceof yr&&this.windowsData.delete(e),e instanceof mr&&this.workspacesData.delete(e),(e instanceof ir||e instanceof cr||e instanceof hr)&&this.parentsData.delete(e),e instanceof Wr&&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 yr){const r=this.windowsData.get(e);r.parent=t.parent||r.parent,r.config=t.config||r.config}if(e instanceof ir||e instanceof cr||e instanceof hr){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 Sr=new WeakMap,xr=(e,t)=>{const r=Sr.get(e).manager;return t instanceof mr?r.getWorkspaceData(t):Sr.get(e).manager.getParentData(t)};class Dr{frameId;workspaceId;positionIndex;constructor(e){Sr.set(this,{manager:e})}getId(e){return xr(this,e).id}getPositionIndex(e){return xr(this,e).config.positionIndex}getWorkspaceId(e){const t=xr(this,e);return t.config.workspaceId||t.workspace.id}getFrameId(e){return xr(this,e).frame.id}getAllChildren(e,t){z(t,!0);const r=xr(this,e).children;return void 0===t?r:r.filter(t)}getMyParent(e){return e instanceof mr?e:xr(this,e).parent}getMyFrame(e){return xr(this,e).frame}getMyWorkspace(e){return e instanceof mr?e:xr(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=N.runWithException(t),n=xr(this,e).controller,i=await n.add("window",xr(this,e).id,r,o);if(e instanceof mr)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=xr(this,e).controller,a=(await i.add("container",xr(this,e).id,r,n)).itemId;if(e instanceof mr)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){z(t);const r=this.getAllChildren(e).find(t);r&&(await r.close(),e instanceof mr?await e.refreshReference():await this.getMyWorkspace(e).refreshReference())}async maximize(e){const{controller:t,id:r}=xr(this,e);await t.maximizeItem(r),await this.getMyWorkspace(e.parent).refreshReference()}async restore(e){const{controller:t,id:r}=xr(this,e);await t.restoreItem(r),await this.getMyWorkspace(e.parent).refreshReference()}async close(e){const t=xr(this,e),r=xr(this,e).controller;await r.closeItem(t.id),await this.getMyWorkspace(t.parent).refreshReference()}async lockContainer(e,t){const r=xr(this,e),o=xr(this,e).controller;await o.lockContainer(r.id,e.type,t),await this.getMyWorkspace(r.parent).refreshReference()}getAllowDrop(e){return xr(this,e).config.allowDrop}getAllowDropLeft(e){const t=xr(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=xr(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=xr(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=xr(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=xr(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=xr(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=xr(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=xr(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=xr(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=xr(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=xr(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 xr(this,e).config.minWidth}getMaxWidth(e){return xr(this,e).config.maxWidth}getMinHeight(e){return xr(this,e).config.minHeight}getMaxHeight(e){return xr(this,e).config.maxHeight}getWidthInPx(e){return xr(this,e).config.widthInPx}getHeightInPx(e){return xr(this,e).config.heightInPx}getIsPinned(e){return xr(this,e).config.isPinned}getIsMaximized(e){return xr(this,e).config.isMaximized}getMaximizationBoundary(e){return xr(this,e).config.maximizationBoundary}async setHeight(e,t){const r=xr(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=xr(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=xr(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=xr(this,e),{controller:o,id:n}=r;await o.setMaximizationBoundary(n,t),await this.getMyWorkspace(r.parent).refreshReference()}async bundleTo(e,t){const r=xr(this,e),{controller:o,id:n}=r;await o.bundleItemTo(t,n)}async processLocalSubscription(e,t){return xr(this,e).controller.processLocalSubscription(t,this.getId(e))}transformDefinition(e,t){let r;return void 0===t?r={type:e,children:[]}:t instanceof Zt?r=t.serialize():(void 0===t.type&&(t.type=e),r=V.runWithException(t),r.children=r.children||[]),r}}class vr{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(Ut.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(Ut.createFrame.name,e)};return this.ioc.getModel("frame",t)}async initFrame(e,t){await this.bridge.send(Ut.initFrame.name,{frameId:e,...t})}async restoreWorkspace(e,t){const r=await this.bridge.send(Ut.openWorkspace.name,{name:e,restoreOptions:t}),o={summary:await this.bridge.send(Ut.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=Ut.addWindow.name;else{if("container"!==e)throw new Error(`Unrecognized add type: ${e}`);n=Ut.addContainer.name}return await this.bridge.send(n,i)}async getFrame(e){const t={summary:await this.bridge.send(Ut.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(Ut.getWorkspaceSnapshot.name,{itemId:e.workspaceSummary.id})};return this.ioc.getModel("workspace",r)}async fetchWorkspace(e){const t=await this.bridge.send(Ut.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(Ut.bundleWorkspace.name,{type:e,workspaceId:t})}async bundleItemTo(e,t){if(!await this.isOperationSupported(Ut.bundleItem.name))throw new Error(`Operation ${Ut.bundleItem.name} is not supported. Ensure that you are running the latest version of all packages`);await this.bridge.send(Ut.bundleItem.name,{type:e,itemId:t})}async getTaskbarIcon(e){return await this.bridge.send(Ut.getTaskbarIcon.name,{frameId:e})}async setTaskbarIcon(e,t){await this.bridge.send(Ut.setTaskbarIcon.name,{icon:e,frameId: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(Ut.restoreItem.name,{itemId:e})}async maximizeItem(e){await this.bridge.send(Ut.maximizeItem.name,{itemId:e})}async focusItem(e){await this.bridge.send(Ut.focusItem.name,{itemId:e})}async closeItem(e){await this.bridge.send(Ut.closeItem.name,{itemId:e})}async closeFrame(e,t){await this.bridge.send(Ut.closeItem.name,{itemId:e,closeOptions:t})}async resizeItem(e,t){await this.bridge.send(Ut.resizeItem.name,Object.assign({},{itemId:e},t))}async setMaximizationBoundary(e,t){await this.bridge.send(Ut.setMaximizationBoundary.name,Object.assign({},{itemId:e},t))}async showWorkspaceLoadingAnimation(e){await this.bridge.send(Ut.showLoadingAnimation.name,{itemId:e,type:"workspace"})}async hideWorkspaceLoadingAnimation(e){await this.bridge.send(Ut.hideLoadingAnimation.name,{itemId:e,type:"workspace"})}async setWindowDragMode(e,t){await this.bridge.send(Ut.setWindowDragMode.name,{itemId:e,dragMode:t})}async moveFrame(e,t){await this.bridge.send(Ut.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(Ut.forceLoadWindow.name,{itemId:e})).windowId}async ejectWindow(e){return await this.bridge.send(Ut.ejectWindow.name,{itemId:e})}async moveWindowTo(e,t){await this.bridge.send(Ut.moveWindowTo.name,{itemId:e,containerId:t})}async getSnapshot(e,t){let r;return"workspace"===t?r=await this.bridge.send(Ut.getWorkspaceSnapshot.name,{itemId:e}):"frame"===t&&(r=await this.bridge.send(Ut.getFrameSnapshot.name,{itemId:e})),r}async setItemTitle(e,t){await this.bridge.send(Ut.setItemTitle.name,{itemId:e,title:t})}refreshChildren(e){const{parent:t,children:r,existingChildren:o,workspace:n}=e;if(t instanceof yr||"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 mr||this.privateDataManager.remapChild(t,{children:i}),i}iterateFindChild(e,t){let r=e.find((e=>t(e)));return r||(e.some((e=>!(e instanceof yr)&&(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 yr||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(Ut.hibernateWorkspace.name,{workspaceId:e})}async resumeWorkspace(e){await this.bridge.send(Ut.resumeWorkspace.name,{workspaceId:e})}async lockWorkspace(e,t){await this.bridge.send(Ut.lockWorkspace.name,{workspaceId:e,config:t})}async lockWindow(e,t){await this.bridge.send(Ut.lockWindow.name,{windowPlacementId:e,config:t})}async lockContainer(e,t,r){await this.bridge.send(Ut.lockContainer.name,{itemId:e,type:t,config:r})}async pinWorkspace(e,t){await this.bridge.send(Ut.pinWorkspace.name,{workspaceId:e,icon:t})}async unpinWorkspace(e){await this.bridge.send(Ut.unpinWorkspace.name,{workspaceId:e})}async getWorkspaceIcon(e){return(await this.bridge.send(Ut.getWorkspaceIcon.name,{workspaceId:e})).icon}setWorkspaceIcon(e,t){return this.bridge.send(Ut.setWorkspaceIcon.name,{workspaceId:e,icon:t})}async getPlatformFrameId(){try{return await this.bridge.send(Ut.getPlatformFrameId.name,{})}catch(e){return{}}}async setLoadingStrategy(e,t){return await this.isOperationSupported(Ut.setLoadingStrategy.name),this.bridge.send(Ut.setLoadingStrategy.name,{itemId:e,strategy:t})}async isOperationSupported(e){return Qt()?{isSupported:!0}:await this.bridge.send(Ut.operationCheck.name,{operation:e})}}class Cr{bridge;base;shortcutsController;closingController;constructor(e,t,r,o){this.bridge=e,this.base=t,this.shortcutsController=r,this.closingController=o}setTaskbarIcon(e,t){return this.base.setTaskbarIcon(e,t)}getTaskbarIcon(e){return this.base.getTaskbarIcon(e)}checkIsWindowLoaded(e){return this.base.checkIsWindowLoaded(e)}async checkIsInSwimlane(e){return(await this.bridge.send(Ut.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(Ut.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 Qt()?this.handleEnterpriseLocalSubscription(e,t):this.handleCoreLocalSubscription(e,t)}processGlobalSubscription(e,t,r){return Qt()?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(Ut.getAllFramesSummaries.name);return this.base.getFrames(t.summaries,e)}getWorkspaceById(e){return this.base.fetchWorkspace(e)}async getWorkspaceByWindowId(e){return Qt()?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(Ut.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(Ut.getAllLayoutsSummaries.name)).summaries}async deleteLayout(e){await this.bridge.send(Ut.deleteLayout.name,{name:e})}async exportLayout(e){return(await this.bridge.send(Ut.exportAllLayouts.name)).layouts.reduce(((t,r)=>(e&&!e(r)||t.push(r),t)),[])}async saveLayout(e){return await this.bridge.send(Ut.saveLayout.name,e)}async importLayouts(e,t){if(Qt())try{await this.bridge.send(Ut.importLayouts.name,{layouts:e,mode:t})}catch(r){await Promise.all(e.map((e=>this.bridge.send(Ut.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(Ut.changeFrameState.name,{frameId:e,requestedState:t})}async getFrameBounds(e){return(await this.bridge.send(Ut.getFrameBounds.name,{itemId:e})).bounds}async getFrameState(e){return(await this.bridge.send(Ut.getFrameState.name,{itemId:e})).state}async closeItem(e){return await this.base.closeItem(e)}async closeFrame(e,t){return await this.base.closeFrame(e,t)}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 setWindowDragMode(e,t){return await this.base.setWindowDragMode(e,t)}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()}setLoadingStrategy(e,t){return this.base.setLoadingStrategy(e,t)}registerFrameOnClosing(e,t){return this.closingController.registerFrameOnClosing(e,t)}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 Er{bridge;_shortcuts=r();constructor(e){this.bridge=e,this.bridge.onOperation((e=>{if(e.operation===Jt.shortcutClicked.name){const t=e.data;this._shortcuts.execute(`${t.frameId}-${t.shortcut}`)}}))}async registerShortcut(e,t,r){await this.bridge.send(Ut.registerShortcut.name,{shortcut:e,frameId:t});const o=this._shortcuts.add(`${t}-${e}`,r);return()=>{o(),this.bridge.send(Ut.unregisterShortcut.name,{shortcut:e,frameId:t})}}}class Br{bridge;registry=r();constructor(e){this.bridge=e,this.subscribeToFrameClosing()}async registerFrameOnClosing(e,t){return await this.bridge.send(Ut.subscribeToFrameClosing.name,{itemId:e}),this.registry.add(e,t)}subscribeToFrameClosing(){this.bridge.onOperationWithResponse((async e=>{if(e.operation!==Jt.frameClosing.name)return;const t=e.data,r=await Promise.all(this.registry.execute(t.frameId));return this.aggregateFrameClosingResult(r)}))}aggregateFrameClosingResult(e){return{prevent:e.some((e=>e?.prevent))}}}class Tr{agm;windows;layouts;contexts;_controllerInstance;_bridgeInstance;_transportInstance;_privateDataManagerInstance;_parentBaseInstance;_baseController;_shortcutsController;_closingController;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 vr(this,this.windows,this.contexts,this.layouts)),this._baseController}get controller(){return this._controllerInstance||(this._controllerInstance=new Cr(this.bridge,this.baseController,this.shortcutsController,this.closingController)),this._controllerInstance}get shortcutsController(){return this._shortcutsController||(this._shortcutsController=new Er(this.bridge)),this._shortcutsController}get closingController(){return this._closingController||(this._closingController=new Br(this.bridge)),this._closingController}get bridge(){return this._bridgeInstance||(this._bridgeInstance=new qt(this.transport,r())),this._bridgeInstance}get transport(){return this._transportInstance||(this._transportInstance=new Xt(this.agm,r())),this._transportInstance}get privateDataManager(){return this._privateDataManagerInstance||(this._privateDataManagerInstance=new Ir),this._privateDataManagerInstance}get parentBase(){return this._parentBaseInstance||(this._parentBaseInstance=new Dr(this.privateDataManager)),this._parentBaseInstance}async initiate(e){await this.transport.initiate(e)}getModel(e,t){switch(e){case"frame":{const e=new Wr(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 yr(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 cr(this.parentBase):"row"===e?new ir(this.parentBase):new hr(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 mr(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 er(this.getBuilder.bind(this));switch(e.type){case"workspace":return new rr(e.definition,t,this.controller);case"row":case"column":case"group":return e.definition.type=e.type,new Zt(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 Mr=async e=>{const t=new Tr(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=>(z(e,!0),r.getFrames(e)),n=async e=>(z(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=se.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=>(z(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=>(z(e),(await r.getWorkspaces(e))[0]),getWorkspaceById:async e=>(v.runWithException(e),r.getWorkspaceById(e)),getAllWorkspaces:e=>(z(e,!0),r.getWorkspaces(e)),getWindow:async e=>(z(e),r.getWindow(e)),getBox:async e=>(z(e),r.getParent(e)),restoreWorkspace:async(e,t)=>{v.runWithException(e);const o=Z.runWithException(t);return r.restoreWorkspace(e,o)},createWorkspace:async(e,t)=>{const o=te.runWithException(e),n=O.runWithException(t);return r.createWorkspace(o,n)},createEmptyFrame:async e=>{const t=ne.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=>(z(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=>Ce.runWithException(e))),r.importLayouts(e,t)},save:async e=>{const t=mt.runWithException(e);return r.saveLayout(t)},onSaved:async e=>(z(e),r.handleOnSaved(e)),onRemoved:async e=>(z(e),r.handleOnRemoved(e))},onFrameOpened:n,onFrameClosed:async e=>(z(e),await r.processGlobalSubscription((t=>{e({frameId:t.frameSummary.id,frameBounds:t.frameBounds})}),"frame","closed")),onWorkspaceOpened:async e=>(z(e),await r.processGlobalSubscription((async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)}),"workspace","opened")),onWorkspaceClosed:async e=>(z(e),await r.processGlobalSubscription((t=>{e({frameId:t.frameSummary.id,workspaceId:t.workspaceSummary.id,frameBounds:t.frameBounds})}),"workspace","closed")),onWorkspaceHibernated:async e=>(z(e),await r.processGlobalSubscription((async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)}),"workspace","hibernated")),onWorkspaceResumed:async e=>(z(e),await r.processGlobalSubscription((async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)}),"workspace","resumed")),onWindowAdded:async e=>(z(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=>(z(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=>(z(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=>(z(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=>(z(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=>(z(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.7"}})(e,t)};return"undefined"!=typeof window&&(window.IOWorkspaces=Mr),Mr}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interopio/workspaces-api",
3
- "version": "3.5.5",
3
+ "version": "3.5.7",
4
4
  "description": "IOConnect Workspaces API",
5
5
  "main": "dist/workspaces.umd.js",
6
6
  "module": "dist/workspaces.es.js",
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "@interopio/core": "^6.5.2"
37
37
  },
38
- "gitHead": "eb750be3359e58d4912b9473f2d9000cedeb19eb"
38
+ "gitHead": "cbeb941d9be28bd9e71c974699d2513d33f99b31"
39
39
  }
package/workspaces.d.ts CHANGED
@@ -218,6 +218,21 @@ export namespace IOConnectWorkspaces {
218
218
  relative?: boolean;
219
219
  }
220
220
 
221
+ /**
222
+ * Options for closing a Frame.
223
+ * @since io.Connect Desktop 9.9
224
+ */
225
+ export interface FrameCloseOptions {
226
+ /**
227
+ * If `true`, will allow preventing the operation for closing the Frame.
228
+ */
229
+ allowPrevent?: boolean;
230
+ /**
231
+ * If `true`, will show a dialog for the user to confirm or cancel closing the Frame.
232
+ */
233
+ showDialog?: boolean;
234
+ }
235
+
221
236
  /** An object containing settings applied when creating a new workspace. */
222
237
  export interface WorkspaceCreateConfig {
223
238
  /** A boolean which defines whether or not the workspace should also be saved as a layout when created. */
@@ -840,10 +855,7 @@ export namespace IOConnectWorkspaces {
840
855
  */
841
856
  restore(): Promise<void>;
842
857
 
843
- /**
844
- * Closes this frame.
845
- */
846
- close(): Promise<void>;
858
+ close(options?: FrameCloseOptions): Promise<void>;
847
859
 
848
860
  /**
849
861
  * Initializes the frame with the provided workspaces in the config when the frame has been opened as empty
@@ -851,6 +863,19 @@ export namespace IOConnectWorkspaces {
851
863
  */
852
864
  init(config: FrameInitializationConfig): Promise<void>;
853
865
 
866
+ /**
867
+ * Returns the taskbar icon of the frame
868
+ * Not available in **io.Connect Browser**.
869
+ */
870
+ getIcon(): Promise<Icon>;
871
+
872
+ /**
873
+ * Updates the taskbar icon of the frame
874
+ * Not available in **io.Connect Browser**.
875
+ * @param icon An object describing the new icon.
876
+ */
877
+ setIcon(icon: Icon): Promise<void>;
878
+
854
879
  /**
855
880
  * Returns an object detailing the current state of this frame.
856
881
  */
@@ -880,6 +905,14 @@ export namespace IOConnectWorkspaces {
880
905
  */
881
906
  createWorkspace(definition: WorkspaceDefinition, config?: WorkspaceCreateConfig): Promise<Workspace>;
882
907
 
908
+ /**
909
+ * Notifies when the Frame is about to be closed.
910
+ * *Available only for io.Connect Desktop.*
911
+ * @param callback Callback function for handling the event. Receives as an argument an object with options for closing the Frame.
912
+ * @since io.Connect Desktop 9.9
913
+ */
914
+ onClosing(callback: (options: FrameClosingData) => void | Promise<void>): Promise<Unsubscribe>;
915
+
883
916
  /**
884
917
  * Notifies when this frame is closed.
885
918
  * @param callback Callback function to handle the event.
@@ -1044,6 +1077,12 @@ export namespace IOConnectWorkspaces {
1044
1077
  /** Indicates if the window add buttons within this workspace are visible to the user */
1045
1078
  showAddWindowButtons?: boolean;
1046
1079
 
1080
+ /**
1081
+ * Indicates the loading strategy for the Workspace.
1082
+ * *Available only for **io.Connect Desktop**.*
1083
+ */
1084
+ loadingStrategy?: LoadingStrategy;
1085
+
1047
1086
  /**
1048
1087
  * Indicates whether the Workspace can be hibernated via the platform configuration.
1049
1088
  * This setting doesn't apply to programmatic hibernation via the `hibernate()` method of a `Workspace` instance.
@@ -1244,6 +1283,16 @@ export namespace IOConnectWorkspaces {
1244
1283
  */
1245
1284
  setWindowDragMode(mode: "keepInside" | "autoEject"): Promise<void>;
1246
1285
 
1286
+ /**
1287
+ * Sets the loading strategy for the Workspace at runtime.
1288
+ * This will override the current loading strategy for the Workspace that may have been specified via configuration or programmatically
1289
+ * when creating or restoring the Workspace. The loading strategy specified via this method will be preserved in the Workspace Layout
1290
+ * only if the Workspace is saved afterwards and the `"persistCurrentStrategy"` flag is set to `true` in the Workspaces App definition.
1291
+ * *Available only for **io.Connect Desktop**.*
1292
+ * @param strategy Loading strategy for the Workspace.
1293
+ */
1294
+ setLoadingStrategy(strategy: LoadingStrategy): Promise<void>;
1295
+
1247
1296
  /**
1248
1297
  * Notifies when this workspace is closed.
1249
1298
  * @param callback Callback function to handle the event.
@@ -1856,6 +1905,16 @@ export namespace IOConnectWorkspaces {
1856
1905
  config: any;
1857
1906
  }
1858
1907
 
1908
+ /**
1909
+ * Describes the data passed to the callback for handling the event which fires when a Frame is about to be closed.
1910
+ */
1911
+ export interface FrameClosingData {
1912
+ /**
1913
+ * Function that can be used to prevent closing a Frame.
1914
+ */
1915
+ prevent: () => void;
1916
+ }
1917
+
1859
1918
  export interface FrameClosedData {
1860
1919
  frameId: string;
1861
1920
  frameBounds?: FrameBounds;
@@ -1871,6 +1930,11 @@ export namespace IOConnectWorkspaces {
1871
1930
  frameBounds?: FrameBounds;
1872
1931
  }
1873
1932
 
1933
+ /** An object describing the complete state of a toolbar icon at the time when the icon was created */
1934
+ export interface Icon {
1935
+ base64Image: string;
1936
+ }
1937
+
1874
1938
  /** An object describing the complete state of a workspace at the time when the object was created */
1875
1939
  export interface WorkspaceSnapshot extends WorkspaceLayoutComponentState {
1876
1940
  /**