@import "mixins/mixins";
@import "common/var";
@import "common/transition";
@import "checkbox";

@include b(tree) {
  position: relative;
  cursor: default;
  background: $--color-white;
  color: $--tree-font-color;

  @include e(empty-block) {
    position: relative;
    min-height: 60px;
    text-align: center;
    width: 100%;
    height: 100%;
  }

  @include e(empty-text) {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    color: $--color-text-secondary;
    font-size: $--font-size-base;
  }

  @include e(drop-indicator) {
    position: absolute;
    left: 0;
    right: 0;
    height: 1px;
    background-color: $--color-primary;
  }
}

@include b(tree-node) {
  white-space: nowrap;
  outline: none;
  &:focus {
    /* focus */
    > .el-tree-node__content {
      background-color: $--tree-node-hover-background-color;
    }
  }

  @include when(drop-inner) {
    > .el-tree-node__content .el-tree-node__label {
      background-color: $--color-primary;
      color: #fff;
    }
  }

  @include e(content) {
    display: flex;
    align-items: center;
    height: 26px;
    cursor: pointer;

    & > .el-tree-node__expand-icon {
      padding: 6px;
    }
    & > label.el-checkbox {
      margin-right: 8px;
    }
    &:hover {
      background-color: $--tree-node-hover-background-color;
    }

    .el-tree.is-dragging & {
      cursor: move;

      & * {
        pointer-events: none;
      }
    }

    .el-tree.is-dragging.is-drop-not-allow & {
      cursor: not-allowed;
    }
  }

  @include e(expand-icon) {
    cursor: pointer;
    color: $--tree-expand-icon-color;
    font-size: 12px;

    transform: rotate(0deg);
    transition: transform 0.3s ease-in-out;

    &.expanded {
      transform: rotate(90deg);
    }

    &.is-leaf {
      color: transparent;
      cursor: default;
    }
  }

  @include e(label) {
    font-size: $--font-size-base;
  }

  @include e(loading-icon) {
    margin-right: 8px;
    font-size: $--font-size-base;
    color: $--tree-expand-icon-color;
  }

  & > .el-tree-node__children {
    overflow: hidden;
    background-color: transparent;
  }

  &.is-expanded > .el-tree-node__children {
    display: block;
  }
}

.el-tree--highlight-current .el-tree-node.is-current > .el-tree-node__content {
  background-color: mix($--color-white, $--color-primary, 92%);
}

.el-tree.is-yzw {
  .el-tree-node__content:hover,
  .el-tree-node:focus > .el-tree-node__content {
    background-color: transparent;
    color: $--color-primary;
    .el-tag--info {
      background-color: transparent;
      color: $--color-primary;
    }
  }
  .el-tree-node:focus > .el-tree-node__content {
    background-color: mix($--color-white, $--color-primary, 80%);
    color: $--color-primary;
  }
  .el-tree-node__expand-icon.expanded.customIcon {
    transform: rotate(0);
  }

  .el-tree-node__expand-icon {
    &.is-leaf {
      color: transparent;
    }
  }
  .el-tree-node__content {
    height: 30px;
  }
  .el-tree__empty-text {
    width: 100%;
  }
  .el-tree-node__label,
  .custom-tree-node {
    display: inline-flex;
    align-items: center;

    .el-tree-node__label-icon {
      display: inline-flex;
      margin-right: 8px;
    }
  }
  .el-tree-node__line {
    display: none;
  }
  .el-tree-node__expand-icon {
    padding: 10px 0;
    font-size: 10px;
    color: $--color-text-regular;
    margin-right: 8px;
    margin-left: 8px;
    width: 14px;
    z-index: 1;
    &:not(.customIcon)::before {
      content: "\e6d9";
      padding: 1px;
      border: 1px solid $--color-text-regular;
      background: #ffffff;
    }
    &.expanded {
      -webkit-transform: rotate(0deg);
      transform: rotate(0deg);
      &:not(.customIcon)::before {
        content: "\e6d8";
      }
    }
    &.customIcon {
      font-size: 16px;
      &::before{
        position: relative;
        z-index: 1;
      }
      
    }
    &.is-leaf {
      color: transparent;
      &::before {
        background: none;
        border-color: transparent;
      }
      &::after {
        width: 16px;
      }
    }
  }
  &.tree-line {
    & > .el-tree-node {
      &.is-first > .el-tree-node__content > .el-tree-node__label::before {
        top: 50%;
        height: 15px;
      }
      &.is-first > .el-tree-node__content > .custom-tree-node::before {
        top: 50%;
        height: 15px;
      }
      &.is-first.is-last
        > .el-tree-node__content
        > .el-tree-node__label::before {
        display: none;
      }
      &.is-first.is-last > .el-tree-node__content > .custom-tree-node::before {
        display: none;
      }
      &.is-last
        > .el-tree-node__children
        > .el-tree-node
        > .el-tree-node__line {
        display: none;
      }
    }
    .el-tree-node {
      position: relative;
      &.is-last {
        &.is-expanded {
          & > .el-tree-node__children > .el-tree-node > .el-tree-node__line {
            display: none;
          }
        }
        & > .el-tree-node__content > .el-tree-node__label::before {
          bottom: 50%;
          height: 15px;
        }
        & > .el-tree-node__content > .custom-tree-node::before {
          bottom: 50%;
          height: 15px;
        }
      }
    }
    .el-tree-node__line {
      position: absolute;
      left: 0;
      top: 0;
      display: inline-block;
      width: 1px;
      height: 100%;
      border-left: 1px dotted $--border-color-base;
      box-sizing: border-box;
      z-index: 1;
      margin-left: -8px;
    }
    .el-tree-node__label,
    .custom-tree-node {
      position: relative;
      &::before {
        content: "";
        position: absolute;
        left: -16px;
        display: inline-block;
        width: 1px;
        height: 30px;
        border-left: 1px dotted $--border-color-base;
        box-sizing: border-box;
      }
    }
    .el-checkbox + .el-tree-node__label,
    .el-checkbox + .custom-tree-node {
      &::before {
        left: -38px;
      }
    }
    .el-tree-node__expand-icon {
      &.is-leaf {
        color: transparent;
        &::before {
          background: none;
          border-color: transparent;
        }
        &::after {
          width: 16px;
        }
      }
      &::after {
        content: "";
        position: absolute;
        top: 50%;
        right: -8px;
        margin-top: -0.5px;
        display: inline-block;
        width: 8px;
        height: 1px;
        border-bottom: 1px dotted $--border-color-base;
        box-sizing: border-box;
      }
    }
  }
}
