import*as CssOverviewModule from"../css_overview/css_overview.js";import*as SDK from"../sdk/sdk.js";export const FontPropertiesRegex=/^[^- ][a-zA-Z-]+|-?\+?(?:[0-9]+\.[0-9]+|\.[0-9]+|[0-9]+)[a-zA-Z%]{0,4}/;export const FontFamilyRegex=/(?:"[\w \,-]+",? ?|'[\w \,-]+',? ?|[\w \,-]+,? ?)+/;const fontSizeRegex=/(^[\+\d\.]+)([a-zA-Z%]+)/,lineHeightRegex=/(^[\+\d\.]+)([a-zA-Z%]*)/,fontWeightRegex=/(^[\+\d\.]+)/,letterSpacingRegex=/([\+-0-9\.]+)([a-zA-Z%]+)/,fontSizeUnits=new Set(["px","em","rem","%","vh","vw"]),lineHeightUnits=new Set(["","px","em","%"]),letterSpacingUnits=new Set(["em","rem","px"]),fontSizeKeyValuesArray=["","xx-small","x-small","smaller","small","medium","large","larger","x-large","xx-large"],lineHeightKeyValuesArray=["","normal"],fontWeightKeyValuesArray=["","lighter","normal","bold","bolder"],letterSpacingKeyValuesArray=["","normal"];export const GlobalValues=["inherit","initial","unset"];fontSizeKeyValuesArray.push(...GlobalValues),lineHeightKeyValuesArray.push(...GlobalValues),fontWeightKeyValuesArray.push(...GlobalValues),letterSpacingKeyValuesArray.push(...GlobalValues);const fontSizeKeyValues=new Set(fontSizeKeyValuesArray),lineHeightKeyValues=new Set(lineHeightKeyValuesArray),fontWeightKeyValues=new Set(fontWeightKeyValuesArray),letterSpacingKeyValues=new Set(letterSpacingKeyValuesArray),fontSizeRangeMap=new Map([["px",{min:0,max:72,step:1}],["em",{min:0,max:4.5,step:.1}],["rem",{min:0,max:4.5,step:.1}],["%",{min:0,max:450,step:1}],["vh",{min:0,max:10,step:.1}],["vw",{min:0,max:10,step:.1}],["vmin",{min:0,max:10,step:.1}],["vmax",{min:0,max:10,step:.1}],["cm",{min:0,max:2,step:.1}],["mm",{min:0,max:20,step:.1}],["in",{min:0,max:1,step:.01}],["pt",{min:0,max:54,step:1}],["pc",{min:0,max:4.5,step:.1}]]),lineHeightRangeMap=new Map([["",{min:0,max:2,step:.1}],["em",{min:0,max:2,step:.1}],["%",{min:0,max:200,step:1}],["px",{min:0,max:32,step:1}],["rem",{min:0,max:2,step:.1}],["vh",{min:0,max:4.5,step:.1}],["vw",{min:0,max:4.5,step:.1}],["vmin",{min:0,max:4.5,step:.1}],["vmax",{min:0,max:4.5,step:.1}],["cm",{min:0,max:1,step:.1}],["mm",{min:0,max:8.5,step:.1}],["in",{min:0,max:.5,step:.1}],["pt",{min:0,max:24,step:1}],["pc",{min:0,max:2,step:.1}]]),fontWeightRangeMap=new Map([["",{min:100,max:700,step:100}]]),letterSpacingRangeMap=new Map([["px",{min:-10,max:10,step:.01}],["em",{min:-.625,max:.625,step:.001}],["rem",{min:-.625,max:.625,step:.001}],["%",{min:-62.5,max:62.5,step:.1}],["vh",{min:-1.5,max:1.5,step:.01}],["vw",{min:-1.5,max:1.5,step:.01}],["vmin",{min:-1.5,max:1.5,step:.01}],["vmax",{min:-1.5,max:1.5,step:.01}],["cm",{min:-.25,max:.025,step:.001}],["mm",{min:-2.5,max:2.5,step:.01}],["in",{min:-.1,max:.1,step:.001}],["pt",{min:-7.5,max:7.5,step:.01}],["pc",{min:-.625,max:.625,step:.001}]]);export const FontSizeStaticParams={regex:fontSizeRegex,units:fontSizeUnits,keyValues:fontSizeKeyValues,rangeMap:fontSizeRangeMap,defaultUnit:"px"};export const LineHeightStaticParams={regex:lineHeightRegex,units:lineHeightUnits,keyValues:lineHeightKeyValues,rangeMap:lineHeightRangeMap,defaultUnit:""};export const FontWeightStaticParams={regex:fontWeightRegex,units:null,keyValues:fontWeightKeyValues,rangeMap:fontWeightRangeMap,defaultUnit:null};export const LetterSpacingStaticParams={regex:letterSpacingRegex,units:letterSpacingUnits,keyValues:letterSpacingKeyValues,rangeMap:letterSpacingRangeMap,defaultUnit:"em"};export const SystemFonts=["Arial","Bookman","Candara","Comic Sans MS","Courier New","Garamond","Georgia","Helvetica","Impact","Palatino","Roboto","Times New Roman","Verdana"];export const GenericFonts=["serif","sans-serif","monspace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","emoji","math","fangsong"];export async function generateComputedFontArray(){const e=SDK.SDKModel.TargetManager.instance().models(CssOverviewModule.CSSOverviewModel.CSSOverviewModel);if(e){const t=e[0];if(t){const{fontInfo:e}=await t.getNodeStyleStats();return Array.from(e.keys())}}return[]}export function getRoundingPrecision(e){switch(e){case 1:return 0;case.1:return 1;case.01:return 2;case.001:return 3;default:return 0}}