import{Runtime as e}from"../../root/root.js";import{ThemeSupport as t}from"../../theme_support/theme_support.js";function n(n,o,c={enableLegacyPatching:!1}){const s=e.cachedResources.get(o)||"";s||console.error(o+" not preloaded. Check module.json");let i=document.createElement("style");if(i.textContent=s,n.appendChild(i),c.enableLegacyPatching){const c=t.instance().themeStyleSheet(o,s);c&&(i=document.createElement("style"),i.textContent=c+"\n"+e.Runtime.resolveSourceURL(o+".theme"),n.appendChild(i))}}function o(e){const t=e.target,n=t?t.ownerDocument:null,o=n?n.deepActiveElement():null;!function(e){for(;e&&!e.__widget;)e=e.parentNodeOrShadowHost();if(!e)return;let t=e.__widget;for(;t._parentWidget;)t._parentWidget._defaultFocusedChild=t,t=t._parentWidget}(o),function(e){e=e&&e.parentNodeOrShadowHost();const t=customElements.get("x-widget");let n=null;for(;e;)e instanceof t&&(n&&(e._defaultFocusedElement=n),n=e),e=e.parentNodeOrShadowHost()}(o)}function c(e){n(e,"ui/inspectorCommon.css",{enableLegacyPatching:!0}),n(e,"ui/textButton.css",{enableLegacyPatching:!0}),t.instance().injectHighlightStyleSheets(e),t.instance().injectCustomStyleSheets(e)}function s(e,t={delegatesFocus:void 0,cssFile:void 0,enableLegacyPatching:!1}){const{cssFile:s,delegatesFocus:i,enableLegacyPatching:l}=t,r=e.attachShadow({mode:"open",delegatesFocus:i});return c(r),s&&n(r,s,{enableLegacyPatching:l}),r.addEventListener("focus",o,!0),r}let i;function l(e){if("number"==typeof i)return i;if(!e)return 16;const t=e.createElement("div"),n=e.createElement("div");return t.setAttribute("style","display: block; width: 100px; height: 100px; overflow: scroll;"),n.setAttribute("style","height: 200px"),t.appendChild(n),e.body.appendChild(t),i=t.offsetWidth-t.clientWidth,e.body.removeChild(t),i}function r(e,t,n){return self.customElements.define(t,class extends n{constructor(){super(),this.setAttribute("is",t)}},{extends:e}),()=>document.createElement(e,{is:t})}export{n as appendStyle,s as createShadowRootWithCoreStyles,o as focusChanged,c as injectCoreStyles,l as measuredScrollbarWidth,r as registerCustomElement};
