import{Runtime as e}from"../../root/root.js";import{ThemeSupport as t}from"../../theme_support/theme_support.js";function n(n,o,i={enableLegacyPatching:!1}){const r=e.cachedResources.get(o)||"";r||console.error(o+" not preloaded. Check module.json");let c=createElement("style");if(c.textContent=r,n.appendChild(c),i.enableLegacyPatching){const i=t.instance().themeStyleSheet(o,r);i&&(c=createElement("style"),c.textContent=i+"\n"+e.Runtime.resolveSourceURL(o+".theme"),n.appendChild(c))}}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 i(e){n(e,"ui/inspectorCommon.css",{enableLegacyPatching:!0}),n(e,"ui/textButton.css",{enableLegacyPatching:!0}),t.instance().injectHighlightStyleSheets(e),t.instance().injectCustomStyleSheets(e)}function r(e,t,r){const c=e.attachShadow({mode:"open",delegatesFocus:r});return i(c),t&&n(c,t,{enableLegacyPatching:!0}),c.addEventListener("focus",o.bind(UI),!0),c}let c;function s(e){if("number"==typeof c)return c;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),c=t.offsetWidth-t.clientWidth,e.body.removeChild(t),c}function l(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,r as createShadowRootWithCoreStyles,o as focusChanged,i as injectCoreStyles,s as measuredScrollbarWidth,l as registerCustomElement};
