/**
 * @license
 * Copyright 2023 Tyler Technologies, Inc. 
 * License: Apache-2.0
 */
@use '../field/selector' as field-selector;
@use './base';

@mixin field {
  // Core
  @include base.field-core;

  // Height
  &:not(.forge-field--dense):not(.forge-field--roomy) {
    @include base.field-height(default, --forge-chip-field-height);
  }
  &.forge-field--roomy:not(.forge-field--dense) {
    @include base.field-height(roomy, --forge-chip-field-height);
  }
  &.forge-field--dense:not(.forge-field--roomy) {
    @include base.field-height(dense, --forge-chip-field-height);
  }
}

@mixin label-input-container {
  &__label-input-container {
    @include base.label-input-container-core;
  }
}

@mixin input-container {
  // Core
  &__input-container {
    @include base.input-container-core;
  }
  // Padding
  &__input-container {
    @include base.input-container-padding;
  }
  // Padding Top
  &--label .forge-field__input-container {
    @include base.input-container-padding-top(default, label);
  }
  &--roomy.forge-field--label .forge-field__input-container {
    @include base.input-container-padding-top(roomy, label);
  }
  // Padding Left
  &--shape-rounded:not(.forge-field--leading) .forge-field__input-container {
    @include base.input-container-padding-left(shape-rounded, default);
  }
  &--leading:not(.forge-field--shape-rounded) .forge-field__input-container {
    @include base.input-container-padding-left(default, leading);
  }
  &--shape-rounded.forge-field--leading .forge-field__input-container {
    @include base.input-container-padding-left(shape-rounded, leading);
  }
  // Padding Bottom
  &--label .forge-field__input-container {
    @include base.input-container-padding-bottom(default, label);
  }
  &--roomy.forge-field--label .forge-field__input-container {
    @include base.input-container-padding-bottom(roomy, label);
  }
  // Padding Right
  &--shape-rounded:not(.forge-field--trailing):not(.forge-field--addon-end) {
    .forge-field__input-container {
      @include base.input-container-padding-right(shape-rounded, default);
    }
  }
  &--trailing:not(.forge-field--shape-rounded),
  &--addon-end:not(.forge-field--shape-rounded) {
    .forge-field__input-container {
      @include base.input-container-padding-right(default, trailing);
    }
  }
  &--shape-rounded.forge-field--trailing,
  &--shape-rounded.forge-field--addon-end {
    .forge-field__input-container {
      @include base.input-container-padding-right(shape-rounded, trailing);
    }
  }
}

@mixin member {
  // Core
  ::slotted([slot='member']) {
    @include base.member-core;
  }
  // Theme
  &--disabled {
    ::slotted([slot='member']) {
      @include base.member-theme(disabled);
    }
  }
  // Padding
  &:not(.forge-field--dense):not(.forge-field--roomy) {
    ::slotted([slot='member']) {
      @include base.member-padding(default);
    }
  }
  &--roomy:not(.forge-field--dense) {
    ::slotted([slot='member']) {
      @include base.member-padding(roomy);
    }
  }
  &--dense:not(.forge-field--roomy) {
    ::slotted([slot='member']) {
      @include base.member-padding(dense);
    }
  }
  // Height
  &:not(.forge-field--dense):not(.forge-field--roomy) {
    ::slotted([slot='member']) {
      @include base.member-height(default);
    }
  }
  &--dense:not(.forge-field--roomy) {
    ::slotted([slot='member']) {
      @include base.member-height(dense);
    }
  }
}

@mixin input {
  // Base
  // chip-field input should have no padding, so we exclude padding from the base.
  @include field-selector.input('::slotted(input)', $exclude: (padding, padding-top, padding-right, padding-bottom, padding-left), $component-name: 'forge-chip-field');
  // Core
  ::slotted(input) {
    @include base.input-core;
  }
  // Margin
  &:not(.forge-field--dense):not(.forge-field--roomy) {
    ::slotted(input) {
      @include base.input-margin(default);
    }
  }
  &--roomy:not(.forge-field--dense) {
    ::slotted(input) {
      @include base.input-margin(roomy);
    }
  }
  &--dense:not(.forge-field--roomy) {
    ::slotted(input) {
      @include base.input-margin(dense);
    }
  }
  // Height
  &:not(.forge-field--dense):not(.forge-field--roomy) {
    ::slotted(input) {
      @include base.input-height(default);
    }
  }
  &--roomy:not(.forge-field--dense) {
    ::slotted(input) {
      @include base.input-height(roomy);
    }
  }
  &--dense:not(.forge-field--roomy) {
    ::slotted(input) {
      @include base.input-height(dense);
    }
  }
}

@mixin leading {
  // Core
  &--leading .forge-field__leading-container {
    @include base.leading-core;
  }
  // Margin
  @include _icon-margin-y('::slotted([slot=\'leading\'])');
  // Padding
  @include _icon-padding-y('::slotted([slot=\'leading\'])');
}

@mixin trailing {
  // Core
  &--trailing .forge-field__trailing-container {
    @include base.trailing-core;
  }
  // Margin
  @include _icon-margin-y('::slotted([slot=\'trailing\'])');
  // Padding
  @include _icon-padding-y('::slotted([slot=\'trailing\'])');
}

@mixin addon-end {
  // Core
  &--addon-end .forge-field__addon-end-container {
    @include base.addon-end-core;
  }
  // Margin
  @include _icon-margin-y('::slotted([slot=\'addon-end\'])');
}

@mixin icon-button {
  // Display
  ::slotted(forge-icon-button) {
    @include base.icon-button-display;
  }
}

@mixin _icon-margin-y($selector) {
  &:not(.forge-field--dense):not(.forge-field--roomy) {
    #{$selector} {
      @include base.icon-margin-y(default);
    }
  }
  &--roomy:not(.forge-field--dense) {
    #{$selector} {
      @include base.icon-margin-y(roomy);
    }
  }
  &--dense:not(.forge-field--roomy) {
    #{$selector} {
      @include base.icon-margin-y(dense);
    }
  }
}

@mixin _icon-padding-y($selector) {
  &--dense:not(.forge-field--roomy) {
    #{$selector} {
      @include base.icon-padding-y(dense);
    }
  }
}
