import{j as i}from"./cm-1.0.63-CSIRHMXC.js";import{l as p,bi as c,bj as g,bw as S,bx as w,by as x}from"./lib-1.0.63-DJZPtMem.js";import{r as a}from"./redux-1.0.63-Df-eBzJn.js";import{A,u as C}from"./AppTheme-1.0.63-CLc-SnB5.js";import{u as h}from"./useTableSettings-1.0.63-DOq9cogk.js";import{u as j}from"./useStoreFormSettings-1.0.63-CruqV90e.js";import{u as F}from"./useMetadata-1.0.63-SO3BYgAj.js";import{u as y}from"./useGlobalCode-1.0.63-DqDx9M25.js";import{u as M}from"./useAppFunctions-1.0.63-DX15IlIH.js";import{T as v}from"./ThemeProvider-1.0.63-Cq0KMgkh.js";import"./vendor-1.0.63-CN03Eozo.js";import"./loglevel-1.0.63-BZ7XahX3.js";import"./lodash-1.0.63-hMxolcpJ.js";import"./moment-1.0.63-C5S46NFB.js";import"./index-1.0.63-BT4mpIxR.js";import"./Typography-1.0.63-mecuj_Wl.js";import"./getThemeProps-1.0.63-5ZzcWe3G.js";import"./useEnhancedEffect-1.0.63-DnR0ZFqV.js";import"./hooks-1.0.63-CWs3kTdT.js";const X=({appId:o,children:d})=>{p.debug(o);const b=h(o),E=j(),T=C(),t=F(o);let n;(t==null?void 0:t.appRootId)===void 0&&(n=A(T,b,E));const r=y(),u=`pp-global-code-${o}`,{app:l}=M(o);return a.useEffect(()=>{var e,s;p.debug("open app",(e=r.onAppOpen)==null?void 0:e.code),c(((s=r.onAppOpen)==null?void 0:s.code)??"",g(t),!1,{app:l,loadScript:x,loadStyle:w})},[]),a.useEffect(()=>()=>{var e;p.debug("close app"),c(((e=r.onAppClose)==null?void 0:e.code)??"",g(t),!1,{app:l})},[]),a.useEffect(()=>{var e,s,f;if(r!==void 0&&S(t)){(e=window.document.getElementById(u))==null||e.remove();const m=window.document.createElement("script");m.id=u,m.innerHTML=((s=r.global)==null?void 0:s.code)??"",(f=window.document.getElementById(`pp-app-${o}`))==null||f.appendChild(m)}},[r]),n!==void 0?i.jsx(v,{theme:n,children:d}):i.jsx(i.Fragment,{children:d})};export{X as default};
