@interopio/workspaces-api 5.0.0-next.0 → 5.0.0

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("")},p=function(e,t){var r=t.at,o=function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r}(t,["at"]);return s({at:e+(r||"")},o)},w=function(){function e(t){var r=this;this.decode=t,this.run=function(e){return a(function(t){return{kind:"DecoderError",input:e,at:"input"+(t.at||""),message:t.message||""}},r.decode(e))},this.runPromise=function(e){return!0===(t=r.run(e)).ok?Promise.resolve(t.result):Promise.reject(t.error);var t},this.runWithException=function(e){return function(e){if(!0===e.ok)return e.result;throw e.error}(r.run(e))},this.map=function(t){return new e(function(e){return function(e,t){return!0===t.ok?o(e(t.result)):t}(t,r.decode(e))})},this.andThen=function(t){return new e(function(e){return function(e,t){return!0===t.ok?e(t.result):t}(function(r){return t(r).decode(e)},r.decode(e))})},this.where=function(t,o){return r.andThen(function(r){return t(r)?e.succeed(r):e.fail(o)})}}return e.string=function(){return new e(function(e){return"string"==typeof e?o(e):n({message:h("a string",e)})})},e.number=function(){return new e(function(e){return"number"==typeof e?o(e):n({message:h("a number",e)})})},e.boolean=function(){return new e(function(e){return"boolean"==typeof e?o(e):n({message:h("a boolean",e)})})},e.constant=function(t){return new e(function(e){return c(e,t)?o(t):n({message:"expected "+JSON.stringify(t)+", got "+JSON.stringify(e)})})},e.object=function(t){return new e(function(e){if(l(e)&&t){var r={};for(var i in t)if(t.hasOwnProperty(i)){var a=t[i].decode(e[i]);if(!0!==a.ok)return void 0===e[i]?n({message:"the key '"+i+"' is required but was not present"}):n(p("."+i,a.error));void 0!==a.result&&(r[i]=a.result)}return o(r)}return l(e)?o(e):n({message:h("an object",e)})})},e.array=function(t){return new e(function(e){if(d(e)&&t){return e.reduce(function(e,r,o){return i(function(e,t){return e.concat([t])},e,function(e,r){return a(function(e){return p("["+r+"]",e)},t.decode(e))}(r,o))},o([]))}return d(e)?o(e):n({message:h("an array",e)})})},e.tuple=function(t){return new e(function(e){if(d(e)){if(e.length!==t.length)return n({message:"expected a tuple of length "+t.length+", got one of length "+e.length});for(var r=[],i=0;i<t.length;i++){var a=t[i].decode(e[i]);if(!a.ok)return n(p("["+i+"]",a.error));r[i]=a.result}return o(r)}return n({message:h("a tuple of length "+t.length,e)})})},e.union=function(t,r){for(var o=[],n=2;n<arguments.length;n++)o[n-2]=arguments[n];return e.oneOf.apply(e,[t,r].concat(o))},e.intersection=function(t,r){for(var n=[],a=2;a<arguments.length;a++)n[a-2]=arguments[a];return new e(function(e){return[t,r].concat(n).reduce(function(t,r){return i(Object.assign,t,r.decode(e))},o({}))})},e.anyJson=function(){return new e(function(e){return o(e)})},e.unknownJson=function(){return new e(function(e){return o(e)})},e.dict=function(t){return new e(function(e){if(l(e)){var r={};for(var i in e)if(e.hasOwnProperty(i)){var a=t.decode(e[i]);if(!0!==a.ok)return n(p("."+i,a.error));r[i]=a.result}return o(r)}return n({message:h("an object",e)})})},e.optional=function(t){return new e(function(e){return null==e?o(void 0):t.decode(e)})},e.oneOf=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return new e(function(e){for(var r=[],o=0;o<t.length;o++){var i=t[o].decode(e);if(!0===i.ok)return i;r[o]=i.error}var a=r.map(function(e){return"at error"+(e.at||"")+": "+e.message}).join('", "');return n({message:'expected a value matching one of the decoders, got the errors ["'+a+'"]'})})},e.withDefault=function(t,r){return new e(function(e){return o(function(e,t){return!0===t.ok?t.result:e}(t,r.decode(e)))})},e.valueAt=function(t,r){return new e(function(e){for(var o=e,i=0;i<t.length;i++){if(void 0===o)return n({at:u(t.slice(0,i+1)),message:"path does not exist"});if("string"==typeof t[i]&&!l(o))return n({at:u(t.slice(0,i+1)),message:h("an object",o)});if("number"==typeof t[i]&&!d(o))return n({at:u(t.slice(0,i+1)),message:h("an array",o)});o=o[t[i]]}return a(function(e){return void 0===o?{at:u(t),message:"path does not exist"}:p(u(t),e)},r.decode(o))})},e.succeed=function(t){return new e(function(e){return o(t)})},e.fail=function(t){return new e(function(e){return n({message:t})})},e.lazy=function(t){return new e(function(e){return t().decode(e)})},e}(),m=w.string,g=w.number,f=w.boolean,y=w.anyJson;w.unknownJson;var b=w.constant,k=w.object,I=w.array;w.tuple,w.dict;var W=w.optional,S=w.oneOf;w.union;var x=w.intersection;w.withDefault,w.valueAt,w.succeed,w.fail;var D=w.lazy;const v=m().where(e=>e.length>0,"Expected a non-empty string"),C=g().where(e=>e>=0,"Expected a non-negative number"),B=g().where(e=>e>0,"Expected a positive number"),E=S(b("keepInside"),b("autoEject")),T=k({inWorkspace:f()}),M=k({isVisible:f()}),F=k({base64Image:v}),R=k({icon:F,frameId:v}),L=S(b("workspace"),b("row"),b("column"),b("group")),A=S(b("row"),b("column"),b("group")),P=S(b("maximized"),b("minimized"),b("normal")),z=S(b("workspace")),O=k({allowInApplicationPopup:W(f()),allowDrop:W(f())}),H=k({appName:v,allowInApplicationPopup:W(f()),allowDrop:W(f())}),$=k({apps:W(I(H)),default:W(O)}),_=(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}`)},j=W(k({saveLayout:W(f())})),G=k({name:v}),N=k({layoutId:v}),V=k({minWidth:W(g()),maxWidth:W(g()),minHeight:W(g()),maxHeight:W(g()),allowExtract:W(f()),allowReorder:W(f()),showCloseButton:W(f())}),J=k({minWidth:W(g()),maxWidth:W(g()),minHeight:W(g()),maxHeight:W(g()),allowExtract:W(f()),allowReorder:W(f()),allowDrop:W(f()),allowDropHeader:W(f()),allowDropLeft:W(f()),allowDropRight:W(f()),allowDropTop:W(f()),allowDropBottom:W(f()),showMaximizeButton:W(f()),showEjectButton:W(f()),showAddWindowButton:W(f())}),U=k({minHeight:W(g()),maxHeight:W(g()),allowDrop:W(f()),allowSplitters:W(f()),isPinned:W(f()),maximizationBoundary:W(f())}),K=k({minWidth:W(g()),maxWidth:W(g()),allowDrop:W(f()),allowSplitters:W(f()),isPinned:W(f()),maximizationBoundary:W(f())}),q=k({type:W(b("window")),appName:W(v),windowId:W(v),context:W(y()),config:W(V)}),Q=k({type:b("window"),appName:W(v),windowId:W(v),context:W(y()),config:W(V)}),X=W(k({type:W(A),children:W(D(()=>I(S(q,X)))),config:W(y())})),Y=k({type:b("column"),children:W(D(()=>I(S(Q,te)))),config:W(K)}),Z=k({type:b("row"),children:W(D(()=>I(S(Q,te)))),config:W(U)}),ee=k({type:b("group"),children:W(D(()=>I(S(Q,te)))),config:W(J)}),te=S(ee,Y,Z);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 re=k({bounds:W(k({left:W(g()),top:W(g()),width:W(C),height:W(C)})),isVisible:W(f()),frameId:W(v)}),oe=S(b("direct"),b("delayed"),b("lazy")),ne=W(k({app:W(v),context:W(y()),loadingStrategy:W(oe),title:W(v),reuseWorkspaceId:W(v),frameId:W(v),applicationName:W(v),lockdown:W(f()),activateFrame:W(f()),newFrame:W(S(re,f())),noTabHeader:W(f()),inMemoryLayout:W(f()),icon:W(v),isPinned:W(f()),isSelected:W(f()),positionIndex:W(C),allowSystemHibernation:W(f())})),ie=x(ne,k({layoutId:v})),ae=x(ne,k({layoutId:v})),se=k({name:v,restoreOptions:W(ne)}),ce=k({children:W(I(S(q,te))),context:W(y()),config:W(k({title:W(v),position:W(C),isFocused:W(f()),noTabHeader:W(f()),reuseWorkspaceId:W(v),loadingStrategy:W(oe),allowDrop:W(f()),allowDropLeft:W(f()),allowDropTop:W(f()),allowDropRight:W(f()),allowDropBottom:W(f()),allowSystemHibernation:W(f()),allowExtract:W(f()),allowWindowReorder:W(f()),showSaveButton:W(f()),allowWorkspaceTabReorder:W(f()),allowWorkspaceTabExtract:W(f()),showCloseButton:W(f()),allowSplitters:W(f()),showWindowCloseButtons:W(f()),showEjectButtons:W(f()),showAddWindowButtons:W(f()),icon:W(v),isPinned:W(f()),isSelected:W(f()),positionIndex:W(C),windowDragMode:W(E),appRestrictions:W($)})),frame:W(k({activate:W(f()),reuseFrameId:W(v),applicationName:W(v),newFrame:W(S(f(),re))}))}),de=k({workspaceId:v}),le=k({name:v,restoreOptions:W(ne)}),he=k({id:v,restoreOptions:W(ne)}),ue=W(k({applicationName:W(m()),frameConfig:W(re),context:W(k()),layoutComponentId:W(v)})),pe=k({workspaces:I(S(W(ce),W(le),W(he)))}),we=k({frameId:v,workspaces:I(S(ce,le,he))}),me=k({type:L,definition:W(S(ce,X))}),ge=x(ce,k({saveConfig:W(k({saveLayout:W(f())}))})),fe=k({itemId:v}),ye=k({context:W(k())}),be=k({id:v,isFocused:W(f()),isInitialized:W(f()),initializationContext:W(ye)});k({type:A,id:v,frameId:v,workspaceId:v,positionIndex:g()});const ke=S(b("frame"),b("workspace"),b("container"),b("window")),Ie=k({type:ke,branch:v}),We=S(b("opened"),b("closing"),b("closed"),b("focus"),b("added"),b("loaded"),b("removed"),b("childrenUpdate"),b("containerChange"),b("maximized"),b("restored"),b("minimized"),b("normal"),b("selected"),b("lock-configuration-changed"),b("hibernated"),b("resumed"),b("tab-reordered")),Se=k({frameId:v,title:v,positionIndex:C,name:v,layoutId:W(v),layoutName:W(v),isHibernated:W(f()),isSelected:W(f()),allowDrop:W(f()),allowSystemHibernation:W(f()),allowExtract:W(f()),allowWindowReorder:W(f()),allowSplitters:W(f()),showCloseButton:W(f()),showSaveButton:W(f()),allowWorkspaceTabReorder:W(f()),allowWorkspaceTabExtract:W(f()),allowDropLeft:W(f()),allowDropTop:W(f()),allowDropRight:W(f()),allowDropBottom:W(f()),minWidth:W(g()),maxWidth:W(g()),minHeight:W(g()),maxHeight:W(g()),showAddWindowButtons:W(f()),showEjectButtons:W(f()),showWindowCloseButtons:W(f()),widthInPx:W(g()),heightInPx:W(g()),isPinned:W(f()),windowDragMode:W(E),loadingStrategy:W(oe),appRestrictions:W($)}),xe=k({frameId:v,workspaceId:v,positionIndex:g(),minWidth:W(g()),maxWidth:W(g()),minHeight:W(g()),maxHeight:W(g())}),De=y(),ve=x(xe,k({windowId:W(v),isMaximized:W(f()),isFocused:f(),isSelected:W(f()),title:W(m()),appName:W(v),allowExtract:W(f()),allowReorder:W(f()),showCloseButton:W(f()),minWidth:W(g()),minHeight:W(g()),maxWidth:W(g()),maxHeight:W(g()),widthInPx:W(g()),heightInPx:W(g()),context:W(y())})),Ce=k({id:W(v),config:De,children:W(D(()=>I(Ee))),type:S(b("row"),b("column"),b("group"))}),Be=k({id:W(v),config:ve,type:b("window")}),Ee=S(Be,Ce),Te=k({id:v,config:Se,children:I(Ee),frameSummary:be,context:W(y())}),Me=k({type:b("window"),config:k({appName:v,windowId:W(v),context:W(y()),url:W(v),title:W(m()),allowExtract:W(f()),allowReorder:W(f()),showCloseButton:W(f()),minWidth:W(g()),minHeight:W(g()),maxWidth:W(g()),maxHeight:W(g()),isMaximized:W(f()),instanceId:W(v)})}),Fe=k({type:b("group"),config:y(),children:I(S(Me))}),Re=k({type:b("column"),config:y(),children:I(S(Fe,Me,D(()=>Re),D(()=>Le)))}),Le=k({type:b("row"),config:y(),children:I(S(Re,Fe,Me,D(()=>Le)))}),Ae=k({id:W(v),name:v,type:b("Workspace"),metadata:W(y()),components:I(k({type:b("Workspace"),application:W(m()),state:k({config:y(),context:y(),children:I(S(Le,Re,Fe,Me))})}))}),Pe=k({layout:Ae,mode:S(b("replace"),b("merge"))}),ze=k({layouts:I(Ae),mode:S(b("replace"),b("merge"))}),Oe=k({layouts:I(Ae)}),He=k({id:v,isFocused:W(f()),isInitialized:W(f()),initializationContext:W(ye)}),$e=k({summaries:I(He)}),_e=k({id:v,config:Se}),je=k({summaries:I(_e)}),Ge=k({id:v,config:y(),workspaces:I(Te)}),Ne=k({id:W(v),name:v,applicationName:W(m())}),Ve=k({summaries:I(Ne)}),Je=k({windowId:v}),Ue=y(),Ke=k({state:P}),qe=k({top:g(),left:g(),width:C,height:C}),Qe=k({bounds:qe}),Xe=k({icon:W(v)}),Ye=k({id:W(v)}),Ze=k({isSupported:f()}),et=k({width:W(B),height:W(B),relative:W(f())}),tt=k({top:W(g()),left:W(g()),relative:W(f())}),rt=k({itemId:v}),ot=k({allowPrevent:W(f()),showDialog:W(f())}),nt=k({itemId:v,closeOptions:W(ot)}),it=k({itemId:v,excludeIds:W(f())}),at=k({frameId:v,requestedState:P}),st=k({itemId:v,title:v}),ct=k({itemId:v,containerId:v}),dt=x(rt,et),lt=k({itemId:v,enabled:f()}),ht=x(rt,tt);k({id:v,type:A});const ut=k({definition:q,parentId:v,parentType:L}),pt=k({definition:te,parentId:v,parentType:L}),wt=k({itemId:v,windowId:W(v)}),mt=k({live:f()}),gt=k({type:S(b("row"),b("column")),workspaceId:v}),ft=k({type:S(b("row"),b("column")),itemId:v}),yt=k({itemId:v,config:De}),bt=k({frameSummary:be,frameBounds:W(qe)}),kt=k({workspaceSummary:_e,frameSummary:be,workspaceSnapshot:W(Te),frameBounds:W(qe)}),It=k({containerSummary:yt}),Wt=k({windowSummary:k({itemId:v,parentId:v,config:ve})}),St=k({id:W(v),name:v,workspaceId:v,saveContext:W(f()),allowMultiple:W(f()),metadata:W(k()),saveWindowContexts:W(f())}),xt=k({id:W(v),name:v,workspaceId:v,saveContext:W(f()),allowMultiple:W(f()),metadata:W(k()),saveWindowContexts:W(f())}),Dt=k({saveContext:W(f()),allowMultiple:W(f()),metadata:W(k()),saveWindowContexts:W(f())}),vt=k({allowDrop:W(f()),allowDropLeft:W(f()),allowDropTop:W(f()),allowDropRight:W(f()),allowDropBottom:W(f()),allowSystemHibernation:W(f()),allowExtract:W(f()),allowWindowReorder:W(f()),allowSplitters:W(f()),showCloseButton:W(f()),showSaveButton:W(f()),allowWorkspaceTabReorder:W(f()),allowWorkspaceTabExtract:W(f()),showWindowCloseButtons:W(f()),showAddWindowButtons:W(f()),showEjectButtons:W(f())}),Ct=k({workspaceId:v,config:W(vt)}),Bt=k({allowExtract:W(f()),allowReorder:W(f()),showCloseButton:W(f())}),Et=k({width:W(C),height:W(C)}),Tt=k({windowPlacementId:v,config:W(Bt)}),Mt=k({allowDrop:W(f()),allowSplitters:W(f())}),Ft=k({allowDrop:W(f()),allowSplitters:W(f())}),Rt=k({allowExtract:W(f()),allowReorder:W(f()),allowDrop:W(f()),allowDropLeft:W(f()),allowDropRight:W(f()),allowDropTop:W(f()),allowDropBottom:W(f()),allowDropHeader:W(f()),showMaximizeButton:W(f()),showEjectButton:W(f()),showAddWindowButton:W(f())}),Lt=k({itemId:v,type:b("row"),config:W(Mt)}),At=k({itemId:v,type:b("column"),config:W(Ft)}),Pt=k({itemId:v,type:b("group"),config:W(Rt)}),zt=S(Lt,At,Pt),Ot=k({workspaceId:v,icon:W(v)}),Ht=k({workspaceId:v,icon:W(v)}),$t=W(k({icon:W(v)})),_t=W(k({activate:W(f())})),jt=k({shortcut:v,frameId:v}),Gt=k({shortcut:v,frameId:v}),Nt=k({frameId:v}),Vt=k({enabled:f()}),Jt=k({itemId:v,type:z}),Ut=k({operation:v}),Kt=k({itemId:v,dragMode:E}),qt=k({itemId:v,strategy:oe}),Qt=k({prevent:f()}),Xt=k({width:C,height:C}),Yt=k({left:g(),top:g(),width:C,height:C}),Zt=S(b("none"),b("left"),b("right"),b("top"),b("bottom")),er=k({size:Xt,targetBounds:Yt,targetLocation:Zt,windowId:v,horizontalOffset:W(g()),verticalOffset:W(g()),focus:W(f())}),tr=k({frameId:v,size:Xt,targetBounds:Yt,targetLocation:Zt,windowId:v,horizontalOffset:W(g()),verticalOffset:W(g()),focus:W(f())}),rr=k({frameId:v,activate:W(f()),isVisible:f()}),or=k({mode:W(S(b("Global"),b("WindowContainer"))),type:m(),size:W(Xt),message:v,messageTitle:W(v),movable:W(f()),transparent:W(f()),title:v,context:W(y()),affirmativeButtonName:W(v),showAffirmativeButton:W(f()),cancelButtonName:W(v),showCancelButton:W(f()),negativeButtonName:W(v),showNegativeButton:W(f()),defaultAction:W(S(b("affirmative"),b("negative"),b("cancel"))),timerDuration:W(B),showTimer:W(f()),inputMaxLength:W(B),inputPattern:W(v),inputPatternErrorMessage:W(v),inputPlaceholder:W(m()),blur:W(f())}),nr=k({frameId:v,options:or}),ir=k({onTop:f()}),ar=k({frameId:v,onTop:f()}),sr="T42.Web.Platform.Control",cr="T42.Web.Platform.WSP.Stream",dr={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}},lr={control:{name:"T42.Workspaces.Client.Control",isStream:!1}},hr={frame:{name:"T42.Workspaces.Stream.Frame",payloadDecoder:bt},workspace:{name:"T42.Workspaces.Stream.Workspace",payloadDecoder:kt},container:{name:"T42.Workspaces.Stream.Container",payloadDecoder:It},window:{name:"T42.Workspaces.Stream.Window",payloadDecoder:Wt}},ur={shortcutClicked:{name:"shortcutClicked",argsDecoder:Gt,resultDecoder:Ue},frameClosing:{name:"frameClosing",argsDecoder:Nt,resultDecoder:Qt}},pr={ping:{name:"ping",resultDecoder:mt},isWindowInWorkspace:{name:"isWindowInWorkspace",argsDecoder:rt,resultDecoder:T},createWorkspace:{name:"createWorkspace",resultDecoder:Te,argsDecoder:ge},createFrame:{name:"createFrame",resultDecoder:He,argsDecoder:ue},initFrame:{name:"initFrame",resultDecoder:Ue,argsDecoder:we},getAllFramesSummaries:{name:"getAllFramesSummaries",resultDecoder:$e},getFrameSummary:{name:"getFrameSummary",resultDecoder:be,argsDecoder:fe},getAllWorkspacesSummaries:{name:"getAllWorkspacesSummaries",resultDecoder:je},getWorkspaceSnapshot:{name:"getWorkspaceSnapshot",resultDecoder:Te,argsDecoder:rt},getAllLayoutsSummaries:{name:"getAllLayoutsSummaries",resultDecoder:Ve},openWorkspaceById:{name:"openWorkspaceById",argsDecoder:ae,resultDecoder:Te},openWorkspace:{name:"openWorkspace",argsDecoder:se,resultDecoder:Te},deleteLayout:{name:"deleteLayout",resultDecoder:Ue,argsDecoder:G},deleteLayoutById:{name:"deleteLayoutById",resultDecoder:Ue,argsDecoder:N},saveLayout:{name:"saveLayout",resultDecoder:Ae,argsDecoder:St},saveLayoutById:{name:"saveLayoutById",resultDecoder:Ae,argsDecoder:xt},importLayout:{name:"importLayout",resultDecoder:Ue,argsDecoder:Pe},importLayouts:{name:"importLayouts",resultDecoder:Ue,argsDecoder:ze},exportAllLayouts:{name:"exportAllLayouts",resultDecoder:Oe},restoreItem:{name:"restoreItem",argsDecoder:rt,resultDecoder:Ue},maximizeItem:{name:"maximizeItem",argsDecoder:rt,resultDecoder:Ue},focusItem:{name:"focusItem",argsDecoder:rt,resultDecoder:Ue},closeItem:{name:"closeItem",argsDecoder:nt,resultDecoder:Ue},closeWorkspace:{name:"closeWorkspace",argsDecoder:nt,resultDecoder:Ue},resizeItem:{name:"resizeItem",argsDecoder:dt,resultDecoder:Ue},setMaximizationBoundary:{name:"setMaximizationBoundary",argsDecoder:lt,resultDecoder:Ue},changeFrameState:{name:"changeFrameState",argsDecoder:at,resultDecoder:Ue},getFrameState:{name:"getFrameState",argsDecoder:rt,resultDecoder:Ke},getFrameBounds:{name:"getFrameBounds",argsDecoder:rt,resultDecoder:Qe},moveFrame:{name:"moveFrame",argsDecoder:ht,resultDecoder:Ue},getFrameSnapshot:{name:"getFrameSnapshot",argsDecoder:it,resultDecoder:Ge},forceLoadWindow:{name:"forceLoadWindow",argsDecoder:rt,resultDecoder:Je},ejectWindow:{name:"ejectWindow",argsDecoder:rt,resultDecoder:Je},setItemTitle:{name:"setItemTitle",argsDecoder:st,resultDecoder:Ue},moveWindowTo:{name:"moveWindowTo",argsDecoder:ct,resultDecoder:Ue},addWindow:{name:"addWindow",argsDecoder:ut,resultDecoder:wt},addContainer:{name:"addContainer",argsDecoder:pt,resultDecoder:wt},bundleWorkspace:{name:"bundleWorkspace",argsDecoder:gt,resultDecoder:Ue},bundleItem:{name:"bundleItem",argsDecoder:ft,resultDecoder:Ue},hibernateWorkspace:{name:"hibernateWorkspace",argsDecoder:de,resultDecoder:Ue},resumeWorkspace:{name:"resumeWorkspace",argsDecoder:de,resultDecoder:Ue},lockWorkspace:{name:"lockWorkspace",argsDecoder:Ct,resultDecoder:Ue},lockWindow:{name:"lockWindow",argsDecoder:Tt,resultDecoder:Ue},lockContainer:{name:"lockContainer",argsDecoder:zt,resultDecoder:Ue},pinWorkspace:{name:"pinWorkspace",argsDecoder:Ot,resultDecoder:Ue},unpinWorkspace:{name:"unpinWorkspace",argsDecoder:de,resultDecoder:Ue},getWorkspaceIcon:{name:"getWorkspaceIcon",argsDecoder:de,resultDecoder:Xe},setWorkspaceIcon:{name:"setWorkspaceIcon",argsDecoder:Ht,resultDecoder:Ue},registerShortcut:{name:"registerShortcut",argsDecoder:jt,resultDecoder:Ue},unregisterShortcut:{name:"unregisterShortcut",argsDecoder:jt,resultDecoder:Ue},showLoadingAnimation:{name:"showLoadingAnimation",argsDecoder:Jt,resultDecoder:Ue},hideLoadingAnimation:{name:"hideLoadingAnimation",argsDecoder:Jt,resultDecoder:Ue},getPlatformFrameId:{name:"getPlatformFrameId",resultDecoder:Ye},operationCheck:{name:"operationCheck",argsDecoder:Ut,resultDecoder:Ze},setWindowDragMode:{name:"setWindowDragMode",argsDecoder:Kt,resultDecoder:Ue},setLoadingStrategy:{name:"setLoadingStrategy",argsDecoder:qt,resultDecoder:Ue},getTaskbarIcon:{name:"getTaskbarIcon",resultDecoder:F},setTaskbarIcon:{name:"setTaskbarIcon",argsDecoder:R,resultDecoder:Ue},subscribeToFrameClosing:{name:"subscribeToFrameClosing",argsDecoder:rt,resultDecoder:Ue},showPopup:{name:"showPopup",argsDecoder:tr,resultDecoder:Ue},changeFrameVisibility:{name:"changeFrameVisibility",argsDecoder:rr,resultDecoder:Ue},getFrameVisibility:{name:"getFrameVisibility",argsDecoder:rt,resultDecoder:M},showFrameDialog:{name:"showFrameDialog",argsDecoder:nr,resultDecoder:y()},setFrameOnTop:{name:"setFrameOnTop",argsDecoder:ar,resultDecoder:Ue}};class wr{resolve;reject;promise;constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class mr{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,r){const o=Object.values(pr).find(t=>t.name===e);if(!o)throw new Error(`Cannot find definition for operation name: ${e}`);if(o.argsDecoder)try{o.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(o.name,t,r);return o.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 wr,o={streamType:e.eventType,level:e.scope,levelId:e.scopeId,promise:t.promise};this.pendingSubScriptions.push(o);try{const o=hr[e.eventType],n=await this.transport.subscribe(o.name,this.getBranchKey(e),e.eventType);n.onData(e=>{const t=e.data,r=Ie.run(e.requestArguments),o=We.run(t.action);if(!r.ok||!o.ok)return;const n=r.result.type,i=`${n}-${r.result.branch}-${o.result}`,a=hr[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(ur).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(ur).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=We.runWithException(t.action),r=ke.runWithException(t.type),o=hr[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 gr=()=>"undefined"==typeof window||(window.glue42gd||window.iodesktop),fr=()=>"undefined"==typeof window?null:window.glue42core||window.iobrowser;class yr{agm;registry;defaultTransportTimeout=12e4;coreEventMethodInitiated=!1;corePlatformSubPromise;constructor(e,t){this.agm=e,this.registry=t}async initiate(e){if(gr())return await Promise.all(Object.values(dr).map(e=>this.verifyMethodLive(e.name))),void await Promise.all(Object.keys(lr).map(e=>this.registerMethod(e)));const t=fr().communicationId;await Promise.all([this.verifyMethodLive(sr,t),this.verifyMethodLive(cr,t)]),await this.transmitControl("frameHello",{windowId:e})}coreSubscriptionReady(e){return this.coreEventMethodInitiated||this.subscribePlatform(e),this.corePlatformSubPromise}subscribePlatform(e){this.coreEventMethodInitiated=!0;const t=fr().communicationId;this.corePlatformSubPromise=this.agm.subscribe(cr,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,r){const o=gr()?{operation:e,operationArguments:t}:{operation:e,domain:"workspaces",data:t},n=gr()?dr.control.name:sr,i=gr()?void 0:fr().communicationId;let a;const s=`Internal Workspaces Communication Error. Attempted operation: ${JSON.stringify(o)}. `;try{if(a=await this.agm.invoke(n,o,i?{instance:i}:"best",{methodResponseTimeoutMs:r?.timeout??this.defaultTransportTimeout}),!a)throw new Error("Received unsupported result from GD - empty result");if(!Array.isArray(a.all_return_values)||0===a.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(`${s} -> Inner message: ${t}`)}throw new Error(`${s} -> Inner message: ${e.message}`)}return a.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=lr[e];return this.agm.register(t.name,(t,r)=>Promise.all(this.registry.execute(e,t,r)))}}const br=new WeakMap;class kr{constructor(e,t){const r=t.wrapChildren(e.children);delete e.children,br.set(this,{base:t,children:r,definition:e})}get type(){return br.get(this).definition.type}addColumn(e){return br.get(this).base.add("column",br.get(this).children,e)}addRow(e){return br.get(this).base.add("row",br.get(this).children,e)}addGroup(e){return br.get(this).base.add("group",br.get(this).children,e)}addWindow(e){return br.get(this).base.addWindow(br.get(this).children,e),this}serialize(){const e=br.get(this).definition;return e.children=br.get(this).base.serializeChildren(br.get(this).children),e}}class Ir{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=X.runWithException(r),n=this.getBuilder({type:e,definition:o});return t.push(n),n}addWindow(e,t){const r=q.runWithException(t);r.type="window",e.push(r)}serializeChildren(e){return e.map(e=>e instanceof kr?e.serialize():e)}}const Wr=new WeakMap;class Sr{constructor(e,t,r){const o=t.wrapChildren(e.children);delete e.children,Wr.set(this,{base:t,children:o,definition:e,controller:r})}addColumn(e){const t=Wr.get(this).children;if(!t.every(e=>e instanceof kr&&"column"===e.type))throw new Error("Cannot add a column to this workspace, because there are already children of another type");return Wr.get(this).base.add("column",t,e)}addRow(e){const t=Wr.get(this).children;if(!t.every(e=>e instanceof kr&&"row"===e.type))throw new Error("Cannot add a row to this workspace, because there are already children of another type");return Wr.get(this).base.add("row",t,e)}addGroup(e){const t=Wr.get(this).children;if(0!==t.length)throw new Error("Cannot add a group to this workspace, because there are already defined children.");return Wr.get(this).base.add("group",t,e)}addWindow(e){const t=Wr.get(this).children;if(0!==t.length)throw new Error("Cannot add a window to this workspace, because there are already defined children.");return Wr.get(this).base.addWindow(t,e),this}getChildAt(e){C.runWithException(e);return Wr.get(this).children[e]}async create(e){const t=j.runWithException(e),r=Wr.get(this).definition;r.children=Wr.get(this).base.serializeChildren(Wr.get(this).children);return Wr.get(this).controller.createWorkspace(r,t)}}const xr=new WeakMap,Dr=e=>xr.get(e).base;class vr{constructor(e){xr.set(this,{base:e})}get type(){return"row"}get id(){return Dr(this).getId(this)}get frameId(){return Dr(this).getFrameId(this)}get workspaceId(){return Dr(this).getWorkspaceId(this)}get positionIndex(){return Dr(this).getPositionIndex(this)}get children(){return Dr(this).getAllChildren(this)}get parent(){return Dr(this).getMyParent(this)}get frame(){return Dr(this).getMyFrame(this)}get workspace(){return Dr(this).getMyWorkspace(this)}get allowDrop(){return Dr(this).getAllowDrop(this)}get allowSplitters(){return Dr(this).getAllowSplitters(this)}get minWidth(){return Dr(this).getMinWidth(this)}get minHeight(){return Dr(this).getMinHeight(this)}get maxWidth(){return Dr(this).getMaxWidth(this)}get maxHeight(){return Dr(this).getMaxHeight(this)}get width(){return Dr(this).getWidthInPx(this)}get height(){return Dr(this).getHeightInPx(this)}get isPinned(){return Dr(this).getIsPinned(this)}get isMaximized(){return Dr(this).getIsMaximized(this)}get maximizationBoundary(){return Dr(this).getMaximizationBoundary(this)}addWindow(e){return Dr(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 Dr(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 Dr(this).addParent(this,"column","row",e)}async addRow(){throw new Error("Adding rows as row children is not supported")}removeChild(e){return Dr(this).removeChild(this,e)}maximize(){return Dr(this).maximize(this)}restore(){return Dr(this).restore(this)}close(){return Dr(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:Mt.runWithException(t);return Dr(this).lockContainer(this,r)}async setHeight(e){return C.runWithException(e),Dr(this).setHeight(this,e)}async onLockConfigurationChanged(e){_(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 Dr(this).processLocalSubscription(this,t)}async setMaximizationBoundary(e){const t=Vt.runWithException(e);return Dr(this).setMaximizationBoundary(this,t)}}const Cr=new WeakMap,Br=e=>Cr.get(e).base;class Er{constructor(e){Cr.set(this,{base:e})}get type(){return"column"}get id(){return Br(this).getId(this)}get frameId(){return Br(this).getFrameId(this)}get workspaceId(){return Br(this).getWorkspaceId(this)}get positionIndex(){return Br(this).getPositionIndex(this)}get children(){return Br(this).getAllChildren(this)}get parent(){return Br(this).getMyParent(this)}get frame(){return Br(this).getMyFrame(this)}get workspace(){return Br(this).getMyWorkspace(this)}get allowDrop(){return Br(this).getAllowDrop(this)}get allowSplitters(){return Br(this).getAllowSplitters(this)}get minWidth(){return Br(this).getMinWidth(this)}get minHeight(){return Br(this).getMinHeight(this)}get maxWidth(){return Br(this).getMaxWidth(this)}get maxHeight(){return Br(this).getMaxHeight(this)}get width(){return Br(this).getWidthInPx(this)}get height(){return Br(this).getHeightInPx(this)}get isPinned(){return Br(this).getIsPinned(this)}get isMaximized(){return Br(this).getIsMaximized(this)}get maximizationBoundary(){return Br(this).getMaximizationBoundary(this)}addWindow(e){return Br(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 Br(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 Br(this).addParent(this,"row","column",e)}removeChild(e){return Br(this).removeChild(this,e)}maximize(){return Br(this).maximize(this)}restore(){return Br(this).restore(this)}close(){return Br(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 Br(this).lockContainer(this,r)}async setWidth(e){return C.runWithException(e),Br(this).setWidth(this,e)}async onLockConfigurationChanged(e){_(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 Br(this).processLocalSubscription(this,t)}async setMaximizationBoundary(e){const t=Vt.runWithException(e);return Br(this).setMaximizationBoundary(this,t)}}const Tr=new WeakMap,Mr=e=>Tr.get(e).base;class Fr{constructor(e){Tr.set(this,{base:e})}get type(){return"group"}get id(){return Mr(this).getId(this)}get frameId(){return Mr(this).getFrameId(this)}get workspaceId(){return Mr(this).getWorkspaceId(this)}get positionIndex(){return Mr(this).getPositionIndex(this)}get children(){return Mr(this).getAllChildren(this)}get parent(){return Mr(this).getMyParent(this)}get frame(){return Mr(this).getMyFrame(this)}get workspace(){return Mr(this).getMyWorkspace(this)}get allowExtract(){return Mr(this).getAllowExtract(this)}get allowReorder(){return Mr(this).getAllowReorder(this)}get allowDropLeft(){return Mr(this).getAllowDropLeft(this)}get allowDropRight(){return Mr(this).getAllowDropRight(this)}get allowDropTop(){return Mr(this).getAllowDropTop(this)}get allowDropBottom(){return Mr(this).getAllowDropBottom(this)}get allowDropHeader(){return Mr(this).getAllowDropHeader(this)}get allowDrop(){return Mr(this).getAllowDrop(this)}get showMaximizeButton(){return Mr(this).getShowMaximizeButton(this)}get showEjectButton(){return Mr(this).getShowEjectButton(this)}get showAddWindowButton(){return Mr(this).getShowAddWindowButton(this)}get minWidth(){return Mr(this).getMinWidth(this)}get minHeight(){return Mr(this).getMinHeight(this)}get maxWidth(){return Mr(this).getMaxWidth(this)}get maxHeight(){return Mr(this).getMaxHeight(this)}get width(){return Mr(this).getWidthInPx(this)}get height(){return Mr(this).getHeightInPx(this)}get isMaximized(){return Mr(this).getIsMaximized(this)}addWindow(e){return Mr(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 Mr(this).removeChild(this,e)}maximize(){return Mr(this).maximize(this)}restore(){return Mr(this).restore(this)}close(){return Mr(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:Rt.runWithException(t);return Mr(this).lockContainer(this,r)}async setSize(e){const t=Et.runWithException(e);if(!t.width&&!t.height)throw new Error("Expected either width or height to be passed.");return Mr(this).setSize(this,e.width,e.height)}async bundleToRow(){await Mr(this).bundleTo(this,"row"),await this.workspace.refreshReference()}async bundleToColumn(){await Mr(this).bundleTo(this,"column"),await this.workspace.refreshReference()}async onLockConfigurationChanged(e){_(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 Mr(this).processLocalSubscription(this,t)}}const Rr=new WeakMap,Lr=e=>Rr.get(e).manager.getWorkspaceData(e),Ar=e=>Rr.get(e).manager;class Pr{constructor(e){Rr.set(this,{manager:e})}get id(){return Lr(this).id}get frameId(){return Lr(this).config.frameId}get positionIndex(){return Lr(this).config.positionIndex}get title(){return Lr(this).config.title}get layoutId(){return Lr(this).config.layoutId}get layoutName(){return Lr(this).config.layoutName}get isHibernated(){return Lr(this).config.isHibernated}get isSelected(){return Lr(this).config.isSelected}get children(){return Lr(this).children}get frame(){return Lr(this).frame}get allowSplitters(){return Lr(this).config.allowSplitters}get allowSystemHibernation(){return Lr(this).config.allowSystemHibernation}get allowDrop(){return Lr(this).config.allowDrop}get allowDropLeft(){return Lr(this).config.allowDropLeft}get allowDropTop(){return Lr(this).config.allowDropTop}get allowDropRight(){return Lr(this).config.allowDropRight}get allowDropBottom(){return Lr(this).config.allowDropBottom}get allowExtract(){return Lr(this).config.allowExtract}get allowWindowReorder(){return Lr(this).config.allowWindowReorder}get appRestrictions(){return Lr(this).config.appRestrictions}get showCloseButton(){return Lr(this).config.showCloseButton}get showSaveButton(){return Lr(this).config.showSaveButton}get allowWorkspaceTabReorder(){return Lr(this).config.allowWorkspaceTabReorder}get allowWorkspaceTabExtract(){return Lr(this).config.allowWorkspaceTabExtract}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 width(){return Lr(this).config.widthInPx}get height(){return Lr(this).config.heightInPx}get showWindowCloseButtons(){return Lr(this).config.showWindowCloseButtons}get showEjectButtons(){return Lr(this).config.showEjectButtons}get showAddWindowButtons(){return Lr(this).config.showAddWindowButtons}get isPinned(){return Lr(this).config.isPinned}get windowDragMode(){return gr()?Lr(this).config.windowDragMode:"keepInside"}get loadingStrategy(){return gr()||console.warn("The workspace.loadingStrategy property is not supported in IO Connect Browser"),Lr(this).config.loadingStrategy}async setLoadingStrategy(e){if(!gr())throw new Error("Not supported in IO Connect Browser");const t=Lr(this).controller;await t.setLoadingStrategy(this.id,e),await this.refreshReference()}async removeChild(e){_(e);const t=this.children.find(e);t&&(await t.close(),await this.refreshReference())}async remove(e){_(e);const t=Lr(this).controller.iterateFindChild(this.children,e);await t.close(),await this.refreshReference()}async focus(){await Lr(this).controller.focusItem(this.id),await this.refreshReference()}async close(){const e=Lr(this).controller;await e.closeWorkspace(this.id,this.frameId)}snapshot(){return Lr(this).controller.getSnapshot(this.id,"workspace")}async saveLayout(e,t){v.runWithException(e),t&&Dt.runWithException(t),await Lr(this).controller.saveLayout({name:e,workspaceId:this.id,saveContext:t?.saveContext,metadata:t?.metadata,allowMultiple:t?.allowMultiple,saveWindowContexts:t?.saveWindowContexts})}async setTitle(e){v.runWithException(e);const t=Lr(this).controller;await t.setItemTitle(this.id,e),await this.refreshReference()}getContext(){return Lr(this).controller.getWorkspaceContext(this.id)}setContext(e){return Lr(this).controller.setWorkspaceContext(this.id,e)}updateContext(e){return Lr(this).controller.updateWorkspaceContext(this.id,e)}onContextUpdated(e){return Lr(this).controller.subscribeWorkspaceContextUpdated(this.id,e)}async refreshReference(){const e=await Lr(this).controller.getSnapshot(this.id,"workspace"),t=Lr(this).controller.flatChildren(Lr(this).children),r=Lr(this).controller.refreshChildren({existingChildren:t,workspace:this,parent:this,children:e.children}),o=this.frame;let n;if(o.id===e.config.frameId)Ar(this).remapFrame(o,e.frameSummary),n=o;else{const t={summary:e.frameSummary};n=Lr(this).ioc.getModel("frame",t)}Ar(this).remapWorkspace(this,{config:e.config,children:r,frame:n})}async getIcon(){return Lr(this).controller.getWorkspaceIcon(this.id)}async setIcon(e){return Lr(this).controller.setWorkspaceIcon(this.id,e)}getBox(e){_(e);const t=Lr(this).children;return Lr(this).controller.iterateFindChild(t,t=>"window"!==t.type&&e(t))}getAllBoxes(e){_(e,!0);const t=Lr(this).children,r=Lr(this).controller.iterateFilterChildren(t,e=>"window"!==e.type);return e?r.filter(e):r}getRow(e){return _(e),this.getBox(t=>"row"===t.type&&e(t))}getAllRows(e){return _(e,!0),e?this.getAllBoxes(t=>"row"===t.type&&e(t)):this.getAllBoxes(e=>"row"===e.type)}getColumn(e){return _(e),this.getBox(t=>"column"===t.type&&e(t))}getAllColumns(e){return _(e,!0),e?this.getAllBoxes(t=>"column"===t.type&&e(t)):this.getAllBoxes(e=>"column"===e.type)}getGroup(e){return _(e),this.getBox(t=>"group"===t.type&&e(t))}getAllGroups(e){return _(e,!0),e?this.getAllBoxes(t=>"group"===t.type&&e(t)):this.getAllBoxes(e=>"group"===e.type)}getWindow(e){_(e);const t=Lr(this).children;return Lr(this).controller.iterateFindChild(t,t=>"window"===t.type&&e(t))}getAllWindows(e){_(e,!0);const t=Lr(this).children,r=Lr(this).controller.iterateFilterChildren(t,e=>"window"===e.type);return e?r.filter(e):r}addRow(e){return Lr(this).base.addParent(this,"row","workspace",e)}addColumn(e){return Lr(this).base.addParent(this,"column","workspace",e)}addGroup(e){return Lr(this).base.addParent(this,"group","workspace",e)}addWindow(e){return Lr(this).base.addWindow(this,e,"workspace")}async bundleToRow(){await Lr(this).controller.bundleWorkspaceTo("row",this.id),await this.refreshReference()}async bundleToColumn(){await Lr(this).controller.bundleWorkspaceTo("column",this.id),await this.refreshReference()}async hibernate(){await Lr(this).controller.hibernateWorkspace(this.id),await this.refreshReference()}async resume(){await Lr(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:vt.runWithException(t);await Lr(this).controller.lockWorkspace(this.id,r),await this.refreshReference()}async pin(e){$t.runWithException(e),await Lr(this).controller.pinWorkspace(this.id,e?.icon),await this.refreshReference()}async unpin(){await Lr(this).controller.unpinWorkspace(this.id),await this.refreshReference()}async showLoadingAnimation(){if(!gr())throw new Error("Not supported in IO Connect Browser");await Lr(this).controller.showWorkspaceLoadingAnimation(this.id)}async hideLoadingAnimation(){if(!gr())throw new Error("Not supported in IO Connect Browser");await Lr(this).controller.hideWorkspaceLoadingAnimation(this.id)}async setWindowDragMode(e){if(!gr())throw new Error("Not supported in IO Connect Browser");E.runWithException(e),await Lr(this).controller.setWindowDragMode(this.id,e),await this.refreshReference()}async onClosed(e){_(e);const t=Lr(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 Lr(this).controller.processLocalSubscription(r,t)}async onHibernated(e){_(e);const t=Lr(this).id,r={action:"hibernated",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await Lr(this).controller.processLocalSubscription(r,t)}async onResumed(e){_(e);const t=Lr(this).id,r={action:"resumed",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await Lr(this).controller.processLocalSubscription(r,t)}async onLockConfigurationChanged(e){_(e);const t=Lr(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 Lr(this).controller.processLocalSubscription(r,t)}async onTabReordered(e){_(e);const t=Lr(this).id,r={action:"tab-reordered",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await Lr(this).controller.processLocalSubscription(r,t)}async onWindowAdded(e){_(e);const t=Lr(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 Lr(this).controller.processLocalSubscription(r,t)}async onWindowRemoved(e){_(e);const t=Lr(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 Lr(this).controller.processLocalSubscription(r,t)}async onWindowLoaded(e){_(e);const t=Lr(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 Lr(this).controller.processLocalSubscription(r,t)}async onWindowMaximized(e){_(e);const t=Lr(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 Lr(this).controller.processLocalSubscription(r,t)}async onWindowRestored(e){_(e);const t=Lr(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 Lr(this).controller.processLocalSubscription(r,t)}async onWindowSelected(e){_(e);const t=Lr(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 Lr(this).controller.processLocalSubscription(r,t)}async onWindowTabReordered(e){_(e);const t=Lr(this).id,r={action:"tab-reordered",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 Lr(this).controller.processLocalSubscription(r,t)}}const zr=new WeakMap,Or=e=>zr.get(e).manager.getWindowData(e);class Hr{constructor(e){zr.set(this,{manager:e})}get id(){return Or(this).config.windowId}get elementId(){return Or(this).id}get type(){return"window"}get frameId(){return Or(this).frame.id}get workspaceId(){return Or(this).workspace.id}get positionIndex(){return Or(this).config.positionIndex}get isMaximized(){return Or(this).config.isMaximized}get isLoaded(){return Or(this).controller.checkIsWindowLoaded(this.id)}get isSelected(){return Or(this).config.isSelected}get focused(){return this.getGdWindow().isFocused}get title(){return Or(this).config.title}get allowExtract(){return Or(this).config.allowExtract}get allowReorder(){return Or(this).config.allowReorder}get showCloseButton(){return Or(this).config.showCloseButton}get width(){return Or(this).config.widthInPx}get height(){return Or(this).config.heightInPx}get minWidth(){return Or(this).config.minWidth}get minHeight(){return Or(this).config.minHeight}get maxWidth(){return Or(this).config.maxWidth}get maxHeight(){return Or(this).config.maxHeight}get workspace(){return Or(this).workspace}get frame(){return Or(this).frame}get parent(){return Or(this).parent}get appName(){return Or(this).config.appName}async forceLoad(){if(this.isLoaded)return;const e=Or(this).controller,t=Or(this).id,r=await e.forceLoadWindow(t);Or(this).config.windowId=r,await this.workspace.refreshReference()}async focus(){const e=Or(this).id,t=Or(this).controller;await t.focusItem(e),await this.workspace.refreshReference()}async close(){const e=Or(this).id,t=Or(this).controller;await t.closeItem(e),await Or(this).parent.removeChild(t=>t.id===e),await this.workspace.refreshReference()}async setTitle(e){v.runWithException(e);const t=Or(this).id,r=Or(this).controller;await r.setItemTitle(t,e),await this.workspace.refreshReference()}async maximize(){const e=Or(this).id,t=Or(this).controller;await t.maximizeItem(e),await this.workspace.refreshReference()}async restore(){const e=Or(this).id,t=Or(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=Or(this).id,t=Or(this).config.windowId,r=await Or(this).controller.ejectWindow(e,t);return Or(this).config.windowId=r,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=Or(this).config.windowId;return Or(this).controller.getGDWindow(e)}async moveTo(e){if(!(e instanceof vr||e instanceof Er||e instanceof Fr))throw new Error("Cannot add to the provided parent, because the provided parent is not an instance of Row, Column or Group");const t=Or(this).id,r=Or(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:Bt.runWithException(t),o=Or(this).id;await Or(this).controller.lockWindow(o,r),await this.workspace.refreshReference()}async setSize(e){const t=Et.runWithException(e);if(!t.width&&!t.height)throw new Error("Expected either width or height to be passed.");const r=Or(this).id,o=Or(this).controller;await o.resizeItem(r,{height:t.height,width:t.width,relative:!1}),await this.workspace.refreshReference()}async onRemoved(e){_(e);const t=Or(this).id,r={callback:async()=>{await this.workspace.refreshReference(),e()},action:"removed",eventType:"window",scope:"window"};return await Or(this).controller.processLocalSubscription(r,t)}async onLockConfigurationChanged(e){_(e);const t=Or(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 Or(this).controller.processLocalSubscription(r,t)}async onTabReordered(e){_(e);const t=Or(this).id,r={callback:async()=>{await this.workspace.refreshReference(),e()},action:"tab-reordered",eventType:"window",scope:"window"};return await Or(this).controller.processLocalSubscription(r,t)}}const $r=new WeakMap,_r=e=>$r.get(e).manager.getFrameData(e);class jr{constructor(e){$r.set(this,{manager:e})}async registerShortcut(e,t){v.runWithException(e),_(t);const r=_r(this).summary.id;return await _r(this).controller.registerShortcut(e,r,t)}get id(){return _r(this).summary.id}get isInitialized(){return _r(this).summary.isInitialized}getBounds(){const e=_r(this).summary.id;return _r(this).controller.getFrameBounds(e)}async resize(e){const t=et.runWithException(e),r=_r(this).summary.id;return _r(this).controller.resizeItem(r,t)}async move(e){const t=tt.runWithException(e),r=_r(this).summary.id;return _r(this).controller.moveFrame(r,t)}focus(){const e=_r(this).summary.id;return _r(this).controller.focusItem(e)}async state(){if(!gr())throw new Error("State operations are not supported in IO Connect Browser");const e=_r(this).summary.id;return _r(this).controller.getFrameState(e)}setIcon(e){if(!gr())throw new Error("frame.setIcon() is not supported in IO Connect Browser");F.runWithException(e);const t=this.id;return _r(this).controller.setTaskbarIcon(e,t)}getIcon(){if(!gr())throw new Error("frame.getIcon() is not supported in IO Connect Browser");const e=this.id;return _r(this).controller.getTaskbarIcon(e)}isVisible(){if(!gr())throw new Error("frame.isVisible() is not supported in IO Connect Browser");const e=this.id;return _r(this).controller.getFrameVisibility(e)}async minimize(){if(!gr())throw new Error("State operations are not supported in IO Connect Browser");const e=_r(this).summary.id;return _r(this).controller.changeFrameState(e,"minimized")}async maximize(){if(!gr())throw new Error("State operations are not supported in IO Connect Browser");const e=_r(this).summary.id;return _r(this).controller.changeFrameState(e,"maximized")}async restore(){if(!gr())throw new Error("State operations are not supported in IO Connect Browser");const e=_r(this).summary.id;return _r(this).controller.changeFrameState(e,"normal")}close(e){const t=W(ot).runWithException(e),r=_r(this).summary.id;return _r(this).controller.closeFrame(r,t)}snapshot(){const e=_r(this).summary.id;return _r(this).controller.getSnapshot(e,"frame")}async workspaces(){return _r(this).controller.getWorkspacesByFrameId(this.id)}async getConstraints(){const e=_r(this).controller,t=_r(this).summary.id;return e.getFrameConstraints(t)}async restoreWorkspace(e,t){v.runWithException(e);const r=ne.runWithException(t);return _r(this).controller.restoreWorkspace(e,r)}createWorkspace(e,t){const r=ce.runWithException(e),o=j.runWithException(t);return _r(this).controller.createWorkspace(r,o)}async init(e){if(pe.runWithException(e),_r(this).summary.isInitialized)throw new Error("The frame has already been initialized");return _r(this).controller.initFrame(this.id,e)}async showPopup(e){if(!gr())throw new Error("Popup operations are not supported in IO Connect Browser");const t=er.runWithException(e),r=_r(this).controller;return await r.showPopup(t,this.id),r.getGDWindow(t.windowId)}async show(e){if(!gr())throw new Error("The show operation is not supported in IO Connect Browser");const t=_t.runWithException(e);return _r(this).controller.showFrame(this.id,t)}async hide(){if(!gr())throw new Error("The hide operation is not supported in IO Connect Browser");return _r(this).controller.hideFrame(this.id)}async showDialog(e){if(!gr())throw new Error("The showModal operation is not supported in IO Connect Browser");return or.runWithException(e),_r(this).controller.showFrameDialog(this.id,e)}async setOnTop(e){if(!gr())throw new Error("The setOnTop operation is not supported in IO Connect Browser");return ir.runWithException(e),_r(this).controller.setFrameOnTop(this.id,e)}async onClosing(e){if(!gr())throw new Error("Frame closing operations are not supported in io.Connect Browser");_(e);return await _r(this).controller.registerFrameOnClosing(this.id,async()=>{let t=!1;return await e({prevent:()=>t=!0}),{prevent:t}})}async onClosed(e){_(e);const t=_r(this).summary.id,r={callback:t=>{e({frameId:t.frameSummary.id,frameBounds:t.frameBounds})},action:"closed",eventType:"frame",scope:"frame"};return await _r(this).controller.processLocalSubscription(r,t)}async onMaximized(e){_(e);const t=_r(this).summary.id,r={callback:()=>{e()},action:"maximized",eventType:"frame",scope:"frame"};return await _r(this).controller.processLocalSubscription(r,t)}async onMinimized(e){_(e);const t=_r(this).summary.id,r={callback:()=>{e()},action:"minimized",eventType:"frame",scope:"frame"};return await _r(this).controller.processLocalSubscription(r,t)}async onNormal(e){_(e);const t=_r(this).summary.id,r={callback:()=>{e()},action:"normal",eventType:"frame",scope:"frame"};return await _r(this).controller.processLocalSubscription(r,t)}async onWorkspaceOpened(e){_(e);const t=_r(this).summary.id,r={callback:async t=>{const r=await _r(this).controller.transformStreamPayloadToWorkspace(t);e(r)},action:"opened",eventType:"workspace",scope:"frame"};return await _r(this).controller.processLocalSubscription(r,t)}async onWorkspaceSelected(e){_(e);const t=_r(this).summary.id,r={callback:async t=>{const r=await _r(this).controller.getWorkspaceById(t.workspaceSummary.id);e(r)},action:"selected",eventType:"workspace",scope:"frame"};return await _r(this).controller.processLocalSubscription(r,t)}async onWorkspaceClosed(e){_(e);const t=_r(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 _r(this).controller.processLocalSubscription(r,t)}async onWindowAdded(e){_(e);const t=_r(this).summary.id,r={callback:async t=>{const r=(await _r(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 _r(this).controller.processLocalSubscription(r,t)}async onWindowRemoved(e){_(e);const t=_r(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 _r(this).controller.processLocalSubscription(r,t)}async onWindowLoaded(e){_(e);const t=_r(this).summary.id,r={callback:async t=>{const r=(await _r(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 _r(this).controller.processLocalSubscription(r,t)}async onInitializationRequested(e){return _(e),this.isInitialized||e(_r(this).summary.initializationContext),()=>{}}async onFocusChanged(e){_(e);const t=_r(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 Gr{parentsData=new WeakMap;workspacesData=new WeakMap;windowsData=new WeakMap;framesData=new WeakMap;deleteData(e){e instanceof Hr&&this.windowsData.delete(e),e instanceof Pr&&this.workspacesData.delete(e),(e instanceof vr||e instanceof Er||e instanceof Fr)&&this.parentsData.delete(e),e instanceof jr&&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 vr||e instanceof Er||e instanceof Fr){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 Nr=new WeakMap,Vr=(e,t)=>{const r=Nr.get(e).manager;return t instanceof Pr?r.getWorkspaceData(t):Nr.get(e).manager.getParentData(t)};class Jr{frameId;workspaceId;positionIndex;constructor(e){Nr.set(this,{manager:e})}getId(e){return Vr(this,e).id}getPositionIndex(e){return Vr(this,e).config.positionIndex}getWorkspaceId(e){const t=Vr(this,e);return t.config.workspaceId||t.workspace.id}getFrameId(e){return Vr(this,e).frame.id}getAllChildren(e,t){_(t,!0);const r=Vr(this,e).children;return void 0===t?r:r.filter(t)}getMyParent(e){return e instanceof Pr?e:Vr(this,e).parent}getMyFrame(e){return Vr(this,e).frame}getMyWorkspace(e){return e instanceof Pr?e:Vr(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=q.runWithException(t),n=Vr(this,e).controller,i=await n.add("window",Vr(this,e).id,r,o);if(e instanceof Pr)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=Vr(this,e).controller,a=(await i.add("container",Vr(this,e).id,r,n)).itemId;if(e instanceof Pr)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){_(t);const r=this.getAllChildren(e).find(t);r&&(await r.close(),e instanceof Pr?await e.refreshReference():await this.getMyWorkspace(e).refreshReference())}async maximize(e){const{controller:t,id:r}=Vr(this,e);await t.maximizeItem(r),await this.getMyWorkspace(e.parent).refreshReference()}async restore(e){const{controller:t,id:r}=Vr(this,e);await t.restoreItem(r),await this.getMyWorkspace(e.parent).refreshReference()}async close(e){const t=Vr(this,e),r=Vr(this,e).controller;await r.closeItem(t.id),await this.getMyWorkspace(t.parent).refreshReference()}async lockContainer(e,t){const r=Vr(this,e),o=Vr(this,e).controller;await o.lockContainer(r.id,e.type,t),await this.getMyWorkspace(r.parent).refreshReference()}getAllowDrop(e){return Vr(this,e).config.allowDrop}getAllowDropLeft(e){const t=Vr(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=Vr(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=Vr(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=Vr(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=Vr(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=Vr(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=Vr(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=Vr(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=Vr(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=Vr(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=Vr(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 Vr(this,e).config.minWidth}getMaxWidth(e){return Vr(this,e).config.maxWidth}getMinHeight(e){return Vr(this,e).config.minHeight}getMaxHeight(e){return Vr(this,e).config.maxHeight}getWidthInPx(e){return Vr(this,e).config.widthInPx}getHeightInPx(e){return Vr(this,e).config.heightInPx}getIsPinned(e){return Vr(this,e).config.isPinned}getIsMaximized(e){return Vr(this,e).config.isMaximized}getMaximizationBoundary(e){return Vr(this,e).config.maximizationBoundary}async setHeight(e,t){const r=Vr(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=Vr(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=Vr(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=Vr(this,e),{controller:o,id:n}=r;await o.setMaximizationBoundary(n,t),await this.getMyWorkspace(r.parent).refreshReference()}async bundleTo(e,t){const r=Vr(this,e),{controller:o,id:n}=r;await o.bundleItemTo(t,n)}async processLocalSubscription(e,t){return Vr(this,e).controller.processLocalSubscription(t,this.getId(e))}transformDefinition(e,t){let r;return void 0===t?r={type:e,children:[]}:t instanceof kr?r=t.serialize():(void 0===t.type&&(t.type=e),r=te.runWithException(t),r.children=r.children||[]),r}}class Ur{ioc;windows;contexts;layouts;layoutsV2;constructor(e,t,r,o,n){this.ioc=e,this.windows=t,this.contexts=r,this.layouts=o,this.layoutsV2=n}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(pr.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(pr.createFrame.name,e)};return this.ioc.getModel("frame",t)}async initFrame(e,t){await this.bridge.send(pr.initFrame.name,{frameId:e,...t})}async restoreWorkspaceById(e){const t=await this.bridge.send(pr.openWorkspaceById.name,{...e}),r={summary:await this.bridge.send(pr.getFrameSummary.name,{itemId:t.config.frameId})},o={frame:this.ioc.getModel("frame",r),snapshot:t};return this.ioc.getModel("workspace",o)}async restoreWorkspace(e,t){const r=await this.bridge.send(pr.openWorkspace.name,{name:e,restoreOptions:t}),o={summary:await this.bridge.send(pr.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=pr.addWindow.name;else{if("container"!==e)throw new Error(`Unrecognized add type: ${e}`);n=pr.addContainer.name}return await this.bridge.send(n,i)}async getFrame(e){const t={summary:await this.bridge.send(pr.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))}async handleOnSaved(e){const t=t=>{"Workspace"===t.type&&e(t)};if(this.layoutsV2){const[e,r]=await Promise.all([this.layoutsV2.onAdded(t),this.layoutsV2.onChanged(t)]);return()=>{e(),r()}}const r=this.layouts.onAdded(t),o=this.layouts.onChanged(t);return()=>{r(),o()}}async handleOnRemoved(e){const t=t=>{"Workspace"===t.type&&e(t)};return this.layoutsV2?this.layoutsV2.onRemoved(t):this.layouts.onRemoved(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(pr.getWorkspaceSnapshot.name,{itemId:e.workspaceSummary.id})};return this.ioc.getModel("workspace",r)}async fetchWorkspace(e){const t=await this.bridge.send(pr.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(pr.bundleWorkspace.name,{type:e,workspaceId:t})}async bundleItemTo(e,t){if(!await this.isOperationSupported(pr.bundleItem.name))throw new Error(`Operation ${pr.bundleItem.name} is not supported. Ensure that you are running the latest version of all packages`);await this.bridge.send(pr.bundleItem.name,{type:e,itemId:t})}async getTaskbarIcon(e){return await this.bridge.send(pr.getTaskbarIcon.name,{frameId:e})}async setTaskbarIcon(e,t){await this.bridge.send(pr.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(pr.restoreItem.name,{itemId:e})}async maximizeItem(e){await this.bridge.send(pr.maximizeItem.name,{itemId:e})}async focusItem(e){await this.bridge.send(pr.focusItem.name,{itemId:e})}async closeWorkspace(e){await this.bridge.send(pr.closeWorkspace.name,{itemId:e})}async closeItem(e){await this.bridge.send(pr.closeItem.name,{itemId:e})}async closeFrame(e,t){await this.bridge.send(pr.closeItem.name,{itemId:e,closeOptions:t})}async resizeItem(e,t){await this.bridge.send(pr.resizeItem.name,Object.assign({},{itemId:e},t))}async setMaximizationBoundary(e,t){await this.bridge.send(pr.setMaximizationBoundary.name,Object.assign({},{itemId:e},t))}async showWorkspaceLoadingAnimation(e){await this.bridge.send(pr.showLoadingAnimation.name,{itemId:e,type:"workspace"})}async hideWorkspaceLoadingAnimation(e){await this.bridge.send(pr.hideLoadingAnimation.name,{itemId:e,type:"workspace"})}async setWindowDragMode(e,t){await this.bridge.send(pr.setWindowDragMode.name,{itemId:e,dragMode:t})}async moveFrame(e,t){await this.bridge.send(pr.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(pr.forceLoadWindow.name,{itemId:e})).windowId}async ejectWindow(e,t){return await this.bridge.send(pr.ejectWindow.name,{itemId:e,windowId:t})}async moveWindowTo(e,t){await this.bridge.send(pr.moveWindowTo.name,{itemId:e,containerId:t})}async getSnapshot(e,t){let r;return"workspace"===t?r=await this.bridge.send(pr.getWorkspaceSnapshot.name,{itemId:e}):"frame"===t&&(r=await this.bridge.send(pr.getFrameSnapshot.name,{itemId:e})),r}async setItemTitle(e,t){await this.bridge.send(pr.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 Pr||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(pr.hibernateWorkspace.name,{workspaceId:e})}async resumeWorkspace(e){await this.bridge.send(pr.resumeWorkspace.name,{workspaceId:e})}async lockWorkspace(e,t){await this.bridge.send(pr.lockWorkspace.name,{workspaceId:e,config:t})}async lockWindow(e,t){await this.bridge.send(pr.lockWindow.name,{windowPlacementId:e,config:t})}async lockContainer(e,t,r){await this.bridge.send(pr.lockContainer.name,{itemId:e,type:t,config:r})}async pinWorkspace(e,t){await this.bridge.send(pr.pinWorkspace.name,{workspaceId:e,icon:t})}async unpinWorkspace(e){await this.bridge.send(pr.unpinWorkspace.name,{workspaceId:e})}async getWorkspaceIcon(e){return(await this.bridge.send(pr.getWorkspaceIcon.name,{workspaceId:e})).icon}setWorkspaceIcon(e,t){return this.bridge.send(pr.setWorkspaceIcon.name,{workspaceId:e,icon:t})}async getPlatformFrameId(){try{return await this.bridge.send(pr.getPlatformFrameId.name,{})}catch(e){return{}}}async setLoadingStrategy(e,t){return await this.isOperationSupported(pr.setLoadingStrategy.name),this.bridge.send(pr.setLoadingStrategy.name,{itemId:e,strategy:t})}async showFrame(e,t){const r={frameId:e,isVisible:!0,...t};return this.bridge.send(pr.changeFrameVisibility.name,r)}async hideFrame(e){return this.bridge.send(pr.changeFrameVisibility.name,{frameId:e,isVisible:!1})}async getFrameVisibility(e){return(await this.bridge.send(pr.getFrameVisibility.name,{itemId:e})).isVisible}async showFrameDialog(e,t){return await this.bridge.send(pr.showFrameDialog.name,{frameId:e,options:t},{timeout:864e5})}async setFrameOnTop(e,t){return this.bridge.send(pr.setFrameOnTop.name,{frameId:e,onTop:t.onTop})}async isOperationSupported(e){return gr()?{isSupported:!0}:await this.bridge.send(pr.operationCheck.name,{operation:e})}async showPopup(e,t){return this.bridge.send(pr.showPopup.name,{...e,frameId:t})}}class Kr{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(pr.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 restoreWorkspaceById(e){if(!(await this.getLayoutSummaries()).some(t=>t.id===e.layoutId))throw new Error(`This layout: ${e.layoutId} cannot be restored, because it doesn't exist.`);if(e?.frameId){if(!(await this.bridge.send(pr.getAllFramesSummaries.name)).summaries.some(t=>t.id===e.frameId))throw new Error(`Cannot reuse the frame with id: ${e.frameId}, because there is no frame with that ID found`)}return await this.base.restoreWorkspaceById(e)}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(pr.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 gr()?this.handleEnterpriseLocalSubscription(e,t):this.handleCoreLocalSubscription(e,t)}processGlobalSubscription(e,t,r){return gr()?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(pr.getAllFramesSummaries.name);return this.base.getFrames(t.summaries,e)}getWorkspaceById(e){return this.base.fetchWorkspace(e)}async getWorkspaceByWindowId(e){return gr()?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 isLastWorkspaceInFrame(e,t){const r=(await this.getAllWorkspaceSummaries()).filter(e=>e.frameId===t);return 1===r.length&&r[0].id===e}async getAllWorkspaceSummaries(){const e=await this.bridge.send(pr.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(pr.getAllLayoutsSummaries.name)).summaries}async deleteLayout(e){await this.bridge.send(pr.deleteLayout.name,{name:e})}async deleteLayoutById(e){await this.bridge.send(pr.deleteLayoutById.name,{layoutId:e})}async exportLayout(e){return(await this.bridge.send(pr.exportAllLayouts.name)).layouts.reduce((t,r)=>(e&&!e(r)||t.push(r),t),[])}async saveLayout(e){return await this.bridge.send(pr.saveLayout.name,e)}async saveLayoutById(e){return await this.bridge.send(pr.saveLayoutById.name,e)}async importLayouts(e,t){if(gr())try{await this.bridge.send(pr.importLayouts.name,{layouts:e,mode:t})}catch(r){await Promise.all(e.map(e=>this.bridge.send(pr.importLayout.name,{layout:e,mode:t})))}else await this.base.importLayouts(e,t)}async handleOnSaved(e){return this.base.handleOnSaved(e)}async 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(pr.changeFrameState.name,{frameId:e,requestedState:t})}async getFrameBounds(e){return(await this.bridge.send(pr.getFrameBounds.name,{itemId:e})).bounds}async getFrameState(e){return(await this.bridge.send(pr.getFrameState.name,{itemId:e})).state}async closeWorkspace(e,t){if(gr())return await this.closeItem(e);let r=!1;try{const{isSupported:e}=await this.base.isOperationSupported(pr.closeWorkspace.name);r=e}catch(e){r=!1}return r?await this.base.closeWorkspace(e):await this.legacyCloseWorkspace(e,t)}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,t){const r=(await this.base.ejectWindow(e,t)).windowId;return await this.base.notifyWindowAdded(r),r}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)}showPopup(e,t){return this.base.showPopup(e,t)}async showFrame(e,t){return this.base.showFrame(e,t)}async hideFrame(e){return this.base.hideFrame(e)}async getFrameVisibility(e){return this.base.getFrameVisibility(e)}async showFrameDialog(e,t){return this.base.showFrameDialog(e,t)}async setFrameOnTop(e,t){return this.base.setFrameOnTop(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)}}async legacyCloseWorkspace(e,t){const r=await this.isLastWorkspaceInFrame(e,t),o=(await this.getPlatformFrameId()).id;if(r&&o!==t)return await this.closeFrame(t,{});await this.closeItem(e)}}class qr{bridge;_shortcuts=r();constructor(e){this.bridge=e,this.bridge.onOperation(e=>{if(e.operation===ur.shortcutClicked.name){const t=e.data;this._shortcuts.execute(`${t.frameId}-${t.shortcut}`)}})}async registerShortcut(e,t,r){await this.bridge.send(pr.registerShortcut.name,{shortcut:e,frameId:t});const o=this._shortcuts.add(`${t}-${e}`,r);return()=>{o(),this.bridge.send(pr.unregisterShortcut.name,{shortcut:e,frameId:t})}}}class Qr{bridge;registry=r();constructor(e){this.bridge=e,this.subscribeToFrameClosing()}async registerFrameOnClosing(e,t){return await this.bridge.send(pr.subscribeToFrameClosing.name,{itemId:e}),this.registry.add(e,t)}subscribeToFrameClosing(){this.bridge.onOperationWithResponse(async e=>{if(e.operation!==ur.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 Xr{agm;windows;layouts;contexts;layoutsV2;_controllerInstance;_bridgeInstance;_transportInstance;_privateDataManagerInstance;_parentBaseInstance;_baseController;_shortcutsController;_closingController;constructor(e,t,r,o,n){this.agm=e,this.windows=t,this.layouts=r,this.contexts=o,this.layoutsV2=n}get baseController(){return this._baseController||(this._baseController=new Ur(this,this.windows,this.contexts,this.layouts,this.layoutsV2)),this._baseController}get controller(){return this._controllerInstance||(this._controllerInstance=new Kr(this.bridge,this.baseController,this.shortcutsController,this.closingController)),this._controllerInstance}get shortcutsController(){return this._shortcutsController||(this._shortcutsController=new qr(this.bridge)),this._shortcutsController}get closingController(){return this._closingController||(this._closingController=new Qr(this.bridge)),this._closingController}get bridge(){return this._bridgeInstance||(this._bridgeInstance=new mr(this.transport,r())),this._bridgeInstance}get transport(){return this._transportInstance||(this._transportInstance=new yr(this.agm,r())),this._transportInstance}get privateDataManager(){return this._privateDataManagerInstance||(this._privateDataManagerInstance=new Gr),this._privateDataManagerInstance}get parentBase(){return this._parentBaseInstance||(this._parentBaseInstance=new Jr(this.privateDataManager)),this._parentBaseInstance}async initiate(e){await this.transport.initiate(e)}getModel(e,t){switch(e){case"frame":{const e=new jr(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 Er(this.parentBase):"row"===e?new vr(this.parentBase):new Fr(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 Pr(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 Ir(this.getBuilder.bind(this));switch(e.type){case"workspace":return new Sr(e.definition,t,this.controller);case"row":case"column":case"group":return e.definition.type=e.type,new kr(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 Yr=async e=>{const t=new Xr(e.agm,e.windows,e.layouts,e.contexts,e.layouts.v2),r=e.interop.instance.windowId;await t.initiate(r),e.workspaces=((e,t)=>{const r=t.controller,o=async e=>(_(e,!0),r.getFrames(e)),n=async e=>(_(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=me.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=>(_(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=>(_(e),(await r.getWorkspaces(e))[0]),getWorkspaceById:async e=>(v.runWithException(e),r.getWorkspaceById(e)),getAllWorkspaces:e=>(_(e,!0),r.getWorkspaces(e)),getWindow:async e=>(_(e),r.getWindow(e)),getBox:async e=>(_(e),r.getParent(e)),restoreWorkspace:async(e,t)=>{v.runWithException(e);const o=ne.runWithException(t);return r.restoreWorkspace(e,o)},restoreWorkspaceById:async e=>{const t=ie.runWithException(e);return r.restoreWorkspaceById(t)},createWorkspace:async(e,t)=>{const o=ce.runWithException(e),n=j.runWithException(t);return r.createWorkspace(o,n)},createEmptyFrame:async e=>{const t=ue.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)),deleteById:async e=>(v.runWithException(e),r.deleteLayoutById(e)),export:async e=>(_(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=>Ae.runWithException(e)),r.importLayouts(e,t)},save:async e=>{const t=St.runWithException(e);return r.saveLayout(t)},saveById:async e=>{const t=xt.runWithException(e);return r.saveLayoutById(t)},onSaved:async e=>(_(e),r.handleOnSaved(e)),onRemoved:async e=>(_(e),r.handleOnRemoved(e))},onFrameOpened:n,onFrameClosed:async e=>(_(e),await r.processGlobalSubscription(t=>{e({frameId:t.frameSummary.id,frameBounds:t.frameBounds})},"frame","closed")),onWorkspaceOpened:async e=>(_(e),await r.processGlobalSubscription(async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)},"workspace","opened")),onWorkspaceClosed:async e=>(_(e),await r.processGlobalSubscription(t=>{e({frameId:t.frameSummary.id,workspaceId:t.workspaceSummary.id,frameBounds:t.frameBounds})},"workspace","closed")),onWorkspaceHibernated:async e=>(_(e),await r.processGlobalSubscription(async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)},"workspace","hibernated")),onWorkspaceResumed:async e=>(_(e),await r.processGlobalSubscription(async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)},"workspace","resumed")),onWorkspaceTabReordered:async e=>(_(e),await r.processGlobalSubscription(async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)},"workspace","tab-reordered")),onWindowTabReordered:async e=>(_(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","tab-reordered")),onWindowAdded:async e=>(_(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=>(_(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=>(_(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=>(_(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=>(_(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=>(_(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:"5.0.0-next.0"}})(e,t)};return"undefined"!=typeof window&&(window.IOWorkspaces=Yr),Yr});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):((e="undefined"!=typeof globalThis?globalThis:e||self).workspaces=e.workspaces||{},e.workspaces.min=t())}(this,function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function t(e){if(e&&e.errorHandling&&"function"!=typeof e.errorHandling&&"log"!==e.errorHandling&&"silent"!==e.errorHandling&&"throw"!==e.errorHandling)throw new Error('Invalid options passed to createRegistry. Prop errorHandling should be ["log" | "silent" | "throw" | (err) => void], but '+typeof e.errorHandling+" was passed");var t=e&&"function"==typeof e.errorHandling&&e.errorHandling,r={};function o(r,o){var n=r instanceof Error?r:new Error(r);if(t)t(n);else{var i='[ERROR] callback-registry: User callback for key "'+o+'" failed: '+n.stack;if(e)switch(e.errorHandling){case"log":return console.error(i);case"silent":return;case"throw":throw new Error(i)}console.error(i)}}return{add:function(e,t,n){var i=r[e];return i||(i=[],r[e]=i),i.push(t),n&&setTimeout(function(){n.forEach(function(n){var i;if(null===(i=r[e])||void 0===i?void 0:i.includes(t))try{Array.isArray(n)?t.apply(void 0,n):t.apply(void 0,[n])}catch(t){o(t,e)}})},0),function(){var o=r[e];o&&(0===(o=o.reduce(function(e,r,o){return r===t&&e.length===o||e.push(r),e},[])).length?delete r[e]:r[e]=o)}},execute:function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];var i=r[e];if(!i||0===i.length)return[];var a=[];return i.forEach(function(r){try{var n=r.apply(void 0,t);a.push(n)}catch(t){a.push(void 0),o(t,e)}}),a},clear:function(){r={}},clearKey:function(e){r[e]&&delete r[e]}}}t.default=t;var r=e(t),o=function(e){return{ok:!0,result:e}},n=function(e){return{ok:!1,error:e}},i=function(e,t,r){return!1===t.ok?t:!1===r.ok?r:o(e(t.result,r.result))},a=function(e,t){return!0===t.ok?t:n(e(t.error))},s=function(){return s=Object.assign||function(e){for(var t,r=1,o=arguments.length;r<o;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},s.apply(this,arguments)};function c(e,t){if(e===t)return!0;if(null===e&&null===t)return!0;if(typeof e!=typeof t)return!1;if("object"==typeof e){if(Array.isArray(e)){if(!Array.isArray(t))return!1;if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!c(e[r],t[r]))return!1;return!0}var o=Object.keys(e);if(o.length!==Object.keys(t).length)return!1;for(r=0;r<o.length;r++){if(!t.hasOwnProperty(o[r]))return!1;if(!c(e[o[r]],t[o[r]]))return!1}return!0}}var d=function(e){return Array.isArray(e)},l=function(e){return"object"==typeof e&&null!==e&&!d(e)},h=function(e,t){return"expected "+e+", got "+function(e){switch(typeof e){case"string":return"a string";case"number":return"a number";case"boolean":return"a boolean";case"undefined":return"undefined";case"object":return e instanceof Array?"an array":null===e?"null":"an object";default:return JSON.stringify(e)}}(t)},u=function(e){return e.map(function(e){return"string"==typeof e?"."+e:"["+e+"]"}).join("")},p=function(e,t){var r=t.at,o=function(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]])}return r}(t,["at"]);return s({at:e+(r||"")},o)},w=function(){function e(t){var r=this;this.decode=t,this.run=function(e){return a(function(t){return{kind:"DecoderError",input:e,at:"input"+(t.at||""),message:t.message||""}},r.decode(e))},this.runPromise=function(e){return!0===(t=r.run(e)).ok?Promise.resolve(t.result):Promise.reject(t.error);var t},this.runWithException=function(e){return function(e){if(!0===e.ok)return e.result;throw e.error}(r.run(e))},this.map=function(t){return new e(function(e){return function(e,t){return!0===t.ok?o(e(t.result)):t}(t,r.decode(e))})},this.andThen=function(t){return new e(function(e){return function(e,t){return!0===t.ok?e(t.result):t}(function(r){return t(r).decode(e)},r.decode(e))})},this.where=function(t,o){return r.andThen(function(r){return t(r)?e.succeed(r):e.fail(o)})}}return e.string=function(){return new e(function(e){return"string"==typeof e?o(e):n({message:h("a string",e)})})},e.number=function(){return new e(function(e){return"number"==typeof e?o(e):n({message:h("a number",e)})})},e.boolean=function(){return new e(function(e){return"boolean"==typeof e?o(e):n({message:h("a boolean",e)})})},e.constant=function(t){return new e(function(e){return c(e,t)?o(t):n({message:"expected "+JSON.stringify(t)+", got "+JSON.stringify(e)})})},e.object=function(t){return new e(function(e){if(l(e)&&t){var r={};for(var i in t)if(t.hasOwnProperty(i)){var a=t[i].decode(e[i]);if(!0!==a.ok)return void 0===e[i]?n({message:"the key '"+i+"' is required but was not present"}):n(p("."+i,a.error));void 0!==a.result&&(r[i]=a.result)}return o(r)}return l(e)?o(e):n({message:h("an object",e)})})},e.array=function(t){return new e(function(e){if(d(e)&&t){return e.reduce(function(e,r,o){return i(function(e,t){return e.concat([t])},e,function(e,r){return a(function(e){return p("["+r+"]",e)},t.decode(e))}(r,o))},o([]))}return d(e)?o(e):n({message:h("an array",e)})})},e.tuple=function(t){return new e(function(e){if(d(e)){if(e.length!==t.length)return n({message:"expected a tuple of length "+t.length+", got one of length "+e.length});for(var r=[],i=0;i<t.length;i++){var a=t[i].decode(e[i]);if(!a.ok)return n(p("["+i+"]",a.error));r[i]=a.result}return o(r)}return n({message:h("a tuple of length "+t.length,e)})})},e.union=function(t,r){for(var o=[],n=2;n<arguments.length;n++)o[n-2]=arguments[n];return e.oneOf.apply(e,[t,r].concat(o))},e.intersection=function(t,r){for(var n=[],a=2;a<arguments.length;a++)n[a-2]=arguments[a];return new e(function(e){return[t,r].concat(n).reduce(function(t,r){return i(Object.assign,t,r.decode(e))},o({}))})},e.anyJson=function(){return new e(function(e){return o(e)})},e.unknownJson=function(){return new e(function(e){return o(e)})},e.dict=function(t){return new e(function(e){if(l(e)){var r={};for(var i in e)if(e.hasOwnProperty(i)){var a=t.decode(e[i]);if(!0!==a.ok)return n(p("."+i,a.error));r[i]=a.result}return o(r)}return n({message:h("an object",e)})})},e.optional=function(t){return new e(function(e){return null==e?o(void 0):t.decode(e)})},e.oneOf=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return new e(function(e){for(var r=[],o=0;o<t.length;o++){var i=t[o].decode(e);if(!0===i.ok)return i;r[o]=i.error}var a=r.map(function(e){return"at error"+(e.at||"")+": "+e.message}).join('", "');return n({message:'expected a value matching one of the decoders, got the errors ["'+a+'"]'})})},e.withDefault=function(t,r){return new e(function(e){return o(function(e,t){return!0===t.ok?t.result:e}(t,r.decode(e)))})},e.valueAt=function(t,r){return new e(function(e){for(var o=e,i=0;i<t.length;i++){if(void 0===o)return n({at:u(t.slice(0,i+1)),message:"path does not exist"});if("string"==typeof t[i]&&!l(o))return n({at:u(t.slice(0,i+1)),message:h("an object",o)});if("number"==typeof t[i]&&!d(o))return n({at:u(t.slice(0,i+1)),message:h("an array",o)});o=o[t[i]]}return a(function(e){return void 0===o?{at:u(t),message:"path does not exist"}:p(u(t),e)},r.decode(o))})},e.succeed=function(t){return new e(function(e){return o(t)})},e.fail=function(t){return new e(function(e){return n({message:t})})},e.lazy=function(t){return new e(function(e){return t().decode(e)})},e}(),m=w.string,g=w.number,f=w.boolean,y=w.anyJson;w.unknownJson;var b=w.constant,k=w.object,I=w.array;w.tuple,w.dict;var W=w.optional,S=w.oneOf;w.union;var x=w.intersection;w.withDefault,w.valueAt,w.succeed,w.fail;var D=w.lazy;const v=m().where(e=>e.length>0,"Expected a non-empty string"),C=g().where(e=>e>=0,"Expected a non-negative number"),B=g().where(e=>e>0,"Expected a positive number"),E=S(b("keepInside"),b("autoEject")),T=k({inWorkspace:f()}),M=k({isVisible:f()}),F=k({base64Image:v}),R=k({icon:F,frameId:v}),L=S(b("workspace"),b("row"),b("column"),b("group")),A=S(b("row"),b("column"),b("group")),P=S(b("maximized"),b("minimized"),b("normal")),z=S(b("workspace")),O=k({allowInApplicationPopup:W(f()),allowDrop:W(f())}),H=k({appName:v,allowInApplicationPopup:W(f()),allowDrop:W(f())}),$=k({apps:W(I(H)),default:W(O)}),_=(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}`)},j=W(k({saveLayout:W(f())})),G=k({name:v}),N=k({layoutId:v}),V=k({minWidth:W(g()),maxWidth:W(g()),minHeight:W(g()),maxHeight:W(g()),allowExtract:W(f()),allowReorder:W(f()),showCloseButton:W(f())}),J=k({minWidth:W(g()),maxWidth:W(g()),minHeight:W(g()),maxHeight:W(g()),allowExtract:W(f()),allowReorder:W(f()),allowDrop:W(f()),allowDropHeader:W(f()),allowDropLeft:W(f()),allowDropRight:W(f()),allowDropTop:W(f()),allowDropBottom:W(f()),showMaximizeButton:W(f()),showEjectButton:W(f()),showAddWindowButton:W(f())}),U=k({minHeight:W(g()),maxHeight:W(g()),allowDrop:W(f()),allowSplitters:W(f()),isPinned:W(f()),maximizationBoundary:W(f())}),K=k({minWidth:W(g()),maxWidth:W(g()),allowDrop:W(f()),allowSplitters:W(f()),isPinned:W(f()),maximizationBoundary:W(f())}),q=k({type:W(b("window")),appName:W(v),windowId:W(v),context:W(y()),config:W(V)}),Q=k({type:b("window"),appName:W(v),windowId:W(v),context:W(y()),config:W(V)}),X=W(k({type:W(A),children:W(D(()=>I(S(q,X)))),config:W(y())})),Y=k({type:b("column"),children:W(D(()=>I(S(Q,te)))),config:W(K)}),Z=k({type:b("row"),children:W(D(()=>I(S(Q,te)))),config:W(U)}),ee=k({type:b("group"),children:W(D(()=>I(S(Q,te)))),config:W(J)}),te=S(ee,Y,Z);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 re=k({bounds:W(k({left:W(g()),top:W(g()),width:W(C),height:W(C)})),isVisible:W(f()),frameId:W(v)}),oe=S(b("direct"),b("delayed"),b("lazy")),ne=W(k({app:W(v),context:W(y()),loadingStrategy:W(oe),title:W(v),reuseWorkspaceId:W(v),frameId:W(v),applicationName:W(v),lockdown:W(f()),activateFrame:W(f()),newFrame:W(S(re,f())),noTabHeader:W(f()),inMemoryLayout:W(f()),icon:W(v),isPinned:W(f()),isSelected:W(f()),positionIndex:W(C),allowSystemHibernation:W(f())})),ie=x(ne,k({layoutId:v})),ae=x(ne,k({layoutId:v})),se=k({name:v,restoreOptions:W(ne)}),ce=k({children:W(I(S(q,te))),context:W(y()),config:W(k({title:W(v),position:W(C),isFocused:W(f()),noTabHeader:W(f()),reuseWorkspaceId:W(v),loadingStrategy:W(oe),allowDrop:W(f()),allowDropLeft:W(f()),allowDropTop:W(f()),allowDropRight:W(f()),allowDropBottom:W(f()),allowSystemHibernation:W(f()),allowExtract:W(f()),allowWindowReorder:W(f()),showSaveButton:W(f()),allowWorkspaceTabReorder:W(f()),allowWorkspaceTabExtract:W(f()),showCloseButton:W(f()),allowSplitters:W(f()),showWindowCloseButtons:W(f()),showEjectButtons:W(f()),showAddWindowButtons:W(f()),icon:W(v),isPinned:W(f()),isSelected:W(f()),positionIndex:W(C),windowDragMode:W(E),appRestrictions:W($)})),frame:W(k({activate:W(f()),reuseFrameId:W(v),applicationName:W(v),newFrame:W(S(f(),re))}))}),de=k({workspaceId:v}),le=k({name:v,restoreOptions:W(ne)}),he=k({id:v,restoreOptions:W(ne)}),ue=W(k({applicationName:W(m()),frameConfig:W(re),context:W(k()),layoutComponentId:W(v)})),pe=k({workspaces:I(S(W(ce),W(le),W(he)))}),we=k({frameId:v,workspaces:I(S(ce,le,he))}),me=k({type:L,definition:W(S(ce,X))}),ge=x(ce,k({saveConfig:W(k({saveLayout:W(f())}))})),fe=k({itemId:v}),ye=k({context:W(k())}),be=k({id:v,isFocused:W(f()),isInitialized:W(f()),initializationContext:W(ye)});k({type:A,id:v,frameId:v,workspaceId:v,positionIndex:g()});const ke=S(b("frame"),b("workspace"),b("container"),b("window")),Ie=k({type:ke,branch:v}),We=S(b("opened"),b("closing"),b("closed"),b("focus"),b("added"),b("loaded"),b("removed"),b("childrenUpdate"),b("containerChange"),b("maximized"),b("restored"),b("minimized"),b("normal"),b("selected"),b("lock-configuration-changed"),b("hibernated"),b("resumed"),b("tab-reordered")),Se=k({frameId:v,title:v,positionIndex:C,name:v,layoutId:W(v),layoutName:W(v),isHibernated:W(f()),isSelected:W(f()),allowDrop:W(f()),allowSystemHibernation:W(f()),allowExtract:W(f()),allowWindowReorder:W(f()),allowSplitters:W(f()),showCloseButton:W(f()),showSaveButton:W(f()),allowWorkspaceTabReorder:W(f()),allowWorkspaceTabExtract:W(f()),allowDropLeft:W(f()),allowDropTop:W(f()),allowDropRight:W(f()),allowDropBottom:W(f()),minWidth:W(g()),maxWidth:W(g()),minHeight:W(g()),maxHeight:W(g()),showAddWindowButtons:W(f()),showEjectButtons:W(f()),showWindowCloseButtons:W(f()),widthInPx:W(g()),heightInPx:W(g()),isPinned:W(f()),windowDragMode:W(E),loadingStrategy:W(oe),appRestrictions:W($)}),xe=k({frameId:v,workspaceId:v,positionIndex:g(),minWidth:W(g()),maxWidth:W(g()),minHeight:W(g()),maxHeight:W(g())}),De=y(),ve=x(xe,k({windowId:W(v),isMaximized:W(f()),isFocused:f(),isSelected:W(f()),title:W(m()),appName:W(v),allowExtract:W(f()),allowReorder:W(f()),showCloseButton:W(f()),minWidth:W(g()),minHeight:W(g()),maxWidth:W(g()),maxHeight:W(g()),widthInPx:W(g()),heightInPx:W(g()),context:W(y())})),Ce=k({id:W(v),config:De,children:W(D(()=>I(Ee))),type:S(b("row"),b("column"),b("group"))}),Be=k({id:W(v),config:ve,type:b("window")}),Ee=S(Be,Ce),Te=k({id:v,config:Se,children:I(Ee),frameSummary:be,context:W(y())}),Me=k({type:b("window"),config:k({appName:v,windowId:W(v),context:W(y()),url:W(v),title:W(m()),allowExtract:W(f()),allowReorder:W(f()),showCloseButton:W(f()),minWidth:W(g()),minHeight:W(g()),maxWidth:W(g()),maxHeight:W(g()),isMaximized:W(f()),instanceId:W(v)})}),Fe=k({type:b("group"),config:y(),children:I(S(Me))}),Re=k({type:b("column"),config:y(),children:I(S(Fe,Me,D(()=>Re),D(()=>Le)))}),Le=k({type:b("row"),config:y(),children:I(S(Re,Fe,Me,D(()=>Le)))}),Ae=k({id:W(v),name:v,type:b("Workspace"),metadata:W(y()),components:I(k({type:b("Workspace"),application:W(m()),state:k({config:y(),context:y(),children:I(S(Le,Re,Fe,Me))})}))}),Pe=k({layout:Ae,mode:S(b("replace"),b("merge"))}),ze=k({layouts:I(Ae),mode:S(b("replace"),b("merge"))}),Oe=k({layouts:I(Ae)}),He=k({id:v,isFocused:W(f()),isInitialized:W(f()),initializationContext:W(ye)}),$e=k({summaries:I(He)}),_e=k({id:v,config:Se}),je=k({summaries:I(_e)}),Ge=k({id:v,config:y(),workspaces:I(Te)}),Ne=k({id:W(v),name:v,applicationName:W(m())}),Ve=k({summaries:I(Ne)}),Je=k({windowId:v}),Ue=y(),Ke=k({state:P}),qe=k({top:g(),left:g(),width:C,height:C}),Qe=k({bounds:qe}),Xe=k({icon:W(v)}),Ye=k({id:W(v)}),Ze=k({isSupported:f()}),et=k({width:W(B),height:W(B),relative:W(f())}),tt=k({top:W(g()),left:W(g()),relative:W(f())}),rt=k({itemId:v}),ot=k({allowPrevent:W(f()),showDialog:W(f())}),nt=k({itemId:v,closeOptions:W(ot)}),it=k({itemId:v,excludeIds:W(f())}),at=k({frameId:v,requestedState:P}),st=k({itemId:v,title:v}),ct=k({itemId:v,containerId:v}),dt=x(rt,et),lt=k({itemId:v,enabled:f()}),ht=x(rt,tt);k({id:v,type:A});const ut=k({definition:q,parentId:v,parentType:L}),pt=k({definition:te,parentId:v,parentType:L}),wt=k({itemId:v,windowId:W(v)}),mt=k({live:f()}),gt=k({type:S(b("row"),b("column")),workspaceId:v}),ft=k({type:S(b("row"),b("column")),itemId:v}),yt=k({itemId:v,config:De}),bt=k({frameSummary:be,frameBounds:W(qe)}),kt=k({workspaceSummary:_e,frameSummary:be,workspaceSnapshot:W(Te),frameBounds:W(qe)}),It=k({containerSummary:yt}),Wt=k({windowSummary:k({itemId:v,parentId:v,config:ve})}),St=k({id:W(v),name:v,workspaceId:v,saveContext:W(f()),allowMultiple:W(f()),metadata:W(k()),saveWindowContexts:W(f())}),xt=k({id:W(v),name:v,workspaceId:v,saveContext:W(f()),allowMultiple:W(f()),metadata:W(k()),saveWindowContexts:W(f())}),Dt=k({saveContext:W(f()),allowMultiple:W(f()),metadata:W(k()),saveWindowContexts:W(f())}),vt=k({allowDrop:W(f()),allowDropLeft:W(f()),allowDropTop:W(f()),allowDropRight:W(f()),allowDropBottom:W(f()),allowSystemHibernation:W(f()),allowExtract:W(f()),allowWindowReorder:W(f()),allowSplitters:W(f()),showCloseButton:W(f()),showSaveButton:W(f()),allowWorkspaceTabReorder:W(f()),allowWorkspaceTabExtract:W(f()),showWindowCloseButtons:W(f()),showAddWindowButtons:W(f()),showEjectButtons:W(f())}),Ct=k({workspaceId:v,config:W(vt)}),Bt=k({allowExtract:W(f()),allowReorder:W(f()),showCloseButton:W(f())}),Et=k({width:W(C),height:W(C)}),Tt=k({windowPlacementId:v,config:W(Bt)}),Mt=k({allowDrop:W(f()),allowSplitters:W(f())}),Ft=k({allowDrop:W(f()),allowSplitters:W(f())}),Rt=k({allowExtract:W(f()),allowReorder:W(f()),allowDrop:W(f()),allowDropLeft:W(f()),allowDropRight:W(f()),allowDropTop:W(f()),allowDropBottom:W(f()),allowDropHeader:W(f()),showMaximizeButton:W(f()),showEjectButton:W(f()),showAddWindowButton:W(f())}),Lt=k({itemId:v,type:b("row"),config:W(Mt)}),At=k({itemId:v,type:b("column"),config:W(Ft)}),Pt=k({itemId:v,type:b("group"),config:W(Rt)}),zt=S(Lt,At,Pt),Ot=k({workspaceId:v,icon:W(v)}),Ht=k({workspaceId:v,icon:W(v)}),$t=W(k({icon:W(v)})),_t=W(k({activate:W(f())})),jt=k({shortcut:v,frameId:v}),Gt=k({shortcut:v,frameId:v}),Nt=k({frameId:v}),Vt=k({enabled:f()}),Jt=k({itemId:v,type:z}),Ut=k({operation:v}),Kt=k({itemId:v,dragMode:E}),qt=k({itemId:v,strategy:oe}),Qt=k({prevent:f()}),Xt=k({width:C,height:C}),Yt=k({left:g(),top:g(),width:C,height:C}),Zt=S(b("none"),b("left"),b("right"),b("top"),b("bottom")),er=k({size:Xt,targetBounds:Yt,targetLocation:Zt,windowId:v,horizontalOffset:W(g()),verticalOffset:W(g()),focus:W(f())}),tr=k({frameId:v,size:Xt,targetBounds:Yt,targetLocation:Zt,windowId:v,horizontalOffset:W(g()),verticalOffset:W(g()),focus:W(f())}),rr=k({frameId:v,activate:W(f()),isVisible:f()}),or=k({mode:W(S(b("Global"),b("WindowContainer"))),type:m(),size:W(Xt),message:v,messageTitle:W(v),movable:W(f()),transparent:W(f()),title:v,context:W(y()),affirmativeButtonName:W(v),showAffirmativeButton:W(f()),cancelButtonName:W(v),showCancelButton:W(f()),negativeButtonName:W(v),showNegativeButton:W(f()),defaultAction:W(S(b("affirmative"),b("negative"),b("cancel"))),timerDuration:W(B),showTimer:W(f()),inputMaxLength:W(B),inputPattern:W(v),inputPatternErrorMessage:W(v),inputPlaceholder:W(m()),blur:W(f())}),nr=k({frameId:v,options:or}),ir=k({onTop:f()}),ar=k({frameId:v,onTop:f()}),sr="T42.Web.Platform.Control",cr="T42.Web.Platform.WSP.Stream",dr={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}},lr={control:{name:"T42.Workspaces.Client.Control",isStream:!1}},hr={frame:{name:"T42.Workspaces.Stream.Frame",payloadDecoder:bt},workspace:{name:"T42.Workspaces.Stream.Workspace",payloadDecoder:kt},container:{name:"T42.Workspaces.Stream.Container",payloadDecoder:It},window:{name:"T42.Workspaces.Stream.Window",payloadDecoder:Wt}},ur={shortcutClicked:{name:"shortcutClicked",argsDecoder:Gt,resultDecoder:Ue},frameClosing:{name:"frameClosing",argsDecoder:Nt,resultDecoder:Qt}},pr={ping:{name:"ping",resultDecoder:mt},isWindowInWorkspace:{name:"isWindowInWorkspace",argsDecoder:rt,resultDecoder:T},createWorkspace:{name:"createWorkspace",resultDecoder:Te,argsDecoder:ge},createFrame:{name:"createFrame",resultDecoder:He,argsDecoder:ue},initFrame:{name:"initFrame",resultDecoder:Ue,argsDecoder:we},getAllFramesSummaries:{name:"getAllFramesSummaries",resultDecoder:$e},getFrameSummary:{name:"getFrameSummary",resultDecoder:be,argsDecoder:fe},getAllWorkspacesSummaries:{name:"getAllWorkspacesSummaries",resultDecoder:je},getWorkspaceSnapshot:{name:"getWorkspaceSnapshot",resultDecoder:Te,argsDecoder:rt},getAllLayoutsSummaries:{name:"getAllLayoutsSummaries",resultDecoder:Ve},openWorkspaceById:{name:"openWorkspaceById",argsDecoder:ae,resultDecoder:Te},openWorkspace:{name:"openWorkspace",argsDecoder:se,resultDecoder:Te},deleteLayout:{name:"deleteLayout",resultDecoder:Ue,argsDecoder:G},deleteLayoutById:{name:"deleteLayoutById",resultDecoder:Ue,argsDecoder:N},saveLayout:{name:"saveLayout",resultDecoder:Ae,argsDecoder:St},saveLayoutById:{name:"saveLayoutById",resultDecoder:Ae,argsDecoder:xt},importLayout:{name:"importLayout",resultDecoder:Ue,argsDecoder:Pe},importLayouts:{name:"importLayouts",resultDecoder:Ue,argsDecoder:ze},exportAllLayouts:{name:"exportAllLayouts",resultDecoder:Oe},restoreItem:{name:"restoreItem",argsDecoder:rt,resultDecoder:Ue},maximizeItem:{name:"maximizeItem",argsDecoder:rt,resultDecoder:Ue},focusItem:{name:"focusItem",argsDecoder:rt,resultDecoder:Ue},closeItem:{name:"closeItem",argsDecoder:nt,resultDecoder:Ue},closeWorkspace:{name:"closeWorkspace",argsDecoder:nt,resultDecoder:Ue},resizeItem:{name:"resizeItem",argsDecoder:dt,resultDecoder:Ue},setMaximizationBoundary:{name:"setMaximizationBoundary",argsDecoder:lt,resultDecoder:Ue},changeFrameState:{name:"changeFrameState",argsDecoder:at,resultDecoder:Ue},getFrameState:{name:"getFrameState",argsDecoder:rt,resultDecoder:Ke},getFrameBounds:{name:"getFrameBounds",argsDecoder:rt,resultDecoder:Qe},moveFrame:{name:"moveFrame",argsDecoder:ht,resultDecoder:Ue},getFrameSnapshot:{name:"getFrameSnapshot",argsDecoder:it,resultDecoder:Ge},forceLoadWindow:{name:"forceLoadWindow",argsDecoder:rt,resultDecoder:Je},ejectWindow:{name:"ejectWindow",argsDecoder:rt,resultDecoder:Je},setItemTitle:{name:"setItemTitle",argsDecoder:st,resultDecoder:Ue},moveWindowTo:{name:"moveWindowTo",argsDecoder:ct,resultDecoder:Ue},addWindow:{name:"addWindow",argsDecoder:ut,resultDecoder:wt},addContainer:{name:"addContainer",argsDecoder:pt,resultDecoder:wt},bundleWorkspace:{name:"bundleWorkspace",argsDecoder:gt,resultDecoder:Ue},bundleItem:{name:"bundleItem",argsDecoder:ft,resultDecoder:Ue},hibernateWorkspace:{name:"hibernateWorkspace",argsDecoder:de,resultDecoder:Ue},resumeWorkspace:{name:"resumeWorkspace",argsDecoder:de,resultDecoder:Ue},lockWorkspace:{name:"lockWorkspace",argsDecoder:Ct,resultDecoder:Ue},lockWindow:{name:"lockWindow",argsDecoder:Tt,resultDecoder:Ue},lockContainer:{name:"lockContainer",argsDecoder:zt,resultDecoder:Ue},pinWorkspace:{name:"pinWorkspace",argsDecoder:Ot,resultDecoder:Ue},unpinWorkspace:{name:"unpinWorkspace",argsDecoder:de,resultDecoder:Ue},getWorkspaceIcon:{name:"getWorkspaceIcon",argsDecoder:de,resultDecoder:Xe},setWorkspaceIcon:{name:"setWorkspaceIcon",argsDecoder:Ht,resultDecoder:Ue},registerShortcut:{name:"registerShortcut",argsDecoder:jt,resultDecoder:Ue},unregisterShortcut:{name:"unregisterShortcut",argsDecoder:jt,resultDecoder:Ue},showLoadingAnimation:{name:"showLoadingAnimation",argsDecoder:Jt,resultDecoder:Ue},hideLoadingAnimation:{name:"hideLoadingAnimation",argsDecoder:Jt,resultDecoder:Ue},getPlatformFrameId:{name:"getPlatformFrameId",resultDecoder:Ye},operationCheck:{name:"operationCheck",argsDecoder:Ut,resultDecoder:Ze},setWindowDragMode:{name:"setWindowDragMode",argsDecoder:Kt,resultDecoder:Ue},setLoadingStrategy:{name:"setLoadingStrategy",argsDecoder:qt,resultDecoder:Ue},getTaskbarIcon:{name:"getTaskbarIcon",resultDecoder:F},setTaskbarIcon:{name:"setTaskbarIcon",argsDecoder:R,resultDecoder:Ue},subscribeToFrameClosing:{name:"subscribeToFrameClosing",argsDecoder:rt,resultDecoder:Ue},showPopup:{name:"showPopup",argsDecoder:tr,resultDecoder:Ue},changeFrameVisibility:{name:"changeFrameVisibility",argsDecoder:rr,resultDecoder:Ue},getFrameVisibility:{name:"getFrameVisibility",argsDecoder:rt,resultDecoder:M},showFrameDialog:{name:"showFrameDialog",argsDecoder:nr,resultDecoder:y()},setFrameOnTop:{name:"setFrameOnTop",argsDecoder:ar,resultDecoder:Ue}};class wr{resolve;reject;promise;constructor(){this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}class mr{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,r){const o=Object.values(pr).find(t=>t.name===e);if(!o)throw new Error(`Cannot find definition for operation name: ${e}`);if(o.argsDecoder)try{o.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(o.name,t,r);return o.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 wr,o={streamType:e.eventType,level:e.scope,levelId:e.scopeId,promise:t.promise};this.pendingSubScriptions.push(o);try{const o=hr[e.eventType],n=await this.transport.subscribe(o.name,this.getBranchKey(e),e.eventType);n.onData(e=>{const t=e.data,r=Ie.run(e.requestArguments),o=We.run(t.action);if(!r.ok||!o.ok)return;const n=r.result.type,i=`${n}-${r.result.branch}-${o.result}`,a=hr[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(ur).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(ur).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=We.runWithException(t.action),r=ke.runWithException(t.type),o=hr[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 gr=()=>"undefined"==typeof window||(window.glue42gd||window.iodesktop),fr=()=>"undefined"==typeof window?null:window.glue42core||window.iobrowser;class yr{agm;registry;defaultTransportTimeout=12e4;coreEventMethodInitiated=!1;corePlatformSubPromise;constructor(e,t){this.agm=e,this.registry=t}async initiate(e){if(gr())return await Promise.all(Object.values(dr).map(e=>this.verifyMethodLive(e.name))),void await Promise.all(Object.keys(lr).map(e=>this.registerMethod(e)));const t=fr().communicationId;await Promise.all([this.verifyMethodLive(sr,t),this.verifyMethodLive(cr,t)]),await this.transmitControl("frameHello",{windowId:e})}coreSubscriptionReady(e){return this.coreEventMethodInitiated||this.subscribePlatform(e),this.corePlatformSubPromise}subscribePlatform(e){this.coreEventMethodInitiated=!0;const t=fr().communicationId;this.corePlatformSubPromise=this.agm.subscribe(cr,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,r){const o=gr()?{operation:e,operationArguments:t}:{operation:e,domain:"workspaces",data:t},n=gr()?dr.control.name:sr,i=gr()?void 0:fr().communicationId;let a;const s=`Internal Workspaces Communication Error. Attempted operation: ${JSON.stringify(o)}. `;try{if(a=await this.agm.invoke(n,o,i?{instance:i}:"best",{methodResponseTimeoutMs:r?.timeout??this.defaultTransportTimeout}),!a)throw new Error("Received unsupported result from GD - empty result");if(!Array.isArray(a.all_return_values)||0===a.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(`${s} -> Inner message: ${t}`)}throw new Error(`${s} -> Inner message: ${e.message}`)}return a.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=lr[e];return this.agm.register(t.name,(t,r)=>Promise.all(this.registry.execute(e,t,r)))}}const br=new WeakMap;class kr{constructor(e,t){const r=t.wrapChildren(e.children);delete e.children,br.set(this,{base:t,children:r,definition:e})}get type(){return br.get(this).definition.type}addColumn(e){return br.get(this).base.add("column",br.get(this).children,e)}addRow(e){return br.get(this).base.add("row",br.get(this).children,e)}addGroup(e){return br.get(this).base.add("group",br.get(this).children,e)}addWindow(e){return br.get(this).base.addWindow(br.get(this).children,e),this}serialize(){const e=br.get(this).definition;return e.children=br.get(this).base.serializeChildren(br.get(this).children),e}}class Ir{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=X.runWithException(r),n=this.getBuilder({type:e,definition:o});return t.push(n),n}addWindow(e,t){const r=q.runWithException(t);r.type="window",e.push(r)}serializeChildren(e){return e.map(e=>e instanceof kr?e.serialize():e)}}const Wr=new WeakMap;class Sr{constructor(e,t,r){const o=t.wrapChildren(e.children);delete e.children,Wr.set(this,{base:t,children:o,definition:e,controller:r})}addColumn(e){const t=Wr.get(this).children;if(!t.every(e=>e instanceof kr&&"column"===e.type))throw new Error("Cannot add a column to this workspace, because there are already children of another type");return Wr.get(this).base.add("column",t,e)}addRow(e){const t=Wr.get(this).children;if(!t.every(e=>e instanceof kr&&"row"===e.type))throw new Error("Cannot add a row to this workspace, because there are already children of another type");return Wr.get(this).base.add("row",t,e)}addGroup(e){const t=Wr.get(this).children;if(0!==t.length)throw new Error("Cannot add a group to this workspace, because there are already defined children.");return Wr.get(this).base.add("group",t,e)}addWindow(e){const t=Wr.get(this).children;if(0!==t.length)throw new Error("Cannot add a window to this workspace, because there are already defined children.");return Wr.get(this).base.addWindow(t,e),this}getChildAt(e){C.runWithException(e);return Wr.get(this).children[e]}async create(e){const t=j.runWithException(e),r=Wr.get(this).definition;r.children=Wr.get(this).base.serializeChildren(Wr.get(this).children);return Wr.get(this).controller.createWorkspace(r,t)}}const xr=new WeakMap,Dr=e=>xr.get(e).base;class vr{constructor(e){xr.set(this,{base:e})}get type(){return"row"}get id(){return Dr(this).getId(this)}get frameId(){return Dr(this).getFrameId(this)}get workspaceId(){return Dr(this).getWorkspaceId(this)}get positionIndex(){return Dr(this).getPositionIndex(this)}get children(){return Dr(this).getAllChildren(this)}get parent(){return Dr(this).getMyParent(this)}get frame(){return Dr(this).getMyFrame(this)}get workspace(){return Dr(this).getMyWorkspace(this)}get allowDrop(){return Dr(this).getAllowDrop(this)}get allowSplitters(){return Dr(this).getAllowSplitters(this)}get minWidth(){return Dr(this).getMinWidth(this)}get minHeight(){return Dr(this).getMinHeight(this)}get maxWidth(){return Dr(this).getMaxWidth(this)}get maxHeight(){return Dr(this).getMaxHeight(this)}get width(){return Dr(this).getWidthInPx(this)}get height(){return Dr(this).getHeightInPx(this)}get isPinned(){return Dr(this).getIsPinned(this)}get isMaximized(){return Dr(this).getIsMaximized(this)}get maximizationBoundary(){return Dr(this).getMaximizationBoundary(this)}addWindow(e){return Dr(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 Dr(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 Dr(this).addParent(this,"column","row",e)}async addRow(){throw new Error("Adding rows as row children is not supported")}removeChild(e){return Dr(this).removeChild(this,e)}maximize(){return Dr(this).maximize(this)}restore(){return Dr(this).restore(this)}close(){return Dr(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:Mt.runWithException(t);return Dr(this).lockContainer(this,r)}async setHeight(e){return C.runWithException(e),Dr(this).setHeight(this,e)}async onLockConfigurationChanged(e){_(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 Dr(this).processLocalSubscription(this,t)}async setMaximizationBoundary(e){const t=Vt.runWithException(e);return Dr(this).setMaximizationBoundary(this,t)}}const Cr=new WeakMap,Br=e=>Cr.get(e).base;class Er{constructor(e){Cr.set(this,{base:e})}get type(){return"column"}get id(){return Br(this).getId(this)}get frameId(){return Br(this).getFrameId(this)}get workspaceId(){return Br(this).getWorkspaceId(this)}get positionIndex(){return Br(this).getPositionIndex(this)}get children(){return Br(this).getAllChildren(this)}get parent(){return Br(this).getMyParent(this)}get frame(){return Br(this).getMyFrame(this)}get workspace(){return Br(this).getMyWorkspace(this)}get allowDrop(){return Br(this).getAllowDrop(this)}get allowSplitters(){return Br(this).getAllowSplitters(this)}get minWidth(){return Br(this).getMinWidth(this)}get minHeight(){return Br(this).getMinHeight(this)}get maxWidth(){return Br(this).getMaxWidth(this)}get maxHeight(){return Br(this).getMaxHeight(this)}get width(){return Br(this).getWidthInPx(this)}get height(){return Br(this).getHeightInPx(this)}get isPinned(){return Br(this).getIsPinned(this)}get isMaximized(){return Br(this).getIsMaximized(this)}get maximizationBoundary(){return Br(this).getMaximizationBoundary(this)}addWindow(e){return Br(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 Br(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 Br(this).addParent(this,"row","column",e)}removeChild(e){return Br(this).removeChild(this,e)}maximize(){return Br(this).maximize(this)}restore(){return Br(this).restore(this)}close(){return Br(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 Br(this).lockContainer(this,r)}async setWidth(e){return C.runWithException(e),Br(this).setWidth(this,e)}async onLockConfigurationChanged(e){_(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 Br(this).processLocalSubscription(this,t)}async setMaximizationBoundary(e){const t=Vt.runWithException(e);return Br(this).setMaximizationBoundary(this,t)}}const Tr=new WeakMap,Mr=e=>Tr.get(e).base;class Fr{constructor(e){Tr.set(this,{base:e})}get type(){return"group"}get id(){return Mr(this).getId(this)}get frameId(){return Mr(this).getFrameId(this)}get workspaceId(){return Mr(this).getWorkspaceId(this)}get positionIndex(){return Mr(this).getPositionIndex(this)}get children(){return Mr(this).getAllChildren(this)}get parent(){return Mr(this).getMyParent(this)}get frame(){return Mr(this).getMyFrame(this)}get workspace(){return Mr(this).getMyWorkspace(this)}get allowExtract(){return Mr(this).getAllowExtract(this)}get allowReorder(){return Mr(this).getAllowReorder(this)}get allowDropLeft(){return Mr(this).getAllowDropLeft(this)}get allowDropRight(){return Mr(this).getAllowDropRight(this)}get allowDropTop(){return Mr(this).getAllowDropTop(this)}get allowDropBottom(){return Mr(this).getAllowDropBottom(this)}get allowDropHeader(){return Mr(this).getAllowDropHeader(this)}get allowDrop(){return Mr(this).getAllowDrop(this)}get showMaximizeButton(){return Mr(this).getShowMaximizeButton(this)}get showEjectButton(){return Mr(this).getShowEjectButton(this)}get showAddWindowButton(){return Mr(this).getShowAddWindowButton(this)}get minWidth(){return Mr(this).getMinWidth(this)}get minHeight(){return Mr(this).getMinHeight(this)}get maxWidth(){return Mr(this).getMaxWidth(this)}get maxHeight(){return Mr(this).getMaxHeight(this)}get width(){return Mr(this).getWidthInPx(this)}get height(){return Mr(this).getHeightInPx(this)}get isMaximized(){return Mr(this).getIsMaximized(this)}addWindow(e){return Mr(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 Mr(this).removeChild(this,e)}maximize(){return Mr(this).maximize(this)}restore(){return Mr(this).restore(this)}close(){return Mr(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:Rt.runWithException(t);return Mr(this).lockContainer(this,r)}async setSize(e){const t=Et.runWithException(e);if(!t.width&&!t.height)throw new Error("Expected either width or height to be passed.");return Mr(this).setSize(this,e.width,e.height)}async bundleToRow(){await Mr(this).bundleTo(this,"row"),await this.workspace.refreshReference()}async bundleToColumn(){await Mr(this).bundleTo(this,"column"),await this.workspace.refreshReference()}async onLockConfigurationChanged(e){_(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 Mr(this).processLocalSubscription(this,t)}}const Rr=new WeakMap,Lr=e=>Rr.get(e).manager.getWorkspaceData(e),Ar=e=>Rr.get(e).manager;class Pr{constructor(e){Rr.set(this,{manager:e})}get id(){return Lr(this).id}get frameId(){return Lr(this).config.frameId}get positionIndex(){return Lr(this).config.positionIndex}get title(){return Lr(this).config.title}get layoutId(){return Lr(this).config.layoutId}get layoutName(){return Lr(this).config.layoutName}get isHibernated(){return Lr(this).config.isHibernated}get isSelected(){return Lr(this).config.isSelected}get children(){return Lr(this).children}get frame(){return Lr(this).frame}get allowSplitters(){return Lr(this).config.allowSplitters}get allowSystemHibernation(){return Lr(this).config.allowSystemHibernation}get allowDrop(){return Lr(this).config.allowDrop}get allowDropLeft(){return Lr(this).config.allowDropLeft}get allowDropTop(){return Lr(this).config.allowDropTop}get allowDropRight(){return Lr(this).config.allowDropRight}get allowDropBottom(){return Lr(this).config.allowDropBottom}get allowExtract(){return Lr(this).config.allowExtract}get allowWindowReorder(){return Lr(this).config.allowWindowReorder}get appRestrictions(){return Lr(this).config.appRestrictions}get showCloseButton(){return Lr(this).config.showCloseButton}get showSaveButton(){return Lr(this).config.showSaveButton}get allowWorkspaceTabReorder(){return Lr(this).config.allowWorkspaceTabReorder}get allowWorkspaceTabExtract(){return Lr(this).config.allowWorkspaceTabExtract}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 width(){return Lr(this).config.widthInPx}get height(){return Lr(this).config.heightInPx}get showWindowCloseButtons(){return Lr(this).config.showWindowCloseButtons}get showEjectButtons(){return Lr(this).config.showEjectButtons}get showAddWindowButtons(){return Lr(this).config.showAddWindowButtons}get isPinned(){return Lr(this).config.isPinned}get windowDragMode(){return gr()?Lr(this).config.windowDragMode:"keepInside"}get loadingStrategy(){return gr()||console.warn("The workspace.loadingStrategy property is not supported in IO Connect Browser"),Lr(this).config.loadingStrategy}async setLoadingStrategy(e){if(!gr())throw new Error("Not supported in IO Connect Browser");const t=Lr(this).controller;await t.setLoadingStrategy(this.id,e),await this.refreshReference()}async removeChild(e){_(e);const t=this.children.find(e);t&&(await t.close(),await this.refreshReference())}async remove(e){_(e);const t=Lr(this).controller.iterateFindChild(this.children,e);await t.close(),await this.refreshReference()}async focus(){await Lr(this).controller.focusItem(this.id),await this.refreshReference()}async close(){const e=Lr(this).controller;await e.closeWorkspace(this.id,this.frameId)}snapshot(){return Lr(this).controller.getSnapshot(this.id,"workspace")}async saveLayout(e,t){v.runWithException(e),t&&Dt.runWithException(t),await Lr(this).controller.saveLayout({name:e,workspaceId:this.id,saveContext:t?.saveContext,metadata:t?.metadata,allowMultiple:t?.allowMultiple,saveWindowContexts:t?.saveWindowContexts})}async setTitle(e){v.runWithException(e);const t=Lr(this).controller;await t.setItemTitle(this.id,e),await this.refreshReference()}getContext(){return Lr(this).controller.getWorkspaceContext(this.id)}setContext(e){return Lr(this).controller.setWorkspaceContext(this.id,e)}updateContext(e){return Lr(this).controller.updateWorkspaceContext(this.id,e)}onContextUpdated(e){return Lr(this).controller.subscribeWorkspaceContextUpdated(this.id,e)}async refreshReference(){const e=await Lr(this).controller.getSnapshot(this.id,"workspace"),t=Lr(this).controller.flatChildren(Lr(this).children),r=Lr(this).controller.refreshChildren({existingChildren:t,workspace:this,parent:this,children:e.children}),o=this.frame;let n;if(o.id===e.config.frameId)Ar(this).remapFrame(o,e.frameSummary),n=o;else{const t={summary:e.frameSummary};n=Lr(this).ioc.getModel("frame",t)}Ar(this).remapWorkspace(this,{config:e.config,children:r,frame:n})}async getIcon(){return Lr(this).controller.getWorkspaceIcon(this.id)}async setIcon(e){return Lr(this).controller.setWorkspaceIcon(this.id,e)}getBox(e){_(e);const t=Lr(this).children;return Lr(this).controller.iterateFindChild(t,t=>"window"!==t.type&&e(t))}getAllBoxes(e){_(e,!0);const t=Lr(this).children,r=Lr(this).controller.iterateFilterChildren(t,e=>"window"!==e.type);return e?r.filter(e):r}getRow(e){return _(e),this.getBox(t=>"row"===t.type&&e(t))}getAllRows(e){return _(e,!0),e?this.getAllBoxes(t=>"row"===t.type&&e(t)):this.getAllBoxes(e=>"row"===e.type)}getColumn(e){return _(e),this.getBox(t=>"column"===t.type&&e(t))}getAllColumns(e){return _(e,!0),e?this.getAllBoxes(t=>"column"===t.type&&e(t)):this.getAllBoxes(e=>"column"===e.type)}getGroup(e){return _(e),this.getBox(t=>"group"===t.type&&e(t))}getAllGroups(e){return _(e,!0),e?this.getAllBoxes(t=>"group"===t.type&&e(t)):this.getAllBoxes(e=>"group"===e.type)}getWindow(e){_(e);const t=Lr(this).children;return Lr(this).controller.iterateFindChild(t,t=>"window"===t.type&&e(t))}getAllWindows(e){_(e,!0);const t=Lr(this).children,r=Lr(this).controller.iterateFilterChildren(t,e=>"window"===e.type);return e?r.filter(e):r}addRow(e){return Lr(this).base.addParent(this,"row","workspace",e)}addColumn(e){return Lr(this).base.addParent(this,"column","workspace",e)}addGroup(e){return Lr(this).base.addParent(this,"group","workspace",e)}addWindow(e){return Lr(this).base.addWindow(this,e,"workspace")}async bundleToRow(){await Lr(this).controller.bundleWorkspaceTo("row",this.id),await this.refreshReference()}async bundleToColumn(){await Lr(this).controller.bundleWorkspaceTo("column",this.id),await this.refreshReference()}async hibernate(){await Lr(this).controller.hibernateWorkspace(this.id),await this.refreshReference()}async resume(){await Lr(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:vt.runWithException(t);await Lr(this).controller.lockWorkspace(this.id,r),await this.refreshReference()}async pin(e){$t.runWithException(e),await Lr(this).controller.pinWorkspace(this.id,e?.icon),await this.refreshReference()}async unpin(){await Lr(this).controller.unpinWorkspace(this.id),await this.refreshReference()}async showLoadingAnimation(){if(!gr())throw new Error("Not supported in IO Connect Browser");await Lr(this).controller.showWorkspaceLoadingAnimation(this.id)}async hideLoadingAnimation(){if(!gr())throw new Error("Not supported in IO Connect Browser");await Lr(this).controller.hideWorkspaceLoadingAnimation(this.id)}async setWindowDragMode(e){if(!gr())throw new Error("Not supported in IO Connect Browser");E.runWithException(e),await Lr(this).controller.setWindowDragMode(this.id,e),await this.refreshReference()}async onClosed(e){_(e);const t=Lr(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 Lr(this).controller.processLocalSubscription(r,t)}async onHibernated(e){_(e);const t=Lr(this).id,r={action:"hibernated",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await Lr(this).controller.processLocalSubscription(r,t)}async onResumed(e){_(e);const t=Lr(this).id,r={action:"resumed",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await Lr(this).controller.processLocalSubscription(r,t)}async onLockConfigurationChanged(e){_(e);const t=Lr(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 Lr(this).controller.processLocalSubscription(r,t)}async onTabReordered(e){_(e);const t=Lr(this).id,r={action:"tab-reordered",eventType:"workspace",scope:"workspace",scopeId:t,callback:async()=>{await this.refreshReference(),e()}};return await Lr(this).controller.processLocalSubscription(r,t)}async onWindowAdded(e){_(e);const t=Lr(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 Lr(this).controller.processLocalSubscription(r,t)}async onWindowRemoved(e){_(e);const t=Lr(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 Lr(this).controller.processLocalSubscription(r,t)}async onWindowLoaded(e){_(e);const t=Lr(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 Lr(this).controller.processLocalSubscription(r,t)}async onWindowMaximized(e){_(e);const t=Lr(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 Lr(this).controller.processLocalSubscription(r,t)}async onWindowRestored(e){_(e);const t=Lr(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 Lr(this).controller.processLocalSubscription(r,t)}async onWindowSelected(e){_(e);const t=Lr(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 Lr(this).controller.processLocalSubscription(r,t)}async onWindowTabReordered(e){_(e);const t=Lr(this).id,r={action:"tab-reordered",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 Lr(this).controller.processLocalSubscription(r,t)}}const zr=new WeakMap,Or=e=>zr.get(e).manager.getWindowData(e);class Hr{constructor(e){zr.set(this,{manager:e})}get id(){return Or(this).config.windowId}get elementId(){return Or(this).id}get type(){return"window"}get frameId(){return Or(this).frame.id}get workspaceId(){return Or(this).workspace.id}get positionIndex(){return Or(this).config.positionIndex}get isMaximized(){return Or(this).config.isMaximized}get isLoaded(){return Or(this).controller.checkIsWindowLoaded(this.id)}get isSelected(){return Or(this).config.isSelected}get focused(){return this.getGdWindow().isFocused}get title(){return Or(this).config.title}get allowExtract(){return Or(this).config.allowExtract}get allowReorder(){return Or(this).config.allowReorder}get showCloseButton(){return Or(this).config.showCloseButton}get width(){return Or(this).config.widthInPx}get height(){return Or(this).config.heightInPx}get minWidth(){return Or(this).config.minWidth}get minHeight(){return Or(this).config.minHeight}get maxWidth(){return Or(this).config.maxWidth}get maxHeight(){return Or(this).config.maxHeight}get workspace(){return Or(this).workspace}get frame(){return Or(this).frame}get parent(){return Or(this).parent}get appName(){return Or(this).config.appName}async forceLoad(){if(this.isLoaded)return;const e=Or(this).controller,t=Or(this).id,r=await e.forceLoadWindow(t);Or(this).config.windowId=r,await this.workspace.refreshReference()}async focus(){const e=Or(this).id,t=Or(this).controller;await t.focusItem(e),await this.workspace.refreshReference()}async close(){const e=Or(this).id,t=Or(this).controller;await t.closeItem(e),await Or(this).parent.removeChild(t=>t.id===e),await this.workspace.refreshReference()}async setTitle(e){v.runWithException(e);const t=Or(this).id,r=Or(this).controller;await r.setItemTitle(t,e),await this.workspace.refreshReference()}async maximize(){const e=Or(this).id,t=Or(this).controller;await t.maximizeItem(e),await this.workspace.refreshReference()}async restore(){const e=Or(this).id,t=Or(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=Or(this).id,t=Or(this).config.windowId,r=await Or(this).controller.ejectWindow(e,t);return Or(this).config.windowId=r,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=Or(this).config.windowId;return Or(this).controller.getGDWindow(e)}async moveTo(e){if(!(e instanceof vr||e instanceof Er||e instanceof Fr))throw new Error("Cannot add to the provided parent, because the provided parent is not an instance of Row, Column or Group");const t=Or(this).id,r=Or(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:Bt.runWithException(t),o=Or(this).id;await Or(this).controller.lockWindow(o,r),await this.workspace.refreshReference()}async setSize(e){const t=Et.runWithException(e);if(!t.width&&!t.height)throw new Error("Expected either width or height to be passed.");const r=Or(this).id,o=Or(this).controller;await o.resizeItem(r,{height:t.height,width:t.width,relative:!1}),await this.workspace.refreshReference()}async onRemoved(e){_(e);const t=Or(this).id,r={callback:async()=>{await this.workspace.refreshReference(),e()},action:"removed",eventType:"window",scope:"window"};return await Or(this).controller.processLocalSubscription(r,t)}async onLockConfigurationChanged(e){_(e);const t=Or(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 Or(this).controller.processLocalSubscription(r,t)}async onTabReordered(e){_(e);const t=Or(this).id,r={callback:async()=>{await this.workspace.refreshReference(),e()},action:"tab-reordered",eventType:"window",scope:"window"};return await Or(this).controller.processLocalSubscription(r,t)}}const $r=new WeakMap,_r=e=>$r.get(e).manager.getFrameData(e);class jr{constructor(e){$r.set(this,{manager:e})}async registerShortcut(e,t){v.runWithException(e),_(t);const r=_r(this).summary.id;return await _r(this).controller.registerShortcut(e,r,t)}get id(){return _r(this).summary.id}get isInitialized(){return _r(this).summary.isInitialized}getBounds(){const e=_r(this).summary.id;return _r(this).controller.getFrameBounds(e)}async resize(e){const t=et.runWithException(e),r=_r(this).summary.id;return _r(this).controller.resizeItem(r,t)}async move(e){const t=tt.runWithException(e),r=_r(this).summary.id;return _r(this).controller.moveFrame(r,t)}focus(){const e=_r(this).summary.id;return _r(this).controller.focusItem(e)}async state(){if(!gr())throw new Error("State operations are not supported in IO Connect Browser");const e=_r(this).summary.id;return _r(this).controller.getFrameState(e)}setIcon(e){if(!gr())throw new Error("frame.setIcon() is not supported in IO Connect Browser");F.runWithException(e);const t=this.id;return _r(this).controller.setTaskbarIcon(e,t)}getIcon(){if(!gr())throw new Error("frame.getIcon() is not supported in IO Connect Browser");const e=this.id;return _r(this).controller.getTaskbarIcon(e)}isVisible(){if(!gr())throw new Error("frame.isVisible() is not supported in IO Connect Browser");const e=this.id;return _r(this).controller.getFrameVisibility(e)}async minimize(){if(!gr())throw new Error("State operations are not supported in IO Connect Browser");const e=_r(this).summary.id;return _r(this).controller.changeFrameState(e,"minimized")}async maximize(){if(!gr())throw new Error("State operations are not supported in IO Connect Browser");const e=_r(this).summary.id;return _r(this).controller.changeFrameState(e,"maximized")}async restore(){if(!gr())throw new Error("State operations are not supported in IO Connect Browser");const e=_r(this).summary.id;return _r(this).controller.changeFrameState(e,"normal")}close(e){const t=W(ot).runWithException(e),r=_r(this).summary.id;return _r(this).controller.closeFrame(r,t)}snapshot(){const e=_r(this).summary.id;return _r(this).controller.getSnapshot(e,"frame")}async workspaces(){return _r(this).controller.getWorkspacesByFrameId(this.id)}async getConstraints(){const e=_r(this).controller,t=_r(this).summary.id;return e.getFrameConstraints(t)}async restoreWorkspace(e,t){v.runWithException(e);const r=ne.runWithException(t);return _r(this).controller.restoreWorkspace(e,r)}createWorkspace(e,t){const r=ce.runWithException(e),o=j.runWithException(t);return _r(this).controller.createWorkspace(r,o)}async init(e){if(pe.runWithException(e),_r(this).summary.isInitialized)throw new Error("The frame has already been initialized");return _r(this).controller.initFrame(this.id,e)}async showPopup(e){if(!gr())throw new Error("Popup operations are not supported in IO Connect Browser");const t=er.runWithException(e),r=_r(this).controller;return await r.showPopup(t,this.id),r.getGDWindow(t.windowId)}async show(e){if(!gr())throw new Error("The show operation is not supported in IO Connect Browser");const t=_t.runWithException(e);return _r(this).controller.showFrame(this.id,t)}async hide(){if(!gr())throw new Error("The hide operation is not supported in IO Connect Browser");return _r(this).controller.hideFrame(this.id)}async showDialog(e){if(!gr())throw new Error("The showModal operation is not supported in IO Connect Browser");return or.runWithException(e),_r(this).controller.showFrameDialog(this.id,e)}async setOnTop(e){if(!gr())throw new Error("The setOnTop operation is not supported in IO Connect Browser");return ir.runWithException(e),_r(this).controller.setFrameOnTop(this.id,e)}async onClosing(e){if(!gr())throw new Error("Frame closing operations are not supported in io.Connect Browser");_(e);return await _r(this).controller.registerFrameOnClosing(this.id,async()=>{let t=!1;return await e({prevent:()=>t=!0}),{prevent:t}})}async onClosed(e){_(e);const t=_r(this).summary.id,r={callback:t=>{e({frameId:t.frameSummary.id,frameBounds:t.frameBounds})},action:"closed",eventType:"frame",scope:"frame"};return await _r(this).controller.processLocalSubscription(r,t)}async onMaximized(e){_(e);const t=_r(this).summary.id,r={callback:()=>{e()},action:"maximized",eventType:"frame",scope:"frame"};return await _r(this).controller.processLocalSubscription(r,t)}async onMinimized(e){_(e);const t=_r(this).summary.id,r={callback:()=>{e()},action:"minimized",eventType:"frame",scope:"frame"};return await _r(this).controller.processLocalSubscription(r,t)}async onNormal(e){_(e);const t=_r(this).summary.id,r={callback:()=>{e()},action:"normal",eventType:"frame",scope:"frame"};return await _r(this).controller.processLocalSubscription(r,t)}async onWorkspaceOpened(e){_(e);const t=_r(this).summary.id,r={callback:async t=>{const r=await _r(this).controller.transformStreamPayloadToWorkspace(t);e(r)},action:"opened",eventType:"workspace",scope:"frame"};return await _r(this).controller.processLocalSubscription(r,t)}async onWorkspaceSelected(e){_(e);const t=_r(this).summary.id,r={callback:async t=>{const r=await _r(this).controller.getWorkspaceById(t.workspaceSummary.id);e(r)},action:"selected",eventType:"workspace",scope:"frame"};return await _r(this).controller.processLocalSubscription(r,t)}async onWorkspaceClosed(e){_(e);const t=_r(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 _r(this).controller.processLocalSubscription(r,t)}async onWindowAdded(e){_(e);const t=_r(this).summary.id,r={callback:async t=>{const r=(await _r(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 _r(this).controller.processLocalSubscription(r,t)}async onWindowRemoved(e){_(e);const t=_r(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 _r(this).controller.processLocalSubscription(r,t)}async onWindowLoaded(e){_(e);const t=_r(this).summary.id,r={callback:async t=>{const r=(await _r(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 _r(this).controller.processLocalSubscription(r,t)}async onInitializationRequested(e){return _(e),this.isInitialized||e(_r(this).summary.initializationContext),()=>{}}async onFocusChanged(e){_(e);const t=_r(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 Gr{parentsData=new WeakMap;workspacesData=new WeakMap;windowsData=new WeakMap;framesData=new WeakMap;deleteData(e){e instanceof Hr&&this.windowsData.delete(e),e instanceof Pr&&this.workspacesData.delete(e),(e instanceof vr||e instanceof Er||e instanceof Fr)&&this.parentsData.delete(e),e instanceof jr&&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 vr||e instanceof Er||e instanceof Fr){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 Nr=new WeakMap,Vr=(e,t)=>{const r=Nr.get(e).manager;return t instanceof Pr?r.getWorkspaceData(t):Nr.get(e).manager.getParentData(t)};class Jr{frameId;workspaceId;positionIndex;constructor(e){Nr.set(this,{manager:e})}getId(e){return Vr(this,e).id}getPositionIndex(e){return Vr(this,e).config.positionIndex}getWorkspaceId(e){const t=Vr(this,e);return t.config.workspaceId||t.workspace.id}getFrameId(e){return Vr(this,e).frame.id}getAllChildren(e,t){_(t,!0);const r=Vr(this,e).children;return void 0===t?r:r.filter(t)}getMyParent(e){return e instanceof Pr?e:Vr(this,e).parent}getMyFrame(e){return Vr(this,e).frame}getMyWorkspace(e){return e instanceof Pr?e:Vr(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=q.runWithException(t),n=Vr(this,e).controller,i=await n.add("window",Vr(this,e).id,r,o);if(e instanceof Pr)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=Vr(this,e).controller,a=(await i.add("container",Vr(this,e).id,r,n)).itemId;if(e instanceof Pr)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){_(t);const r=this.getAllChildren(e).find(t);r&&(await r.close(),e instanceof Pr?await e.refreshReference():await this.getMyWorkspace(e).refreshReference())}async maximize(e){const{controller:t,id:r}=Vr(this,e);await t.maximizeItem(r),await this.getMyWorkspace(e.parent).refreshReference()}async restore(e){const{controller:t,id:r}=Vr(this,e);await t.restoreItem(r),await this.getMyWorkspace(e.parent).refreshReference()}async close(e){const t=Vr(this,e),r=Vr(this,e).controller;await r.closeItem(t.id),await this.getMyWorkspace(t.parent).refreshReference()}async lockContainer(e,t){const r=Vr(this,e),o=Vr(this,e).controller;await o.lockContainer(r.id,e.type,t),await this.getMyWorkspace(r.parent).refreshReference()}getAllowDrop(e){return Vr(this,e).config.allowDrop}getAllowDropLeft(e){const t=Vr(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=Vr(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=Vr(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=Vr(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=Vr(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=Vr(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=Vr(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=Vr(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=Vr(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=Vr(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=Vr(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 Vr(this,e).config.minWidth}getMaxWidth(e){return Vr(this,e).config.maxWidth}getMinHeight(e){return Vr(this,e).config.minHeight}getMaxHeight(e){return Vr(this,e).config.maxHeight}getWidthInPx(e){return Vr(this,e).config.widthInPx}getHeightInPx(e){return Vr(this,e).config.heightInPx}getIsPinned(e){return Vr(this,e).config.isPinned}getIsMaximized(e){return Vr(this,e).config.isMaximized}getMaximizationBoundary(e){return Vr(this,e).config.maximizationBoundary}async setHeight(e,t){const r=Vr(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=Vr(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=Vr(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=Vr(this,e),{controller:o,id:n}=r;await o.setMaximizationBoundary(n,t),await this.getMyWorkspace(r.parent).refreshReference()}async bundleTo(e,t){const r=Vr(this,e),{controller:o,id:n}=r;await o.bundleItemTo(t,n)}async processLocalSubscription(e,t){return Vr(this,e).controller.processLocalSubscription(t,this.getId(e))}transformDefinition(e,t){let r;return void 0===t?r={type:e,children:[]}:t instanceof kr?r=t.serialize():(void 0===t.type&&(t.type=e),r=te.runWithException(t),r.children=r.children||[]),r}}class Ur{ioc;windows;contexts;layouts;layoutsV2;constructor(e,t,r,o,n){this.ioc=e,this.windows=t,this.contexts=r,this.layouts=o,this.layoutsV2=n}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(pr.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(pr.createFrame.name,e)};return this.ioc.getModel("frame",t)}async initFrame(e,t){await this.bridge.send(pr.initFrame.name,{frameId:e,...t})}async restoreWorkspaceById(e){const t=await this.bridge.send(pr.openWorkspaceById.name,{...e}),r={summary:await this.bridge.send(pr.getFrameSummary.name,{itemId:t.config.frameId})},o={frame:this.ioc.getModel("frame",r),snapshot:t};return this.ioc.getModel("workspace",o)}async restoreWorkspace(e,t){const r=await this.bridge.send(pr.openWorkspace.name,{name:e,restoreOptions:t}),o={summary:await this.bridge.send(pr.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=pr.addWindow.name;else{if("container"!==e)throw new Error(`Unrecognized add type: ${e}`);n=pr.addContainer.name}return await this.bridge.send(n,i)}async getFrame(e){const t={summary:await this.bridge.send(pr.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))}async handleOnSaved(e){const t=t=>{"Workspace"===t.type&&e(t)};if(this.layoutsV2){const[e,r]=await Promise.all([this.layoutsV2.onAdded(t),this.layoutsV2.onChanged(t)]);return()=>{e(),r()}}const r=this.layouts.onAdded(t),o=this.layouts.onChanged(t);return()=>{r(),o()}}async handleOnRemoved(e){const t=t=>{"Workspace"===t.type&&e(t)};return this.layoutsV2?this.layoutsV2.onRemoved(t):this.layouts.onRemoved(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(pr.getWorkspaceSnapshot.name,{itemId:e.workspaceSummary.id})};return this.ioc.getModel("workspace",r)}async fetchWorkspace(e){const t=await this.bridge.send(pr.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(pr.bundleWorkspace.name,{type:e,workspaceId:t})}async bundleItemTo(e,t){if(!await this.isOperationSupported(pr.bundleItem.name))throw new Error(`Operation ${pr.bundleItem.name} is not supported. Ensure that you are running the latest version of all packages`);await this.bridge.send(pr.bundleItem.name,{type:e,itemId:t})}async getTaskbarIcon(e){return await this.bridge.send(pr.getTaskbarIcon.name,{frameId:e})}async setTaskbarIcon(e,t){await this.bridge.send(pr.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(pr.restoreItem.name,{itemId:e})}async maximizeItem(e){await this.bridge.send(pr.maximizeItem.name,{itemId:e})}async focusItem(e){await this.bridge.send(pr.focusItem.name,{itemId:e})}async closeWorkspace(e){await this.bridge.send(pr.closeWorkspace.name,{itemId:e})}async closeItem(e){await this.bridge.send(pr.closeItem.name,{itemId:e})}async closeFrame(e,t){await this.bridge.send(pr.closeItem.name,{itemId:e,closeOptions:t})}async resizeItem(e,t){await this.bridge.send(pr.resizeItem.name,Object.assign({},{itemId:e},t))}async setMaximizationBoundary(e,t){await this.bridge.send(pr.setMaximizationBoundary.name,Object.assign({},{itemId:e},t))}async showWorkspaceLoadingAnimation(e){await this.bridge.send(pr.showLoadingAnimation.name,{itemId:e,type:"workspace"})}async hideWorkspaceLoadingAnimation(e){await this.bridge.send(pr.hideLoadingAnimation.name,{itemId:e,type:"workspace"})}async setWindowDragMode(e,t){await this.bridge.send(pr.setWindowDragMode.name,{itemId:e,dragMode:t})}async moveFrame(e,t){await this.bridge.send(pr.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(pr.forceLoadWindow.name,{itemId:e})).windowId}async ejectWindow(e,t){return await this.bridge.send(pr.ejectWindow.name,{itemId:e,windowId:t})}async moveWindowTo(e,t){await this.bridge.send(pr.moveWindowTo.name,{itemId:e,containerId:t})}async getSnapshot(e,t){let r;return"workspace"===t?r=await this.bridge.send(pr.getWorkspaceSnapshot.name,{itemId:e}):"frame"===t&&(r=await this.bridge.send(pr.getFrameSnapshot.name,{itemId:e})),r}async setItemTitle(e,t){await this.bridge.send(pr.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 Pr||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(pr.hibernateWorkspace.name,{workspaceId:e})}async resumeWorkspace(e){await this.bridge.send(pr.resumeWorkspace.name,{workspaceId:e})}async lockWorkspace(e,t){await this.bridge.send(pr.lockWorkspace.name,{workspaceId:e,config:t})}async lockWindow(e,t){await this.bridge.send(pr.lockWindow.name,{windowPlacementId:e,config:t})}async lockContainer(e,t,r){await this.bridge.send(pr.lockContainer.name,{itemId:e,type:t,config:r})}async pinWorkspace(e,t){await this.bridge.send(pr.pinWorkspace.name,{workspaceId:e,icon:t})}async unpinWorkspace(e){await this.bridge.send(pr.unpinWorkspace.name,{workspaceId:e})}async getWorkspaceIcon(e){return(await this.bridge.send(pr.getWorkspaceIcon.name,{workspaceId:e})).icon}setWorkspaceIcon(e,t){return this.bridge.send(pr.setWorkspaceIcon.name,{workspaceId:e,icon:t})}async getPlatformFrameId(){try{return await this.bridge.send(pr.getPlatformFrameId.name,{})}catch(e){return{}}}async setLoadingStrategy(e,t){return await this.isOperationSupported(pr.setLoadingStrategy.name),this.bridge.send(pr.setLoadingStrategy.name,{itemId:e,strategy:t})}async showFrame(e,t){const r={frameId:e,isVisible:!0,...t};return this.bridge.send(pr.changeFrameVisibility.name,r)}async hideFrame(e){return this.bridge.send(pr.changeFrameVisibility.name,{frameId:e,isVisible:!1})}async getFrameVisibility(e){return(await this.bridge.send(pr.getFrameVisibility.name,{itemId:e})).isVisible}async showFrameDialog(e,t){return await this.bridge.send(pr.showFrameDialog.name,{frameId:e,options:t},{timeout:864e5})}async setFrameOnTop(e,t){return this.bridge.send(pr.setFrameOnTop.name,{frameId:e,onTop:t.onTop})}async isOperationSupported(e){return gr()?{isSupported:!0}:await this.bridge.send(pr.operationCheck.name,{operation:e})}async showPopup(e,t){return this.bridge.send(pr.showPopup.name,{...e,frameId:t})}}class Kr{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(pr.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 restoreWorkspaceById(e){if(!(await this.getLayoutSummaries()).some(t=>t.id===e.layoutId))throw new Error(`This layout: ${e.layoutId} cannot be restored, because it doesn't exist.`);if(e?.frameId){if(!(await this.bridge.send(pr.getAllFramesSummaries.name)).summaries.some(t=>t.id===e.frameId))throw new Error(`Cannot reuse the frame with id: ${e.frameId}, because there is no frame with that ID found`)}return await this.base.restoreWorkspaceById(e)}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(pr.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 gr()?this.handleEnterpriseLocalSubscription(e,t):this.handleCoreLocalSubscription(e,t)}processGlobalSubscription(e,t,r){return gr()?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(pr.getAllFramesSummaries.name);return this.base.getFrames(t.summaries,e)}getWorkspaceById(e){return this.base.fetchWorkspace(e)}async getWorkspaceByWindowId(e){return gr()?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 isLastWorkspaceInFrame(e,t){const r=(await this.getAllWorkspaceSummaries()).filter(e=>e.frameId===t);return 1===r.length&&r[0].id===e}async getAllWorkspaceSummaries(){const e=await this.bridge.send(pr.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(pr.getAllLayoutsSummaries.name)).summaries}async deleteLayout(e){await this.bridge.send(pr.deleteLayout.name,{name:e})}async deleteLayoutById(e){await this.bridge.send(pr.deleteLayoutById.name,{layoutId:e})}async exportLayout(e){return(await this.bridge.send(pr.exportAllLayouts.name)).layouts.reduce((t,r)=>(e&&!e(r)||t.push(r),t),[])}async saveLayout(e){return await this.bridge.send(pr.saveLayout.name,e)}async saveLayoutById(e){return await this.bridge.send(pr.saveLayoutById.name,e)}async importLayouts(e,t){if(gr())try{await this.bridge.send(pr.importLayouts.name,{layouts:e,mode:t})}catch(r){await Promise.all(e.map(e=>this.bridge.send(pr.importLayout.name,{layout:e,mode:t})))}else await this.base.importLayouts(e,t)}async handleOnSaved(e){return this.base.handleOnSaved(e)}async 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(pr.changeFrameState.name,{frameId:e,requestedState:t})}async getFrameBounds(e){return(await this.bridge.send(pr.getFrameBounds.name,{itemId:e})).bounds}async getFrameState(e){return(await this.bridge.send(pr.getFrameState.name,{itemId:e})).state}async closeWorkspace(e,t){if(gr())return await this.closeItem(e);let r=!1;try{const{isSupported:e}=await this.base.isOperationSupported(pr.closeWorkspace.name);r=e}catch(e){r=!1}return r?await this.base.closeWorkspace(e):await this.legacyCloseWorkspace(e,t)}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,t){const r=(await this.base.ejectWindow(e,t)).windowId;return await this.base.notifyWindowAdded(r),r}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)}showPopup(e,t){return this.base.showPopup(e,t)}async showFrame(e,t){return this.base.showFrame(e,t)}async hideFrame(e){return this.base.hideFrame(e)}async getFrameVisibility(e){return this.base.getFrameVisibility(e)}async showFrameDialog(e,t){return this.base.showFrameDialog(e,t)}async setFrameOnTop(e,t){return this.base.setFrameOnTop(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)}}async legacyCloseWorkspace(e,t){const r=await this.isLastWorkspaceInFrame(e,t),o=(await this.getPlatformFrameId()).id;if(r&&o!==t)return await this.closeFrame(t,{});await this.closeItem(e)}}class qr{bridge;_shortcuts=r();constructor(e){this.bridge=e,this.bridge.onOperation(e=>{if(e.operation===ur.shortcutClicked.name){const t=e.data;this._shortcuts.execute(`${t.frameId}-${t.shortcut}`)}})}async registerShortcut(e,t,r){await this.bridge.send(pr.registerShortcut.name,{shortcut:e,frameId:t});const o=this._shortcuts.add(`${t}-${e}`,r);return()=>{o(),this.bridge.send(pr.unregisterShortcut.name,{shortcut:e,frameId:t})}}}class Qr{bridge;registry=r();constructor(e){this.bridge=e,this.subscribeToFrameClosing()}async registerFrameOnClosing(e,t){return await this.bridge.send(pr.subscribeToFrameClosing.name,{itemId:e}),this.registry.add(e,t)}subscribeToFrameClosing(){this.bridge.onOperationWithResponse(async e=>{if(e.operation!==ur.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 Xr{agm;windows;layouts;contexts;layoutsV2;_controllerInstance;_bridgeInstance;_transportInstance;_privateDataManagerInstance;_parentBaseInstance;_baseController;_shortcutsController;_closingController;constructor(e,t,r,o,n){this.agm=e,this.windows=t,this.layouts=r,this.contexts=o,this.layoutsV2=n}get baseController(){return this._baseController||(this._baseController=new Ur(this,this.windows,this.contexts,this.layouts,this.layoutsV2)),this._baseController}get controller(){return this._controllerInstance||(this._controllerInstance=new Kr(this.bridge,this.baseController,this.shortcutsController,this.closingController)),this._controllerInstance}get shortcutsController(){return this._shortcutsController||(this._shortcutsController=new qr(this.bridge)),this._shortcutsController}get closingController(){return this._closingController||(this._closingController=new Qr(this.bridge)),this._closingController}get bridge(){return this._bridgeInstance||(this._bridgeInstance=new mr(this.transport,r())),this._bridgeInstance}get transport(){return this._transportInstance||(this._transportInstance=new yr(this.agm,r())),this._transportInstance}get privateDataManager(){return this._privateDataManagerInstance||(this._privateDataManagerInstance=new Gr),this._privateDataManagerInstance}get parentBase(){return this._parentBaseInstance||(this._parentBaseInstance=new Jr(this.privateDataManager)),this._parentBaseInstance}async initiate(e){await this.transport.initiate(e)}getModel(e,t){switch(e){case"frame":{const e=new jr(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 Er(this.parentBase):"row"===e?new vr(this.parentBase):new Fr(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 Pr(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 Ir(this.getBuilder.bind(this));switch(e.type){case"workspace":return new Sr(e.definition,t,this.controller);case"row":case"column":case"group":return e.definition.type=e.type,new kr(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 Yr=async e=>{const t=new Xr(e.agm,e.windows,e.layouts,e.contexts,e.layouts.v2),r=e.interop.instance.windowId;await t.initiate(r),e.workspaces=((e,t)=>{const r=t.controller,o=async e=>(_(e,!0),r.getFrames(e)),n=async e=>(_(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=me.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=>(_(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=>(_(e),(await r.getWorkspaces(e))[0]),getWorkspaceById:async e=>(v.runWithException(e),r.getWorkspaceById(e)),getAllWorkspaces:e=>(_(e,!0),r.getWorkspaces(e)),getWindow:async e=>(_(e),r.getWindow(e)),getBox:async e=>(_(e),r.getParent(e)),restoreWorkspace:async(e,t)=>{v.runWithException(e);const o=ne.runWithException(t);return r.restoreWorkspace(e,o)},restoreWorkspaceById:async e=>{const t=ie.runWithException(e);return r.restoreWorkspaceById(t)},createWorkspace:async(e,t)=>{const o=ce.runWithException(e),n=j.runWithException(t);return r.createWorkspace(o,n)},createEmptyFrame:async e=>{const t=ue.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)),deleteById:async e=>(v.runWithException(e),r.deleteLayoutById(e)),export:async e=>(_(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=>Ae.runWithException(e)),r.importLayouts(e,t)},save:async e=>{const t=St.runWithException(e);return r.saveLayout(t)},saveById:async e=>{const t=xt.runWithException(e);return r.saveLayoutById(t)},onSaved:async e=>(_(e),r.handleOnSaved(e)),onRemoved:async e=>(_(e),r.handleOnRemoved(e))},onFrameOpened:n,onFrameClosed:async e=>(_(e),await r.processGlobalSubscription(t=>{e({frameId:t.frameSummary.id,frameBounds:t.frameBounds})},"frame","closed")),onWorkspaceOpened:async e=>(_(e),await r.processGlobalSubscription(async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)},"workspace","opened")),onWorkspaceClosed:async e=>(_(e),await r.processGlobalSubscription(t=>{e({frameId:t.frameSummary.id,workspaceId:t.workspaceSummary.id,frameBounds:t.frameBounds})},"workspace","closed")),onWorkspaceHibernated:async e=>(_(e),await r.processGlobalSubscription(async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)},"workspace","hibernated")),onWorkspaceResumed:async e=>(_(e),await r.processGlobalSubscription(async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)},"workspace","resumed")),onWorkspaceTabReordered:async e=>(_(e),await r.processGlobalSubscription(async t=>{const o=await r.transformStreamPayloadToWorkspace(t);e(o)},"workspace","tab-reordered")),onWindowTabReordered:async e=>(_(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","tab-reordered")),onWindowAdded:async e=>(_(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=>(_(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=>(_(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=>(_(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=>(_(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=>(_(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:"5.0.0"}})(e,t)};return"undefined"!=typeof window&&(window.IOWorkspaces=Yr),Yr});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@interopio/workspaces-api",
3
- "version": "5.0.0-next.0",
3
+ "version": "5.0.0",
4
4
  "description": "IOConnect Workspaces API",
5
5
  "main": "dist/workspaces.umd.js",
6
6
  "module": "dist/workspaces.es.js",