{"version":3,"file":"path.mjs","sources":["../../../../../src/render/svg/utils/path.ts"],"sourcesContent":["import { ResolvedValues } from \"../../types\"\n\nconst dashKeys = {\n    offset: \"stroke-dashoffset\",\n    array: \"stroke-dasharray\",\n}\n\nconst camelKeys = {\n    offset: \"strokeDashoffset\",\n    array: \"strokeDasharray\",\n}\n\n/**\n * Build SVG path properties. Uses the path's measured length to convert\n * our custom pathLength, pathSpacing and pathOffset into stroke-dashoffset\n * and stroke-dasharray attributes.\n *\n * This function is mutative to reduce per-frame GC.\n *\n * Note: We use unitless values for stroke-dasharray and stroke-dashoffset\n * because Safari incorrectly scales px values when the page is zoomed.\n */\nexport function buildSVGPath(\n    attrs: ResolvedValues,\n    length: number,\n    spacing = 1,\n    offset = 0,\n    useDashCase: boolean = true\n): void {\n    // Normalise path length by setting SVG attribute pathLength to 1\n    attrs.pathLength = 1\n\n    // We use dash case when setting attributes directly to the DOM node and camel case\n    // when defining props on a React component.\n    const keys = useDashCase ? dashKeys : camelKeys\n\n    // Build the dash offset (unitless to avoid Safari zoom bug)\n    attrs[keys.offset] = `${-offset}`\n\n    // Build the dash array (unitless to avoid Safari zoom bug)\n    attrs[keys.array] = `${length} ${spacing}`\n}\n"],"names":[],"mappings":"AAEA,MAAM,QAAQ,GAAG;AACb,IAAA,MAAM,EAAE,mBAAmB;AAC3B,IAAA,KAAK,EAAE,kBAAkB;CAC5B;AAED,MAAM,SAAS,GAAG;AACd,IAAA,MAAM,EAAE,kBAAkB;AAC1B,IAAA,KAAK,EAAE,iBAAiB;CAC3B;AAED;;;;;;;;;AASG;SACa,YAAY,CACxB,KAAqB,EACrB,MAAc,EACd,OAAO,GAAG,CAAC,EACX,MAAM,GAAG,CAAC,EACV,cAAuB,IAAI,EAAA;;AAG3B,IAAA,KAAK,CAAC,UAAU,GAAG,CAAC;;;IAIpB,MAAM,IAAI,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS;;IAG/C,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAA,EAAG,CAAC,MAAM,CAAA,CAAE;;IAGjC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,OAAO,CAAA,CAAE;AAC9C;;;;"}