UNPKG

@interopio/browser

Version:

IOConnect Browser client application package

1 lines 344 kB
!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).browser=e.browser||{},e.browser.min=t())}(this,function(){"use strict";function e(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===n}(e)}(e)};var n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function i(e,t){return!1!==t.clone&&t.isMergeableObject(e)?c((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function r(e,t,n){return e.concat(t).map(function(e){return i(e,n)})}function s(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}(e))}function o(e,t){try{return t in e}catch(e){return!1}}function a(e,t,n){var r={};return n.isMergeableObject(e)&&s(e).forEach(function(t){r[t]=i(e[t],n)}),s(t).forEach(function(s){(function(e,t){return o(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,s)||(o(e,s)&&n.isMergeableObject(t[s])?r[s]=function(e,t){if(!t.customMerge)return c;var n=t.customMerge(e);return"function"==typeof n?n:c}(s,n)(e[s],t[s],n):r[s]=i(t[s],n))}),r}function c(e,n,s){(s=s||{}).arrayMerge=s.arrayMerge||r,s.isMergeableObject=s.isMergeableObject||t,s.cloneUnlessOtherwiseSpecified=i;var o=Array.isArray(n);return o===Array.isArray(e)?o?s.arrayMerge(e,n,s):a(e,n,s):i(n,s)}c.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,n){return c(e,n,t)},{})};var d=e(c),l=function(e){return{ok:!0,result:e}},h=function(e){return{ok:!1,error:e}},u=function(e,t,n){return!1===t.ok?t:!1===n.ok?n:l(e(t.result,n.result))},p=function(e,t){return!0===t.ok?t:h(e(t.error))},g=function(){return g=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},g.apply(this,arguments)};function f(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 n=0;n<e.length;n++)if(!f(e[n],t[n]))return!1;return!0}var i=Object.keys(e);if(i.length!==Object.keys(t).length)return!1;for(n=0;n<i.length;n++){if(!t.hasOwnProperty(i[n]))return!1;if(!f(e[i[n]],t[i[n]]))return!1}return!0}}var m=function(e){return Array.isArray(e)},b=function(e){return"object"==typeof e&&null!==e&&!m(e)},y=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)},w=function(e){return e.map(function(e){return"string"==typeof e?"."+e:"["+e+"]"}).join("")},v=function(e,t){var n=t.at,i=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["at"]);return g({at:e+(n||"")},i)},C=function(){function e(t){var n=this;this.decode=t,this.run=function(e){return p(function(t){return{kind:"DecoderError",input:e,at:"input"+(t.at||""),message:t.message||""}},n.decode(e))},this.runPromise=function(e){return!0===(t=n.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}(n.run(e))},this.map=function(t){return new e(function(e){return function(e,t){return!0===t.ok?l(e(t.result)):t}(t,n.decode(e))})},this.andThen=function(t){return new e(function(e){return function(e,t){return!0===t.ok?e(t.result):t}(function(n){return t(n).decode(e)},n.decode(e))})},this.where=function(t,i){return n.andThen(function(n){return t(n)?e.succeed(n):e.fail(i)})}}return e.string=function(){return new e(function(e){return"string"==typeof e?l(e):h({message:y("a string",e)})})},e.number=function(){return new e(function(e){return"number"==typeof e?l(e):h({message:y("a number",e)})})},e.boolean=function(){return new e(function(e){return"boolean"==typeof e?l(e):h({message:y("a boolean",e)})})},e.constant=function(t){return new e(function(e){return f(e,t)?l(t):h({message:"expected "+JSON.stringify(t)+", got "+JSON.stringify(e)})})},e.object=function(t){return new e(function(e){if(b(e)&&t){var n={};for(var i in t)if(t.hasOwnProperty(i)){var r=t[i].decode(e[i]);if(!0!==r.ok)return void 0===e[i]?h({message:"the key '"+i+"' is required but was not present"}):h(v("."+i,r.error));void 0!==r.result&&(n[i]=r.result)}return l(n)}return b(e)?l(e):h({message:y("an object",e)})})},e.array=function(t){return new e(function(e){if(m(e)&&t){return e.reduce(function(e,n,i){return u(function(e,t){return e.concat([t])},e,function(e,n){return p(function(e){return v("["+n+"]",e)},t.decode(e))}(n,i))},l([]))}return m(e)?l(e):h({message:y("an array",e)})})},e.tuple=function(t){return new e(function(e){if(m(e)){if(e.length!==t.length)return h({message:"expected a tuple of length "+t.length+", got one of length "+e.length});for(var n=[],i=0;i<t.length;i++){var r=t[i].decode(e[i]);if(!r.ok)return h(v("["+i+"]",r.error));n[i]=r.result}return l(n)}return h({message:y("a tuple of length "+t.length,e)})})},e.union=function(t,n){for(var i=[],r=2;r<arguments.length;r++)i[r-2]=arguments[r];return e.oneOf.apply(e,[t,n].concat(i))},e.intersection=function(t,n){for(var i=[],r=2;r<arguments.length;r++)i[r-2]=arguments[r];return new e(function(e){return[t,n].concat(i).reduce(function(t,n){return u(Object.assign,t,n.decode(e))},l({}))})},e.anyJson=function(){return new e(function(e){return l(e)})},e.unknownJson=function(){return new e(function(e){return l(e)})},e.dict=function(t){return new e(function(e){if(b(e)){var n={};for(var i in e)if(e.hasOwnProperty(i)){var r=t.decode(e[i]);if(!0!==r.ok)return h(v("."+i,r.error));n[i]=r.result}return l(n)}return h({message:y("an object",e)})})},e.optional=function(t){return new e(function(e){return null==e?l(void 0):t.decode(e)})},e.oneOf=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return new e(function(e){for(var n=[],i=0;i<t.length;i++){var r=t[i].decode(e);if(!0===r.ok)return r;n[i]=r.error}var s=n.map(function(e){return"at error"+(e.at||"")+": "+e.message}).join('", "');return h({message:'expected a value matching one of the decoders, got the errors ["'+s+'"]'})})},e.withDefault=function(t,n){return new e(function(e){return l(function(e,t){return!0===t.ok?t.result:e}(t,n.decode(e)))})},e.valueAt=function(t,n){return new e(function(e){for(var i=e,r=0;r<t.length;r++){if(void 0===i)return h({at:w(t.slice(0,r+1)),message:"path does not exist"});if("string"==typeof t[r]&&!b(i))return h({at:w(t.slice(0,r+1)),message:y("an object",i)});if("number"==typeof t[r]&&!m(i))return h({at:w(t.slice(0,r+1)),message:y("an array",i)});i=i[t[r]]}return p(function(e){return void 0===i?{at:w(t),message:"path does not exist"}:v(w(t),e)},n.decode(i))})},e.succeed=function(t){return new e(function(e){return l(t)})},e.fail=function(t){return new e(function(e){return h({message:t})})},e.lazy=function(t){return new e(function(e){return t().decode(e)})},e}(),I=C.string,S=C.number,_=C.boolean,x=C.anyJson;C.unknownJson;var T=C.constant,k=C.object,P=C.array;C.tuple,C.dict;var O=C.optional,R=C.oneOf,A=C.union,M=C.intersection;C.withDefault,C.valueAt,C.succeed,C.fail;var E=C.lazy;const D={gateway:{webPlatform:{}},libraries:[],exposeAPI:!0},j={awaitFactory:!0,enable:!1,timeout:5e3,restoreLastKnownPosition:!0},N={alerts:{enabled:!1},dialogs:{enabled:!1},awaitFactory:!0,timeout:5e3},F={enable:!1,timeout:5e3,awaitFactory:!0},L={name:"platformUnload"},$={name:"transportSwitchRequest"},W={name:"transportSwitchResponse"},H={name:"getCurrentTransport"},U={name:"getCurrentTransportResponse"},q={name:"checkPreferredLogic"},B={name:"checkPreferredConnection"},G={name:"checkPreferredLogicResponse"},J={name:"checkPreferredConnectionResponse"},z="web-platform",V="latest_fdc3_type",K=new MessageChannel,Z=2147483647,Q={configurable:!1,enumerable:!0,writable:!1},Y=e=>"string"==typeof e?e:e?.message?"string"==typeof e.message?e.message:JSON.stringify(e.message):JSON.stringify(e),X=(e,t)=>{try{return e.runWithException(t)}catch(e){return re.raiseError(e,!0)}},ee=e=>Object.keys(e).filter(t=>e[t].execute),te=(e,t)=>({isSupported:e.some(e=>e.toLowerCase()===t.toLowerCase())}),ne=e=>Math.min(e,Z),ie=()=>{let e,t;return{promise:new Promise((n,i)=>{e=n,t=i}),resolve:e,reject:t}};const re=new class{raiseError(e,t){const n=Y(e);if(K.port1.postMessage(n),t)throw e;throw new Error(n)}},se=["name","title","version","customProperties","icon","caption","type"],oe=["appId","name","type","details","version","title","tooltip","lang","description","categories","icons","screenshots","contactEmail","moreInfo","publisher","customConfig","hostManifests","interop","localizedVersions"];var ae=function(e){return{ok:!0,result:e}},ce=function(e){return{ok:!1,error:e}},de=function(e,t,n){return!1===t.ok?t:!1===n.ok?n:ae(e(t.result,n.result))},le=function(e,t){return!0===t.ok?t:ce(e(t.error))},he=function(){return he=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e},he.apply(this,arguments)};function ue(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 n=0;n<e.length;n++)if(!ue(e[n],t[n]))return!1;return!0}var i=Object.keys(e);if(i.length!==Object.keys(t).length)return!1;for(n=0;n<i.length;n++){if(!t.hasOwnProperty(i[n]))return!1;if(!ue(e[i[n]],t[i[n]]))return!1}return!0}}var pe=function(e){return Array.isArray(e)},ge=function(e){return"object"==typeof e&&null!==e&&!pe(e)},fe=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)},me=function(e){return e.map(function(e){return"string"==typeof e?"."+e:"["+e+"]"}).join("")},be=function(e,t){var n=t.at,i=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["at"]);return he({at:e+(n||"")},i)},ye=function(){function e(t){var n=this;this.decode=t,this.run=function(e){return le(function(t){return{kind:"DecoderError",input:e,at:"input"+(t.at||""),message:t.message||""}},n.decode(e))},this.runPromise=function(e){return!0===(t=n.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}(n.run(e))},this.map=function(t){return new e(function(e){return function(e,t){return!0===t.ok?ae(e(t.result)):t}(t,n.decode(e))})},this.andThen=function(t){return new e(function(e){return function(e,t){return!0===t.ok?e(t.result):t}(function(n){return t(n).decode(e)},n.decode(e))})},this.where=function(t,i){return n.andThen(function(n){return t(n)?e.succeed(n):e.fail(i)})}}return e.string=function(){return new e(function(e){return"string"==typeof e?ae(e):ce({message:fe("a string",e)})})},e.number=function(){return new e(function(e){return"number"==typeof e?ae(e):ce({message:fe("a number",e)})})},e.boolean=function(){return new e(function(e){return"boolean"==typeof e?ae(e):ce({message:fe("a boolean",e)})})},e.constant=function(t){return new e(function(e){return ue(e,t)?ae(t):ce({message:"expected "+JSON.stringify(t)+", got "+JSON.stringify(e)})})},e.object=function(t){return new e(function(e){if(ge(e)&&t){var n={};for(var i in t)if(t.hasOwnProperty(i)){var r=t[i].decode(e[i]);if(!0!==r.ok)return void 0===e[i]?ce({message:"the key '"+i+"' is required but was not present"}):ce(be("."+i,r.error));void 0!==r.result&&(n[i]=r.result)}return ae(n)}return ge(e)?ae(e):ce({message:fe("an object",e)})})},e.array=function(t){return new e(function(e){if(pe(e)&&t){return e.reduce(function(e,n,i){return de(function(e,t){return e.concat([t])},e,function(e,n){return le(function(e){return be("["+n+"]",e)},t.decode(e))}(n,i))},ae([]))}return pe(e)?ae(e):ce({message:fe("an array",e)})})},e.tuple=function(t){return new e(function(e){if(pe(e)){if(e.length!==t.length)return ce({message:"expected a tuple of length "+t.length+", got one of length "+e.length});for(var n=[],i=0;i<t.length;i++){var r=t[i].decode(e[i]);if(!r.ok)return ce(be("["+i+"]",r.error));n[i]=r.result}return ae(n)}return ce({message:fe("a tuple of length "+t.length,e)})})},e.union=function(t,n){for(var i=[],r=2;r<arguments.length;r++)i[r-2]=arguments[r];return e.oneOf.apply(e,[t,n].concat(i))},e.intersection=function(t,n){for(var i=[],r=2;r<arguments.length;r++)i[r-2]=arguments[r];return new e(function(e){return[t,n].concat(i).reduce(function(t,n){return de(Object.assign,t,n.decode(e))},ae({}))})},e.anyJson=function(){return new e(function(e){return ae(e)})},e.unknownJson=function(){return new e(function(e){return ae(e)})},e.dict=function(t){return new e(function(e){if(ge(e)){var n={};for(var i in e)if(e.hasOwnProperty(i)){var r=t.decode(e[i]);if(!0!==r.ok)return ce(be("."+i,r.error));n[i]=r.result}return ae(n)}return ce({message:fe("an object",e)})})},e.optional=function(t){return new e(function(e){return null==e?ae(void 0):t.decode(e)})},e.oneOf=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return new e(function(e){for(var n=[],i=0;i<t.length;i++){var r=t[i].decode(e);if(!0===r.ok)return r;n[i]=r.error}var s=n.map(function(e){return"at error"+(e.at||"")+": "+e.message}).join('", "');return ce({message:'expected a value matching one of the decoders, got the errors ["'+s+'"]'})})},e.withDefault=function(t,n){return new e(function(e){return ae(function(e,t){return!0===t.ok?t.result:e}(t,n.decode(e)))})},e.valueAt=function(t,n){return new e(function(e){for(var i=e,r=0;r<t.length;r++){if(void 0===i)return ce({at:me(t.slice(0,r+1)),message:"path does not exist"});if("string"==typeof t[r]&&!ge(i))return ce({at:me(t.slice(0,r+1)),message:fe("an object",i)});if("number"==typeof t[r]&&!pe(i))return ce({at:me(t.slice(0,r+1)),message:fe("an array",i)});i=i[t[r]]}return le(function(e){return void 0===i?{at:me(t),message:"path does not exist"}:be(me(t),e)},n.decode(i))})},e.succeed=function(t){return new e(function(e){return ae(t)})},e.fail=function(t){return new e(function(e){return ce({message:t})})},e.lazy=function(t){return new e(function(e){return t().decode(e)})},e}(),we=ye.string,ve=ye.number,Ce=ye.boolean,Ie=ye.anyJson;ye.unknownJson;var Se=ye.constant,_e=ye.object,xe=ye.array;ye.tuple;var Te=ye.dict,ke=ye.optional,Pe=ye.oneOf;ye.union,ye.intersection,ye.withDefault,ye.valueAt,ye.succeed,ye.fail,ye.lazy;const Oe=we().where(e=>e.length>0,"Expected a non-empty string"),Re=ve().where(e=>e>=0,"Expected a non-negative number"),Ae=Ie().andThen(e=>e instanceof RegExp?Ie():fail("expected a regex, got a "+typeof e)),Me=Oe.andThen(e=>{try{return new URL(e),Oe}catch{return fail("Should be a valid URL")}}),Ee=_e({name:Oe,displayName:ke(we()),contexts:ke(xe(we())),customConfig:ke(_e())}),De=Pe(Se("web"),Se("native"),Se("citrix"),Se("onlineNative"),Se("other")),je=_e({url:Oe}),Ne=_e({src:Oe,size:ke(Oe),type:ke(Oe)}),Fe=_e({src:Oe,size:ke(Oe),type:ke(Oe),label:ke(Oe)}),Le=_e({contexts:xe(Oe),displayName:ke(Oe),resultType:ke(Oe),customConfig:ke(Ie())}),$e=_e({listensFor:ke(Te(Le)),raises:ke(Te(xe(Oe)))}),We=_e({broadcasts:ke(xe(Oe)),listensFor:ke(xe(Oe))}),He=_e({name:Oe,description:ke(Oe),broadcasts:ke(xe(Oe)),listensFor:ke(xe(Oe))}),Ue=_e({intents:ke($e),userChannels:ke(We),appChannels:ke(xe(He))}),qe=_e({url:ke(Oe),top:ke(ve()),left:ke(ve()),width:ke(Re),height:ke(Re)}),Be=_e({name:ke(Oe),type:ke(Oe.where(e=>"window"===e,"Expected a value of window")),title:ke(Oe),version:ke(Oe),customProperties:ke(Ie()),icon:ke(we()),caption:ke(we()),details:ke(qe),intents:ke(xe(Ee)),hidden:ke(Ce())}),Ge=_e({name:Oe,appId:Oe,title:ke(Oe),version:ke(Oe),manifest:Oe,manifestType:Oe,tooltip:ke(Oe),description:ke(Oe),contactEmail:ke(Oe),supportEmail:ke(Oe),publisher:ke(Oe),images:ke(xe(_e({url:ke(Oe)}))),icons:ke(xe(_e({icon:ke(Oe)}))),customConfig:Ie(),intents:ke(xe(Ee))}),Je=_e({appId:ke(Oe),name:ke(Oe),details:ke(je),version:ke(Oe),title:ke(Oe),tooltip:ke(Oe),lang:ke(Oe),description:ke(Oe),categories:ke(xe(Oe)),icons:ke(xe(Ne)),screenshots:ke(xe(Fe)),contactEmail:ke(Oe),supportEmail:ke(Oe),moreInfo:ke(Oe),publisher:ke(Oe),customConfig:ke(xe(Ie())),hostManifests:ke(Ie()),interop:ke(Ue)}),ze=_e({appId:Oe,name:ke(Oe),type:De,details:je,version:ke(Oe),title:ke(Oe),tooltip:ke(Oe),lang:ke(Oe),description:ke(Oe),categories:ke(xe(Oe)),icons:ke(xe(Ne)),screenshots:ke(xe(Fe)),contactEmail:ke(Oe),supportEmail:ke(Oe),moreInfo:ke(Oe),publisher:ke(Oe),customConfig:ke(xe(Ie())),hostManifests:ke(Ie()),interop:ke(Ue),localizedVersions:ke(Te(Je))}),Ve=Pe(Ge,ze),Ke=e=>`${e.kind} at ${e.at}: ${JSON.stringify(e.input)}. Reason - ${e.message}`;class Ze{fdc3ToDesktopDefinitionType={web:"window",native:"exe",citrix:"citrix",onlineNative:"clickonce",other:"window"};toApi(){return{isFdc3Definition:this.isFdc3Definition.bind(this),parseToBrowserBaseAppData:this.parseToBrowserBaseAppData.bind(this),parseToDesktopAppConfig:this.parseToDesktopAppConfig.bind(this)}}isFdc3Definition(e){const t=Ve.run(e);return t.ok?e.appId&&e.details?{isFdc3:!0,version:"2.0"}:e.manifest?{isFdc3:!0,version:"1.2"}:{isFdc3:!1,reason:"The passed definition is not FDC3"}:{isFdc3:!1,reason:Ke(t.error)}}parseToBrowserBaseAppData(e){const{isFdc3:t,version:n}=this.isFdc3Definition(e);if(!t)throw new Error("The passed definition is not FDC3");const i=Ve.run(e);if(!i.ok)throw new Error(`Invalid FDC3 ${n} definition. Error: ${Ke(i.error)}`);const r=this.getUserPropertiesFromDefinition(e,n),s={url:this.getUrl(e,n)},o={name:e.appId,type:"window",createOptions:s,userProperties:{...r,intents:"1.2"===n?r.intents:this.getIntentsFromV2AppDefinition(e),details:s},title:e.title,version:e.version,icon:this.getIconFromDefinition(e,n),caption:e.description,fdc3:"2.0"===n?{...e,definitionVersion:"2.0"}:void 0},a=e.hostManifests?.ioConnect||e.hostManifests?.Glue42;if(!a)return o;const c=Be.run(a);if(!c.ok)throw new Error(`Invalid FDC3 ${n} definition. Error: ${Ke(c.error)}`);return Object.keys(c.result).length?this.mergeBaseAppDataWithGlueManifest(o,c.result):o}parseToDesktopAppConfig(e){const{isFdc3:t,version:n}=this.isFdc3Definition(e);if(!t)throw new Error("The passed definition is not FDC3");const i=Ve.run(e);if(!i.ok)throw new Error(`Invalid FDC3 ${n} definition. Error: ${Ke(i.error)}`);if("1.2"===n){const t=e;return{name:t.appId,type:"window",details:{url:this.getUrl(e,n)},version:t.version,title:t.title,tooltip:t.tooltip,caption:t.description,icon:t.icons?.[0].icon,intents:t.intents,customProperties:{manifestType:t.manifestType,images:t.images,contactEmail:t.contactEmail,supportEmail:t.supportEmail,publisher:t.publisher,icons:t.icons,customConfig:t.customConfig}}}const r=e,s={name:r.appId,type:this.fdc3ToDesktopDefinitionType[r.type],details:r.details,version:r.version,title:r.title,tooltip:r.tooltip,caption:r.description,icon:this.getIconFromDefinition(r,"2.0"),intents:this.getIntentsFromV2AppDefinition(r),fdc3:{...r,definitionVersion:"2.0"}},o=e.hostManifests?.ioConnect||e.hostManifests?.Glue42;if(!o)return s;if("object"!=typeof o||Array.isArray(o))throw new Error(`Invalid '${e.hostManifests.ioConnect?"hostManifests.ioConnect":"hostManifests['Glue42']"}' key`);return this.mergeDesktopConfigWithGlueManifest(s,o)}getUserPropertiesFromDefinition(e,t){return"1.2"===t?Object.fromEntries(Object.entries(e).filter(([e])=>!se.includes(e))):Object.fromEntries(Object.entries(e).filter(([e])=>!se.includes(e)&&!oe.includes(e)))}getUrl(e,t){let n;if("1.2"===t){const t=JSON.parse(e.manifest);n=t.details?.url||t.url}else n=e.details?.url;if(!n||"string"!=typeof n)throw new Error(`Invalid FDC3 ${t} definition. Provide valid 'url' under '${"1.2"===t?"manifest":"details"}' key`);return n}getIntentsFromV2AppDefinition(e){const t=e.interop?.intents?.listensFor;if(!t)return;return Object.entries(t).map(e=>{const[t,n]=e;return{name:t,...n}})}getIconFromDefinition(e,t){return"1.2"===t?e.icons?.find(e=>e.icon)?.icon||void 0:e.icons?.find(e=>e.src)?.src||void 0}mergeBaseAppDataWithGlueManifest(e,t){let n=e;if(t.customProperties&&(n.userProperties={...e.userProperties,...t.customProperties}),t.details){const i={...e.createOptions,...t.details};n.createOptions=i,n.userProperties.details=i}return Array.isArray(t.intents)&&(n.userProperties.intents=(n.userProperties.intents||[]).concat(t.intents)),n={...n,...t},delete n.details,delete n.intents,n}mergeDesktopConfigWithGlueManifest(e,t){const n=Object.assign({},e,t,{details:{...e.details,...t.details}});return Array.isArray(t.intents)&&(n.intents=(e.intents||[]).concat(t.intents)),n}}const Qe={common:{nonEmptyStringDecoder:Oe,nonNegativeNumberDecoder:Re,regexDecoder:Ae,urlDecoder:Me},fdc3:{allDefinitionsDecoder:Ve,v1DefinitionDecoder:Ge,v2DefinitionDecoder:ze}};var Ye;!function(e){e.USER_CANCELLED="User Closed Intents Resolver UI without choosing a handler",e.CALLER_NOT_DEFINED="Caller Id is not defined",e.TIMEOUT_HIT="Timeout hit",e.INTENT_NOT_FOUND="Cannot find Intent",e.HANDLER_NOT_FOUND="Cannot find Intent Handler",e.TARGET_INSTANCE_UNAVAILABLE="Cannot start Target Instance",e.INTENT_DELIVERY_FAILED="Target Instance did not add a listener",e.RESOLVER_UNAVAILABLE="Intents Resolver UI unavailable",e.RESOLVER_TIMEOUT="User did not choose a handler",e.INVALID_RESOLVER_RESPONSE="Intents Resolver UI returned invalid response",e.INTENT_HANDLER_REJECTION="Intent Handler function processing the raised intent threw an error or rejected the promise it returned"}(Ye||(Ye={}));const Xe=new class{_fdc3;_decoders=Qe;_errors={intents:Ye};get fdc3(){return this._fdc3||(this._fdc3=(new Ze).toApi()),this._fdc3}get decoders(){return this._decoders}get errors(){return this._errors}};Xe.fdc3;const et=Xe.decoders;Xe.errors;const tt=I().where(e=>e.length>0,"Expected a non-empty string"),nt=S().where(e=>e>=0,"Expected a non-negative number"),it=O(tt),rt=R(T("system"),T("windows"),T("appManager"),T("layouts"),T("intents"),T("notifications"),T("channels"),T("extension"),T("themes"),T("prefs"),T("ui")),st=R(T("openWindow"),T("windowHello"),T("windowAdded"),T("windowRemoved"),T("getBounds"),T("getFrameBounds"),T("getUrl"),T("moveResize"),T("focus"),T("close"),T("getTitle"),T("setTitle"),T("focusChange"),T("getChannel"),T("notifyChannelsChanged"),T("setZoomFactor"),T("zoomFactorChange"),T("refresh"),T("operationCheck")),ot=R(T("appHello"),T("appDirectoryStateChange"),T("instanceStarted"),T("instanceStopped"),T("applicationStart"),T("instanceStop"),T("clear"),T("operationCheck")),at=R(T("layoutAdded"),T("layoutChanged"),T("layoutRemoved"),T("layoutRenamed"),T("get"),T("getAll"),T("export"),T("import"),T("remove"),T("rename"),T("clientSaveRequest"),T("getGlobalPermissionState"),T("checkGlobalActivated"),T("requestGlobalPermission"),T("getDefaultGlobal"),T("setDefaultGlobal"),T("clearDefaultGlobal"),T("updateMetadata"),T("operationCheck"),T("getCurrent"),T("defaultLayoutChanged"),T("layoutRestored")),ct=R(T("raiseNotification"),T("requestPermission"),T("notificationShow"),T("notificationClick"),T("getPermission"),T("list"),T("notificationRaised"),T("notificationClosed"),T("click"),T("clear"),T("clearAll"),T("configure"),T("getConfiguration"),T("configurationChanged"),T("setState"),T("clearOld"),T("activeCountChange"),T("stateChange"),T("operationCheck"),T("getActiveCount")),dt=R(T("getEnvironment"),T("getBase"),T("platformShutdown"),T("isFdc3DataWrappingSupported"),T("clientError"),T("systemHello"),T("operationCheck")),lt=R(T("top"),T("left"),T("right"),T("bottom")),ht=k({top:S(),left:S(),width:nt,height:nt}),ut=O(k({top:O(S()),left:O(S()),width:O(nt),height:O(nt),context:O(x()),relativeTo:O(tt),relativeDirection:O(lt),windowId:O(tt),layoutComponentId:O(tt)})),pt=k({name:tt,url:tt,options:ut}),gt=k({windowId:O(tt)}),ft=k({windowId:tt,name:tt}),mt=k({windowId:tt}),bt=k({windows:P(ft),isWorkspaceFrame:_()}),yt=k({windowId:tt,title:I()}),wt=k({windowId:tt,hasFocus:_()}),vt=k({windowId:tt,top:O(S()),left:O(S()),width:O(nt),height:O(nt),relative:O(_())}),Ct=k({windowId:tt,bounds:k({top:S(),left:S(),width:nt,height:nt})}),It=k({bounds:k({top:S(),left:S(),width:nt,height:nt})}),St=k({windowId:tt,url:tt}),_t=k({windowId:tt,factorIndex:nt}),xt=x(),Tt=k({top:O(S()),left:O(S()),width:O(nt),height:O(nt)}),kt=k({id:tt,applicationName:tt}),Pt=k({flags:I()}),Ot=k({flags:I()}),Rt=k({windowId:tt,channelsNames:P(tt)}),At=k({enabled:_()}),Mt=k({url:tt,top:O(S()),left:O(S()),width:O(nt),height:O(nt),workspacesSandbox:O(Ot),channelSelector:O(At),iframePermissionsPolicy:O(Pt)}),Et=k({name:tt,displayName:O(I()),contexts:O(P(I())),customConfig:O(k()),resultType:O(I())}),Dt=k({name:tt,type:tt.where(e=>"window"===e,"Expected a value of window"),title:O(tt),version:O(tt),customProperties:O(x()),icon:O(I()),caption:O(I()),details:Mt,intents:O(P(Et)),hidden:O(_()),fdc3:O(et.fdc3.v2DefinitionDecoder)}),jt=k({name:tt}),Nt=k({definitions:P(Dt)}),Ft=k({name:tt,type:tt.where(e=>"window"===e,"Expected a value of window"),instances:P(kt),userProperties:O(x()),title:O(tt),version:O(tt),icon:O(I()),caption:O(tt),fdc3:O(x())}),Lt=k({name:tt,type:tt.where(e=>"window"===e,"Expected a value of window"),userProperties:x(),title:O(tt),version:O(tt),icon:O(I()),caption:O(tt),fdc3:O(x())}),$t=k({appsAdded:P(Lt),appsChanged:P(Lt),appsRemoved:P(Lt)}),Wt=k({apps:P(Ft),initialChannelId:O(tt)}),Ht=k({id:tt}),Ut=R(T("Global"),T("Activity"),T("ApplicationDefault"),T("Swimlane"),T("Workspace")),qt=R(T("application"),T("activity")),Bt=k({context:O(x()),bounds:ht,createArgs:k({name:O(tt),url:O(tt),context:O(x())}),windowState:O(tt),restoreState:O(tt),instanceId:tt,isCollapsed:O(_()),isSticky:O(_()),restoreSettings:k({groupId:O(tt),groupZOrder:O(S())}),channelId:O(tt)}),Gt=k({type:T("window"),componentType:O(qt),application:tt,state:Bt}),Jt=k({type:T("window"),config:k({appName:tt,url:O(tt),title:O(I()),allowExtract:O(_()),allowReorder:O(_()),showCloseButton:O(_()),isMaximized:O(_()),instanceId:O(tt)})}),zt=k({type:T("group"),config:x(),children:P(R(Jt))}),Vt=k({type:T("column"),config:x(),children:P(R(zt,Jt,E(()=>Vt),E(()=>Kt)))}),Kt=k({type:T("row"),config:x(),children:P(R(Vt,zt,Jt,E(()=>Kt)))}),Zt=k({config:x(),context:x(),children:P(R(Kt,Vt,zt,Jt))}),Qt=k({type:T("Workspace"),application:O(tt),state:Zt}),Yt=k({bounds:ht,instanceId:tt,selectedWorkspace:nt,workspaces:P(Zt),windowState:O(tt),restoreState:O(tt),context:O(x())}),Xt=k({type:T("workspaceFrame"),application:tt,componentType:O(qt),state:Yt}),en=k({name:tt,type:Ut,token:O(tt),components:P(R(Gt,Qt,Xt)),context:O(x()),metadata:O(x()),version:O(S())}),tn=k({name:tt,type:Ut,token:O(tt),components:P(R(Gt,Qt,Xt)),context:O(x()),metadata:O(x()),version:O(S()),prevName:tt}),nn=k({name:tt,context:O(x()),metadata:O(x()),instances:O(P(tt)),ignoreInstances:O(P(tt)),setAsCurrent:O(_()),ignoreContexts:O(_()),saveWindowContexts:O(_())}),rn=k({name:tt,context:O(x()),closeRunningInstance:O(_()),closeMe:O(_()),timeout:O(nt)}),sn=k({name:tt,type:Ut,context:O(x()),metadata:O(x())}),on=k({name:tt,type:Ut}),an=k({layout:nn}),cn=k({layout:en,newName:tt}),dn=k({status:tt}),ln=k({layout:en}),hn=k({layout:rn}),un=k({type:Ut}),pn=k({layouts:P(en)}),gn=O(k({name:tt})),fn=R(T("replace"),T("merge")),mn=k({layouts:P(en),mode:fn,skipManagerRequest:O(_())}),bn=k({summaries:P(sn)}),yn=k({layout:en}),wn=k({layout:O(en)}),vn=k({name:tt}),Cn=R(T("findIntent"),T("getIntents"),T("getIntentsByHandler"),T("raise"),T("filterHandlers")),In=k({applicationName:tt,applicationTitle:O(I()),applicationDescription:O(I()),applicationIcon:O(I()),type:R(T("app"),T("instance")),displayName:O(I()),contextTypes:O(P(tt)),instanceId:O(I()),instanceTitle:O(I()),resultType:O(I()),customConfig:O(k())});k({applicationName:I(),applicationIcon:O(I()),instanceId:O(I())}),k({intent:tt,handler:In});const Sn=k({name:tt,handlers:P(In)}),_n=R(T("startNew"),T("reuse"),k({app:O(tt),instance:O(tt)})),xn=k({type:O(tt),data:O(x())}),Tn=P(Sn),kn=k({intents:Tn}),Pn=k({name:O(tt),contextType:O(tt),resultType:O(tt)}),On=R(tt,Pn),Rn=k({filter:O(Pn)}),An=k({top:O(S()),left:O(S()),width:O(nt),height:O(nt),relativeTo:O(tt),relativeDirection:O(lt),waitForAGMReady:O(_()),channelId:O(tt)}),Mn=k({intent:tt,target:O(_n),context:O(xn),options:O(An),handlers:O(P(In)),timeout:O(nt),waitUserResponseIndefinitely:O(_()),clearSavedHandler:O(_())}),En=k({interopInstance:tt,name:O(tt)}),Dn=k({originApp:En,intentRequest:O(Mn)}),jn=k({name:tt,waitForAGMReady:_(),id:O(tt),context:O(x()),top:O(S()),left:O(S()),width:O(nt),height:O(nt),relativeTo:O(tt),relativeDirection:O(lt),forceChromeTab:O(_()),layoutComponentId:O(tt),channelId:O(tt),startReason:Dn}),Nn=R(tt,Mn),Fn=k({enabled:_(),appName:tt,waitResponseTimeout:S()}),Ln=R(k({applicationName:tt}),k({instanceId:tt})),$n=k({title:O(tt),openResolver:O(_()),timeout:O(nt),intent:O(tt),contextTypes:O(P(tt)),resultType:O(tt),applicationNames:O(P(tt)),excludeList:O(P(Ln))}),Wn=k({enabled:_(),initialCaller:k({instanceId:tt})}),Hn=k({intentRequest:Mn,resolverConfig:Fn,embeddedResolverConfig:O(Wn)}),Un=k({request:Mn,handler:In,result:x()}),qn=k({handlers:P(In)}),Bn=k({filterHandlersRequest:$n,resolverConfig:Fn,embeddedResolverConfig:O(Wn)}),Gn=k({intent:tt,contextTypes:O(P(tt)),displayName:O(I()),icon:O(I()),description:O(I()),resultType:O(I()),customConfig:O(k())}),Jn=R(tt,Gn),zn=k({intent:tt,contextTypes:O(P(tt)),description:O(tt),displayName:O(tt),icon:O(tt),resultType:O(tt)}),Vn=k({intents:P(zn)}),Kn=e=>tt.where(t=>e.includes(t),"Expected a valid channel name"),Zn=k({contextType:O(tt)}),Qn=O(R(tt,k({name:O(tt),fdc3:O(_())}))),Yn=k({windowId:it,channel:it}),Xn=x().where(e=>"string"==typeof e.type,"Expected a valid FDC3 Context with compulsory 'type' field"),ei=k({method:tt,arguments:O(x()),target:O(R(T("all"),T("best")))}),ti=k({action:I(),title:tt,icon:O(I()),interop:O(ei)}),ni=R(T("Active"),T("Acknowledged"),T("Seen"),T("Closed"),T("Stale"),T("Snoozed"),T("Processing")),ii=k({count:S()}),ri=k({badge:O(I()),body:O(I()),data:O(x()),dir:O(R(T("auto"),T("ltr"),T("rtl"))),icon:O(I()),image:O(I()),lang:O(I()),renotify:O(_()),requireInteraction:O(_()),silent:O(_()),tag:O(I()),timestamp:O(nt),vibrate:O(P(S()))}),si=k({title:tt,clickInterop:O(ei),actions:O(P(ti)),focusPlatformOnDefaultClick:O(_()),badge:O(I()),body:O(I()),data:O(x()),dir:O(R(T("auto"),T("ltr"),T("rtl"))),icon:O(I()),image:O(I()),lang:O(I()),renotify:O(_()),requireInteraction:O(_()),silent:O(_()),tag:O(I()),timestamp:O(nt),vibrate:O(P(S())),severity:O(R(T("Low"),T("None"),T("Medium"),T("High"),T("Critical"))),showToast:O(_()),showInPanel:O(_()),state:O(ni)}),oi=k({id:tt,state:ni});k().where(e=>!e.fdc3||"string"==typeof e.fdc3.type,"Expected a valid FDC3 Context with compulsory 'type' field");const ai=k({color:O(tt),icon:O(tt),name:O(tt),glyph:O(tt)}),ci=k({id:tt,displayMetadata:O(ai)}),di=k({color:tt,fdc3:O(ci)}),li=k({name:tt,meta:di,data:O(k())}),hi=k({path:tt,value:x()}),ui=P(hi),pi=k({name:tt}),gi=k({name:tt,read:_(),write:_(),windowId:O(tt)}),fi=k({name:tt,read:_(),write:_(),windowId:tt}),mi=k({config:fi}),bi=k({channels:P(gi)}),yi=k({windowId:tt}),wi=k({read:_(),write:_(),windowId:O(tt)}),vi=k({restrictions:wi}),Ci=k({settings:si,id:tt}),Ii=k({settings:si}),Si=k({permissionGranted:_()}),_i=k({permission:R(T("default"),T("granted"),T("denied"))}),xi=k({definition:ri,action:O(I()),id:O(tt)}),Ti=k({allowed:O(P(tt)),blocked:O(P(tt))}),ki=k({enable:O(_()),enableToasts:O(_()),sourceFilter:O(Ti),showNotificationBadge:O(_())}),Pi=k({configuration:ki}),Oi=k({configuration:k({enable:_(),enableToasts:_(),sourceFilter:k({allowed:P(tt),blocked:P(tt)})})}),Ri=k({layoutType:R(T("Global"),T("Workspace")),layoutName:tt,context:O(x())}),Ai=k({windowContext:O(x())}),Mi=k({state:R(T("prompt"),T("denied"),T("granted"))}),Ei=k({isAvailable:_()}),Di=k({itemId:tt}),ji=k({isSupported:_()}),Ni=k({operation:tt}),Fi=k({bounds:ht}),Li=k({displayName:tt,name:tt}),$i=k({theme:Li}),Wi=k({themes:P(Li)}),Hi=k({name:tt}),Ui=k({id:tt,title:tt,clickInterop:O(ei),actions:O(P(ti)),focusPlatformOnDefaultClick:O(_()),badge:O(I()),body:O(I()),data:O(x()),dir:O(R(T("auto"),T("ltr"),T("rtl"))),icon:O(I()),image:O(I()),lang:O(I()),renotify:O(_()),requireInteraction:O(_()),silent:O(_()),tag:O(I()),timestamp:O(nt),vibrate:O(P(S())),severity:O(R(T("Low"),T("None"),T("Medium"),T("High"),T("Critical"))),showToast:O(_()),showInPanel:O(_()),state:O(ni)}),qi=k({notification:Ui}),Bi=k({notifications:P(Ui)}),Gi=k({id:tt}),Ji=k({channel:tt}),zi=k({windowIds:P(tt)}),Vi=R(T("appHello"),T("addChannel"),T("getMyChannel"),T("getWindowIdsOnChannel"),T("getWindowIdsWithChannels"),T("joinChannel"),T("restrict"),T("getRestrictions"),T("restrictAll"),T("notifyChannelsChanged"),T("leaveChannel"),T("getMode"),T("operationCheck")),Ki=R(T("single"),T("multi")),Zi=k({mode:Ki}),Qi=k({windowId:tt}),Yi=k({mode:Ki,channels:P(tt),restrictions:P(gi)}),Xi=k({channel:O(tt)}),er=k({application:O(tt),channels:O(P(tt)),windowIds:O(P(tt))}),tr=k({filter:O(er)}),nr=k({windowIdsWithChannels:P(k({application:tt,channel:O(tt),windowId:tt}))}),ir=O(x()),rr=O(k({top:O(S()),left:O(S()),width:O(nt),height:O(nt),relativeTo:O(tt),relativeDirection:O(lt),waitForAGMReady:O(_()),channelId:O(tt),reuseId:O(tt),originIntentRequest:O(Mn)})),sr=k({channel:tt,windowId:tt}),or=k({windowId:tt,channelName:O(tt)}),ar=k({windowId:tt,channelNames:P(tt)}),cr=k({channel:O(tt)}),dr=R(T("clear"),T("clearAll"),T("get"),T("getAll"),T("set"),T("update"),T("prefsChanged"),T("prefsHello"),T("operationCheck"),T("registerSubscriber")),lr=k({app:tt,data:k(),lastUpdate:O(tt)}),hr=k({app:tt}),ur=k({prefs:lr}),pr=k({all:P(lr)}),gr=k({interopId:tt,appName:O(tt)}),fr=k({app:tt,data:k()}),mr=k({platform:k({app:tt}),validNonExistentApps:O(P(tt)),isAppValidationEnabled:O(_())}),br=k({message:tt}),yr=k({isClientErrorOperationSupported:_()}),wr=et.common.nonEmptyStringDecoder,vr=et.common.nonNegativeNumberDecoder,Cr=k({bundle:wr,styles:P(wr),fonts:O(P(wr))}),Ir=k({bundle:wr,styles:P(wr),fonts:O(P(wr))}),Sr=k({bundle:wr,styles:P(wr),fonts:O(P(wr))}),_r=R(T("directional"),T("default")),xr=k({type:O(_r),enable:O(_())}),Tr=R(T("top-left"),T("top-center"),T("top-right"),T("center-left"),T("center-right"),T("bottom-left"),T("bottom-center"),T("bottom-right")),kr=R(T("all"),T("fdc3")),Pr=k({selector:O(xr),displayMode:O(kr)}),Or=k({channels:O(Pr),position:O(Tr),displayInWorkspace:O(_()),restoreLastKnownPosition:O(_())}),Rr=k({enable:_(),awaitFactory:O(_()),timeout:O(vr),channels:O(Pr),position:O(Tr),displayInWorkspace:O(_()),restoreLastKnownPosition:O(_())}),Ar=k({alerts:O(k({enabled:_()})),dialogs:O(k({enabled:_()})),awaitFactory:O(_()),timeout:O(vr)}),Mr=R(T("getResources"),T("operationCheck"),T("showAlert"),T("showDialog"),T("alertInteropAction"),T("showResolver")),Er=k({origin:wr}),Dr=k({blockedOrigin:T(!0)}),jr=A(Dr,k({blockedOrigin:T(!1),config:Or,sources:Cr})),Nr=A(Dr,k({blockedOrigin:T(!1),sources:Ir})),Fr=A(Dr,k({blockedOrigin:T(!1),sources:Sr})),Lr=k({widget:O(jr),modals:O(Nr),intentResolver:O(Fr)}),$r=k({resources:Lr}),Wr=k({method:wr,arguments:O(x()),target:O(R(T("best"),T("all"),wr))}),Hr=R(T("Global"),T("WindowContainer"),wr),Ur=k({instance:wr,container:O(R(T("Global"),T("WindowContainer")))}),qr=k({variant:R(T("default"),T("success"),T("critical"),T("info"),T("warning")),text:wr,showCloseButton:O(_()),clickInterop:O(Wr),onCloseInterop:O(Wr),actions:O(P(k({id:wr,title:wr,clickInterop:Wr}))),data:O(x()),ttl:O(vr),target:O(Hr)}),Br=k({config:qr,target:Ur}),Gr=k({templateName:wr,variables:x(),target:O(Hr),timer:O(k({duration:vr})),size:O(k({width:vr,height:vr})),movable:O(_()),transparent:O(_())}),Jr=k({isExpired:O(_()),isClosed:O(_()),isEnterPressed:O(_()),responseButtonClicked:O(k({id:wr,text:wr})),inputs:O(P(k({type:R(T("checkbox"),T("email"),T("number"),T("password"),T("text")),id:wr,checked:O(_()),value:O(I())})))});k({result:Jr});const zr=k({config:Gr,target:Ur}),Vr=k({id:wr}),Kr=k({id:wr,responsePromise:x()}),Zr=k({response:Jr}),Qr=k({name:wr,settings:Wr}),Yr=k({interopAction:Qr}),Xr=k({interopAction:Qr}),es=k({enable:_(),awaitFactory:O(_()),timeout:O(vr)}),ts=k({id:wr}),ns=k({preserveChoice:_()}),is=k({intent:wr,handler:In,userSettings:ns}),rs=k({isExpired:O(_()),isClosed:O(_()),userChoice:O(is)}),ss=k({response:rs}),os=M(A(k({intentRequest:Mn}),k({handlerFilter:$n})),k({timeout:vr})),as=k({config:os}),cs=k({result:rs}),ds={openWindow:{name:"openWindow",dataDecoder:pt,resultDecoder:ft},windowHello:{name:"windowHello",dataDecoder:gt,resultDecoder:bt},windowAdded:{name:"windowAdded",dataDecoder:ft},windowRemoved:{name:"windowRemoved",dataDecoder:mt},getBounds:{name:"getBounds",dataDecoder:mt,resultDecoder:Ct},getFrameBounds:{name:"getFrameBounds",dataDecoder:mt,resultDecoder:It},getUrl:{name:"getUrl",dataDecoder:mt,resultDecoder:St},moveResize:{name:"moveResize",dataDecoder:vt},focus:{name:"focus",dataDecoder:mt},close:{name:"close",dataDecoder:mt},getTitle:{name:"getTitle",dataDecoder:mt,resultDecoder:yt},setTitle:{name:"setTitle",dataDecoder:yt},focusChange:{name:"focusChange",dataDecoder:wt},getChannel:{name:"getChannel",dataDecoder:mt,resultDecoder:cr},notifyChannelsChanged:{name:"notifyChannelsChanged",dataDecoder:ar},setZoomFactor:{name:"setZoomFactor",dataDecoder:_t},zoomFactorChange:{name:"zoomFactorChange",dataDecoder:_t},refresh:{name:"refresh",dataDecoder:mt},operationCheck:{name:"operationCheck"}};function ls(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,n={};function i(n,i){var r=n instanceof Error?n:new Error(n);if(t)t(r);else{var s='[ERROR] callback-registry: User callback for key "'+i+'" failed: '+r.stack;if(e)switch(e.errorHandling){case"log":return console.error(s);case"silent":return;case"throw":throw new Error(s)}console.error(s)}}return{add:function(e,t,r){var s=n[e];return s||(s=[],n[e]=s),s.push(t),r&&setTimeout(function(){r.forEach(function(r){var s;if(null===(s=n[e])||void 0===s?void 0:s.includes(t))try{Array.isArray(r)?t.apply(void 0,r):t.apply(void 0,[r])}catch(t){i(t,e)}})},0),function(){var i=n[e];i&&(0===(i=i.reduce(function(e,n,i){return n===t&&e.length===i||e.push(n),e},[])).length?delete n[e]:n[e]=i)}},execute:function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var s=n[e];if(!s||0===s.length)return[];var o=[];return s.forEach(function(n){try{var r=n.apply(void 0,t);o.push(r)}catch(t){o.push(void 0),i(t,e)}}),o},clear:function(){n={}},clearKey:function(e){n[e]&&delete n[e]}}}ls.default=ls;var hs=e(ls);const us=Object.freeze({0:24,1:33,2:50,3:67,4:75,5:80,6:90,7:100,8:110,9:125,10:150,11:175,12:200,13:250,14:300,15:400,16:500});class ps{_id;_name;_bridge;_logger;registry=hs();myCtxKey;ctxUnsubscribe;zoomFactorIndex=7;me;constructor(e,t,n,i){this._id=e,this._name=t,this._bridge=n,this._logger=i,this.myCtxKey=`___window___${this.id}`}get id(){return this._id.slice()}get name(){return this._name.slice()}get zoomFactor(){return us[this.zoomFactorIndex]}clean(){this.ctxUnsubscribe&&this.ctxUnsubscribe()}processSelfFocusEvent(e){this.me.isFocused=e,this.registry.execute("focus-change",this.me)}processChannelsChangedEvent(e){this.registry.execute("channels-changed",e)}processSelfZoomFactorChangedEvent(e){this.zoomFactorIndex=e,this.registry.execute("zoom-factor-changed",this.me)}async toApi(){return this.ctxUnsubscribe=await this._bridge.contextLib.subscribe(this.myCtxKey,e=>this.registry.execute("context-updated",e)),this.me={id:this.id,name:this.name,isFocused:!1,zoomFactor:this.zoomFactor,getURL:this.getURL.bind(this),moveResize:this.moveResize.bind(this),resizeTo:this.resizeTo.bind(this),moveTo:this.moveTo.bind(this),focus:this.focus.bind(this),close:this.close.bind(this),getTitle:this.getTitle.bind(this),setTitle:this.setTitle.bind(this),getBounds:this.getBounds.bind(this),getContext:this.getContext.bind(this),updateContext:this.updateContext.bind(this),setContext:this.setContext.bind(this),refresh:this.refresh.bind(this),onContextUpdated:this.onContextUpdated.bind(this),onFocusChanged:this.onFocusChanged.bind(this),getChannel:this.getChannel.bind(this),onChannelsChanged:this.onChannelsChanged.bind(this),zoomIn:this.zoomIn.bind(this),zoomOut:this.zoomOut.bind(this),setZoomFactor:this.setZoomFactor.bind(this),onZoomFactorChanged:this.onZoomFactorChanged.bind(this)},Object.defineProperties(this.me,{id:Q,name:Q,zoomFactor:{get:()=>this.zoomFactor,enumerable:!0}}),this.me}async getURL(){return(await this._bridge.send("windows",ds.getUrl,{windowId:this.id})).url}onFocusChanged(e){return"function"!=typeof e?re.raiseError("Cannot subscribe to context changes, because the provided callback is not a function!"):this.registry.add("focus-change",e)}async moveResize(e){const t=X(Tt,e),n=Object.assign({},t,{windowId:this.id,relative:!1});return await this._bridge.send("windows",ds.moveResize,n),this.me}async resizeTo(e,t){if(void 0===e&&void 0===t)return this.me;void 0!==e&&X(nt,e),void 0!==t&&X(nt,t);const n=Object.assign({},{width:e,height:t},{windowId:this.id,relative:!0});return await this._bridge.send("windows",ds.moveResize,n),this.me}async moveTo(e,t){if(void 0===e&&void 0===t)return this.me;void 0!==e&&X(S(),e),void 0!==t&&X(S(),t);const n=Object.assign({},{top:e,left:t},{windowId:this.id,relative:!0});return await this._bridge.send("windows",ds.moveResize,n),this.me}async focus(){return"Platform"===this.name?window.open(void 0,this.id):await this._bridge.send("windows",ds.focus,{windowId:this.id}),this.me}async close(){return await this._bridge.send("windows",ds.close,{windowId:this.id}),this.me}async getTitle(){return(await this._bridge.send("windows",ds.getTitle,{windowId:this.id})).title}async setTitle(e){const t=X(tt,e);return await this._bridge.send("windows",ds.setTitle,{windowId:this.id,title:t}),this.me}async getBounds(){return(await this._bridge.send("windows",ds.getBounds,{windowId:this.id})).bounds}async getContext(){const e=await this._bridge.contextLib.get(this.myCtxKey),{___io___:t,...n}=e;return n}async updateContext(e){const t=X(xt,e);return await this._bridge.contextLib.update(this.myCtxKey,t),this.me}async setContext(e){const t=X(xt,e),n=await this._bridge.contextLib.get(this.myCtxKey),i=n.___io___?{...t,___io___:n.___io___}:t;return await this._bridge.contextLib.set(this.myCtxKey,i),this.me}onContextUpdated(e){if("function"!=typeof e)return re.raiseError("Cannot subscribe to context changes, because the provided callback is not a function!");return this.registry.add("context-updated",t=>{const{___io___:n,...i}=t;e(i,this.me)})}async getChannel(){return(await this._bridge.send("windows",ds.getChannel,{windowId:this.id},void 0,{includeOperationCheck:!0})).channel}onChannelsChanged(e){return this.registry.add("channels-changed",e)}getClosestZoomFactorIndex(e){const t=Object.entries(us).reduce((t,[n,i])=>Math.abs(i-e)<=Math.abs(us[t]-e)?parseInt(n):t,0),n=us[t];return n!==e&&this._logger.warn(`Zoom factor ${e} is not available, using closest value ${n} instead.`),t}async zoom(e){e!==this.zoomFactorIndex&&e in us&&(await this._bridge.send("windows",ds.setZoomFactor,{windowId:this.id,factorIndex:e},void 0,{includeOperationCheck:!0}),this.zoomFactorIndex=e)}async zoomIn(){return await this.zoom(this.zoomFactorIndex+1),this.me}async zoomOut(){return await this.zoom(this.zoomFactorIndex-1),this.me}async setZoomFactor(e){const t=X(S(),e),n=this.getClosestZoomFactorIndex(t);return await this.zoom(n),this.me}onZoomFactorChanged(e){return"function"!=typeof e?re.raiseError("Cannot subscribe to zoom factor changes, because the provided callback is not a function!"):this.registry.add("zoom-factor-changed",e)}async refresh(){return await this._bridge.send("windows",ds.refresh,{windowId:this.id},void 0,{includeOperationCheck:!0}),this.me}}const gs={operationCheck:{name:"operationCheck",dataDecoder:Ni,resultDecoder:ji},getWorkspaceWindowFrameBounds:{name:"getWorkspaceWindowFrameBounds",resultDecoder:Fi,dataDecoder:Di}},fs=(e,t,n)=>new Promise((i,r)=>{let s=!0;const o=setTimeout(()=>{if(!s)return;s=!1;r(n||`Promise timeout hit: ${t}`)},t);e().then(e=>{s&&(s=!1,clearTimeout(o),i(e))}).catch(e=>{s&&(s=!1,clearTimeout(o),r(e))})}),ms=(e,t,n)=>new Promise((i,r)=>{const s=setTimeout(()=>{r(n||`Promise timeout hit: ${t}`)},t);new Promise(e).then(e=>{clearTimeout(s),i(e)}).catch(e=>{clearTimeout(s),r(e)})});class bs{supportedOperationsNames=[];focusEventHandler;registry=hs();platformRegistration;ioc;bridge;publicWindowId;allWindowProjections=[];me;logger;isWorkspaceFrame;instanceId;channelsController;async start(e,t){this.logger=e.logger.subLogger("windows.controller.web"),this.logger.trace("starting the web windows controller"),this.publicWindowId=t.publicWindowId,this.addWindowOperationExecutors(),this.ioc=t,this.bridge=t.bridge,this.instanceId=e.interop.instance.instance,this.channelsController=t.channelsController,this.logger.trace(`set the public window id: ${this.publicWindowId}, set the bridge operations and ioc, registering with the platform now`),this.platformRegistration=this.registerWithPlatform(),await this.platformRegistration,await this.initializeFocusTracking(),this.logger.trace("registration with the platform successful, attaching the windows property to glue and returning");const n=this.toApi();e.windows=n}handlePlatformShutdown(){this.registry.clear(),this.allWindowProjections=[],this.focusEventHandler&&(document.removeEventListener("visibilityChange",this.focusEventHandler),window.removeEventListener("focus",this.focusEventHandler),window.removeEventListener("blur",this.focusEventHandler))}async handleBridgeMessage(e){await this.platformRegistration;const t=X(st,e.operation),n=ds[t];if(!n.execute)return;let i=e.data;return n.dataDecoder&&(i=X(n.dataDecoder,e.data)),await n.execute(i)}async open(e,t,n){X(tt,e),X(tt,t);const i=X(ut,n),r=await this.bridge.send("windows",ds.openWindow,{name:e,url:t,options:i});return this.waitForWindowAdded(r.windowId)}list(){return this.allWindowProjections.map(e=>e.api)}findById(e){return X(tt,e),this.allWindowProjections.find(t=>t.id===e)?.api}toApi(){return{open:this.open.bind(this),my:this.my.bind(this),list:this.list.bind(this),findById:this.findById.bind(this),onWindowAdded:this.onWindowAdded.bind(this),onWindowRemoved:this.onWindowRemoved.bind(this),onWindowGotFocus:this.onWindowGotFocus.bind(this),onWindowLostFocus:this.onWindowLostFocus.bind(this)}}addWindowOperationExecutors(){ds.focusChange.execute=this.handleFocusChangeEvent.bind(this),ds.windowAdded.execute=this.handleWindowAdded.bind(this),ds.windowRemoved.execute=this.handleWindowRemoved.bind(this),ds.getBounds.execute=this.handleGetBounds.bind(this),ds.getFrameBounds.execute=this.handleGetBounds.bind(this),ds.getTitle.execute=this.handleGetTitle.bind(this),ds.getUrl.execute=this.handleGetUrl.bind(this),ds.moveResize.execute=this.handleMoveResize.bind(this),ds.setTitle.execute=this.handleSetTitle.bind(this),ds.getChannel.execute=this.handleGetChannel.bind(this),ds.notifyChannelsChanged.execute=this.handleChannelsChanged.bind(this),ds.setZoomFactor.execute=this.handleSetZoomFactor.bind(this),ds.zoomFactorChange.execute=this.handleZoomFactorChanged.bind(this),ds.refresh.execute=this.handleRefresh.bind(this),ds.operationCheck.execute=async e=>te(this.supportedOperationsNames,e.operation),this.supportedOperationsNames=ee(ds)}my(){return Object.assign({},this.me)}onWindowAdded(e){return"function"!=typeof e?re.raiseError("Cannot subscribe to window added, because the provided callback is not a function!"):this.registry.add("window-added",e)}onWindowRemoved(e){return"function"!=typeof e?re.raiseError("Cannot subscribe to window removed, because the provided callback is not a function!"):this.registry.add("window-removed",e)}onWindowGotFocus(e){return"function"!=typeof e?re.raiseError("Cannot subscribe to onWindowGotFocus, because the provided callback is not a function!"):this.registry.add("window-got-focus",e)}onWindowLostFocus(e){return"function"!=typeof e?re.raiseError("Cannot subscribe to onWindowLostFocus, because the provided callback is not a function!"):this.registry.add("window-lost-focus",e)}async sayHello(){return await this.bridge.send("windows",ds.windowHello,{windowId:this.publicWindowId})}async registerWithPlatform(){const{windows:e,isWorkspaceFrame:t}=await this.sayHello();if(this.isWorkspaceFrame=t,this.logger.trace("the platform responded to the hello message"),!this.isWorkspaceFrame&&this.publicWindowId){this.logger.trace("i am not treated as a workspace frame, setting my window");const t=e.find(e=>e.windowId===this.publicWindowId);if(!t){const t=e.map(e=>`${e.windowId}:${e.name}`).join(",