{"version":3,"file":"animatedLogo.mjs","names":[],"sources":["../../../../package/common/animatedLogo/animatedLogo.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react';\nimport type { CSSProperties, ReactElement } from 'react';\nimport cx from 'classnames';\n\nimport type { AnimatedLogoProps } from './animatedLogo.types';\nimport styles from './animatedLogo.module.pcss';\nimport { cssColor, useToneCheck } from '../styles/tone';\n\nconst DEFAULT_PATH =\n  'M 1.292 0.278 C -0.41 4.855 3.185 6.433 0.344 8.916 Q 3.923 10.712 5.361 14.001 Q 6.128 14.398 6.876 14.003 Q 8.439 10.632 11.86 8.912 C 8.893 6.387 12.578 5.159 10.86 0.255 Q 8.655 1.166 7.391 3.377 Q 6.092 2.93 4.843 3.38 Q 3.246 0.883 1.292 0.278 Z M 1.663 1.28 Q 2.413 1.635 3.195 2.718 Q 2.083 2.778 1.595 3.884 Q 1.309 2.7 1.663 1.28 M 3.802 7.908 Q 4.426 8.069 3.284 9.003 Q 3.824 9.32 4.557 10.141 Q 4.812 10.869 4.849 11.671 Q 4.371 10.09 2.642 9.144 Q 2.438 9.033 2.609 8.922 Q 3.229 8.537 3.802 7.908 M 8.469 7.927 Q 8.955 8.469 9.646 8.926 Q 9.791 9.032 9.647 9.136 Q 7.821 10.157 7.389 11.702 Q 7.464 10.869 7.709 10.119 Q 8.219 9.53 8.956 9.025 Q 7.81 7.927 8.469 7.927';\n\nconst DEFAULT_VIEW_BOX = '0.244 0.155 11.72 14.25';\n\nfunction AnimatedLogo(props: AnimatedLogoProps): ReactElement {\n  const {\n    path = DEFAULT_PATH,\n    viewBox = DEFAULT_VIEW_BOX,\n    size = 96,\n    color,\n    duration = 4.2,\n    loop = true,\n    fill = true,\n    spin = false,\n    scale = false,\n    className,\n    style,\n    classNames,\n    styles: slotStyles,\n    ...rest\n  } = props;\n  useToneCheck('AnimatedLogo', [color]);\n\n  const pathRef = useRef<SVGPathElement>(null);\n  const [ready, setReady] = useState(false);\n\n  useEffect(() => {\n    const pathEl = pathRef.current;\n    if (!pathEl) return;\n\n    setReady(false);\n    const length = pathEl.getTotalLength();\n    pathEl.style.setProperty('--animated-logo-length', String(length));\n    pathEl.style.strokeDasharray = String(length);\n    pathEl.style.strokeDashoffset = String(length);\n\n    const frame = requestAnimationFrame(() => setReady(true));\n    return () => cancelAnimationFrame(frame);\n  }, [path]);\n\n  const pathStyle: CSSProperties = {\n    animationDuration: `${duration}s`,\n    ...(color ? { stroke: cssColor(color), fill: cssColor(color) } : undefined),\n    ...slotStyles?.path,\n  };\n\n  return (\n    <svg\n      {...rest}\n      className={cx(styles.animatedLogo, className)}\n      style={{ width: size, height: size, ...style }}\n      viewBox={viewBox}\n      xmlns='http://www.w3.org/2000/svg'\n    >\n      <g\n        className={cx(ready && scale && (loop ? styles.animatedLogoScaleLoop : styles.animatedLogoScaleOnce))}\n        style={{ animationDuration: `${duration}s` }}\n      >\n        <g\n          className={cx(ready && spin && (loop ? styles.animatedLogoSpinLoop : styles.animatedLogoSpinOnce))}\n          style={{ animationDuration: `${duration}s` }}\n        >\n          <path\n            ref={pathRef}\n            className={cx(\n              styles.animatedLogoPath,\n              ready &&\n                (loop\n                  ? fill\n                    ? styles.animatedLogoPathLoop\n                    : styles.animatedLogoPathLoopNoFill\n                  : fill\n                    ? styles.animatedLogoPathOnce\n                    : styles.animatedLogoPathOnceNoFill),\n              classNames?.path,\n            )}\n            style={pathStyle}\n            strokeWidth={0.1}\n            strokeLinejoin='round'\n            strokeLinecap='round'\n            d={path}\n          />\n        </g>\n      </g>\n    </svg>\n  );\n}\n\nexport default AnimatedLogo;\n"],"mappings":"oPAQA,IAAM,EACJ,8qBAEI,EAAmB,0BAEzB,SAAS,EAAa,EAAwC,CAC5D,GAAM,CACJ,OAAO,EACP,UAAU,EACV,OAAO,GACP,QACA,WAAW,IACX,OAAO,GACP,OAAO,GACP,OAAO,GACP,QAAQ,GACR,YACA,QACA,aACA,OAAQ,EACR,GAAG,GACD,EACJ,EAAa,eAAgB,CAAC,CAAK,CAAC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