import{Runtime as e}from"../../root/root.js";import{ThemeSupport as t}from"../../theme_support/theme_support.js";function n(n,o){const r=e.cachedResources.get(o)||"";r||console.error(o+" not preloaded. Check module.json");let s=createElement("style");s.textContent=r,n.appendChild(s);const i=t.instance().themeStyleSheet(o,r);i&&(s=createElement("style"),s.textContent=i+"\n"+e.Runtime.resolveSourceURL(o+".theme"),n.appendChild(s))}function o(e){const t=e.target&&e.target.ownerDocument,n=t?t.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}(n),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()}(n)}function r(e){n(e,"ui/inspectorCommon.css"),n(e,"ui/textButton.css"),t.instance().injectHighlightStyleSheets(e),t.instance().injectCustomStyleSheets(e)}function s(e,t,s){const i=e.attachShadow({mode:"open",delegatesFocus:s});return r(i),t&&n(i,t),i.addEventListener("focus",o.bind(UI),!0),i}let i;function c(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 d(e,t,n){return self.customElements.define(t,class extends n{constructor(){super(),this.setAttribute("is",t)}},{extends:e}),()=>createElement(e,t)}export{n as appendStyle,s as createShadowRootWithCoreStyles,o as focusChanged,r as injectCoreStyles,c as measuredScrollbarWidth,d as registerCustomElement};
