import { TRANSITION_STYLE } from "../constants";
import type { OrganSvgProps } from "../types";

export function Muscle({ style, colorScale, isActive = false, className }: OrganSvgProps) {
  const defaultColor = colorScale[100];
  const activeColor = colorScale[300];
  const color = style?.fill ?? (isActive ? activeColor : defaultColor);

  return (
    <g className={className} data-organ="muscle">
      {/* Invisible outline for interaction */}
      <path d={OUTLINE_ARM_PATH} fill="transparent" />
      <path d={OUTLINE_LEG_PATH} fill="transparent" />
      {/* Muscle */}
      <path
        d={MUSCLE_A_PATH}
        fill="url(#paint0_radial_898_163643)"
        stroke={style?.stroke}
        strokeWidth={style?.strokeWidth}
        style={{ transition: TRANSITION_STYLE }}
      />
      <path
        d={MUSCLE_B_PATH}
        fill="url(#paint1_radial_898_163643)"
        stroke={style?.stroke}
        strokeWidth={style?.strokeWidth}
        style={{ transition: TRANSITION_STYLE }}
      />
      <path
        d={MUSCLE_C_PATH}
        fill="url(#paint2_radial_898_163643)"
        stroke={style?.stroke}
        strokeWidth={style?.strokeWidth}
        style={{ transition: TRANSITION_STYLE }}
      />
      <path
        d={MUSCLE_D_PATH}
        fill="url(#paint3_radial_898_163643)"
        stroke={style?.stroke}
        strokeWidth={style?.strokeWidth}
        style={{ transition: TRANSITION_STYLE }}
      />
      <path
        d={MUSCLE_E_PATH}
        fill="url(#paint4_radial_898_163643)"
        stroke={style?.stroke}
        strokeWidth={style?.strokeWidth}
        style={{ transition: TRANSITION_STYLE }}
      />
      <path
        d={MUSCLE_F_PATH}
        fill="url(#paint5_radial_898_163643)"
        stroke={style?.stroke}
        strokeWidth={style?.strokeWidth}
        style={{ transition: TRANSITION_STYLE }}
      />
      <path
        d={MUSCLE_G_PATH}
        fill="url(#paint6_radial_898_163643)"
        stroke={style?.stroke}
        strokeWidth={style?.strokeWidth}
        style={{ transition: TRANSITION_STYLE }}
      />
      <path
        d={MUSCLE_H_PATH}
        fill="url(#paint7_radial_898_163643)"
        stroke={style?.stroke}
        strokeWidth={style?.strokeWidth}
        style={{ transition: TRANSITION_STYLE }}
      />
      <path
        d={MUSCLE_I_PATH}
        fill="url(#paint8_radial_898_163643)"
        stroke={style?.stroke}
        strokeWidth={style?.strokeWidth}
        style={{ transition: TRANSITION_STYLE }}
      />
      <path
        d={MUSCLE_J_PATH}
        fill="url(#paint9_radial_898_163643)"
        stroke={style?.stroke}
        strokeWidth={style?.strokeWidth}
        style={{ transition: TRANSITION_STYLE }}
      />

      <defs>
        <radialGradient
          id="paint0_radial_898_163643"
          cx="0"
          cy="0"
          r="1"
          gradientUnits="userSpaceOnUse"
          gradientTransform="translate(71.1984 148.714) rotate(90) scale(58.5321 53.8452)"
        >
          <stop offset="0.191556" stopColor={color} style={{ transition: TRANSITION_STYLE }} />
          <stop offset="1" stopColor="white" stopOpacity="0" />
        </radialGradient>
        <radialGradient
          id="paint1_radial_898_163643"
          cx="0"
          cy="0"
          r="1"
          gradientUnits="userSpaceOnUse"
          gradientTransform="translate(71.1984 148.714) rotate(90) scale(58.5321 53.8452)"
        >
          <stop offset="0.191556" stopColor={color} style={{ transition: TRANSITION_STYLE }} />
          <stop offset="1" stopColor="white" stopOpacity="0" />
        </radialGradient>
        <radialGradient
          id="paint2_radial_898_163643"
          cx="0"
          cy="0"
          r="1"
          gradientUnits="userSpaceOnUse"
          gradientTransform="translate(71.1984 148.714) rotate(90) scale(58.5321 53.8452)"
        >
          <stop offset="0.191556" stopColor={color} style={{ transition: TRANSITION_STYLE }} />
          <stop offset="1" stopColor="white" stopOpacity="0" />
        </radialGradient>
        <radialGradient
          id="paint3_radial_898_163643"
          cx="0"
          cy="0"
          r="1"
          gradientUnits="userSpaceOnUse"
          gradientTransform="translate(71.1984 148.714) rotate(90) scale(58.5321 53.8452)"
        >
          <stop offset="0.191556" stopColor={color} style={{ transition: TRANSITION_STYLE }} />
          <stop offset="1" stopColor="white" stopOpacity="0" />
        </radialGradient>
        <radialGradient
          id="paint4_radial_898_163643"
          cx="0"
          cy="0"
          r="1"
          gradientUnits="userSpaceOnUse"
          gradientTransform="translate(71.1984 148.714) rotate(90) scale(58.5321 53.8452)"
        >
          <stop offset="0.191556" stopColor={color} style={{ transition: TRANSITION_STYLE }} />
          <stop offset="1" stopColor="white" stopOpacity="0" />
        </radialGradient>
        <radialGradient
          id="paint5_radial_898_163643"
          cx="0"
          cy="0"
          r="1"
          gradientTransform="matrix(-11.9776 38.1917 -20.3672 -6.51529 12.8369 22.4744)"
          gradientUnits="userSpaceOnUse"
        >
          <stop offset="0.19" stopColor={color} style={{ transition: TRANSITION_STYLE }} />
          <stop offset="1" stopColor="white" stopOpacity="0" />
        </radialGradient>
        <radialGradient
          id="paint6_radial_898_163643"
          cx="0"
          cy="0"
          r="1"
          gradientTransform="matrix(-11.9776 38.1917 -20.3672 -6.51529 12.8369 22.4744)"
          gradientUnits="userSpaceOnUse"
        >
          <stop offset="0.19" stopColor={color} style={{ transition: TRANSITION_STYLE }} />
          <stop offset="1" stopColor="white" stopOpacity="0" />
        </radialGradient>
        <radialGradient
          id="paint7_radial_898_163643"
          cx="0"
          cy="0"
          r="1"
          gradientTransform="matrix(-11.9776 38.1917 -20.3672 -6.51529 12.8369 22.4744)"
          gradientUnits="userSpaceOnUse"
        >
          <stop offset="0.19" stopColor={color} style={{ transition: TRANSITION_STYLE }} />
          <stop offset="1" stopColor="white" stopOpacity="0" />
        </radialGradient>
        <radialGradient
          id="paint8_radial_898_163643"
          cx="0"
          cy="0"
          r="1"
          gradientTransform="matrix(-11.9776 38.1917 -20.3672 -6.51529 12.8369 22.4744)"
          gradientUnits="userSpaceOnUse"
        >
          <stop offset="0.19" stopColor={color} style={{ transition: TRANSITION_STYLE }} />
          <stop offset="1" stopColor="white" stopOpacity="0" />
        </radialGradient>
        <radialGradient
          id="paint9_radial_898_163643"
          cx="0"
          cy="0"
          r="1"
          gradientTransform="matrix(-11.9776 38.1917 -20.3672 -6.51529 12.8369 22.4744)"
          gradientUnits="userSpaceOnUse"
        >
          <stop offset="0.19" stopColor={color} style={{ transition: TRANSITION_STYLE }} />
          <stop offset="1" stopColor="white" stopOpacity="0" />
        </radialGradient>
      </defs>
    </g>
  );
}

const OUTLINE_LEG_PATH =
  "M72.9604 109.81C74.894 109.646 76.2139 111.205 77.0609 112.72C77.9657 114.339 78.6776 116.507 79.2445 118.699C80.2217 122.477 80.8728 126.819 81.2338 128.847L81.3705 129.567L81.3803 129.614C81.584 130.801 81.8018 132.041 81.9994 133.263L82.1889 134.477C82.2795 135.086 82.3498 135.647 82.3861 136.102L82.392 136.321C82.38 136.864 82.1646 137.61 81.3773 137.908C81.1243 138.004 80.8877 138.025 80.6713 137.998C82.5377 143.389 83.1157 149.069 83.0141 154.752C82.9806 158.78 82.7449 163.23 81.9477 167.371C81.7168 168.626 81.432 169.863 81.1576 171.064C80.881 172.275 80.6149 173.455 80.4096 174.643V174.645C80.2847 175.359 80.1813 176.086 80.0893 176.82L80.0844 176.855L80.0775 176.89C80.0161 177.221 79.9673 177.719 79.9066 178.362C79.8486 178.978 79.7821 179.695 79.685 180.381C79.5892 181.056 79.4549 181.773 79.2377 182.375C79.1225 182.694 78.9325 183.127 78.6107 183.488L78.6381 184.119L77.3891 184.123C76.37 184.126 75.745 183.38 75.4262 182.856C75.0777 182.284 74.8358 181.572 74.6645 180.902C74.3245 179.574 74.178 178.055 74.2113 177.234L74.226 176.825C74.2297 176.744 74.234 176.663 74.2387 176.582C73.6919 177.813 72.7288 179.338 70.9916 179.615L70.9242 179.626L70.8559 179.63L70.8305 179.631L69.6313 179.683L69.6166 179.355C69.111 179.12 68.7092 178.76 68.393 178.365C68.3833 178.768 68.3592 179.153 68.3139 179.511C68.2354 180.128 68.0858 180.771 67.7807 181.302C67.4534 181.872 66.8927 182.387 66.06 182.461L65.8793 182.476L65.7025 182.438L65.684 182.434V182.432C65.1745 182.331 64.7741 182.032 64.4936 181.758C64.19 181.46 63.9187 181.088 63.6801 180.686C63.0862 179.691 62.6091 178.369 62.2953 177.28L62.2934 177.271C60.2355 169.913 60.5821 162.236 61.5502 154.873C60.9179 154.934 60.5013 154.537 60.3305 154.305C60.1514 154.062 60.0607 153.791 60.0092 153.592C59.9526 153.372 59.9175 153.129 59.8969 152.878C59.8555 152.373 59.8689 151.749 59.9486 151.026L60.0443 150.202C60.5432 146.076 61.3581 141.84 62.4975 137.123L62.4984 137.121C63.2049 134.216 63.9955 131.458 64.5385 128.655L64.5404 128.641C64.9418 126.691 65.1752 124.614 65.4242 122.47C65.6705 120.35 65.9322 118.166 66.3959 116.103L66.3988 116.094C66.5024 115.649 66.6174 115.243 66.7436 114.916C66.8059 114.754 66.8823 114.581 66.977 114.423C67.0514 114.298 67.2243 114.028 67.5355 113.844C67.7143 113.739 67.9748 113.642 68.2904 113.664C68.6113 113.686 68.866 113.822 69.0414 113.969C69.3406 114.221 69.4624 114.548 69.5121 114.695C69.5282 114.743 69.5431 114.793 69.557 114.844C69.5825 114.473 69.6255 114.098 69.6898 113.721L69.6947 113.695L69.7006 113.669C69.8503 112.981 70.1251 112.16 70.5854 111.45C71.0448 110.741 71.7728 110.023 72.8461 109.826L72.9027 109.815L72.9604 109.81Z";
const OUTLINE_ARM_PATH =
  "M23.3953 2.03599e-05C24.2449 0.00166229 25.0165 0.413796 25.4881 1.03127C25.9739 1.66746 26.1689 2.57612 25.7176 3.44533C25.6131 3.64654 25.3992 4.00105 25.0037 4.19826C24.9955 4.20237 24.9867 4.2061 24.9784 4.20998C21.1687 5.97808 17.7654 10.0768 15.2694 13.7266C14.8489 14.3411 14.475 14.9948 14.0926 15.6836C14.5149 15.3102 15.065 14.9829 15.703 15.0733C16.505 15.187 16.8666 15.8585 17.0135 16.2383C17.1792 16.6667 17.2503 17.161 17.2821 17.5772C17.315 18.0079 17.311 18.4304 17.2938 18.7539C17.2406 20.767 17.1991 22.6997 17.2049 24.6348L17.202 25.3252C17.1776 26.9529 17.0045 28.6884 16.3416 30.3106L16.3387 30.3164C15.0775 33.3488 13.3427 36.4285 11.7694 39.293C11.7599 39.3103 11.7496 39.3271 11.7391 39.3438C11.5879 39.5839 11.4169 39.9178 11.2049 40.3399C11.0018 40.7443 10.7682 41.2157 10.5155 41.6641C10.264 42.1103 9.97121 42.5751 9.63363 42.9668C9.30428 43.349 8.86289 43.7431 8.29379 43.9248C8.28586 43.9274 8.27736 43.9284 8.26937 43.9307C8.21713 43.947 8.16316 43.9611 8.10726 43.9688C7.73446 44.0201 7.37554 43.9291 7.08285 43.7158C7.00277 44.2864 6.85295 44.8825 6.55746 45.4151L6.55551 45.4141C6.27643 45.944 5.83517 46.3866 5.32406 46.6572C4.81026 46.9293 4.12327 47.0759 3.44711 46.8037L3.41879 46.793C3.37355 46.7751 3.33044 46.7534 3.2889 46.7295C2.60391 46.387 2.20219 45.7812 1.96761 45.1846C1.72507 44.5676 1.6204 43.8661 1.57601 43.21C1.52906 42.5155 1.54838 41.7385 1.57504 41.0733C1.42461 41.0765 1.28063 41.0513 1.15316 41.0049C0.906421 40.9151 0.733692 40.7603 0.626794 40.6426C0.227714 40.203 0.0333357 39.492 0.0418335 38.7998C0.0580357 37.5799 -0.295141 33.4576 0.799646 29.001L1.0389 28.0674C1.59712 25.9816 2.15763 24.5206 2.82211 23.1299C2.82896 23.1156 2.83704 23.1009 2.84457 23.0869C2.91505 22.9559 3.01498 22.7942 3.15609 22.6533C3.28788 22.5218 3.57984 22.2871 4.01254 22.3008C4.01612 22.3009 4.01972 22.3016 4.02328 22.3018C4.04367 22.0337 4.06753 21.7721 4.09359 21.5225L4.09554 21.5049C4.22543 20.4471 4.43304 19.3918 4.70785 18.3506C4.51168 18.3613 4.31598 18.3155 4.14535 18.2149L4.13851 18.211C4.12014 18.2001 4.10422 18.1857 4.08676 18.1738C4.06472 18.159 4.04325 18.1446 4.02328 18.1289C4.00713 18.116 3.99161 18.1027 3.9764 18.0889C3.75849 17.8958 3.67591 17.6657 3.65316 17.6006C3.60576 17.4649 3.58289 17.3311 3.57015 17.2305C3.54377 17.022 3.53832 16.7739 3.54281 16.5186V16.5078C3.63091 13.4064 4.49506 10.2517 6.07113 7.69533C7.64993 5.13476 9.98138 3.12279 12.9989 2.46096L13.0106 2.45803C13.2591 2.40669 13.726 2.30261 14.1737 2.26467C14.3997 2.24553 14.6676 2.23855 14.9325 2.27834C15.1836 2.31611 15.5479 2.41234 15.8495 2.69631C15.882 2.72699 15.9111 2.76118 15.9393 2.79592C17.7995 1.54623 19.0771 0.667557 21.6141 0.154317C22.2076 0.0334562 22.84 -0.000976811 23.3953 2.03599e-05Z";
const MUSCLE_A_PATH =
  "M77.2354 181.922C75.7739 181.927 75.1989 177.622 75.261 176.264C75.3668 172.141 76.8355 168.18 77.5127 164.099C79.5463 153.236 79.1584 142.442 76.4525 132.589C76.0042 130.738 76.1933 130.508 77.1089 132.211C80.7325 138.876 81.7984 146.246 81.6645 153.73C81.6317 157.734 81.3982 162.11 80.6186 166.154C80.168 168.604 79.5003 170.989 79.0774 173.438C78.9482 174.177 78.842 174.924 78.7484 175.67C78.4542 177.253 78.4725 181.449 77.2504 181.919L77.2353 181.92L77.2354 181.922Z";
const MUSCLE_B_PATH =
  "M65.7844 180.26C65.4035 180.194 64.9715 179.762 64.5609 179.071C64.0445 178.206 63.6014 176.997 63.2988 175.947C61.0286 167.83 61.7652 159.254 63.0204 151.011C63.4869 148.521 63.7251 151.569 63.8288 152.45C64.3123 157.377 64.7985 161.843 65.717 166.92C65.9949 168.91 68.5163 180.026 65.8048 180.264L65.787 180.26L65.7844 180.26Z";
const MUSCLE_C_PATH =
  "M60.9914 150.157C61.4716 145.833 62.3074 141.401 63.5144 136.404C64.2052 133.564 65.0168 130.721 65.5665 127.882C66.3948 123.857 66.5217 119.35 67.4174 115.365C67.8061 113.695 68.2494 113.167 68.3723 115.071C68.4527 122.263 67.0612 129.34 65.3362 136.455C64.094 141.453 62.5474 146.465 61.7695 151.536C61.4423 153.52 60.6966 152.829 60.9914 150.157Z";
const MUSCLE_D_PATH =
  "M70.6277 177.428C68.9378 177.339 68.3194 175.052 67.9361 173.596C66.2923 166.672 65.2495 157.569 65.0221 149.137C64.9854 147.247 65.0213 145.461 65.2487 143.617C65.6376 140.441 66.6376 137.41 67.3771 134.473C68.308 130.896 68.8461 127.383 69.2098 123.628C69.3956 122.103 69.6474 118.73 71.1016 122.099C78.0249 138.827 78.2597 154.63 74.0822 171.548C73.6059 173.407 72.8455 177.08 70.6529 177.43L70.6278 177.431L70.6277 177.428Z";
const MUSCLE_E_PATH =
  "M80.3076 135.51C80.1087 135.165 79.8722 134.711 79.6076 134.188C78.8731 132.711 78.0862 131.187 77.2372 129.743C74.3643 124.522 69.7024 118.899 70.7232 112.923C70.9838 111.725 71.65 110.237 72.9127 110.005C77.5052 109.615 79.3288 125.442 80.0473 128.816C80.3206 130.408 80.6143 132.067 80.8521 133.654C80.941 134.252 81.0069 134.783 81.0401 135.2C81.0935 135.85 80.5964 136.008 80.3075 135.508L80.3076 135.51Z";
const MUSCLE_F_PATH =
  "M0.892519 37.8121C0.910234 36.4783 0.562419 32.5495 1.62117 28.2396C2.24625 25.6968 2.84908 24.0815 3.57558 22.561C4.36428 21.0944 4.26726 26.2694 4.16052 26.8675C3.99014 28.5531 3.26006 30.0482 2.80618 31.6484C2.13036 33.8982 1.78676 36.3094 1.60806 38.6896C1.53413 39.5264 0.879232 38.8944 0.892519 37.8121Z";
const MUSCLE_G_PATH =
  "M3.6397 44.8612C1.96267 44.1065 2.46488 40.3894 2.47552 38.7877C2.83742 31.664 5.9489 24.9036 10.4202 19.615C10.8884 19.0998 11.3947 18.7335 10.8786 19.8775C10.3589 20.9982 9.72473 22.1811 9.25617 23.3457C7.46514 27.8373 6.82721 32.2352 6.23899 36.9814C6.09147 38.4059 6.0381 39.8164 6.03037 41.2496C6.0127 42.147 5.96344 43.1548 5.53351 43.9296C5.16384 44.6519 4.32072 45.1424 3.6658 44.8745L3.63772 44.8634L3.6397 44.8612Z";
const MUSCLE_H_PATH =
  "M7.82159 41.9777C6.74133 42.1267 7.26011 38.7322 7.23779 37.9096C7.63578 32.1378 8.77581 26.535 11.1822 21.3002C12.1542 19.3182 13.0493 17.247 14.4589 15.5712C16.0753 13.9663 16.2075 16.541 16.1459 17.7006C16.0923 19.7264 16.0494 21.6812 16.0553 23.6417C16.0681 25.4293 15.9466 27.2674 15.2665 28.9321C14.031 31.9026 12.328 34.9264 10.7435 37.8111C10.0169 38.9654 9.10829 41.5675 7.84027 41.9724L7.82134 41.9735L7.82159 41.9777Z";
const MUSCLE_I_PATH =
  "M4.49965 16.3498C4.41901 16.3056 4.38511 16.0117 4.39346 15.5364C4.56078 9.64404 7.68311 3.61758 13.0634 2.4375C13.6118 2.3242 14.6531 2.08386 15.0146 2.42443C15.1178 2.56524 14.9962 2.7981 14.6948 3.09693C10.5602 6.29199 6.89523 10.2726 5.14686 15.1363C4.97588 15.4999 4.75697 16.3112 4.5041 16.3538L4.49755 16.3499L4.49965 16.3498Z";
const MUSCLE_J_PATH =
  "M5.19155 24.5363L5.18675 24.5341C5.00167 24.4654 4.89297 24.1364 4.84414 23.6191C4.7709 22.6824 4.83838 21.5884 4.93883 20.6265C5.38621 16.9829 6.78389 13.3513 8.79173 10.2712C9.70904 8.91192 10.8077 7.69523 11.987 6.52486C13.1112 5.42162 14.6806 3.67181 15.9907 2.86417C18.067 1.47688 19.1882 0.635379 21.6635 0.134675C22.1659 0.0322893 22.7244 -0.00091378 23.2439 1.90292e-05C24.3036 0.00192167 25.1732 1.03712 24.6809 1.9848C24.602 2.13663 24.5116 2.25177 24.4086 2.30312C20.3322 4.1949 16.7992 8.50076 14.295 12.1624C13.3067 13.6068 12.5832 15.2165 11.63 16.6843C10.44 18.5451 8.86012 20.1607 7.53194 21.9317C6.96116 22.5701 5.84354 24.6246 5.20563 24.5409L5.19735 24.5387C5.19534 24.5381 5.19339 24.5373 5.19155 24.5363Z";
