@use 'sass:color';
@use 'sass:map';
@use 'sass:math';

@mixin theme-builder($theme, $isDark: false) {
  @each $name, $color in $theme {
    --flexy-sys-color-#{$name}: #{$color};
  }

  @if map.has-key($theme, primary) and map.has-key($theme, on-primary) {
    @each $i in (10 20 30 40 50 60 70 80 90) {
      --flexy-sys-palette-tint-#{$i}: #{color.mix(
          map.get($theme, primary),
          map.get($theme, on-primary),
          $weight: calc($i * 1%)
        )};
    }
  }

  @if map.has-key($theme, surface) and map.has-key($theme, on-surface) {
    @each $i in (0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100)
    {
      --flexy-sys-palette-grey-#{$i}: #{color.mix(
          map.get($theme, surface),
          map.get($theme, on-surface),
          $weight: calc(100% - $i * 1%)
        )};
    }
  }
}
