import{i as n}from"../ssr-C2pjZzfv.js";import"../observable-tloG64m6.js";import"../i18n-B98kiI7M.js";import"../empty_html-CjXB8rB4.js";import"@kdcloudjs/kwc";let e=1;const t={},s=[],i={isMessageEventHandled:!1};function r(){s.splice(0,s.length)}function o(){return s.map(n=>n.domain)}function a(n){if(!n||""===n)return;const e=s.find(e=>e.domain===n);e?e.ref+=1:s.push({domain:n,ref:1})}function d(n){if(!n||""===n)return;const e=s.findIndex(e=>e.domain===n);if(e>=0){const n=s[e];n.ref-=1,0===n.ref&&s.splice(e,1)}}function c(){i.isMessageEventHandled=!0}function f(s){const r="kingdeeIframeMessage-"+e++;return t[r]=s,n&&!i.isMessageEventHandled&&(i.isMessageEventHandled=!0,window.addEventListener("message",n=>{m(n)})),r}function u(n){delete t[n]}function m(n){try{const e=n.data?JSON.parse(n.data):{},s=e.arguments?e.arguments.cmpId:null;s&&t[s]&&t[s](e)}catch(n){}}function l(n,e,t){return t.cmpId=n,{event:e,arguments:t}}function p(n,e,t,s){n&&n(s?e:JSON.stringify(e||{}),t)}export{r as clearDomains,l as createMessage,m as dispatchEvent,o as getDomains,p as postMessage,a as registerDomain,f as registerMessageHandler,c as setMessageEventHandled,d as unregisterDomain,u as unregisterMessageHandler};
