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

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

  return (
    <g className={className} data-organ="nervous">
      {/* Invisible outline for interaction */}
      <path d={OUTLINE_ARM_PATH} fill="transparent" />
      <path d={OUTLINE_LEG_PATH} fill="transparent" />
      {/* Nervous system */}
      <path
        d={BRAIN_PATH}
        fill={style?.fill ?? fillColor}
        stroke={style?.stroke}
        strokeWidth={style?.strokeWidth}
        style={{ transition: TRANSITION_STYLE }}
      />
      <path
        d={ARM_PATH}
        fill={style?.fill ?? fillColor}
        stroke={style?.stroke}
        strokeWidth={style?.strokeWidth}
        style={{ transition: TRANSITION_STYLE }}
      />
      <path
        d={LEG_PATH}
        fill={style?.fill ?? fillColor}
        stroke={style?.stroke}
        strokeWidth={style?.strokeWidth}
        style={{ transition: TRANSITION_STYLE }}
      />
    </g>
  );
}

const OUTLINE_ARM_PATH =
  "M66.5328 85.769C67.2273 85.6336 67.9069 86.0377 68.1266 86.6977L68.1647 86.8334V86.8354C68.7242 89.3373 69.8595 91.3481 71.2555 93.1918C71.3204 93.2718 71.3809 93.3515 71.4371 93.4301L71.9117 94.0268C72.4012 94.6269 72.9139 95.2128 73.4391 95.8002C74.501 96.988 75.2623 97.7959 75.8844 98.6655C76.4547 99.4628 76.9034 100.299 77.4371 101.521L77.6715 102.07L77.6979 102.14L77.7164 102.196C77.724 102.218 77.731 102.242 77.7369 102.265C78.396 104.847 78.4561 107.107 78.5231 109.093C78.591 111.108 78.6691 112.796 79.2447 114.526L79.2828 114.664C79.437 115.357 79.0441 116.065 78.3629 116.296C77.9891 116.423 77.5974 116.381 77.2711 116.212C77.4809 116.812 77.6859 117.448 77.8727 118.063C78.3031 119.481 78.6915 120.959 78.8941 121.95L78.9693 122.343L78.9762 122.391L78.9791 122.414L78.9801 122.424C79.0534 123.064 79.0949 123.694 79.1197 124.31C79.1675 124.388 79.2086 124.472 79.2408 124.561L79.2818 124.698L79.3756 125.007C79.6273 125.729 80.118 126.456 80.7408 127.391C81.3659 128.329 82.212 129.596 82.3375 131.033C82.4012 131.762 81.892 132.413 81.1793 132.536C81.4325 133.086 81.7013 133.672 81.9508 134.231C82.4133 135.268 82.875 136.358 83.234 137.38C83.5413 138.255 83.8019 139.159 83.899 139.976L83.9303 140.321C83.9762 141.088 83.3946 141.753 82.6256 141.806C81.8491 141.859 81.1823 141.267 81.1354 140.496C81.1044 139.989 80.9212 139.248 80.5924 138.312C80.3489 137.619 80.0438 136.872 79.7135 136.109C79.9083 136.793 79.5586 137.505 78.9195 137.779L78.7857 137.829C78.0517 138.059 77.2611 137.654 77.0309 136.909C76.2592 134.405 76.2107 131.963 76.2623 129.639C76.3118 127.412 76.4464 125.352 76.2428 123.179L76.2018 122.784C76.0561 121.975 75.664 120.434 75.193 118.881C74.7016 117.262 74.1869 115.84 73.8492 115.246L73.0943 113.936C73.0923 113.932 73.0905 113.929 73.0885 113.925L72.4176 112.726C72.1947 112.324 71.9733 111.921 71.7525 111.517C68.7985 106.114 68.0453 104.539 67.2877 102.081C66.7468 100.327 66.5202 98.0727 66.3072 95.6362C66.0897 93.1464 65.881 90.365 65.4147 87.3617C65.2994 86.6191 65.7931 85.914 66.5328 85.769Z";
const OUTLINE_LEG_PATH =
  "M14.575 197.37C14.8653 196.021 16.194 195.162 17.5437 195.452C18.8935 195.742 19.7527 197.071 19.4627 198.421C18.6261 202.312 17.2133 208.751 16.4148 214.453C15.8062 218.799 15.6552 222.508 15.8474 224.986C15.8481 224.995 15.8488 225.003 15.8494 225.012C16.4373 232.528 17.9807 241.524 16.9148 250.832C16.7188 252.544 16.567 254.508 16.4382 256.592C16.4879 256.692 16.5323 256.784 16.5701 256.867C16.747 257.256 16.9216 257.71 17.0877 258.2C17.4209 259.184 17.7552 260.415 18.0183 261.762C18.5313 264.388 18.8427 267.785 18.116 270.716C17.8199 271.909 16.7124 272.684 15.5271 272.606C15.4444 273.523 15.3534 274.371 15.2478 275.127C15.0566 276.494 13.7928 277.448 12.4256 277.257C11.6462 277.148 11.0019 276.69 10.6267 276.064C10.4871 278.161 10.2308 280.468 10.0388 282.938C9.74284 286.746 9.55501 291.377 10.0144 297.341C10.1205 298.718 9.09014 299.92 7.71364 300.027C6.33711 300.133 5.13431 299.102 5.02809 297.726C4.84475 295.346 4.76049 293.164 4.74196 291.156C4.30936 292.031 3.38315 292.607 2.3484 292.544C0.970622 292.46 -0.0788071 291.275 0.00465233 289.898L0.0056289 289.895L0.00465233 289.891C0.00484981 289.888 0.00626899 289.883 0.00660546 289.878C0.0072902 289.867 0.00729223 289.851 0.00855858 289.832C0.0110871 289.794 0.0151845 289.74 0.0202773 289.67C0.0305332 289.529 0.0462892 289.323 0.0691055 289.055C0.114813 288.518 0.188925 287.729 0.302504 286.705C0.529693 284.658 0.91544 281.669 1.55446 277.865C2.21728 273.921 3.12071 271.564 4.14625 269.941C4.66137 269.125 5.16764 268.559 5.56911 268.135C5.6689 268.029 5.75156 267.941 5.82106 267.868C5.92819 264.692 6.07978 260.971 6.07106 256.37C5.61919 257.019 4.86992 257.446 4.0193 257.445C2.63887 257.445 1.51989 256.325 1.52028 254.945C1.52252 249.773 1.25876 242.813 2.72047 234.112C3.34934 230.369 5.13404 226.037 6.9275 222.264C8.62049 218.702 10.465 215.351 11.5252 213.325C12.3631 207.519 13.77 201.115 14.575 197.37Z";
const BRAIN_PATH =
  "M26.7823 1.20492C27.8315 0.567599 32.6087 -0.60506 33.3956 0.377768C33.562 0.58558 33.9784 1.1477 33.8536 1.35628C34.2872 1.7172 34.0372 2.82492 34.0372 3.61703C34.0372 4.40925 34.1239 5.6758 34.0372 6.58187C34.1495 6.97176 34.0913 7.46992 34.0372 8.03499C34.0619 8.16154 34.0616 8.30127 34.0616 8.45101V11.6864C34.0615 12.9326 33.7283 13.4368 32.9796 13.7039C32.2309 13.971 31.4404 13.8232 30.6085 13.5858C30.9463 14.9983 29.0578 15.6286 27.4894 15.0692C26.0204 15.2264 23.4282 15.0536 22.4142 14.1493C20.8843 13.938 19.7473 12.7366 19.461 11.7157C19.1675 10.6684 18.9001 9.67156 19.8634 8.68832C19.6651 7.32653 20.8109 4.84671 22.3985 4.05843C23.0308 2.99075 25.0923 1.07195 26.7823 1.20492ZM35.3214 0.377768C36.1084 -0.605048 40.8855 0.567602 41.9347 1.20492C43.6247 1.07195 45.6853 2.99075 46.3175 4.05843C47.9055 4.8464 49.0519 7.32636 48.8536 8.68832C49.8169 9.67156 49.5495 10.6684 49.256 11.7157C48.9697 12.7366 47.8327 13.938 46.3028 14.1493C45.2889 15.0536 42.6966 15.2264 41.2276 15.0692C39.6592 15.6287 37.7707 14.9983 38.1085 13.5858C37.2766 13.8232 36.4861 13.971 35.7374 13.7039C34.9888 13.4368 34.6555 12.9326 34.6554 11.6864V8.45101C34.6554 8.30127 34.6551 8.16154 34.6798 8.03499C34.6257 7.46992 34.5675 6.97176 34.6798 6.58187C34.5932 5.6758 34.6798 4.40925 34.6798 3.61703C34.6798 2.82491 34.4298 1.7172 34.8634 1.35628C34.7386 1.1477 35.155 0.58558 35.3214 0.377768Z";
const ARM_PATH =
  "M66.7239 86.7507C66.9358 86.7094 67.1416 86.8436 67.1887 87.0535C67.7887 89.7366 69.0056 91.8762 70.4583 93.7947C70.5222 93.8719 70.583 93.9522 70.6409 94.0339L71.1379 94.658C71.6415 95.2755 72.1645 95.8747 72.6936 96.4666C73.7842 97.6864 74.4905 98.4356 75.0715 99.2478C75.6609 100.072 76.1194 100.956 76.7493 102.457L76.7688 102.512C77.3976 104.976 77.4574 107.133 77.5247 109.128C77.5922 111.13 77.6676 112.956 78.2952 114.842C78.3645 115.051 78.2508 115.277 78.0413 115.348C77.8317 115.419 77.6051 115.308 77.5354 115.099C76.8664 113.09 76.7911 111.152 76.7239 109.159C76.6566 107.166 76.5994 105.101 76.0022 102.746C75.3876 101.284 74.9561 100.466 74.4192 99.7156C74.3625 99.6363 74.3039 99.5578 74.2444 99.4792C74.2484 99.4912 74.2522 99.5034 74.2561 99.5154C74.4393 100.073 74.5834 100.644 74.7004 101.223C74.9036 102.228 75.0247 103.264 75.1194 104.306C75.1392 104.526 74.977 104.721 74.7571 104.743C74.5374 104.764 74.3437 104.604 74.3235 104.385C74.2301 103.357 74.1127 102.358 73.9192 101.398C73.7415 100.795 73.5935 100.235 73.4905 99.7517C73.1657 98.7675 72.7163 97.8401 72.0803 96.9841C71.3756 96.1955 70.6708 95.3846 70.0061 94.5261C69.9433 94.445 69.8807 94.363 69.8186 94.281C69.0205 93.227 68.2867 92.0963 67.677 90.8435C67.8516 92.4955 67.9755 94.0492 68.0999 95.4724C68.3164 97.9503 68.5335 100.008 69.0081 101.547C69.7063 103.811 70.3755 105.243 73.3313 110.649C73.7687 111.449 74.2125 112.249 74.6555 113.035L75.4124 114.348L75.4133 114.35C75.8648 115.144 76.4306 116.756 76.9153 118.353C77.4031 119.961 77.8274 121.613 77.9846 122.514L77.9875 122.539C78.071 123.268 78.1139 123.987 78.135 124.698C78.2204 124.751 78.2857 124.836 78.3118 124.94C78.57 125.974 79.2319 126.929 79.9084 127.945C80.5603 128.924 81.2415 129.98 81.3411 131.12C81.3601 131.34 81.1977 131.534 80.9778 131.555C80.7578 131.576 80.5636 131.415 80.5442 131.195C80.4653 130.292 79.9154 129.403 79.2415 128.391C79.0125 128.048 78.7714 127.69 78.5403 127.319C78.5543 127.473 78.5663 127.622 78.5803 127.765C78.6597 128.578 78.7425 129.213 78.8655 129.634C79.0091 130.124 79.3158 130.85 79.7122 131.73C80.1004 132.592 80.5826 133.619 81.0374 134.638C81.4962 135.667 81.9458 136.728 82.2913 137.712C82.6345 138.689 82.8855 139.62 82.9319 140.382C82.9451 140.602 82.7773 140.792 82.5569 140.807C82.3364 140.822 82.1465 140.656 82.1331 140.435C82.0935 139.787 81.8723 138.941 81.5354 137.981C81.2007 137.028 80.7619 135.991 80.3059 134.969C79.8457 133.936 79.3843 132.955 78.9827 132.063C78.5895 131.19 78.2594 130.414 78.0979 129.862C78.0853 129.819 78.0736 129.773 78.0618 129.727C78.0131 131.995 78.074 134.177 78.7512 136.374C78.8159 136.584 78.6975 136.808 78.4866 136.875C78.2754 136.941 78.0505 136.824 77.9856 136.613C77.2638 134.271 77.2118 131.965 77.2629 129.662C77.3112 127.489 77.4502 125.335 77.2395 123.086L77.1917 122.635C77.0395 121.776 76.6301 120.174 76.1497 118.591C75.6623 116.985 75.119 115.458 74.718 114.752L73.9612 113.437L73.9592 113.434C73.5139 112.644 73.0688 111.841 72.6292 111.037C69.6741 105.632 68.9679 104.137 68.2434 101.787C67.7395 100.152 67.5179 98.0081 67.303 95.5486C67.0867 93.0739 66.8753 90.2522 66.4026 87.2078C66.3698 86.9951 66.5121 86.7924 66.7239 86.7507Z";
const LEG_PATH =
  "M17.1033 197.505C17.3188 197.552 17.4553 197.765 17.4089 197.981C16.5784 201.844 15.1495 208.35 14.3376 214.136C14.3372 214.142 14.3364 214.149 14.3357 214.155C14.3353 214.157 14.3351 214.16 14.3347 214.163C13.7125 218.606 13.5465 222.481 13.7556 225.161C14.3626 232.936 15.8638 241.546 14.8279 250.593C14.607 252.522 14.4427 254.755 14.3044 257.101C14.4226 257.262 14.543 257.484 14.658 257.737C14.7981 258.045 14.948 258.431 15.0984 258.874C15.3996 259.763 15.7105 260.905 15.9568 262.165C16.4473 264.676 16.6958 267.718 16.0779 270.21C16.0247 270.425 15.8077 270.555 15.5935 270.502C15.3793 270.449 15.2486 270.232 15.3015 270.018C15.878 267.692 15.6536 264.786 15.1716 262.319C14.9317 261.091 14.6306 259.984 14.3416 259.131C14.2988 259.005 14.2525 258.886 14.2107 258.772C14.1314 260.257 14.0594 261.768 13.988 263.26C13.7755 267.704 13.5669 271.985 13.1687 274.836C13.138 275.055 12.9352 275.208 12.7166 275.177C12.498 275.147 12.3454 274.945 12.3757 274.726C12.7677 271.919 12.9759 267.681 13.1892 263.222C13.4019 258.776 13.6191 254.117 14.033 250.502C14.9866 242.174 13.7654 234.265 13.0964 226.86C11.235 231.593 8.50792 240.793 8.82495 249.042C9.16249 257.826 8.84052 264.041 8.69019 268.834C8.64059 270.416 8.60977 271.839 8.62671 273.149C8.66142 275.833 8.24542 278.912 7.94507 282.776C7.64321 286.66 7.45075 291.403 7.92065 297.503C7.93734 297.723 7.77238 297.916 7.55249 297.933C7.33236 297.95 7.13997 297.785 7.1228 297.565C6.64891 291.413 6.84315 286.627 7.14722 282.714C7.45283 278.782 7.86098 275.796 7.8269 273.16C7.81389 272.153 7.82758 271.082 7.85718 269.934C7.79621 269.998 7.73715 270.063 7.67651 270.127C7.33729 270.486 6.97223 270.899 6.59839 271.491C5.84991 272.676 5.04046 274.623 4.41479 278.346C3.78524 282.093 3.40687 285.029 3.1853 287.026C3.07459 288.023 3.0024 288.787 2.95874 289.3C2.93694 289.556 2.92225 289.751 2.91284 289.88C2.90814 289.945 2.90425 289.994 2.9021 290.026C2.90103 290.042 2.90065 290.054 2.90015 290.062C2.89991 290.066 2.90026 290.069 2.90015 290.071L2.89917 290.073C2.88579 290.293 2.69671 290.462 2.47632 290.449C2.25589 290.435 2.08794 290.244 2.10132 290.024H2.10034C2.10038 290.023 2.10125 290.022 2.10132 290.021C2.10146 290.019 2.10203 290.015 2.10229 290.011C2.10284 290.003 2.10314 289.99 2.10425 289.973C2.1065 289.939 2.11018 289.889 2.11499 289.823C2.12464 289.69 2.14073 289.492 2.16284 289.232C2.20708 288.712 2.27788 287.941 2.3894 286.936C2.61253 284.926 2.99465 281.976 3.62671 278.214C4.26268 274.429 5.09762 272.369 5.92261 271.063C6.33546 270.409 6.73906 269.954 7.09546 269.578C7.42638 269.228 7.68276 268.971 7.89429 268.683C8.04651 263.898 8.35839 257.746 8.02515 249.074C7.66615 239.732 11.1249 229.257 12.9509 225.123C12.7818 222.834 12.8746 219.754 13.2673 216.237C12.2072 218.227 10.8454 220.777 9.54663 223.509C7.77038 227.246 6.13879 231.272 5.58081 234.593C4.16817 243.001 4.42293 249.683 4.42065 254.946C4.42045 255.167 4.24106 255.345 4.02026 255.345C3.79952 255.345 3.62075 255.166 3.62085 254.945C3.6231 249.707 3.36561 242.949 4.79175 234.46C5.36933 231.023 7.04398 226.912 8.82495 223.165C10.59 219.452 12.4849 216.045 13.5525 213.983C14.3703 208.172 15.801 201.657 16.6277 197.812C16.6743 197.596 16.8874 197.459 17.1033 197.505Z";
