import*as i18n from"../i18n/i18n.js";import*as Root from"../root/root.js";import{TimelineCategory,TimelineRecordStyle}from"./TimelineUIUtils.js";const UIStrings={frameStart:"Frame Start",drawFrame:"Draw Frame",layout:"Layout",rasterizing:"Rasterizing",drawing:"Drawing",painting:"Painting",system:"System",idle:"Idle"},str_=i18n.i18n.registerUIStrings("timeline/UIDevtoolsUtils.js",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);let _eventStylesMap=null,_categories=null;export class UIDevtoolsUtils{static isUiDevTools(){return"true"===Root.Runtime.Runtime.queryParam("uiDevTools")}static categorizeEvents(){if(_eventStylesMap)return _eventStylesMap;const e=RecordType,i=UIDevtoolsUtils.categories(),n=i.drawing,r=i.rasterizing,t=i.layout,a=i.painting,s=i.other,o={};return o[e.ViewPaint]=new TimelineRecordStyle("View::Paint",a),o[e.ViewOnPaint]=new TimelineRecordStyle("View::OnPaint",a),o[e.ViewPaintChildren]=new TimelineRecordStyle("View::PaintChildren",a),o[e.ViewOnPaintBackground]=new TimelineRecordStyle("View::OnPaintBackground",a),o[e.ViewOnPaintBorder]=new TimelineRecordStyle("View::OnPaintBorder",a),o[e.LayerPaintContentsToDisplayList]=new TimelineRecordStyle("Layer::PaintContentsToDisplayList",a),o[e.ViewLayout]=new TimelineRecordStyle("View::Layout",t),o[e.ViewLayoutBoundsChanged]=new TimelineRecordStyle("View::Layout(bounds_changed)",t),o[e.RasterTask]=new TimelineRecordStyle("RasterTask",r),o[e.RasterizerTaskImplRunOnWorkerThread]=new TimelineRecordStyle("RasterizerTaskImpl::RunOnWorkerThread",r),o[e.DirectRendererDrawFrame]=new TimelineRecordStyle("DirectRenderer::DrawFrame",n),o[e.BeginFrame]=new TimelineRecordStyle(i18nString(UIStrings.frameStart),n,!0),o[e.DrawFrame]=new TimelineRecordStyle(i18nString(UIStrings.drawFrame),n,!0),o[e.NeedsBeginFrameChanged]=new TimelineRecordStyle("NeedsBeginFrameChanged",n,!0),o[e.ThreadControllerImplRunTask]=new TimelineRecordStyle("ThreadControllerImpl::RunTask",s),_eventStylesMap=o,o}static categories(){return _categories||(_categories={layout:new TimelineCategory("layout",i18nString(UIStrings.layout),!0,"hsl(214, 67%, 74%)","hsl(214, 67%, 66%)"),rasterizing:new TimelineCategory("rasterizing",i18nString(UIStrings.rasterizing),!0,"hsl(43, 83%, 72%)","hsl(43, 83%, 64%) "),drawing:new TimelineCategory("drawing",i18nString(UIStrings.drawing),!0,"hsl(256, 67%, 76%)","hsl(256, 67%, 70%)"),painting:new TimelineCategory("painting",i18nString(UIStrings.painting),!0,"hsl(109, 33%, 64%)","hsl(109, 33%, 55%)"),other:new TimelineCategory("other",i18nString(UIStrings.system),!1,"hsl(0, 0%, 87%)","hsl(0, 0%, 79%)"),idle:new TimelineCategory("idle",i18nString(UIStrings.idle),!1,"hsl(0, 0%, 98%)","hsl(0, 0%, 98%)")},_categories)}static getMainCategoriesList(){return["idle","drawing","painting","rasterizing","layout","other"]}}export const RecordType={ViewPaint:"View::Paint",ViewOnPaint:"View::OnPaint",ViewPaintChildren:"View::PaintChildren",ViewOnPaintBackground:"View::OnPaintBackground",ViewOnPaintBorder:"View::OnPaintBorder",ViewLayout:"View::Layout",ViewLayoutBoundsChanged:"View::Layout(bounds_changed)",LayerPaintContentsToDisplayList:"Layer::PaintContentsToDisplayList",DirectRendererDrawFrame:"DirectRenderer::DrawFrame",RasterTask:"RasterTask",RasterizerTaskImplRunOnWorkerThread:"RasterizerTaskImpl::RunOnWorkerThread",BeginFrame:"BeginFrame",DrawFrame:"DrawFrame",NeedsBeginFrameChanged:"NeedsBeginFrameChanged",ThreadControllerImplRunTask:"ThreadControllerImpl::RunTask"};