{
  "version": 3,
  "sources": ["../../../src/rendering-util/rendering-elements/shapes/handDrawnShapeStyles.ts"],
  "sourcesContent": ["import { getConfig } from '../../../diagram-api/diagramAPI.js';\nimport type { Node } from '../../types.js';\n\n// Striped fill like start or fork nodes in state diagrams\nexport const solidStateFill = (color: string) => {\n  const { handDrawnSeed } = getConfig();\n  return {\n    fill: color,\n    hachureAngle: 120, // angle of hachure,\n    hachureGap: 4,\n    fillWeight: 2,\n    roughness: 0.7,\n    stroke: color,\n    seed: handDrawnSeed,\n  };\n};\n\nexport const compileStyles = (node: Node) => {\n  // node.cssCompiledStyles is an array of strings in the form of 'key: value' where key is the css property and value is the value\n  // the array is the styles of node from the classes it is using\n  // node.cssStyles is an array of styles directly set on the node\n  // concat the arrays and remove duplicates such that the values from node.cssStyles are used if there are duplicates\n  const stylesMap = styles2Map([\n    ...(node.cssCompiledStyles || []),\n    ...(node.cssStyles || []),\n    ...(node.labelStyle || []),\n  ]);\n  return { stylesMap, stylesArray: [...stylesMap] };\n};\n\nexport const styles2Map = (styles: string[]) => {\n  const styleMap = new Map<string, string>();\n  styles.forEach((style) => {\n    const [key, value] = style.split(':');\n    styleMap.set(key.trim(), value?.trim());\n  });\n  return styleMap;\n};\nexport const isLabelStyle = (key: string) => {\n  return (\n    key === 'color' ||\n    key === 'font-size' ||\n    key === 'font-family' ||\n    key === 'font-weight' ||\n    key === 'font-style' ||\n    key === 'text-decoration' ||\n    key === 'text-align' ||\n    key === 'text-transform' ||\n    key === 'line-height' ||\n    key === 'letter-spacing' ||\n    key === 'word-spacing' ||\n    key === 'text-shadow' ||\n    key === 'text-overflow' ||\n    key === 'white-space' ||\n    key === 'word-wrap' ||\n    key === 'word-break' ||\n    key === 'overflow-wrap' ||\n    key === 'hyphens'\n  );\n};\nexport const styles2String = (node: Node) => {\n  const { stylesArray } = compileStyles(node);\n  const labelStyles: string[] = [];\n  const nodeStyles: string[] = [];\n  const borderStyles: string[] = [];\n  const backgroundStyles: string[] = [];\n\n  stylesArray.forEach((style) => {\n    const key = style[0];\n    if (isLabelStyle(key)) {\n      labelStyles.push(style.join(':') + ' !important');\n    } else {\n      nodeStyles.push(style.join(':') + ' !important');\n      if (key.includes('stroke')) {\n        borderStyles.push(style.join(':') + ' !important');\n      }\n      if (key === 'fill') {\n        backgroundStyles.push(style.join(':') + ' !important');\n      }\n    }\n  });\n\n  return {\n    labelStyles: labelStyles.join(';'),\n    nodeStyles: nodeStyles.join(';'),\n    stylesArray,\n    borderStyles,\n    backgroundStyles,\n  };\n};\n\n// Striped fill like start or fork nodes in state diagrams\n// TODO remove any\nexport const userNodeOverrides = (node: Node, options: any) => {\n  const { themeVariables, handDrawnSeed } = getConfig();\n  const { nodeBorder, mainBkg } = themeVariables;\n  const { stylesMap } = compileStyles(node);\n\n  // index the style array to a map object\n  const result = Object.assign(\n    {\n      roughness: 0.7,\n      fill: stylesMap.get('fill') || mainBkg,\n      fillStyle: 'hachure', // solid fill\n      fillWeight: 4,\n      hachureGap: 5.2,\n      stroke: stylesMap.get('stroke') || nodeBorder,\n      seed: handDrawnSeed,\n      strokeWidth: stylesMap.get('stroke-width')?.replace('px', '') || 1.3,\n      fillLineDash: [0, 0],\n      strokeLineDash: getStrokeDashArray(stylesMap.get('stroke-dasharray')),\n    },\n    options\n  );\n  return result;\n};\n\nconst getStrokeDashArray = (strokeDasharrayStyle?: string) => {\n  if (!strokeDasharrayStyle) {\n    return [0, 0];\n  }\n  const dashArray = strokeDasharrayStyle.trim().split(/\\s+/).map(Number);\n  if (dashArray.length === 1) {\n    const val = isNaN(dashArray[0]) ? 0 : dashArray[0];\n    return [val, val];\n  }\n  const first = isNaN(dashArray[0]) ? 0 : dashArray[0];\n  const second = isNaN(dashArray[1]) ? 0 : dashArray[1];\n  return [first, second];\n};\n"],
  "mappings": "kFAIO,IAAMA,EAAiBC,EAACC,GAAkB,CAC/C,GAAM,CAAE,cAAAC,CAAc,EAAIC,EAAU,EACpC,MAAO,CACL,KAAMF,EACN,aAAc,IACd,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CAAM,CACvB,EAZ2B",
  "names": ["solidStateFill", "__name", "color", "handDrawnSeed", "getConfig", "compileStyles", "node", "stylesMap", "styles2Map", "styles", "styleMap", "style", "key", "value", "isLabelStyle", "styles2String", "stylesArray", "labelStyles", "nodeStyles", "borderStyles", "backgroundStyles", "userNodeOverrides", "options", "themeVariables", "nodeBorder", "mainBkg", "getStrokeDashArray", "strokeDasharrayStyle", "dashArray", "val", "first", "second"]
}
