$hu-border-width-core-modules: hu-format-modules(hu-get-class-modules($hu-border-width-modules, core, $hu-border-width-modules));
$hu-border-width-pseudos: hu-get-class-modules($hu-border-width-modules, pseudos, null);
$hu-border-width-parents: hu-get-class-modules($hu-border-width-modules, parents, null);

@each $module in $hu-border-width-core-modules {
  @each $type, $value in $hu-border-width-types {
    @each $side-type, $side-properties in $hu-border-width-sides {
      $side-properties: if($side-properties, $side-properties, $side-type);
      $class-name: hu-class-name("#{$side-type}-width:#{$type}");
      $value: if($value, $value, $type);

      @include hu-generic($class-name, $module) {
        @each $property in $side-properties {
          #{$property}-width: $value #{hu-important()};
        }
      }
    }
  }
}

@if (index($hu-border-width-core-modules, responsive)) {
  @each $mq-scale, $mq-value in $hu-media-queries {
    @include hu-media-query($mq-value) {
      @each $type, $value in $hu-border-width-types {
        @each $side-type, $side-properties in $hu-border-width-sides {
          $side-properties: if($side-properties, $side-properties, $side-type);
          $class-name: hu-class-name("#{$side-type}-width:#{$type}");
          $value: if($value, $value, $type);

          @include hu-responsive($class-name, $hu-border-width-core-modules, $mq-scale) {
            @each $property in $side-properties {
              #{$property}-width: $value #{hu-important()};
            }
          }
        }
      }
    }
  }
}

@if ($hu-border-width-pseudos) {
  @each $module in $hu-border-width-core-modules {
    @each $type, $value in $hu-border-width-types {
      @each $side-type, $side-properties in $hu-border-width-sides {
        $side-properties: if($side-properties, $side-properties, $side-type);
        $class-name: hu-class-name("#{$side-type}-width:#{$type}");
        $value: if($value, $value, $type);

        @include hu-pseudo($class-name, $hu-border-width-pseudos, $module) {
          @each $property in $side-properties {
            #{$property}-width: $value #{hu-important()};
          }
        }
      }
    }
  }

  @if (index($hu-border-width-core-modules, responsive)) {
    @each $mq-scale, $mq-value in $hu-media-queries {
      @include hu-media-query($mq-value) {
        @each $type, $value in $hu-border-width-types {
          @each $side-type, $side-properties in $hu-border-width-sides {
            $side-properties: if($side-properties, $side-properties, $side-type);
            $class-name: hu-class-name("#{$side-type}-width:#{$type}");
            $value: if($value, $value, $type);

            @include hu-pseudo-responsive($class-name, $hu-border-width-pseudos, $hu-border-width-core-modules, $mq-scale) {
              @each $property in $side-properties {
                #{$property}-width: $value #{hu-important()};
              }
            }
          }
        }
      }
    }
  }
}

@if ($hu-border-width-parents) {
  @each $module in $hu-border-width-core-modules {
    @each $type, $value in $hu-border-width-types {
      @each $side-type, $side-properties in $hu-border-width-sides {
        $side-properties: if($side-properties, $side-properties, $side-type);
        $class-name: hu-class-name("#{$side-type}-width:#{$type}");
        $value: if($value, $value, $type);

        @include hu-parent($class-name, $hu-border-width-parents, $module) {
          @each $property in $side-properties {
            #{$property}-width: $value #{hu-important()};
          }
        }
      }
    }
  }

  @if (index($hu-border-width-core-modules, responsive)) {
    @each $mq-scale, $mq-value in $hu-media-queries {
      @include hu-media-query($mq-value) {
        @each $type, $value in $hu-border-width-types {
          @each $side-type, $side-properties in $hu-border-width-sides {
            $side-properties: if($side-properties, $side-properties, $side-type);
            $class-name: hu-class-name("#{$side-type}-width:#{$type}");
            $value: if($value, $value, $type);

            @include hu-parent-responsive($class-name, $hu-border-width-parents, $hu-border-width-core-modules, $mq-scale) {
              @each $property in $side-properties {
                #{$property}-width: $value #{hu-important()};
              }
            }
          }
        }
      }
    }
  }
}
