@openfin/core-web 0.40.5 → 0.40.7
Sign up to get free protection for your applications and to get access to all the features.
package/out/api-client.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
"use strict";var e=require("./main-
|
1
|
+
"use strict";var e=require("./main-6c540c1e.js");require("buffer/"),require("uuid"),require("events"),require("lodash"),exports.connect=e.connect;
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";var e=require("./main-ad0b29e8.js"),t=require("golden-layout"),i=require("uuid");require("buffer/"),require("events"),require("lodash");var o={},n={};Object.defineProperty(n,"__esModule",{value:!0}),n.mapValuesAsync=n.mapEntriesAsync=void 0;const s=(e,[t,i])=>({...e,[t]:i});async function r(e,t){return(await Promise.all(t.map((async([t,i])=>[t,await e(i,t)])))).reduce(s,{})}n.mapEntriesAsync=r,n.mapValuesAsync=async function(e,t){let i;return i=t instanceof Map?[...t.entries()]:Object.entries(t),r(e,i)};var a,l,c,u,h=e.commonjsGlobal&&e.commonjsGlobal.__classPrivateFieldSet||function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},d=e.commonjsGlobal&&e.commonjsGlobal.__classPrivateFieldGet||function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};Object.defineProperty(o,"__esModule",{value:!0});var m=o.DefaultLayoutManager=void 0;const y=n;class f{constructor(e){l.set(this,void 0),c.set(this,new Map),h(this,l,e,"f")}size(){return d(this,c,"f").size}async applyLayoutSnapshot({layouts:e}){if(Object.keys(e).length>1)throw new Error("[LayoutManager] Tried to call applyLayoutSnapshot with more than 1 layout. When implementing multiple layouts via overridden LayoutManager class, you must override and fully implement the applyLayoutSnapshot method without calling super.applyLayoutSnapshot().");const[[t,i]]=Object.entries(e);await f.createLayout(this,{layoutName:t,layout:i})}async showLayout({layoutName:e}){}async getLayoutSnapshot(){return{layouts:await(0,y.mapValuesAsync)((e=>e.getFrameSnapshot()),d(this,c,"f"))}}async removeLayout({layoutName:e}){}getLayoutIdentityForView(e){const t=[...d(this,c,"f").values()].find((t=>t.getCurrentViews().some((t=>t.name===e.name&&t.uuid===e.uuid))));return t?.identity??void 0}isLayoutVisible({layoutName:e}){return d(f,a,"m",u).call(f,this,e).isVisible()}resolveLayoutIdentity(e){if(e&&"layoutName"in e)return e;const t=[...d(this,c,"f").values()];if(1===t.length)return t[0].identity;const i=t.find((e=>e.isVisible()));return i?.identity??void 0}static async resolveLayout(e,t){const i=e.resolveLayoutIdentity(t);if(void 0===i||!("layoutName"in i))throw new Error("[layout-manager] resolveLayout: Could not resolve the layout identity. Make sure you include 'layoutName' in the identity object.");return d(f,a,"m",u).call(f,e,i.layoutName)}static async handleSharedView(e,t,i){await(0,y.mapValuesAsync)((async e=>{if(e.identity.layoutName!==t.layoutName){const t=e.getCurrentViews().find((e=>e.name===i.name));t&&await e.onViewDetached({viewIdentity:t,target:null}).catch(console.error)}}),d(e,c,"f"))}static async handleLastViewRemoved(e,t){await e.removeLayout(t),await d(e,l,"f").handleLastViewRemoved(e)}static async destroyLayout(e,{layoutName:t}){await d(f,a,"m",u).call(f,e,t).destroy(),d(e,c,"f").delete(t)}static async createLayout(e,t){const{layoutName:i}=t;if(d(e,c,"f").has(i))throw new Error(`Layout name ${i} already exists`);await d(e,l,"f").createLayout(t,e)}static registerLayout(e,t,i){d(e,c,"f").set(t,i)}static getAllLayouts(e){return[...d(e,c,"f").values()]}static setInitialSnapshot(e,t){d(e,l,"f").setInitialSnapshot(t)}static createClosedConstructor(...e){return class extends f{constructor(){super(...e)}}}}m=o.DefaultLayoutManager=f,a=f,l=new WeakMap,c=new WeakMap,u=function(e,t){const i=d(e,c,"f").get(t);if(!i)throw new Error(`[layout-manager] getLayoutByName: Could not locate layout with name '${t}'`);return i};var p={};Object.defineProperty(p,"__esModule",{value:!0});var w=p.BaseLayout=void 0;w=p.BaseLayout=class{};var v={};Object.defineProperty(v,"__esModule",{value:!0});var g=v.DOMEmitter=void 0;g=v.DOMEmitter=class{constructor(e){this.container=e}dispatchLocalEvent(e,t){const i={...t,type:e,tabSelector:`tab-${t.name}`,containerSelector:`container-${t.name}`,topic:"openfin-DOM-event"};this.container.dispatchEvent(new CustomEvent(e,{detail:i}))}};var b={};Object.defineProperty(b,"__esModule",{value:!0});var C=b.isVisible=void 0;C=b.isVisible=e=>(0!==e.offsetWidth||0!==e.offsetHeight)&&"hidden"!==window.getComputedStyle(e).visibility&&e.offsetTop>=0&&e.offsetLeft>=0&&e.offsetTop<=window.innerHeight&&e.offsetLeft<=window.innerWidth;const E="initial_",L={show:"top",popout:!1,maximise:!1,close:"close-tab-unused"},S={headerHeight:31},V={hasHeaders:!0,reorderEnabled:!0},_={popoutWholeStack:!1,constrainDragToContainer:!1,constrainDragToHeaders:!1,preventDragout:!1,showMaximiseIcon:!1,showPopoutIcon:!1,showCloseIcon:!1,blockedPopoutsThrowError:!0,closePopoutsOnUnload:!0,selectionEnabled:!1};var M,N;class A{constructor(t){this.layout=t,M.set(this,void 0),N.set(this,void 0),this.handleResize=e=>{e.forEach((e=>{const t=this.layout.viewComponentsByContainerElement.get(e.target);t&&t.resize(t.container.element.getBoundingClientRect())}))},this.handleMutation=()=>{const e=document.body.classList.contains("lm_dragging");this.layout.viewComponentsByContainerElement.forEach((t=>{const i=t.container.tab.element;i&&i.className.includes("lm_dragging")&&t.hide(),e?this.layout.handleDragStart():this.layout.handleDragEnd()}))},e.__classPrivateFieldSet(this,M,new ResizeObserver(this.handleResize),"f"),e.__classPrivateFieldSet(this,N,new MutationObserver(this.handleMutation),"f")}observeDragging(){const t=this.layout.layout.rootItem;if(!t)throw new Error("Root item not found in layout.");e.__classPrivateFieldGet(this,N,"f")?.observe(t.element,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]})}destroy(){e.__classPrivateFieldGet(this,M,"f").disconnect(),e.__classPrivateFieldGet(this,N,"f").disconnect()}observeContainer(t){e.__classPrivateFieldGet(this,M,"f").observe(t)}unobserveContainer(t){e.__classPrivateFieldGet(this,M,"f").unobserve(t)}}function P(e=[],t){for(const i of e)"component"===i.type?Object.keys(t).forEach((e=>{e in i&&(i.componentState={[`${E}${e}`]:i[e],...i.componentState}),i[e]=t[e]})):P(i.content,t)}function $(e=[],t,i){for(const o of e)if("component"===o.type)Object.keys(t).forEach((e=>{if(`${E}${e}`in o.componentState)return o[e]=o.componentState[`${E}${e}`],void delete o.componentState[`${E}${e}`];o[e]=t[e]}));else{if(o.size&&("row"===i||"column"===i)){o["row"===i?"width":"height"]=o.size?.includes(".")?parseFloat(o.size):parseInt(o.size)}$(o.content,t,o.type)}}function x(e){if(e.root){e.root.content&&$([e.root],{componentName:"view",isClosable:!0});const t=e.root;e.content=[t],delete e.root}return e}M=new WeakMap,N=new WeakMap;const k=t=>class extends t{connectedCallback(){if(!this.name||!this.uuid)throw new Error("<of-view> Name or uuid attribute missing");if(!this.src)throw new Error("<of-view> missing 'src' attribute.");this.#e||(this.#e=document.createElement("iframe"),this.#e.src=this.src,this.#e.style.height="100%",this.#e.style.width="100%",this.#e.style.border="none",this.forceFrameName?this.#e.setAttribute("name",this.forceFrameName):this.#e.setAttribute("name",e.encodeOptions({brokerUrl:this.brokerUrl,name:this.name,uuid:this.uuid,providerId:this.providerId,contextGroup:this.contextGroup},"of-frame")),this.#e.setAttribute("id",this.name),this.appendChild(this.#e))}#e;get brokerUrl(){return this.getAttribute("of-broker")}set brokerUrl(e){e&&this.setAttribute("of-broker",e)}get name(){return this.getAttribute("of-name")}set name(e){e&&this.setAttribute("of-name",e)}get forceFrameName(){return this.getAttribute("forceFrameName")}set forceFrameName(e){e&&this.setAttribute("forceFrameName",e)}get uuid(){return this.getAttribute("of-uuid")}set uuid(e){e&&this.setAttribute("of-uuid",e)}get src(){return this.getAttribute("src")}set src(e){e&&this.setAttribute("src",e)}get providerId(){return this.getAttribute("of-provider-id")}set providerId(e){e&&this.setAttribute("of-provider-id",e)}get contextGroup(){return this.getAttribute("of-context-group")}set contextGroup(e){e&&this.setAttribute("of-context-group",e)}static get observedAttributes(){return["name"]}};class F{static create(e){const t=document.createElement("of-view");return Object.entries(e).forEach((([e,i])=>{t.setAttribute(e,i)})),t}}customElements.define("of-view",k(HTMLElement));class I{constructor(e,t,o,{brokerUrl:n,interopConfig:s},r){this.container=e,this.config=t,this.ofView=null;const{url:a,web:l,interop:c}=t||{},u=`internal-generated-view-${i.v4()}`;if(this.identity={uuid:o,name:u},this.container.element.setAttribute("of-name",u),this.container.element.id=`container-${u}`,void 0===a)return void this.handleUrlMissing();const h=this.updateTitleIfNotSet(a),d={"of-broker":n,"of-uuid":o,"of-name":u,src:a};l?.frameName&&(d.forceFrameName=l.frameName);const m=c?.currentContextGroup??s?.currentContextGroup;m&&(d["of-context-group"]=m),s?.providerId&&(d["of-provider-id"]=s?.providerId),this.ofView=F.create(d),this.ofView.title=h??`Iframe: ${a}`,r.appendChild(this.ofView),this.ofView.style.position="absolute"}updateTitleIfNotSet(e){return"view"===this.container.parent.title&&this.container.parent.setTitle(e),this.container.parent.title}handleUrlMissing(){const e=document.createElement("div");e.setAttribute("style","padding: 20px");e.innerText="No URL provided",this.container.element.appendChild(e)}destroy(){this.ofView?.remove(),this.ofView=null}resize(e){this.ofView&&(this.ofView.style.position="absolute",this.ofView.style.height=`${e.height}px`,this.ofView.style.width=`${e.width}px`,this.ofView.style.inset=`${e.top}px ${e.right}px ${e.bottom}px ${e.left}px`,this.ofView.style.display="block")}hide(){this.ofView&&(this.ofView.style.display="none")}}class j extends w{static overrideConfig(e){const t={...V,...e.settings,..._};return t.reorderEnabled&&P(e.content,{isClosable:!0}),{dimensions:S,...e,settings:t,header:{...L,show:!1!==e.settings?.hasHeaders&&L.show}}}constructor(e,i,o,{options:n}){super(),this.identity=e,this.container=i,this.initialConfig=o,this.viewComponentsByContainerElement=new Map,this.createViewComponent=(e,t)=>{const i=new I(e,t,this.identity.uuid,this.options,this.iframeContainer);return t&&!1===t[`${E}isClosable`]&&this.stylesheet.insertRule(`#tab-${i.identity.name} .lm_close_tab { display: none; }`),this.viewComponentsByContainerElement.set(e.element,i),this.resizeController.observeContainer(e.element),i},this.iframeContainer=document.createElement("div"),this.iframeContainer.id=`openfin-layout-iframe-container-${this.identity.layoutName}`,this.container.setAttribute("data-openfin-layout-name",this.identity.layoutName),this.domEmitter=new g(i),this.stylesheet=new CSSStyleSheet,this.stylesheet.insertRule(".lm_close { display: none; }"),document.adoptedStyleSheets.push(this.stylesheet),this.layout=new t.GoldenLayout(this.container),this.layout.resizeWithContainerAutomatically=!0,this.options=n,this.layout.registerComponent("view",this.createViewComponent),this.setupListeners(),this.resizeController=new A(this),this.layout.loadLayout(j.overrideConfig(o));const s=document.createElement("div");s.attachShadow({mode:"open",delegatesFocus:!1}).appendChild(this.iframeContainer),this.container.appendChild(s),this.initialConfig.settings?.preventSplitterResize&&this.preventPointerEvents(),this.resizeController.observeDragging()}preventPointerEvents(){const e=`\n [data-openfin-layout-name='${this.identity.layoutName}'] .lm_splitter {\n pointer-events: none;\n }\n `;this.stylesheet.insertRule(e)}addView(e){throw new Error("Method not implemented.")}replaceView({viewToReplace:e,newView:t}){throw new Error("Method not implemented.")}replaceLayout(e){throw new Error("Method not implemented.")}closeView(e){throw new Error("Method not implemented.")}applyPreset(e){throw new Error("Method not implemented.")}getCurrentViews(){throw new Error("Method not implemented.")}async getFrameSnapshot(){return x(t.LayoutConfig.fromResolved(this.layout.toConfig()))}isVisible(){return C(this.container)}async onViewDetached(){throw new Error("Method not implemented.")}async destroy(){this.layout.destroy(),this.iframeContainer.remove(),this.resizeController.destroy(),document.adoptedStyleSheets=document.adoptedStyleSheets.filter((e=>e!==this.stylesheet)),this.viewComponentsByContainerElement.clear()}setupListeners(){this.container.addEventListener("mousedown",(e=>{e.target instanceof HTMLElement&&e.target.classList.contains("lm_drag_handle")&&this.handleDragStart()})),this.layout.on("tabCreated",(e=>{const t=e.componentItem.container.element.getAttribute("of-name")??i.v4(),o={name:t,uuid:t};e.element.id=`tab-${t}`,this.domEmitter.dispatchLocalEvent("tab-created",o)})),this.layout.on("itemCreated",(({target:e})=>{const t=e;if(!t.isComponent)return;const o=t.element.querySelector("[of-name]")?.getAttribute("of-name")??i.v4(),n={name:o,uuid:o};this.domEmitter.dispatchLocalEvent("container-created",n)})),this.layout.on("itemDestroyed",(e=>{const t=e.target;if(!t.isComponent)return;const i=t.component;this.removeViewComponent(i)}))}handleDragStart(){this.iframeContainer.style.pointerEvents="none"}handleDragEnd(){this.iframeContainer.style.pointerEvents=""}removeViewComponent(e){if(e.config&&!1===e.config[`${E}isClosable`]){const t=[...this.stylesheet.cssRules].findIndex((t=>t.cssText.includes(`#tab-${e.identity.name}`)));this.stylesheet.deleteRule(t)}e.destroy(),this.viewComponentsByContainerElement.delete(e.container.element),this.resizeController.unobserveContainer(e.container.element)}}class G{constructor(e,t,i){this.windowIdentity=e,this.connectConfig=t,this.fallbackContainer=i}async createLayout(e,t){if(!("container"in e)&&!this.fallbackContainer)throw new Error("Container property is not optional in web");const{layout:i,layoutName:o}=e,n=e.container??this.fallbackContainer,s={...this.windowIdentity,layoutName:o},r=new j(s,n,i,this.connectConfig);m.registerLayout(t,o,r),this.fallbackContainer=null}async getLayoutSnapshot(e){return e.getLayoutSnapshot()}async handleLastViewRemoved(e){throw new Error("Method not implemented.")}}var O;const T=e=>e;O=new WeakMap,exports.WebLayoutEntryPoint=class{constructor(t){O.set(this,void 0),this.initLayoutManager=async(t,i,{container:o,layoutManagerOverride:n})=>{const s=n??T,r=new G(i.me,e.__classPrivateFieldGet(this,O,"f"),o);return new(s(m.createClosedConstructor(r)))},this.applyLayoutSnapshot=async(t,i,o)=>{await i.applyLayoutSnapshot(e.__classPrivateFieldGet(this,O,"f").platform.layoutSnapshot)},this.createLayout=async(e,t)=>m.createLayout(e,t),this.destroyLayout=async(e,t)=>m.destroyLayout(e,t),e.__classPrivateFieldSet(this,O,t,"f")}};
|
1
|
+
"use strict";var e=require("./main-6c540c1e.js"),t=require("golden-layout"),i=require("uuid");require("buffer/"),require("events"),require("lodash");var o={},n={};Object.defineProperty(n,"__esModule",{value:!0}),n.mapValuesAsync=n.mapEntriesAsync=void 0;const s=(e,[t,i])=>({...e,[t]:i});async function a(e,t){return(await Promise.all(t.map((async([t,i])=>[t,await e(i,t)])))).reduce(s,{})}n.mapEntriesAsync=a,n.mapValuesAsync=async function(e,t){let i;return i=t instanceof Map?[...t.entries()]:Object.entries(t),a(e,i)};var r,l,c,u,h=e.commonjsGlobal&&e.commonjsGlobal.__classPrivateFieldSet||function(e,t,i,o,n){if("m"===o)throw new TypeError("Private method is not writable");if("a"===o&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===o?n.call(e,i):n?n.value=i:t.set(e,i),i},d=e.commonjsGlobal&&e.commonjsGlobal.__classPrivateFieldGet||function(e,t,i,o){if("a"===i&&!o)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===i?o:"a"===i?o.call(e):o?o.value:t.get(e)};Object.defineProperty(o,"__esModule",{value:!0});var m=o.DefaultLayoutManager=void 0;const y=n;class f{constructor(e){l.set(this,void 0),c.set(this,new Map),h(this,l,e,"f")}size(){return d(this,c,"f").size}async applyLayoutSnapshot({layouts:e}){if(Object.keys(e).length>1)throw new Error("[LayoutManager] Tried to call applyLayoutSnapshot with more than 1 layout. When implementing multiple layouts via overridden LayoutManager class, you must override and fully implement the applyLayoutSnapshot method without calling super.applyLayoutSnapshot().");const[[t,i]]=Object.entries(e);await f.createLayout(this,{layoutName:t,layout:i})}async showLayout({layoutName:e}){}async getLayoutSnapshot(){return{layouts:await(0,y.mapValuesAsync)((e=>e.getFrameSnapshot()),d(this,c,"f"))}}async removeLayout({layoutName:e}){}getLayoutIdentityForView(e){const t=[...d(this,c,"f").values()].find((t=>t.getCurrentViews().some((t=>t.name===e.name&&t.uuid===e.uuid))));return t?.identity??void 0}isLayoutVisible({layoutName:e}){return d(f,r,"m",u).call(f,this,e).isVisible()}resolveLayoutIdentity(e){if(e&&"layoutName"in e)return e;const t=[...d(this,c,"f").values()];if(1===t.length)return t[0].identity;const i=t.find((e=>e.isVisible()));return i?.identity??void 0}static async resolveLayout(e,t){const i=e.resolveLayoutIdentity(t);if(void 0===i||!("layoutName"in i))throw new Error("[layout-manager] resolveLayout: Could not resolve the layout identity. Make sure you include 'layoutName' in the identity object.");return d(f,r,"m",u).call(f,e,i.layoutName)}static async handleSharedView(e,t,i){await(0,y.mapValuesAsync)((async e=>{if(e.identity.layoutName!==t.layoutName){const t=e.getCurrentViews().find((e=>e.name===i.name));t&&await e.onViewDetached({viewIdentity:t,target:null}).catch(console.error)}}),d(e,c,"f"))}static async handleLastViewRemoved(e,t){await e.removeLayout(t),await d(e,l,"f").handleLastViewRemoved(e)}static async destroyLayout(e,{layoutName:t}){await d(f,r,"m",u).call(f,e,t).destroy(),d(e,c,"f").delete(t)}static async createLayout(e,t){const{layoutName:i}=t;if(d(e,c,"f").has(i))throw new Error(`Layout name ${i} already exists`);await d(e,l,"f").createLayout(t,e)}static registerLayout(e,t,i){d(e,c,"f").set(t,i)}static getAllLayouts(e){return[...d(e,c,"f").values()]}static setInitialSnapshot(e,t){d(e,l,"f").setInitialSnapshot(t)}static createClosedConstructor(...e){return class extends f{constructor(){super(...e)}}}}m=o.DefaultLayoutManager=f,r=f,l=new WeakMap,c=new WeakMap,u=function(e,t){const i=d(e,c,"f").get(t);if(!i)throw new Error(`[layout-manager] getLayoutByName: Could not locate layout with name '${t}'`);return i};var p={};Object.defineProperty(p,"__esModule",{value:!0});var w=p.BaseLayout=void 0;w=p.BaseLayout=class{};var v={};Object.defineProperty(v,"__esModule",{value:!0});var g=v.DOMEmitter=void 0;g=v.DOMEmitter=class{constructor(e){this.container=e}dispatchLocalEvent(e,t){const i={...t,type:e,tabSelector:`tab-${t.name}`,containerSelector:`container-${t.name}`,topic:"openfin-DOM-event"};this.container.dispatchEvent(new CustomEvent(e,{detail:i}))}};var b={};Object.defineProperty(b,"__esModule",{value:!0});var C=b.isVisible=void 0;C=b.isVisible=e=>(0!==e.offsetWidth||0!==e.offsetHeight)&&"hidden"!==window.getComputedStyle(e).visibility&&e.offsetTop>=0&&e.offsetLeft>=0&&e.offsetTop<=window.innerHeight&&e.offsetLeft<=window.innerWidth;const E="initial_",L={show:"top",popout:!1,maximise:!1,close:"close-tab-unused"},S={headerHeight:31},_={hasHeaders:!0,reorderEnabled:!0},V={popoutWholeStack:!1,constrainDragToContainer:!1,constrainDragToHeaders:!1,preventDragout:!1,showMaximiseIcon:!1,showPopoutIcon:!1,showCloseIcon:!1,blockedPopoutsThrowError:!0,closePopoutsOnUnload:!0,selectionEnabled:!1};var M,N;class A{constructor(t){this.layout=t,M.set(this,void 0),N.set(this,void 0),this.handleResize=e=>{e.forEach((e=>{const t=this.layout.viewComponentsByContainerElement.get(e.target);t&&t.resize(t.container.element.getBoundingClientRect())}))},this.handleMutation=()=>{const e=document.body.classList.contains("lm_dragging");this.layout.viewComponentsByContainerElement.forEach((t=>{const i=t.container.tab.element;i&&i.className.includes("lm_dragging")&&t.hide(),e?this.layout.handleDragStart():this.layout.handleDragEnd()}))},e.__classPrivateFieldSet(this,M,new ResizeObserver(this.handleResize),"f"),e.__classPrivateFieldSet(this,N,new MutationObserver(this.handleMutation),"f")}observeDragging(){const t=this.layout.layout.rootItem;if(!t)throw new Error("Root item not found in layout.");e.__classPrivateFieldGet(this,N,"f")?.observe(t.element,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]})}destroy(){e.__classPrivateFieldGet(this,M,"f").disconnect(),e.__classPrivateFieldGet(this,N,"f").disconnect()}observeContainer(t){e.__classPrivateFieldGet(this,M,"f").observe(t)}unobserveContainer(t){e.__classPrivateFieldGet(this,M,"f").unobserve(t)}}function $(e=[],t){for(const i of e)"component"===i.type?Object.keys(t).forEach((e=>{e in i&&(i.componentState={[`${E}${e}`]:i[e],...i.componentState}),i[e]=t[e]})):$(i.content,t)}function P(e=[],t,i){for(const o of e)if("component"===o.type)Object.keys(t).forEach((e=>{if(`${E}${e}`in o.componentState)return o[e]=o.componentState[`${E}${e}`],void delete o.componentState[`${E}${e}`];o[e]=t[e]}));else{if(o.size&&("row"===i||"column"===i)){o["row"===i?"width":"height"]=o.size?.includes(".")?parseFloat(o.size):parseInt(o.size)}P(o.content,t,o.type)}}function x(e){if(e.root){e.root.content&&P([e.root],{componentName:"view",isClosable:!0});const t=e.root;e.content=[t],delete e.root}return e}M=new WeakMap,N=new WeakMap;const k=t=>class extends t{connectedCallback(){if(!this.name||!this.uuid)throw new Error("<of-view> Name or uuid attribute missing");if(!this.src)throw new Error("<of-view> missing 'src' attribute.");this.#e||(this.#e=document.createElement("iframe"),this.#e.src=this.src,this.#e.style.height="100%",this.#e.style.width="100%",this.#e.style.border="none",this.forceFrameName?this.#e.setAttribute("name",this.forceFrameName):this.#e.setAttribute("name",e.encodeOptions({brokerUrl:this.brokerUrl,name:this.name,uuid:this.uuid,providerId:this.providerId,contextGroup:this.contextGroup},"of-frame")),this.#e.setAttribute("id",this.name),this.appendChild(this.#e))}#e;get brokerUrl(){return this.getAttribute("of-broker")}set brokerUrl(e){e&&this.setAttribute("of-broker",e)}get name(){return this.getAttribute("of-name")}set name(e){e&&this.setAttribute("of-name",e)}get forceFrameName(){return this.getAttribute("forceFrameName")}set forceFrameName(e){e&&this.setAttribute("forceFrameName",e)}get uuid(){return this.getAttribute("of-uuid")}set uuid(e){e&&this.setAttribute("of-uuid",e)}get src(){return this.getAttribute("src")}set src(e){e&&this.setAttribute("src",e)}get providerId(){return this.getAttribute("of-provider-id")}set providerId(e){e&&this.setAttribute("of-provider-id",e)}get contextGroup(){return this.getAttribute("of-context-group")}set contextGroup(e){e&&this.setAttribute("of-context-group",e)}static get observedAttributes(){return["name"]}};class F{static create(e){const t=document.createElement("of-view");return Object.entries(e).forEach((([e,i])=>{t.setAttribute(e,i)})),t}}customElements.define("of-view",k(HTMLElement));class I{constructor(e,t,o,{brokerUrl:n,interopConfig:s},a){this.container=e,this.config=t,this.ofView=null;const{url:r,web:l,interop:c}=t||{},u=`internal-generated-view-${i.v4()}`;if(this.identity={uuid:o,name:u},this.container.element.setAttribute("of-name",u),this.container.element.id=`container-${u}`,void 0===r)return void this.handleUrlMissing();const h=this.updateTitleIfNotSet(r),d={"of-broker":n,"of-uuid":o,"of-name":u,src:r};l?.frameName&&(d.forceFrameName=l.frameName);const m=c?.currentContextGroup??s?.currentContextGroup;m&&(d["of-context-group"]=m),s?.providerId&&(d["of-provider-id"]=s?.providerId),this.ofView=F.create(d),this.ofView.title=h??`Iframe: ${r}`,a.appendChild(this.ofView),this.ofView.style.position="absolute"}updateTitleIfNotSet(e){return"view"===this.container.parent.title&&this.container.parent.setTitle(e),this.container.parent.title}handleUrlMissing(){const e=document.createElement("div");e.setAttribute("style","padding: 20px");e.innerText="No URL provided",this.container.element.appendChild(e)}destroy(){this.ofView?.remove(),this.ofView=null}resize(e){this.ofView&&(this.ofView.style.position="absolute",this.ofView.style.height=`${e.height}px`,this.ofView.style.width=`${e.width}px`,this.ofView.style.inset=`${e.top}px ${e.right}px ${e.bottom}px ${e.left}px`,this.ofView.style.display="block")}hide(){this.ofView&&(this.ofView.style.display="none")}}class T extends w{static overrideConfig(e){const t={..._,...e.settings,...V};return t.reorderEnabled?$(e.content,{isClosable:!0}):$(e.content,{reorderEnabled:!1}),{dimensions:S,...e,settings:t,header:{...L,show:!1!==e.settings?.hasHeaders&&L.show}}}constructor(e,i,o,{options:n}){super(),this.identity=e,this.container=i,this.initialConfig=o,this.viewComponentsByContainerElement=new Map,this.createViewComponent=(e,t)=>{const i=new I(e,t,this.identity.uuid,this.options,this.iframeContainer);return t&&!1===t[`${E}isClosable`]&&this.stylesheet.insertRule(`#tab-${i.identity.name} .lm_close_tab { display: none; }`),this.viewComponentsByContainerElement.set(e.element,i),this.resizeController.observeContainer(e.element),i},this.iframeContainer=document.createElement("div"),this.iframeContainer.id=`openfin-layout-iframe-container-${this.identity.layoutName}`,this.domEmitter=new g(i),this.setupStylesheets(),this.layout=new t.GoldenLayout(this.container),this.layout.resizeWithContainerAutomatically=!0,this.options=n,this.layout.registerComponent("view",this.createViewComponent),this.setupListeners(),this.resizeController=new A(this),this.layout.loadLayout(T.overrideConfig(o));const s=document.createElement("div");s.attachShadow({mode:"open",delegatesFocus:!1}).appendChild(this.iframeContainer),this.container.appendChild(s),this.resizeController.observeDragging()}setupStylesheets(){if(this.container.setAttribute("data-openfin-layout-name",this.identity.layoutName),this.stylesheet=new CSSStyleSheet,this.stylesheet.insertRule(".lm_close { display: none; }"),document.adoptedStyleSheets.push(this.stylesheet),this.initialConfig.settings?.preventSplitterResize){const e=`\n [data-openfin-layout-name='${this.identity.layoutName}'] .lm_splitter {\n pointer-events: none;\n }`;this.stylesheet.insertRule(e)}}addView(e){throw new Error("Method not implemented.")}replaceView({viewToReplace:e,newView:t}){throw new Error("Method not implemented.")}replaceLayout(e){throw new Error("Method not implemented.")}closeView(e){throw new Error("Method not implemented.")}applyPreset(e){throw new Error("Method not implemented.")}getCurrentViews(){throw new Error("Method not implemented.")}async getFrameSnapshot(){return x(t.LayoutConfig.fromResolved(this.layout.toConfig()))}isVisible(){return C(this.container)}async onViewDetached(){throw new Error("Method not implemented.")}async destroy(){this.layout.destroy(),this.iframeContainer.remove(),this.resizeController.destroy(),document.adoptedStyleSheets=document.adoptedStyleSheets.filter((e=>e!==this.stylesheet)),this.viewComponentsByContainerElement.clear()}setupListeners(){this.container.addEventListener("mousedown",(e=>{e.target instanceof HTMLElement&&e.target.classList.contains("lm_drag_handle")&&this.handleDragStart()})),this.container.addEventListener("pointerdown",(e=>{if(e.target instanceof HTMLElement&&2===e.button){const t=e.target.classList;["lm_tab","lm_title","lm_splitter","lm_drag_handle"].some((e=>t.contains(e)))&&e.stopPropagation()}}),!0),this.layout.on("tabCreated",(e=>{const t=e.componentItem.container.element.getAttribute("of-name")??i.v4(),o={name:t,uuid:t};e.element.id=`tab-${t}`,this.domEmitter.dispatchLocalEvent("tab-created",o)})),this.layout.on("itemCreated",(({target:e})=>{const t=e;if(!t.isComponent)return;const o=t.element.querySelector("[of-name]")?.getAttribute("of-name")??i.v4(),n={name:o,uuid:o};this.domEmitter.dispatchLocalEvent("container-created",n)})),this.layout.on("itemDestroyed",(e=>{const t=e.target;if(!t.isComponent)return;const i=t.component;this.removeViewComponent(i)}))}handleDragStart(){this.iframeContainer.style.pointerEvents="none"}handleDragEnd(){this.iframeContainer.style.pointerEvents=""}removeViewComponent(e){if(e.config&&!1===e.config[`${E}isClosable`]){const t=[...this.stylesheet.cssRules].findIndex((t=>t.cssText.includes(`#tab-${e.identity.name}`)));this.stylesheet.deleteRule(t)}e.destroy(),this.viewComponentsByContainerElement.delete(e.container.element),this.resizeController.unobserveContainer(e.container.element)}}class j{constructor(e,t,i){this.windowIdentity=e,this.connectConfig=t,this.fallbackContainer=i}async createLayout(e,t){if(!("container"in e)&&!this.fallbackContainer)throw new Error("Container property is not optional in web");const{layout:i,layoutName:o}=e,n=e.container??this.fallbackContainer,s={...this.windowIdentity,layoutName:o},a=new T(s,n,i,this.connectConfig);m.registerLayout(t,o,a),this.fallbackContainer=null}async getLayoutSnapshot(e){return e.getLayoutSnapshot()}async handleLastViewRemoved(e){throw new Error("Method not implemented.")}}var G;const O=e=>e;G=new WeakMap,exports.WebLayoutEntryPoint=class{constructor(t){G.set(this,void 0),this.initLayoutManager=async(t,i,{container:o,layoutManagerOverride:n})=>{const s=n??O,a=new j(i.me,e.__classPrivateFieldGet(this,G,"f"),o);return new(s(m.createClosedConstructor(a)))},this.applyLayoutSnapshot=async(t,i,o)=>{await i.applyLayoutSnapshot(e.__classPrivateFieldGet(this,G,"f").platform.layoutSnapshot)},this.createLayout=async(e,t)=>m.createLayout(e,t),this.destroyLayout=async(e,t)=>m.destroyLayout(e,t),e.__classPrivateFieldSet(this,G,t,"f")}};
|
@@ -1 +1 @@
|
|
1
|
-
"use strict";var e=require("buffer/"),t=require("events"),n=require("lodash"),i=require("uuid");const r=(e,t)=>`${t}<${btoa(JSON.stringify(e))}>`;var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},s={},a={},c={},d={};async function h(e){const t=[];for(const n of e){const e=await n();t.push(e)}return t}Object.defineProperty(d,"__esModule",{value:!0}),d.promiseMapSerial=d.serial=d.promiseMap=d.promisify=void 0,d.promisify=function(e){return(...t)=>new Promise(((n,i)=>{e(...t,((e,t)=>e?i(e):n(t)))}))},d.promiseMap=async function(e,t){return Promise.all(e.map(t))},d.serial=h,d.promiseMapSerial=async function(e,t){return h(e.map(((e,n,i)=>()=>t(e,n,i))))};var l,u=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},p=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(c,"__esModule",{value:!0}),c.Reply=c.EmitterBase=c.Base=void 0;const w=d;class y{constructor(e){this.isNodeEnvironment=()=>"node"===this.wire.environment.type,this.isOpenFinEnvironment=()=>"openfin"===this.wire.environment.type,this.isBrowserEnvironment=()=>"other"===this.wire.environment.type,this.wire=e}get fin(){return this.wire.getFin()}get me(){return this.wire.me}}c.Base=y;c.EmitterBase=class extends y{constructor(e,t,...n){super(e),this.topic=t,l.set(this,void 0),this.eventNames=()=>this.hasEmitter()?this.getOrCreateEmitter().eventNames():[],this.emit=(e,t,...n)=>!!this.hasEmitter()&&this.getOrCreateEmitter().emit(e,t,...n),this.hasEmitter=()=>this.wire.eventAggregator.has(p(this,l,"f")),this.getOrCreateEmitter=()=>this.wire.eventAggregator.getOrCreate(p(this,l,"f")),this.listeners=e=>this.hasEmitter()?this.getOrCreateEmitter().listeners(e):[],this.listenerCount=e=>this.hasEmitter()?this.getOrCreateEmitter().listenerCount(e):0,this.registerEventListener=async(e,t={},n,i)=>{const r={...this.identity,timestamp:t.timestamp||Date.now(),topic:this.topic,type:e},o=this.getOrCreateEmitter();n(o);try{await this.wire.sendAction("subscribe-to-desktop-event",r)}catch(e){throw i(o),this.deleteEmitterIfNothingRegistered(o),e}},this.deregisterEventListener=async(e,t={})=>{if(this.hasEmitter()){const n={...this.identity,timestamp:t.timestamp||Date.now(),topic:this.topic,type:e};await this.wire.sendAction("unsubscribe-to-desktop-event",n).catch((()=>null));return this.getOrCreateEmitter()}return Promise.resolve()},u(this,l,[t,...n],"f"),this.listeners=e=>this.hasEmitter()?this.getOrCreateEmitter().listeners(e):[]}async on(e,t,n){return await this.registerEventListener(e,n,(n=>{n.on(e,t)}),(n=>{n.removeListener(e,t)})),this}async addListener(e,t,n){return this.on(e,t,n)}async once(e,t,n){const i=()=>this.deregisterEventListener(e);return await this.registerEventListener(e,n,(n=>{n.once(e,i),n.once(e,t)}),(n=>{n.removeListener(e,i),n.removeListener(e,t)})),this}async prependListener(e,t,n){return await this.registerEventListener(e,n,(n=>{n.prependListener(e,t)}),(n=>{n.removeListener(e,t)})),this}async prependOnceListener(e,t,n){const i=()=>this.deregisterEventListener(e);return await this.registerEventListener(e,n,(n=>{n.prependOnceListener(e,t),n.once(e,i)}),(n=>{n.removeListener(e,t),n.removeListener(e,i)})),this}async removeListener(e,t,n){const i=await this.deregisterEventListener(e,n);return i&&(i.removeListener(e,t),this.deleteEmitterIfNothingRegistered(i)),this}async deregisterAllListeners(e){const t={...this.identity,type:e,topic:this.topic};if(this.hasEmitter()){const e=this.getOrCreateEmitter(),n=e.listenerCount(t.type),i=[];for(let e=0;e<n;e++)i.push(this.wire.sendAction("unsubscribe-to-desktop-event",t).catch((()=>null)));return await Promise.all(i),e}}async removeAllListeners(e){const t=async e=>{const t=await this.deregisterAllListeners(e);t&&(t.removeAllListeners(e),this.deleteEmitterIfNothingRegistered(t))};if(e)await t(e);else if(this.hasEmitter()){const e=this.getOrCreateEmitter().eventNames();await(0,w.promiseMap)(e,t)}return this}deleteEmitterIfNothingRegistered(e){0===e.eventNames().length&&this.wire.eventAggregator.delete(p(this,l,"f"))}},l=new WeakMap;c.Reply=class{};var f={};Object.defineProperty(f,"__esModule",{value:!0});var g=f.RuntimeError=f.NotSupportedError=f.NotImplementedError=f.NoAckError=f.DuplicateCorrelationError=f.UnexpectedActionError=f.DisconnectedError=void 0;class m extends Error{constructor(e){super(`Expected websocket state OPEN but found ${e}`),this.readyState=e}}f.DisconnectedError=m;class v extends Error{}f.UnexpectedActionError=v;class C extends Error{}f.DuplicateCorrelationError=C;class b extends Error{}f.NoAckError=b;class I extends Error{}f.NotImplementedError=I;class E extends Error{}f.NotSupportedError=E;class x extends Error{constructor(e){const{message:t,name:n,stack:i,...r}=e;super(t),this.name=n||"Error",this.stack=i??this.toString(),Object.keys(r).forEach((e=>{this[e]=r[e]}))}}class A extends Error{static getCallSite(e=0){const t=Error.stackTraceLimit,n=e+1;Error.stackTraceLimit=t+n;const i=Error.prepareStackTrace;Error.prepareStackTrace=(e,t)=>t;const r=(new Error).stack?.slice(n)??[];return Error.prepareStackTrace=i,Error.stackTraceLimit=t,r}static prepareStackTrace(e,t){if("function"==typeof Error.prepareStackTrace)return Error.prepareStackTrace(e,t);let n="";n+=e.name||"Error",n+=`: ${e.message||""}`;for(const e of t)n+=`\n at ${e.toString()}`;return n}constructor(e,t){const{reason:n,error:i}=e;super(n),this.name="RuntimeError",i?.stack&&(this.cause=new x(i)),t&&(this.stack=A.prepareStackTrace(this,t))}}g=f.RuntimeError=A;var P={},M={},O={};Object.defineProperty(O,"__esModule",{value:!0}),O.validateIdentity=void 0,O.validateIdentity=function(e){let t;return"object"==typeof e&&"string"==typeof e.uuid||(t="Not a valid identity object"),t};var _={},S={},R={},F={},j={},L={},k={};Object.defineProperty(k,"__esModule",{value:!0}),k.handleDeprecatedWarnings=void 0;var T;k.handleDeprecatedWarnings=e=>{(e.contentNavigation?.whitelist||e.contentNavigation?.blacklist||e.contentRedirect?.whitelist||e.contentRedirect?.blacklist)&&console.warn("The properties 'whitelist' and 'blacklist' have been marked as deprecated and will be removed in a future version. Please use 'allowlist' and 'denylist'.")};var $={},B={};Object.defineProperty(B,"__esModule",{value:!0}),B.AsyncRetryableLazy=G=B.Lazy=void 0;var G=B.Lazy=class{constructor(e){this.producerFn=e}getValue(){return this.value||(this.value=this.producerFn()),this.value}};B.AsyncRetryableLazy=class{constructor(e){this.producerFn=e}async getValue(){return this.promise||(this.promise=this.producerFn().catch((e=>{throw delete this.promise,e}))),this.promise}};var W={},H={},N={};Object.defineProperty(N,"__esModule",{value:!0}),N.ApiConsumer=void 0;N.ApiConsumer=class{constructor(e){this.strategy=e,this.consume=async e=>(await this.strategy.getExposedFunctions(e)).reduce(((t,n)=>({...t,[n.key]:this.strategy.createFunction(n,e)})),{})}};var D={},U={};Object.defineProperty(U,"__esModule",{value:!0}),U.expose=U.getExposedProperties=void 0;const V=Symbol("exposedProperties");U.getExposedProperties=e=>e[V]||e.prototype[V]||[];U.expose=e=>(t,n,i)=>{t[V]=t[V]||[],t[V].push({key:n,descriptor:i,options:e})},Object.defineProperty(D,"__esModule",{value:!0}),D.ApiExposer=void 0;const z=U;D.ApiExposer=class{constructor(e){this.strategy=e,this.exposeInstance=async(e,t)=>{const n=(0,z.getExposedProperties)(e),i=await Promise.all(n.map((async({key:n,options:i})=>({key:n,options:await this.strategy.exposeFunction(e[n].bind(e),{key:n,options:i,meta:t})}))));await this.strategy.exposeMeta(t,i)}}};var K={},q={},Y={};Object.defineProperty(Y,"__esModule",{value:!0}),Y.ChannelsConsumer=void 0;Y.ChannelsConsumer=class{constructor(e){this.channel=e,this.getExposedFunctions=async e=>{const{id:t}=e,{props:n}=await this.channel.dispatch(`api-meta:${t}`);return n},this.createFunction=e=>(...t)=>{const{action:n}=e.options;return this.channel.dispatch(n,{args:t})}}};var J={};Object.defineProperty(J,"__esModule",{value:!0}),J.ChannelsExposer=void 0;J.ChannelsExposer=class{constructor(e){this.channelProviderOrClient=e,this.exposeFunction=async(e,t)=>{const{key:n,options:i,meta:r}=t,{id:o}=r,s=`${o}.${i?.action||n}`;return await this.channelProviderOrClient.register(s,(async({args:t})=>e(...t))),{action:s}},this.exposeMeta=async({id:e},t)=>{const n=`api-meta:${e}`;await this.channelProviderOrClient.register(n,(()=>({props:t})))}}},function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(Y,e),n(J,e)}(q),function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(q,e)}(K),function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(N,e),n(D,e),n(K,e),n(U,e)}(H);var Z={};Object.defineProperty(Z,"__esModule",{value:!0}),Z.createRelayedDispatch=Z.relayChannelClientApi=void 0;const Q=["no longer connected","RTCDataChannel closed unexpectedly","The client you are trying to dispatch from is disconnected from the target provider"];Z.relayChannelClientApi=async(e,t)=>{e.register(`relay:${t}`,(({action:t,target:n,payload:i})=>e.dispatch(n,t,i))),await Promise.resolve()};Z.createRelayedDispatch=(e,t,n,i)=>async(r,o)=>{try{return await e.dispatch(`relay:${n}`,{action:r,payload:o,target:t})}catch(e){if(s=e.message,Q.some((e=>s.includes(e)))&&i)throw new Error(i);throw e}var s};var X,ee,te,ne=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},ie=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(W,"__esModule",{value:!0}),W.ColumnOrRow=W.TabStack=W.LayoutNode=void 0;const re=H,oe=Z;class se{constructor(e,t){X.set(this,void 0),this.isRoot=()=>ie(this,X,"f").isRoot(this.entityId),this.exists=()=>ie(this,X,"f").exists(this.entityId),this.getParent=async()=>{const e=await ie(this,X,"f").getParent(this.entityId);if(e)return se.getEntity(e,ie(this,X,"f"))},this.createAdjacentStack=async(e,t)=>{const n=await ie(this,X,"f").createAdjacentStack(this.entityId,e,t);return se.getEntity({entityId:n,type:"stack"},ie(this,X,"f"))},this.getAdjacentStacks=async e=>(await ie(this,X,"f").getAdjacentStacks({targetId:this.entityId,edge:e})).map((e=>se.getEntity({type:"stack",entityId:e.entityId},ie(this,X,"f")))),ne(this,X,e,"f"),this.entityId=t}}W.LayoutNode=se,X=new WeakMap,se.newLayoutEntitiesClient=async(e,t,n)=>{const i=(0,oe.createRelayedDispatch)(e,n,"layout-relay","You are trying to interact with a layout component on a window that does not exist or has been destroyed.");return new re.ApiConsumer(new re.ChannelsConsumer({dispatch:i})).consume({id:t})},se.getEntity=(e,t)=>{const{entityId:n,type:i}=e;switch(i){case"column":case"row":return new ce(t,n,i);case"stack":return new ae(t,n);default:throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(e)})`)}};class ae extends se{constructor(e,t){super(e,t),ee.set(this,void 0),this.type="stack",this.getViews=()=>ie(this,ee,"f").getStackViews(this.entityId),this.addView=async(e,t={index:0})=>ie(this,ee,"f").addViewToStack(this.entityId,e,t),this.removeView=async e=>{await ie(this,ee,"f").removeViewFromStack(this.entityId,e)},this.setActiveView=async e=>{await ie(this,ee,"f").setStackActiveView(this.entityId,e)},ne(this,ee,e,"f")}}W.TabStack=ae,ee=new WeakMap;class ce extends se{constructor(e,t,n){super(e,t),te.set(this,void 0),this.getContent=async()=>(await ie(this,te,"f").getContent(this.entityId)).map((e=>se.getEntity(e,ie(this,te,"f")))),ne(this,te,e,"f"),this.type=n}}W.ColumnOrRow=ce,te=new WeakMap;var de={};Object.defineProperty(de,"__esModule",{value:!0}),de.DEFAULT_LAYOUT_KEY=de.LAYOUT_CONTROLLER_ID=void 0,de.LAYOUT_CONTROLLER_ID="layout-entities",de.DEFAULT_LAYOUT_KEY="__default__";var he={};Object.defineProperty(he,"__esModule",{value:!0}),he.WebContents=void 0;const le=c;class ue extends le.EmitterBase{constructor(e,t,n){super(e,n,t.uuid,t.name),this.identity=t,this.entityType=n}capturePage(e){return this.wire.sendAction("capture-page",{options:e,...this.identity}).then((({payload:e})=>e.data))}executeJavaScript(e){return this.wire.sendAction("execute-javascript-in-window",{...this.identity,code:e}).then((({payload:e})=>e.data))}getZoomLevel(){return this.wire.sendAction("get-zoom-level",this.identity).then((({payload:e})=>e.data))}setZoomLevel(e){return this.wire.sendAction("set-zoom-level",{...this.identity,level:e}).then((()=>{}))}navigate(e){return this.wire.sendAction("navigate-window",{...this.identity,url:e}).then((()=>{}))}navigateBack(){return this.wire.sendAction("navigate-window-back",{...this.identity}).then((()=>{}))}async navigateForward(){await this.wire.sendAction("navigate-window-forward",{...this.identity})}stopNavigation(){return this.wire.sendAction("stop-window-navigation",{...this.identity}).then((()=>{}))}reload(e=!1){return this.wire.sendAction("reload-window",{ignoreCache:e,...this.identity}).then((()=>{}))}print(e={}){return this.wire.sendAction("print",{...this.identity,options:e}).then((()=>{}))}findInPage(e,t){return this.wire.sendAction("find-in-page",{...this.identity,searchTerm:e,options:t}).then((({payload:e})=>e.data))}stopFindInPage(e){return this.wire.sendAction("stop-find-in-page",{...this.identity,action:e}).then((()=>{}))}getPrinters(){return this.wire.sendAction("get-printers",{...this.identity}).then((({payload:e})=>e.data))}async focus({emitSynthFocused:e}={emitSynthFocused:!0}){await this.wire.sendAction("focus-window",{emitSynthFocused:e,...this.identity})}async showDeveloperTools(){await this.wire.sendAction("show-developer-tools",this.identity)}async getProcessInfo(){const{payload:{data:e}}=await this.wire.sendAction("get-process-info",this.identity);return e}async getSharedWorkers(){return this.wire.sendAction("get-shared-workers",this.identity).then((({payload:e})=>e.data))}async inspectSharedWorker(){await this.wire.sendAction("inspect-shared-worker",{...this.identity})}async inspectSharedWorkerById(e){await this.wire.sendAction("inspect-shared-worker-by-id",{...this.identity,workerId:e})}async inspectServiceWorker(){await this.wire.sendAction("inspect-service-worker",{...this.identity})}async showPopupWindow(e){if(this.wire.sendAction(`${this.entityType}-show-popup-window`,this.identity).catch((()=>{})),e?.onPopupReady){const t=async({popupName:t})=>{try{const n=this.fin.Window.wrapSync({uuid:this.fin.me.uuid,name:t});await e.onPopupReady(n)}catch(e){throw new Error(`Something went wrong during onPopupReady execution: ${e}`)}};await this.once("popup-ready",t)}const{payload:t}=await this.wire.sendAction("try-create-popup-window",{options:{...e,hasResultCallback:!!e?.onPopupResult,hasReadyCallback:!!e?.onPopupReady},...this.identity}),{data:{willOpen:n,options:i}}=t;n&&await this.fin.Window.create(i.initialOptions);if(e?.onPopupResult){const t=async t=>{await e.onPopupResult((e=>{const{name:t,uuid:n,result:i,data:r}=e,o={identity:{name:t,uuid:n},result:i};return r&&(o.data=r),o})(t))},n=async()=>{await this.removeListener("popup-result",t)};await this.on("popup-result",t),await this.once("popup-teardown",n)}const{payload:r}=await this.wire.sendAction("show-popup-window",{options:i,...this.identity});return r.data}}var pe,we,ye,fe,ge;function me(){return we||(we=1,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(function(){if(T)return L;T=1,Object.defineProperty(L,"__esModule",{value:!0}),L.ViewModule=void 0;const e=c,t=O,n=me(),i=k;class r extends e.Base{async create(e){const{uuid:t}=this.wire.me;if(!e.name||"string"!=typeof e.name)throw new Error("Please provide a name property as a string in order to create a View.");return(0,i.handleDeprecatedWarnings)(e),this.wire.environment.childViews?await this.wire.environment.createChildContent({entityType:"view",options:{...e,uuid:t}}):await this.wire.sendAction("create-view",{...e,uuid:t}),this.wrapSync({uuid:t,name:e.name})}async wrap(e){this.wire.sendAction("view-wrap");const i=(0,t.validateIdentity)(e);if(i)throw new Error(i);return new n.View(this.wire,e)}wrapSync(e){this.wire.sendAction("view-wrap-sync").catch((e=>{}));const i=(0,t.validateIdentity)(e);if(i)throw new Error(i);return new n.View(this.wire,e)}getCurrent(){if(this.wire.sendAction("view-get-current").catch((e=>{})),!this.wire.me.isView)throw new Error("You are not in a View context");const{uuid:e,name:t}=this.wire.me;return this.wrap({uuid:e,name:t})}getCurrentSync(){if(this.wire.sendAction("view-get-current-sync").catch((e=>{})),!this.wire.me.isView)throw new Error("You are not in a View context");const{uuid:e,name:t}=this.wire.me;return this.wrapSync({uuid:e,name:t})}}return L.ViewModule=r,L}(),e),n(function(){if(pe)return $;pe=1;var e,t=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty($,"__esModule",{value:!0}),$.View=void 0;const n=f,i=B,r=W,s=de,a=he,c=Pe();class d extends a.WebContents{constructor(o,a){super(o,a,"view"),this.identity=a,e.set(this,new i.Lazy((()=>this.fin.Platform.wrapSync(this.identity).getClient()))),this.attach=async e=>{await this.wire.sendAction("attach-view",{target:e,...this.identity})},this.destroy=async()=>{await this.wire.sendAction("destroy-view",{...this.identity})},this.show=async()=>{await this.wire.sendAction("show-view",{...this.identity})},this.showAt=async(e,t={})=>{await this.wire.sendAction("show-view-at",{bounds:e,...this.identity,options:t})},this.bringToFront=async()=>{await this.wire.sendAction("bring-view-to-front",{...this.identity})},this.hide=async()=>{await this.wire.sendAction("hide-view",{...this.identity})},this.setBounds=async e=>{await this.wire.sendAction("set-view-bounds",{bounds:e,...this.identity})},this.getBounds=async()=>(await this.wire.sendAction("get-view-bounds",{...this.identity})).payload.data,this.getInfo=async()=>(await this.wire.sendAction("get-view-info",{...this.identity})).payload.data,this.getParentLayout=async()=>{this.wire.sendAction("view-get-parent-layout",{...this.identity}).catch((()=>{}));const n=await this.getCurrentWindow();try{const i=await t(this,e,"f").getValue(),o=await r.LayoutNode.newLayoutEntitiesClient(i,s.LAYOUT_CONTROLLER_ID,n.identity),a=await o.getLayoutIdentityForViewOrThrow(this.identity);return this.fin.Platform.Layout.wrap(a)}catch(e){if(!["No action registered at target for","getLayoutIdentityForViewOrThrow is not a function"].some((t=>e.message.includes(t))))throw e;return this.fin.Platform.Layout.wrap(n.identity)}},this.getOptions=async()=>this.wire.sendAction("get-view-options",{...this.identity}).then((({payload:e})=>e.data)),this.updateOptions=async e=>this.wire.sendAction("update-view-options",{options:e,...this.identity}).then((()=>{})),this.getCurrentWindow=async()=>{const{payload:{data:e}}=await this.wire.sendAction("get-view-window",{...this.identity});return new c._Window(this.wire,e)},this.getCurrentStack=async()=>{this.wire.sendAction("view-get-current-stack").catch((()=>{}));try{const n=await this.getCurrentWindow(),i=await t(this,e,"f").getValue(),o=await r.LayoutNode.newLayoutEntitiesClient(i,s.LAYOUT_CONTROLLER_ID,n.identity),a=await o.getStackByView(this.identity);return r.LayoutNode.getEntity(a,o)}catch(e){throw new n.RuntimeError({reason:"This view does not belong to a stack.",error:e})}},this.triggerBeforeUnload=async()=>(await this.wire.sendAction("trigger-before-unload",{...this.identity})).payload.data,this.bindToElement=async e=>{if(!e)throw new Error("Element not found.");return this.wire.environment.observeBounds(e,(async e=>this.setBounds(e)))}}async focus({emitSynthFocused:e}={emitSynthFocused:!0}){const t=await this.getCurrentWindow();await t.focusedWebViewWasChanged(),await super.focus({emitSynthFocused:e})}}return $.View=d,e=new WeakMap,$}(),e)}(j)),j}function ve(){if(ye)return F;ye=1,Object.defineProperty(F,"__esModule",{value:!0}),F.Application=void 0;const e=c,t=Pe(),n=me();class i extends e.EmitterBase{constructor(e,n){super(e,"application",n.uuid),this.identity=n,this.window=new t._Window(this.wire,{uuid:this.identity.uuid,name:this.identity.uuid})}windowListFromIdentityList(e){const n=[];return e.forEach((e=>{n.push(new t._Window(this.wire,{uuid:e.uuid,name:e.name}))})),n}isRunning(){return this.wire.sendAction("is-application-running",this.identity).then((({payload:e})=>e.data))}async quit(e=!1){try{await this._close(e),await this.wire.sendAction("destroy-application",{force:e,...this.identity})}catch(e){if(!["Remote connection has closed","Could not locate the requested application"].some((t=>e.message.includes(t))))throw e}}async _close(e=!1){try{await this.wire.sendAction("close-application",{force:e,...this.identity})}catch(e){if(!e.message.includes("Remote connection has closed"))throw e}}close(e=!1){return console.warn("Deprecation Warning: Application.close is deprecated Please use Application.quit"),this.wire.sendAction("application-close",this.identity).catch((e=>{})),this._close(e)}getChildWindows(){return this.wire.sendAction("get-child-windows",this.identity).then((({payload:e})=>{const t=[];return e.data.forEach((e=>{t.push({uuid:this.identity.uuid,name:e})})),this.windowListFromIdentityList(t)}))}getManifest(){return this.wire.sendAction("get-application-manifest",this.identity).then((({payload:e})=>e.data))}getParentUuid(){return this.wire.sendAction("get-parent-application",this.identity).then((({payload:e})=>e.data))}getShortcuts(){return this.wire.sendAction("get-shortcuts",this.identity).then((({payload:e})=>e.data))}async getViews(){const{payload:e}=await this.wire.sendAction("application-get-views",this.identity);return e.data.map((e=>new n.View(this.wire,e)))}getZoomLevel(){return this.wire.sendAction("get-application-zoom-level",this.identity).then((({payload:e})=>e.data))}getWindow(){return this.wire.sendAction("application-get-window",this.identity).catch((e=>{})),Promise.resolve(this.window)}registerUser(e,t){return this.wire.sendAction("register-user",{userName:e,appName:t,...this.identity}).then((()=>{}))}removeTrayIcon(){return this.wire.sendAction("remove-tray-icon",this.identity).then((()=>{}))}restart(){return this.wire.sendAction("restart-application",this.identity).then((()=>{}))}run(){return console.warn("Deprecation Warning: Application.run is deprecated Please use fin.Application.start"),this.wire.sendAction("application-run",this.identity).catch((e=>{})),this._run()}_run(e={}){return this.wire.sendAction("run-application",{manifestUrl:this._manifestUrl,opts:e,...this.identity}).then((()=>{}))}scheduleRestart(){return this.wire.sendAction("relaunch-on-close",this.identity).then((()=>{}))}async sendApplicationLog(){const{payload:e}=await this.wire.sendAction("send-application-log",this.identity);return e.data}async setJumpList(e){await this.wire.sendAction("set-jump-list",{config:e,...this.identity})}setTrayIcon(e){return this.wire.sendAction("set-tray-icon",{enabledIcon:e,...this.identity}).then((()=>{}))}setShortcuts(e){return this.wire.sendAction("set-shortcuts",{data:e,...this.identity}).then((()=>{}))}async setShortcutQueryParams(e){await this.wire.sendAction("set-shortcut-query-args",{data:e,...this.identity})}setZoomLevel(e){return this.wire.sendAction("set-application-zoom-level",{level:e,...this.identity}).then((()=>{}))}async setAppLogUsername(e){await this.wire.sendAction("set-app-log-username",{data:e,...this.identity})}getTrayIconInfo(){return this.wire.sendAction("get-tray-icon-info",this.identity).then((({payload:e})=>e.data))}hasTrayIcon(){return this.wire.sendAction("has-tray-icon",this.identity).then((({payload:e})=>e.data))}terminate(){return this.wire.sendAction("terminate-application",this.identity).then((()=>{}))}wait(){return this.wire.sendAction("wait-for-hung-application",this.identity).then((()=>{}))}getInfo(){return this.wire.sendAction("get-info",this.identity).then((({payload:e})=>e.data))}async getProcessInfo(){const{payload:{data:e}}=await this.wire.sendAction("application-get-process-info",this.identity);return e}async setFileDownloadLocation(e){const{name:t}=this.wire.me,n={uuid:this.identity.uuid,name:t};await this.wire.sendAction("set-file-download-location",{...n,downloadLocation:e})}async getFileDownloadLocation(){const{payload:{data:e}}=await this.wire.sendAction("get-file-download-location",this.identity);return e}async showTrayIconPopupMenu(e){const{name:t}=this.wire.me,n={uuid:this.identity.uuid,name:t},{payload:i}=await this.wire.sendAction("show-tray-icon-popup-menu",{...n,options:e});return i.data}async closeTrayIconPopupMenu(){const{name:e}=this.wire.me,t={uuid:this.identity.uuid,name:e};await this.wire.sendAction("close-tray-icon-popup-menu",{...t})}}return F.Application=i,F}function Ce(){return ge||(ge=1,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(function(){if(fe)return R;fe=1,Object.defineProperty(R,"__esModule",{value:!0}),R.ApplicationModule=void 0;const e=c,t=O,n=ve();class i extends e.Base{async wrap(e){this.wire.sendAction("wrap-application").catch((e=>{}));const i=(0,t.validateIdentity)(e);if(i)throw new Error(i);return new n.Application(this.wire,e)}wrapSync(e){this.wire.sendAction("wrap-application-sync").catch((e=>{}));const i=(0,t.validateIdentity)(e);if(i)throw new Error(i);return new n.Application(this.wire,e)}async _create(e){return void 0===e.waitForPageLoad&&(e.waitForPageLoad=!1),void 0===e.autoShow&&void 0===e.isPlatformController&&(e.autoShow=!0),await this.wire.sendAction("create-application",e),this.wrap({uuid:e.uuid})}create(e){return console.warn("Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start"),this.wire.sendAction("application-create").catch((e=>{})),this._create(e)}async start(e){this.wire.sendAction("start-application").catch((e=>{}));const t=await this._create(e);return await this.wire.sendAction("run-application",{uuid:e.uuid}),t}async startManyManifests(e,t){return this.wire.sendAction("run-applications",{applications:e,opts:t}).then((()=>{}))}getCurrent(){return this.wire.sendAction("get-current-application").catch((e=>{})),this.wrap({uuid:this.wire.me.uuid})}getCurrentSync(){return this.wire.sendAction("get-current-application-sync").catch((e=>{})),this.wrapSync({uuid:this.wire.me.uuid})}async startFromManifest(e,t){this.wire.sendAction("application-start-from-manifest").catch((e=>{}));const n=await this._createFromManifest(e);return await n._run(t),n}createFromManifest(e){return console.warn("Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest"),this.wire.sendAction("application-create-from-manifest").catch((e=>{})),this._createFromManifest(e)}_createFromManifest(e){return this.wire.sendAction("get-application-manifest",{manifestUrl:e}).then((({payload:e})=>{const t=e.data.platform?e.data.platform.uuid:e.data.startup_app.uuid;return this.wrap({uuid:t})})).then((t=>(t._manifestUrl=e,t)))}}return R.ApplicationModule=i,R}(),e),n(ve(),e)}(S)),S}he.WebContents=ue;var be={};Object.defineProperty(be,"__esModule",{value:!0}),be.promisifySubscription=void 0;var Ie,Ee,xe;function Ae(){if(Ie)return _;Ie=1,Object.defineProperty(_,"__esModule",{value:!0}),_._Window=void 0;const e=Ce(),t=he,n=me(),i=k,r=be;class o extends t.WebContents{constructor(e,t){super(e,t,"window")}async createWindow(e){this.wire.sendAction("window-create-window",this.identity).catch((e=>{}));const t=await(0,r.promisifySubscription)(this,"fire-constructor-callback");void 0===e.waitForPageLoad&&(e.waitForPageLoad=!1),void 0===e.autoShow&&(e.autoShow=!0),(0,i.handleDeprecatedWarnings)(e);const n=this.wire.environment.createChildContent({entityType:"window",options:e}),[o]=await Promise.all([t.getValue(),n]);let s;const{success:a}=o,c=o.data,{message:d}=c;s=a?{httpResponseCode:c.httpResponseCode,apiInjected:c.apiInjected}:{message:c.message,networkErrorCode:c.networkErrorCode,stack:c.stack};const h={message:d,cbPayload:s,success:a};try{this.getWebWindow().fin.__internal_.openerSuccessCBCalled()}catch(e){}return h.success?this:Promise.reject(h)}getAllFrames(){return this.wire.sendAction("get-all-frames",this.identity).then((({payload:e})=>e.data))}getBounds(){return this.wire.sendAction("get-window-bounds",this.identity).then((({payload:e})=>e.data))}center(){return this.wire.sendAction("center-window",this.identity).then((()=>{}))}blur(){return this.wire.sendAction("blur-window",this.identity).then((()=>{}))}bringToFront(){return this.wire.sendAction("bring-window-to-front",this.identity).then((()=>{}))}animate(e,t){return this.wire.sendAction("animate-window",{transitions:e,options:t,...this.identity}).then((()=>{}))}hide(){return this.wire.sendAction("hide-window",this.identity).then((()=>{}))}close(e=!1){return this.wire.sendAction("close-window",{force:e,...this.identity}).then((()=>{Object.setPrototypeOf(this,null)}))}focusedWebViewWasChanged(){return this.wire.sendAction("focused-webview-changed",this.identity).then((()=>{}))}getNativeId(){return this.wire.sendAction("get-window-native-id",this.identity).then((({payload:e})=>e.data))}async getCurrentViews(){const{payload:e}=await this.wire.sendAction("window-get-views",this.identity);return e.data.map((e=>new n.View(this.wire,e)))}disableFrame(){return console.warn("Function is deprecated; use disableUserMovement instead."),this.wire.sendAction("disable-window-frame",this.identity).then((()=>{}))}disableUserMovement(){return this.wire.sendAction("disable-window-frame",this.identity).then((()=>{}))}enableFrame(){return console.warn("Function is deprecated; use enableUserMovement instead."),this.wire.sendAction("enable-window-frame",this.identity).then((()=>{}))}enableUserMovement(){return this.wire.sendAction("enable-window-frame",this.identity).then((()=>{}))}flash(){return this.wire.sendAction("flash-window",this.identity).then((()=>{}))}stopFlashing(){return this.wire.sendAction("stop-flash-window",this.identity).then((()=>{}))}getInfo(){return this.wire.sendAction("get-window-info",this.identity).then((({payload:e})=>e.data))}async getLayout(e){this.wire.sendAction("window-get-layout",this.identity).catch((e=>{}));const t=await this.getOptions();if(!t.layout&&!t.layoutSnapshot)throw new Error("Window does not have a Layout");return this.fin.Platform.Layout.wrap(e??this.identity)}getOptions(){return this.wire.sendAction("get-window-options",this.identity).then((({payload:e})=>e.data))}getParentApplication(){return this.wire.sendAction("window-get-parent-application",this.identity).catch((e=>{})),Promise.resolve(new e.Application(this.wire,this.identity))}getParentWindow(){return this.wire.sendAction("window-get-parent-window",this.identity).catch((e=>{})),Promise.resolve(new e.Application(this.wire,this.identity)).then((e=>e.getWindow()))}async getSnapshot(e){const t={area:e,...this.identity};console.warn("Window.getSnapshot has been deprecated, please use Window.capturePage");return(await this.wire.sendAction("get-window-snapshot",t)).payload.data}getState(){return this.wire.sendAction("get-window-state",this.identity).then((({payload:e})=>e.data))}getWebWindow(){return this.wire.sendAction("window-get-web-window",this.identity).catch((e=>{})),this.wire.environment.getWebWindow(this.identity)}isMainWindow(){return this.wire.sendAction("window-is-main-window",this.identity).catch((e=>{})),this.me.uuid===this.me.name}isShowing(){return this.wire.sendAction("is-window-showing",this.identity).then((({payload:e})=>e.data))}maximize(){return this.wire.sendAction("maximize-window",this.identity).then((()=>{}))}minimize(){return this.wire.sendAction("minimize-window",this.identity).then((()=>{}))}moveBy(e,t,n){return this.wire.sendAction("move-window-by",{deltaLeft:e,deltaTop:t,positioningOptions:n,...this.identity}).then((()=>{}))}moveTo(e,t,n){return this.wire.sendAction("move-window",{left:e,top:t,positioningOptions:n,...this.identity}).then((()=>{}))}resizeBy(e,t,n,i){return this.wire.sendAction("resize-window-by",{deltaWidth:Math.floor(e),deltaHeight:Math.floor(t),anchor:n,positioningOptions:i,...this.identity}).then((()=>{}))}resizeTo(e,t,n,i){return this.wire.sendAction("resize-window",{width:Math.floor(e),height:Math.floor(t),anchor:n,positioningOptions:i,...this.identity}).then((()=>{}))}restore(){return this.wire.sendAction("restore-window",this.identity).then((()=>{}))}setAsForeground(){return this.wire.sendAction("set-foreground-window",this.identity).then((()=>{}))}setBounds(e,t){return this.wire.sendAction("set-window-bounds",{...e,...this.identity,positioningOptions:t}).then((()=>{}))}show(e=!1){return this.wire.sendAction("show-window",{force:e,...this.identity}).then((()=>{}))}showAt(e,t,n=!1){return this.wire.sendAction("show-at-window",{force:n,left:Math.floor(e),top:Math.floor(t),...this.identity}).then((()=>{}))}updateOptions(e){return this.wire.sendAction("update-window-options",{options:e,...this.identity}).then((()=>{}))}authenticate(e,t){return this.wire.sendAction("window-authenticate",{userName:e,password:t,...this.identity}).then((()=>{}))}async showPopupMenu(e){const{payload:t}=await this.wire.sendAction("show-popup-menu",{options:e,...this.identity});return t.data}async closePopupMenu(){return this.wire.sendAction("close-popup-menu",{...this.identity}).then((()=>{}))}async dispatchPopupResult(e){this.wire.sendAction("window-dispatch-popup-result",this.identity).catch((e=>{})),await this.wire.sendAction("dispatch-popup-result",{data:e,...this.identity})}async print(e={content:"self"}){switch(e.content){case void 0:case"self":return super.print(e);case"screenshot":return this.wire.sendAction("print-screenshot",this.identity).then((()=>{}));case"views":return this.wire.sendAction("print-views",{...this.identity,options:e}).then((()=>{}));default:return}}}return _._Window=o,_}function Pe(){return xe||(xe=1,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(function(){if(Ee)return M;Ee=1,Object.defineProperty(M,"__esModule",{value:!0}),M._WindowModule=void 0;const e=c,t=O,n=Ae();class i extends e.Base{async wrap(e){this.wire.sendAction("window-wrap").catch((e=>{}));const i=(0,t.validateIdentity)(e);if(i)throw new Error(i);return new n._Window(this.wire,e)}wrapSync(e){this.wire.sendAction("window-wrap-sync").catch((e=>{}));const i=(0,t.validateIdentity)(e);if(i)throw new Error(i);return new n._Window(this.wire,e)}create(e){return this.wire.sendAction("create-window").catch((e=>{})),new n._Window(this.wire,{uuid:this.me.uuid,name:e.name}).createWindow(e)}getCurrent(){if(this.wire.sendAction("get-current-window").catch((e=>{})),!this.wire.me.isWindow)throw new Error("You are not in a Window context");const{uuid:e,name:t}=this.wire.me;return this.wrap({uuid:e,name:t})}getCurrentSync(){if(this.wire.sendAction("get-current-window-sync").catch((e=>{})),!this.wire.me.isWindow)throw new Error("You are not in a Window context");const{uuid:e,name:t}=this.wire.me;return this.wrapSync({uuid:e,name:t})}}return M._WindowModule=i,M}(),e),n(Ae(),e)}(P)),P}be.promisifySubscription=async(e,t,n=(()=>!0),i)=>{let r,o,s;const a=new Promise(((e,t)=>{r=e,o=t})),c=e=>{n(e)&&(clearTimeout(s),r(e))};return await e.on(t,c),i&&(s=setTimeout((()=>o(new Error("event timed out"))),i)),a.finally((()=>{e.removeListener(t,c).catch((()=>null))})),{getValue:()=>a}},Object.defineProperty(a,"__esModule",{value:!0}),a.System=void 0;const Me=c,Oe=f,_e=Pe(),Se=t;class Re extends Me.EmitterBase{constructor(e){super(e,"system")}sendExternalProcessRequest(e,t){return new Promise(((n,i)=>{const r="external-process-exited";let o,s,a,c;"function"==typeof t.listener&&(a=e=>{const n=e||{};s={topic:"exited",uuid:n.processUuid||"",exitCode:n.exitCode||0},o===e.processUuid&&(t.listener(s),c.removeListener(r,a))},this.wire.me.name||(this.wire.me.name=this.wire.me.uuid),c=new _e._Window(this.wire,this.wire.me),c.on(r,a)),this.wire.sendAction(e,t).then((({payload:e})=>{o=e.data.uuid,n(e.data),s&&o===s.uuid&&(t.listener(s),c.removeListener(r,a))})).catch((e=>{c&&c.removeListener(r,a),i(e)}))}))}getVersion(){return this.wire.sendAction("get-version").then((({payload:e})=>e.data))}clearCache(e){return this.wire.sendAction("clear-cache",e).then((()=>{}))}deleteCacheOnExit(){return this.wire.sendAction("delete-cache-request").then((()=>{}))}exit(){return this.wire.sendAction("exit-desktop").then((()=>{}))}async fetchManifest(e){const{payload:{data:t}}=await this.wire.sendAction("fetch-manifest",{manifestUrl:e});return t}flushCookieStore(){return this.wire.sendAction("flush-cookie-store").then((()=>{}))}getAllWindows(){return this.wire.sendAction("get-all-windows").then((({payload:e})=>e.data))}getAllApplications(){return this.wire.sendAction("get-all-applications").then((({payload:e})=>e.data))}getCommandLineArguments(){return this.wire.sendAction("get-command-line-arguments").then((({payload:e})=>e.data))}async getCrashReporterState(){const{payload:{data:{diagnosticMode:e,isRunning:t}}}=await this.wire.sendAction("get-crash-reporter-state");return console.warn("diagnosticMode property is deprecated. It will be removed in a future version"),{diagnosticMode:e,diagnosticsMode:e,isRunning:t}}async startCrashReporter(e){const t=e,n={...t,diagnosticMode:t.diagnosticsMode||t.diagnosticMode},{payload:{data:{diagnosticMode:i,isRunning:r}}}=await this.wire.sendAction("start-crash-reporter",n);return{diagnosticMode:i,diagnosticsMode:i,isRunning:r}}getUniqueUserId(){return this.wire.sendAction("get-unique-user-id").then((({payload:e})=>e.data))}getEntityInfo(e,t){return this.wire.sendAction("get-entity-info",{uuid:e,name:t}).then((({payload:e})=>e.data))}getEnvironmentVariable(e){return this.wire.sendAction("get-environment-variable",{environmentVariables:e}).then((({payload:e})=>e.data))}getFocusedWindow(){return this.wire.sendAction("get-focused-window").then((({payload:e})=>e.data))}async isAppCertified(e){const{payload:{data:{certifiedInfo:t}}}=await this.wire.sendAction("is-app-certified",{manifestUrl:e});return t}getInstalledRuntimes(){return this.wire.sendAction("get-installed-runtimes").then((({payload:e})=>e.data.runtimes))}async getInstalledApps(){const{payload:{data:{installedApps:e}}}=await this.wire.sendAction("get-installed-apps");return e}getLog(e){return this.wire.sendAction("view-log",e).then((({payload:e})=>e.data))}getMachineId(){return this.wire.sendAction("get-machine-id").then((({payload:e})=>e.data))}getMinLogLevel(){return this.wire.sendAction("get-min-log-level").then((({payload:e})=>e.data))}getLogList(){return this.wire.sendAction("list-logs").then((({payload:e})=>e.data))}getMonitorInfo(){return this.wire.sendAction("get-monitor-info").then((({payload:e})=>e.data))}getMousePosition(){return this.wire.sendAction("get-mouse-position").then((({payload:e})=>e.data))}getProcessList(){return console.warn("System.getProcessList has been deprecated. Please consider using our new process APIs: Window.getProcessInfo, View.getProcessInfo, Application.getProcessInfo, System.getAllProcessInfo"),this.wire.sendAction("process-snapshot").then((({payload:e})=>e.data))}async getAllProcessInfo(){const{payload:{data:e}}=await this.wire.sendAction("get-all-process-info",this.identity);return e}getProxySettings(){return this.wire.sendAction("get-proxy-settings").then((({payload:e})=>e.data))}getRuntimeInfo(){return this.wire.sendAction("get-runtime-info").then((({payload:e})=>e.data))}getRvmInfo(){return this.wire.sendAction("get-rvm-info").then((({payload:e})=>e.data))}getHostSpecs(){return this.wire.sendAction("get-host-specs").then((({payload:e})=>e.data))}getOSInfo(){return this.wire.sendAction("get-os-info").then((({payload:e})=>e.data))}launchExternalProcess(e){return this.sendExternalProcessRequest("launch-external-process",e)}monitorExternalProcess(e){return this.sendExternalProcessRequest("monitor-external-process",e)}log(e,t){return this.wire.sendAction("write-to-log",{level:e,message:t}).then((()=>{}))}openUrlWithBrowser(e){return this.wire.sendAction("open-url-with-browser",{url:e}).then((()=>{}))}async registerCustomProtocol(e){if("object"!=typeof e)throw new Error("Must provide an object with a `protocolName` property having a string value.");await this.wire.sendAction("register-custom-protocol",e)}async unregisterCustomProtocol(e){await this.wire.sendAction("unregister-custom-protocol",{protocolName:e})}async getCustomProtocolState(e){return this.wire.sendAction("get-custom-protocol-state",{protocolName:e}).then((({payload:e})=>e.data))}releaseExternalProcess(e){return this.wire.sendAction("release-external-process",{uuid:e}).then((()=>{}))}showDeveloperTools(e){return this.wire.sendAction("show-developer-tools",e).then((()=>{}))}terminateExternalProcess(e){return this.wire.sendAction("terminate-external-process",e).then((()=>{}))}updateProxySettings(e){return this.wire.sendAction("update-proxy",e).then((()=>{}))}async downloadAsset(e,t){const n=()=>{};let i=n,r=n;const o=new Promise(((e,t)=>{i=e,r=t}));if("openfin"!==this.wire.environment.type)throw new Oe.NotSupportedError("downloadAsset only supported in an OpenFin Render process");const s=Oe.RuntimeError.getCallSite(),a=this.wire.environment.getNextMessageId().toString(),c=`asset-download-progress-${a}`,d=`asset-download-error-${a}`,h=`asset-download-complete-${a}`,l=e=>{const n={downloadedBytes:e.downloadedBytes,totalBytes:e.totalBytes};t(n)},u=()=>{this.removeListener(c,l)};await Promise.all([this.on(c,l),this.once(d,(e=>{u();const{reason:t,err:n}=e;r(new Oe.RuntimeError({reason:t,error:n},s))})),this.once(h,(()=>{u(),i()}))]);const p=Object.assign(e,{downloadId:a});return await this.wire.sendAction("download-asset",p).catch((e=>{throw u(),e})),o}downloadRuntime(e,t){const n=Oe.RuntimeError.getCallSite();return new Promise(((i,r)=>{if("openfin"!==this.wire.environment.type)return void r(new Oe.NotSupportedError("downloadRuntime only supported in an OpenFin Render process"));const o=this.wire.environment.getNextMessageId().toString(),s=`runtime-download-progress-${o}`,a=`runtime-download-error-${o}`,c=`runtime-download-complete-${o}`,d=e=>{const n={downloadedBytes:e.downloadedBytes,totalBytes:e.totalBytes};t(n)},h=()=>{this.removeListener(s,d)};this.on(s,d),this.once(a,(e=>{h();const{reason:t,err:i}=e;r(new Oe.RuntimeError({reason:t,error:i},n))})),this.once(c,(()=>{h(),i()}));const l=Object.assign(e,{downloadId:o});this.wire.sendAction("download-runtime",l).catch((e=>{h(),r(e)}))}))}downloadPreloadScripts(e){return this.wire.sendAction("download-preload-scripts",{scripts:e}).then((({payload:e})=>e.data))}getAllExternalApplications(){return this.wire.sendAction("get-all-external-applications").then((({payload:e})=>e.data))}getAppAssetInfo(e){return this.wire.sendAction("get-app-asset-info",e).then((({payload:e})=>e.data))}getCookies(e){const t=this.wire.environment.getUrl(),n=Object.assign(e,{url:t});return this.wire.sendAction("get-cookies",n).then((({payload:e})=>e.data))}setMinLogLevel(e){return this.wire.sendAction("set-min-log-level",{level:e}).then((()=>{}))}resolveUuid(e){return this.wire.sendAction("resolve-uuid",{entityKey:e}).then((({payload:e})=>e.data))}executeOnRemote(e,t){return t.requestingIdentity=e,this.wire.ferryAction(t)}readRegistryValue(e,t,n){return this.wire.sendAction("read-registry-value",{rootKey:e,subkey:t,value:n}).then((({payload:e})=>e.data))}registerExternalConnection(e){return this.wire.sendAction("register-external-connection",{uuid:e}).then((({payload:e})=>e.data))}async getServiceConfiguration(e){if("string"!=typeof e.name)throw new Error("Must provide an object with a `name` property having a string value");const{name:t}=e;return this.wire.sendAction("get-service-configuration",{name:t}).then((({payload:e})=>e.data))}async getSystemAppConfig(e){if("string"!=typeof e)throw new Error("Must provide a string value for name of system app");return this.wire.sendAction("get-system-app-configuration",{name:e}).then((({payload:e})=>e.data))}async registerShutdownHandler(e){this.wire.sendAction("system-register-shutdown-handler").catch((e=>{}));const{uuid:t,name:n}=this.wire.me;this.on("system-shutdown",(i=>{e({proceed:()=>{this.wire.environment.raiseEvent("application/system-shutdown-handled",{uuid:t,name:n,topic:"application"})}})}))}runRvmHealthCheck(){return this.wire.sendAction("run-rvm-health-check").then((({payload:e})=>e.data))}async launchManifest(e,t={}){const{subscribe:n,...i}=t,r=i;if(n){const e=new Se.EventEmitter;n(e);const t="app-version-progress",i="runtime-status",o="app-version-complete",s="app-version-error",a=this.wire.environment.getNextMessageId().toString();r.appVersionId=a;const c=[o,t,i,s],d=e=>{const{appVersionId:t,topic:n,type:i,...r}=e;return{...r,type:c.find((e=>i.includes(e)))}},h=t=>{const n=d(t);e.emit(n.type,n)},l=()=>{this.removeListener(`${t}.${a}`,h),this.removeListener(`${i}.${a}`,h),this.removeListener(`${o}.${a}`,h),this.removeListener(`${s}.${a}`,h),this.removeListener(`${o}.${a}`,l),this.removeListener(`${s}.${a}`,l)};await Promise.all([this.on(`${t}.${a}`,h),this.on(`${i}.${a}`,h),this.once(`${o}.${a}`,h),this.once(`${s}.${a}`,h),this.once(`${o}.${a}`,l),this.once(`${s}.${a}`,l)])}return(await this.wire.sendAction("launch-manifest",{manifestUrl:e,opts:r})).payload.data.manifest}async queryPermissionForCurrentContext(e){const t={uuid:this.wire.me.uuid,name:this.wire.me.name};return(await this.wire.sendAction("query-permission-for-current-context",{apiName:e,identity:t})).payload.data}async enableNativeWindowIntegrationProvider(e){const{payload:t}=await this.wire.sendAction("enable-native-window-integration-provider",{permissions:e});return t.data}async registerUsage({data:e,type:t}){await this.wire.sendAction("register-usage",{data:e,type:t})}async getPrinters(){const{payload:e}=await this.wire.sendAction("system-get-printers");return e.data}async updateProcessLoggingOptions(e){await this.wire.sendAction("system-update-process-logging-options",{options:e})}async getDomainSettings(){const{payload:{data:e}}=await this.wire.sendAction("get-domain-settings",this.identity);return e}async setDomainSettings(e){await this.wire.sendAction("set-domain-settings",{domainSettings:e,...this.identity})}}a.System=Re;var Fe={},je={};Object.defineProperty(je,"__esModule",{value:!0}),je.RefCounter=void 0;je.RefCounter=class{constructor(){this.topicRefMap=new Map}incRefCount(e){const t=this.topicRefMap.get(e);let n;if(t){const i=t+1;n=i,this.topicRefMap.set(e,i)}else this.topicRefMap.set(e,1),n=1;return n}decRefCount(e){const t=this.topicRefMap.get(e);let n;if(t){const i=t-1;this.topicRefMap.set(e,i),n=i}else n=-1;return n}actOnFirst(e,t,n){return 1===this.incRefCount(e)?t():n()}actOnLast(e,t,n){return 0===this.decRefCount(e)?t():n()}};var Le={},ke={},Te={};Object.defineProperty(Te,"__esModule",{value:!0}),Te.ChannelBase=Te.ProtectedItems=void 0;const $e=e=>async(t,n,i)=>{const r=await e(t,n,i);return void 0===r?n:r};Te.ProtectedItems=class{constructor(e,t){this.providerIdentity=e,this.close=t}};class Be{static defaultAction(e){throw new Error(`No action registered at target for ${e}`)}constructor(){this.subscriptions=new Map}async processAction(e,t,n){try{const i=this.subscriptions.has(e)?this.subscriptions.get(e):(t,n)=>(this.defaultAction??Be.defaultAction)(e,t,n),r=this.preAction?await this.preAction(e,t,n):t,o=await i(r,n);return this.postAction?await this.postAction(e,o,n):o}catch(t){if(this.errorMiddleware)return this.errorMiddleware(e,t,n);throw t}}beforeAction(e){if(this.preAction)throw new Error("Already registered beforeAction middleware");this.preAction=$e(e)}onError(e){if(this.errorMiddleware)throw new Error("Already registered error middleware");this.errorMiddleware=e}afterAction(e){if(this.postAction)throw new Error("Already registered afterAction middleware");this.postAction=$e(e)}remove(e){this.subscriptions.delete(e)}setDefaultAction(e){if(this.defaultAction)throw new Error("default action can only be set once");this.defaultAction=e}register(e,t){if(this.subscriptions.has(e))throw new Error(`Subscription already registered for action: ${e}. Unsubscribe before adding new subscription`);return this.subscriptions.set(e,t),!0}}Te.ChannelBase=Be;var Ge,We,He,Ne=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},De=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n};Object.defineProperty(ke,"__esModule",{value:!0}),ke.ChannelClient=void 0;const Ue=Te,Ve=new Map;class ze extends Ue.ChannelBase{static closeChannelByEndpointId(e){const t=Ve.get(e);t&&Ne(t,He,"f").call(t)}static handleProviderDisconnect(e){for(const t of Ve.values())t.providerIdentity.channelId===e.channelId&&(t.disconnectListener(e),Ne(t,He,"f").call(t))}constructor(e,t,n){super(),Ge.set(this,void 0),We.set(this,void 0),this.processAction=(e,t,n)=>super.processAction(e,t,n),He.set(this,(()=>{Ve.delete(this.endpointId),Ne(this,We,"f").close()})),De(this,Ge,new Ue.ProtectedItems(e,t),"f"),this.disconnectListener=()=>{},this.endpointId=e.endpointId,De(this,We,n,"f"),Ve.set(this.endpointId,this),n.receive(this.processAction)}get providerIdentity(){return Ne(this,Ge,"f").providerIdentity}async dispatch(e,t){if(Ne(this,We,"f").isEndpointConnected(this.providerIdentity.channelId))return Ne(this,We,"f").send(this.providerIdentity.channelId,e,t);throw new Error("The client you are trying to dispatch from is disconnected from the target provider.")}onDisconnection(e){this.disconnectListener=t=>{try{e(t)}catch(e){throw new Error(`Error while calling the onDisconnection callback: ${e.message}`)}finally{this.disconnectListener=()=>{}}}}async disconnect(){await this.sendDisconnectAction(),Ne(this,He,"f").call(this)}async sendDisconnectAction(){const e=Ne(this,Ge,"f");await e.close()}static async wireClose(e,t,n){const{channelName:i,uuid:r,name:o}=t;await e.sendAction("disconnect-from-channel",{channelName:i,uuid:r,name:o,endpointId:n})}}ke.ChannelClient=ze,Ge=new WeakMap,We=new WeakMap,He=new WeakMap;var Ke={},qe={};Object.defineProperty(qe,"__esModule",{value:!0}),qe.exhaustiveCheck=void 0,qe.exhaustiveCheck=function(e,t){throw new Error(`Unsupported value: ${e}${t?`\n Supported values are: ${t.join("")}`:""}`)};var Ye,Je,Ze,Qe={},Xe=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},et=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.ClassicInfo=Qe.ClassicStrategy=void 0;Qe.ClassicStrategy=class{constructor(e,t,n,i){this.messageReceiver=t,this.endpointId=n,this.providerIdentity=i,Ye.set(this,void 0),Je.set(this,new Map),Ze.set(this,new Map),this.send=async(e,t,n)=>{const i=et(this,Je,"f").get(e);if(!i)throw new Error(`Could not locate routing info for endpoint ${e}`);const r={...i};r.isLocalEndpointId&&delete r.endpointId,delete r.isLocalEndpointId;const o=et(this,Ye,"f").sendAction("send-channel-message",{...r,providerIdentity:this.providerIdentity,action:t,payload:n});et(this,Ze,"f").get(e)?.add(o);return(await o.catch((e=>{throw new Error(e.message)})).finally((()=>{et(this,Ze,"f").get(e)?.delete(o)}))).payload.data.result},this.close=async()=>{this.messageReceiver.removeEndpoint(this.providerIdentity.channelId,this.endpointId),[...et(this,Je,"f").keys()].forEach((e=>this.closeEndpoint(e))),Xe(this,Je,new Map,"f")},Xe(this,Ye,e,"f")}onEndpointDisconnect(e,t){}receive(e){this.messageReceiver.addEndpoint(e,this.providerIdentity.channelId,this.endpointId)}async closeEndpoint(e){const t=et(this,Je,"f").get(e);et(this,Je,"f").delete(e);const n=et(this,Ze,"f").get(e);n?.forEach((n=>{const i=`Channel connection with identity uuid: ${t?.uuid} / name: ${t?.name} / endpointId: ${e} no longer connected.`;n.cancel(new Error(i))}))}isEndpointConnected(e){return et(this,Je,"f").has(e)}addEndpoint(e,t){et(this,Je,"f").set(e,t.endpointIdentity),et(this,Ze,"f").set(e,new Set)}isValidEndpointPayload(e){return"string"==typeof e?.endpointIdentity?.endpointId||"string"==typeof e?.endpointIdentity?.channelId}},Ye=new WeakMap,Je=new WeakMap,Ze=new WeakMap,Qe.ClassicInfo={version:5,minimumVersion:0,type:"classic"};var tt={},nt={},it={};Object.defineProperty(it,"__esModule",{value:!0}),it.errorToPOJO=void 0,it.errorToPOJO=function(e){return{stack:e.stack,name:e.name,message:e.message,toString:()=>e.stack||e.toString()}};var rt,ot,st=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},at=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n};Object.defineProperty(nt,"__esModule",{value:!0}),nt.RTCEndpoint=void 0;const ct=it;nt.RTCEndpoint=class{static isValidEndpointPayload(e){const t=e=>"object"==typeof e&&null!==e;return t(e)&&t(e.endpointIdentity)&&t(e.rtc)&&"string"==typeof e.endpointIdentity.endpointId}constructor({rtc:e,endpointIdentity:t}){this.responseMap=new Map,rt.set(this,null),ot.set(this,void 0),this.connectionStateChangeHandler=e=>{"connected"!==this.rtc.rtcClient.connectionState&&(this.rtc.rtcClient.removeEventListener("connectionstatechange",this.connectionStateChangeHandler),this.close(),st(this,ot,"f")&&st(this,ot,"f").call(this))},this.send=async(e,t)=>{const n=`message-${Math.random()}`,i=new Promise(((e,t)=>{this.responseMap.set(n,{resolve:e,reject:t})}));return this.rtc.channels.request.send(JSON.stringify({action:e,payload:t,messageId:n})),i},this.close=()=>{this.responseMap.forEach((e=>e.reject("Connection has closed."))),this.responseMap=new Map,this.rtc.channels.request.close(),this.rtc.channels.response.close(),this.rtc.rtcClient.close()},this.rtc=e,this.endpointIdentity=t,this.rtc.channels.response.addEventListener("message",(e=>{let{data:t}=e;e.data instanceof ArrayBuffer&&(t=(new TextDecoder).decode(e.data));const{messageId:n,payload:i,success:r,error:o}=JSON.parse(t),{resolve:s,reject:a}=this.responseMap.get(n)??{};s&&a?(this.responseMap.delete(n),r?s(i):a(o)):(console.log("Could not find id in responseMap."),console.log(e))})),this.rtc.channels.request.addEventListener("message",(async e=>{let{data:n}=e;e.data instanceof ArrayBuffer&&(n=(new TextDecoder).decode(e.data));const{messageId:i,action:r,payload:o}=JSON.parse(n);if(st(this,rt,"f"))try{const e=await st(this,rt,"f").call(this,r,o,t);this.rtc.channels.response.send(JSON.stringify({messageId:i,payload:e,success:!0}))}catch(e){"open"===this.rtc.channels.response.readyState&&this.rtc.channels.response.send(JSON.stringify({messageId:i,error:(0,ct.errorToPOJO)(e),success:!1}))}else"open"===this.rtc.channels.response.readyState&&this.rtc.channels.response.send(JSON.stringify({messageId:i,success:!1,error:"Connection not ready."}))})),this.rtc.rtcClient.addEventListener("connectionstatechange",this.connectionStateChangeHandler),Object.values(this.rtc.channels).forEach((e=>{e.onclose=e=>{[...this.responseMap.values()].forEach((e=>e.reject(new Error("RTCDataChannel closed unexpectedly, this is most commonly caused by message size. Note: RTC Channels have a message size limit of ~255kB.")))),this.close(),st(this,ot,"f")&&st(this,ot,"f").call(this)}}))}onDisconnect(e){if(st(this,ot,"f"))throw new Error("RTCEndpoint disconnectListener cannot be set twice.");at(this,ot,e,"f")}receive(e){if(st(this,rt,"f"))throw new Error("You have already set a listener for this RTC Endpoint.");at(this,rt,e,"f")}get connected(){return"connected"===this.rtc.rtcClient.connectionState}},rt=new WeakMap,ot=new WeakMap;var dt,ht,lt,ut={},pt=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},wt=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n};Object.defineProperty(ut,"__esModule",{value:!0}),ut.EndpointStrategy=void 0;ut.EndpointStrategy=class{constructor(e,t,n){this.EndpointType=e,this.StrategyName=n,dt.set(this,null),ht.set(this,new Map),lt.set(this,!0),this.send=async(e,t,n)=>this.getEndpointById(e).send(t,n),this.close=async()=>{pt(this,lt,"f")&&(pt(this,ht,"f").forEach((e=>e.close())),wt(this,ht,new Map,"f")),wt(this,lt,!1,"f")},this.isValidEndpointPayload=t}onEndpointDisconnect(e,t){this.getEndpointById(e).onDisconnect(t)}receive(e){if(pt(this,dt,"f"))throw new Error(`You have already set a listener for this ${this.StrategyName} Strategy`);wt(this,dt,e,"f"),pt(this,ht,"f").forEach((e=>e.receive(pt(this,dt,"f"))))}getEndpointById(e){const t=pt(this,ht,"f").get(e);if(!t)throw new Error(`Client with endpoint id ${e} is not connected`);return t}get connected(){return pt(this,lt,"f")}isEndpointConnected(e){return pt(this,ht,"f").has(e)}addEndpoint(e,t){if(!pt(this,lt,"f"))return void console.warn(`Adding endpoint to disconnected ${this.StrategyName} Strategy`);const n=new this.EndpointType(t);pt(this,dt,"f")&&n.receive(pt(this,dt,"f")),pt(this,ht,"f").set(e,n)}async closeEndpoint(e){pt(this,ht,"f").delete(e)}},dt=new WeakMap,ht=new WeakMap,lt=new WeakMap,Object.defineProperty(tt,"__esModule",{value:!0}),tt.RTCInfo=tt.RTCStrategy=void 0;const yt=nt,ft=ut;class gt extends ft.EndpointStrategy{constructor(){super(yt.RTCEndpoint,yt.RTCEndpoint.isValidEndpointPayload,"RTC")}}tt.RTCStrategy=gt,tt.RTCInfo={version:2,minimumVersion:0,type:"rtc"};var mt={};Object.defineProperty(mt,"__esModule",{value:!0}),mt.RTCICEManager=void 0;const vt=c;class Ct extends vt.EmitterBase{constructor(e){super(e,"channel"),this.ensureChannelOpened=e=>new Promise(((t,n)=>{if("open"===e.readyState)t();else if("connecting"===e.readyState){const n=()=>{e.removeEventListener("open",n),t()};e.addEventListener("open",n)}else n(new Error("This Channel has already closed"))}))}static createDataChannelPromise(e,t){let n;const i=new Promise((e=>{n=e})),r=i=>{const o=()=>{i.channel.removeEventListener("open",o),n(i.channel)};i.channel.label===e&&(i.channel.addEventListener("open",o),t.removeEventListener("datachannel",r))};return t.addEventListener("datachannel",r),i}async listenForProviderIce(e,t){await this.on(this.createProviderEventName(e),t,{timestamp:Date.now()})}async raiseProviderIce(e,t){await this.wire.environment.raiseEvent(this.createRouteString(this.createProviderEventName(e)),t)}async listenForClientIce(e,t){await this.on(this.createClientEventName(e),t,{timestamp:Date.now()})}async raiseClientIce(e,t){await this.wire.environment.raiseEvent(this.createRouteString(this.createClientEventName(e)),t)}cleanupIceListeners(e){this.removeAllListeners(this.createClientEventName(e)),this.removeAllListeners(this.createProviderEventName(e))}createClientEventName(e){return`ice-client-${e}`}createProviderEventName(e){return`ice-provider-${e}`}createRouteString(e){return`channel/${e}`}createRtcPeer(){return this.wire.environment.getRtcPeer()}async startClientOffer(){const e=Math.random().toString(),t=this.createRtcPeer();t.addEventListener("icecandidate",(async t=>{t.candidate&&await this.raiseClientIce(e,{candidate:t.candidate?.toJSON()})})),await this.listenForProviderIce(e,(async e=>{await t.addIceCandidate(e.candidate)}));const n={request:t.createDataChannel("request"),response:t.createDataChannel("response")},i=await t.createOffer();await t.setLocalDescription(i);const r=Promise.all([n.request,n.response].map(this.ensureChannelOpened)).then((()=>{}));return{rtcClient:t,channels:n,offer:i,rtcConnectionId:e,channelsOpened:r}}async finishClientOffer(e,t,n){return await e.setRemoteDescription(t),await n,!0}async createProviderAnswer(e,t){const n=this.createRtcPeer(),i=Ct.createDataChannelPromise("request",n),r=Ct.createDataChannelPromise("response",n);n.addEventListener("icecandidate",(async t=>{t.candidate&&await this.raiseProviderIce(e,{candidate:t.candidate?.toJSON()})})),await this.listenForClientIce(e,(async e=>{await n.addIceCandidate(e.candidate)})),await n.setRemoteDescription(t);const o=await n.createAnswer();await n.setLocalDescription(o);const s=Promise.all([i,r]).then((([t,n])=>(this.cleanupIceListeners(e),{request:t,response:n})));return{rtcClient:n,answer:o,channels:s}}}mt.RTCICEManager=Ct;var bt={},It={};function Et(e){return[...e.split(".").reverse().entries()].reduce(((e,[t,n])=>e+ +n*1e4**t),0)}function xt(e,t){return Et(e)>=Et(t)}function At(e){return e.split("/")[0]}Object.defineProperty(It,"__esModule",{value:!0}),It.runtimeUuidMeetsMinimumRuntimeVersion=It.parseRuntimeUuid=It.meetsMinimumRuntimeVersion=void 0,It.meetsMinimumRuntimeVersion=xt,It.parseRuntimeUuid=At,It.runtimeUuidMeetsMinimumRuntimeVersion=function(e,t){return xt(At(e),t)};var Pt,Mt,Ot,_t,St,Rt=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},Ft=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n};Object.defineProperty(bt,"__esModule",{value:!0}),bt.ChannelProvider=void 0;const jt=Te,Lt=It;class kt extends jt.ChannelBase{get connections(){return[...Rt(this,Pt,"f")]}static handleClientDisconnection(e,t){const n=e.connections.find((e=>e.endpointId===t.endpointId));if(n)Rt(e,_t,"f").call(e,n);else{e.connections.filter((e=>e.uuid===t.uuid&&e.name===t.name)).forEach(Rt(e,_t,"f"))}e.disconnectListener(t)}static setProviderRemoval(e,t){kt.removalMap.set(e,t)}constructor(e,t,n){super(),Pt.set(this,void 0),Mt.set(this,void 0),Ot.set(this,void 0),_t.set(this,(e=>{const t=this.connections.filter((t=>t.endpointId!==e.endpointId));Rt(this,Ot,"f").closeEndpoint(e.endpointId),Ft(this,Pt,t,"f")})),this.processAction=async(e,t,n)=>(kt.clientIsMultiRuntime(n)&&!(0,Lt.runtimeUuidMeetsMinimumRuntimeVersion)(n.runtimeUuid,"18.87.56.0")?this.handleMultiRuntimeLegacyClient(n):this.checkForClientConnection(n),super.processAction(e,t,n)),St.set(this,(()=>{Rt(this,Ot,"f").close();const e=kt.removalMap.get(this);e&&e()})),Ft(this,Mt,new jt.ProtectedItems(e,t),"f"),this.connectListener=()=>{},this.disconnectListener=()=>{},Ft(this,Pt,[],"f"),Ft(this,Ot,n,"f"),n.receive(this.processAction)}dispatch(e,t,n){const i=e.endpointId??this.getEndpointIdForOpenFinId(e,t);return i&&Rt(this,Ot,"f").isEndpointConnected(i)?Rt(this,Ot,"f").send(i,t,n):Promise.reject(new Error(`Client connection with identity uuid: ${e.uuid} / name: ${e.name} / endpointId: ${i} no longer connected.`))}async processConnection(e,t){return Rt(this,Pt,"f").push(e),this.connectListener(e,t)}publish(e,t){return this.connections.map((n=>Rt(this,Ot,"f").send(n.endpointId,e,t)))}onConnection(e){this.connectListener=e}onDisconnection(e){this.disconnectListener=e}async destroy(){const e=Rt(this,Mt,"f");e.providerIdentity,Ft(this,Pt,[],"f"),await e.close(),Rt(this,St,"f").call(this)}async getAllClientInfo(){return this.connections.map((e=>{const{uuid:t,name:n,endpointId:i,entityType:r,connectionUrl:o}=e;return{uuid:t,name:n,endpointId:i,entityType:r,connectionUrl:o}}))}checkForClientConnection(e){if(!this.isClientConnected(e))throw new Error(`This action was sent from a client that is not connected to the provider.\n Client Identity: {uuid: ${e.uuid}, name: ${e.name}, endpointId: ${e.endpointId}}`)}isClientConnected(e){return kt.clientIdentityIncludesEndpointId(e)?this.connections.some((t=>t.endpointId===e.endpointId&&t.uuid===e.uuid&&t.name===e.name)):this.isLegacyClientConnected(e)}isLegacyClientConnected(e){return this.connections.some((t=>t.uuid===e.uuid&&t.name===e.name))}handleMultiRuntimeLegacyClient(e){if(!this.isLegacyClientConnected(e))throw new Error(`This action was sent from a client that is not connected to the provider. Client Identity:\n {uuid: ${e.uuid}, name: ${e.name}, endpointId: ${e.endpointId}}`)}getEndpointIdForOpenFinId(e,t){const n=this.connections.filter((t=>t.name===e.name&&t.uuid===e.uuid));if(n.length>=2){const n=Rt(this,Mt,"f"),{uuid:i,name:r}=e,o=n?.providerIdentity.uuid,s=n?.providerIdentity.name;console.warn(`WARNING: Dispatch call may have unintended results. The "to" argument of your dispatch call is missing the\n "endpointId" parameter. The identity you are dispatching to ({uuid: ${i}, name: ${r}})\n has multiple channelClients for this channel. Your dispatched action: (${t}) from the provider:\n ({uuid: ${o}, name: ${s}}) will only be processed by the most recently-created client.`)}return n.pop()?.endpointId}static clientIdentityIncludesEndpointId(e){return void 0!==e.endpointId}static clientIsMultiRuntime(e){return void 0!==e.runtimeUuid}static async wireClose(e,t){await e.sendAction("destroy-channel",{channelName:t})}}bt.ChannelProvider=kt,Pt=new WeakMap,Mt=new WeakMap,Ot=new WeakMap,_t=new WeakMap,St=new WeakMap,kt.removalMap=new WeakMap;var Tt={};Object.defineProperty(Tt,"__esModule",{value:!0}),Tt.MessageReceiver=void 0;const $t=ke,Bt=c;class Gt extends Bt.Base{constructor(e){super(e),this.onmessage=e=>"process-channel-message"===e.action&&(this.processChannelMessage(e),!0),this.endpointMap=new Map,this.latestEndpointIdByChannelId=new Map,e.registerMessageHandler(this.onmessage.bind(this))}async processChannelMessage(e){const{senderIdentity:t,providerIdentity:n,action:i,ackToSender:r,payload:o,intendedTargetIdentity:s}=e.payload,a=s.channelId??s.endpointId??this.latestEndpointIdByChannelId.get(n.channelId),c=this.endpointMap.get(a);if(!c)return r.payload.success=!1,r.payload.reason=`Client connection with identity uuid: ${this.wire.me.uuid} / name: ${this.wire.me.name} / endpointId: ${a} no longer connected.`,this.wire.sendRaw(r);try{const e=await c(i,o,t);return r.payload.payload=r.payload.payload||{},r.payload.payload.result=e,this.wire.sendRaw(r)}catch(e){return r.payload.success=!1,r.payload.reason=e.message,this.wire.sendRaw(r)}}addEndpoint(e,t,n){this.endpointMap.set(n,e),t!==n&&this.latestEndpointIdByChannelId.set(t,n)}removeEndpoint(e,t){this.endpointMap.delete(t),this.latestEndpointIdByChannelId.get(e)===t&&this.latestEndpointIdByChannelId.delete(e)}checkForPreviousClientConnection(e){const t=this.latestEndpointIdByChannelId.get(e);t&&($t.ChannelClient.closeChannelByEndpointId(t),console.warn("You have created a second connection to an older provider. First connection has been removed from the clientMap"),console.warn("If the provider calls publish(), you may receive multiple messages."))}}Tt.MessageReceiver=Gt;var Wt={};Object.defineProperty(Wt,"__esModule",{value:!0}),Wt.ProtocolManager=void 0;Wt.ProtocolManager=class{constructor(e){this.ProtocolsInPreferenceOrder=e,this.DefaultClientProtocols=["classic"],this.DefaultProviderProtocols=["classic"],this.getClientProtocols=e=>{const t=e?this.ProtocolsInPreferenceOrder.filter((t=>e.includes(t))):this.DefaultClientProtocols;if(!t.length)throw new Error(`No valid protocols were passed in. Accepted values are: ${this.ProtocolsInPreferenceOrder.join(", ")}.`);return t},this.getProviderProtocols=e=>{const t=e?this.ProtocolsInPreferenceOrder.filter((t=>e.includes(t))):this.DefaultProviderProtocols;if(!t.length)throw new Error(`No valid protocols were passed in. Accepted values are: ${this.ProtocolsInPreferenceOrder.join(", ")}.`);return t},this.getCompatibleProtocols=(e,t)=>t.supportedProtocols.filter((t=>e.some((e=>e.type===t.type&&t.version>=e.minimumVersion&&e.version>=(t.minimumVersion??0))))).slice(0,t.maxProtocols)}};var Ht={};Object.defineProperty(Ht,"__esModule",{value:!0});class Nt{static combine(e,t){return new Nt(e,t)}constructor(e,t){this.primary=e,this.secondary=t}onEndpointDisconnect(e,t){this.primary.onEndpointDisconnect(e,(()=>{this.secondary.isEndpointConnected(e)||t()})),this.secondary.onEndpointDisconnect(e,(()=>{this.primary.isEndpointConnected(e)||t()}))}isValidEndpointPayload(e){return this.primary.isValidEndpointPayload(e)||this.secondary.isValidEndpointPayload(e)}async closeEndpoint(e){await this.primary.closeEndpoint(e),await this.secondary.closeEndpoint(e)}isEndpointConnected(e){return this.primary.isEndpointConnected(e)||this.secondary.isEndpointConnected(e)}async addEndpoint(e,t){this.primary.isValidEndpointPayload(t)&&await this.primary.addEndpoint(e,t),this.secondary.isValidEndpointPayload(t)&&await this.secondary.addEndpoint(e,t)}receive(e){this.primary.receive(e),this.secondary.receive(e)}send(e,t,n){return this.primary.isEndpointConnected(e)?this.primary.send(e,t,n):this.secondary.send(e,t,n)}async close(){await Promise.all([this.primary.close(),this.secondary.close()])}}Ht.default=Nt;var Dt,Ut,Vt=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},zt=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.ConnectionManager=void 0;const Kt=qe,qt=c,Yt=Qe,Jt=tt,Zt=mt,Qt=bt,Xt=Tt,en=Wt,tn=Ht;class nn extends qt.Base{static getProtocolOptionsFromStrings(e){return e.map((e=>{switch(e){case"rtc":return Jt.RTCInfo;case"classic":return Yt.ClassicInfo;default:return(0,Kt.exhaustiveCheck)(e,["rtc","classic"])}}))}constructor(e){super(e),Dt.set(this,void 0),Ut.set(this,void 0),this.removeChannelFromProviderMap=e=>{this.providerMap.delete(e)},this.onmessage=e=>"process-channel-connection"===e.action&&(this.processChannelConnection(e),!0),this.providerMap=new Map,this.protocolManager=new en.ProtocolManager("node"===this.wire.environment.type?["classic"]:["rtc","classic"]),Vt(this,Dt,new Xt.MessageReceiver(e),"f"),Vt(this,Ut,new Zt.RTCICEManager(e),"f"),e.registerMessageHandler(this.onmessage.bind(this))}createProvider(e,t){const n=Object.assign(this.wire.environment.getDefaultChannelOptions().create,e||{}),i=this.protocolManager.getProviderProtocols(n?.protocols),r=i.map((e=>{switch(e){case"rtc":return new Jt.RTCStrategy;case"classic":return new Yt.ClassicStrategy(this.wire,zt(this,Dt,"f"),t.channelId,t);default:return(0,Kt.exhaustiveCheck)(e,["rtc","classic"])}}));let o;if(2===r.length){const[e,t]=r;o=tn.default.combine(e,t)}else{if(1!==r.length)throw new Error("failed to combine strategies");[o]=r}const s=new Qt.ChannelProvider(t,(()=>Qt.ChannelProvider.wireClose(this.wire,t.channelName)),o),a=t.channelId;return this.providerMap.set(a,{provider:s,strategy:o,supportedProtocols:nn.getProtocolOptionsFromStrings(i)}),Qt.ChannelProvider.setProviderRemoval(s,this.removeChannelFromProviderMap.bind(this)),s}async createClientOffer(e){const t=this.protocolManager.getClientProtocols(e?.protocols);let n;return{offer:{supportedProtocols:await Promise.all(t.map((async e=>{switch(e){case"rtc":{const{rtcClient:e,channels:t,offer:i,rtcConnectionId:r,channelsOpened:o}=await zt(this,Ut,"f").startClientOffer();return n={rtcClient:e,channels:t,channelsOpened:o},{type:"rtc",version:Jt.RTCInfo.version,payload:{offer:i,rtcConnectionId:r}}}case"classic":return{type:"classic",version:Yt.ClassicInfo.version};default:return(0,Kt.exhaustiveCheck)(e,["rtc","classic"])}}))),maxProtocols:2},rtc:n}}async createClientStrategy(e,t){t.endpointId||(t.endpointId=this.wire.environment.getNextMessageId(),zt(this,Dt,"f").checkForPreviousClientConnection(t.channelId));const n=t.answer??{supportedProtocols:[{type:"classic",version:1}]},i=(await Promise.all(n.supportedProtocols.map((async n=>"rtc"===n.type&&e?(await zt(this,Ut,"f").finishClientOffer(e.rtcClient,n.payload.answer,e.channelsOpened),new Jt.RTCStrategy):"classic"===n.type?new Yt.ClassicStrategy(this.wire,zt(this,Dt,"f"),t.endpointId,t):null)))).filter((e=>null!==e));let r;if(e&&!i.some((e=>e instanceof Jt.RTCStrategy))&&e&&e.rtcClient.close(),i.length>=2)r=tn.default.combine(i[0],i[1]);else{if(!i.length)throw new Error("No compatible protocols");[r]=i}const o={endpointIdentity:t,rtc:e};return r.addEndpoint(t.channelId,o),r}async processChannelConnection(e){const{clientIdentity:t,providerIdentity:n,ackToSender:i,payload:r,offer:o}=e.payload;t.endpointId?t.isLocalEndpointId=!1:(t.endpointId=this.wire.environment.getNextMessageId(),t.isLocalEndpointId=!0);const s=n.channelId,a=this.providerMap.get(s);if(!a)return i.payload.success=!1,i.payload.reason=`Channel "${n.channelName}" has been destroyed.`,this.wire.sendRaw(i);const{provider:c,strategy:d,supportedProtocols:h}=a;try{if(!(c instanceof Qt.ChannelProvider))throw Error("Cannot connect to a channel client");const e=o??{supportedProtocols:[{type:"classic",version:1}],maxProtocols:1},n=this.protocolManager.getCompatibleProtocols(h,e);if(!n.length)throw new Error("This provider does not support any of the offered protocols.");const s=await c.processConnection(t,r);i.payload.payload=i.payload.payload||{};let a={supportedProtocols:[],endpointPayloadPromise:Promise.resolve({endpointIdentity:t})};return a=await n.reduce((async(e,t)=>{const n=await e;if("rtc"===t.type){const{answer:e,rtcClient:i,channels:r}=await zt(this,Ut,"f").createProviderAnswer(t.payload.rtcConnectionId,t.payload.offer);n.supportedProtocols.push({type:"rtc",version:Jt.RTCInfo.version,payload:{answer:e}}),n.endpointPayloadPromise=n.endpointPayloadPromise.then((e=>r.then((t=>({...e,rtc:{rtcClient:i,channels:t}})))))}else n.supportedProtocols.push({type:"classic",version:Yt.ClassicInfo.version});return n}),Promise.resolve(a)),a.endpointPayloadPromise.then((e=>d.addEndpoint(t.endpointId,e))),i.payload.payload.result=s,i.payload.payload.answer=a,this.wire.sendRaw(i)}catch(e){return i.payload.success=!1,i.payload.reason=e.message,this.wire.sendRaw(i)}}}Ke.ConnectionManager=nn,Dt=new WeakMap,Ut=new WeakMap;var rn,on,sn,an=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},cn=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(Le,"__esModule",{value:!0}),Le.Channel=void 0;const dn=t,hn=B,ln=c,un=ke,pn=Ke,wn=bt;function yn(e){const t=Math.floor(e/10),n=Math.min(3e4,500*2**t);return new Promise((e=>{setTimeout((()=>{e(!1)}),n)}))}class fn extends ln.EmitterBase{constructor(e){super(e,"channel"),rn.set(this,void 0),on.set(this,new dn.EventEmitter),sn.set(this,new hn.AsyncRetryableLazy((async()=>{await Promise.all([this.on("disconnected",(e=>{un.ChannelClient.handleProviderDisconnect(e)})),this.on("connected",((...e)=>{cn(this,on,"f").emit("connected",...e)}))]).catch((()=>new Error("error setting up channel connection listeners")))}))),an(this,rn,new pn.ConnectionManager(e),"f")}async getAllChannels(){return this.wire.sendAction("get-all-channels").then((({payload:e})=>e.data))}async onChannelConnect(e){await this.on("connected",e)}async onChannelDisconnect(e){await this.on("disconnected",e)}async safeConnect(e,t,n){const i={count:0};do{let r=()=>{};const o=new Promise((t=>{r=n=>{e===n.channelName&&t(!0)},cn(this,on,"f").on("connected",r)}));try{if(i.count>0){i.gotConnectedEvent=await Promise.race([yn(i.count),o]);const t=await this.wire.sendAction("connect-to-channel",{...n,retryInfo:i});return console.log(`Successfully connected to channelName: ${e}`),t.payload.data}const t=this.wire.sendAction("connect-to-channel",n);i.originalMessageId=t.messageId;return(await t).payload.data}catch(n){if(!n.message.includes("internal-nack"))throw n;t&&0===i.count&&console.warn(`No channel found for channelName: ${e}. Waiting for connection...`)}finally{i.count+=1,cn(this,on,"f").removeListener("connected",r)}}while(t);throw new Error(`No channel found for channelName: ${e}.`)}async connect(e,t={}){if(await cn(this,sn,"f").getValue(),!e||"string"!=typeof e)throw new Error("Please provide a channelName string to connect to a channel.");const n={wait:!0,...this.wire.environment.getDefaultChannelOptions().connect,...t},{offer:i,rtc:r}=await cn(this,rn,"f").createClientOffer(n);let o;(this.fin.me.isFrame||this.fin.me.isView||this.fin.me.isWindow)&&(o=(await this.fin.me.getInfo()).url);const s={channelName:e,...n,offer:i,connectionUrl:o},a=await this.safeConnect(e,n.wait,s),c=await cn(this,rn,"f").createClientStrategy(r,a),d=new un.ChannelClient(a,(()=>un.ChannelClient.wireClose(this.wire,a,a.endpointId)),c);return c.onEndpointDisconnect(a.channelId,(async()=>{try{await d.sendDisconnectAction()}catch(e){console.warn(`Something went wrong during disconnect for client with uuid: ${a.uuid} / name: ${a.name} / endpointId: ${a.endpointId}.`)}finally{un.ChannelClient.handleProviderDisconnect(a)}})),d}async create(e,t){if(!e)throw new Error("Please provide a channelName to create a channel");const{payload:{data:n}}=await this.wire.sendAction("create-channel",{channelName:e}),i=cn(this,rn,"f").createProvider(t,n);return this.on("client-disconnected",(t=>{t.channelName===e&&wn.ChannelProvider.handleClientDisconnection(i,t)})),i}}Le.Channel=fn,rn=new WeakMap,on=new WeakMap,sn=new WeakMap,Object.defineProperty(Fe,"__esModule",{value:!0}),Fe.InterAppPayload=Fe.InterApplicationBus=void 0;const gn=t,mn=c,vn=je,Cn=Le,bn=O;class In extends mn.Base{constructor(e){super(e),this.events={subscriberAdded:"subscriber-added",subscriberRemoved:"subscriber-removed"},this.refCounter=new vn.RefCounter,this.Channel=new Cn.Channel(e),this.emitter=new gn.EventEmitter,e.registerMessageHandler(this.onmessage.bind(this)),this.on=this.emitter.on.bind(this.emitter),this.removeAllListeners=this.emitter.removeAllListeners.bind(this.emitter)}async publish(e,t){await this.wire.sendAction("publish-message",{topic:e,message:t,sourceWindowName:this.me.name})}async send(e,t,n){const i=(0,bn.validateIdentity)(e);if(i)throw new Error(i);await this.wire.sendAction("send-message",{destinationUuid:e.uuid,destinationWindowName:e.name,topic:t,message:n,sourceWindowName:this.me.name})}subscribe(e,t,n){const i=this.createSubscriptionKey(e.uuid,e.name||"*",t);return this.emitter.on(i,n),this.refCounter.actOnFirst(i,(async()=>{await this.wire.sendAction("subscribe",{sourceUuid:e.uuid,sourceWindowName:e.name||"*",topic:t,destinationWindowName:this.me.name})}),(()=>Promise.resolve()))}unsubscribe(e,t,n){const i=e.name||"*",r=this.createSubscriptionKey(e.uuid,i,t);return this.emitter.removeListener(r,n),this.refCounter.actOnLast(r,(async()=>{await this.wire.sendAction("unsubscribe",{sourceUuid:e.uuid,sourceWindowName:i,topic:t,destinationWindowName:this.me.name})}),(()=>new Promise((e=>e)).then((()=>{}))))}processMessage(e){const{payload:{message:t,sourceWindowName:n,sourceUuid:i,topic:r}}=e,o=[this.createSubscriptionKey(i,n,r),this.createSubscriptionKey(i,"*",r),this.createSubscriptionKey("*","*",r)],s={uuid:i,name:n};o.forEach((e=>{this.emitter.emit(e,t,s)}))}emitSubscriverEvent(e,t){const{payload:{targetName:n,uuid:i,topic:r}}=t,o={name:n,uuid:i,topic:r};this.emitter.emit(e,o)}createSubscriptionKey(e,t,n){const i=t||"*";if(!(e&&i&&n))throw new Error("Missing uuid, name, or topic string");return function(...e){return e.map((e=>Buffer.from(`${e}`).toString("base64"))).join("/")}(e,i,n)}onmessage(e){const{action:t}=e;switch(t){case"process-message":this.processMessage(e);break;case this.events.subscriberAdded:this.emitSubscriverEvent(this.events.subscriberAdded,e);break;case this.events.subscriberRemoved:this.emitSubscriverEvent(this.events.subscriberRemoved,e)}return!0}}Fe.InterApplicationBus=In;Fe.InterAppPayload=class{};var En={};Object.defineProperty(En,"__esModule",{value:!0}),En.Clipboard=void 0;const xn=c;class An extends xn.Base{async writeText(e){await this.wire.sendAction("clipboard-write-text",e)}async readText(e){const{payload:t}=await this.wire.sendAction("clipboard-read-text",{type:e});return t.data}async writeImage(e){await this.wire.sendAction("clipboard-write-image",e)}async readImage(e={format:"dataURL"}){const{payload:t}=await this.wire.sendAction("clipboard-read-image",e);return t.data}async writeHtml(e){await this.wire.sendAction("clipboard-write-html",e)}async readHtml(e){const{payload:t}=await this.wire.sendAction("clipboard-read-html",{type:e});return t.data}async writeRtf(e){await this.wire.sendAction("clipboard-write-rtf",e)}async readRtf(e){const{payload:t}=await this.wire.sendAction("clipboard-read-rtf",{type:e});return t.data}async write(e){await this.wire.sendAction("clipboard-write",e)}async getAvailableFormats(e){const{payload:t}=await this.wire.sendAction("clipboard-read-formats",{type:e});return t.data}}En.Clipboard=An;var Pn={},Mn={},On={};Object.defineProperty(On,"__esModule",{value:!0}),On.ExternalApplication=void 0;const _n=c;class Sn extends _n.EmitterBase{constructor(e,t){super(e,"external-application",t.uuid),this.identity=t}getInfo(){return this.wire.sendAction("get-external-application-info",this.identity).then((({payload:e})=>e.data))}}On.ExternalApplication=Sn,Object.defineProperty(Mn,"__esModule",{value:!0}),Mn.ExternalApplicationModule=void 0;const Rn=c,Fn=On;class jn extends Rn.Base{wrap(e){return this.wire.sendAction("external-application-wrap").catch((e=>{})),Promise.resolve(new Fn.ExternalApplication(this.wire,{uuid:e}))}wrapSync(e){return this.wire.sendAction("external-application-wrap-sync").catch((e=>{})),new Fn.ExternalApplication(this.wire,{uuid:e})}}Mn.ExternalApplicationModule=jn,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(Mn,e),n(On,e)}(Pn);var Ln={},kn={},Tn={};Object.defineProperty(Tn,"__esModule",{value:!0}),Tn._Frame=void 0;const $n=c;class Bn extends $n.EmitterBase{constructor(e,t){super(e,"frame",t.uuid,t.name),this.identity=t}getInfo(){return this.wire.sendAction("get-frame-info",this.identity).then((({payload:e})=>e.data))}getParentWindow(){return this.wire.sendAction("get-parent-window",this.identity).then((({payload:e})=>e.data))}}Tn._Frame=Bn,Object.defineProperty(kn,"__esModule",{value:!0}),kn._FrameModule=void 0;const Gn=c,Wn=O,Hn=Tn;class Nn extends Gn.Base{async wrap(e){this.wire.sendAction("frame-wrap").catch((e=>{}));const t=(0,Wn.validateIdentity)(e);if(t)throw new Error(t);return new Hn._Frame(this.wire,e)}wrapSync(e){this.wire.sendAction("frame-wrap-sync").catch((e=>{}));const t=(0,Wn.validateIdentity)(e);if(t)throw new Error(t);return new Hn._Frame(this.wire,e)}getCurrent(){return this.wire.sendAction("frame-get-current").catch((e=>{})),Promise.resolve(new Hn._Frame(this.wire,this.wire.environment.getCurrentEntityIdentity()))}getCurrentSync(){return this.wire.sendAction("frame-get-current-sync").catch((e=>{})),new Hn._Frame(this.wire,this.wire.environment.getCurrentEntityIdentity())}}kn._FrameModule=Nn,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(kn,e),n(Tn,e)}(Ln);var Dn={};Object.defineProperty(Dn,"__esModule",{value:!0}),Dn.GlobalHotkey=void 0;const Un=c;class Vn extends Un.EmitterBase{constructor(e){super(e,"global-hotkey")}async register(e,t){await this.on(e,t),await this.wire.sendAction("global-hotkey-register",{hotkey:e})}async unregister(e){await this.removeAllListeners(e),await this.wire.sendAction("global-hotkey-unregister",{hotkey:e})}async unregisterAll(){await Promise.all(this.eventNames().filter((e=>!("registered"===e||"unregistered"===e))).map((e=>this.removeAllListeners(e)))),await this.wire.sendAction("global-hotkey-unregister-all",{})}async isRegistered(e){const{payload:{data:t}}=await this.wire.sendAction("global-hotkey-is-registered",{hotkey:e});return t}}Dn.GlobalHotkey=Vn;var zn,Kn={},qn={},Yn={},Jn=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(Yn,"__esModule",{value:!0}),Yn.Platform=void 0;const Zn=c,Qn=O,Xn=new Map;class ei extends Zn.EmitterBase{constructor(e,t){super(t.wire,"application",e.uuid),this.getClient=e=>{this.wire.sendAction("platform-get-client",this.identity).catch((e=>{}));const t=e||this.identity,{uuid:n}=t;if(!Xn.has(n)){const e=Jn(this,zn,"f").call(this,n);Xn.set(n,e)}return Xn.get(n)},zn.set(this,(async e=>{try{const t=`custom-frame-${e}`,n=await this._channel.connect(t,{wait:!1});return n.onDisconnection((()=>{Xn.delete(e)})),n}catch(t){throw Xn.delete(e),new Error("The targeted Platform is not currently running. Listen for application-started event for the given Uuid.")}})),this.launchLegacyManifest=this.launchContentManifest;const n=(0,Qn.validateIdentity)(e);if(n)throw new Error(n);this._channel=t,this.identity={uuid:e.uuid},this.Layout=this.fin.Platform.Layout,this.Application=this.fin.Application.wrapSync(this.identity)}async createView(e,t,n){this.wire.sendAction("platform-create-view",this.identity).catch((e=>{}));const i=await this.getClient(),r=await i.dispatch("create-view",{target:t,opts:e,targetView:n});if(!r||(0,Qn.validateIdentity)(r.identity))throw new Error(`When overwriting the createView call, please return an object that has a valid 'identity' property: ${JSON.stringify(r)}`);return this.fin.View.wrapSync(r.identity)}async createWindow(e){this.wire.sendAction("platform-create-window",this.identity).catch((e=>{}));const t=await this.getClient();e.reason||(e.reason="api-call");const n=await t.dispatch("create-view-container",e);if(!n||(0,Qn.validateIdentity)(n.identity))throw new Error(`When overwriting the createWindow call, please return an object that has a valid 'identity' property: ${JSON.stringify(n)}`);const{identity:i}=n,r=this.fin.Window.wrapSync(i);return r.name=i.name,r.uuid=i.uuid,r}async quit(){this.wire.sendAction("platform-quit",this.identity).catch((e=>{}));return(await this.getClient()).dispatch("quit")}async closeView(e){this.wire.sendAction("platform-close-view",this.identity).catch((e=>{}));const t=await this.getClient();await t.dispatch("close-view",{view:e})}async reparentView(e,t){console.warn("Platform.reparentView has been deprecated, please use Platform.createView"),this.wire.sendAction("platform-reparent-view",this.identity).catch((e=>{}));const n={...e,uuid:e.uuid??this.identity.uuid},i=await this.fin.View.wrap(n),r=await i.getOptions();return this.createView(r,t)}async getSnapshot(){this.wire.sendAction("platform-get-snapshot",this.identity).catch((e=>{}));return(await this.getClient()).dispatch("get-snapshot")}async getViewSnapshot(e){return(await this.getClient()).dispatch("get-view-snapshot",{viewIdentity:e})}async applySnapshot(e,t){this.wire.sendAction("platform-apply-snapshot",this.identity).catch((e=>{}));const n="Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.";let i;if("string"==typeof e)try{i=(await this._channel.wire.sendAction("get-application-manifest",{manifestUrl:e})).payload.data}catch(e){throw new Error(`${n}: ${e}`)}else i=e;if(!i.windows)throw new Error(n);const r=await this.getClient();return await r.dispatch("apply-snapshot",{snapshot:i,options:t}),this}async fetchManifest(e){return(await this.getClient()).dispatch("platform-fetch-manifest",{manifestUrl:e})}async launchContentManifest(e){this.wire.sendAction("platform-launch-content-manifest",this.identity).catch((()=>{}));const t=await this.getClient(),n=await this.fetchManifest(e);return t.dispatch("launch-into-platform",{manifest:n,manifestUrl:e}),this}async setWindowContext(e={},t){if(this.wire.sendAction("platform-set-window-context",this.identity).catch((e=>{})),!e)throw new Error("Please provide a serializable object or string to set the context.");const n=await this.getClient(),{entityType:i}=t?await this.fin.System.getEntityInfo(t.uuid,t.name):this.fin.me;await n.dispatch("set-window-context",{context:e,entityType:i,target:t||{uuid:this.fin.me.uuid,name:this.fin.me.name}})}async getWindowContext(e){this.wire.sendAction("platform-get-window-context",this.identity).catch((e=>{}));const t=await this.getClient(),{entityType:n}=e?await this.fin.System.getEntityInfo(e.uuid,e.name):this.fin.me;return t.dispatch("get-window-context",{target:e||{uuid:this.fin.me.uuid,name:this.fin.me.name},entityType:n})}async closeWindow(e,t={skipBeforeUnload:!1}){this.wire.sendAction("platform-close-window",this.identity).catch((e=>{}));return(await this.getClient()).dispatch("close-window",{windowId:e,options:t})}}Yn.Platform=ei,zn=new WeakMap;var ti={},ni={},ii={},ri={};function oi(e){switch(e){case"columns":case"grid":case"rows":case"tabs":return!0;default:return!1}}Object.defineProperty(ri,"__esModule",{value:!0}),ri.overrideFromComposables=ri.isValidPresetType=void 0,ri.isValidPresetType=oi,ri.overrideFromComposables=function(...e){return t=>e.reduceRight(((e,t)=>n=>t(e(n))),(e=>e))(t)},ri.default={isValidPresetType:oi};var si,ai=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(ii,"__esModule",{value:!0}),ii.Layout=void 0;const ci=B,di=O,hi=c,li=ri,ui=W,pi=de;class wi extends hi.Base{constructor(e,t){super(t),si.set(this,new ci.Lazy((async()=>ui.LayoutNode.newLayoutEntitiesClient(await this.platform.getClient(),pi.LAYOUT_CONTROLLER_ID,this.identity)))),this.replace=async e=>{this.wire.sendAction("layout-replace").catch((e=>{}));const t=await this.platform.getClient();await t.dispatch("replace-layout",{target:this.identity,opts:{layout:e}})},this.replaceView=async(e,t)=>{this.wire.sendAction("layout-replace-view").catch((e=>{}));const n=await this.platform.getClient();await n.dispatch("replace-view",{target:this.identity,opts:{viewToReplace:e,newView:t}})},this.applyPreset=async e=>{this.wire.sendAction("layout-apply-preset").catch((e=>{}));const t=await this.platform.getClient(),{presetType:n}=e;if(!n||!(0,li.isValidPresetType)(n))throw new Error("Cannot apply preset layout, please include an applicable presetType property in the PresetLayoutOptions.");await t.dispatch("apply-preset-layout",{target:this.identity,opts:{presetType:n}})};const n=(0,di.validateIdentity)(e);if(n)throw new Error(n);this.identity=e,this.platform=this.fin.Platform.wrapSync({uuid:e.uuid}),e.uuid===this.fin.me.uuid&&e.name===this.fin.me.name&&(this.init=this.fin.Platform.Layout.init)}async getConfig(){this.wire.sendAction("layout-get-config").catch((e=>{}));return(await this.platform.getClient()).dispatch("get-frame-snapshot",{target:this.identity})}async getCurrentViews(){this.wire.sendAction("layout-get-views").catch((e=>{}));const e=await this.platform.getClient();return(await e.dispatch("get-layout-views",{target:this.identity})).map((e=>this.fin.View.wrapSync(e)))}async getRootItem(){this.wire.sendAction("layout-get-root-item").catch((()=>{}));const e=await ai(this,si,"f").getValue(),t=await e.getRoot("layoutName"in this.identity?this.identity:void 0);return ui.LayoutNode.getEntity(t,e)}}ii.Layout=wi,si=new WeakMap;var yi,fi,gi,mi,vi,Ci=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},bi=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n};Object.defineProperty(ni,"__esModule",{value:!0}),ni.LayoutModule=void 0;const Ii=c,Ei=ii,xi=de;class Ai extends Ii.Base{constructor(){super(...arguments),yi.add(this),fi.set(this,!1),gi.set(this,null),this.init=async(e={})=>{if(this.wire.sendAction("layout-init").catch((e=>{})),!this.wire.environment.layoutAllowedInContext(this.fin))throw new Error("Layout.init can only be called from a Window context.");if(Ci(this,fi,"f"))throw new Error("Layout.init was already called, please use Layout.create to add additional layouts.");"openfin"===this.wire.environment.type&&await this.fin.Platform.getCurrentSync().getClient(),bi(this,fi,!0,"f"),bi(this,gi,await this.wire.environment.initLayoutManager(this.fin,this.wire,e),"f"),await this.wire.environment.applyLayoutSnapshot(this.fin,Ci(this,gi,"f"),e);const t={name:this.fin.me.name,uuid:this.fin.me.uuid};if(!e.layoutManagerOverride){const e={layoutName:xi.DEFAULT_LAYOUT_KEY,...t};return Ci(this,mi,"f").call(this,e)}return this.wrapSync(t)},mi.set(this,(e=>{const t="[Layout] You are using a deprecated property `layoutManager` - it will throw if you access it starting in v37.",n=new Proxy({},{get(e,n){throw console.warn(`[Layout-mgr-proxy] accessing ${n.toString()}`),new Error(t)}}),i=Object.assign(this.wrapSync(e),{layoutManager:n});return new Proxy(i,{get(e,n){if("layoutManager"===n)throw console.warn(`[Layout-proxy] accessing ${n.toString()}`),new Error(t);return e[n]}})})),this.getCurrentLayoutManagerSync=()=>Ci(this,yi,"m",vi).call(this,"fin.Platform.Layout.getCurrentLayoutManagerSync()"),this.create=async e=>this.wire.environment.createLayout(Ci(this,yi,"m",vi).call(this,"fin.Platform.Layout.create()"),e),this.destroy=async e=>this.wire.environment.destroyLayout(Ci(this,yi,"m",vi).call(this,"fin.Platform.Layout.destroy()"),e)}async wrap(e){return this.wire.sendAction("layout-wrap").catch((e=>{})),new Ei.Layout(e,this.wire)}wrapSync(e){return this.wire.sendAction("layout-wrap-sync").catch((e=>{})),new Ei.Layout(e,this.wire)}async getCurrent(){if(this.wire.sendAction("layout-get-current").catch((e=>{})),!this.fin.me.isWindow)throw new Error("You are not in a Window context. Only Windows can have a Layout.");const{uuid:e,name:t}=this.fin.me;return this.wrap({uuid:e,name:t})}getCurrentSync(){if(this.wire.sendAction("layout-get-current-sync").catch((e=>{})),!this.fin.me.isWindow)throw new Error("You are not in a Window context. Only Windows can have a Layout.");const{uuid:e,name:t}=this.fin.me;return this.wrapSync({uuid:e,name:t})}}ni.LayoutModule=Ai,fi=new WeakMap,gi=new WeakMap,mi=new WeakMap,yi=new WeakSet,vi=function(e){if(!Ci(this,gi,"f"))throw new Error(`You must call init before using the API ${e}`);return Ci(this,gi,"f")},function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(ni,e),n(ii,e)}(ti),Object.defineProperty(qn,"__esModule",{value:!0}),qn.PlatformModule=void 0;const Pi=c,Mi=Yn,Oi=ti;class _i extends Pi.Base{constructor(e,t){super(e),this._channel=t,this.Layout=new Oi.LayoutModule(this.wire)}async init(e){if(!fin.__internal_.isPlatform||fin.me.name!==fin.me.uuid)throw new Error("fin.Platform.init should only be called from a custom platform provider running in the main window of the application.");return this.wire.environment.initPlatform(this.fin,e)}async wrap(e){return this.wire.sendAction("platform-wrap").catch((e=>{})),new Mi.Platform({uuid:e.uuid},this._channel)}wrapSync(e){return this.wire.sendAction("platform-wrap-sync").catch((e=>{})),new Mi.Platform({uuid:e.uuid},this._channel)}async getCurrent(){return this.wire.sendAction("platform-get-current").catch((e=>{})),this.wrap({uuid:this.wire.me.uuid})}getCurrentSync(){return this.wire.sendAction("platform-get-current-sync").catch((e=>{})),this.wrapSync({uuid:this.wire.me.uuid})}start(e){return this.wire.sendAction("platform-start").catch((e=>{})),new Promise((async(t,n)=>{try{const{uuid:n}=e,i=await this.fin.Application._create({...e,isPlatformController:!0});i.once("platform-api-ready",(()=>t(this.wrapSync({uuid:n})))),i._run({uuid:n})}catch(e){n(e)}}))}startFromManifest(e,t){return this.wire.sendAction("platform-start-from-manifest").catch((e=>{})),new Promise((async(n,i)=>{try{const i=await this.fin.Application._createFromManifest(e);i.once("platform-api-ready",(()=>n(this.wrapSync({uuid:i.identity.uuid})))),i._run(t)}catch(e){i(e)}}))}}qn.PlatformModule=_i,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(qn,e),n(Yn,e)}(Kn);var Si={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getMe=e.getBaseMe=e.environmentUnsupportedMessage=void 0;const t=me(),n=Ln,i=Pe(),r=Pn;function o(e,t,n){return{...{isView:"view"===e,isWindow:"window"===e,isFrame:"iframe"===e,isExternal:"external connection"===e},uuid:t,name:n,entityType:e}}e.environmentUnsupportedMessage="You are not running in OpenFin.",e.getBaseMe=o,e.getMe=function(s){const{uuid:a,name:c,entityType:d}=s.me,h={setContext(){throw new Error(e.environmentUnsupportedMessage)},addContextHandler(){throw new Error(e.environmentUnsupportedMessage)},getContextGroups(){throw new Error(e.environmentUnsupportedMessage)},joinContextGroup(){throw new Error(e.environmentUnsupportedMessage)},removeFromContextGroup(){throw new Error(e.environmentUnsupportedMessage)},getAllClientsInContextGroup(){throw new Error(e.environmentUnsupportedMessage)},getInfoForContextGroup(){throw new Error(e.environmentUnsupportedMessage)}},l="Interop API has not been instantiated. Either connection has failed or you have not declared interop in your config.",u={setContext(){throw new Error(l)},addContextHandler(){throw new Error(l)},getContextGroups(){throw new Error(l)},joinContextGroup(){throw new Error(l)},removeFromContextGroup(){throw new Error(l)},getAllClientsInContextGroup(){throw new Error(l)},getInfoForContextGroup(){throw new Error(l)}},p={eventNames:()=>{throw new Error(e.environmentUnsupportedMessage)},emit:()=>{throw new Error(e.environmentUnsupportedMessage)},listeners:()=>{throw new Error(e.environmentUnsupportedMessage)},listenerCount:()=>{throw new Error(e.environmentUnsupportedMessage)},on:()=>{throw new Error(e.environmentUnsupportedMessage)},addListener:()=>{throw new Error(e.environmentUnsupportedMessage)},once:()=>{throw new Error(e.environmentUnsupportedMessage)},prependListener:()=>{throw new Error(e.environmentUnsupportedMessage)},prependOnceListener:()=>{throw new Error(e.environmentUnsupportedMessage)},removeListener:()=>{throw new Error(e.environmentUnsupportedMessage)},removeAllListeners:()=>{throw new Error(e.environmentUnsupportedMessage)}};switch(d){case"view":return Object.assign(new t.View(s,{uuid:a,name:c}),o(d,a,c),{interop:u,isOpenFin:!0});case"window":return Object.assign(new i._Window(s,{uuid:a,name:c}),o(d,a,c),{interop:u,isOpenFin:!0});case"iframe":return Object.assign(new n._Frame(s,{uuid:a,name:c}),o(d,a,c),{interop:u,isOpenFin:!0});case"external connection":return Object.assign(new r.ExternalApplication(s,{uuid:a}),o(d,a,c),{interop:u,isOpenFin:!1});default:return{...o(d,a,c),...p,interop:h,isOpenFin:!1}}}}(Si);var Ri={},Fi={},ji={};Object.defineProperty(ji,"__esModule",{value:!0}),ji.createWarningObject=ji.createUnusableObject=void 0,ji.createUnusableObject=function(e){const t=()=>{throw new Error(e)};return new Proxy({},{apply:t,construct:t,defineProperty:t,deleteProperty:t,get:t,getOwnPropertyDescriptor:t,getPrototypeOf:t,has:t,isExtensible:t,ownKeys:t,preventExtensions:t,set:t,setPrototypeOf:t})},ji.createWarningObject=function(e,t){return new Proxy(t,{get:(...t)=>(console.warn(e),Reflect.get(...t)),set:(...t)=>(console.warn(e),Reflect.set(...t)),getOwnPropertyDescriptor:(...t)=>(console.warn(e),Reflect.getOwnPropertyDescriptor(...t)),ownKeys:(...t)=>(console.warn(e),Reflect.ownKeys(...t))})};var Li,ki={},Ti={};var $i={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.wrapIntentHandler=e.BROKER_ERRORS=e.generateOverrideWarning=e.generateOverrideError=e.wrapContextHandler=e.wrapInTryCatch=e.generateId=void 0;e.generateId=()=>`${Math.random()}${Date.now()}`;e.wrapInTryCatch=(e,t)=>(...n)=>{try{return e(...n)}catch(e){throw new Error((t||"")+e)}};e.wrapContextHandler=(e,t)=>async n=>{try{await e(n)}catch(e){throw console.error(`Error thrown by handler ${t} for context type ${n.type}: ${e}`),e}};e.generateOverrideError=(e,t)=>`You have tried to to use ${e} but ${t} has not been overridden in the Interop Broker. Please override this function. Refer to our documentation for more info.`;e.generateOverrideWarning=(e,t,n,i)=>{const{uuid:r,name:o}=n;return i?`Entity with identity: ${r}/${o} has called ${i} or ${e} but ${t} has not been overridden.`:`Entity with identity: ${r}/${o} has called ${e} but ${t} has not been overridden.`},e.BROKER_ERRORS={fireIntent:(0,e.generateOverrideError)("fireIntent","handleFiredIntent"),fireIntentForContext:(0,e.generateOverrideError)("fireIntentForContext","handleFiredIntentForContext"),getInfoForIntent:(0,e.generateOverrideError)("getInfoForIntent","handleInfoForIntent"),getInfoForIntentsByContext:(0,e.generateOverrideError)("getInfoForIntentsByContext","handleInfoForIntentsByContext"),joinSessionContextGroupWithJoinContextGroup:"The Context Group you have tried to join is a Session Context Group. Custom Context Groups can only be defined by the Interop Broker through code or manifest configuration. Please use joinSessionContextGroup.",fdc3Open:(0,e.generateOverrideError)("fdc3.open","fdc3HandleOpen"),fdc3FindInstances:(0,e.generateOverrideError)("fdc3.findInstances","fdc3HandleFindInstances"),fdc3GetAppMetadata:(0,e.generateOverrideError)("fdc3.getAppMetadata","fdc3HandleGetAppMetadata"),fdc3GetInfo:(0,e.generateOverrideError)("fdc3.getInfo","fdc3HandleGetInfo")};e.wrapIntentHandler=(e,t)=>async n=>{try{return e(n)}catch(e){throw console.error(`Error thrown by handler ${t}: ${e}`),e}}}($i);var Bi,Gi,Wi={};function Hi(){if(Gi)return ki;Gi=1;var e,t,i,r=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},s=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(ki,"__esModule",{value:!0}),ki.InteropBroker=void 0;const a=c,d=function(){if(Li)return Ti;Li=1,Object.defineProperty(Ti,"__esModule",{value:!0});const e=pr();return Ti.default=class{constructor(e,t){this.provider=e,this.id=t,this.lastContext=void 0,this.contextGroupMap=new Map,this.clients=new Map,this.registerListeners()}registerListeners(){this.provider.register(`sessionContextGroup:getContext-${this.id}`,this.getCurrentContext.bind(this)),this.provider.register(`sessionContextGroup:setContext-${this.id}`,this.setContext.bind(this)),this.provider.register(`sessionContextGroup:handlerAdded-${this.id}`,this.handlerAdded.bind(this)),this.provider.register(`sessionContextGroup:handlerRemoved-${this.id}`,this.handlerRemoved.bind(this))}getCurrentContext(e){return e.type?this.contextGroupMap.get(e.type):this.lastContext}setContext(t,n){const{context:i}=t,r=e.InteropBroker.checkContextIntegrity(i);if(!1===r.isValid)throw new Error(`Failed to set Context - bad Context. Reason: ${r.reason}. Context: ${JSON.stringify(i)}`);if(!this.getClientState(n))throw new Error(`Client with Identity: ${n.uuid} ${n.name} not in Session Client State Map`);this.contextGroupMap.set(i.type,i),this.lastContext=i,Array.from(this.clients.values()).forEach((e=>{e.contextHandlers.get(i.type)?.forEach((t=>{this.provider.dispatch(e.clientIdentity,t,i)})),e.globalHandler&&this.provider.dispatch(e.clientIdentity,e.globalHandler,i)}))}getClientState(e){return this.clients.get(e.endpointId)}async handlerAdded(e,t){const{handlerId:n,contextType:i}=e,r=this.getClientState(t);if(!r)throw new Error(`Client with Identity: ${t.uuid} ${t.name} not in Client State Map`);if(i){const e=r.contextHandlers.get(i)||[];r.contextHandlers.set(i,[...e,n]);const o=this.contextGroupMap.get(i);o&&await this.provider.dispatch(t,n,o)}else{r.globalHandler=n;const e=[...this.contextGroupMap.keys()].map((async e=>{const i=this.contextGroupMap.get(e);i&&await this.provider.dispatch(t,n,i)}));await Promise.all(e)}}handlerRemoved(e,t){const{handlerId:n}=e,i=this.clients.get(t.endpointId);i?(Array.from(i.contextHandlers).forEach((([,e])=>{const t=e.indexOf(n);t>-1&&e.splice(t,1)})),i.globalHandler===n&&(i.globalHandler=void 0)):console.warn(`Trying to remove a handler from a client that isn't mapped. handlerId: ${n}. clientIdentity: ${t}`)}registerNewClient(e){if(!this.clients.has(e.endpointId)){const t={contextHandlers:new Map,clientIdentity:e,globalHandler:void 0};this.clients.set(e.endpointId,t)}}onDisconnection(e){this.clients.delete(e.endpointId)}},Ti}(),h=$i,l=n,u=function(){if(Bi)return Wi;Bi=1,Object.defineProperty(Wi,"__esModule",{value:!0}),Wi.PrivateChannelProvider=void 0;const e=Hi();return Wi.PrivateChannelProvider=class t{constructor(e,t){this.provider=e,this.id=t,this.clients=new Map,this.registerListeners(),this.contextByContextType=new Map,this.lastContext=void 0,this.provider.onConnection((e=>this.registerNewClient(e))),this.provider.onDisconnection((async e=>{const{endpointId:t}=e;this.clients.has(t)&&await this.handleClientDisconnecting(e),0===(await this.provider.getAllClientInfo()).length&&this.provider.destroy()}))}getClientState(e){return this.clients.get(e.endpointId)}registerListeners(){this.provider.register("broadcast",this.broadcast.bind(this)),this.provider.register("getCurrentContext",this.getCurrentContext.bind(this)),this.provider.register("contextHandlerAdded",this.contextHandlerAdded.bind(this)),this.provider.register("contextHandlerRemoved",this.contextHandlerRemoved.bind(this)),this.provider.register("nonStandardHandlerRemoved",this.nonStandardHandlerRemoved.bind(this)),this.provider.register("onAddContextHandlerAdded",this.onAddContextHandlerAdded.bind(this)),this.provider.register("onDisconnectHandlerAdded",this.onDisconnectHandlerAdded.bind(this)),this.provider.register("onUnsubscribeHandlerAdded",this.onUnsubscribeHandlerAdded.bind(this)),this.provider.register("clientDisconnecting",((e,t)=>{this.handleClientDisconnecting(t)}))}broadcast(t,n){const{context:i}=t;if(!this.getClientState(n))throw new Error(`Client with Identity: ${n.uuid} ${n.name}, tried to call broadcast, is not connected to this Private Channel`);const r=e.InteropBroker.checkContextIntegrity(i);if(!1===r.isValid)throw new Error(`Failed to broadcast - bad Context. Reason: ${r.reason}. Context: ${JSON.stringify(i)}`);this.contextByContextType.set(i.type,i),this.lastContext=i,Array.from(this.clients.values()).forEach((e=>{const t=e.handlerIdsByContextTypes.get(i.type);t&&t.forEach((t=>{this.provider.dispatch(e.clientIdentity,t,i)})),e.globalHandler&&this.provider.dispatch(e.clientIdentity,e.globalHandler,i)}))}getCurrentContext(e,t){const{contextType:n}=e;if(!this.getClientState(t))throw new Error(`Client with Identity: ${t.uuid} ${t.name}, tried to call getCurrentContext, is not connected to this Private Channel`);if(void 0!==n){return this.contextByContextType.get(n)||null}return this.lastContext?this.lastContext:null}contextHandlerAdded(e,t){const{handlerId:n,contextType:i}=e,r=this.getClientState(t);if(!r)throw new Error(`Client with Identity: ${t.uuid} ${t.name}, tried to call addContextListener, is not connected to this Private Channel`);if(i){const e=r.handlerIdsByContextTypes.get(i)||[];r.handlerIdsByContextTypes.set(i,[...e,n])}else r.globalHandler=n;Array.from(this.clients.values()).forEach((e=>{e.clientIdentity.endpointId!==t.endpointId&&e.onAddContextListenerHandlerId&&this.provider.dispatch(e.clientIdentity,e.onAddContextListenerHandlerId,i)}))}async contextHandlerRemoved(e,t){const{handlerId:n}=e,i=this.getClientState(t);if(i){let e;if(i.globalHandler===n)i.globalHandler=void 0;else for(const[t,r]of i.handlerIdsByContextTypes){const i=r.indexOf(n);i>-1&&(r.splice(i,1),e=t)}const r=(await this.getConnectedClients()).map((async n=>{const{clientIdentity:i,clientIdentity:{endpointId:r},onUnsubscribeHandlerId:o}=n;r!==t.endpointId&&o&&await this.provider.dispatch(i,o,e)}));try{await Promise.all(r)}catch(e){throw console.error(`Problem when attempting to dispatch to onUnsubscribeHandlers. Error: ${e} Removing Client: ${n}. uuid: ${t.uuid}. name: ${t.name}. endpointId: ${t.endpointId}`),new Error(e)}}else console.warn(`Trying to remove a handler from a client that isn't mapped. handlerId: ${n}. uuid: ${t.uuid}. name: ${t.name}. endpointId: ${t.endpointId}.`)}nonStandardHandlerRemoved(e,t){const{handlerId:n}=e,i=this.getClientState(t);i?i.onDisconnectHandlerId===n?i.onDisconnectHandlerId=void 0:i.onAddContextListenerHandlerId===n?i.onAddContextListenerHandlerId=void 0:i.onUnsubscribeHandlerId===n&&(i.onUnsubscribeHandlerId=void 0):console.warn(`Trying to remove a handler from a client that isn't mapped. handlerId: ${n}. clientIdentity: ${t}`)}onAddContextHandlerAdded(e,t){const n=this.getClientState(t),{handlerId:i}=e;if(!n)throw new Error(`Client with Identity: ${t.uuid} ${t.name}, tried to call onAddContextListener, is not connected to this Private Channel`);n.onAddContextListenerHandlerId=i,Array.from(this.clients.values()).forEach((e=>{e.clientIdentity.endpointId!==t.endpointId&&Array.from(e.handlerIdsByContextTypes.keys()).forEach((e=>{this.provider.dispatch(t,i,e)}))}))}onDisconnectHandlerAdded(e,t){const n=this.getClientState(t),{handlerId:i}=e;if(!n)throw new Error(`Client with Identity: ${t.uuid} ${t.name}, tried to call onDisconnect, is not connected to this Private Channel`);n.onDisconnectHandlerId=i}onUnsubscribeHandlerAdded(e,t){const n=this.getClientState(t),{handlerId:i}=e;if(!n)throw new Error(`Client with Identity: ${t.uuid} ${t.name}, tried to call onUnsubscribe, is not connected to this Private Channel`);n.onUnsubscribeHandlerId=i}removeClient(e){const t=this.getClientState(e);if(!t)throw new Error(`Client with Identity: ${e.uuid} ${e.name}, tried to call disconnect, is not connected to this Private Channel`);t.handlerIdsByContextTypes.clear(),this.clients.delete(e.endpointId)}async fireOnDisconnectForOtherClients(e){const{endpointId:t}=e,n=(await this.getConnectedClients()).map((async e=>{const{clientIdentity:{endpointId:n},onDisconnectHandlerId:i}=e;n!==t&&i&&await this.provider.dispatch(e.clientIdentity,i)}));try{await Promise.all(n)}catch(t){throw console.error(`Problem when attempting to dispatch to onDisconnectHandlers. Error: ${t} Disconnecting Client: uuid: ${e.uuid}. name: ${e.name}. endpointId: ${e.endpointId}`),new Error(t)}}async unsubscribeAll(e){const{endpointId:t}=e,n=this.clients.get(t);if(n){const t=Array.from(n.handlerIdsByContextTypes.values()).flat(),i=n.globalHandler;if(t.length>0){const n=t.map((async t=>this.contextHandlerRemoved({handlerId:t},e)));try{await Promise.all(n)}catch(e){console.error(e.message)}}if(i)try{await this.contextHandlerRemoved({handlerId:i},e)}catch(e){console.error(e.message)}}}async handleClientDisconnecting(e){await this.unsubscribeAll(e),this.removeClient(e),await this.fireOnDisconnectForOtherClients(e)}registerNewClient(e){if(!this.clients.has(e.endpointId)){const t={clientIdentity:e,handlerIdsByContextTypes:new Map,globalHandler:void 0,onAddContextListenerHandlerId:void 0,onUnsubscribeHandlerId:void 0,onDisconnectHandlerId:void 0};this.clients.set(e.endpointId,t)}}async getConnectedClients(){const e=await this.provider.getAllClientInfo();return Array.from(this.clients.values()).filter((t=>{const{uuid:n,name:i}=t.clientIdentity;return e.some((e=>i===e.name&&n===e.uuid))}))}static init(e,n){return new t(e,n)}},Wi}(),p=B,w=[{id:"green",displayMetadata:{color:"#00CC88",name:"green"}},{id:"purple",displayMetadata:{color:"#8C61FF",name:"purple"}},{id:"orange",displayMetadata:{color:"#FF8C4C",name:"orange"}},{id:"red",displayMetadata:{color:"#FF5E60",name:"red"}},{id:"pink",displayMetadata:{color:"#FF8FB8",name:"pink"}},{id:"yellow",displayMetadata:{color:"#E9FF8F",name:"yellow"}}];let y=class n extends a.Base{constructor(n,o,a){super(n),e.set(this,void 0),t.set(this,void 0),i.set(this,void 0),this.getProvider=()=>s(this,i,"f").getValue(),this.interopClients=new Map,this.contextGroupsById=new Map,r(this,t,a.contextGroups??[...w],"f"),r(this,e,a.fdc3Info,"f"),a?.logging&&(this.logging=a.logging),this.intentClientMap=new Map,this.lastContextMap=new Map,this.sessionContextGroupMap=new Map,r(this,i,new p.Lazy(o),"f"),this.setContextGroupMap(),this.setupChannelProvider()}static createClosedConstructor(...e){return class extends n{constructor(...t){if(t.length){const[n,i,r]=t;if(r&&"object"==typeof r&&!(0,l.isEqual)(r,e[2]))return console.warn("You have modified the parameters of the InteropOverride constructor. This behavior is deprecated and will be removed in a future version. You can modify these options in your manifest. Please consult our Interop docs for guidance on migrating to the new override scheme."),void super(e[0],e[1],r);console.warn("You are attempting to pass arguments to the InteropOverride constructor. This is not necessary, and these passed arguments will be ignored. You are likely using an older InteropBroker override scheme. Please consult our Interop docs for guidance on migrating to the new override scheme.")}super(...e)}}}setContext({context:e},t){this.wire.sendAction("interop-broker-set-context").catch((e=>{}));const n=this.getClientState(t);if(!n||!n.contextGroupId)throw n?new Error("You must join a context group before you can set context."):new Error(`Client with Identity: ${t.uuid} ${t.name} not in Client State Map`);{const{contextGroupId:t}=n;this.setContextForGroup({context:e},t)}}setContextForGroup({context:e},t){this.wire.sendAction("interop-broker-set-context-for-group").catch((e=>{}));const i=this.contextGroupsById.get(t);if(!i)throw new Error(`Unable to set context for context group that isn't in the context group mapping: ${t}.`);const r=n.checkContextIntegrity(e);if(!1===r.isValid)throw new Error(`Failed to set Context - bad Context. Reason: ${r.reason}. Context: ${JSON.stringify(e)}`);const o=e.type;i.set(o,e),this.lastContextMap.set(t,o);Array.from(this.interopClients.values()).filter((e=>e.contextGroupId===t)).forEach((t=>{for(const[,i]of t.contextHandlers)n.isContextTypeCompatible(o,i.contextType)&&this.invokeContextHandler(t.clientIdentity,i.handlerId,e)}))}getCurrentContext(e,t){this.wire.sendAction("interop-broker-get-current-context").catch((e=>{}));const n=this.getClientState(t);if(!n?.contextGroupId)throw new Error("You must be a member of a context group to call getCurrentContext");const{contextGroupId:i}=n,r=this.contextGroupsById.get(i),o=this.lastContextMap.get(i),s=e?.contextType??o;return r&&s?r.get(s):void 0}async joinContextGroup({contextGroupId:e,target:t},i){if(this.wire.sendAction("interop-broker-join-context-group").catch((e=>{})),this.sessionContextGroupMap.has(e))throw new Error(h.BROKER_ERRORS.joinSessionContextGroupWithJoinContextGroup);if(t){n.hasEndpointId(t)&&await this.addClientToContextGroup({contextGroupId:e},t);try{const n=this.channel.connections.filter((e=>e.uuid===t.uuid&&e.name===t.name));if(!n.length)throw new Error(`Given Identity ${t.uuid} ${t.name} is not connected to the Interop Broker.`);n.length>1&&console.warn(`More than one connection found for identity ${t.uuid} ${t.name}`);const i=[];for(const t of n)i.push(this.addClientToContextGroup({contextGroupId:e},t));await Promise.all(i)}catch(e){throw new Error(e)}}else await this.addClientToContextGroup({contextGroupId:e},i)}async addClientToContextGroup({contextGroupId:e},t){this.wire.sendAction("interop-broker-add-client-to-context-group").catch((e=>{}));const n=this.getClientState(t);if(!n)throw new Error(`Client with Identity: ${t.uuid} ${t.name} not in Client State Map`);if(!this.getContextGroups().find((t=>t.id===e)))throw new Error(`Attempting to join a context group that does not exist: ${e}. You may only join existing context groups.`);if(n.contextGroupId!==e){n.contextGroupId=e,await this.setCurrentContextGroupInClientOptions(t,e);const i=this.contextGroupsById.get(e);for(const[,e]of n.contextHandlers){const{contextType:n,handlerId:r}=e;if(void 0===n)i.forEach(((e,n)=>{this.invokeContextHandler(t,r,e)}));else if(i.has(n)){const e=i.get(n);e&&this.invokeContextHandler(t,r,e)}}}}async removeFromContextGroup({target:e},t){if(this.wire.sendAction("interop-broker-remove-from-context-group").catch((e=>{})),e){n.hasEndpointId(e)&&await this.removeClientFromContextGroup(e);try{const t=this.channel.connections.filter((t=>t.uuid===e.uuid&&t.name===e.name));if(!t.length)throw new Error(`No connection found for given Identity ${e.uuid} ${e.name}`);t.length>1&&console.warn(`More than one connection found for identity ${e.uuid} ${e.name}`);const n=[];for(const e of t)n.push(this.removeClientFromContextGroup(e));await Promise.all(n)}catch(e){throw new Error(e)}}else await this.removeClientFromContextGroup(t)}async removeClientFromContextGroup(e){this.wire.sendAction("interop-broker-remove-client-from-context-group").catch((e=>{}));const t=this.getClientState(e);t&&(t.contextGroupId=void 0),await this.setCurrentContextGroupInClientOptions(e,null)}getContextGroups(){return this.wire.sendAction("interop-broker-get-context-groups").catch((e=>{})),s(this,t,"f").map((e=>({...e})))}getInfoForContextGroup({contextGroupId:e}){return this.wire.sendAction("interop-broker-get-info-for-context-group").catch((e=>{})),this.getContextGroups().find((t=>t.id===e))}getAllClientsInContextGroup({contextGroupId:e}){this.wire.sendAction("interop-broker-get-all-clients-in-context-group").catch((e=>{}));return Array.from(this.interopClients.values()).filter((t=>t.contextGroupId===e)).map((e=>e.clientIdentity))}async handleFiredIntent(e,t){const n=(0,h.generateOverrideWarning)("fdc3.raiseIntent","InteropBroker.handleFiredIntent",t,"interopClient.fireIntent");throw console.warn(n),new Error(h.BROKER_ERRORS.fireIntent)}async setIntentTarget(e,t){this.wire.sendAction("interop-broker-set-intent-target").catch((e=>{}));const n=this.intentClientMap.get(t.name),i=`intent-handler-${e.name}`;if(n){const t=n.get(i);if(t){if(t.pendingIntents.push(e),t.clientIdentity&&t.isReady){const{clientIdentity:e,pendingIntents:n}=t;try{const r=n[n.length-1];await this.invokeIntentHandler(e,i,r),t.pendingIntents=[]}catch(n){console.error(`Error invoking intent handler for client ${e.uuid}/${e.name}/${e.endpointId}`),t.isReady=!1}}}else n.set(i,{isReady:!1,pendingIntents:[e]})}else{this.intentClientMap.set(t.name,new Map);const n=this.intentClientMap.get(t.name);n&&n.set(i,{isReady:!1,pendingIntents:[e]})}}async handleInfoForIntent(e,t){const n=(0,h.generateOverrideWarning)("fdc3.findIntent","InteropBroker.handleInfoForIntent",t,"interopClient.getInfoForIntent");throw console.warn(n),new Error(h.BROKER_ERRORS.getInfoForIntent)}async handleInfoForIntentsByContext(e,t){const n=(0,h.generateOverrideWarning)("fdc3.findIntentsByContext","InteropBroker.handleInfoForIntentsByContext",t,"interopClient.getInfoForIntentsByContext");throw console.warn(n),new Error(h.BROKER_ERRORS.getInfoForIntentsByContext)}async handleFiredIntentForContext(e,t){const n=(0,h.generateOverrideWarning)("fdc3.raiseIntentForContext","InteropBroker.handleFiredIntentForContext",t,"interopClient.fireIntentForContext");throw console.warn(n),new Error(h.BROKER_ERRORS.fireIntentForContext)}async clientDisconnected(e){}async fdc3HandleOpen({app:e,context:t},n){const i=(0,h.generateOverrideWarning)("fdc3.open","InteropBroker.fdc3HandleOpen",n);throw console.warn(i),new Error(h.BROKER_ERRORS.fdc3Open)}async fdc3HandleFindInstances(e,t){const n=(0,h.generateOverrideWarning)("fdc3.open","InteropBroker.fdc3HandleFindInstances",t);throw console.warn(n),new Error(h.BROKER_ERRORS.fdc3FindInstances)}async fdc3HandleGetAppMetadata(e,t){const n=(0,h.generateOverrideWarning)("fdc3.getAppMetadata","InteropBroker.fdc3HandleGetAppMetadata",t);throw console.warn(n),new Error(h.BROKER_ERRORS.fdc3GetAppMetadata)}async invokeContextHandler(e,t,n){const i=await this.getProvider();try{await i.dispatch(e,t,n)}catch(i){console.error(`Error invoking context handler ${t} for context type ${n.type} in client ${e.uuid}/${e.name}/${e.endpointId}`,i)}}async invokeIntentHandler(e,t,n){const i=await this.getProvider();await i.dispatch(e,t,n)}async fdc3HandleGetInfo(t,n){const{fdc3Version:i}=t;return{fdc3Version:i,...s(this,e,"f"),optionalFeatures:{OriginatingAppMetadata:!1,UserChannelMembershipAPIs:!0},appMetadata:{appId:"",instanceId:""}}}async getAllClientInfo(){return(await this.getProvider()).getAllClientInfo()}decorateSnapshot(e){return{...e,interopSnapshotDetails:{contextGroupStates:this.getContextGroupStates()}}}applySnapshot(e,t){const n=e?.interopSnapshotDetails?.contextGroupStates;n&&(t?.closeExistingWindows||this.updateExistingClients(n),this.rehydrateContextGroupStates(n))}updateExistingClients(e){this.interopClients.forEach((t=>{const{clientIdentity:i,contextGroupId:r,contextHandlers:o}=t;if(r){const t=e[r];for(const[,e]of Object.entries(t))o.forEach((t=>{const{handlerId:r,contextType:o}=t;n.isContextTypeCompatible(e.type,o)&&this.invokeContextHandler(i,r,e)}))}}))}getContextGroupStates(){return n.toObject(this.contextGroupsById)}rehydrateContextGroupStates(e){const t=Object.entries(e);for(const[e,n]of t){const t=Object.entries(n);for(const[n,i]of t)if(this.contextGroupsById.has(e)){this.contextGroupsById.get(e).set(n,i)}else console.warn(`Attempting to set a context group that isn't in the context group mapping. Skipping context group rehydration for: ${e}`)}}contextHandlerRegistered({contextType:e,handlerId:t},n){const i={contextType:e,handlerId:t},r=this.getClientState(n);if(r?.contextHandlers.set(t,i),r&&r.contextGroupId){const{contextGroupId:i}=r,o=this.contextGroupsById.get(i);if(void 0===e)o.forEach(((e,i)=>{this.invokeContextHandler(n,t,e)}));else if(o.has(e)){const i=o.get(e);i&&this.invokeContextHandler(n,t,i)}}}async intentHandlerRegistered(e,t){const{handlerId:n}=e,i=this.intentClientMap.get(t.name),r=i?.get(n);if(i)if(r){const{pendingIntents:e}=r;r.clientIdentity=t,r.isReady=!0;try{if(e.length>0){const i=e[e.length-1];await this.invokeIntentHandler(t,n,i),r.pendingIntents=[]}}catch(e){console.error(`Error invoking intent handler: ${n} for client ${t.uuid}/${t.name}/${t.endpointId}`)}}else i.set(n,{isReady:!0,pendingIntents:[],clientIdentity:t});else{this.intentClientMap.set(t.name,new Map);const e=this.intentClientMap.get(t.name);e&&e.set(n,{isReady:!0,pendingIntents:[],clientIdentity:t})}}removeContextHandler({handlerId:e},t){const n=this.getClientState(t);n&&n.contextHandlers.delete(e)}handleJoinSessionContextGroup({sessionContextGroupId:e},t){try{if(!e)throw new Error("Failed to join session context group: must specify group id.");const n=this.sessionContextGroupMap.get(e);if(n)n.registerNewClient(t);else{const n=new d.default(this.channel,e);n.registerNewClient(t),this.sessionContextGroupMap.set(e,n)}return{hasConflict:this.contextGroupsById.has(e)}}catch(e){throw new Error(e)}}getClientState(e){return this.interopClients.get(e.endpointId)}static toObject(e){const t=Object.fromEntries(e),n={};return Object.entries(t).forEach((([e,t])=>{const i=Object.fromEntries(t);n[e]=i})),n}static checkContextIntegrity(e){if(!e)return{isValid:!1,reason:"No context supplied"};if("object"!=typeof e)return{isValid:!1,reason:"Context must be an Object"};if(!e.type)return{isValid:!1,reason:"Context must have a type property"};if(e.id&&"object"!=typeof e.id)return{isValid:!1,reason:"Context id must be an Object populated with key-value identifiers (if set)"};if(e.id){const{id:t}=e,n=Object.keys(t);let i=!1;if(!n.length)return{isValid:!1,reason:"Context id must have at least one key-value identifier"};if(n.forEach((e=>{"string"==typeof e&&"string"==typeof t[e]||(i=!0)})),i)return{isValid:!1,reason:"Context id key-value identifiers must be of type string"}}return e.name&&"string"!=typeof e.name?{isValid:!1,reason:"Context name must be of string type (if set)"}:{isValid:!0}}static hasEndpointId(e){return void 0!==e.endpointId}static isContextTypeCompatible(e,t){return void 0===t||e===t}setContextGroupMap(){for(const e of this.getContextGroups())this.contextGroupsById.set(e.id,new Map)}async setCurrentContextGroupInClientOptions(e,t){try{const n=await this.fin.System.getEntityInfo(e.uuid,e.name);let i;"view"===n.entityType?i=await this.fin.View.wrap(e):"window"===n.entityType&&(i=await this.fin.Window.wrap(e)),i&&await i.updateOptions({interop:{currentContextGroup:t}})}catch(e){}}async setupChannelProvider(){try{const e=await this.getProvider();this.channel=e,this.wireChannel(e)}catch(e){throw new Error(`Error setting up Interop Broker Channel Provider: ${e}`)}}wireChannel(e){e.onConnection((async(e,t)=>{if(!await this.isConnectionAuthorized(e,t))throw new Error(`Connection not authorized for ${e.uuid}, ${e.name}`);if(!e.endpointId)throw new Error("Version too old to be compatible with Interop. Please upgrade your runtime to a more recent version.");const n={contextGroupId:void 0,contextHandlers:new Map,clientIdentity:e};t?.currentContextGroup&&this.contextGroupsById.has(t.currentContextGroup)&&(n.contextGroupId=t?.currentContextGroup),this.interopClients.set(e.endpointId,n)})),e.onDisconnection((e=>{this.interopClients.delete(e.endpointId);const t=this.intentClientMap.get(e.name);t&&e.uuid===this.fin.me.uuid&&t.forEach((e=>{e.isReady=!1})),this.sessionContextGroupMap.forEach((t=>{t.onDisconnection(e)})),this.clientDisconnected(e)})),e.beforeAction((async(e,t,n)=>{if(!await this.isActionAuthorized(e,t,n))throw new Error(`Action (${e}) not authorized for ${n.uuid}, ${n.name}`);this.logging?.beforeAction?.enabled&&console.log(e,t,n)})),e.afterAction(((e,t,n)=>{this.logging?.afterAction?.enabled&&console.log(e,t,n)})),e.register("setContext",this.setContext.bind(this)),e.register("fireIntent",this.handleFiredIntent.bind(this)),e.register("getCurrentContext",this.getCurrentContext.bind(this)),e.register("getInfoForIntent",this.handleInfoForIntent.bind(this)),e.register("getInfoForIntentsByContext",this.handleInfoForIntentsByContext.bind(this)),e.register("fireIntentForContext",this.handleFiredIntentForContext.bind(this)),e.register("getContextGroups",this.getContextGroups.bind(this)),e.register("joinContextGroup",this.joinContextGroup.bind(this)),e.register("removeFromContextGroup",this.removeFromContextGroup.bind(this)),e.register("getAllClientsInContextGroup",this.getAllClientsInContextGroup.bind(this)),e.register("getInfoForContextGroup",this.getInfoForContextGroup.bind(this)),e.register("contextHandlerRegistered",this.contextHandlerRegistered.bind(this)),e.register("intentHandlerRegistered",this.intentHandlerRegistered.bind(this)),e.register("removeContextHandler",this.removeContextHandler.bind(this)),e.register("sessionContextGroup:createIfNeeded",this.handleJoinSessionContextGroup.bind(this)),e.register("fdc3Open",this.fdc3HandleOpen.bind(this)),e.register("fdc3v2FindIntentsByContext",this.handleInfoForIntentsByContext.bind(this)),e.register("fdc3FindInstances",this.fdc3HandleFindInstances.bind(this)),e.register("fdc3GetAppMetadata",this.fdc3HandleGetAppMetadata.bind(this)),e.register("fdc3v2GetInfo",(async(e,t)=>this.fdc3HandleGetInfo.bind(this)(e,t))),e.register("createPrivateChannelProvider",(async e=>{const{channelId:t}=e,n=await this.fin.InterApplicationBus.Channel.create(t);u.PrivateChannelProvider.init(n,t)}))}isConnectionAuthorized(e,t){return this.wire.sendAction("interop-broker-is-connection-authorized").catch((e=>{})),Promise.resolve(!0)}isActionAuthorized(e,t,n){return this.wire.sendAction("interop-broker-is-action-authorized").catch((e=>{})),Promise.resolve(!0)}};return ki.InteropBroker=y,e=new WeakMap,t=new WeakMap,i=new WeakMap,ki}var Ni,Di={},Ui={},Vi=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},zi=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(Ui,"__esModule",{value:!0});const Ki=c,qi=$i;class Yi extends Ki.Base{constructor(e,t,n){super(e),Ni.set(this,void 0),this.id=n,Vi(this,Ni,t,"f")}async setContext(e){this.wire.sendAction("interop-session-context-group-set-context").catch((e=>{}));return(await zi(this,Ni,"f")).dispatch(`sessionContextGroup:setContext-${this.id}`,{sessionContextGroupId:this.id,context:e})}async getCurrentContext(e){this.wire.sendAction("interop-session-context-group-get-context").catch((e=>{}));return(await zi(this,Ni,"f")).dispatch(`sessionContextGroup:getContext-${this.id}`,{sessionContextGroupId:this.id,type:e})}async addContextHandler(e,t){if(this.wire.sendAction("interop-session-context-group-add-handler").catch((e=>{})),"function"!=typeof e)throw new Error("Non-function argument passed to the first parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");const n=await zi(this,Ni,"f");let i;return i=t?`sessionContextHandler:invoke-${this.id}-${t}-${(0,qi.generateId)()}`:`sessionContextHandler:invoke-${this.id}`,n.register(i,(0,qi.wrapContextHandler)(e,i)),await n.dispatch(`sessionContextGroup:handlerAdded-${this.id}`,{handlerId:i,contextType:t}),{unsubscribe:await this.createUnsubscribeCb(i)}}async createUnsubscribeCb(e){const t=await zi(this,Ni,"f");return async()=>{t.remove(e),await t.dispatch(`sessionContextGroup:handlerRemoved-${this.id}`,{handlerId:e})}}getUserInstance(){return{id:this.id,setContext:(0,qi.wrapInTryCatch)(this.setContext.bind(this),"Failed to set context: "),getCurrentContext:(0,qi.wrapInTryCatch)(this.getCurrentContext.bind(this),"Failed to get context: "),addContextHandler:(0,qi.wrapInTryCatch)(this.addContextHandler.bind(this),"Failed to add context handler: ")}}}Ui.default=Yi,Ni=new WeakMap;var Ji={},Zi={},Qi={},Xi={};Object.defineProperty(Xi,"__esModule",{value:!0}),Xi.PrivateChannelClient=void 0;const er=$i;var tr,nr;function ir(){if(tr)return Zi;tr=1;var e,t=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},i=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n};Object.defineProperty(Zi,"__esModule",{value:!0}),Zi.FDC3ModuleBase=void 0;const r=Qi,s=$i,a=ar(),c=n;return Zi.FDC3ModuleBase=class{get client(){return t(this,e,"f").call(this)}get fin(){return this.wire.getFin()}constructor(t,n){this.wire=n,e.set(this,void 0),i(this,e,t,"f")}async broadcast(e){return this.wire.sendAction("fdc3-broadcast").catch((e=>{})),this.client.setContext(e)}async _open(e,t){this.wire.sendAction("fdc3-open").catch((e=>{}));try{return await a.InteropClient.ferryFdc3Call(this.client,"fdc3Open",{app:e,context:t})}catch(e){const t=e.message===s.BROKER_ERRORS.fdc3Open?"ResolverUnavailable":e.message;throw new Error(t)}}async _getChannels(){return(await this.client.getContextGroups()).map((e=>({...e,type:"system",...(0,r.getUnsupportedChannelApis)()})))}async getOrCreateChannel(e){this.wire.sendAction("fdc3-get-or-create-channel").catch((e=>{}));const t=(await this._getChannels()).find((t=>t.id===e));if(t)return{...t,type:"system",...(0,r.getUnsupportedChannelApis)()};try{const t=await this.client.joinSessionContextGroup(e);return(0,r.buildAppChannelObject)(t)}catch(e){throw console.error(e.message),new Error(r.ChannelError.CreationFailed)}}async getSystemChannels(){return this.wire.sendAction("fdc3-get-system-channels").catch((e=>{})),this._getChannels()}async joinChannel(e){this.wire.sendAction("fdc3-join-channel").catch((e=>{}));try{return await this.client.joinContextGroup(e)}catch(e){if(e.message===s.BROKER_ERRORS.joinSessionContextGroupWithJoinContextGroup?console.error("The Channel you have tried to join is an App Channel. Custom Channels can only be defined by the Interop Broker through code or manifest configuration. Please use getOrCreateChannel."):console.error(e.message),e.message.startsWith("Attempting to join a context group that does not exist"))throw new Error(r.ChannelError.NoChannelFound);throw new Error(r.ChannelError.AccessDenied)}}async getCurrentChannel(){this.wire.sendAction("fdc3-get-current-channel").catch((e=>{}));const e=await this.getCurrentContextGroupInfo();return e?this.buildChannelObject(e):null}async leaveCurrentChannel(){return this.wire.sendAction("fdc3-leave-current-channel").catch((e=>{})),this.client.removeFromContextGroup()}async getCurrentContextGroupInfo(){const e=await this.client.getContextGroups(),t=e.map((async e=>this.client.getAllClientsInContextGroup(e.id))),n=(await Promise.all(t)).findIndex((e=>e.some((e=>{const{uuid:t,name:n}=e;return this.wire.me.uuid===t&&this.wire.me.name===n}))));return e[n]}async buildChannelObject(e){return{...e,type:"system",addContextListener:(...[e,t])=>{let n,i;"function"==typeof e?(console.warn("addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)"),n=e):(n=t,"string"==typeof e&&(i=e));const r=(async()=>{let e=!0;const t=await this.client.getCurrentContext(i);return this.client.addContextHandler(((i,r)=>{if(!e||(e=!1,!(0,c.isEqual)(t,i)))return n(i,r)}),i)})();return{...r,unsubscribe:()=>r.then((e=>e.unsubscribe()))}},broadcast:this.broadcast.bind(this),getCurrentContext:async e=>{const t=await this.client.getCurrentContext(e);return void 0===t?null:t}}}},e=new WeakMap,Zi}Xi.PrivateChannelClient=class{constructor(e,t){this.id=t,this.client=e,this.listeners=new Map}async broadcast(e){return this.client.dispatch("broadcast",{context:e})}async getCurrentContext(e){return this.client.dispatch("getCurrentContext",{contextType:e})}async addContextListener(e,t){if("function"!=typeof t)throw new Error("Non-function argument passed to the second parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");let n;n=e?`contextHandler:invoke-${this.id}-${e}-${er.generateId()}`:`contextHandler:invoke-${this.id}-${er.generateId()}`,this.client.register(n,er.wrapContextHandler(t,n));const i={unsubscribe:await this.createContextUnsubscribeCb(n)};return this.listeners.set(n,i),await this.client.dispatch("contextHandlerAdded",{handlerId:n,contextType:e}),i}createNonStandardUnsubscribeCb(e){return async()=>{this.client.remove(e),this.listeners.delete(e),await this.client.dispatch("nonStandardHandlerRemoved",{handlerId:e})}}createContextUnsubscribeCb(e){return async()=>{this.client.remove(e),this.listeners.delete(e),await this.client.dispatch("contextHandlerRemoved",{handlerId:e})}}onAddContextListener(e){const t=`onContextHandlerAdded:invoke-${this.id}-${er.generateId()}`;this.client.register(t,e);const n={unsubscribe:this.createNonStandardUnsubscribeCb(t)};return this.listeners.set(t,n),this.client.dispatch("onAddContextHandlerAdded",{handlerId:t}),n}onDisconnect(e){const t=`onDisconnect:invoke-${this.id}-${er.generateId()}`;this.client.register(t,e);const n={unsubscribe:this.createNonStandardUnsubscribeCb(t)};return this.listeners.set(t,n),this.client.dispatch("onDisconnectHandlerAdded",{handlerId:t}),n}onUnsubscribe(e){const t=`onUnsubscribe:invoke-${this.id}-${er.generateId()}`;this.client.register(t,e);const n={unsubscribe:this.createNonStandardUnsubscribeCb(t)};return this.listeners.set(t,n),this.client.dispatch("onUnsubscribeHandlerAdded",{handlerId:t}),n}async cleanUpAllSubs(){Array.from(this.listeners.keys()).forEach((e=>{this.client.remove(e),this.listeners.delete(e)}))}async disconnect(){try{await this.client.dispatch("clientDisconnecting"),await this.cleanUpAllSubs(),await this.client.disconnect()}catch(e){throw new Error(e.message)}}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getIntentResolution=e.isChannel=e.isContext=e.connectPrivateChannel=e.buildAppChannelObject=e.buildPrivateChannelObject=e.ChannelError=e.ResultError=e.UnsupportedChannelApiError=e.getUnsupportedChannelApis=void 0;const t=$i,i=Xi,r=n;e.getUnsupportedChannelApis=e=>({addContextListener:()=>{throw new o("Channel.addContextListener",e)},broadcast:()=>{throw new o("Channel.broadcast",e)},getCurrentContext:()=>{throw new o("Channel.getCurrentContext",e)}});class o extends Error{constructor(e,t="System"){super(e),this.message=`Calling ${e} on an instance of a ${t} Channel returned by fdc3.get${t}Channels is not supported. If you would like to use a ${t} Channel, please use fdc3.joinChannel, fdc3.addContextListener, and fdc3.broadcast instead.`}}var s,a;e.UnsupportedChannelApiError=o,function(e){e.NoResultReturned="NoResultReturned",e.IntentHandlerRejected="IntentHandlerRejected"}(s=e.ResultError||(e.ResultError={})),(a=e.ChannelError||(e.ChannelError={})).NoChannelFound="NoChannelFound",a.AccessDenied="AccessDenied",a.CreationFailed="CreationFailed";e.buildPrivateChannelObject=e=>{let t=!1;const n=()=>{if(t)throw new Error("Private Channel Client has been disconnected from the Private Channel")};return{id:e.id,type:"private",broadcast:async t=>(n(),e.broadcast(t)),getCurrentContext:async t=>(n(),e.getCurrentContext(t)),addContextListener:async(t,i)=>{n();let r=i,o=t;"function"==typeof t&&(console.warn("addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)"),r=t,o=null);return e.addContextListener(o,r)},onAddContextListener:t=>(n(),e.onAddContextListener(t)),disconnect:async()=>(n(),t=!0,e.disconnect()),onDisconnect:t=>(n(),e.onDisconnect(t)),onUnsubscribe:t=>(n(),e.onUnsubscribe(t))}};e.buildAppChannelObject=e=>({id:e.id,type:"app",broadcast:e.setContext,getCurrentContext:async t=>{const n=await e.getCurrentContext(t);return void 0===n?null:n},addContextListener:(t,n)=>{let i,o;"function"==typeof t?(console.warn("addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)"),i=t):(i=n,"string"==typeof t&&(o=t));const s=(async()=>{let t=!0;const n=await e.getCurrentContext(o);return e.addContextHandler(((e,o)=>{if(!t||(t=!1,!(0,r.isEqual)(n,e)))return i(e,o)}),o)})();return{...s,unsubscribe:()=>s.then((e=>e.unsubscribe()))}}});e.connectPrivateChannel=async t=>{try{const n=await fin.InterApplicationBus.Channel.connect(t),r=new i.PrivateChannelClient(n,t);return(0,e.buildPrivateChannelObject)(r)}catch(e){throw new Error(`Private Channel with id: ${t} doesn't exist`)}};e.isContext=e=>{if(e&&"object"==typeof e&&"type"in e){const{type:t}=e;return"string"==typeof t}return!1};e.isChannel=e=>{if(e&&"object"==typeof e&&"type"in e&&"id"in e){const{type:t,id:n}=e;return"string"==typeof t&&"string"==typeof n&&("app"===t||"private"===t)}return!1};e.getIntentResolution=async(n,i,r,o)=>{const a=(0,t.generateId)(),c=new Promise(((e,t)=>{fin.InterApplicationBus.subscribe({uuid:"*"},a,(t=>{e(t)})).catch((()=>t(new Error("getResult is not supported in this environment"))))})),d=r?{target:r,intentResolutionResultId:a}:{intentResolutionResultId:a},h=o?{name:o,context:i,metadata:d}:{...i,metadata:d},l=async()=>{let t=await c;if(!t||"object"!=typeof t)throw new Error(s.NoResultReturned);const{error:i}=t;if(i)throw new Error(s.IntentHandlerRejected);if((0,e.isChannel)(t)){const{id:i,type:r}=t;switch(r){case"private":t=await(0,e.connectPrivateChannel)(i);break;case"app":{const r=await n.joinSessionContextGroup(i);t=(0,e.buildAppChannelObject)(r);break}}}else if(!(0,e.isContext)(t))throw new Error(s.NoResultReturned);return t},u=o?await n.fireIntent(h):await n.fireIntentForContext(h);return"object"!=typeof u?{source:{appId:"",instanceId:""},intent:"",version:"2.0",getResult:l}:{...u,getResult:l}}}(Qi);var rr,or,sr={};function ar(){if(or)return Di;or=1;var e,t,n=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},i=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(Di,"__esModule",{value:!0}),Di.InteropClient=void 0;const r=c,s=Ui,a=function(){if(nr)return Ji;nr=1,Object.defineProperty(Ji,"__esModule",{value:!0}),Ji.Fdc3Module=void 0;const e=$i,t=ir();class n extends t.FDC3ModuleBase{async open(e,t){await super._open(e,t)}addContextListener(e,t){let n;return this.wire.sendAction("fdc3-add-context-listener").catch((e=>{})),"function"==typeof e?(console.warn("addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)"),n=this.client.addContextHandler(e)):n=this.client.addContextHandler(t,null===e?void 0:e),{...n,unsubscribe:()=>n.then((e=>e.unsubscribe()))}}addIntentListener(e,t){this.wire.sendAction("fdc3-add-intent-listener").catch((e=>{}));const n=this.client.registerIntentHandler((e=>{const{context:n,metadata:i}=e,{metadata:r}=n,o=i?.intentResolutionResultId||r?.intentResolutionResultId;o&&this.fin.InterApplicationBus.publish(o,null).catch((()=>null)),t(e.context)}),e,{fdc3Version:"1.2"});return{...n,unsubscribe:()=>n.then((e=>e.unsubscribe()))}}async raiseIntent(t,n,i){this.wire.sendAction("fdc3-raise-intent").catch((e=>{}));const r=i?{name:t,context:n,metadata:{target:i}}:{name:t,context:n};try{return await this.client.fireIntent(r)}catch(t){const n=t.message===e.BROKER_ERRORS.fireIntent?"ResolverUnavailable":t.message;throw new Error(n)}}async findIntent(t,n){this.wire.sendAction("fdc3-find-intent").catch((e=>{}));try{return await this.client.getInfoForIntent({name:t,context:n})}catch(t){const n=t.message===e.BROKER_ERRORS.getInfoForIntent?"ResolverUnavailable":t.message;throw new Error(n)}}async findIntentsByContext(t){this.wire.sendAction("fdc3-find-intents-by-context").catch((e=>{}));try{return await this.client.getInfoForIntentsByContext(t)}catch(t){const n=t.message===e.BROKER_ERRORS.getInfoForIntentsByContext?"ResolverUnavailable":t.message;throw new Error(n)}}async raiseIntentForContext(t,n){this.wire.sendAction("fdc3-raise-intent-for-context").catch((e=>{}));try{return await this.client.fireIntentForContext({...t,metadata:{target:n}})}catch(t){const n=t.message===e.BROKER_ERRORS.fireIntentForContext?"ResolverUnavailable":t.message;throw new Error(n)}}async getOrCreateChannel(e){return super.getOrCreateChannel(e)}getInfo(){return this.wire.sendAction("fdc3-get-info").catch((e=>{})),{providerVersion:this.wire.environment.getAdapterVersionSync(),provider:`openfin-${this.wire.me.uuid}`,fdc3Version:"1.2"}}}return Ji.Fdc3Module=n,Ji}(),d=function(){if(rr)return sr;rr=1,Object.defineProperty(sr,"__esModule",{value:!0}),sr.Fdc3Module2=void 0;const e=ir(),t=$i,n=ar(),i=Qi,r=Xi;class o extends e.FDC3ModuleBase{async open(e,t){return"string"==typeof e&&console.warn("Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string })."),super._open(e,t)}async findInstances(e){this.wire.sendAction("fdc3-find-instances").catch((e=>{}));try{return await n.InteropClient.ferryFdc3Call(this.client,"fdc3FindInstances",e)}catch(e){const n=e.message===t.BROKER_ERRORS.fdc3FindInstances?"ResolverUnavailable":e.message;throw new Error(n)}}async getAppMetadata(e){this.wire.sendAction("fdc3-get-app-metadata").catch((e=>{}));try{return await n.InteropClient.ferryFdc3Call(this.client,"fdc3GetAppMetadata",e)}catch(e){const n=e.message===t.BROKER_ERRORS.fdc3GetAppMetadata?"ResolverUnavailable":e.message;throw new Error(n)}}async addContextListener(e,t){this.wire.sendAction("fdc3-add-context-listener").catch((e=>{}));const n=e=>t=>{const{contextMetadata:n,...i}=t,r=n?[{...i},n]:[t,null];e(...r)};let i=t,r=n(i);return"function"==typeof e?(console.warn("addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)"),i=e,r=n(i),this.client.addContextHandler(r)):this.client.addContextHandler(r,null===e?void 0:e)}async findIntent(e,n,i){this.wire.sendAction("fdc3-find-intent").catch((e=>{}));try{return await this.client.getInfoForIntent({name:e,context:n,metadata:{resultType:i}})}catch(e){const n=e.message===t.BROKER_ERRORS.getInfoForIntent?"ResolverUnavailable":e.message;throw new Error(n)}}async findIntentsByContext(e,i){this.wire.sendAction("fdc3-find-intents-by-context").catch((e=>{}));const r=i?{context:e,metadata:{resultType:i}}:e;try{return await n.InteropClient.ferryFdc3Call(this.client,"fdc3v2FindIntentsByContext",r)}catch(e){const n=e.message===t.BROKER_ERRORS.getInfoForIntentsByContext?"ResolverUnavailable":e.message;throw new Error(n)}}async raiseIntent(e,n,r){this.wire.sendAction("fdc3-raise-intent").catch((e=>{}));try{return"string"==typeof r&&console.warn("Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string })."),(0,i.getIntentResolution)(this.client,n,r,e)}catch(e){const n=e.message===t.BROKER_ERRORS.fireIntent?"ResolverUnavailable":e.message;throw new Error(n)}}async raiseIntentForContext(e,n){this.wire.sendAction("fdc3-raise-intent-for-context").catch((e=>{}));try{return"string"==typeof n&&console.warn("Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string })."),(0,i.getIntentResolution)(this.client,e,n)}catch(e){const n=e.message===t.BROKER_ERRORS.fireIntent?"ResolverUnavailable":e.message;throw new Error(n)}}async addIntentListener(e,t){if(this.wire.sendAction("fdc3-add-intent-listener").catch((e=>{})),"string"!=typeof e)throw new Error("First argument must be an Intent name");return this.client.registerIntentHandler((async e=>{let n,i;const{context:r,metadata:o}=e,{contextMetadata:s,metadata:a,...c}=r,d=o?.intentResolutionResultId||a?.intentResolutionResultId;try{const e=a?{metadata:a,...c}:{...c};n=await t(e,s),i=n}catch(e){n=e,i={error:!0}}if(d&&this.fin.InterApplicationBus.publish(d,i).catch((()=>null)),n instanceof Error)throw new Error(n.message);return n}),e,{fdc3Version:"2.0"})}async getOrCreateChannel(e){return super.getOrCreateChannel(e)}async createPrivateChannel(){const e=(0,t.generateId)();await n.InteropClient.ferryFdc3Call(this.client,"createPrivateChannelProvider",{channelId:e});const o=await this.fin.InterApplicationBus.Channel.connect(e),s=new r.PrivateChannelClient(o,e);return(0,i.buildPrivateChannelObject)(s)}async getUserChannels(){return(await this.client.getContextGroups()).map((e=>({...e,type:"user",...(0,i.getUnsupportedChannelApis)("User")})))}async getSystemChannels(){return console.warn("This API has been deprecated. Please use fdc3.getUserChannels instead."),super.getSystemChannels()}async joinUserChannel(e){return super.joinChannel(e)}async joinChannel(e){return console.warn("This API has been deprecated. Please use fdc3.joinUserChannel instead."),super.joinChannel(e)}async getCurrentChannel(){const e=await super.getCurrentChannel();return e?{...e,type:"user",broadcast:this.broadcast.bind(this)}:null}async getInfo(){return n.InteropClient.ferryFdc3Call(this.client,"fdc3v2GetInfo",{fdc3Version:"2.0"})}}return sr.Fdc3Module2=o,sr}(),h=$i;let l=class extends r.Base{constructor(i,r){super(i),e.set(this,void 0),t.set(this,void 0),n(this,t,new Map,"f"),n(this,e,r,"f")}async setContext(t){this.wire.sendAction("interop-client-set-context").catch((e=>{}));return(await i(this,e,"f")).dispatch("setContext",{context:t})}async addContextHandler(t,n){if(this.wire.sendAction("interop-client-add-context-handler").catch((e=>{})),"function"!=typeof t)throw new Error("Non-function argument passed to the first parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");const r=await i(this,e,"f");let o;o=n?`invokeContextHandler-${n}-${(0,h.generateId)()}`:"invokeContextHandler";const s=(0,h.wrapContextHandler)(t,o);return r.register(o,s),await r.dispatch("contextHandlerRegistered",{handlerId:o,contextType:n}),{unsubscribe:async()=>{r.remove(o),await r.dispatch("removeContextHandler",{handlerId:o})}}}async getContextGroups(){this.wire.sendAction("interop-client-get-context-groups").catch((e=>{}));return(await i(this,e,"f")).dispatch("getContextGroups")}async joinContextGroup(t,n){this.wire.sendAction("interop-client-join-context-group").catch((e=>{}));const r=await i(this,e,"f");if(!t)throw new Error("No contextGroupId specified for joinContextGroup.");return r.dispatch("joinContextGroup",{contextGroupId:t,target:n})}async removeFromContextGroup(t){this.wire.sendAction("interop-client-remove-from-context-group").catch((e=>{}));return(await i(this,e,"f")).dispatch("removeFromContextGroup",{target:t})}async getAllClientsInContextGroup(t){this.wire.sendAction("interop-client-get-all-clients-in-context-group").catch((e=>{}));const n=await i(this,e,"f");if(!t)throw new Error("No contextGroupId specified for getAllClientsInContextGroup.");return n.dispatch("getAllClientsInContextGroup",{contextGroupId:t})}async getInfoForContextGroup(t){this.wire.sendAction("interop-client-get-info-for-context-group").catch((e=>{}));const n=await i(this,e,"f");if(!t)throw new Error("No contextGroupId specified for getInfoForContextGroup.");return n.dispatch("getInfoForContextGroup",{contextGroupId:t})}async fireIntent(t){this.wire.sendAction("interop-client-fire-intent").catch((e=>{}));return(await i(this,e,"f")).dispatch("fireIntent",t)}async registerIntentHandler(t,n,r){this.wire.sendAction("interop-client-register-intent-handler").catch((e=>{}));const o=await i(this,e,"f"),s=`intent-handler-${n}`,a=(0,h.wrapIntentHandler)(t,s);try{await o.register(s,a),await o.dispatch("intentHandlerRegistered",{handlerId:s,...r})}catch(e){throw new Error("Unable to register intent handler")}return{unsubscribe:async()=>{o.remove(s)}}}async getCurrentContext(t){this.wire.sendAction("interop-client-get-current-context").catch((e=>{}));return(await i(this,e,"f")).dispatch("getCurrentContext",{contextType:t})}async getInfoForIntent(t){this.wire.sendAction("interop-client-get-info-for-intent").catch((e=>{}));return(await i(this,e,"f")).dispatch("getInfoForIntent",t)}async getInfoForIntentsByContext(t){this.wire.sendAction("interop-client-get-info-for-intents-by-context").catch((e=>{}));return(await i(this,e,"f")).dispatch("getInfoForIntentsByContext",t)}async fireIntentForContext(t){this.wire.sendAction("interop-client-fire-intent-for-context").catch((e=>{}));return(await i(this,e,"f")).dispatch("fireIntentForContext",t)}async joinSessionContextGroup(n){try{const r=i(this,t,"f").get(n);if(r)return r.getUserInstance();const o=await i(this,e,"f"),{hasConflict:a}=await o.dispatch("sessionContextGroup:createIfNeeded",{sessionContextGroupId:n});a&&console.warn(`A (non-session) context group with the name "${n}" already exists. If you are trying to join a Context Group, call joinContextGroup instead.`);const c=new s.default(this.wire,i(this,e,"f"),n);return i(this,t,"f").set(n,c),c.getUserInstance()}catch(e){throw console.error(`Error thrown trying to create Session Context Group with id "${n}": ${e}`),e}}async onDisconnection(t){this.wire.sendAction("interop-client-add-ondisconnection-listener").catch((e=>{}));return(await i(this,e,"f")).onDisconnection((e=>{const{uuid:n}=e;t({type:"interop-broker",topic:"disconnected",brokerName:n})}))}getFDC3Sync(e){switch(e){case"1.2":return new a.Fdc3Module((()=>this),this.wire);case"2.0":return new d.Fdc3Module2((()=>this),this.wire);default:throw new Error(`Invalid FDC3 version provided: ${e}. Must be '1.2' or '2.0'`)}}async getFDC3(e){return this.getFDC3Sync(e)}static async ferryFdc3Call(t,n,r){return(await i(t,e,"f")).dispatch(n,r||null)}};return Di.InteropClient=l,e=new WeakMap,t=new WeakMap,Di}var cr,dr,hr,lr={};function ur(){if(cr)return lr;cr=1,Object.defineProperty(lr,"__esModule",{value:!0}),lr.overrideCheck=lr.checkFDC32Overrides=lr.getDefaultViewFdc3VersionFromAppInfo=void 0;const e=Hi();function t(t){return["fdc3HandleFindInstances","handleInfoForIntent","handleInfoForIntentsByContext","fdc3HandleGetAppMetadata","fdc3HandleGetInfo","fdc3HandleOpen","handleFiredIntent","handleFiredIntentForContext"].filter((n=>t[n]===e.InteropBroker.prototype[n]))}return lr.getDefaultViewFdc3VersionFromAppInfo=function({manifest:e,initialOptions:t}){const n=e?.platform?.defaultViewOptions?.fdc3InteropApi??t.defaultViewOptions?.fdc3InteropApi;return["1.2","2.0"].includes(n??"")?n:void 0},lr.checkFDC32Overrides=t,lr.overrideCheck=function(e,n){if(n&&"2.0"===n){const n=t(e);n.length>0&&console.warn(`WARNING: FDC3 2.0 has been set as a default option for Views in this Platform, but the required InteropBroker APIs for FDC3 2.0 compliance have not all been overridden.\nThe following APIs need to be overridden:\n${n.join("\n")}`)}},lr}function pr(){return hr||(hr=1,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),i=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),i(function(){if(dr)return Fi;dr=1,Object.defineProperty(Fi,"__esModule",{value:!0}),Fi.InteropModule=void 0;const e=n,t=ji,i=c,r=Hi(),o=ar(),s=ur(),a=ri,d=e=>new e,h="You have attempted to use or modify InteropBroker parameters, which is not allowed. You are likely using an older InteropBroker override scheme. Please consult our Interop docs for guidance on migrating to the new override scheme.";class l extends i.Base{async init(n,i=d){this.wire.sendAction("interop-init").catch((()=>{}));const o=await this.wire.environment.getInteropInfo(this.wire.getFin()),c=(0,t.createUnusableObject)(h),l=(0,t.createWarningObject)(h,(0,e.cloneDeep)(o)),u=async()=>{throw new Error(h)},p=r.InteropBroker.createClosedConstructor(this.wire,(()=>this.fin.InterApplicationBus.Channel.create(`interop-broker-${n}`)),o);let w;return w=Array.isArray(i)?new((0,a.overrideFromComposables)(...i)(p))(c,u,l):await i(p,c,u,l),(0,s.overrideCheck)(w,o.fdc3Version),w}connectSync(e,t){return this.wire.sendAction("interop-connect-sync").catch((()=>{})),new o.InteropClient(this.wire,this.wire.environment.whenReady().then((()=>this.fin.InterApplicationBus.Channel.connect(`interop-broker-${e}`,{payload:t}))))}}return Fi.InteropModule=l,Fi}(),e),i(ar(),e),i(Hi(),e)}(Ri)),Ri}var wr={},yr={},fr={},gr={};Object.defineProperty(gr,"__esModule",{value:!0}),gr.getSnapshotSourceChannelName=void 0;gr.getSnapshotSourceChannelName=e=>`snapshot-source-provider-${e.uuid}`;var mr,vr,Cr,br,Ir,Er=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},xr=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(fr,"__esModule",{value:!0}),fr.SnapshotSource=void 0;const Ar=c,Pr=gr,Mr=new Map;class Or extends Ar.Base{constructor(e,t){super(e),mr.set(this,void 0),vr.set(this,(()=>(Mr.has(this.identity.uuid)||Mr.set(this.identity.uuid,{eventFired:null,clientPromise:null}),Mr.get(this.identity.uuid)))),Cr.set(this,(()=>(xr(this,vr,"f").call(this).clientPromise||(xr(this,vr,"f").call(this).clientPromise=xr(this,br,"f").call(this)),xr(this,vr,"f").call(this).clientPromise))),br.set(this,(async()=>{const e=(0,Pr.getSnapshotSourceChannelName)(this.identity);try{xr(this,vr,"f").call(this).eventFired||await xr(this,Ir,"f").call(this);const t=await this.fin.InterApplicationBus.Channel.connect(e,{wait:!1});return t.onDisconnection((()=>{xr(this,vr,"f").call(this).clientPromise=null,xr(this,vr,"f").call(this).eventFired=null})),t}catch(e){throw xr(this,vr,"f").call(this).clientPromise=null,new Error("The targeted SnapshotSource is not currently initialized. Await this object's ready() method.")}})),Ir.set(this,(async()=>{const e=(0,Pr.getSnapshotSourceChannelName)(this.identity);let t,n;const i=new Promise(((e,i)=>{t=e,n=i}));xr(this,vr,"f").call(this).eventFired=i;const r=async i=>{try{i.channelName===e&&(t(),await this.fin.InterApplicationBus.Channel.removeListener("connected",r))}catch(e){n(e)}};await this.fin.InterApplicationBus.Channel.on("connected",r)})),Er(this,mr,t,"f")}get identity(){return xr(this,mr,"f")}async ready(){this.wire.sendAction("snapshot-source-ready").catch((e=>{}));try{await xr(this,Cr,"f").call(this)}catch(e){await xr(this,vr,"f").call(this).eventFired}}async getSnapshot(){this.wire.sendAction("snapshot-source-get-snapshot").catch((e=>{}));const e=await xr(this,Cr,"f").call(this),t=await e.dispatch("get-snapshot");return(await t).snapshot}async applySnapshot(e){this.wire.sendAction("snapshot-source-apply-snapshot").catch((e=>{}));return(await xr(this,Cr,"f").call(this)).dispatch("apply-snapshot",{snapshot:e})}}fr.SnapshotSource=Or,mr=new WeakMap,vr=new WeakMap,Cr=new WeakMap,br=new WeakMap,Ir=new WeakMap,Object.defineProperty(yr,"__esModule",{value:!0}),yr.SnapshotSourceModule=void 0;const _r=c,Sr=fr,Rr=gr;class Fr extends _r.Base{async init(e){if(this.wire.sendAction("snapshot-source-init").catch((e=>{})),"object"!=typeof e||"function"!=typeof e.getSnapshot||"function"!=typeof e.applySnapshot)throw new Error("you must pass in a valid SnapshotProvider");const t=await this.fin.InterApplicationBus.Channel.create((0,Rr.getSnapshotSourceChannelName)(this.fin.me));t.register("get-snapshot",(async()=>({snapshot:await e.getSnapshot()}))),t.register("apply-snapshot",(({snapshot:t})=>e.applySnapshot(t)))}wrapSync(e){return this.wire.sendAction("snapshot-source-wrap-sync").catch((e=>{})),new Sr.SnapshotSource(this.wire,e)}async wrap(e){return this.wire.sendAction("snapshot-source-wrap").catch((e=>{})),this.wrapSync(e)}}yr.SnapshotSourceModule=Fr,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(yr,e),n(fr,e)}(wr),Object.defineProperty(s,"__esModule",{value:!0});var jr=s.Fin=void 0;const Lr=t,kr=a,Tr=Pe(),$r=Ce(),Br=Fe,Gr=En,Wr=Pn,Hr=Ln,Nr=Dn,Dr=me(),Ur=Kn,Vr=Si,zr=pr(),Kr=wr;class qr extends Lr.EventEmitter{constructor(e){super(),this.wire=e,this.System=new kr.System(e),this.Window=new Tr._WindowModule(e),this.Application=new $r.ApplicationModule(e),this.InterApplicationBus=new Br.InterApplicationBus(e),this.Clipboard=new Gr.Clipboard(e),this.ExternalApplication=new Wr.ExternalApplicationModule(e),this.Frame=new Hr._FrameModule(e),this.GlobalHotkey=new Nr.GlobalHotkey(e),this.Platform=new Ur.PlatformModule(e,this.InterApplicationBus.Channel),this.View=new Dr.ViewModule(e),this.Interop=new zr.InteropModule(e),this.SnapshotSource=new Kr.SnapshotSourceModule(e),e.registerFin(this),this.me=(0,Vr.getMe)(e),e.on("disconnected",(()=>{this.emit("disconnected")}))}}jr=s.Fin=qr;var Yr={},Jr={};function Zr(e){return"string"==typeof e.manifestUrl}function Qr(e){return eo(e)&&"string"==typeof e.address}function Xr(e){return Qr(e)&&"string"==typeof e.token}function eo(e){return"string"==typeof e.uuid}function to(e){return e.runtime&&"string"==typeof e.runtime.version}function no(e){return eo(e)&&to(e)}Object.defineProperty(Jr,"__esModule",{value:!0}),Jr.isInternalConnectConfig=Jr.isPortDiscoveryConfig=Jr.isNewConnectConfig=Jr.isConfigWithReceiver=Jr.isRemoteConfig=Jr.isExistingConnectConfig=Jr.isExternalConfig=void 0,Jr.isExternalConfig=Zr,Jr.isExistingConnectConfig=Qr,Jr.isRemoteConfig=Xr,Jr.isConfigWithReceiver=function(e){return"object"==typeof e.receiver&&Xr({...e,address:""})},Jr.isNewConnectConfig=no,Jr.isPortDiscoveryConfig=function(e){return Zr(e)&&to(e)||no(e)},Jr.isInternalConnectConfig=function(e){return Qr(e)||no(e)};var io={},ro={};Object.defineProperty(ro,"__esModule",{value:!0}),ro.EmitterMap=void 0;const oo=t;function so(e){return Buffer.from(e).toString("base64")}ro.EmitterMap=class{constructor(){this.storage=new Map}hashKeys(e){return e.map(so).join("/")}getOrCreate(e){const t=this.hashKeys(e);return this.storage.has(t)||this.storage.set(t,new oo.EventEmitter),this.storage.get(t)}has(e){return this.storage.has(this.hashKeys(e))}delete(e){const t=this.hashKeys(e);return this.storage.delete(t)}},Object.defineProperty(io,"__esModule",{value:!0});const ao=ro;class co extends ao.EmitterMap{constructor(){super(...arguments),this.dispatchEvent=e=>{if(function(e){return"process-desktop-event"===e.action}(e)){const{payload:t}=e,n=function(e){const{topic:t}=e;if("frame"===t||"window"===t||"view"===t){const{uuid:n,name:i}=e;return[t,n,i]}if("application"===t){const{uuid:n}=e;return[t,n]}return[t]}(t);if(this.has(n))return this.getOrCreate(n).emit(t.type,t),!0}return!1}}}io.default=co;var ho,lo,uo=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},po=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(Yr,"__esModule",{value:!0});var wo=Yr.Transport=void 0;const yo=t,fo=Jr,go=f,mo=io,vo=Si,Co=it;class bo extends yo.EventEmitter{constructor(e,t,n){super(),this.wireListeners=new Map,this.topicRefMap=new Map,this.eventAggregator=new mo.default,this.messageHandlers=[this.eventAggregator.dispatchEvent],ho.set(this,void 0),lo.set(this,void 0),this.connectSync=()=>{po(this,ho,"f").connectSync()},this.getPort=()=>po(this,ho,"f").getPort(),uo(this,ho,new e(this.onmessage.bind(this)),"f"),this.environment=t,this.sendRaw=po(this,ho,"f").send.bind(po(this,ho,"f")),this.registerMessageHandler(this.handleMessage.bind(this)),po(this,ho,"f").on("disconnected",(()=>{for(const[,{handleNack:e}]of this.wireListeners)e({reason:"Remote connection has closed"});this.wireListeners.clear(),this.emit("disconnected")}));const{uuid:i,name:r}=n,o=this.environment.getCurrentEntityType();this.me=(0,vo.getBaseMe)(o,i,r)}getFin(){if(!po(this,lo,"f"))throw new Error("No Fin object registered for this transport");return po(this,lo,"f")}registerFin(e){if(po(this,lo,"f"))throw new Error("Fin object has already been registered for this transport");uo(this,lo,e,"f")}shutdown(){return po(this,ho,"f").shutdown()}async connect(e){if((0,fo.isConfigWithReceiver)(e))return await po(this,ho,"f").connect(e.receiver),this.authorize(e);if((0,fo.isRemoteConfig)(e))return this.connectRemote(e);if((0,fo.isExistingConnectConfig)(e))return this.connectByPort(e);if((0,fo.isNewConnectConfig)(e)){const t=await this.environment.retrievePort(e);return this.connectByPort({...e,address:`ws://localhost:${t}`})}}async connectRemote(e){return await po(this,ho,"f").connect(new(this.environment.getWsConstructor())(e.address)),this.authorize(e)}async connectByPort(e){const{address:t,uuid:n}=e,i={...e,type:"file-token"},r=po(this,ho,"f");await r.connect(new(this.environment.getWsConstructor())(e.address));const o=await this.sendAction("request-external-authorization",{uuid:n,type:"file-token"},!0);if("external-authorization-response"!==o.action)throw new go.UnexpectedActionError(o.action);return await this.environment.writeToken(o.payload.file,o.payload.token),this.authorize(i)}async authorize(e){const t=await this.sendAction("request-authorization",e,!0);if("authorization-response"!==t.action)throw new go.UnexpectedActionError(t.action);if(!0!==t.payload.success)throw new go.RuntimeError(t.payload)}sendAction(e,t={},n=!1){let i=()=>{};const r=go.RuntimeError.getCallSite(1),o=this.environment.getNextMessageId(),s=new Promise(((s,a)=>{i=a;const c={action:e,payload:t,messageId:o},d=po(this,ho,"f");return this.addWireListener(o,s,(e=>this.nackHandler(e,a,r)),n),d.send(c).catch(a)}));return Object.assign(s,{cancel:i,messageId:o})}nackHandler(e,t,n){t("string"==typeof e?e:new go.RuntimeError(e,n))}ferryAction(e){return new Promise(((t,n)=>{const i=this.environment.getNextMessageId();e.messageId=i;const r=e=>{t(e.payload)};return po(this,ho,"f").send(e).then((()=>this.addWireListener(i,r,(e=>this.nackHandler(e,n)),!1))).catch(n)}))}registerMessageHandler(e){this.messageHandlers.push(e)}addWireListener(e,t,n,i){i?this.uncorrelatedListener=t:this.wireListeners.has(e)?n({reason:"Duplicate handler id",error:(0,Co.errorToPOJO)(new go.DuplicateCorrelationError(String(e)))}):this.wireListeners.set(e,{resolve:t,handleNack:n})}onmessage(e){for(const t of this.messageHandlers)t.call(null,e)}handleMessage(e){const t=e.correlationId||NaN;if("correlationId"in e){if(!this.wireListeners.has(t))return!1;{const{resolve:n,handleNack:i}=this.wireListeners.get(t);"ack"!==e.action?i({reason:"Did not receive ack action",error:(0,Co.errorToPOJO)(new go.NoAckError(e.action))}):"payload"in e?e.payload.success?n.call(null,e):i(e.payload):"string"==typeof e.reason?i(e):(console.warn("Received invalid response from core",e),i({reason:"invalid response shape"})),this.wireListeners.delete(t)}}else this.uncorrelatedListener&&this.uncorrelatedListener.call(null,e),this.uncorrelatedListener=()=>{};return!0}}wo=Yr.Transport=bo,ho=new WeakMap,lo=new WeakMap;const Io=(...e)=>({log:(...t)=>console.log(`[${(new Date).toISOString()}]`,...(e=>e.map((e=>`[${e}]`)))(e),...t),getLogger:(...t)=>Io(...e,...t)}),Eo=Io("[@openfin/core-web/client");function xo(e,t){if(!function(e){return"string"==typeof e}(e))throw new Error(`Property ${t} has invalid type. Expected string, got ${typeof e}.`)}const Ao="web-broker-ports-ready",Po=Eo.getLogger("get-web-interop-ports");function Mo(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function Oo(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;const _o=e=>{var n,i,r;return r=class extends t.EventEmitter{constructor(t){super(),n.set(this,void 0),i.set(this,!1),this.connectSync=()=>{Mo(this,i,"f")||(e.addEventListener("message",(e=>{e.data?.topic?.startsWith("wire-message")&&e.data.message&&Mo(this,n,"f").call(this,{...JSON.parse(e.data.message),ports:e.ports})})),e.start())},this.connect=async()=>{this.connectSync()},this.send=t=>(e.postMessage({topic:"wire-message",message:JSON.stringify(t)}),Promise.resolve()),this.shutdown=async()=>{e.close()},Oo(this,n,t,"f")}getPort(){return e}},n=new WeakMap,i=new WeakMap,r};var So={},Ro={};Object.defineProperty(Ro,"__esModule",{value:!0}),Ro.BaseEnvironment=void 0;const Fo=ur();Ro.BaseEnvironment=class{async getInteropInfo(e){const t=await e.Application.getCurrentSync().getInfo().catch((()=>null)),n=t?.initialOptions?.interopBrokerConfiguration??{};return{fdc3Version:t?(0,Fo.getDefaultViewFdc3VersionFromAppInfo)(t):void 0,...n,fdc3Info:{providerVersion:await e.System.getVersion(),provider:"OpenFin"}}}},Object.defineProperty(So,"__esModule",{value:!0});var jo=So.BrowserEnvironment=void 0;const Lo=Ro;class ko extends Lo.BaseEnvironment{constructor(){super(...arguments),this.type="other",this.getRandomId=()=>{const e=new Uint32Array(1);return window.crypto.getRandomValues(e)[0].toString(32)}}getAdapterVersionSync(){return""}observeBounds(e,t){throw new Error("Method not implemented.")}layoutAllowedInContext(e){return!1}initLayoutManager(e,t,n){throw new Error("Method not implemented.")}applyLayoutSnapshot(e,t,n){throw new Error("Method not implemented.")}createLayout(e,t){throw new Error("Method not implemented.")}destroyLayout(e,t){throw new Error("Method not implemented.")}resolveLayout(e,t){throw new Error("Method not implemented.")}initPlatform(...e){throw new Error("Method not implemented.")}writeToken(e,t){return Promise.resolve("")}retrievePort(e){throw new Error("Method not implemented.")}getNextMessageId(){return this.getRandomId()}createChildContent(e){throw new Error("Method not implemented.")}getWebWindow(e){throw new Error("Method not implemented.")}getCurrentEntityIdentity(){throw new Error("Method not implemented.")}getCurrentEntityType(){return"external connection"}raiseEvent(e,t){throw new Error("Method not implemented.")}getUrl(){return location.href}getDefaultChannelOptions(){return{create:{},connect:{}}}getRtcPeer(){return new RTCPeerConnection}getWsConstructor(){return WebSocket}whenReady(){return Promise.resolve()}}jo=So.BrowserEnvironment=ko;const To=e=>"platform"in e&&void 0!==e.platform;var $o,Bo;class Go extends jo{constructor(e){super(),this.connectConfig=e,$o.set(this,void 0),Bo.set(this,new G((async()=>Promise.resolve().then((function(){return require("./main-07021ef9.js")}))))),To(e)&&this.validatePlatformOptions(e)}getAdapterVersionSync(){return"0.40.5"}validatePlatformOptions({platform:e}){if(!("layoutSnapshot"in e))throw new Error("Platform options are missing layoutSnapshot. Please provide a layoutSnapshot in the platform options.");if("windows"in e||"windows"in e.layoutSnapshot)throw new Error("It appears you tried to call connect() with a snapshot object from an OpenFin desktop environment. Note that connect() expects to be called with a platform property with this structure: { platform: { layoutSnapshot } }. To get a layoutSnapshot of the expected structure, use fin.Platform.Layout.getCurrentLayoutManagerSync().getLayoutSnapshot() in v34+ in your desktop environment.");const{layouts:t}=e.layoutSnapshot;Object.entries(t).map((([e,t])=>{if("object"!=typeof t||null===t)throw new Error(`Invalid layout detected: layoutSnapshot.layouts.${e} must be an object.`);if(!("content"in t))throw new Error(`Invalid layout detected: layoutSnapshot.layouts.${e} must contain a 'content' property.`)}))}async getInteropInfo(e){return{...{contextGroups:void 0,logging:{beforeAction:{enabled:!1},afterAction:{enabled:!1}}},fdc3Version:void 0,fdc3Info:{providerVersion:"0.40.5",provider:"OpenFin Web"}}}layoutAllowedInContext(e){return!0}async initLayoutManager(e,t,n){if(Mo(this,$o,"f"))throw new Error("Layout already initialized.");if(!To(this.connectConfig))throw new Error("Platform options are missing from connection config.");const{WebLayoutEntryPoint:i}=await Mo(this,Bo,"f").getValue();return Oo(this,$o,new i(this.connectConfig),"f"),await Mo(this,$o,"f").initLayoutManager(e,t,n)}async applyLayoutSnapshot(e,t,n){Mo(this,$o,"f")?.applyLayoutSnapshot(e,t,n)}async createLayout(e,t){return Mo(this,$o,"f")?.createLayout(e,t)}async destroyLayout(e,t){return Mo(this,$o,"f")?.destroyLayout(e,t)}}$o=new WeakMap,Bo=new WeakMap;const Wo=()=>{const e=((e,t)=>{const n=new RegExp(`^${t}<(?<meta>.*)>$`).exec(e)?.groups?.meta;if(n)try{return JSON.parse(atob(n))}catch(e){throw new Error(`Failed to decode JSON from ${n}.`)}})(window.name,"of-frame");if(e)try{const{name:t,uuid:n,brokerUrl:i,providerId:r,contextGroup:o}=e;return xo(i,"brokerUrl"),xo(n,"uuid"),xo(t,"name"),{identity:{name:t,uuid:n},brokerUrl:i,interopConfig:{providerId:r,currentContextGroup:o}}}catch(e){throw new Error(`Unexpected error occurred when inferring platform information: ${e.stack}`)}},Ho=()=>{const e=i.v4();return{uuid:e,name:e}},No=async e=>{if("enabled"===e.connectionInheritance){const t=await(async e=>{const t=Wo();if(t){const{validateOptions:n=(()=>!0)}=e,{identity:i,...r}=t;if(!await n(r))throw new Error("Parent options were rejected by validateOptions.");return t}})(e);if(t)return t}if(!e.options){const t="enabled"===e.connectionInheritance?"Broker URL was not specified nor provided by a platform container.":"Connection inheritance is disabled but no options were provided.";throw new Error(t)}return{...e.options,identity:Ho()}};exports.__classPrivateFieldGet=Mo,exports.__classPrivateFieldSet=Oo,exports.commonjsGlobal=o,exports.connect=async t=>{try{Eo.log("Establishing connection",t);const{brokerUrl:n,identity:i,timeout:o,interopConfig:s}=await No(t),{workerPort:a,iframeBrokerPort:c}=await(async(e,t,n)=>{const{origin:i}=new URL(e),o=document.createElement("IFRAME");let s;o.style.display="none";try{return await new Promise(((a,c)=>{const d=e=>{if(e.source===o.contentWindow&&e.data?.topic===`ack-${Ao}`){if(e.origin!==i)c(new Error(`Broker redirected to unexpected origin ${e.origin}, expected ${i}.`));else if(e.data.success){const[t,n]=e.ports;a({iframeBrokerPort:t,workerPort:n})}else c(new g(e.data));window.removeEventListener("message",d),clearTimeout(s)}};window.addEventListener("message",d),Po.log(`Connecting to broker ${e}`),o.setAttribute("src",e),o.setAttribute("name",r(t,"of-broker")),document.body.appendChild(o),Po.log("Iframe loaded, awaiting init message from iframe"),n&&(s=setTimeout((()=>{window.removeEventListener("message",d),document.body.removeChild(o),c(new Error("Worker did not initialize in time"))}),n))}))}catch(e){throw new Error(`Failed to initialise Fin Web Client. ${e.message}`,{cause:e})}})(n,i,o);Eo.log("Successfully established connection to shared worker");const d={entityType:"external connection",...i};a.start(),c.start();const h=((t,n,i)=>{const r=_o(n),o=new Go(t),s=new wo(r,o,i);return s.connectSync(),window.Buffer=e.Buffer,new jr(s)})(t,a,d);return s?.providerId&&(h.me.interop=h.Interop.connectSync(s.providerId),s?.currentContextGroup&&h.me.interop.joinContextGroup(s.currentContextGroup).catch((e=>{console.warn(`Error joining specified context group: ${s?.currentContextGroup}, continuing`,e)}))),{...h,me:{...h.me,identity:{uuid:h.me.uuid,name:h.me.name}}}}catch(e){throw new Error(`An error occured during web-interop connection: ${e.message}`)}},exports.encodeOptions=r;
|
1
|
+
"use strict";var e=require("buffer/"),t=require("events"),n=require("lodash"),i=require("uuid");const r=(e,t)=>`${t}<${btoa(JSON.stringify(e))}>`;var o="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},s={},a={},c={},d={};async function h(e){const t=[];for(const n of e){const e=await n();t.push(e)}return t}Object.defineProperty(d,"__esModule",{value:!0}),d.promiseMapSerial=d.serial=d.promiseMap=d.promisify=void 0,d.promisify=function(e){return(...t)=>new Promise(((n,i)=>{e(...t,((e,t)=>e?i(e):n(t)))}))},d.promiseMap=async function(e,t){return Promise.all(e.map(t))},d.serial=h,d.promiseMapSerial=async function(e,t){return h(e.map(((e,n,i)=>()=>t(e,n,i))))};var l,u=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},p=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(c,"__esModule",{value:!0}),c.Reply=c.EmitterBase=c.Base=void 0;const w=d;class y{constructor(e){this.isNodeEnvironment=()=>"node"===this.wire.environment.type,this.isOpenFinEnvironment=()=>"openfin"===this.wire.environment.type,this.isBrowserEnvironment=()=>"other"===this.wire.environment.type,this.wire=e}get fin(){return this.wire.getFin()}get me(){return this.wire.me}}c.Base=y;c.EmitterBase=class extends y{constructor(e,t,...n){super(e),this.topic=t,l.set(this,void 0),this.eventNames=()=>this.hasEmitter()?this.getOrCreateEmitter().eventNames():[],this.emit=(e,t,...n)=>!!this.hasEmitter()&&this.getOrCreateEmitter().emit(e,t,...n),this.hasEmitter=()=>this.wire.eventAggregator.has(p(this,l,"f")),this.getOrCreateEmitter=()=>this.wire.eventAggregator.getOrCreate(p(this,l,"f")),this.listeners=e=>this.hasEmitter()?this.getOrCreateEmitter().listeners(e):[],this.listenerCount=e=>this.hasEmitter()?this.getOrCreateEmitter().listenerCount(e):0,this.registerEventListener=async(e,t={},n,i)=>{const r={...this.identity,timestamp:t.timestamp||Date.now(),topic:this.topic,type:e},o=this.getOrCreateEmitter();n(o);try{await this.wire.sendAction("subscribe-to-desktop-event",r)}catch(e){throw i(o),this.deleteEmitterIfNothingRegistered(o),e}},this.deregisterEventListener=async(e,t={})=>{if(this.hasEmitter()){const n={...this.identity,timestamp:t.timestamp||Date.now(),topic:this.topic,type:e};await this.wire.sendAction("unsubscribe-to-desktop-event",n).catch((()=>null));return this.getOrCreateEmitter()}return Promise.resolve()},u(this,l,[t,...n],"f"),this.listeners=e=>this.hasEmitter()?this.getOrCreateEmitter().listeners(e):[]}async on(e,t,n){return await this.registerEventListener(e,n,(n=>{n.on(e,t)}),(n=>{n.removeListener(e,t)})),this}async addListener(e,t,n){return this.on(e,t,n)}async once(e,t,n){const i=()=>this.deregisterEventListener(e);return await this.registerEventListener(e,n,(n=>{n.once(e,i),n.once(e,t)}),(n=>{n.removeListener(e,i),n.removeListener(e,t)})),this}async prependListener(e,t,n){return await this.registerEventListener(e,n,(n=>{n.prependListener(e,t)}),(n=>{n.removeListener(e,t)})),this}async prependOnceListener(e,t,n){const i=()=>this.deregisterEventListener(e);return await this.registerEventListener(e,n,(n=>{n.prependOnceListener(e,t),n.once(e,i)}),(n=>{n.removeListener(e,t),n.removeListener(e,i)})),this}async removeListener(e,t,n){const i=await this.deregisterEventListener(e,n);return i&&(i.removeListener(e,t),this.deleteEmitterIfNothingRegistered(i)),this}async deregisterAllListeners(e){const t={...this.identity,type:e,topic:this.topic};if(this.hasEmitter()){const e=this.getOrCreateEmitter(),n=e.listenerCount(t.type),i=[];for(let e=0;e<n;e++)i.push(this.wire.sendAction("unsubscribe-to-desktop-event",t).catch((()=>null)));return await Promise.all(i),e}}async removeAllListeners(e){const t=async e=>{const t=await this.deregisterAllListeners(e);t&&(t.removeAllListeners(e),this.deleteEmitterIfNothingRegistered(t))};if(e)await t(e);else if(this.hasEmitter()){const e=this.getOrCreateEmitter().eventNames();await(0,w.promiseMap)(e,t)}return this}deleteEmitterIfNothingRegistered(e){0===e.eventNames().length&&this.wire.eventAggregator.delete(p(this,l,"f"))}},l=new WeakMap;c.Reply=class{};var f={};Object.defineProperty(f,"__esModule",{value:!0});var g=f.RuntimeError=f.NotSupportedError=f.NotImplementedError=f.NoAckError=f.DuplicateCorrelationError=f.UnexpectedActionError=f.DisconnectedError=void 0;class m extends Error{constructor(e){super(`Expected websocket state OPEN but found ${e}`),this.readyState=e}}f.DisconnectedError=m;class v extends Error{}f.UnexpectedActionError=v;class C extends Error{}f.DuplicateCorrelationError=C;class b extends Error{}f.NoAckError=b;class I extends Error{}f.NotImplementedError=I;class E extends Error{}f.NotSupportedError=E;class x extends Error{constructor(e){const{message:t,name:n,stack:i,...r}=e;super(t),this.name=n||"Error",this.stack=i??this.toString(),Object.keys(r).forEach((e=>{this[e]=r[e]}))}}class A extends Error{static getCallSite(e=0){const t=Error.stackTraceLimit,n=e+1;Error.stackTraceLimit=t+n;const i=Error.prepareStackTrace;Error.prepareStackTrace=(e,t)=>t;const r=(new Error).stack?.slice(n)??[];return Error.prepareStackTrace=i,Error.stackTraceLimit=t,r}static prepareStackTrace(e,t){if("function"==typeof Error.prepareStackTrace)return Error.prepareStackTrace(e,t);let n="";n+=e.name||"Error",n+=`: ${e.message||""}`;for(const e of t)n+=`\n at ${e.toString()}`;return n}constructor(e,t){const{reason:n,error:i}=e;super(n),this.name="RuntimeError",i?.stack&&(this.cause=new x(i)),t&&(this.stack=A.prepareStackTrace(this,t))}}g=f.RuntimeError=A;var P={},M={},O={};Object.defineProperty(O,"__esModule",{value:!0}),O.validateIdentity=void 0,O.validateIdentity=function(e){let t;return"object"==typeof e&&"string"==typeof e.uuid||(t="Not a valid identity object"),t};var _={},S={},R={},F={},j={},L={},k={};Object.defineProperty(k,"__esModule",{value:!0}),k.handleDeprecatedWarnings=void 0;var T;k.handleDeprecatedWarnings=e=>{(e.contentNavigation?.whitelist||e.contentNavigation?.blacklist||e.contentRedirect?.whitelist||e.contentRedirect?.blacklist)&&console.warn("The properties 'whitelist' and 'blacklist' have been marked as deprecated and will be removed in a future version. Please use 'allowlist' and 'denylist'.")};var $={},B={};Object.defineProperty(B,"__esModule",{value:!0}),B.AsyncRetryableLazy=G=B.Lazy=void 0;var G=B.Lazy=class{constructor(e){this.producerFn=e}getValue(){return this.value||(this.value=this.producerFn()),this.value}};B.AsyncRetryableLazy=class{constructor(e){this.producerFn=e}async getValue(){return this.promise||(this.promise=this.producerFn().catch((e=>{throw delete this.promise,e}))),this.promise}};var W={},H={},N={};Object.defineProperty(N,"__esModule",{value:!0}),N.ApiConsumer=void 0;N.ApiConsumer=class{constructor(e){this.strategy=e,this.consume=async e=>(await this.strategy.getExposedFunctions(e)).reduce(((t,n)=>({...t,[n.key]:this.strategy.createFunction(n,e)})),{})}};var D={},U={};Object.defineProperty(U,"__esModule",{value:!0}),U.expose=U.getExposedProperties=void 0;const V=Symbol("exposedProperties");U.getExposedProperties=e=>e[V]||e.prototype[V]||[];U.expose=e=>(t,n,i)=>{t[V]=t[V]||[],t[V].push({key:n,descriptor:i,options:e})},Object.defineProperty(D,"__esModule",{value:!0}),D.ApiExposer=void 0;const z=U;D.ApiExposer=class{constructor(e){this.strategy=e,this.exposeInstance=async(e,t)=>{const n=(0,z.getExposedProperties)(e),i=await Promise.all(n.map((async({key:n,options:i})=>({key:n,options:await this.strategy.exposeFunction(e[n].bind(e),{key:n,options:i,meta:t})}))));await this.strategy.exposeMeta(t,i)}}};var K={},q={},Y={};Object.defineProperty(Y,"__esModule",{value:!0}),Y.ChannelsConsumer=void 0;Y.ChannelsConsumer=class{constructor(e){this.channel=e,this.getExposedFunctions=async e=>{const{id:t}=e,{props:n}=await this.channel.dispatch(`api-meta:${t}`);return n},this.createFunction=e=>(...t)=>{const{action:n}=e.options;return this.channel.dispatch(n,{args:t})}}};var J={};Object.defineProperty(J,"__esModule",{value:!0}),J.ChannelsExposer=void 0;J.ChannelsExposer=class{constructor(e){this.channelProviderOrClient=e,this.exposeFunction=async(e,t)=>{const{key:n,options:i,meta:r}=t,{id:o}=r,s=`${o}.${i?.action||n}`;return await this.channelProviderOrClient.register(s,(async({args:t})=>e(...t))),{action:s}},this.exposeMeta=async({id:e},t)=>{const n=`api-meta:${e}`;await this.channelProviderOrClient.register(n,(()=>({props:t})))}}},function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(Y,e),n(J,e)}(q),function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(q,e)}(K),function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(N,e),n(D,e),n(K,e),n(U,e)}(H);var Z={};Object.defineProperty(Z,"__esModule",{value:!0}),Z.createRelayedDispatch=Z.relayChannelClientApi=void 0;const Q=["no longer connected","RTCDataChannel closed unexpectedly","The client you are trying to dispatch from is disconnected from the target provider"];Z.relayChannelClientApi=async(e,t)=>{e.register(`relay:${t}`,(({action:t,target:n,payload:i})=>e.dispatch(n,t,i))),await Promise.resolve()};Z.createRelayedDispatch=(e,t,n,i)=>async(r,o)=>{try{return await e.dispatch(`relay:${n}`,{action:r,payload:o,target:t})}catch(e){if(s=e.message,Q.some((e=>s.includes(e)))&&i)throw new Error(i);throw e}var s};var X,ee,te,ne=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},ie=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(W,"__esModule",{value:!0}),W.ColumnOrRow=W.TabStack=W.LayoutNode=void 0;const re=H,oe=Z;class se{constructor(e,t){X.set(this,void 0),this.isRoot=()=>ie(this,X,"f").isRoot(this.entityId),this.exists=()=>ie(this,X,"f").exists(this.entityId),this.getParent=async()=>{const e=await ie(this,X,"f").getParent(this.entityId);if(e)return se.getEntity(e,ie(this,X,"f"))},this.createAdjacentStack=async(e,t)=>{const n=await ie(this,X,"f").createAdjacentStack(this.entityId,e,t);return se.getEntity({entityId:n,type:"stack"},ie(this,X,"f"))},this.getAdjacentStacks=async e=>(await ie(this,X,"f").getAdjacentStacks({targetId:this.entityId,edge:e})).map((e=>se.getEntity({type:"stack",entityId:e.entityId},ie(this,X,"f")))),ne(this,X,e,"f"),this.entityId=t}}W.LayoutNode=se,X=new WeakMap,se.newLayoutEntitiesClient=async(e,t,n)=>{const i=(0,oe.createRelayedDispatch)(e,n,"layout-relay","You are trying to interact with a layout component on a window that does not exist or has been destroyed.");return new re.ApiConsumer(new re.ChannelsConsumer({dispatch:i})).consume({id:t})},se.getEntity=(e,t)=>{const{entityId:n,type:i}=e;switch(i){case"column":case"row":return new ce(t,n,i);case"stack":return new ae(t,n);default:throw new Error(`Unrecognised Layout Entity encountered ('${JSON.stringify(e)})`)}};class ae extends se{constructor(e,t){super(e,t),ee.set(this,void 0),this.type="stack",this.getViews=()=>ie(this,ee,"f").getStackViews(this.entityId),this.addView=async(e,t={index:0})=>ie(this,ee,"f").addViewToStack(this.entityId,e,t),this.removeView=async e=>{await ie(this,ee,"f").removeViewFromStack(this.entityId,e)},this.setActiveView=async e=>{await ie(this,ee,"f").setStackActiveView(this.entityId,e)},ne(this,ee,e,"f")}}W.TabStack=ae,ee=new WeakMap;class ce extends se{constructor(e,t,n){super(e,t),te.set(this,void 0),this.getContent=async()=>(await ie(this,te,"f").getContent(this.entityId)).map((e=>se.getEntity(e,ie(this,te,"f")))),ne(this,te,e,"f"),this.type=n}}W.ColumnOrRow=ce,te=new WeakMap;var de={};Object.defineProperty(de,"__esModule",{value:!0}),de.DEFAULT_LAYOUT_KEY=de.LAYOUT_CONTROLLER_ID=void 0,de.LAYOUT_CONTROLLER_ID="layout-entities",de.DEFAULT_LAYOUT_KEY="__default__";var he={};Object.defineProperty(he,"__esModule",{value:!0}),he.WebContents=void 0;const le=c;class ue extends le.EmitterBase{constructor(e,t,n){super(e,n,t.uuid,t.name),this.identity=t,this.entityType=n}capturePage(e){return this.wire.sendAction("capture-page",{options:e,...this.identity}).then((({payload:e})=>e.data))}executeJavaScript(e){return this.wire.sendAction("execute-javascript-in-window",{...this.identity,code:e}).then((({payload:e})=>e.data))}getZoomLevel(){return this.wire.sendAction("get-zoom-level",this.identity).then((({payload:e})=>e.data))}setZoomLevel(e){return this.wire.sendAction("set-zoom-level",{...this.identity,level:e}).then((()=>{}))}navigate(e){return this.wire.sendAction("navigate-window",{...this.identity,url:e}).then((()=>{}))}navigateBack(){return this.wire.sendAction("navigate-window-back",{...this.identity}).then((()=>{}))}async navigateForward(){await this.wire.sendAction("navigate-window-forward",{...this.identity})}stopNavigation(){return this.wire.sendAction("stop-window-navigation",{...this.identity}).then((()=>{}))}reload(e=!1){return this.wire.sendAction("reload-window",{ignoreCache:e,...this.identity}).then((()=>{}))}print(e={}){return this.wire.sendAction("print",{...this.identity,options:e}).then((()=>{}))}findInPage(e,t){return this.wire.sendAction("find-in-page",{...this.identity,searchTerm:e,options:t}).then((({payload:e})=>e.data))}stopFindInPage(e){return this.wire.sendAction("stop-find-in-page",{...this.identity,action:e}).then((()=>{}))}getPrinters(){return this.wire.sendAction("get-printers",{...this.identity}).then((({payload:e})=>e.data))}async focus({emitSynthFocused:e}={emitSynthFocused:!0}){await this.wire.sendAction("focus-window",{emitSynthFocused:e,...this.identity})}async showDeveloperTools(){await this.wire.sendAction("show-developer-tools",this.identity)}async getProcessInfo(){const{payload:{data:e}}=await this.wire.sendAction("get-process-info",this.identity);return e}async getSharedWorkers(){return this.wire.sendAction("get-shared-workers",this.identity).then((({payload:e})=>e.data))}async inspectSharedWorker(){await this.wire.sendAction("inspect-shared-worker",{...this.identity})}async inspectSharedWorkerById(e){await this.wire.sendAction("inspect-shared-worker-by-id",{...this.identity,workerId:e})}async inspectServiceWorker(){await this.wire.sendAction("inspect-service-worker",{...this.identity})}async showPopupWindow(e){if(this.wire.sendAction(`${this.entityType}-show-popup-window`,this.identity).catch((()=>{})),e?.onPopupReady){const t=async({popupName:t})=>{try{const n=this.fin.Window.wrapSync({uuid:this.fin.me.uuid,name:t});await e.onPopupReady(n)}catch(e){throw new Error(`Something went wrong during onPopupReady execution: ${e}`)}};await this.once("popup-ready",t)}const{payload:t}=await this.wire.sendAction("try-create-popup-window",{options:{...e,hasResultCallback:!!e?.onPopupResult,hasReadyCallback:!!e?.onPopupReady},...this.identity}),{data:{willOpen:n,options:i}}=t;n&&await this.fin.Window.create(i.initialOptions);if(e?.onPopupResult){const t=async t=>{await e.onPopupResult((e=>{const{name:t,uuid:n,result:i,data:r}=e,o={identity:{name:t,uuid:n},result:i};return r&&(o.data=r),o})(t))},n=async()=>{await this.removeListener("popup-result",t)};await this.on("popup-result",t),await this.once("popup-teardown",n)}const{payload:r}=await this.wire.sendAction("show-popup-window",{options:i,...this.identity});return r.data}}var pe,we,ye,fe,ge;function me(){return we||(we=1,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(function(){if(T)return L;T=1,Object.defineProperty(L,"__esModule",{value:!0}),L.ViewModule=void 0;const e=c,t=O,n=me(),i=k;class r extends e.Base{async create(e){const{uuid:t}=this.wire.me;if(!e.name||"string"!=typeof e.name)throw new Error("Please provide a name property as a string in order to create a View.");return(0,i.handleDeprecatedWarnings)(e),this.wire.environment.childViews?await this.wire.environment.createChildContent({entityType:"view",options:{...e,uuid:t}}):await this.wire.sendAction("create-view",{...e,uuid:t}),this.wrapSync({uuid:t,name:e.name})}async wrap(e){this.wire.sendAction("view-wrap");const i=(0,t.validateIdentity)(e);if(i)throw new Error(i);return new n.View(this.wire,e)}wrapSync(e){this.wire.sendAction("view-wrap-sync").catch((e=>{}));const i=(0,t.validateIdentity)(e);if(i)throw new Error(i);return new n.View(this.wire,e)}getCurrent(){if(this.wire.sendAction("view-get-current").catch((e=>{})),!this.wire.me.isView)throw new Error("You are not in a View context");const{uuid:e,name:t}=this.wire.me;return this.wrap({uuid:e,name:t})}getCurrentSync(){if(this.wire.sendAction("view-get-current-sync").catch((e=>{})),!this.wire.me.isView)throw new Error("You are not in a View context");const{uuid:e,name:t}=this.wire.me;return this.wrapSync({uuid:e,name:t})}}return L.ViewModule=r,L}(),e),n(function(){if(pe)return $;pe=1;var e,t=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty($,"__esModule",{value:!0}),$.View=void 0;const n=f,i=B,r=W,s=de,a=he,c=Pe();class d extends a.WebContents{constructor(o,a){super(o,a,"view"),this.identity=a,e.set(this,new i.Lazy((()=>this.fin.Platform.wrapSync(this.identity).getClient()))),this.attach=async e=>{await this.wire.sendAction("attach-view",{target:e,...this.identity})},this.destroy=async()=>{await this.wire.sendAction("destroy-view",{...this.identity})},this.show=async()=>{await this.wire.sendAction("show-view",{...this.identity})},this.showAt=async(e,t={})=>{await this.wire.sendAction("show-view-at",{bounds:e,...this.identity,options:t})},this.bringToFront=async()=>{await this.wire.sendAction("bring-view-to-front",{...this.identity})},this.hide=async()=>{await this.wire.sendAction("hide-view",{...this.identity})},this.setBounds=async e=>{await this.wire.sendAction("set-view-bounds",{bounds:e,...this.identity})},this.getBounds=async()=>(await this.wire.sendAction("get-view-bounds",{...this.identity})).payload.data,this.getInfo=async()=>(await this.wire.sendAction("get-view-info",{...this.identity})).payload.data,this.getParentLayout=async()=>{this.wire.sendAction("view-get-parent-layout",{...this.identity}).catch((()=>{}));const n=await this.getCurrentWindow();try{const i=await t(this,e,"f").getValue(),o=await r.LayoutNode.newLayoutEntitiesClient(i,s.LAYOUT_CONTROLLER_ID,n.identity),a=await o.getLayoutIdentityForViewOrThrow(this.identity);return this.fin.Platform.Layout.wrap(a)}catch(e){if(!["No action registered at target for","getLayoutIdentityForViewOrThrow is not a function"].some((t=>e.message.includes(t))))throw e;return this.fin.Platform.Layout.wrap(n.identity)}},this.getOptions=async()=>this.wire.sendAction("get-view-options",{...this.identity}).then((({payload:e})=>e.data)),this.updateOptions=async e=>this.wire.sendAction("update-view-options",{options:e,...this.identity}).then((()=>{})),this.getCurrentWindow=async()=>{const{payload:{data:e}}=await this.wire.sendAction("get-view-window",{...this.identity});return new c._Window(this.wire,e)},this.getCurrentStack=async()=>{this.wire.sendAction("view-get-current-stack").catch((()=>{}));try{const n=await this.getCurrentWindow(),i=await t(this,e,"f").getValue(),o=await r.LayoutNode.newLayoutEntitiesClient(i,s.LAYOUT_CONTROLLER_ID,n.identity),a=await o.getStackByView(this.identity);return r.LayoutNode.getEntity(a,o)}catch(e){throw new n.RuntimeError({reason:"This view does not belong to a stack.",error:e})}},this.triggerBeforeUnload=async()=>(await this.wire.sendAction("trigger-before-unload",{...this.identity})).payload.data,this.bindToElement=async e=>{if(!e)throw new Error("Element not found.");return this.wire.environment.observeBounds(e,(async e=>this.setBounds(e)))}}async focus({emitSynthFocused:e}={emitSynthFocused:!0}){const t=await this.getCurrentWindow();await t.focusedWebViewWasChanged(),await super.focus({emitSynthFocused:e})}}return $.View=d,e=new WeakMap,$}(),e)}(j)),j}function ve(){if(ye)return F;ye=1,Object.defineProperty(F,"__esModule",{value:!0}),F.Application=void 0;const e=c,t=Pe(),n=me();class i extends e.EmitterBase{constructor(e,n){super(e,"application",n.uuid),this.identity=n,this.window=new t._Window(this.wire,{uuid:this.identity.uuid,name:this.identity.uuid})}windowListFromIdentityList(e){const n=[];return e.forEach((e=>{n.push(new t._Window(this.wire,{uuid:e.uuid,name:e.name}))})),n}isRunning(){return this.wire.sendAction("is-application-running",this.identity).then((({payload:e})=>e.data))}async quit(e=!1){try{await this._close(e),await this.wire.sendAction("destroy-application",{force:e,...this.identity})}catch(e){if(!["Remote connection has closed","Could not locate the requested application"].some((t=>e.message.includes(t))))throw e}}async _close(e=!1){try{await this.wire.sendAction("close-application",{force:e,...this.identity})}catch(e){if(!e.message.includes("Remote connection has closed"))throw e}}close(e=!1){return console.warn("Deprecation Warning: Application.close is deprecated Please use Application.quit"),this.wire.sendAction("application-close",this.identity).catch((e=>{})),this._close(e)}getChildWindows(){return this.wire.sendAction("get-child-windows",this.identity).then((({payload:e})=>{const t=[];return e.data.forEach((e=>{t.push({uuid:this.identity.uuid,name:e})})),this.windowListFromIdentityList(t)}))}getManifest(){return this.wire.sendAction("get-application-manifest",this.identity).then((({payload:e})=>e.data))}getParentUuid(){return this.wire.sendAction("get-parent-application",this.identity).then((({payload:e})=>e.data))}getShortcuts(){return this.wire.sendAction("get-shortcuts",this.identity).then((({payload:e})=>e.data))}async getViews(){const{payload:e}=await this.wire.sendAction("application-get-views",this.identity);return e.data.map((e=>new n.View(this.wire,e)))}getZoomLevel(){return this.wire.sendAction("get-application-zoom-level",this.identity).then((({payload:e})=>e.data))}getWindow(){return this.wire.sendAction("application-get-window",this.identity).catch((e=>{})),Promise.resolve(this.window)}registerUser(e,t){return this.wire.sendAction("register-user",{userName:e,appName:t,...this.identity}).then((()=>{}))}removeTrayIcon(){return this.wire.sendAction("remove-tray-icon",this.identity).then((()=>{}))}restart(){return this.wire.sendAction("restart-application",this.identity).then((()=>{}))}run(){return console.warn("Deprecation Warning: Application.run is deprecated Please use fin.Application.start"),this.wire.sendAction("application-run",this.identity).catch((e=>{})),this._run()}_run(e={}){return this.wire.sendAction("run-application",{manifestUrl:this._manifestUrl,opts:e,...this.identity}).then((()=>{}))}scheduleRestart(){return this.wire.sendAction("relaunch-on-close",this.identity).then((()=>{}))}async sendApplicationLog(){const{payload:e}=await this.wire.sendAction("send-application-log",this.identity);return e.data}async setJumpList(e){await this.wire.sendAction("set-jump-list",{config:e,...this.identity})}setTrayIcon(e){return this.wire.sendAction("set-tray-icon",{enabledIcon:e,...this.identity}).then((()=>{}))}setShortcuts(e){return this.wire.sendAction("set-shortcuts",{data:e,...this.identity}).then((()=>{}))}async setShortcutQueryParams(e){await this.wire.sendAction("set-shortcut-query-args",{data:e,...this.identity})}setZoomLevel(e){return this.wire.sendAction("set-application-zoom-level",{level:e,...this.identity}).then((()=>{}))}async setAppLogUsername(e){await this.wire.sendAction("set-app-log-username",{data:e,...this.identity})}getTrayIconInfo(){return this.wire.sendAction("get-tray-icon-info",this.identity).then((({payload:e})=>e.data))}hasTrayIcon(){return this.wire.sendAction("has-tray-icon",this.identity).then((({payload:e})=>e.data))}terminate(){return this.wire.sendAction("terminate-application",this.identity).then((()=>{}))}wait(){return this.wire.sendAction("wait-for-hung-application",this.identity).then((()=>{}))}getInfo(){return this.wire.sendAction("get-info",this.identity).then((({payload:e})=>e.data))}async getProcessInfo(){const{payload:{data:e}}=await this.wire.sendAction("application-get-process-info",this.identity);return e}async setFileDownloadLocation(e){const{name:t}=this.wire.me,n={uuid:this.identity.uuid,name:t};await this.wire.sendAction("set-file-download-location",{...n,downloadLocation:e})}async getFileDownloadLocation(){const{payload:{data:e}}=await this.wire.sendAction("get-file-download-location",this.identity);return e}async showTrayIconPopupMenu(e){const{name:t}=this.wire.me,n={uuid:this.identity.uuid,name:t},{payload:i}=await this.wire.sendAction("show-tray-icon-popup-menu",{...n,options:e});return i.data}async closeTrayIconPopupMenu(){const{name:e}=this.wire.me,t={uuid:this.identity.uuid,name:e};await this.wire.sendAction("close-tray-icon-popup-menu",{...t})}}return F.Application=i,F}function Ce(){return ge||(ge=1,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(function(){if(fe)return R;fe=1,Object.defineProperty(R,"__esModule",{value:!0}),R.ApplicationModule=void 0;const e=c,t=O,n=ve();class i extends e.Base{async wrap(e){this.wire.sendAction("wrap-application").catch((e=>{}));const i=(0,t.validateIdentity)(e);if(i)throw new Error(i);return new n.Application(this.wire,e)}wrapSync(e){this.wire.sendAction("wrap-application-sync").catch((e=>{}));const i=(0,t.validateIdentity)(e);if(i)throw new Error(i);return new n.Application(this.wire,e)}async _create(e){return void 0===e.waitForPageLoad&&(e.waitForPageLoad=!1),void 0===e.autoShow&&void 0===e.isPlatformController&&(e.autoShow=!0),await this.wire.sendAction("create-application",e),this.wrap({uuid:e.uuid})}create(e){return console.warn("Deprecation Warning: fin.Application.create is deprecated. Please use fin.Application.start"),this.wire.sendAction("application-create").catch((e=>{})),this._create(e)}async start(e){this.wire.sendAction("start-application").catch((e=>{}));const t=await this._create(e);return await this.wire.sendAction("run-application",{uuid:e.uuid}),t}async startManyManifests(e,t){return this.wire.sendAction("run-applications",{applications:e,opts:t}).then((()=>{}))}getCurrent(){return this.wire.sendAction("get-current-application").catch((e=>{})),this.wrap({uuid:this.wire.me.uuid})}getCurrentSync(){return this.wire.sendAction("get-current-application-sync").catch((e=>{})),this.wrapSync({uuid:this.wire.me.uuid})}async startFromManifest(e,t){this.wire.sendAction("application-start-from-manifest").catch((e=>{}));const n=await this._createFromManifest(e);return await n._run(t),n}createFromManifest(e){return console.warn("Deprecation Warning: fin.Application.createFromManifest is deprecated. Please use fin.Application.startFromManifest"),this.wire.sendAction("application-create-from-manifest").catch((e=>{})),this._createFromManifest(e)}_createFromManifest(e){return this.wire.sendAction("get-application-manifest",{manifestUrl:e}).then((({payload:e})=>{const t=e.data.platform?e.data.platform.uuid:e.data.startup_app.uuid;return this.wrap({uuid:t})})).then((t=>(t._manifestUrl=e,t)))}}return R.ApplicationModule=i,R}(),e),n(ve(),e)}(S)),S}he.WebContents=ue;var be={};Object.defineProperty(be,"__esModule",{value:!0}),be.promisifySubscription=void 0;var Ie,Ee,xe;function Ae(){if(Ie)return _;Ie=1,Object.defineProperty(_,"__esModule",{value:!0}),_._Window=void 0;const e=Ce(),t=he,n=me(),i=k,r=be;class o extends t.WebContents{constructor(e,t){super(e,t,"window")}async createWindow(e){this.wire.sendAction("window-create-window",this.identity).catch((e=>{}));const t=await(0,r.promisifySubscription)(this,"fire-constructor-callback");void 0===e.waitForPageLoad&&(e.waitForPageLoad=!1),void 0===e.autoShow&&(e.autoShow=!0),(0,i.handleDeprecatedWarnings)(e);const n=this.wire.environment.createChildContent({entityType:"window",options:e}),[o]=await Promise.all([t.getValue(),n]);let s;const{success:a}=o,c=o.data,{message:d}=c;s=a?{httpResponseCode:c.httpResponseCode,apiInjected:c.apiInjected}:{message:c.message,networkErrorCode:c.networkErrorCode,stack:c.stack};const h={message:d,cbPayload:s,success:a};try{this.getWebWindow().fin.__internal_.openerSuccessCBCalled()}catch(e){}return h.success?this:Promise.reject(h)}getAllFrames(){return this.wire.sendAction("get-all-frames",this.identity).then((({payload:e})=>e.data))}getBounds(){return this.wire.sendAction("get-window-bounds",this.identity).then((({payload:e})=>e.data))}center(){return this.wire.sendAction("center-window",this.identity).then((()=>{}))}blur(){return this.wire.sendAction("blur-window",this.identity).then((()=>{}))}bringToFront(){return this.wire.sendAction("bring-window-to-front",this.identity).then((()=>{}))}animate(e,t){return this.wire.sendAction("animate-window",{transitions:e,options:t,...this.identity}).then((()=>{}))}hide(){return this.wire.sendAction("hide-window",this.identity).then((()=>{}))}close(e=!1){return this.wire.sendAction("close-window",{force:e,...this.identity}).then((()=>{Object.setPrototypeOf(this,null)}))}focusedWebViewWasChanged(){return this.wire.sendAction("focused-webview-changed",this.identity).then((()=>{}))}getNativeId(){return this.wire.sendAction("get-window-native-id",this.identity).then((({payload:e})=>e.data))}async getCurrentViews(){const{payload:e}=await this.wire.sendAction("window-get-views",this.identity);return e.data.map((e=>new n.View(this.wire,e)))}disableFrame(){return console.warn("Function is deprecated; use disableUserMovement instead."),this.wire.sendAction("disable-window-frame",this.identity).then((()=>{}))}disableUserMovement(){return this.wire.sendAction("disable-window-frame",this.identity).then((()=>{}))}enableFrame(){return console.warn("Function is deprecated; use enableUserMovement instead."),this.wire.sendAction("enable-window-frame",this.identity).then((()=>{}))}enableUserMovement(){return this.wire.sendAction("enable-window-frame",this.identity).then((()=>{}))}flash(){return this.wire.sendAction("flash-window",this.identity).then((()=>{}))}stopFlashing(){return this.wire.sendAction("stop-flash-window",this.identity).then((()=>{}))}getInfo(){return this.wire.sendAction("get-window-info",this.identity).then((({payload:e})=>e.data))}async getLayout(e){this.wire.sendAction("window-get-layout",this.identity).catch((e=>{}));const t=await this.getOptions();if(!t.layout&&!t.layoutSnapshot)throw new Error("Window does not have a Layout");return this.fin.Platform.Layout.wrap(e??this.identity)}getOptions(){return this.wire.sendAction("get-window-options",this.identity).then((({payload:e})=>e.data))}getParentApplication(){return this.wire.sendAction("window-get-parent-application",this.identity).catch((e=>{})),Promise.resolve(new e.Application(this.wire,this.identity))}getParentWindow(){return this.wire.sendAction("window-get-parent-window",this.identity).catch((e=>{})),Promise.resolve(new e.Application(this.wire,this.identity)).then((e=>e.getWindow()))}async getSnapshot(e){const t={area:e,...this.identity};console.warn("Window.getSnapshot has been deprecated, please use Window.capturePage");return(await this.wire.sendAction("get-window-snapshot",t)).payload.data}getState(){return this.wire.sendAction("get-window-state",this.identity).then((({payload:e})=>e.data))}getWebWindow(){return this.wire.sendAction("window-get-web-window",this.identity).catch((e=>{})),this.wire.environment.getWebWindow(this.identity)}isMainWindow(){return this.wire.sendAction("window-is-main-window",this.identity).catch((e=>{})),this.me.uuid===this.me.name}isShowing(){return this.wire.sendAction("is-window-showing",this.identity).then((({payload:e})=>e.data))}maximize(){return this.wire.sendAction("maximize-window",this.identity).then((()=>{}))}minimize(){return this.wire.sendAction("minimize-window",this.identity).then((()=>{}))}moveBy(e,t,n){return this.wire.sendAction("move-window-by",{deltaLeft:e,deltaTop:t,positioningOptions:n,...this.identity}).then((()=>{}))}moveTo(e,t,n){return this.wire.sendAction("move-window",{left:e,top:t,positioningOptions:n,...this.identity}).then((()=>{}))}resizeBy(e,t,n,i){return this.wire.sendAction("resize-window-by",{deltaWidth:Math.floor(e),deltaHeight:Math.floor(t),anchor:n,positioningOptions:i,...this.identity}).then((()=>{}))}resizeTo(e,t,n,i){return this.wire.sendAction("resize-window",{width:Math.floor(e),height:Math.floor(t),anchor:n,positioningOptions:i,...this.identity}).then((()=>{}))}restore(){return this.wire.sendAction("restore-window",this.identity).then((()=>{}))}setAsForeground(){return this.wire.sendAction("set-foreground-window",this.identity).then((()=>{}))}setBounds(e,t){return this.wire.sendAction("set-window-bounds",{...e,...this.identity,positioningOptions:t}).then((()=>{}))}show(e=!1){return this.wire.sendAction("show-window",{force:e,...this.identity}).then((()=>{}))}showAt(e,t,n=!1){return this.wire.sendAction("show-at-window",{force:n,left:Math.floor(e),top:Math.floor(t),...this.identity}).then((()=>{}))}updateOptions(e){return this.wire.sendAction("update-window-options",{options:e,...this.identity}).then((()=>{}))}authenticate(e,t){return this.wire.sendAction("window-authenticate",{userName:e,password:t,...this.identity}).then((()=>{}))}async showPopupMenu(e){const{payload:t}=await this.wire.sendAction("show-popup-menu",{options:e,...this.identity});return t.data}async closePopupMenu(){return this.wire.sendAction("close-popup-menu",{...this.identity}).then((()=>{}))}async dispatchPopupResult(e){this.wire.sendAction("window-dispatch-popup-result",this.identity).catch((e=>{})),await this.wire.sendAction("dispatch-popup-result",{data:e,...this.identity})}async print(e={content:"self"}){switch(e.content){case void 0:case"self":return super.print(e);case"screenshot":return this.wire.sendAction("print-screenshot",this.identity).then((()=>{}));case"views":return this.wire.sendAction("print-views",{...this.identity,options:e}).then((()=>{}));default:return}}}return _._Window=o,_}function Pe(){return xe||(xe=1,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(function(){if(Ee)return M;Ee=1,Object.defineProperty(M,"__esModule",{value:!0}),M._WindowModule=void 0;const e=c,t=O,n=Ae();class i extends e.Base{async wrap(e){this.wire.sendAction("window-wrap").catch((e=>{}));const i=(0,t.validateIdentity)(e);if(i)throw new Error(i);return new n._Window(this.wire,e)}wrapSync(e){this.wire.sendAction("window-wrap-sync").catch((e=>{}));const i=(0,t.validateIdentity)(e);if(i)throw new Error(i);return new n._Window(this.wire,e)}create(e){return this.wire.sendAction("create-window").catch((e=>{})),new n._Window(this.wire,{uuid:this.me.uuid,name:e.name}).createWindow(e)}getCurrent(){if(this.wire.sendAction("get-current-window").catch((e=>{})),!this.wire.me.isWindow)throw new Error("You are not in a Window context");const{uuid:e,name:t}=this.wire.me;return this.wrap({uuid:e,name:t})}getCurrentSync(){if(this.wire.sendAction("get-current-window-sync").catch((e=>{})),!this.wire.me.isWindow)throw new Error("You are not in a Window context");const{uuid:e,name:t}=this.wire.me;return this.wrapSync({uuid:e,name:t})}}return M._WindowModule=i,M}(),e),n(Ae(),e)}(P)),P}be.promisifySubscription=async(e,t,n=(()=>!0),i)=>{let r,o,s;const a=new Promise(((e,t)=>{r=e,o=t})),c=e=>{n(e)&&(clearTimeout(s),r(e))};return await e.on(t,c),i&&(s=setTimeout((()=>o(new Error("event timed out"))),i)),a.finally((()=>{e.removeListener(t,c).catch((()=>null))})),{getValue:()=>a}},Object.defineProperty(a,"__esModule",{value:!0}),a.System=void 0;const Me=c,Oe=f,_e=Pe(),Se=t;class Re extends Me.EmitterBase{constructor(e){super(e,"system")}sendExternalProcessRequest(e,t){return new Promise(((n,i)=>{const r="external-process-exited";let o,s,a,c;"function"==typeof t.listener&&(a=e=>{const n=e||{};s={topic:"exited",uuid:n.processUuid||"",exitCode:n.exitCode||0},o===e.processUuid&&(t.listener(s),c.removeListener(r,a))},this.wire.me.name||(this.wire.me.name=this.wire.me.uuid),c=new _e._Window(this.wire,this.wire.me),c.on(r,a)),this.wire.sendAction(e,t).then((({payload:e})=>{o=e.data.uuid,n(e.data),s&&o===s.uuid&&(t.listener(s),c.removeListener(r,a))})).catch((e=>{c&&c.removeListener(r,a),i(e)}))}))}getVersion(){return this.wire.sendAction("get-version").then((({payload:e})=>e.data))}clearCache(e){return this.wire.sendAction("clear-cache",e).then((()=>{}))}deleteCacheOnExit(){return this.wire.sendAction("delete-cache-request").then((()=>{}))}exit(){return this.wire.sendAction("exit-desktop").then((()=>{}))}async fetchManifest(e){const{payload:{data:t}}=await this.wire.sendAction("fetch-manifest",{manifestUrl:e});return t}flushCookieStore(){return this.wire.sendAction("flush-cookie-store").then((()=>{}))}getAllWindows(){return this.wire.sendAction("get-all-windows").then((({payload:e})=>e.data))}getAllApplications(){return this.wire.sendAction("get-all-applications").then((({payload:e})=>e.data))}getCommandLineArguments(){return this.wire.sendAction("get-command-line-arguments").then((({payload:e})=>e.data))}async getCrashReporterState(){const{payload:{data:{diagnosticMode:e,isRunning:t}}}=await this.wire.sendAction("get-crash-reporter-state");return console.warn("diagnosticMode property is deprecated. It will be removed in a future version"),{diagnosticMode:e,diagnosticsMode:e,isRunning:t}}async startCrashReporter(e){const t=e,n={...t,diagnosticMode:t.diagnosticsMode||t.diagnosticMode},{payload:{data:{diagnosticMode:i,isRunning:r}}}=await this.wire.sendAction("start-crash-reporter",n);return{diagnosticMode:i,diagnosticsMode:i,isRunning:r}}getUniqueUserId(){return this.wire.sendAction("get-unique-user-id").then((({payload:e})=>e.data))}getEntityInfo(e,t){return this.wire.sendAction("get-entity-info",{uuid:e,name:t}).then((({payload:e})=>e.data))}getEnvironmentVariable(e){return this.wire.sendAction("get-environment-variable",{environmentVariables:e}).then((({payload:e})=>e.data))}getFocusedWindow(){return this.wire.sendAction("get-focused-window").then((({payload:e})=>e.data))}async isAppCertified(e){const{payload:{data:{certifiedInfo:t}}}=await this.wire.sendAction("is-app-certified",{manifestUrl:e});return t}getInstalledRuntimes(){return this.wire.sendAction("get-installed-runtimes").then((({payload:e})=>e.data.runtimes))}async getInstalledApps(){const{payload:{data:{installedApps:e}}}=await this.wire.sendAction("get-installed-apps");return e}getLog(e){return this.wire.sendAction("view-log",e).then((({payload:e})=>e.data))}getMachineId(){return this.wire.sendAction("get-machine-id").then((({payload:e})=>e.data))}getMinLogLevel(){return this.wire.sendAction("get-min-log-level").then((({payload:e})=>e.data))}getLogList(){return this.wire.sendAction("list-logs").then((({payload:e})=>e.data))}getMonitorInfo(){return this.wire.sendAction("get-monitor-info").then((({payload:e})=>e.data))}getMousePosition(){return this.wire.sendAction("get-mouse-position").then((({payload:e})=>e.data))}getProcessList(){return console.warn("System.getProcessList has been deprecated. Please consider using our new process APIs: Window.getProcessInfo, View.getProcessInfo, Application.getProcessInfo, System.getAllProcessInfo"),this.wire.sendAction("process-snapshot").then((({payload:e})=>e.data))}async getAllProcessInfo(){const{payload:{data:e}}=await this.wire.sendAction("get-all-process-info",this.identity);return e}getProxySettings(){return this.wire.sendAction("get-proxy-settings").then((({payload:e})=>e.data))}getRuntimeInfo(){return this.wire.sendAction("get-runtime-info").then((({payload:e})=>e.data))}getRvmInfo(){return this.wire.sendAction("get-rvm-info").then((({payload:e})=>e.data))}getHostSpecs(){return this.wire.sendAction("get-host-specs").then((({payload:e})=>e.data))}getOSInfo(){return this.wire.sendAction("get-os-info").then((({payload:e})=>e.data))}launchExternalProcess(e){return this.sendExternalProcessRequest("launch-external-process",e)}monitorExternalProcess(e){return this.sendExternalProcessRequest("monitor-external-process",e)}log(e,t){return this.wire.sendAction("write-to-log",{level:e,message:t}).then((()=>{}))}openUrlWithBrowser(e){return this.wire.sendAction("open-url-with-browser",{url:e}).then((()=>{}))}async registerCustomProtocol(e){if("object"!=typeof e)throw new Error("Must provide an object with a `protocolName` property having a string value.");await this.wire.sendAction("register-custom-protocol",e)}async unregisterCustomProtocol(e){await this.wire.sendAction("unregister-custom-protocol",{protocolName:e})}async getCustomProtocolState(e){return this.wire.sendAction("get-custom-protocol-state",{protocolName:e}).then((({payload:e})=>e.data))}releaseExternalProcess(e){return this.wire.sendAction("release-external-process",{uuid:e}).then((()=>{}))}showDeveloperTools(e){return this.wire.sendAction("show-developer-tools",e).then((()=>{}))}terminateExternalProcess(e){return this.wire.sendAction("terminate-external-process",e).then((()=>{}))}updateProxySettings(e){return this.wire.sendAction("update-proxy",e).then((()=>{}))}async downloadAsset(e,t){const n=()=>{};let i=n,r=n;const o=new Promise(((e,t)=>{i=e,r=t}));if("openfin"!==this.wire.environment.type)throw new Oe.NotSupportedError("downloadAsset only supported in an OpenFin Render process");const s=Oe.RuntimeError.getCallSite(),a=this.wire.environment.getNextMessageId().toString(),c=`asset-download-progress-${a}`,d=`asset-download-error-${a}`,h=`asset-download-complete-${a}`,l=e=>{const n={downloadedBytes:e.downloadedBytes,totalBytes:e.totalBytes};t(n)},u=()=>{this.removeListener(c,l)};await Promise.all([this.on(c,l),this.once(d,(e=>{u();const{reason:t,err:n}=e;r(new Oe.RuntimeError({reason:t,error:n},s))})),this.once(h,(()=>{u(),i()}))]);const p=Object.assign(e,{downloadId:a});return await this.wire.sendAction("download-asset",p).catch((e=>{throw u(),e})),o}downloadRuntime(e,t){const n=Oe.RuntimeError.getCallSite();return new Promise(((i,r)=>{if("openfin"!==this.wire.environment.type)return void r(new Oe.NotSupportedError("downloadRuntime only supported in an OpenFin Render process"));const o=this.wire.environment.getNextMessageId().toString(),s=`runtime-download-progress-${o}`,a=`runtime-download-error-${o}`,c=`runtime-download-complete-${o}`,d=e=>{const n={downloadedBytes:e.downloadedBytes,totalBytes:e.totalBytes};t(n)},h=()=>{this.removeListener(s,d)};this.on(s,d),this.once(a,(e=>{h();const{reason:t,err:i}=e;r(new Oe.RuntimeError({reason:t,error:i},n))})),this.once(c,(()=>{h(),i()}));const l=Object.assign(e,{downloadId:o});this.wire.sendAction("download-runtime",l).catch((e=>{h(),r(e)}))}))}downloadPreloadScripts(e){return this.wire.sendAction("download-preload-scripts",{scripts:e}).then((({payload:e})=>e.data))}getAllExternalApplications(){return this.wire.sendAction("get-all-external-applications").then((({payload:e})=>e.data))}getAppAssetInfo(e){return this.wire.sendAction("get-app-asset-info",e).then((({payload:e})=>e.data))}getCookies(e){const t=this.wire.environment.getUrl(),n=Object.assign(e,{url:t});return this.wire.sendAction("get-cookies",n).then((({payload:e})=>e.data))}setMinLogLevel(e){return this.wire.sendAction("set-min-log-level",{level:e}).then((()=>{}))}resolveUuid(e){return this.wire.sendAction("resolve-uuid",{entityKey:e}).then((({payload:e})=>e.data))}executeOnRemote(e,t){return t.requestingIdentity=e,this.wire.ferryAction(t)}readRegistryValue(e,t,n){return this.wire.sendAction("read-registry-value",{rootKey:e,subkey:t,value:n}).then((({payload:e})=>e.data))}registerExternalConnection(e){return this.wire.sendAction("register-external-connection",{uuid:e}).then((({payload:e})=>e.data))}async getServiceConfiguration(e){if("string"!=typeof e.name)throw new Error("Must provide an object with a `name` property having a string value");const{name:t}=e;return this.wire.sendAction("get-service-configuration",{name:t}).then((({payload:e})=>e.data))}async getSystemAppConfig(e){if("string"!=typeof e)throw new Error("Must provide a string value for name of system app");return this.wire.sendAction("get-system-app-configuration",{name:e}).then((({payload:e})=>e.data))}async registerShutdownHandler(e){this.wire.sendAction("system-register-shutdown-handler").catch((e=>{}));const{uuid:t,name:n}=this.wire.me;this.on("system-shutdown",(i=>{e({proceed:()=>{this.wire.environment.raiseEvent("application/system-shutdown-handled",{uuid:t,name:n,topic:"application"})}})}))}runRvmHealthCheck(){return this.wire.sendAction("run-rvm-health-check").then((({payload:e})=>e.data))}async launchManifest(e,t={}){const{subscribe:n,...i}=t,r=i;if(n){const e=new Se.EventEmitter;n(e);const t="app-version-progress",i="runtime-status",o="app-version-complete",s="app-version-error",a=this.wire.environment.getNextMessageId().toString();r.appVersionId=a;const c=[o,t,i,s],d=e=>{const{appVersionId:t,topic:n,type:i,...r}=e;return{...r,type:c.find((e=>i.includes(e)))}},h=t=>{const n=d(t);e.emit(n.type,n)},l=()=>{this.removeListener(`${t}.${a}`,h),this.removeListener(`${i}.${a}`,h),this.removeListener(`${o}.${a}`,h),this.removeListener(`${s}.${a}`,h),this.removeListener(`${o}.${a}`,l),this.removeListener(`${s}.${a}`,l)};await Promise.all([this.on(`${t}.${a}`,h),this.on(`${i}.${a}`,h),this.once(`${o}.${a}`,h),this.once(`${s}.${a}`,h),this.once(`${o}.${a}`,l),this.once(`${s}.${a}`,l)])}return(await this.wire.sendAction("launch-manifest",{manifestUrl:e,opts:r})).payload.data.manifest}async queryPermissionForCurrentContext(e){const t={uuid:this.wire.me.uuid,name:this.wire.me.name};return(await this.wire.sendAction("query-permission-for-current-context",{apiName:e,identity:t})).payload.data}async enableNativeWindowIntegrationProvider(e){const{payload:t}=await this.wire.sendAction("enable-native-window-integration-provider",{permissions:e});return t.data}async registerUsage({data:e,type:t}){await this.wire.sendAction("register-usage",{data:e,type:t})}async getPrinters(){const{payload:e}=await this.wire.sendAction("system-get-printers");return e.data}async updateProcessLoggingOptions(e){await this.wire.sendAction("system-update-process-logging-options",{options:e})}async getDomainSettings(){const{payload:{data:e}}=await this.wire.sendAction("get-domain-settings",this.identity);return e}async setDomainSettings(e){await this.wire.sendAction("set-domain-settings",{domainSettings:e,...this.identity})}}a.System=Re;var Fe={},je={};Object.defineProperty(je,"__esModule",{value:!0}),je.RefCounter=void 0;je.RefCounter=class{constructor(){this.topicRefMap=new Map}incRefCount(e){const t=this.topicRefMap.get(e);let n;if(t){const i=t+1;n=i,this.topicRefMap.set(e,i)}else this.topicRefMap.set(e,1),n=1;return n}decRefCount(e){const t=this.topicRefMap.get(e);let n;if(t){const i=t-1;this.topicRefMap.set(e,i),n=i}else n=-1;return n}actOnFirst(e,t,n){return 1===this.incRefCount(e)?t():n()}actOnLast(e,t,n){return 0===this.decRefCount(e)?t():n()}};var Le={},ke={},Te={};Object.defineProperty(Te,"__esModule",{value:!0}),Te.ChannelBase=Te.ProtectedItems=void 0;const $e=e=>async(t,n,i)=>{const r=await e(t,n,i);return void 0===r?n:r};Te.ProtectedItems=class{constructor(e,t){this.providerIdentity=e,this.close=t}};class Be{static defaultAction(e){throw new Error(`No action registered at target for ${e}`)}constructor(){this.subscriptions=new Map}async processAction(e,t,n){try{const i=this.subscriptions.has(e)?this.subscriptions.get(e):(t,n)=>(this.defaultAction??Be.defaultAction)(e,t,n),r=this.preAction?await this.preAction(e,t,n):t,o=await i(r,n);return this.postAction?await this.postAction(e,o,n):o}catch(t){if(this.errorMiddleware)return this.errorMiddleware(e,t,n);throw t}}beforeAction(e){if(this.preAction)throw new Error("Already registered beforeAction middleware");this.preAction=$e(e)}onError(e){if(this.errorMiddleware)throw new Error("Already registered error middleware");this.errorMiddleware=e}afterAction(e){if(this.postAction)throw new Error("Already registered afterAction middleware");this.postAction=$e(e)}remove(e){this.subscriptions.delete(e)}setDefaultAction(e){if(this.defaultAction)throw new Error("default action can only be set once");this.defaultAction=e}register(e,t){if(this.subscriptions.has(e))throw new Error(`Subscription already registered for action: ${e}. Unsubscribe before adding new subscription`);return this.subscriptions.set(e,t),!0}}Te.ChannelBase=Be;var Ge,We,He,Ne=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},De=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n};Object.defineProperty(ke,"__esModule",{value:!0}),ke.ChannelClient=void 0;const Ue=Te,Ve=new Map;class ze extends Ue.ChannelBase{static closeChannelByEndpointId(e){const t=Ve.get(e);t&&Ne(t,He,"f").call(t)}static handleProviderDisconnect(e){for(const t of Ve.values())t.providerIdentity.channelId===e.channelId&&(t.disconnectListener(e),Ne(t,He,"f").call(t))}constructor(e,t,n){super(),Ge.set(this,void 0),We.set(this,void 0),this.processAction=(e,t,n)=>super.processAction(e,t,n),He.set(this,(()=>{Ve.delete(this.endpointId),Ne(this,We,"f").close()})),De(this,Ge,new Ue.ProtectedItems(e,t),"f"),this.disconnectListener=()=>{},this.endpointId=e.endpointId,De(this,We,n,"f"),Ve.set(this.endpointId,this),n.receive(this.processAction)}get providerIdentity(){return Ne(this,Ge,"f").providerIdentity}async dispatch(e,t){if(Ne(this,We,"f").isEndpointConnected(this.providerIdentity.channelId))return Ne(this,We,"f").send(this.providerIdentity.channelId,e,t);throw new Error("The client you are trying to dispatch from is disconnected from the target provider.")}onDisconnection(e){this.disconnectListener=t=>{try{e(t)}catch(e){throw new Error(`Error while calling the onDisconnection callback: ${e.message}`)}finally{this.disconnectListener=()=>{}}}}async disconnect(){await this.sendDisconnectAction(),Ne(this,He,"f").call(this)}async sendDisconnectAction(){const e=Ne(this,Ge,"f");await e.close()}static async wireClose(e,t,n){const{channelName:i,uuid:r,name:o}=t;await e.sendAction("disconnect-from-channel",{channelName:i,uuid:r,name:o,endpointId:n})}}ke.ChannelClient=ze,Ge=new WeakMap,We=new WeakMap,He=new WeakMap;var Ke={},qe={};Object.defineProperty(qe,"__esModule",{value:!0}),qe.exhaustiveCheck=void 0,qe.exhaustiveCheck=function(e,t){throw new Error(`Unsupported value: ${e}${t?`\n Supported values are: ${t.join("")}`:""}`)};var Ye,Je,Ze,Qe={},Xe=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},et=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.ClassicInfo=Qe.ClassicStrategy=void 0;Qe.ClassicStrategy=class{constructor(e,t,n,i){this.messageReceiver=t,this.endpointId=n,this.providerIdentity=i,Ye.set(this,void 0),Je.set(this,new Map),Ze.set(this,new Map),this.send=async(e,t,n)=>{const i=et(this,Je,"f").get(e);if(!i)throw new Error(`Could not locate routing info for endpoint ${e}`);const r={...i};r.isLocalEndpointId&&delete r.endpointId,delete r.isLocalEndpointId;const o=et(this,Ye,"f").sendAction("send-channel-message",{...r,providerIdentity:this.providerIdentity,action:t,payload:n});et(this,Ze,"f").get(e)?.add(o);return(await o.catch((e=>{throw new Error(e.message)})).finally((()=>{et(this,Ze,"f").get(e)?.delete(o)}))).payload.data.result},this.close=async()=>{this.messageReceiver.removeEndpoint(this.providerIdentity.channelId,this.endpointId),[...et(this,Je,"f").keys()].forEach((e=>this.closeEndpoint(e))),Xe(this,Je,new Map,"f")},Xe(this,Ye,e,"f")}onEndpointDisconnect(e,t){}receive(e){this.messageReceiver.addEndpoint(e,this.providerIdentity.channelId,this.endpointId)}async closeEndpoint(e){const t=et(this,Je,"f").get(e);et(this,Je,"f").delete(e);const n=et(this,Ze,"f").get(e);n?.forEach((n=>{const i=`Channel connection with identity uuid: ${t?.uuid} / name: ${t?.name} / endpointId: ${e} no longer connected.`;n.cancel(new Error(i))}))}isEndpointConnected(e){return et(this,Je,"f").has(e)}addEndpoint(e,t){et(this,Je,"f").set(e,t.endpointIdentity),et(this,Ze,"f").set(e,new Set)}isValidEndpointPayload(e){return"string"==typeof e?.endpointIdentity?.endpointId||"string"==typeof e?.endpointIdentity?.channelId}},Ye=new WeakMap,Je=new WeakMap,Ze=new WeakMap,Qe.ClassicInfo={version:5,minimumVersion:0,type:"classic"};var tt={},nt={},it={};Object.defineProperty(it,"__esModule",{value:!0}),it.errorToPOJO=void 0,it.errorToPOJO=function(e){return{stack:e.stack,name:e.name,message:e.message,toString:()=>e.stack||e.toString()}};var rt,ot,st=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},at=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n};Object.defineProperty(nt,"__esModule",{value:!0}),nt.RTCEndpoint=void 0;const ct=it;nt.RTCEndpoint=class{static isValidEndpointPayload(e){const t=e=>"object"==typeof e&&null!==e;return t(e)&&t(e.endpointIdentity)&&t(e.rtc)&&"string"==typeof e.endpointIdentity.endpointId}constructor({rtc:e,endpointIdentity:t}){this.responseMap=new Map,rt.set(this,null),ot.set(this,void 0),this.connectionStateChangeHandler=e=>{"connected"!==this.rtc.rtcClient.connectionState&&(this.rtc.rtcClient.removeEventListener("connectionstatechange",this.connectionStateChangeHandler),this.close(),st(this,ot,"f")&&st(this,ot,"f").call(this))},this.send=async(e,t)=>{const n=`message-${Math.random()}`,i=new Promise(((e,t)=>{this.responseMap.set(n,{resolve:e,reject:t})}));return this.rtc.channels.request.send(JSON.stringify({action:e,payload:t,messageId:n})),i},this.close=()=>{this.responseMap.forEach((e=>e.reject("Connection has closed."))),this.responseMap=new Map,this.rtc.channels.request.close(),this.rtc.channels.response.close(),this.rtc.rtcClient.close()},this.rtc=e,this.endpointIdentity=t,this.rtc.channels.response.addEventListener("message",(e=>{let{data:t}=e;e.data instanceof ArrayBuffer&&(t=(new TextDecoder).decode(e.data));const{messageId:n,payload:i,success:r,error:o}=JSON.parse(t),{resolve:s,reject:a}=this.responseMap.get(n)??{};s&&a?(this.responseMap.delete(n),r?s(i):a(o)):(console.log("Could not find id in responseMap."),console.log(e))})),this.rtc.channels.request.addEventListener("message",(async e=>{let{data:n}=e;e.data instanceof ArrayBuffer&&(n=(new TextDecoder).decode(e.data));const{messageId:i,action:r,payload:o}=JSON.parse(n);if(st(this,rt,"f"))try{const e=await st(this,rt,"f").call(this,r,o,t);this.rtc.channels.response.send(JSON.stringify({messageId:i,payload:e,success:!0}))}catch(e){"open"===this.rtc.channels.response.readyState&&this.rtc.channels.response.send(JSON.stringify({messageId:i,error:(0,ct.errorToPOJO)(e),success:!1}))}else"open"===this.rtc.channels.response.readyState&&this.rtc.channels.response.send(JSON.stringify({messageId:i,success:!1,error:"Connection not ready."}))})),this.rtc.rtcClient.addEventListener("connectionstatechange",this.connectionStateChangeHandler),Object.values(this.rtc.channels).forEach((e=>{e.onclose=e=>{[...this.responseMap.values()].forEach((e=>e.reject(new Error("RTCDataChannel closed unexpectedly, this is most commonly caused by message size. Note: RTC Channels have a message size limit of ~255kB.")))),this.close(),st(this,ot,"f")&&st(this,ot,"f").call(this)}}))}onDisconnect(e){if(st(this,ot,"f"))throw new Error("RTCEndpoint disconnectListener cannot be set twice.");at(this,ot,e,"f")}receive(e){if(st(this,rt,"f"))throw new Error("You have already set a listener for this RTC Endpoint.");at(this,rt,e,"f")}get connected(){return"connected"===this.rtc.rtcClient.connectionState}},rt=new WeakMap,ot=new WeakMap;var dt,ht,lt,ut={},pt=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},wt=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n};Object.defineProperty(ut,"__esModule",{value:!0}),ut.EndpointStrategy=void 0;ut.EndpointStrategy=class{constructor(e,t,n){this.EndpointType=e,this.StrategyName=n,dt.set(this,null),ht.set(this,new Map),lt.set(this,!0),this.send=async(e,t,n)=>this.getEndpointById(e).send(t,n),this.close=async()=>{pt(this,lt,"f")&&(pt(this,ht,"f").forEach((e=>e.close())),wt(this,ht,new Map,"f")),wt(this,lt,!1,"f")},this.isValidEndpointPayload=t}onEndpointDisconnect(e,t){this.getEndpointById(e).onDisconnect(t)}receive(e){if(pt(this,dt,"f"))throw new Error(`You have already set a listener for this ${this.StrategyName} Strategy`);wt(this,dt,e,"f"),pt(this,ht,"f").forEach((e=>e.receive(pt(this,dt,"f"))))}getEndpointById(e){const t=pt(this,ht,"f").get(e);if(!t)throw new Error(`Client with endpoint id ${e} is not connected`);return t}get connected(){return pt(this,lt,"f")}isEndpointConnected(e){return pt(this,ht,"f").has(e)}addEndpoint(e,t){if(!pt(this,lt,"f"))return void console.warn(`Adding endpoint to disconnected ${this.StrategyName} Strategy`);const n=new this.EndpointType(t);pt(this,dt,"f")&&n.receive(pt(this,dt,"f")),pt(this,ht,"f").set(e,n)}async closeEndpoint(e){pt(this,ht,"f").delete(e)}},dt=new WeakMap,ht=new WeakMap,lt=new WeakMap,Object.defineProperty(tt,"__esModule",{value:!0}),tt.RTCInfo=tt.RTCStrategy=void 0;const yt=nt,ft=ut;class gt extends ft.EndpointStrategy{constructor(){super(yt.RTCEndpoint,yt.RTCEndpoint.isValidEndpointPayload,"RTC")}}tt.RTCStrategy=gt,tt.RTCInfo={version:2,minimumVersion:0,type:"rtc"};var mt={};Object.defineProperty(mt,"__esModule",{value:!0}),mt.RTCICEManager=void 0;const vt=c;class Ct extends vt.EmitterBase{constructor(e){super(e,"channel"),this.ensureChannelOpened=e=>new Promise(((t,n)=>{if("open"===e.readyState)t();else if("connecting"===e.readyState){const n=()=>{e.removeEventListener("open",n),t()};e.addEventListener("open",n)}else n(new Error("This Channel has already closed"))}))}static createDataChannelPromise(e,t){let n;const i=new Promise((e=>{n=e})),r=i=>{const o=()=>{i.channel.removeEventListener("open",o),n(i.channel)};i.channel.label===e&&(i.channel.addEventListener("open",o),t.removeEventListener("datachannel",r))};return t.addEventListener("datachannel",r),i}async listenForProviderIce(e,t){await this.on(this.createProviderEventName(e),t,{timestamp:Date.now()})}async raiseProviderIce(e,t){await this.wire.environment.raiseEvent(this.createRouteString(this.createProviderEventName(e)),t)}async listenForClientIce(e,t){await this.on(this.createClientEventName(e),t,{timestamp:Date.now()})}async raiseClientIce(e,t){await this.wire.environment.raiseEvent(this.createRouteString(this.createClientEventName(e)),t)}cleanupIceListeners(e){this.removeAllListeners(this.createClientEventName(e)),this.removeAllListeners(this.createProviderEventName(e))}createClientEventName(e){return`ice-client-${e}`}createProviderEventName(e){return`ice-provider-${e}`}createRouteString(e){return`channel/${e}`}createRtcPeer(){return this.wire.environment.getRtcPeer()}async startClientOffer(){const e=Math.random().toString(),t=this.createRtcPeer();t.addEventListener("icecandidate",(async t=>{t.candidate&&await this.raiseClientIce(e,{candidate:t.candidate?.toJSON()})})),await this.listenForProviderIce(e,(async e=>{await t.addIceCandidate(e.candidate)}));const n={request:t.createDataChannel("request"),response:t.createDataChannel("response")},i=await t.createOffer();await t.setLocalDescription(i);const r=Promise.all([n.request,n.response].map(this.ensureChannelOpened)).then((()=>{}));return{rtcClient:t,channels:n,offer:i,rtcConnectionId:e,channelsOpened:r}}async finishClientOffer(e,t,n){return await e.setRemoteDescription(t),await n,!0}async createProviderAnswer(e,t){const n=this.createRtcPeer(),i=Ct.createDataChannelPromise("request",n),r=Ct.createDataChannelPromise("response",n);n.addEventListener("icecandidate",(async t=>{t.candidate&&await this.raiseProviderIce(e,{candidate:t.candidate?.toJSON()})})),await this.listenForClientIce(e,(async e=>{await n.addIceCandidate(e.candidate)})),await n.setRemoteDescription(t);const o=await n.createAnswer();await n.setLocalDescription(o);const s=Promise.all([i,r]).then((([t,n])=>(this.cleanupIceListeners(e),{request:t,response:n})));return{rtcClient:n,answer:o,channels:s}}}mt.RTCICEManager=Ct;var bt={},It={};function Et(e){return[...e.split(".").reverse().entries()].reduce(((e,[t,n])=>e+ +n*1e4**t),0)}function xt(e,t){return Et(e)>=Et(t)}function At(e){return e.split("/")[0]}Object.defineProperty(It,"__esModule",{value:!0}),It.runtimeUuidMeetsMinimumRuntimeVersion=It.parseRuntimeUuid=It.meetsMinimumRuntimeVersion=void 0,It.meetsMinimumRuntimeVersion=xt,It.parseRuntimeUuid=At,It.runtimeUuidMeetsMinimumRuntimeVersion=function(e,t){return xt(At(e),t)};var Pt,Mt,Ot,_t,St,Rt=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},Ft=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n};Object.defineProperty(bt,"__esModule",{value:!0}),bt.ChannelProvider=void 0;const jt=Te,Lt=It;class kt extends jt.ChannelBase{get connections(){return[...Rt(this,Pt,"f")]}static handleClientDisconnection(e,t){const n=e.connections.find((e=>e.endpointId===t.endpointId));if(n)Rt(e,_t,"f").call(e,n);else{e.connections.filter((e=>e.uuid===t.uuid&&e.name===t.name)).forEach(Rt(e,_t,"f"))}e.disconnectListener(t)}static setProviderRemoval(e,t){kt.removalMap.set(e,t)}constructor(e,t,n){super(),Pt.set(this,void 0),Mt.set(this,void 0),Ot.set(this,void 0),_t.set(this,(e=>{const t=this.connections.filter((t=>t.endpointId!==e.endpointId));Rt(this,Ot,"f").closeEndpoint(e.endpointId),Ft(this,Pt,t,"f")})),this.processAction=async(e,t,n)=>(kt.clientIsMultiRuntime(n)&&!(0,Lt.runtimeUuidMeetsMinimumRuntimeVersion)(n.runtimeUuid,"18.87.56.0")?this.handleMultiRuntimeLegacyClient(n):this.checkForClientConnection(n),super.processAction(e,t,n)),St.set(this,(()=>{Rt(this,Ot,"f").close();const e=kt.removalMap.get(this);e&&e()})),Ft(this,Mt,new jt.ProtectedItems(e,t),"f"),this.connectListener=()=>{},this.disconnectListener=()=>{},Ft(this,Pt,[],"f"),Ft(this,Ot,n,"f"),n.receive(this.processAction)}dispatch(e,t,n){const i=e.endpointId??this.getEndpointIdForOpenFinId(e,t);return i&&Rt(this,Ot,"f").isEndpointConnected(i)?Rt(this,Ot,"f").send(i,t,n):Promise.reject(new Error(`Client connection with identity uuid: ${e.uuid} / name: ${e.name} / endpointId: ${i} no longer connected.`))}async processConnection(e,t){return Rt(this,Pt,"f").push(e),this.connectListener(e,t)}publish(e,t){return this.connections.map((n=>Rt(this,Ot,"f").send(n.endpointId,e,t)))}onConnection(e){this.connectListener=e}onDisconnection(e){this.disconnectListener=e}async destroy(){const e=Rt(this,Mt,"f");e.providerIdentity,Ft(this,Pt,[],"f"),await e.close(),Rt(this,St,"f").call(this)}async getAllClientInfo(){return this.connections.map((e=>{const{uuid:t,name:n,endpointId:i,entityType:r,connectionUrl:o}=e;return{uuid:t,name:n,endpointId:i,entityType:r,connectionUrl:o}}))}checkForClientConnection(e){if(!this.isClientConnected(e))throw new Error(`This action was sent from a client that is not connected to the provider.\n Client Identity: {uuid: ${e.uuid}, name: ${e.name}, endpointId: ${e.endpointId}}`)}isClientConnected(e){return kt.clientIdentityIncludesEndpointId(e)?this.connections.some((t=>t.endpointId===e.endpointId&&t.uuid===e.uuid&&t.name===e.name)):this.isLegacyClientConnected(e)}isLegacyClientConnected(e){return this.connections.some((t=>t.uuid===e.uuid&&t.name===e.name))}handleMultiRuntimeLegacyClient(e){if(!this.isLegacyClientConnected(e))throw new Error(`This action was sent from a client that is not connected to the provider. Client Identity:\n {uuid: ${e.uuid}, name: ${e.name}, endpointId: ${e.endpointId}}`)}getEndpointIdForOpenFinId(e,t){const n=this.connections.filter((t=>t.name===e.name&&t.uuid===e.uuid));if(n.length>=2){const n=Rt(this,Mt,"f"),{uuid:i,name:r}=e,o=n?.providerIdentity.uuid,s=n?.providerIdentity.name;console.warn(`WARNING: Dispatch call may have unintended results. The "to" argument of your dispatch call is missing the\n "endpointId" parameter. The identity you are dispatching to ({uuid: ${i}, name: ${r}})\n has multiple channelClients for this channel. Your dispatched action: (${t}) from the provider:\n ({uuid: ${o}, name: ${s}}) will only be processed by the most recently-created client.`)}return n.pop()?.endpointId}static clientIdentityIncludesEndpointId(e){return void 0!==e.endpointId}static clientIsMultiRuntime(e){return void 0!==e.runtimeUuid}static async wireClose(e,t){await e.sendAction("destroy-channel",{channelName:t})}}bt.ChannelProvider=kt,Pt=new WeakMap,Mt=new WeakMap,Ot=new WeakMap,_t=new WeakMap,St=new WeakMap,kt.removalMap=new WeakMap;var Tt={};Object.defineProperty(Tt,"__esModule",{value:!0}),Tt.MessageReceiver=void 0;const $t=ke,Bt=c;class Gt extends Bt.Base{constructor(e){super(e),this.onmessage=e=>"process-channel-message"===e.action&&(this.processChannelMessage(e),!0),this.endpointMap=new Map,this.latestEndpointIdByChannelId=new Map,e.registerMessageHandler(this.onmessage.bind(this))}async processChannelMessage(e){const{senderIdentity:t,providerIdentity:n,action:i,ackToSender:r,payload:o,intendedTargetIdentity:s}=e.payload,a=s.channelId??s.endpointId??this.latestEndpointIdByChannelId.get(n.channelId),c=this.endpointMap.get(a);if(!c)return r.payload.success=!1,r.payload.reason=`Client connection with identity uuid: ${this.wire.me.uuid} / name: ${this.wire.me.name} / endpointId: ${a} no longer connected.`,this.wire.sendRaw(r);try{const e=await c(i,o,t);return r.payload.payload=r.payload.payload||{},r.payload.payload.result=e,this.wire.sendRaw(r)}catch(e){return r.payload.success=!1,r.payload.reason=e.message,this.wire.sendRaw(r)}}addEndpoint(e,t,n){this.endpointMap.set(n,e),t!==n&&this.latestEndpointIdByChannelId.set(t,n)}removeEndpoint(e,t){this.endpointMap.delete(t),this.latestEndpointIdByChannelId.get(e)===t&&this.latestEndpointIdByChannelId.delete(e)}checkForPreviousClientConnection(e){const t=this.latestEndpointIdByChannelId.get(e);t&&($t.ChannelClient.closeChannelByEndpointId(t),console.warn("You have created a second connection to an older provider. First connection has been removed from the clientMap"),console.warn("If the provider calls publish(), you may receive multiple messages."))}}Tt.MessageReceiver=Gt;var Wt={};Object.defineProperty(Wt,"__esModule",{value:!0}),Wt.ProtocolManager=void 0;Wt.ProtocolManager=class{constructor(e){this.ProtocolsInPreferenceOrder=e,this.DefaultClientProtocols=["classic"],this.DefaultProviderProtocols=["classic"],this.getClientProtocols=e=>{const t=e?this.ProtocolsInPreferenceOrder.filter((t=>e.includes(t))):this.DefaultClientProtocols;if(!t.length)throw new Error(`No valid protocols were passed in. Accepted values are: ${this.ProtocolsInPreferenceOrder.join(", ")}.`);return t},this.getProviderProtocols=e=>{const t=e?this.ProtocolsInPreferenceOrder.filter((t=>e.includes(t))):this.DefaultProviderProtocols;if(!t.length)throw new Error(`No valid protocols were passed in. Accepted values are: ${this.ProtocolsInPreferenceOrder.join(", ")}.`);return t},this.getCompatibleProtocols=(e,t)=>t.supportedProtocols.filter((t=>e.some((e=>e.type===t.type&&t.version>=e.minimumVersion&&e.version>=(t.minimumVersion??0))))).slice(0,t.maxProtocols)}};var Ht={};Object.defineProperty(Ht,"__esModule",{value:!0});class Nt{static combine(e,t){return new Nt(e,t)}constructor(e,t){this.primary=e,this.secondary=t}onEndpointDisconnect(e,t){this.primary.onEndpointDisconnect(e,(()=>{this.secondary.isEndpointConnected(e)||t()})),this.secondary.onEndpointDisconnect(e,(()=>{this.primary.isEndpointConnected(e)||t()}))}isValidEndpointPayload(e){return this.primary.isValidEndpointPayload(e)||this.secondary.isValidEndpointPayload(e)}async closeEndpoint(e){await this.primary.closeEndpoint(e),await this.secondary.closeEndpoint(e)}isEndpointConnected(e){return this.primary.isEndpointConnected(e)||this.secondary.isEndpointConnected(e)}async addEndpoint(e,t){this.primary.isValidEndpointPayload(t)&&await this.primary.addEndpoint(e,t),this.secondary.isValidEndpointPayload(t)&&await this.secondary.addEndpoint(e,t)}receive(e){this.primary.receive(e),this.secondary.receive(e)}send(e,t,n){return this.primary.isEndpointConnected(e)?this.primary.send(e,t,n):this.secondary.send(e,t,n)}async close(){await Promise.all([this.primary.close(),this.secondary.close()])}}Ht.default=Nt;var Dt,Ut,Vt=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},zt=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.ConnectionManager=void 0;const Kt=qe,qt=c,Yt=Qe,Jt=tt,Zt=mt,Qt=bt,Xt=Tt,en=Wt,tn=Ht;class nn extends qt.Base{static getProtocolOptionsFromStrings(e){return e.map((e=>{switch(e){case"rtc":return Jt.RTCInfo;case"classic":return Yt.ClassicInfo;default:return(0,Kt.exhaustiveCheck)(e,["rtc","classic"])}}))}constructor(e){super(e),Dt.set(this,void 0),Ut.set(this,void 0),this.removeChannelFromProviderMap=e=>{this.providerMap.delete(e)},this.onmessage=e=>"process-channel-connection"===e.action&&(this.processChannelConnection(e),!0),this.providerMap=new Map,this.protocolManager=new en.ProtocolManager("node"===this.wire.environment.type?["classic"]:["rtc","classic"]),Vt(this,Dt,new Xt.MessageReceiver(e),"f"),Vt(this,Ut,new Zt.RTCICEManager(e),"f"),e.registerMessageHandler(this.onmessage.bind(this))}createProvider(e,t){const n=Object.assign(this.wire.environment.getDefaultChannelOptions().create,e||{}),i=this.protocolManager.getProviderProtocols(n?.protocols),r=i.map((e=>{switch(e){case"rtc":return new Jt.RTCStrategy;case"classic":return new Yt.ClassicStrategy(this.wire,zt(this,Dt,"f"),t.channelId,t);default:return(0,Kt.exhaustiveCheck)(e,["rtc","classic"])}}));let o;if(2===r.length){const[e,t]=r;o=tn.default.combine(e,t)}else{if(1!==r.length)throw new Error("failed to combine strategies");[o]=r}const s=new Qt.ChannelProvider(t,(()=>Qt.ChannelProvider.wireClose(this.wire,t.channelName)),o),a=t.channelId;return this.providerMap.set(a,{provider:s,strategy:o,supportedProtocols:nn.getProtocolOptionsFromStrings(i)}),Qt.ChannelProvider.setProviderRemoval(s,this.removeChannelFromProviderMap.bind(this)),s}async createClientOffer(e){const t=this.protocolManager.getClientProtocols(e?.protocols);let n;return{offer:{supportedProtocols:await Promise.all(t.map((async e=>{switch(e){case"rtc":{const{rtcClient:e,channels:t,offer:i,rtcConnectionId:r,channelsOpened:o}=await zt(this,Ut,"f").startClientOffer();return n={rtcClient:e,channels:t,channelsOpened:o},{type:"rtc",version:Jt.RTCInfo.version,payload:{offer:i,rtcConnectionId:r}}}case"classic":return{type:"classic",version:Yt.ClassicInfo.version};default:return(0,Kt.exhaustiveCheck)(e,["rtc","classic"])}}))),maxProtocols:2},rtc:n}}async createClientStrategy(e,t){t.endpointId||(t.endpointId=this.wire.environment.getNextMessageId(),zt(this,Dt,"f").checkForPreviousClientConnection(t.channelId));const n=t.answer??{supportedProtocols:[{type:"classic",version:1}]},i=(await Promise.all(n.supportedProtocols.map((async n=>"rtc"===n.type&&e?(await zt(this,Ut,"f").finishClientOffer(e.rtcClient,n.payload.answer,e.channelsOpened),new Jt.RTCStrategy):"classic"===n.type?new Yt.ClassicStrategy(this.wire,zt(this,Dt,"f"),t.endpointId,t):null)))).filter((e=>null!==e));let r;if(e&&!i.some((e=>e instanceof Jt.RTCStrategy))&&e&&e.rtcClient.close(),i.length>=2)r=tn.default.combine(i[0],i[1]);else{if(!i.length)throw new Error("No compatible protocols");[r]=i}const o={endpointIdentity:t,rtc:e};return r.addEndpoint(t.channelId,o),r}async processChannelConnection(e){const{clientIdentity:t,providerIdentity:n,ackToSender:i,payload:r,offer:o}=e.payload;t.endpointId?t.isLocalEndpointId=!1:(t.endpointId=this.wire.environment.getNextMessageId(),t.isLocalEndpointId=!0);const s=n.channelId,a=this.providerMap.get(s);if(!a)return i.payload.success=!1,i.payload.reason=`Channel "${n.channelName}" has been destroyed.`,this.wire.sendRaw(i);const{provider:c,strategy:d,supportedProtocols:h}=a;try{if(!(c instanceof Qt.ChannelProvider))throw Error("Cannot connect to a channel client");const e=o??{supportedProtocols:[{type:"classic",version:1}],maxProtocols:1},n=this.protocolManager.getCompatibleProtocols(h,e);if(!n.length)throw new Error("This provider does not support any of the offered protocols.");const s=await c.processConnection(t,r);i.payload.payload=i.payload.payload||{};let a={supportedProtocols:[],endpointPayloadPromise:Promise.resolve({endpointIdentity:t})};return a=await n.reduce((async(e,t)=>{const n=await e;if("rtc"===t.type){const{answer:e,rtcClient:i,channels:r}=await zt(this,Ut,"f").createProviderAnswer(t.payload.rtcConnectionId,t.payload.offer);n.supportedProtocols.push({type:"rtc",version:Jt.RTCInfo.version,payload:{answer:e}}),n.endpointPayloadPromise=n.endpointPayloadPromise.then((e=>r.then((t=>({...e,rtc:{rtcClient:i,channels:t}})))))}else n.supportedProtocols.push({type:"classic",version:Yt.ClassicInfo.version});return n}),Promise.resolve(a)),a.endpointPayloadPromise.then((e=>d.addEndpoint(t.endpointId,e))),i.payload.payload.result=s,i.payload.payload.answer=a,this.wire.sendRaw(i)}catch(e){return i.payload.success=!1,i.payload.reason=e.message,this.wire.sendRaw(i)}}}Ke.ConnectionManager=nn,Dt=new WeakMap,Ut=new WeakMap;var rn,on,sn,an=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},cn=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(Le,"__esModule",{value:!0}),Le.Channel=void 0;const dn=t,hn=B,ln=c,un=ke,pn=Ke,wn=bt;function yn(e){const t=Math.floor(e/10),n=Math.min(3e4,500*2**t);return new Promise((e=>{setTimeout((()=>{e(!1)}),n)}))}class fn extends ln.EmitterBase{constructor(e){super(e,"channel"),rn.set(this,void 0),on.set(this,new dn.EventEmitter),sn.set(this,new hn.AsyncRetryableLazy((async()=>{await Promise.all([this.on("disconnected",(e=>{un.ChannelClient.handleProviderDisconnect(e)})),this.on("connected",((...e)=>{cn(this,on,"f").emit("connected",...e)}))]).catch((()=>new Error("error setting up channel connection listeners")))}))),an(this,rn,new pn.ConnectionManager(e),"f")}async getAllChannels(){return this.wire.sendAction("get-all-channels").then((({payload:e})=>e.data))}async onChannelConnect(e){await this.on("connected",e)}async onChannelDisconnect(e){await this.on("disconnected",e)}async safeConnect(e,t,n){const i={count:0};do{let r=()=>{};const o=new Promise((t=>{r=n=>{e===n.channelName&&t(!0)},cn(this,on,"f").on("connected",r)}));try{if(i.count>0){i.gotConnectedEvent=await Promise.race([yn(i.count),o]);const t=await this.wire.sendAction("connect-to-channel",{...n,retryInfo:i});return console.log(`Successfully connected to channelName: ${e}`),t.payload.data}const t=this.wire.sendAction("connect-to-channel",n);i.originalMessageId=t.messageId;return(await t).payload.data}catch(n){if(!n.message.includes("internal-nack"))throw n;t&&0===i.count&&console.warn(`No channel found for channelName: ${e}. Waiting for connection...`)}finally{i.count+=1,cn(this,on,"f").removeListener("connected",r)}}while(t);throw new Error(`No channel found for channelName: ${e}.`)}async connect(e,t={}){if(await cn(this,sn,"f").getValue(),!e||"string"!=typeof e)throw new Error("Please provide a channelName string to connect to a channel.");const n={wait:!0,...this.wire.environment.getDefaultChannelOptions().connect,...t},{offer:i,rtc:r}=await cn(this,rn,"f").createClientOffer(n);let o;(this.fin.me.isFrame||this.fin.me.isView||this.fin.me.isWindow)&&(o=(await this.fin.me.getInfo()).url);const s={channelName:e,...n,offer:i,connectionUrl:o},a=await this.safeConnect(e,n.wait,s),c=await cn(this,rn,"f").createClientStrategy(r,a),d=new un.ChannelClient(a,(()=>un.ChannelClient.wireClose(this.wire,a,a.endpointId)),c);return c.onEndpointDisconnect(a.channelId,(async()=>{try{await d.sendDisconnectAction()}catch(e){console.warn(`Something went wrong during disconnect for client with uuid: ${a.uuid} / name: ${a.name} / endpointId: ${a.endpointId}.`)}finally{un.ChannelClient.handleProviderDisconnect(a)}})),d}async create(e,t){if(!e)throw new Error("Please provide a channelName to create a channel");const{payload:{data:n}}=await this.wire.sendAction("create-channel",{channelName:e}),i=cn(this,rn,"f").createProvider(t,n);return this.on("client-disconnected",(t=>{t.channelName===e&&wn.ChannelProvider.handleClientDisconnection(i,t)})),i}}Le.Channel=fn,rn=new WeakMap,on=new WeakMap,sn=new WeakMap,Object.defineProperty(Fe,"__esModule",{value:!0}),Fe.InterAppPayload=Fe.InterApplicationBus=void 0;const gn=t,mn=c,vn=je,Cn=Le,bn=O;class In extends mn.Base{constructor(e){super(e),this.events={subscriberAdded:"subscriber-added",subscriberRemoved:"subscriber-removed"},this.refCounter=new vn.RefCounter,this.Channel=new Cn.Channel(e),this.emitter=new gn.EventEmitter,e.registerMessageHandler(this.onmessage.bind(this)),this.on=this.emitter.on.bind(this.emitter),this.removeAllListeners=this.emitter.removeAllListeners.bind(this.emitter)}async publish(e,t){await this.wire.sendAction("publish-message",{topic:e,message:t,sourceWindowName:this.me.name})}async send(e,t,n){const i=(0,bn.validateIdentity)(e);if(i)throw new Error(i);await this.wire.sendAction("send-message",{destinationUuid:e.uuid,destinationWindowName:e.name,topic:t,message:n,sourceWindowName:this.me.name})}subscribe(e,t,n){const i=this.createSubscriptionKey(e.uuid,e.name||"*",t);return this.emitter.on(i,n),this.refCounter.actOnFirst(i,(async()=>{await this.wire.sendAction("subscribe",{sourceUuid:e.uuid,sourceWindowName:e.name||"*",topic:t,destinationWindowName:this.me.name})}),(()=>Promise.resolve()))}unsubscribe(e,t,n){const i=e.name||"*",r=this.createSubscriptionKey(e.uuid,i,t);return this.emitter.removeListener(r,n),this.refCounter.actOnLast(r,(async()=>{await this.wire.sendAction("unsubscribe",{sourceUuid:e.uuid,sourceWindowName:i,topic:t,destinationWindowName:this.me.name})}),(()=>new Promise((e=>e)).then((()=>{}))))}processMessage(e){const{payload:{message:t,sourceWindowName:n,sourceUuid:i,topic:r}}=e,o=[this.createSubscriptionKey(i,n,r),this.createSubscriptionKey(i,"*",r),this.createSubscriptionKey("*","*",r)],s={uuid:i,name:n};o.forEach((e=>{this.emitter.emit(e,t,s)}))}emitSubscriverEvent(e,t){const{payload:{targetName:n,uuid:i,topic:r}}=t,o={name:n,uuid:i,topic:r};this.emitter.emit(e,o)}createSubscriptionKey(e,t,n){const i=t||"*";if(!(e&&i&&n))throw new Error("Missing uuid, name, or topic string");return function(...e){return e.map((e=>Buffer.from(`${e}`).toString("base64"))).join("/")}(e,i,n)}onmessage(e){const{action:t}=e;switch(t){case"process-message":this.processMessage(e);break;case this.events.subscriberAdded:this.emitSubscriverEvent(this.events.subscriberAdded,e);break;case this.events.subscriberRemoved:this.emitSubscriverEvent(this.events.subscriberRemoved,e)}return!0}}Fe.InterApplicationBus=In;Fe.InterAppPayload=class{};var En={};Object.defineProperty(En,"__esModule",{value:!0}),En.Clipboard=void 0;const xn=c;class An extends xn.Base{async writeText(e){await this.wire.sendAction("clipboard-write-text",e)}async readText(e){const{payload:t}=await this.wire.sendAction("clipboard-read-text",{type:e});return t.data}async writeImage(e){await this.wire.sendAction("clipboard-write-image",e)}async readImage(e={format:"dataURL"}){const{payload:t}=await this.wire.sendAction("clipboard-read-image",e);return t.data}async writeHtml(e){await this.wire.sendAction("clipboard-write-html",e)}async readHtml(e){const{payload:t}=await this.wire.sendAction("clipboard-read-html",{type:e});return t.data}async writeRtf(e){await this.wire.sendAction("clipboard-write-rtf",e)}async readRtf(e){const{payload:t}=await this.wire.sendAction("clipboard-read-rtf",{type:e});return t.data}async write(e){await this.wire.sendAction("clipboard-write",e)}async getAvailableFormats(e){const{payload:t}=await this.wire.sendAction("clipboard-read-formats",{type:e});return t.data}}En.Clipboard=An;var Pn={},Mn={},On={};Object.defineProperty(On,"__esModule",{value:!0}),On.ExternalApplication=void 0;const _n=c;class Sn extends _n.EmitterBase{constructor(e,t){super(e,"external-application",t.uuid),this.identity=t}getInfo(){return this.wire.sendAction("get-external-application-info",this.identity).then((({payload:e})=>e.data))}}On.ExternalApplication=Sn,Object.defineProperty(Mn,"__esModule",{value:!0}),Mn.ExternalApplicationModule=void 0;const Rn=c,Fn=On;class jn extends Rn.Base{wrap(e){return this.wire.sendAction("external-application-wrap").catch((e=>{})),Promise.resolve(new Fn.ExternalApplication(this.wire,{uuid:e}))}wrapSync(e){return this.wire.sendAction("external-application-wrap-sync").catch((e=>{})),new Fn.ExternalApplication(this.wire,{uuid:e})}}Mn.ExternalApplicationModule=jn,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(Mn,e),n(On,e)}(Pn);var Ln={},kn={},Tn={};Object.defineProperty(Tn,"__esModule",{value:!0}),Tn._Frame=void 0;const $n=c;class Bn extends $n.EmitterBase{constructor(e,t){super(e,"frame",t.uuid,t.name),this.identity=t}getInfo(){return this.wire.sendAction("get-frame-info",this.identity).then((({payload:e})=>e.data))}getParentWindow(){return this.wire.sendAction("get-parent-window",this.identity).then((({payload:e})=>e.data))}}Tn._Frame=Bn,Object.defineProperty(kn,"__esModule",{value:!0}),kn._FrameModule=void 0;const Gn=c,Wn=O,Hn=Tn;class Nn extends Gn.Base{async wrap(e){this.wire.sendAction("frame-wrap").catch((e=>{}));const t=(0,Wn.validateIdentity)(e);if(t)throw new Error(t);return new Hn._Frame(this.wire,e)}wrapSync(e){this.wire.sendAction("frame-wrap-sync").catch((e=>{}));const t=(0,Wn.validateIdentity)(e);if(t)throw new Error(t);return new Hn._Frame(this.wire,e)}getCurrent(){return this.wire.sendAction("frame-get-current").catch((e=>{})),Promise.resolve(new Hn._Frame(this.wire,this.wire.environment.getCurrentEntityIdentity()))}getCurrentSync(){return this.wire.sendAction("frame-get-current-sync").catch((e=>{})),new Hn._Frame(this.wire,this.wire.environment.getCurrentEntityIdentity())}}kn._FrameModule=Nn,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(kn,e),n(Tn,e)}(Ln);var Dn={};Object.defineProperty(Dn,"__esModule",{value:!0}),Dn.GlobalHotkey=void 0;const Un=c;class Vn extends Un.EmitterBase{constructor(e){super(e,"global-hotkey")}async register(e,t){await this.on(e,t),await this.wire.sendAction("global-hotkey-register",{hotkey:e})}async unregister(e){await this.removeAllListeners(e),await this.wire.sendAction("global-hotkey-unregister",{hotkey:e})}async unregisterAll(){await Promise.all(this.eventNames().filter((e=>!("registered"===e||"unregistered"===e))).map((e=>this.removeAllListeners(e)))),await this.wire.sendAction("global-hotkey-unregister-all",{})}async isRegistered(e){const{payload:{data:t}}=await this.wire.sendAction("global-hotkey-is-registered",{hotkey:e});return t}}Dn.GlobalHotkey=Vn;var zn,Kn={},qn={},Yn={},Jn=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(Yn,"__esModule",{value:!0}),Yn.Platform=void 0;const Zn=c,Qn=O,Xn=new Map;class ei extends Zn.EmitterBase{constructor(e,t){super(t.wire,"application",e.uuid),this.getClient=e=>{this.wire.sendAction("platform-get-client",this.identity).catch((e=>{}));const t=e||this.identity,{uuid:n}=t;if(!Xn.has(n)){const e=Jn(this,zn,"f").call(this,n);Xn.set(n,e)}return Xn.get(n)},zn.set(this,(async e=>{try{const t=`custom-frame-${e}`,n=await this._channel.connect(t,{wait:!1});return n.onDisconnection((()=>{Xn.delete(e)})),n}catch(t){throw Xn.delete(e),new Error("The targeted Platform is not currently running. Listen for application-started event for the given Uuid.")}})),this.launchLegacyManifest=this.launchContentManifest;const n=(0,Qn.validateIdentity)(e);if(n)throw new Error(n);this._channel=t,this.identity={uuid:e.uuid},this.Layout=this.fin.Platform.Layout,this.Application=this.fin.Application.wrapSync(this.identity)}async createView(e,t,n){this.wire.sendAction("platform-create-view",this.identity).catch((e=>{}));const i=await this.getClient(),r=await i.dispatch("create-view",{target:t,opts:e,targetView:n});if(!r||(0,Qn.validateIdentity)(r.identity))throw new Error(`When overwriting the createView call, please return an object that has a valid 'identity' property: ${JSON.stringify(r)}`);return this.fin.View.wrapSync(r.identity)}async createWindow(e){this.wire.sendAction("platform-create-window",this.identity).catch((e=>{}));const t=await this.getClient();e.reason||(e.reason="api-call");const n=await t.dispatch("create-view-container",e);if(!n||(0,Qn.validateIdentity)(n.identity))throw new Error(`When overwriting the createWindow call, please return an object that has a valid 'identity' property: ${JSON.stringify(n)}`);const{identity:i}=n,r=this.fin.Window.wrapSync(i);return r.name=i.name,r.uuid=i.uuid,r}async quit(){this.wire.sendAction("platform-quit",this.identity).catch((e=>{}));return(await this.getClient()).dispatch("quit")}async closeView(e){this.wire.sendAction("platform-close-view",this.identity).catch((e=>{}));const t=await this.getClient();await t.dispatch("close-view",{view:e})}async reparentView(e,t){console.warn("Platform.reparentView has been deprecated, please use Platform.createView"),this.wire.sendAction("platform-reparent-view",this.identity).catch((e=>{}));const n={...e,uuid:e.uuid??this.identity.uuid},i=await this.fin.View.wrap(n),r=await i.getOptions();return this.createView(r,t)}async getSnapshot(){this.wire.sendAction("platform-get-snapshot",this.identity).catch((e=>{}));return(await this.getClient()).dispatch("get-snapshot")}async getViewSnapshot(e){return(await this.getClient()).dispatch("get-view-snapshot",{viewIdentity:e})}async applySnapshot(e,t){this.wire.sendAction("platform-apply-snapshot",this.identity).catch((e=>{}));const n="Requested snapshot must be a valid Snapshot object, or a url or filepath to such an object.";let i;if("string"==typeof e)try{i=(await this._channel.wire.sendAction("get-application-manifest",{manifestUrl:e})).payload.data}catch(e){throw new Error(`${n}: ${e}`)}else i=e;if(!i.windows)throw new Error(n);const r=await this.getClient();return await r.dispatch("apply-snapshot",{snapshot:i,options:t}),this}async fetchManifest(e){return(await this.getClient()).dispatch("platform-fetch-manifest",{manifestUrl:e})}async launchContentManifest(e){this.wire.sendAction("platform-launch-content-manifest",this.identity).catch((()=>{}));const t=await this.getClient(),n=await this.fetchManifest(e);return t.dispatch("launch-into-platform",{manifest:n,manifestUrl:e}),this}async setWindowContext(e={},t){if(this.wire.sendAction("platform-set-window-context",this.identity).catch((e=>{})),!e)throw new Error("Please provide a serializable object or string to set the context.");const n=await this.getClient(),{entityType:i}=t?await this.fin.System.getEntityInfo(t.uuid,t.name):this.fin.me;await n.dispatch("set-window-context",{context:e,entityType:i,target:t||{uuid:this.fin.me.uuid,name:this.fin.me.name}})}async getWindowContext(e){this.wire.sendAction("platform-get-window-context",this.identity).catch((e=>{}));const t=await this.getClient(),{entityType:n}=e?await this.fin.System.getEntityInfo(e.uuid,e.name):this.fin.me;return t.dispatch("get-window-context",{target:e||{uuid:this.fin.me.uuid,name:this.fin.me.name},entityType:n})}async closeWindow(e,t={skipBeforeUnload:!1}){this.wire.sendAction("platform-close-window",this.identity).catch((e=>{}));return(await this.getClient()).dispatch("close-window",{windowId:e,options:t})}}Yn.Platform=ei,zn=new WeakMap;var ti={},ni={},ii={},ri={};function oi(e){switch(e){case"columns":case"grid":case"rows":case"tabs":return!0;default:return!1}}Object.defineProperty(ri,"__esModule",{value:!0}),ri.overrideFromComposables=ri.isValidPresetType=void 0,ri.isValidPresetType=oi,ri.overrideFromComposables=function(...e){return t=>e.reduceRight(((e,t)=>n=>t(e(n))),(e=>e))(t)},ri.default={isValidPresetType:oi};var si,ai=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(ii,"__esModule",{value:!0}),ii.Layout=void 0;const ci=B,di=O,hi=c,li=ri,ui=W,pi=de;class wi extends hi.Base{constructor(e,t){super(t),si.set(this,new ci.Lazy((async()=>ui.LayoutNode.newLayoutEntitiesClient(await this.platform.getClient(),pi.LAYOUT_CONTROLLER_ID,this.identity)))),this.replace=async e=>{this.wire.sendAction("layout-replace").catch((e=>{}));const t=await this.platform.getClient();await t.dispatch("replace-layout",{target:this.identity,opts:{layout:e}})},this.replaceView=async(e,t)=>{this.wire.sendAction("layout-replace-view").catch((e=>{}));const n=await this.platform.getClient();await n.dispatch("replace-view",{target:this.identity,opts:{viewToReplace:e,newView:t}})},this.applyPreset=async e=>{this.wire.sendAction("layout-apply-preset").catch((e=>{}));const t=await this.platform.getClient(),{presetType:n}=e;if(!n||!(0,li.isValidPresetType)(n))throw new Error("Cannot apply preset layout, please include an applicable presetType property in the PresetLayoutOptions.");await t.dispatch("apply-preset-layout",{target:this.identity,opts:{presetType:n}})};const n=(0,di.validateIdentity)(e);if(n)throw new Error(n);this.identity=e,this.platform=this.fin.Platform.wrapSync({uuid:e.uuid}),e.uuid===this.fin.me.uuid&&e.name===this.fin.me.name&&(this.init=this.fin.Platform.Layout.init)}async getConfig(){this.wire.sendAction("layout-get-config").catch((e=>{}));return(await this.platform.getClient()).dispatch("get-frame-snapshot",{target:this.identity})}async getCurrentViews(){this.wire.sendAction("layout-get-views").catch((e=>{}));const e=await this.platform.getClient();return(await e.dispatch("get-layout-views",{target:this.identity})).map((e=>this.fin.View.wrapSync(e)))}async getRootItem(){this.wire.sendAction("layout-get-root-item").catch((()=>{}));const e=await ai(this,si,"f").getValue(),t=await e.getRoot("layoutName"in this.identity?this.identity:void 0);return ui.LayoutNode.getEntity(t,e)}}ii.Layout=wi,si=new WeakMap;var yi,fi,gi,mi,vi,Ci=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},bi=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n};Object.defineProperty(ni,"__esModule",{value:!0}),ni.LayoutModule=void 0;const Ii=c,Ei=ii,xi=de;class Ai extends Ii.Base{constructor(){super(...arguments),yi.add(this),fi.set(this,!1),gi.set(this,null),this.init=async(e={})=>{if(this.wire.sendAction("layout-init").catch((e=>{})),!this.wire.environment.layoutAllowedInContext(this.fin))throw new Error("Layout.init can only be called from a Window context.");if(Ci(this,fi,"f"))throw new Error("Layout.init was already called, please use Layout.create to add additional layouts.");"openfin"===this.wire.environment.type&&await this.fin.Platform.getCurrentSync().getClient(),bi(this,fi,!0,"f"),bi(this,gi,await this.wire.environment.initLayoutManager(this.fin,this.wire,e),"f"),await this.wire.environment.applyLayoutSnapshot(this.fin,Ci(this,gi,"f"),e);const t={name:this.fin.me.name,uuid:this.fin.me.uuid};if(!e.layoutManagerOverride){const e={layoutName:xi.DEFAULT_LAYOUT_KEY,...t};return Ci(this,mi,"f").call(this,e)}return this.wrapSync(t)},mi.set(this,(e=>{const t="[Layout] You are using a deprecated property `layoutManager` - it will throw if you access it starting in v37.",n=new Proxy({},{get(e,n){throw console.warn(`[Layout-mgr-proxy] accessing ${n.toString()}`),new Error(t)}}),i=Object.assign(this.wrapSync(e),{layoutManager:n});return new Proxy(i,{get(e,n){if("layoutManager"===n)throw console.warn(`[Layout-proxy] accessing ${n.toString()}`),new Error(t);return e[n]}})})),this.getCurrentLayoutManagerSync=()=>Ci(this,yi,"m",vi).call(this,"fin.Platform.Layout.getCurrentLayoutManagerSync()"),this.create=async e=>this.wire.environment.createLayout(Ci(this,yi,"m",vi).call(this,"fin.Platform.Layout.create()"),e),this.destroy=async e=>this.wire.environment.destroyLayout(Ci(this,yi,"m",vi).call(this,"fin.Platform.Layout.destroy()"),e)}async wrap(e){return this.wire.sendAction("layout-wrap").catch((e=>{})),new Ei.Layout(e,this.wire)}wrapSync(e){return this.wire.sendAction("layout-wrap-sync").catch((e=>{})),new Ei.Layout(e,this.wire)}async getCurrent(){if(this.wire.sendAction("layout-get-current").catch((e=>{})),!this.fin.me.isWindow)throw new Error("You are not in a Window context. Only Windows can have a Layout.");const{uuid:e,name:t}=this.fin.me;return this.wrap({uuid:e,name:t})}getCurrentSync(){if(this.wire.sendAction("layout-get-current-sync").catch((e=>{})),!this.fin.me.isWindow)throw new Error("You are not in a Window context. Only Windows can have a Layout.");const{uuid:e,name:t}=this.fin.me;return this.wrapSync({uuid:e,name:t})}}ni.LayoutModule=Ai,fi=new WeakMap,gi=new WeakMap,mi=new WeakMap,yi=new WeakSet,vi=function(e){if(!Ci(this,gi,"f"))throw new Error(`You must call init before using the API ${e}`);return Ci(this,gi,"f")},function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(ni,e),n(ii,e)}(ti),Object.defineProperty(qn,"__esModule",{value:!0}),qn.PlatformModule=void 0;const Pi=c,Mi=Yn,Oi=ti;class _i extends Pi.Base{constructor(e,t){super(e),this._channel=t,this.Layout=new Oi.LayoutModule(this.wire)}async init(e){if(!fin.__internal_.isPlatform||fin.me.name!==fin.me.uuid)throw new Error("fin.Platform.init should only be called from a custom platform provider running in the main window of the application.");return this.wire.environment.initPlatform(this.fin,e)}async wrap(e){return this.wire.sendAction("platform-wrap").catch((e=>{})),new Mi.Platform({uuid:e.uuid},this._channel)}wrapSync(e){return this.wire.sendAction("platform-wrap-sync").catch((e=>{})),new Mi.Platform({uuid:e.uuid},this._channel)}async getCurrent(){return this.wire.sendAction("platform-get-current").catch((e=>{})),this.wrap({uuid:this.wire.me.uuid})}getCurrentSync(){return this.wire.sendAction("platform-get-current-sync").catch((e=>{})),this.wrapSync({uuid:this.wire.me.uuid})}start(e){return this.wire.sendAction("platform-start").catch((e=>{})),new Promise((async(t,n)=>{try{const{uuid:n}=e,i=await this.fin.Application._create({...e,isPlatformController:!0});i.once("platform-api-ready",(()=>t(this.wrapSync({uuid:n})))),i._run({uuid:n})}catch(e){n(e)}}))}startFromManifest(e,t){return this.wire.sendAction("platform-start-from-manifest").catch((e=>{})),new Promise((async(n,i)=>{try{const i=await this.fin.Application._createFromManifest(e);i.once("platform-api-ready",(()=>n(this.wrapSync({uuid:i.identity.uuid})))),i._run(t)}catch(e){i(e)}}))}}qn.PlatformModule=_i,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(qn,e),n(Yn,e)}(Kn);var Si={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getMe=e.getBaseMe=e.environmentUnsupportedMessage=void 0;const t=me(),n=Ln,i=Pe(),r=Pn;function o(e,t,n){return{...{isView:"view"===e,isWindow:"window"===e,isFrame:"iframe"===e,isExternal:"external connection"===e},uuid:t,name:n,entityType:e}}e.environmentUnsupportedMessage="You are not running in OpenFin.",e.getBaseMe=o,e.getMe=function(s){const{uuid:a,name:c,entityType:d}=s.me,h={setContext(){throw new Error(e.environmentUnsupportedMessage)},addContextHandler(){throw new Error(e.environmentUnsupportedMessage)},getContextGroups(){throw new Error(e.environmentUnsupportedMessage)},joinContextGroup(){throw new Error(e.environmentUnsupportedMessage)},removeFromContextGroup(){throw new Error(e.environmentUnsupportedMessage)},getAllClientsInContextGroup(){throw new Error(e.environmentUnsupportedMessage)},getInfoForContextGroup(){throw new Error(e.environmentUnsupportedMessage)}},l="Interop API has not been instantiated. Either connection has failed or you have not declared interop in your config.",u={setContext(){throw new Error(l)},addContextHandler(){throw new Error(l)},getContextGroups(){throw new Error(l)},joinContextGroup(){throw new Error(l)},removeFromContextGroup(){throw new Error(l)},getAllClientsInContextGroup(){throw new Error(l)},getInfoForContextGroup(){throw new Error(l)}},p={eventNames:()=>{throw new Error(e.environmentUnsupportedMessage)},emit:()=>{throw new Error(e.environmentUnsupportedMessage)},listeners:()=>{throw new Error(e.environmentUnsupportedMessage)},listenerCount:()=>{throw new Error(e.environmentUnsupportedMessage)},on:()=>{throw new Error(e.environmentUnsupportedMessage)},addListener:()=>{throw new Error(e.environmentUnsupportedMessage)},once:()=>{throw new Error(e.environmentUnsupportedMessage)},prependListener:()=>{throw new Error(e.environmentUnsupportedMessage)},prependOnceListener:()=>{throw new Error(e.environmentUnsupportedMessage)},removeListener:()=>{throw new Error(e.environmentUnsupportedMessage)},removeAllListeners:()=>{throw new Error(e.environmentUnsupportedMessage)}};switch(d){case"view":return Object.assign(new t.View(s,{uuid:a,name:c}),o(d,a,c),{interop:u,isOpenFin:!0});case"window":return Object.assign(new i._Window(s,{uuid:a,name:c}),o(d,a,c),{interop:u,isOpenFin:!0});case"iframe":return Object.assign(new n._Frame(s,{uuid:a,name:c}),o(d,a,c),{interop:u,isOpenFin:!0});case"external connection":return Object.assign(new r.ExternalApplication(s,{uuid:a}),o(d,a,c),{interop:u,isOpenFin:!1});default:return{...o(d,a,c),...p,interop:h,isOpenFin:!1}}}}(Si);var Ri={},Fi={},ji={};Object.defineProperty(ji,"__esModule",{value:!0}),ji.createWarningObject=ji.createUnusableObject=void 0,ji.createUnusableObject=function(e){const t=()=>{throw new Error(e)};return new Proxy({},{apply:t,construct:t,defineProperty:t,deleteProperty:t,get:t,getOwnPropertyDescriptor:t,getPrototypeOf:t,has:t,isExtensible:t,ownKeys:t,preventExtensions:t,set:t,setPrototypeOf:t})},ji.createWarningObject=function(e,t){return new Proxy(t,{get:(...t)=>(console.warn(e),Reflect.get(...t)),set:(...t)=>(console.warn(e),Reflect.set(...t)),getOwnPropertyDescriptor:(...t)=>(console.warn(e),Reflect.getOwnPropertyDescriptor(...t)),ownKeys:(...t)=>(console.warn(e),Reflect.ownKeys(...t))})};var Li,ki={},Ti={};var $i={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.wrapIntentHandler=e.BROKER_ERRORS=e.generateOverrideWarning=e.generateOverrideError=e.wrapContextHandler=e.wrapInTryCatch=e.generateId=void 0;e.generateId=()=>`${Math.random()}${Date.now()}`;e.wrapInTryCatch=(e,t)=>(...n)=>{try{return e(...n)}catch(e){throw new Error((t||"")+e)}};e.wrapContextHandler=(e,t)=>async n=>{try{await e(n)}catch(e){throw console.error(`Error thrown by handler ${t} for context type ${n.type}: ${e}`),e}};e.generateOverrideError=(e,t)=>`You have tried to to use ${e} but ${t} has not been overridden in the Interop Broker. Please override this function. Refer to our documentation for more info.`;e.generateOverrideWarning=(e,t,n,i)=>{const{uuid:r,name:o}=n;return i?`Entity with identity: ${r}/${o} has called ${i} or ${e} but ${t} has not been overridden.`:`Entity with identity: ${r}/${o} has called ${e} but ${t} has not been overridden.`},e.BROKER_ERRORS={fireIntent:(0,e.generateOverrideError)("fireIntent","handleFiredIntent"),fireIntentForContext:(0,e.generateOverrideError)("fireIntentForContext","handleFiredIntentForContext"),getInfoForIntent:(0,e.generateOverrideError)("getInfoForIntent","handleInfoForIntent"),getInfoForIntentsByContext:(0,e.generateOverrideError)("getInfoForIntentsByContext","handleInfoForIntentsByContext"),joinSessionContextGroupWithJoinContextGroup:"The Context Group you have tried to join is a Session Context Group. Custom Context Groups can only be defined by the Interop Broker through code or manifest configuration. Please use joinSessionContextGroup.",fdc3Open:(0,e.generateOverrideError)("fdc3.open","fdc3HandleOpen"),fdc3FindInstances:(0,e.generateOverrideError)("fdc3.findInstances","fdc3HandleFindInstances"),fdc3GetAppMetadata:(0,e.generateOverrideError)("fdc3.getAppMetadata","fdc3HandleGetAppMetadata"),fdc3GetInfo:(0,e.generateOverrideError)("fdc3.getInfo","fdc3HandleGetInfo")};e.wrapIntentHandler=(e,t)=>async n=>{try{return e(n)}catch(e){throw console.error(`Error thrown by handler ${t}: ${e}`),e}}}($i);var Bi,Gi,Wi={};function Hi(){if(Gi)return ki;Gi=1;var e,t,i,r=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},s=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(ki,"__esModule",{value:!0}),ki.InteropBroker=void 0;const a=c,d=function(){if(Li)return Ti;Li=1,Object.defineProperty(Ti,"__esModule",{value:!0});const e=pr();return Ti.default=class{constructor(e,t){this.provider=e,this.id=t,this.lastContext=void 0,this.contextGroupMap=new Map,this.clients=new Map,this.registerListeners()}registerListeners(){this.provider.register(`sessionContextGroup:getContext-${this.id}`,this.getCurrentContext.bind(this)),this.provider.register(`sessionContextGroup:setContext-${this.id}`,this.setContext.bind(this)),this.provider.register(`sessionContextGroup:handlerAdded-${this.id}`,this.handlerAdded.bind(this)),this.provider.register(`sessionContextGroup:handlerRemoved-${this.id}`,this.handlerRemoved.bind(this))}getCurrentContext(e){return e.type?this.contextGroupMap.get(e.type):this.lastContext}setContext(t,n){const{context:i}=t,r=e.InteropBroker.checkContextIntegrity(i);if(!1===r.isValid)throw new Error(`Failed to set Context - bad Context. Reason: ${r.reason}. Context: ${JSON.stringify(i)}`);if(!this.getClientState(n))throw new Error(`Client with Identity: ${n.uuid} ${n.name} not in Session Client State Map`);this.contextGroupMap.set(i.type,i),this.lastContext=i,Array.from(this.clients.values()).forEach((e=>{e.contextHandlers.get(i.type)?.forEach((t=>{this.provider.dispatch(e.clientIdentity,t,i)})),e.globalHandler&&this.provider.dispatch(e.clientIdentity,e.globalHandler,i)}))}getClientState(e){return this.clients.get(e.endpointId)}async handlerAdded(e,t){const{handlerId:n,contextType:i}=e,r=this.getClientState(t);if(!r)throw new Error(`Client with Identity: ${t.uuid} ${t.name} not in Client State Map`);if(i){const e=r.contextHandlers.get(i)||[];r.contextHandlers.set(i,[...e,n]);const o=this.contextGroupMap.get(i);o&&await this.provider.dispatch(t,n,o)}else{r.globalHandler=n;const e=[...this.contextGroupMap.keys()].map((async e=>{const i=this.contextGroupMap.get(e);i&&await this.provider.dispatch(t,n,i)}));await Promise.all(e)}}handlerRemoved(e,t){const{handlerId:n}=e,i=this.clients.get(t.endpointId);i?(Array.from(i.contextHandlers).forEach((([,e])=>{const t=e.indexOf(n);t>-1&&e.splice(t,1)})),i.globalHandler===n&&(i.globalHandler=void 0)):console.warn(`Trying to remove a handler from a client that isn't mapped. handlerId: ${n}. clientIdentity: ${t}`)}registerNewClient(e){if(!this.clients.has(e.endpointId)){const t={contextHandlers:new Map,clientIdentity:e,globalHandler:void 0};this.clients.set(e.endpointId,t)}}onDisconnection(e){this.clients.delete(e.endpointId)}},Ti}(),h=$i,l=n,u=function(){if(Bi)return Wi;Bi=1,Object.defineProperty(Wi,"__esModule",{value:!0}),Wi.PrivateChannelProvider=void 0;const e=Hi();return Wi.PrivateChannelProvider=class t{constructor(e,t){this.provider=e,this.id=t,this.clients=new Map,this.registerListeners(),this.contextByContextType=new Map,this.lastContext=void 0,this.provider.onConnection((e=>this.registerNewClient(e))),this.provider.onDisconnection((async e=>{const{endpointId:t}=e;this.clients.has(t)&&await this.handleClientDisconnecting(e),0===(await this.provider.getAllClientInfo()).length&&this.provider.destroy()}))}getClientState(e){return this.clients.get(e.endpointId)}registerListeners(){this.provider.register("broadcast",this.broadcast.bind(this)),this.provider.register("getCurrentContext",this.getCurrentContext.bind(this)),this.provider.register("contextHandlerAdded",this.contextHandlerAdded.bind(this)),this.provider.register("contextHandlerRemoved",this.contextHandlerRemoved.bind(this)),this.provider.register("nonStandardHandlerRemoved",this.nonStandardHandlerRemoved.bind(this)),this.provider.register("onAddContextHandlerAdded",this.onAddContextHandlerAdded.bind(this)),this.provider.register("onDisconnectHandlerAdded",this.onDisconnectHandlerAdded.bind(this)),this.provider.register("onUnsubscribeHandlerAdded",this.onUnsubscribeHandlerAdded.bind(this)),this.provider.register("clientDisconnecting",((e,t)=>{this.handleClientDisconnecting(t)}))}broadcast(t,n){const{context:i}=t;if(!this.getClientState(n))throw new Error(`Client with Identity: ${n.uuid} ${n.name}, tried to call broadcast, is not connected to this Private Channel`);const r=e.InteropBroker.checkContextIntegrity(i);if(!1===r.isValid)throw new Error(`Failed to broadcast - bad Context. Reason: ${r.reason}. Context: ${JSON.stringify(i)}`);this.contextByContextType.set(i.type,i),this.lastContext=i,Array.from(this.clients.values()).forEach((e=>{const t=e.handlerIdsByContextTypes.get(i.type);t&&t.forEach((t=>{this.provider.dispatch(e.clientIdentity,t,i)})),e.globalHandler&&this.provider.dispatch(e.clientIdentity,e.globalHandler,i)}))}getCurrentContext(e,t){const{contextType:n}=e;if(!this.getClientState(t))throw new Error(`Client with Identity: ${t.uuid} ${t.name}, tried to call getCurrentContext, is not connected to this Private Channel`);if(void 0!==n){return this.contextByContextType.get(n)||null}return this.lastContext?this.lastContext:null}contextHandlerAdded(e,t){const{handlerId:n,contextType:i}=e,r=this.getClientState(t);if(!r)throw new Error(`Client with Identity: ${t.uuid} ${t.name}, tried to call addContextListener, is not connected to this Private Channel`);if(i){const e=r.handlerIdsByContextTypes.get(i)||[];r.handlerIdsByContextTypes.set(i,[...e,n])}else r.globalHandler=n;Array.from(this.clients.values()).forEach((e=>{e.clientIdentity.endpointId!==t.endpointId&&e.onAddContextListenerHandlerId&&this.provider.dispatch(e.clientIdentity,e.onAddContextListenerHandlerId,i)}))}async contextHandlerRemoved(e,t){const{handlerId:n}=e,i=this.getClientState(t);if(i){let e;if(i.globalHandler===n)i.globalHandler=void 0;else for(const[t,r]of i.handlerIdsByContextTypes){const i=r.indexOf(n);i>-1&&(r.splice(i,1),e=t)}const r=(await this.getConnectedClients()).map((async n=>{const{clientIdentity:i,clientIdentity:{endpointId:r},onUnsubscribeHandlerId:o}=n;r!==t.endpointId&&o&&await this.provider.dispatch(i,o,e)}));try{await Promise.all(r)}catch(e){throw console.error(`Problem when attempting to dispatch to onUnsubscribeHandlers. Error: ${e} Removing Client: ${n}. uuid: ${t.uuid}. name: ${t.name}. endpointId: ${t.endpointId}`),new Error(e)}}else console.warn(`Trying to remove a handler from a client that isn't mapped. handlerId: ${n}. uuid: ${t.uuid}. name: ${t.name}. endpointId: ${t.endpointId}.`)}nonStandardHandlerRemoved(e,t){const{handlerId:n}=e,i=this.getClientState(t);i?i.onDisconnectHandlerId===n?i.onDisconnectHandlerId=void 0:i.onAddContextListenerHandlerId===n?i.onAddContextListenerHandlerId=void 0:i.onUnsubscribeHandlerId===n&&(i.onUnsubscribeHandlerId=void 0):console.warn(`Trying to remove a handler from a client that isn't mapped. handlerId: ${n}. clientIdentity: ${t}`)}onAddContextHandlerAdded(e,t){const n=this.getClientState(t),{handlerId:i}=e;if(!n)throw new Error(`Client with Identity: ${t.uuid} ${t.name}, tried to call onAddContextListener, is not connected to this Private Channel`);n.onAddContextListenerHandlerId=i,Array.from(this.clients.values()).forEach((e=>{e.clientIdentity.endpointId!==t.endpointId&&Array.from(e.handlerIdsByContextTypes.keys()).forEach((e=>{this.provider.dispatch(t,i,e)}))}))}onDisconnectHandlerAdded(e,t){const n=this.getClientState(t),{handlerId:i}=e;if(!n)throw new Error(`Client with Identity: ${t.uuid} ${t.name}, tried to call onDisconnect, is not connected to this Private Channel`);n.onDisconnectHandlerId=i}onUnsubscribeHandlerAdded(e,t){const n=this.getClientState(t),{handlerId:i}=e;if(!n)throw new Error(`Client with Identity: ${t.uuid} ${t.name}, tried to call onUnsubscribe, is not connected to this Private Channel`);n.onUnsubscribeHandlerId=i}removeClient(e){const t=this.getClientState(e);if(!t)throw new Error(`Client with Identity: ${e.uuid} ${e.name}, tried to call disconnect, is not connected to this Private Channel`);t.handlerIdsByContextTypes.clear(),this.clients.delete(e.endpointId)}async fireOnDisconnectForOtherClients(e){const{endpointId:t}=e,n=(await this.getConnectedClients()).map((async e=>{const{clientIdentity:{endpointId:n},onDisconnectHandlerId:i}=e;n!==t&&i&&await this.provider.dispatch(e.clientIdentity,i)}));try{await Promise.all(n)}catch(t){throw console.error(`Problem when attempting to dispatch to onDisconnectHandlers. Error: ${t} Disconnecting Client: uuid: ${e.uuid}. name: ${e.name}. endpointId: ${e.endpointId}`),new Error(t)}}async unsubscribeAll(e){const{endpointId:t}=e,n=this.clients.get(t);if(n){const t=Array.from(n.handlerIdsByContextTypes.values()).flat(),i=n.globalHandler;if(t.length>0){const n=t.map((async t=>this.contextHandlerRemoved({handlerId:t},e)));try{await Promise.all(n)}catch(e){console.error(e.message)}}if(i)try{await this.contextHandlerRemoved({handlerId:i},e)}catch(e){console.error(e.message)}}}async handleClientDisconnecting(e){await this.unsubscribeAll(e),this.removeClient(e),await this.fireOnDisconnectForOtherClients(e)}registerNewClient(e){if(!this.clients.has(e.endpointId)){const t={clientIdentity:e,handlerIdsByContextTypes:new Map,globalHandler:void 0,onAddContextListenerHandlerId:void 0,onUnsubscribeHandlerId:void 0,onDisconnectHandlerId:void 0};this.clients.set(e.endpointId,t)}}async getConnectedClients(){const e=await this.provider.getAllClientInfo();return Array.from(this.clients.values()).filter((t=>{const{uuid:n,name:i}=t.clientIdentity;return e.some((e=>i===e.name&&n===e.uuid))}))}static init(e,n){return new t(e,n)}},Wi}(),p=B,w=[{id:"green",displayMetadata:{color:"#00CC88",name:"green"}},{id:"purple",displayMetadata:{color:"#8C61FF",name:"purple"}},{id:"orange",displayMetadata:{color:"#FF8C4C",name:"orange"}},{id:"red",displayMetadata:{color:"#FF5E60",name:"red"}},{id:"pink",displayMetadata:{color:"#FF8FB8",name:"pink"}},{id:"yellow",displayMetadata:{color:"#E9FF8F",name:"yellow"}}];let y=class n extends a.Base{constructor(n,o,a){super(n),e.set(this,void 0),t.set(this,void 0),i.set(this,void 0),this.getProvider=()=>s(this,i,"f").getValue(),this.interopClients=new Map,this.contextGroupsById=new Map,r(this,t,a.contextGroups??[...w],"f"),r(this,e,a.fdc3Info,"f"),a?.logging&&(this.logging=a.logging),this.intentClientMap=new Map,this.lastContextMap=new Map,this.sessionContextGroupMap=new Map,r(this,i,new p.Lazy(o),"f"),this.setContextGroupMap(),this.setupChannelProvider()}static createClosedConstructor(...e){return class extends n{constructor(...t){if(t.length){const[n,i,r]=t;if(r&&"object"==typeof r&&!(0,l.isEqual)(r,e[2]))return console.warn("You have modified the parameters of the InteropOverride constructor. This behavior is deprecated and will be removed in a future version. You can modify these options in your manifest. Please consult our Interop docs for guidance on migrating to the new override scheme."),void super(e[0],e[1],r);console.warn("You are attempting to pass arguments to the InteropOverride constructor. This is not necessary, and these passed arguments will be ignored. You are likely using an older InteropBroker override scheme. Please consult our Interop docs for guidance on migrating to the new override scheme.")}super(...e)}}}setContext({context:e},t){this.wire.sendAction("interop-broker-set-context").catch((e=>{}));const n=this.getClientState(t);if(!n||!n.contextGroupId)throw n?new Error("You must join a context group before you can set context."):new Error(`Client with Identity: ${t.uuid} ${t.name} not in Client State Map`);{const{contextGroupId:t}=n;this.setContextForGroup({context:e},t)}}setContextForGroup({context:e},t){this.wire.sendAction("interop-broker-set-context-for-group").catch((e=>{}));const i=this.contextGroupsById.get(t);if(!i)throw new Error(`Unable to set context for context group that isn't in the context group mapping: ${t}.`);const r=n.checkContextIntegrity(e);if(!1===r.isValid)throw new Error(`Failed to set Context - bad Context. Reason: ${r.reason}. Context: ${JSON.stringify(e)}`);const o=e.type;i.set(o,e),this.lastContextMap.set(t,o);Array.from(this.interopClients.values()).filter((e=>e.contextGroupId===t)).forEach((t=>{for(const[,i]of t.contextHandlers)n.isContextTypeCompatible(o,i.contextType)&&this.invokeContextHandler(t.clientIdentity,i.handlerId,e)}))}getCurrentContext(e,t){this.wire.sendAction("interop-broker-get-current-context").catch((e=>{}));const n=this.getClientState(t);if(!n?.contextGroupId)throw new Error("You must be a member of a context group to call getCurrentContext");const{contextGroupId:i}=n,r=this.contextGroupsById.get(i),o=this.lastContextMap.get(i),s=e?.contextType??o;return r&&s?r.get(s):void 0}async joinContextGroup({contextGroupId:e,target:t},i){if(this.wire.sendAction("interop-broker-join-context-group").catch((e=>{})),this.sessionContextGroupMap.has(e))throw new Error(h.BROKER_ERRORS.joinSessionContextGroupWithJoinContextGroup);if(t){n.hasEndpointId(t)&&await this.addClientToContextGroup({contextGroupId:e},t);try{const n=this.channel.connections.filter((e=>e.uuid===t.uuid&&e.name===t.name));if(!n.length)throw new Error(`Given Identity ${t.uuid} ${t.name} is not connected to the Interop Broker.`);n.length>1&&console.warn(`More than one connection found for identity ${t.uuid} ${t.name}`);const i=[];for(const t of n)i.push(this.addClientToContextGroup({contextGroupId:e},t));await Promise.all(i)}catch(e){throw new Error(e)}}else await this.addClientToContextGroup({contextGroupId:e},i)}async addClientToContextGroup({contextGroupId:e},t){this.wire.sendAction("interop-broker-add-client-to-context-group").catch((e=>{}));const n=this.getClientState(t);if(!n)throw new Error(`Client with Identity: ${t.uuid} ${t.name} not in Client State Map`);if(!this.getContextGroups().find((t=>t.id===e)))throw new Error(`Attempting to join a context group that does not exist: ${e}. You may only join existing context groups.`);if(n.contextGroupId!==e){n.contextGroupId=e,await this.setCurrentContextGroupInClientOptions(t,e);const i=this.contextGroupsById.get(e);for(const[,e]of n.contextHandlers){const{contextType:n,handlerId:r}=e;if(void 0===n)i.forEach(((e,n)=>{this.invokeContextHandler(t,r,e)}));else if(i.has(n)){const e=i.get(n);e&&this.invokeContextHandler(t,r,e)}}}}async removeFromContextGroup({target:e},t){if(this.wire.sendAction("interop-broker-remove-from-context-group").catch((e=>{})),e){n.hasEndpointId(e)&&await this.removeClientFromContextGroup(e);try{const t=this.channel.connections.filter((t=>t.uuid===e.uuid&&t.name===e.name));if(!t.length)throw new Error(`No connection found for given Identity ${e.uuid} ${e.name}`);t.length>1&&console.warn(`More than one connection found for identity ${e.uuid} ${e.name}`);const n=[];for(const e of t)n.push(this.removeClientFromContextGroup(e));await Promise.all(n)}catch(e){throw new Error(e)}}else await this.removeClientFromContextGroup(t)}async removeClientFromContextGroup(e){this.wire.sendAction("interop-broker-remove-client-from-context-group").catch((e=>{}));const t=this.getClientState(e);t&&(t.contextGroupId=void 0),await this.setCurrentContextGroupInClientOptions(e,null)}getContextGroups(){return this.wire.sendAction("interop-broker-get-context-groups").catch((e=>{})),s(this,t,"f").map((e=>({...e})))}getInfoForContextGroup({contextGroupId:e}){return this.wire.sendAction("interop-broker-get-info-for-context-group").catch((e=>{})),this.getContextGroups().find((t=>t.id===e))}getAllClientsInContextGroup({contextGroupId:e}){this.wire.sendAction("interop-broker-get-all-clients-in-context-group").catch((e=>{}));return Array.from(this.interopClients.values()).filter((t=>t.contextGroupId===e)).map((e=>e.clientIdentity))}async handleFiredIntent(e,t){const n=(0,h.generateOverrideWarning)("fdc3.raiseIntent","InteropBroker.handleFiredIntent",t,"interopClient.fireIntent");throw console.warn(n),new Error(h.BROKER_ERRORS.fireIntent)}async setIntentTarget(e,t){this.wire.sendAction("interop-broker-set-intent-target").catch((e=>{}));const n=this.intentClientMap.get(t.name),i=`intent-handler-${e.name}`;if(n){const t=n.get(i);if(t){if(t.pendingIntents.push(e),t.clientIdentity&&t.isReady){const{clientIdentity:e,pendingIntents:n}=t;try{const r=n[n.length-1];await this.invokeIntentHandler(e,i,r),t.pendingIntents=[]}catch(n){console.error(`Error invoking intent handler for client ${e.uuid}/${e.name}/${e.endpointId}`),t.isReady=!1}}}else n.set(i,{isReady:!1,pendingIntents:[e]})}else{this.intentClientMap.set(t.name,new Map);const n=this.intentClientMap.get(t.name);n&&n.set(i,{isReady:!1,pendingIntents:[e]})}}async handleInfoForIntent(e,t){const n=(0,h.generateOverrideWarning)("fdc3.findIntent","InteropBroker.handleInfoForIntent",t,"interopClient.getInfoForIntent");throw console.warn(n),new Error(h.BROKER_ERRORS.getInfoForIntent)}async handleInfoForIntentsByContext(e,t){const n=(0,h.generateOverrideWarning)("fdc3.findIntentsByContext","InteropBroker.handleInfoForIntentsByContext",t,"interopClient.getInfoForIntentsByContext");throw console.warn(n),new Error(h.BROKER_ERRORS.getInfoForIntentsByContext)}async handleFiredIntentForContext(e,t){const n=(0,h.generateOverrideWarning)("fdc3.raiseIntentForContext","InteropBroker.handleFiredIntentForContext",t,"interopClient.fireIntentForContext");throw console.warn(n),new Error(h.BROKER_ERRORS.fireIntentForContext)}async clientDisconnected(e){}async fdc3HandleOpen({app:e,context:t},n){const i=(0,h.generateOverrideWarning)("fdc3.open","InteropBroker.fdc3HandleOpen",n);throw console.warn(i),new Error(h.BROKER_ERRORS.fdc3Open)}async fdc3HandleFindInstances(e,t){const n=(0,h.generateOverrideWarning)("fdc3.open","InteropBroker.fdc3HandleFindInstances",t);throw console.warn(n),new Error(h.BROKER_ERRORS.fdc3FindInstances)}async fdc3HandleGetAppMetadata(e,t){const n=(0,h.generateOverrideWarning)("fdc3.getAppMetadata","InteropBroker.fdc3HandleGetAppMetadata",t);throw console.warn(n),new Error(h.BROKER_ERRORS.fdc3GetAppMetadata)}async invokeContextHandler(e,t,n){const i=await this.getProvider();try{await i.dispatch(e,t,n)}catch(i){console.error(`Error invoking context handler ${t} for context type ${n.type} in client ${e.uuid}/${e.name}/${e.endpointId}`,i)}}async invokeIntentHandler(e,t,n){const i=await this.getProvider();await i.dispatch(e,t,n)}async fdc3HandleGetInfo(t,n){const{fdc3Version:i}=t;return{fdc3Version:i,...s(this,e,"f"),optionalFeatures:{OriginatingAppMetadata:!1,UserChannelMembershipAPIs:!0},appMetadata:{appId:"",instanceId:""}}}async getAllClientInfo(){return(await this.getProvider()).getAllClientInfo()}decorateSnapshot(e){return{...e,interopSnapshotDetails:{contextGroupStates:this.getContextGroupStates()}}}applySnapshot(e,t){const n=e?.interopSnapshotDetails?.contextGroupStates;n&&(t?.closeExistingWindows||this.updateExistingClients(n),this.rehydrateContextGroupStates(n))}updateExistingClients(e){this.interopClients.forEach((t=>{const{clientIdentity:i,contextGroupId:r,contextHandlers:o}=t;if(r){const t=e[r];for(const[,e]of Object.entries(t))o.forEach((t=>{const{handlerId:r,contextType:o}=t;n.isContextTypeCompatible(e.type,o)&&this.invokeContextHandler(i,r,e)}))}}))}getContextGroupStates(){return n.toObject(this.contextGroupsById)}rehydrateContextGroupStates(e){const t=Object.entries(e);for(const[e,n]of t){const t=Object.entries(n);for(const[n,i]of t)if(this.contextGroupsById.has(e)){this.contextGroupsById.get(e).set(n,i)}else console.warn(`Attempting to set a context group that isn't in the context group mapping. Skipping context group rehydration for: ${e}`)}}contextHandlerRegistered({contextType:e,handlerId:t},n){const i={contextType:e,handlerId:t},r=this.getClientState(n);if(r?.contextHandlers.set(t,i),r&&r.contextGroupId){const{contextGroupId:i}=r,o=this.contextGroupsById.get(i);if(void 0===e)o.forEach(((e,i)=>{this.invokeContextHandler(n,t,e)}));else if(o.has(e)){const i=o.get(e);i&&this.invokeContextHandler(n,t,i)}}}async intentHandlerRegistered(e,t){const{handlerId:n}=e,i=this.intentClientMap.get(t.name),r=i?.get(n);if(i)if(r){const{pendingIntents:e}=r;r.clientIdentity=t,r.isReady=!0;try{if(e.length>0){const i=e[e.length-1];await this.invokeIntentHandler(t,n,i),r.pendingIntents=[]}}catch(e){console.error(`Error invoking intent handler: ${n} for client ${t.uuid}/${t.name}/${t.endpointId}`)}}else i.set(n,{isReady:!0,pendingIntents:[],clientIdentity:t});else{this.intentClientMap.set(t.name,new Map);const e=this.intentClientMap.get(t.name);e&&e.set(n,{isReady:!0,pendingIntents:[],clientIdentity:t})}}removeContextHandler({handlerId:e},t){const n=this.getClientState(t);n&&n.contextHandlers.delete(e)}handleJoinSessionContextGroup({sessionContextGroupId:e},t){try{if(!e)throw new Error("Failed to join session context group: must specify group id.");const n=this.sessionContextGroupMap.get(e);if(n)n.registerNewClient(t);else{const n=new d.default(this.channel,e);n.registerNewClient(t),this.sessionContextGroupMap.set(e,n)}return{hasConflict:this.contextGroupsById.has(e)}}catch(e){throw new Error(e)}}getClientState(e){return this.interopClients.get(e.endpointId)}static toObject(e){const t=Object.fromEntries(e),n={};return Object.entries(t).forEach((([e,t])=>{const i=Object.fromEntries(t);n[e]=i})),n}static checkContextIntegrity(e){if(!e)return{isValid:!1,reason:"No context supplied"};if("object"!=typeof e)return{isValid:!1,reason:"Context must be an Object"};if(!e.type)return{isValid:!1,reason:"Context must have a type property"};if(e.id&&"object"!=typeof e.id)return{isValid:!1,reason:"Context id must be an Object populated with key-value identifiers (if set)"};if(e.id){const{id:t}=e,n=Object.keys(t);let i=!1;if(!n.length)return{isValid:!1,reason:"Context id must have at least one key-value identifier"};if(n.forEach((e=>{"string"==typeof e&&"string"==typeof t[e]||(i=!0)})),i)return{isValid:!1,reason:"Context id key-value identifiers must be of type string"}}return e.name&&"string"!=typeof e.name?{isValid:!1,reason:"Context name must be of string type (if set)"}:{isValid:!0}}static hasEndpointId(e){return void 0!==e.endpointId}static isContextTypeCompatible(e,t){return void 0===t||e===t}setContextGroupMap(){for(const e of this.getContextGroups())this.contextGroupsById.set(e.id,new Map)}async setCurrentContextGroupInClientOptions(e,t){try{const n=await this.fin.System.getEntityInfo(e.uuid,e.name);let i;"view"===n.entityType?i=await this.fin.View.wrap(e):"window"===n.entityType&&(i=await this.fin.Window.wrap(e)),i&&await i.updateOptions({interop:{currentContextGroup:t}})}catch(e){}}async setupChannelProvider(){try{const e=await this.getProvider();this.channel=e,this.wireChannel(e)}catch(e){throw new Error(`Error setting up Interop Broker Channel Provider: ${e}`)}}wireChannel(e){e.onConnection((async(e,t)=>{if(!await this.isConnectionAuthorized(e,t))throw new Error(`Connection not authorized for ${e.uuid}, ${e.name}`);if(!e.endpointId)throw new Error("Version too old to be compatible with Interop. Please upgrade your runtime to a more recent version.");const n={contextGroupId:void 0,contextHandlers:new Map,clientIdentity:e};t?.currentContextGroup&&this.contextGroupsById.has(t.currentContextGroup)&&(n.contextGroupId=t?.currentContextGroup),this.interopClients.set(e.endpointId,n)})),e.onDisconnection((e=>{this.interopClients.delete(e.endpointId);const t=this.intentClientMap.get(e.name);t&&e.uuid===this.fin.me.uuid&&t.forEach((e=>{e.isReady=!1})),this.sessionContextGroupMap.forEach((t=>{t.onDisconnection(e)})),this.clientDisconnected(e)})),e.beforeAction((async(e,t,n)=>{if(!await this.isActionAuthorized(e,t,n))throw new Error(`Action (${e}) not authorized for ${n.uuid}, ${n.name}`);this.logging?.beforeAction?.enabled&&console.log(e,t,n)})),e.afterAction(((e,t,n)=>{this.logging?.afterAction?.enabled&&console.log(e,t,n)})),e.register("setContext",this.setContext.bind(this)),e.register("fireIntent",this.handleFiredIntent.bind(this)),e.register("getCurrentContext",this.getCurrentContext.bind(this)),e.register("getInfoForIntent",this.handleInfoForIntent.bind(this)),e.register("getInfoForIntentsByContext",this.handleInfoForIntentsByContext.bind(this)),e.register("fireIntentForContext",this.handleFiredIntentForContext.bind(this)),e.register("getContextGroups",this.getContextGroups.bind(this)),e.register("joinContextGroup",this.joinContextGroup.bind(this)),e.register("removeFromContextGroup",this.removeFromContextGroup.bind(this)),e.register("getAllClientsInContextGroup",this.getAllClientsInContextGroup.bind(this)),e.register("getInfoForContextGroup",this.getInfoForContextGroup.bind(this)),e.register("contextHandlerRegistered",this.contextHandlerRegistered.bind(this)),e.register("intentHandlerRegistered",this.intentHandlerRegistered.bind(this)),e.register("removeContextHandler",this.removeContextHandler.bind(this)),e.register("sessionContextGroup:createIfNeeded",this.handleJoinSessionContextGroup.bind(this)),e.register("fdc3Open",this.fdc3HandleOpen.bind(this)),e.register("fdc3v2FindIntentsByContext",this.handleInfoForIntentsByContext.bind(this)),e.register("fdc3FindInstances",this.fdc3HandleFindInstances.bind(this)),e.register("fdc3GetAppMetadata",this.fdc3HandleGetAppMetadata.bind(this)),e.register("fdc3v2GetInfo",(async(e,t)=>this.fdc3HandleGetInfo.bind(this)(e,t))),e.register("createPrivateChannelProvider",(async e=>{const{channelId:t}=e,n=await this.fin.InterApplicationBus.Channel.create(t);u.PrivateChannelProvider.init(n,t)}))}isConnectionAuthorized(e,t){return this.wire.sendAction("interop-broker-is-connection-authorized").catch((e=>{})),Promise.resolve(!0)}isActionAuthorized(e,t,n){return this.wire.sendAction("interop-broker-is-action-authorized").catch((e=>{})),Promise.resolve(!0)}};return ki.InteropBroker=y,e=new WeakMap,t=new WeakMap,i=new WeakMap,ki}var Ni,Di={},Ui={},Vi=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},zi=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(Ui,"__esModule",{value:!0});const Ki=c,qi=$i;class Yi extends Ki.Base{constructor(e,t,n){super(e),Ni.set(this,void 0),this.id=n,Vi(this,Ni,t,"f")}async setContext(e){this.wire.sendAction("interop-session-context-group-set-context").catch((e=>{}));return(await zi(this,Ni,"f")).dispatch(`sessionContextGroup:setContext-${this.id}`,{sessionContextGroupId:this.id,context:e})}async getCurrentContext(e){this.wire.sendAction("interop-session-context-group-get-context").catch((e=>{}));return(await zi(this,Ni,"f")).dispatch(`sessionContextGroup:getContext-${this.id}`,{sessionContextGroupId:this.id,type:e})}async addContextHandler(e,t){if(this.wire.sendAction("interop-session-context-group-add-handler").catch((e=>{})),"function"!=typeof e)throw new Error("Non-function argument passed to the first parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");const n=await zi(this,Ni,"f");let i;return i=t?`sessionContextHandler:invoke-${this.id}-${t}-${(0,qi.generateId)()}`:`sessionContextHandler:invoke-${this.id}`,n.register(i,(0,qi.wrapContextHandler)(e,i)),await n.dispatch(`sessionContextGroup:handlerAdded-${this.id}`,{handlerId:i,contextType:t}),{unsubscribe:await this.createUnsubscribeCb(i)}}async createUnsubscribeCb(e){const t=await zi(this,Ni,"f");return async()=>{t.remove(e),await t.dispatch(`sessionContextGroup:handlerRemoved-${this.id}`,{handlerId:e})}}getUserInstance(){return{id:this.id,setContext:(0,qi.wrapInTryCatch)(this.setContext.bind(this),"Failed to set context: "),getCurrentContext:(0,qi.wrapInTryCatch)(this.getCurrentContext.bind(this),"Failed to get context: "),addContextHandler:(0,qi.wrapInTryCatch)(this.addContextHandler.bind(this),"Failed to add context handler: ")}}}Ui.default=Yi,Ni=new WeakMap;var Ji={},Zi={},Qi={},Xi={};Object.defineProperty(Xi,"__esModule",{value:!0}),Xi.PrivateChannelClient=void 0;const er=$i;var tr,nr;function ir(){if(tr)return Zi;tr=1;var e,t=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)},i=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n};Object.defineProperty(Zi,"__esModule",{value:!0}),Zi.FDC3ModuleBase=void 0;const r=Qi,s=$i,a=ar(),c=n;return Zi.FDC3ModuleBase=class{get client(){return t(this,e,"f").call(this)}get fin(){return this.wire.getFin()}constructor(t,n){this.wire=n,e.set(this,void 0),i(this,e,t,"f")}async broadcast(e){return this.wire.sendAction("fdc3-broadcast").catch((e=>{})),this.client.setContext(e)}async _open(e,t){this.wire.sendAction("fdc3-open").catch((e=>{}));try{return await a.InteropClient.ferryFdc3Call(this.client,"fdc3Open",{app:e,context:t})}catch(e){const t=e.message===s.BROKER_ERRORS.fdc3Open?"ResolverUnavailable":e.message;throw new Error(t)}}async _getChannels(){return(await this.client.getContextGroups()).map((e=>({...e,type:"system",...(0,r.getUnsupportedChannelApis)()})))}async getOrCreateChannel(e){this.wire.sendAction("fdc3-get-or-create-channel").catch((e=>{}));const t=(await this._getChannels()).find((t=>t.id===e));if(t)return{...t,type:"system",...(0,r.getUnsupportedChannelApis)()};try{const t=await this.client.joinSessionContextGroup(e);return(0,r.buildAppChannelObject)(t)}catch(e){throw console.error(e.message),new Error(r.ChannelError.CreationFailed)}}async getSystemChannels(){return this.wire.sendAction("fdc3-get-system-channels").catch((e=>{})),this._getChannels()}async joinChannel(e){this.wire.sendAction("fdc3-join-channel").catch((e=>{}));try{return await this.client.joinContextGroup(e)}catch(e){if(e.message===s.BROKER_ERRORS.joinSessionContextGroupWithJoinContextGroup?console.error("The Channel you have tried to join is an App Channel. Custom Channels can only be defined by the Interop Broker through code or manifest configuration. Please use getOrCreateChannel."):console.error(e.message),e.message.startsWith("Attempting to join a context group that does not exist"))throw new Error(r.ChannelError.NoChannelFound);throw new Error(r.ChannelError.AccessDenied)}}async getCurrentChannel(){this.wire.sendAction("fdc3-get-current-channel").catch((e=>{}));const e=await this.getCurrentContextGroupInfo();return e?this.buildChannelObject(e):null}async leaveCurrentChannel(){return this.wire.sendAction("fdc3-leave-current-channel").catch((e=>{})),this.client.removeFromContextGroup()}async getCurrentContextGroupInfo(){const e=await this.client.getContextGroups(),t=e.map((async e=>this.client.getAllClientsInContextGroup(e.id))),n=(await Promise.all(t)).findIndex((e=>e.some((e=>{const{uuid:t,name:n}=e;return this.wire.me.uuid===t&&this.wire.me.name===n}))));return e[n]}async buildChannelObject(e){return{...e,type:"system",addContextListener:(...[e,t])=>{let n,i;"function"==typeof e?(console.warn("addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)"),n=e):(n=t,"string"==typeof e&&(i=e));const r=(async()=>{let e=!0;const t=await this.client.getCurrentContext(i);return this.client.addContextHandler(((i,r)=>{if(!e||(e=!1,!(0,c.isEqual)(t,i)))return n(i,r)}),i)})();return{...r,unsubscribe:()=>r.then((e=>e.unsubscribe()))}},broadcast:this.broadcast.bind(this),getCurrentContext:async e=>{const t=await this.client.getCurrentContext(e);return void 0===t?null:t}}}},e=new WeakMap,Zi}Xi.PrivateChannelClient=class{constructor(e,t){this.id=t,this.client=e,this.listeners=new Map}async broadcast(e){return this.client.dispatch("broadcast",{context:e})}async getCurrentContext(e){return this.client.dispatch("getCurrentContext",{contextType:e})}async addContextListener(e,t){if("function"!=typeof t)throw new Error("Non-function argument passed to the second parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");let n;n=e?`contextHandler:invoke-${this.id}-${e}-${er.generateId()}`:`contextHandler:invoke-${this.id}-${er.generateId()}`,this.client.register(n,er.wrapContextHandler(t,n));const i={unsubscribe:await this.createContextUnsubscribeCb(n)};return this.listeners.set(n,i),await this.client.dispatch("contextHandlerAdded",{handlerId:n,contextType:e}),i}createNonStandardUnsubscribeCb(e){return async()=>{this.client.remove(e),this.listeners.delete(e),await this.client.dispatch("nonStandardHandlerRemoved",{handlerId:e})}}createContextUnsubscribeCb(e){return async()=>{this.client.remove(e),this.listeners.delete(e),await this.client.dispatch("contextHandlerRemoved",{handlerId:e})}}onAddContextListener(e){const t=`onContextHandlerAdded:invoke-${this.id}-${er.generateId()}`;this.client.register(t,e);const n={unsubscribe:this.createNonStandardUnsubscribeCb(t)};return this.listeners.set(t,n),this.client.dispatch("onAddContextHandlerAdded",{handlerId:t}),n}onDisconnect(e){const t=`onDisconnect:invoke-${this.id}-${er.generateId()}`;this.client.register(t,e);const n={unsubscribe:this.createNonStandardUnsubscribeCb(t)};return this.listeners.set(t,n),this.client.dispatch("onDisconnectHandlerAdded",{handlerId:t}),n}onUnsubscribe(e){const t=`onUnsubscribe:invoke-${this.id}-${er.generateId()}`;this.client.register(t,e);const n={unsubscribe:this.createNonStandardUnsubscribeCb(t)};return this.listeners.set(t,n),this.client.dispatch("onUnsubscribeHandlerAdded",{handlerId:t}),n}async cleanUpAllSubs(){Array.from(this.listeners.keys()).forEach((e=>{this.client.remove(e),this.listeners.delete(e)}))}async disconnect(){try{await this.client.dispatch("clientDisconnecting"),await this.cleanUpAllSubs(),await this.client.disconnect()}catch(e){throw new Error(e.message)}}},function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.getIntentResolution=e.isChannel=e.isContext=e.connectPrivateChannel=e.buildAppChannelObject=e.buildPrivateChannelObject=e.ChannelError=e.ResultError=e.UnsupportedChannelApiError=e.getUnsupportedChannelApis=void 0;const t=$i,i=Xi,r=n;e.getUnsupportedChannelApis=e=>({addContextListener:()=>{throw new o("Channel.addContextListener",e)},broadcast:()=>{throw new o("Channel.broadcast",e)},getCurrentContext:()=>{throw new o("Channel.getCurrentContext",e)}});class o extends Error{constructor(e,t="System"){super(e),this.message=`Calling ${e} on an instance of a ${t} Channel returned by fdc3.get${t}Channels is not supported. If you would like to use a ${t} Channel, please use fdc3.joinChannel, fdc3.addContextListener, and fdc3.broadcast instead.`}}var s,a;e.UnsupportedChannelApiError=o,function(e){e.NoResultReturned="NoResultReturned",e.IntentHandlerRejected="IntentHandlerRejected"}(s=e.ResultError||(e.ResultError={})),(a=e.ChannelError||(e.ChannelError={})).NoChannelFound="NoChannelFound",a.AccessDenied="AccessDenied",a.CreationFailed="CreationFailed";e.buildPrivateChannelObject=e=>{let t=!1;const n=()=>{if(t)throw new Error("Private Channel Client has been disconnected from the Private Channel")};return{id:e.id,type:"private",broadcast:async t=>(n(),e.broadcast(t)),getCurrentContext:async t=>(n(),e.getCurrentContext(t)),addContextListener:async(t,i)=>{n();let r=i,o=t;"function"==typeof t&&(console.warn("addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)"),r=t,o=null);return e.addContextListener(o,r)},onAddContextListener:t=>(n(),e.onAddContextListener(t)),disconnect:async()=>(n(),t=!0,e.disconnect()),onDisconnect:t=>(n(),e.onDisconnect(t)),onUnsubscribe:t=>(n(),e.onUnsubscribe(t))}};e.buildAppChannelObject=e=>({id:e.id,type:"app",broadcast:e.setContext,getCurrentContext:async t=>{const n=await e.getCurrentContext(t);return void 0===n?null:n},addContextListener:(t,n)=>{let i,o;"function"==typeof t?(console.warn("addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)"),i=t):(i=n,"string"==typeof t&&(o=t));const s=(async()=>{let t=!0;const n=await e.getCurrentContext(o);return e.addContextHandler(((e,o)=>{if(!t||(t=!1,!(0,r.isEqual)(n,e)))return i(e,o)}),o)})();return{...s,unsubscribe:()=>s.then((e=>e.unsubscribe()))}}});e.connectPrivateChannel=async t=>{try{const n=await fin.InterApplicationBus.Channel.connect(t),r=new i.PrivateChannelClient(n,t);return(0,e.buildPrivateChannelObject)(r)}catch(e){throw new Error(`Private Channel with id: ${t} doesn't exist`)}};e.isContext=e=>{if(e&&"object"==typeof e&&"type"in e){const{type:t}=e;return"string"==typeof t}return!1};e.isChannel=e=>{if(e&&"object"==typeof e&&"type"in e&&"id"in e){const{type:t,id:n}=e;return"string"==typeof t&&"string"==typeof n&&("app"===t||"private"===t)}return!1};e.getIntentResolution=async(n,i,r,o)=>{const a=(0,t.generateId)(),c=new Promise(((e,t)=>{fin.InterApplicationBus.subscribe({uuid:"*"},a,(t=>{e(t)})).catch((()=>t(new Error("getResult is not supported in this environment"))))})),d=r?{target:r,intentResolutionResultId:a}:{intentResolutionResultId:a},h=o?{name:o,context:i,metadata:d}:{...i,metadata:d},l=async()=>{let t=await c;if(!t||"object"!=typeof t)throw new Error(s.NoResultReturned);const{error:i}=t;if(i)throw new Error(s.IntentHandlerRejected);if((0,e.isChannel)(t)){const{id:i,type:r}=t;switch(r){case"private":t=await(0,e.connectPrivateChannel)(i);break;case"app":{const r=await n.joinSessionContextGroup(i);t=(0,e.buildAppChannelObject)(r);break}}}else if(!(0,e.isContext)(t))throw new Error(s.NoResultReturned);return t},u=o?await n.fireIntent(h):await n.fireIntentForContext(h);return"object"!=typeof u?{source:{appId:"",instanceId:""},intent:"",version:"2.0",getResult:l}:{...u,getResult:l}}}(Qi);var rr,or,sr={};function ar(){if(or)return Di;or=1;var e,t,n=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},i=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(Di,"__esModule",{value:!0}),Di.InteropClient=void 0;const r=c,s=Ui,a=function(){if(nr)return Ji;nr=1,Object.defineProperty(Ji,"__esModule",{value:!0}),Ji.Fdc3Module=void 0;const e=$i,t=ir();class n extends t.FDC3ModuleBase{async open(e,t){await super._open(e,t)}addContextListener(e,t){let n;return this.wire.sendAction("fdc3-add-context-listener").catch((e=>{})),"function"==typeof e?(console.warn("addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)"),n=this.client.addContextHandler(e)):n=this.client.addContextHandler(t,null===e?void 0:e),{...n,unsubscribe:()=>n.then((e=>e.unsubscribe()))}}addIntentListener(e,t){this.wire.sendAction("fdc3-add-intent-listener").catch((e=>{}));const n=this.client.registerIntentHandler((e=>{const{context:n,metadata:i}=e,{metadata:r}=n,o=i?.intentResolutionResultId||r?.intentResolutionResultId;o&&this.fin.InterApplicationBus.publish(o,null).catch((()=>null)),t(e.context)}),e,{fdc3Version:"1.2"});return{...n,unsubscribe:()=>n.then((e=>e.unsubscribe()))}}async raiseIntent(t,n,i){this.wire.sendAction("fdc3-raise-intent").catch((e=>{}));const r=i?{name:t,context:n,metadata:{target:i}}:{name:t,context:n};try{return await this.client.fireIntent(r)}catch(t){const n=t.message===e.BROKER_ERRORS.fireIntent?"ResolverUnavailable":t.message;throw new Error(n)}}async findIntent(t,n){this.wire.sendAction("fdc3-find-intent").catch((e=>{}));try{return await this.client.getInfoForIntent({name:t,context:n})}catch(t){const n=t.message===e.BROKER_ERRORS.getInfoForIntent?"ResolverUnavailable":t.message;throw new Error(n)}}async findIntentsByContext(t){this.wire.sendAction("fdc3-find-intents-by-context").catch((e=>{}));try{return await this.client.getInfoForIntentsByContext(t)}catch(t){const n=t.message===e.BROKER_ERRORS.getInfoForIntentsByContext?"ResolverUnavailable":t.message;throw new Error(n)}}async raiseIntentForContext(t,n){this.wire.sendAction("fdc3-raise-intent-for-context").catch((e=>{}));try{return await this.client.fireIntentForContext({...t,metadata:{target:n}})}catch(t){const n=t.message===e.BROKER_ERRORS.fireIntentForContext?"ResolverUnavailable":t.message;throw new Error(n)}}async getOrCreateChannel(e){return super.getOrCreateChannel(e)}getInfo(){return this.wire.sendAction("fdc3-get-info").catch((e=>{})),{providerVersion:this.wire.environment.getAdapterVersionSync(),provider:`openfin-${this.wire.me.uuid}`,fdc3Version:"1.2"}}}return Ji.Fdc3Module=n,Ji}(),d=function(){if(rr)return sr;rr=1,Object.defineProperty(sr,"__esModule",{value:!0}),sr.Fdc3Module2=void 0;const e=ir(),t=$i,n=ar(),i=Qi,r=Xi;class o extends e.FDC3ModuleBase{async open(e,t){return"string"==typeof e&&console.warn("Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string })."),super._open(e,t)}async findInstances(e){this.wire.sendAction("fdc3-find-instances").catch((e=>{}));try{return await n.InteropClient.ferryFdc3Call(this.client,"fdc3FindInstances",e)}catch(e){const n=e.message===t.BROKER_ERRORS.fdc3FindInstances?"ResolverUnavailable":e.message;throw new Error(n)}}async getAppMetadata(e){this.wire.sendAction("fdc3-get-app-metadata").catch((e=>{}));try{return await n.InteropClient.ferryFdc3Call(this.client,"fdc3GetAppMetadata",e)}catch(e){const n=e.message===t.BROKER_ERRORS.fdc3GetAppMetadata?"ResolverUnavailable":e.message;throw new Error(n)}}async addContextListener(e,t){this.wire.sendAction("fdc3-add-context-listener").catch((e=>{}));const n=e=>t=>{const{contextMetadata:n,...i}=t,r=n?[{...i},n]:[t,null];e(...r)};let i=t,r=n(i);return"function"==typeof e?(console.warn("addContextListener(handler) has been deprecated. Please use addContextListener(null, handler)"),i=e,r=n(i),this.client.addContextHandler(r)):this.client.addContextHandler(r,null===e?void 0:e)}async findIntent(e,n,i){this.wire.sendAction("fdc3-find-intent").catch((e=>{}));try{return await this.client.getInfoForIntent({name:e,context:n,metadata:{resultType:i}})}catch(e){const n=e.message===t.BROKER_ERRORS.getInfoForIntent?"ResolverUnavailable":e.message;throw new Error(n)}}async findIntentsByContext(e,i){this.wire.sendAction("fdc3-find-intents-by-context").catch((e=>{}));const r=i?{context:e,metadata:{resultType:i}}:e;try{return await n.InteropClient.ferryFdc3Call(this.client,"fdc3v2FindIntentsByContext",r)}catch(e){const n=e.message===t.BROKER_ERRORS.getInfoForIntentsByContext?"ResolverUnavailable":e.message;throw new Error(n)}}async raiseIntent(e,n,r){this.wire.sendAction("fdc3-raise-intent").catch((e=>{}));try{return"string"==typeof r&&console.warn("Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string })."),(0,i.getIntentResolution)(this.client,n,r,e)}catch(e){const n=e.message===t.BROKER_ERRORS.fireIntent?"ResolverUnavailable":e.message;throw new Error(n)}}async raiseIntentForContext(e,n){this.wire.sendAction("fdc3-raise-intent-for-context").catch((e=>{}));try{return"string"==typeof n&&console.warn("Passing a string as the app parameter is deprecated, please use an AppIdentifier ({ appId: string; instanceId?: string })."),(0,i.getIntentResolution)(this.client,e,n)}catch(e){const n=e.message===t.BROKER_ERRORS.fireIntent?"ResolverUnavailable":e.message;throw new Error(n)}}async addIntentListener(e,t){if(this.wire.sendAction("fdc3-add-intent-listener").catch((e=>{})),"string"!=typeof e)throw new Error("First argument must be an Intent name");return this.client.registerIntentHandler((async e=>{let n,i;const{context:r,metadata:o}=e,{contextMetadata:s,metadata:a,...c}=r,d=o?.intentResolutionResultId||a?.intentResolutionResultId;try{const e=a?{metadata:a,...c}:{...c};n=await t(e,s),i=n}catch(e){n=e,i={error:!0}}if(d&&this.fin.InterApplicationBus.publish(d,i).catch((()=>null)),n instanceof Error)throw new Error(n.message);return n}),e,{fdc3Version:"2.0"})}async getOrCreateChannel(e){return super.getOrCreateChannel(e)}async createPrivateChannel(){const e=(0,t.generateId)();await n.InteropClient.ferryFdc3Call(this.client,"createPrivateChannelProvider",{channelId:e});const o=await this.fin.InterApplicationBus.Channel.connect(e),s=new r.PrivateChannelClient(o,e);return(0,i.buildPrivateChannelObject)(s)}async getUserChannels(){return(await this.client.getContextGroups()).map((e=>({...e,type:"user",...(0,i.getUnsupportedChannelApis)("User")})))}async getSystemChannels(){return console.warn("This API has been deprecated. Please use fdc3.getUserChannels instead."),super.getSystemChannels()}async joinUserChannel(e){return super.joinChannel(e)}async joinChannel(e){return console.warn("This API has been deprecated. Please use fdc3.joinUserChannel instead."),super.joinChannel(e)}async getCurrentChannel(){const e=await super.getCurrentChannel();return e?{...e,type:"user",broadcast:this.broadcast.bind(this)}:null}async getInfo(){return n.InteropClient.ferryFdc3Call(this.client,"fdc3v2GetInfo",{fdc3Version:"2.0"})}}return sr.Fdc3Module2=o,sr}(),h=$i;let l=class extends r.Base{constructor(i,r){super(i),e.set(this,void 0),t.set(this,void 0),n(this,t,new Map,"f"),n(this,e,r,"f")}async setContext(t){this.wire.sendAction("interop-client-set-context").catch((e=>{}));return(await i(this,e,"f")).dispatch("setContext",{context:t})}async addContextHandler(t,n){if(this.wire.sendAction("interop-client-add-context-handler").catch((e=>{})),"function"!=typeof t)throw new Error("Non-function argument passed to the first parameter 'handler'. Be aware that the argument order does not match the FDC3 standard.");const r=await i(this,e,"f");let o;o=n?`invokeContextHandler-${n}-${(0,h.generateId)()}`:"invokeContextHandler";const s=(0,h.wrapContextHandler)(t,o);return r.register(o,s),await r.dispatch("contextHandlerRegistered",{handlerId:o,contextType:n}),{unsubscribe:async()=>{r.remove(o),await r.dispatch("removeContextHandler",{handlerId:o})}}}async getContextGroups(){this.wire.sendAction("interop-client-get-context-groups").catch((e=>{}));return(await i(this,e,"f")).dispatch("getContextGroups")}async joinContextGroup(t,n){this.wire.sendAction("interop-client-join-context-group").catch((e=>{}));const r=await i(this,e,"f");if(!t)throw new Error("No contextGroupId specified for joinContextGroup.");return r.dispatch("joinContextGroup",{contextGroupId:t,target:n})}async removeFromContextGroup(t){this.wire.sendAction("interop-client-remove-from-context-group").catch((e=>{}));return(await i(this,e,"f")).dispatch("removeFromContextGroup",{target:t})}async getAllClientsInContextGroup(t){this.wire.sendAction("interop-client-get-all-clients-in-context-group").catch((e=>{}));const n=await i(this,e,"f");if(!t)throw new Error("No contextGroupId specified for getAllClientsInContextGroup.");return n.dispatch("getAllClientsInContextGroup",{contextGroupId:t})}async getInfoForContextGroup(t){this.wire.sendAction("interop-client-get-info-for-context-group").catch((e=>{}));const n=await i(this,e,"f");if(!t)throw new Error("No contextGroupId specified for getInfoForContextGroup.");return n.dispatch("getInfoForContextGroup",{contextGroupId:t})}async fireIntent(t){this.wire.sendAction("interop-client-fire-intent").catch((e=>{}));return(await i(this,e,"f")).dispatch("fireIntent",t)}async registerIntentHandler(t,n,r){this.wire.sendAction("interop-client-register-intent-handler").catch((e=>{}));const o=await i(this,e,"f"),s=`intent-handler-${n}`,a=(0,h.wrapIntentHandler)(t,s);try{await o.register(s,a),await o.dispatch("intentHandlerRegistered",{handlerId:s,...r})}catch(e){throw new Error("Unable to register intent handler")}return{unsubscribe:async()=>{o.remove(s)}}}async getCurrentContext(t){this.wire.sendAction("interop-client-get-current-context").catch((e=>{}));return(await i(this,e,"f")).dispatch("getCurrentContext",{contextType:t})}async getInfoForIntent(t){this.wire.sendAction("interop-client-get-info-for-intent").catch((e=>{}));return(await i(this,e,"f")).dispatch("getInfoForIntent",t)}async getInfoForIntentsByContext(t){this.wire.sendAction("interop-client-get-info-for-intents-by-context").catch((e=>{}));return(await i(this,e,"f")).dispatch("getInfoForIntentsByContext",t)}async fireIntentForContext(t){this.wire.sendAction("interop-client-fire-intent-for-context").catch((e=>{}));return(await i(this,e,"f")).dispatch("fireIntentForContext",t)}async joinSessionContextGroup(n){try{const r=i(this,t,"f").get(n);if(r)return r.getUserInstance();const o=await i(this,e,"f"),{hasConflict:a}=await o.dispatch("sessionContextGroup:createIfNeeded",{sessionContextGroupId:n});a&&console.warn(`A (non-session) context group with the name "${n}" already exists. If you are trying to join a Context Group, call joinContextGroup instead.`);const c=new s.default(this.wire,i(this,e,"f"),n);return i(this,t,"f").set(n,c),c.getUserInstance()}catch(e){throw console.error(`Error thrown trying to create Session Context Group with id "${n}": ${e}`),e}}async onDisconnection(t){this.wire.sendAction("interop-client-add-ondisconnection-listener").catch((e=>{}));return(await i(this,e,"f")).onDisconnection((e=>{const{uuid:n}=e;t({type:"interop-broker",topic:"disconnected",brokerName:n})}))}getFDC3Sync(e){switch(e){case"1.2":return new a.Fdc3Module((()=>this),this.wire);case"2.0":return new d.Fdc3Module2((()=>this),this.wire);default:throw new Error(`Invalid FDC3 version provided: ${e}. Must be '1.2' or '2.0'`)}}async getFDC3(e){return this.getFDC3Sync(e)}static async ferryFdc3Call(t,n,r){return(await i(t,e,"f")).dispatch(n,r||null)}};return Di.InteropClient=l,e=new WeakMap,t=new WeakMap,Di}var cr,dr,hr,lr={};function ur(){if(cr)return lr;cr=1,Object.defineProperty(lr,"__esModule",{value:!0}),lr.overrideCheck=lr.checkFDC32Overrides=lr.getDefaultViewFdc3VersionFromAppInfo=void 0;const e=Hi();function t(t){return["fdc3HandleFindInstances","handleInfoForIntent","handleInfoForIntentsByContext","fdc3HandleGetAppMetadata","fdc3HandleGetInfo","fdc3HandleOpen","handleFiredIntent","handleFiredIntentForContext"].filter((n=>t[n]===e.InteropBroker.prototype[n]))}return lr.getDefaultViewFdc3VersionFromAppInfo=function({manifest:e,initialOptions:t}){const n=e?.platform?.defaultViewOptions?.fdc3InteropApi??t.defaultViewOptions?.fdc3InteropApi;return["1.2","2.0"].includes(n??"")?n:void 0},lr.checkFDC32Overrides=t,lr.overrideCheck=function(e,n){if(n&&"2.0"===n){const n=t(e);n.length>0&&console.warn(`WARNING: FDC3 2.0 has been set as a default option for Views in this Platform, but the required InteropBroker APIs for FDC3 2.0 compliance have not all been overridden.\nThe following APIs need to be overridden:\n${n.join("\n")}`)}},lr}function pr(){return hr||(hr=1,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),i=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),i(function(){if(dr)return Fi;dr=1,Object.defineProperty(Fi,"__esModule",{value:!0}),Fi.InteropModule=void 0;const e=n,t=ji,i=c,r=Hi(),o=ar(),s=ur(),a=ri,d=e=>new e,h="You have attempted to use or modify InteropBroker parameters, which is not allowed. You are likely using an older InteropBroker override scheme. Please consult our Interop docs for guidance on migrating to the new override scheme.";class l extends i.Base{async init(n,i=d){this.wire.sendAction("interop-init").catch((()=>{}));const o=await this.wire.environment.getInteropInfo(this.wire.getFin()),c=(0,t.createUnusableObject)(h),l=(0,t.createWarningObject)(h,(0,e.cloneDeep)(o)),u=async()=>{throw new Error(h)},p=r.InteropBroker.createClosedConstructor(this.wire,(()=>this.fin.InterApplicationBus.Channel.create(`interop-broker-${n}`)),o);let w;return w=Array.isArray(i)?new((0,a.overrideFromComposables)(...i)(p))(c,u,l):await i(p,c,u,l),(0,s.overrideCheck)(w,o.fdc3Version),w}connectSync(e,t){return this.wire.sendAction("interop-connect-sync").catch((()=>{})),new o.InteropClient(this.wire,this.wire.environment.whenReady().then((()=>this.fin.InterApplicationBus.Channel.connect(`interop-broker-${e}`,{payload:t}))))}}return Fi.InteropModule=l,Fi}(),e),i(ar(),e),i(Hi(),e)}(Ri)),Ri}var wr={},yr={},fr={},gr={};Object.defineProperty(gr,"__esModule",{value:!0}),gr.getSnapshotSourceChannelName=void 0;gr.getSnapshotSourceChannelName=e=>`snapshot-source-provider-${e.uuid}`;var mr,vr,Cr,br,Ir,Er=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},xr=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(fr,"__esModule",{value:!0}),fr.SnapshotSource=void 0;const Ar=c,Pr=gr,Mr=new Map;class Or extends Ar.Base{constructor(e,t){super(e),mr.set(this,void 0),vr.set(this,(()=>(Mr.has(this.identity.uuid)||Mr.set(this.identity.uuid,{eventFired:null,clientPromise:null}),Mr.get(this.identity.uuid)))),Cr.set(this,(()=>(xr(this,vr,"f").call(this).clientPromise||(xr(this,vr,"f").call(this).clientPromise=xr(this,br,"f").call(this)),xr(this,vr,"f").call(this).clientPromise))),br.set(this,(async()=>{const e=(0,Pr.getSnapshotSourceChannelName)(this.identity);try{xr(this,vr,"f").call(this).eventFired||await xr(this,Ir,"f").call(this);const t=await this.fin.InterApplicationBus.Channel.connect(e,{wait:!1});return t.onDisconnection((()=>{xr(this,vr,"f").call(this).clientPromise=null,xr(this,vr,"f").call(this).eventFired=null})),t}catch(e){throw xr(this,vr,"f").call(this).clientPromise=null,new Error("The targeted SnapshotSource is not currently initialized. Await this object's ready() method.")}})),Ir.set(this,(async()=>{const e=(0,Pr.getSnapshotSourceChannelName)(this.identity);let t,n;const i=new Promise(((e,i)=>{t=e,n=i}));xr(this,vr,"f").call(this).eventFired=i;const r=async i=>{try{i.channelName===e&&(t(),await this.fin.InterApplicationBus.Channel.removeListener("connected",r))}catch(e){n(e)}};await this.fin.InterApplicationBus.Channel.on("connected",r)})),Er(this,mr,t,"f")}get identity(){return xr(this,mr,"f")}async ready(){this.wire.sendAction("snapshot-source-ready").catch((e=>{}));try{await xr(this,Cr,"f").call(this)}catch(e){await xr(this,vr,"f").call(this).eventFired}}async getSnapshot(){this.wire.sendAction("snapshot-source-get-snapshot").catch((e=>{}));const e=await xr(this,Cr,"f").call(this),t=await e.dispatch("get-snapshot");return(await t).snapshot}async applySnapshot(e){this.wire.sendAction("snapshot-source-apply-snapshot").catch((e=>{}));return(await xr(this,Cr,"f").call(this)).dispatch("apply-snapshot",{snapshot:e})}}fr.SnapshotSource=Or,mr=new WeakMap,vr=new WeakMap,Cr=new WeakMap,br=new WeakMap,Ir=new WeakMap,Object.defineProperty(yr,"__esModule",{value:!0}),yr.SnapshotSourceModule=void 0;const _r=c,Sr=fr,Rr=gr;class Fr extends _r.Base{async init(e){if(this.wire.sendAction("snapshot-source-init").catch((e=>{})),"object"!=typeof e||"function"!=typeof e.getSnapshot||"function"!=typeof e.applySnapshot)throw new Error("you must pass in a valid SnapshotProvider");const t=await this.fin.InterApplicationBus.Channel.create((0,Rr.getSnapshotSourceChannelName)(this.fin.me));t.register("get-snapshot",(async()=>({snapshot:await e.getSnapshot()}))),t.register("apply-snapshot",(({snapshot:t})=>e.applySnapshot(t)))}wrapSync(e){return this.wire.sendAction("snapshot-source-wrap-sync").catch((e=>{})),new Sr.SnapshotSource(this.wire,e)}async wrap(e){return this.wire.sendAction("snapshot-source-wrap").catch((e=>{})),this.wrapSync(e)}}yr.SnapshotSourceModule=Fr,function(e){var t=o&&o.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),n=o&&o.__exportStar||function(e,n){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(n,i)||t(n,e,i)};Object.defineProperty(e,"__esModule",{value:!0}),n(yr,e),n(fr,e)}(wr),Object.defineProperty(s,"__esModule",{value:!0});var jr=s.Fin=void 0;const Lr=t,kr=a,Tr=Pe(),$r=Ce(),Br=Fe,Gr=En,Wr=Pn,Hr=Ln,Nr=Dn,Dr=me(),Ur=Kn,Vr=Si,zr=pr(),Kr=wr;class qr extends Lr.EventEmitter{constructor(e){super(),this.wire=e,this.System=new kr.System(e),this.Window=new Tr._WindowModule(e),this.Application=new $r.ApplicationModule(e),this.InterApplicationBus=new Br.InterApplicationBus(e),this.Clipboard=new Gr.Clipboard(e),this.ExternalApplication=new Wr.ExternalApplicationModule(e),this.Frame=new Hr._FrameModule(e),this.GlobalHotkey=new Nr.GlobalHotkey(e),this.Platform=new Ur.PlatformModule(e,this.InterApplicationBus.Channel),this.View=new Dr.ViewModule(e),this.Interop=new zr.InteropModule(e),this.SnapshotSource=new Kr.SnapshotSourceModule(e),e.registerFin(this),this.me=(0,Vr.getMe)(e),e.on("disconnected",(()=>{this.emit("disconnected")}))}}jr=s.Fin=qr;var Yr={},Jr={};function Zr(e){return"string"==typeof e.manifestUrl}function Qr(e){return eo(e)&&"string"==typeof e.address}function Xr(e){return Qr(e)&&"string"==typeof e.token}function eo(e){return"string"==typeof e.uuid}function to(e){return e.runtime&&"string"==typeof e.runtime.version}function no(e){return eo(e)&&to(e)}Object.defineProperty(Jr,"__esModule",{value:!0}),Jr.isInternalConnectConfig=Jr.isPortDiscoveryConfig=Jr.isNewConnectConfig=Jr.isConfigWithReceiver=Jr.isRemoteConfig=Jr.isExistingConnectConfig=Jr.isExternalConfig=void 0,Jr.isExternalConfig=Zr,Jr.isExistingConnectConfig=Qr,Jr.isRemoteConfig=Xr,Jr.isConfigWithReceiver=function(e){return"object"==typeof e.receiver&&Xr({...e,address:""})},Jr.isNewConnectConfig=no,Jr.isPortDiscoveryConfig=function(e){return Zr(e)&&to(e)||no(e)},Jr.isInternalConnectConfig=function(e){return Qr(e)||no(e)};var io={},ro={};Object.defineProperty(ro,"__esModule",{value:!0}),ro.EmitterMap=void 0;const oo=t;function so(e){return Buffer.from(e).toString("base64")}ro.EmitterMap=class{constructor(){this.storage=new Map}hashKeys(e){return e.map(so).join("/")}getOrCreate(e){const t=this.hashKeys(e);return this.storage.has(t)||this.storage.set(t,new oo.EventEmitter),this.storage.get(t)}has(e){return this.storage.has(this.hashKeys(e))}delete(e){const t=this.hashKeys(e);return this.storage.delete(t)}},Object.defineProperty(io,"__esModule",{value:!0});const ao=ro;class co extends ao.EmitterMap{constructor(){super(...arguments),this.dispatchEvent=e=>{if(function(e){return"process-desktop-event"===e.action}(e)){const{payload:t}=e,n=function(e){const{topic:t}=e;if("frame"===t||"window"===t||"view"===t){const{uuid:n,name:i}=e;return[t,n,i]}if("application"===t){const{uuid:n}=e;return[t,n]}return[t]}(t);if(this.has(n))return this.getOrCreate(n).emit(t.type,t),!0}return!1}}}io.default=co;var ho,lo,uo=o&&o.__classPrivateFieldSet||function(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n},po=o&&o.__classPrivateFieldGet||function(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)};Object.defineProperty(Yr,"__esModule",{value:!0});var wo=Yr.Transport=void 0;const yo=t,fo=Jr,go=f,mo=io,vo=Si,Co=it;class bo extends yo.EventEmitter{constructor(e,t,n){super(),this.wireListeners=new Map,this.topicRefMap=new Map,this.eventAggregator=new mo.default,this.messageHandlers=[this.eventAggregator.dispatchEvent],ho.set(this,void 0),lo.set(this,void 0),this.connectSync=()=>{po(this,ho,"f").connectSync()},this.getPort=()=>po(this,ho,"f").getPort(),uo(this,ho,new e(this.onmessage.bind(this)),"f"),this.environment=t,this.sendRaw=po(this,ho,"f").send.bind(po(this,ho,"f")),this.registerMessageHandler(this.handleMessage.bind(this)),po(this,ho,"f").on("disconnected",(()=>{for(const[,{handleNack:e}]of this.wireListeners)e({reason:"Remote connection has closed"});this.wireListeners.clear(),this.emit("disconnected")}));const{uuid:i,name:r}=n,o=this.environment.getCurrentEntityType();this.me=(0,vo.getBaseMe)(o,i,r)}getFin(){if(!po(this,lo,"f"))throw new Error("No Fin object registered for this transport");return po(this,lo,"f")}registerFin(e){if(po(this,lo,"f"))throw new Error("Fin object has already been registered for this transport");uo(this,lo,e,"f")}shutdown(){return po(this,ho,"f").shutdown()}async connect(e){if((0,fo.isConfigWithReceiver)(e))return await po(this,ho,"f").connect(e.receiver),this.authorize(e);if((0,fo.isRemoteConfig)(e))return this.connectRemote(e);if((0,fo.isExistingConnectConfig)(e))return this.connectByPort(e);if((0,fo.isNewConnectConfig)(e)){const t=await this.environment.retrievePort(e);return this.connectByPort({...e,address:`ws://localhost:${t}`})}}async connectRemote(e){return await po(this,ho,"f").connect(new(this.environment.getWsConstructor())(e.address)),this.authorize(e)}async connectByPort(e){const{address:t,uuid:n}=e,i={...e,type:"file-token"},r=po(this,ho,"f");await r.connect(new(this.environment.getWsConstructor())(e.address));const o=await this.sendAction("request-external-authorization",{uuid:n,type:"file-token"},!0);if("external-authorization-response"!==o.action)throw new go.UnexpectedActionError(o.action);return await this.environment.writeToken(o.payload.file,o.payload.token),this.authorize(i)}async authorize(e){const t=await this.sendAction("request-authorization",e,!0);if("authorization-response"!==t.action)throw new go.UnexpectedActionError(t.action);if(!0!==t.payload.success)throw new go.RuntimeError(t.payload)}sendAction(e,t={},n=!1){let i=()=>{};const r=go.RuntimeError.getCallSite(1),o=this.environment.getNextMessageId(),s=new Promise(((s,a)=>{i=a;const c={action:e,payload:t,messageId:o},d=po(this,ho,"f");return this.addWireListener(o,s,(e=>this.nackHandler(e,a,r)),n),d.send(c).catch(a)}));return Object.assign(s,{cancel:i,messageId:o})}nackHandler(e,t,n){t("string"==typeof e?e:new go.RuntimeError(e,n))}ferryAction(e){return new Promise(((t,n)=>{const i=this.environment.getNextMessageId();e.messageId=i;const r=e=>{t(e.payload)};return po(this,ho,"f").send(e).then((()=>this.addWireListener(i,r,(e=>this.nackHandler(e,n)),!1))).catch(n)}))}registerMessageHandler(e){this.messageHandlers.push(e)}addWireListener(e,t,n,i){i?this.uncorrelatedListener=t:this.wireListeners.has(e)?n({reason:"Duplicate handler id",error:(0,Co.errorToPOJO)(new go.DuplicateCorrelationError(String(e)))}):this.wireListeners.set(e,{resolve:t,handleNack:n})}onmessage(e){for(const t of this.messageHandlers)t.call(null,e)}handleMessage(e){const t=e.correlationId||NaN;if("correlationId"in e){if(!this.wireListeners.has(t))return!1;{const{resolve:n,handleNack:i}=this.wireListeners.get(t);"ack"!==e.action?i({reason:"Did not receive ack action",error:(0,Co.errorToPOJO)(new go.NoAckError(e.action))}):"payload"in e?e.payload.success?n.call(null,e):i(e.payload):"string"==typeof e.reason?i(e):(console.warn("Received invalid response from core",e),i({reason:"invalid response shape"})),this.wireListeners.delete(t)}}else this.uncorrelatedListener&&this.uncorrelatedListener.call(null,e),this.uncorrelatedListener=()=>{};return!0}}wo=Yr.Transport=bo,ho=new WeakMap,lo=new WeakMap;const Io=(...e)=>({log:(...t)=>console.log(`[${(new Date).toISOString()}]`,...(e=>e.map((e=>`[${e}]`)))(e),...t),getLogger:(...t)=>Io(...e,...t)}),Eo=Io("[@openfin/core-web/client");function xo(e,t){if(!function(e){return"string"==typeof e}(e))throw new Error(`Property ${t} has invalid type. Expected string, got ${typeof e}.`)}const Ao="web-broker-ports-ready",Po=Eo.getLogger("get-web-interop-ports");function Mo(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function Oo(e,t,n,i,r){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!r)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!r:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?r.call(e,n):r?r.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;const _o=e=>{var n,i,r;return r=class extends t.EventEmitter{constructor(t){super(),n.set(this,void 0),i.set(this,!1),this.connectSync=()=>{Mo(this,i,"f")||(e.addEventListener("message",(e=>{e.data?.topic?.startsWith("wire-message")&&e.data.message&&Mo(this,n,"f").call(this,{...JSON.parse(e.data.message),ports:e.ports})})),e.start())},this.connect=async()=>{this.connectSync()},this.send=t=>(e.postMessage({topic:"wire-message",message:JSON.stringify(t)}),Promise.resolve()),this.shutdown=async()=>{e.close()},Oo(this,n,t,"f")}getPort(){return e}},n=new WeakMap,i=new WeakMap,r};var So={},Ro={};Object.defineProperty(Ro,"__esModule",{value:!0}),Ro.BaseEnvironment=void 0;const Fo=ur();Ro.BaseEnvironment=class{async getInteropInfo(e){const t=await e.Application.getCurrentSync().getInfo().catch((()=>null)),n=t?.initialOptions?.interopBrokerConfiguration??{};return{fdc3Version:t?(0,Fo.getDefaultViewFdc3VersionFromAppInfo)(t):void 0,...n,fdc3Info:{providerVersion:await e.System.getVersion(),provider:"OpenFin"}}}},Object.defineProperty(So,"__esModule",{value:!0});var jo=So.BrowserEnvironment=void 0;const Lo=Ro;class ko extends Lo.BaseEnvironment{constructor(){super(...arguments),this.type="other",this.getRandomId=()=>{const e=new Uint32Array(1);return window.crypto.getRandomValues(e)[0].toString(32)}}getAdapterVersionSync(){return""}observeBounds(e,t){throw new Error("Method not implemented.")}layoutAllowedInContext(e){return!1}initLayoutManager(e,t,n){throw new Error("Method not implemented.")}applyLayoutSnapshot(e,t,n){throw new Error("Method not implemented.")}createLayout(e,t){throw new Error("Method not implemented.")}destroyLayout(e,t){throw new Error("Method not implemented.")}resolveLayout(e,t){throw new Error("Method not implemented.")}initPlatform(...e){throw new Error("Method not implemented.")}writeToken(e,t){return Promise.resolve("")}retrievePort(e){throw new Error("Method not implemented.")}getNextMessageId(){return this.getRandomId()}createChildContent(e){throw new Error("Method not implemented.")}getWebWindow(e){throw new Error("Method not implemented.")}getCurrentEntityIdentity(){throw new Error("Method not implemented.")}getCurrentEntityType(){return"external connection"}raiseEvent(e,t){throw new Error("Method not implemented.")}getUrl(){return location.href}getDefaultChannelOptions(){return{create:{},connect:{}}}getRtcPeer(){return new RTCPeerConnection}getWsConstructor(){return WebSocket}whenReady(){return Promise.resolve()}}jo=So.BrowserEnvironment=ko;const To=e=>"platform"in e&&void 0!==e.platform;var $o,Bo;class Go extends jo{constructor(e){super(),this.connectConfig=e,$o.set(this,void 0),Bo.set(this,new G((async()=>Promise.resolve().then((function(){return require("./main-4aa7d90d.js")}))))),To(e)&&this.validatePlatformOptions(e)}getAdapterVersionSync(){return"0.40.7"}validatePlatformOptions({platform:e}){if(!("layoutSnapshot"in e))throw new Error("Platform options are missing layoutSnapshot. Please provide a layoutSnapshot in the platform options.");if("windows"in e||"windows"in e.layoutSnapshot)throw new Error("It appears you tried to call connect() with a snapshot object from an OpenFin desktop environment. Note that connect() expects to be called with a platform property with this structure: { platform: { layoutSnapshot } }. To get a layoutSnapshot of the expected structure, use fin.Platform.Layout.getCurrentLayoutManagerSync().getLayoutSnapshot() in v34+ in your desktop environment.");const{layouts:t}=e.layoutSnapshot;Object.entries(t).map((([e,t])=>{if("object"!=typeof t||null===t)throw new Error(`Invalid layout detected: layoutSnapshot.layouts.${e} must be an object.`);if(!("content"in t))throw new Error(`Invalid layout detected: layoutSnapshot.layouts.${e} must contain a 'content' property.`)}))}async getInteropInfo(e){return{...{contextGroups:void 0,logging:{beforeAction:{enabled:!1},afterAction:{enabled:!1}}},fdc3Version:void 0,fdc3Info:{providerVersion:"0.40.7",provider:"OpenFin Web"}}}layoutAllowedInContext(e){return!0}async initLayoutManager(e,t,n){if(Mo(this,$o,"f"))throw new Error("Layout already initialized.");if(!To(this.connectConfig))throw new Error("Platform options are missing from connection config.");const{WebLayoutEntryPoint:i}=await Mo(this,Bo,"f").getValue();return Oo(this,$o,new i(this.connectConfig),"f"),await Mo(this,$o,"f").initLayoutManager(e,t,n)}async applyLayoutSnapshot(e,t,n){Mo(this,$o,"f")?.applyLayoutSnapshot(e,t,n)}async createLayout(e,t){return Mo(this,$o,"f")?.createLayout(e,t)}async destroyLayout(e,t){return Mo(this,$o,"f")?.destroyLayout(e,t)}}$o=new WeakMap,Bo=new WeakMap;const Wo=()=>{const e=((e,t)=>{const n=new RegExp(`^${t}<(?<meta>.*)>$`).exec(e)?.groups?.meta;if(n)try{return JSON.parse(atob(n))}catch(e){throw new Error(`Failed to decode JSON from ${n}.`)}})(window.name,"of-frame");if(e)try{const{name:t,uuid:n,brokerUrl:i,providerId:r,contextGroup:o}=e;return xo(i,"brokerUrl"),xo(n,"uuid"),xo(t,"name"),{identity:{name:t,uuid:n},brokerUrl:i,interopConfig:{providerId:r,currentContextGroup:o}}}catch(e){throw new Error(`Unexpected error occurred when inferring platform information: ${e.stack}`)}},Ho=()=>{const e=i.v4();return{uuid:e,name:e}},No=async e=>{if("enabled"===e.connectionInheritance){const t=await(async e=>{const t=Wo();if(t){const{validateOptions:n=(()=>!0)}=e,{identity:i,...r}=t;if(!await n(r))throw new Error("Parent options were rejected by validateOptions.");return t}})(e);if(t)return t}if(!e.options){const t="enabled"===e.connectionInheritance?"Broker URL was not specified nor provided by a platform container.":"Connection inheritance is disabled but no options were provided.";throw new Error(t)}return{...e.options,identity:Ho()}};exports.__classPrivateFieldGet=Mo,exports.__classPrivateFieldSet=Oo,exports.commonjsGlobal=o,exports.connect=async t=>{try{Eo.log("Establishing connection",t);const{brokerUrl:n,identity:i,timeout:o,interopConfig:s}=await No(t),{workerPort:a,iframeBrokerPort:c}=await(async(e,t,n)=>{const{origin:i}=new URL(e),o=document.createElement("IFRAME");let s;o.style.display="none";try{return await new Promise(((a,c)=>{const d=e=>{if(e.source===o.contentWindow&&e.data?.topic===`ack-${Ao}`){if(e.origin!==i)c(new Error(`Broker redirected to unexpected origin ${e.origin}, expected ${i}.`));else if(e.data.success){const[t,n]=e.ports;a({iframeBrokerPort:t,workerPort:n})}else c(new g(e.data));window.removeEventListener("message",d),clearTimeout(s)}};window.addEventListener("message",d),Po.log(`Connecting to broker ${e}`),o.setAttribute("src",e),o.setAttribute("name",r(t,"of-broker")),document.body.appendChild(o),Po.log("Iframe loaded, awaiting init message from iframe"),n&&(s=setTimeout((()=>{window.removeEventListener("message",d),document.body.removeChild(o),c(new Error("Worker did not initialize in time"))}),n))}))}catch(e){throw new Error(`Failed to initialise Fin Web Client. ${e.message}`,{cause:e})}})(n,i,o);Eo.log("Successfully established connection to shared worker");const d={entityType:"external connection",...i};a.start(),c.start();const h=((t,n,i)=>{const r=_o(n),o=new Go(t),s=new wo(r,o,i);return s.connectSync(),window.Buffer=e.Buffer,new jr(s)})(t,a,d);return s?.providerId&&(h.me.interop=h.Interop.connectSync(s.providerId),s?.currentContextGroup&&h.me.interop.joinContextGroup(s.currentContextGroup).catch((e=>{console.warn(`Error joining specified context group: ${s?.currentContextGroup}, continuing`,e)}))),{...h,me:{...h.me,identity:{uuid:h.me.uuid,name:h.me.name}}}}catch(e){throw new Error(`An error occured during web-interop connection: ${e.message}`)}},exports.encodeOptions=r;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@openfin/core-web",
|
3
|
-
"version": "0.40.
|
3
|
+
"version": "0.40.7",
|
4
4
|
"description": "",
|
5
5
|
"private": false,
|
6
6
|
"files": [
|
@@ -54,6 +54,6 @@
|
|
54
54
|
"uuid": "^8.3.2"
|
55
55
|
},
|
56
56
|
"peerDependencies": {
|
57
|
-
"@openfin/core": "40.82.
|
57
|
+
"@openfin/core": "40.82.7"
|
58
58
|
}
|
59
59
|
}
|