{ "version": 3, "sources": ["../../../../../src/lib/shapes/geo/components/DashStyleCloud.tsx"], "sourcesContent": ["import {\n\tTLDefaultColorTheme,\n\tTLGeoShape,\n\tTLShapeId,\n\tVec2d,\n\tcanonicalizeRotation,\n} from '@tldraw/editor'\nimport * as React from 'react'\nimport {\n\tShapeFill,\n\tgetShapeFillSvg,\n\tgetSvgWithShapeFill,\n\tuseDefaultColorTheme,\n} from '../../shared/ShapeFill'\nimport { getPerfectDashProps } from '../../shared/getPerfectDashProps'\nimport { cloudSvgPath, getCloudArcs } from '../cloudOutline'\n\nexport const DashStyleCloud = React.memo(function DashStylePolygon({\n\tdash,\n\tfill,\n\tcolor,\n\tstrokeWidth,\n\tw,\n\th,\n\tid,\n\tsize,\n}: Pick & {\n\tstrokeWidth: number\n\tid: TLShapeId\n}) {\n\tconst theme = useDefaultColorTheme()\n\tconst innerPath = cloudSvgPath(w, h, id, size)\n\tconst arcs = getCloudArcs(w, h, id, size)\n\n\treturn (\n\t\t<>\n\t\t\t\n\t\t\t\n\t\t\t\t{arcs.map(({ leftPoint, rightPoint, center, radius }, i) => {\n\t\t\t\t\tconst arcLength = center\n\t\t\t\t\t\t? radius *\n\t\t\t\t\t\t canonicalizeRotation(\n\t\t\t\t\t\t\t\tcanonicalizeRotation(Vec2d.Angle(center, rightPoint)) -\n\t\t\t\t\t\t\t\t\tcanonicalizeRotation(Vec2d.Angle(center, leftPoint))\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: Vec2d.Dist(leftPoint, rightPoint)\n\n\t\t\t\t\tconst { strokeDasharray, strokeDashoffset } = getPerfectDashProps(\n\t\t\t\t\t\tarcLength,\n\t\t\t\t\t\tstrokeWidth,\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tstyle: dash,\n\t\t\t\t\t\t\tstart: 'outset',\n\t\t\t\t\t\t\tend: 'outset',\n\t\t\t\t\t\t}\n\t\t\t\t\t)\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t\n\t\t\t\t\t)\n\t\t\t\t})}\n\t\t\t\n\t\t\n\t)\n})\n\nexport function DashStyleCloudSvg({\n\tdash,\n\tfill,\n\tcolor,\n\ttheme,\n\tstrokeWidth,\n\tw,\n\th,\n\tid,\n\tsize,\n}: Pick & {\n\tid: TLShapeId\n\tstrokeWidth: number\n\ttheme: TLDefaultColorTheme\n}) {\n\tconst innerPath = cloudSvgPath(w, h, id, size)\n\tconst arcs = getCloudArcs(w, h, id, size)\n\n\tconst strokeElement = document.createElementNS('http://www.w3.org/2000/svg', 'g')\n\tstrokeElement.setAttribute('stroke-width', strokeWidth.toString())\n\tstrokeElement.setAttribute('stroke', theme[color].solid)\n\tstrokeElement.setAttribute('fill', 'none')\n\n\tfor (const { leftPoint, rightPoint, center, radius } of arcs) {\n\t\tconst arcLength = center\n\t\t\t? radius *\n\t\t\t canonicalizeRotation(\n\t\t\t\t\tcanonicalizeRotation(Vec2d.Angle(center, rightPoint)) -\n\t\t\t\t\t\tcanonicalizeRotation(Vec2d.Angle(center, leftPoint))\n\t\t\t )\n\t\t\t: Vec2d.Dist(leftPoint, rightPoint)\n\n\t\tconst { strokeDasharray, strokeDashoffset } = getPerfectDashProps(arcLength, strokeWidth, {\n\t\t\tstyle: dash,\n\t\t\tstart: 'outset',\n\t\t\tend: 'outset',\n\t\t})\n\n\t\tconst path = document.createElementNS('http://www.w3.org/2000/svg', 'path')\n\t\tpath.setAttribute(\n\t\t\t'd',\n\t\t\tcenter\n\t\t\t\t? `M${leftPoint.x},${leftPoint.y}A${radius},${radius},0,0,1,${rightPoint.x},${rightPoint.y}`\n\t\t\t\t: `M${leftPoint.x},${leftPoint.y}L${rightPoint.x},${rightPoint.y}`\n\t\t)\n\t\tpath.setAttribute('stroke-dasharray', strokeDasharray.toString())\n\t\tpath.setAttribute('stroke-dashoffset', strokeDashoffset.toString())\n\t\tstrokeElement.appendChild(path)\n\t}\n\n\t// Get the fill element, if any\n\tconst fillElement = getShapeFillSvg({\n\t\td: innerPath,\n\t\tfill,\n\t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