import{Runtime as e}from"../root/root.js";const s=new Map;function t(){return document.documentElement.classList.contains("-theme-with-dark-background")||window.matchMedia("prefers-color-scheme: dark").matches}async function o(){self.Runtime&&console.error("poulateRuntimeCacheForTests found existing Runtime, refusing to overwrite it."),self.Runtime={cachedResources:{}};const e=c.map(e=>fetch("/"+e).then(e=>e.text()).then(s=>{self.Runtime.cachedResources[e]=s}));return Promise.all(e)}const c=["ui/checkboxTextLabel.css","ui/closeButton.css","ui/confirmDialog.css","ui/dialog.css","ui/dropTarget.css","ui/emptyWidget.css","ui/filter.css","ui/glassPane.css","ui/infobar.css","ui/inlineButton.css","ui/inspectorCommon.css","ui/inspectorStyle.css","ui/inspectorSyntaxHighlight.css","ui/inspectorSyntaxHighlightDark.css","ui/inspectorViewTabbedPane.css","ui/listWidget.css","ui/popover.css","ui/progressIndicator.css","ui/radioButton.css","ui/remoteDebuggingTerminatedScreen.css","ui/reportView.css","ui/rootView.css","ui/searchableView.css","ui/slider.css","ui/smallBubble.css","ui/segmentedButton.css","ui/softContextMenu.css","ui/softDropDown.css","ui/softDropDownButton.css","ui/splitWidget.css","ui/toolbar.css","ui/suggestBox.css","ui/tabbedPane.css","ui/targetCrashedScreen.css","ui/textButton.css","ui/textPrompt.css","ui/tooltip.css","ui/treeoutline.css","ui/viewContainers.css","elements/layoutPane.css","components/imagePreview.css","components/jsUtils.css","persistence/editFileSystemView.css","persistence/workspaceSettingsTab.css","console_counters/errorWarningCounter.css","mobile_throttling/throttlingSettingsTab.css","emulation/deviceModeToolbar.css","emulation/deviceModeView.css","emulation/devicesSettingsTab.css","emulation/inspectedPagePlaceholder.css","emulation/locationsSettingsTab.css","emulation/mediaQueryInspector.css","emulation/sensors.css","inspector_main/nodeIcon.css","inspector_main/renderingOptions.css","data_grid/dataGrid.css","help/releaseNote.css","object_ui/customPreviewComponent.css","object_ui/objectPopover.css","object_ui/objectPropertiesSection.css","object_ui/objectValue.css","console/consoleContextSelector.css","console/consolePinPane.css","console/consolePrompt.css","console/consoleSidebar.css","console/consoleView.css","cm/codemirror.css","text_editor/autocompleteTooltip.css","text_editor/cmdevtools.css"];var i=Object.freeze({__proto__:null,getStyleSheets:function(t,{patchThemeSupport:o=!1}={}){const c=s.get(t);if(c&&c.patchThemeSupport===o)return c.sheets;if(!self.Runtime)return[];const i=self.Runtime.cachedResources[t]||"";if(!i)throw new Error(t+" not preloaded.");const n=new CSSStyleSheet;n.replaceSync(i);const r=self.UI&&self.UI.themeSupport.themeStyleSheet(t,i);if(!o||!r)return s.set(t,{patchThemeSupport:o,sheets:[n]}),[n];const u=new CSSStyleSheet;return u.replaceSync(r+"\n"+e.Runtime.resolveSourceURL(t+".theme")),s.set(t,{patchThemeSupport:o,sheets:[n,u]}),[n,u]},DARK_MODE_CLASS:".component-in-dark-mode",isInDarkMode:t,applyDarkModeClassIfNeeded:function(){return t()?".component-in-dark-mode".slice(1):""},populateRuntimeCacheForTests:o,CSS_RESOURCES_TO_LOAD_INTO_RUNTIME:c});var n=Object.freeze({__proto__:null,setup:async function(){return o()}});export{n as ComponentServerSetup,i as GetStylesheet};
