import { css, LitElement, html } from "lit";
import { property } from "lit/decorators.js";
import { WatchCircleType } from "../watch/watch.js";
import { TickmarkType } from "../watch/tickmark.js";
import { AdviceState, AdviceType } from "../watch/advice.js";
import { customElement } from "../../decorator.js";
import { Priority } from "../types.js";
import { VesselImage, VesselImageSize } from "../watch/vessel.js";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __decorateClass = (decorators, target, key, kind) => {
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
    if (decorator = decorators[i])
      result = (kind ? decorator(target, key, result) : decorator(result)) || result;
  if (kind && result) __defProp(target, key, result);
  return result;
};
var PitchRollPriorityElement = /* @__PURE__ */ ((PitchRollPriorityElement2) => {
  PitchRollPriorityElement2["pitch"] = "pitch";
  PitchRollPriorityElement2["roll"] = "roll";
  return PitchRollPriorityElement2;
})(PitchRollPriorityElement || {});
let ObcPitchRoll = class extends LitElement {
  constructor() {
    super(...arguments);
    this.pitch = 0;
    this.roll = 0;
    this.minAvgPitch = 0;
    this.maxAvgPitch = 0;
    this.minAvgRoll = 0;
    this.maxAvgRoll = 0;
    this.vesselImageFore = VesselImage.psvFore;
    this.vesselImageSide = VesselImage.psvSide;
    this.maxPitchAdvice = void 0;
    this.maxRollAdvice = void 0;
    this.triggerPitchAdvice = false;
    this.triggerRollAdvice = false;
    this.priority = Priority.regular;
    this.priorityElements = [
      "pitch",
      "roll"
      /* roll */
    ];
  }
  priorityFor(element) {
    const selected = Array.isArray(this.priorityElements) ? this.priorityElements : [];
    return selected.includes(element) ? this.priority : Priority.regular;
  }
  needleColor(element) {
    return this.priorityFor(element) === Priority.enhanced ? "var(--instrument-enhanced-secondary-color)" : "var(--instrument-regular-secondary-color)";
  }
  barColor(element) {
    return this.priorityFor(element) === Priority.enhanced ? "var(--instrument-enhanced-tertiary-color)" : "var(--instrument-regular-tertiary-color)";
  }
  render() {
    return html`
      <div class="container">
        <svg viewBox="-200 -200 400 400">
          <line
            x1="-150"
            y1="0"
            x2="150"
            y2="0"
            stroke="var(--instrument-frame-tertiary-color)"
          />
        </svg>
        <obc-watch
          .watchCircleType=${WatchCircleType.double}
          .areas=${[
      {
        startAngle: 60,
        endAngle: 120,
        roundOutsideCut: true,
        roundInsideCut: true
      },
      {
        startAngle: 240,
        endAngle: 300,
        roundOutsideCut: true,
        roundInsideCut: true
      },
      {
        startAngle: 315,
        endAngle: 45,
        roundOutsideCut: true,
        roundInsideCut: true
      },
      {
        startAngle: 135,
        endAngle: 225,
        roundOutsideCut: true,
        roundInsideCut: true
      }
    ]}
          .barAreas=${[
      {
        startAngle: this.minAvgRoll,
        endAngle: this.maxAvgRoll,
        fillColor: this.barColor(
          "roll"
          /* roll */
        )
      },
      {
        startAngle: 180 + this.minAvgRoll,
        endAngle: 180 + this.maxAvgRoll,
        fillColor: this.barColor(
          "roll"
          /* roll */
        )
      },
      {
        startAngle: 90 + this.minAvgPitch,
        endAngle: 90 + this.maxAvgPitch,
        fillColor: this.barColor(
          "pitch"
          /* pitch */
        )
      },
      {
        startAngle: 270 + this.minAvgPitch,
        endAngle: 270 + this.maxAvgPitch,
        fillColor: this.barColor(
          "pitch"
          /* pitch */
        )
      }
    ]}
          .needles=${[
      {
        angle: this.roll,
        fillColor: this.needleColor(
          "roll"
          /* roll */
        ),
        strokeColor: "var(--border-silhouette-color)"
      },
      {
        angle: 180 + this.roll,
        fillColor: this.needleColor(
          "roll"
          /* roll */
        ),
        strokeColor: "var(--border-silhouette-color)"
      },
      {
        angle: 90 + this.pitch,
        fillColor: this.needleColor(
          "pitch"
          /* pitch */
        ),
        strokeColor: "var(--border-silhouette-color)"
      },
      {
        angle: 270 + this.pitch,
        fillColor: this.needleColor(
          "pitch"
          /* pitch */
        ),
        strokeColor: "var(--border-silhouette-color)"
      }
    ]}
          .vessels=${[
      {
        size: VesselImageSize.large,
        vesselImage: this.vesselImageSide,
        transform: `rotate(${this.pitch}deg)`
      },
      {
        size: VesselImageSize.large,
        vesselImage: this.vesselImageFore,
        transform: `rotate(${this.roll}deg)`
      }
    ]}
          .tickmarks=${[
      {
        angle: 0,
        type: TickmarkType.main
      },
      {
        angle: 90,
        type: TickmarkType.main
      },
      {
        angle: 180,
        type: TickmarkType.main
      },
      {
        angle: 270,
        type: TickmarkType.main
      }
    ]}
          .advices=${this.advices}
        ></obc-watch>
      </div>
    `;
  }
  get advices() {
    const advices = [];
    if (this.maxPitchAdvice !== void 0) {
      const state = this.triggerPitchAdvice ? AdviceState.triggered : AdviceState.regular;
      advices.push({
        minAngle: 60,
        maxAngle: 90 - this.maxPitchAdvice,
        type: AdviceType.caution,
        state,
        hideMinTickmark: true
      });
      advices.push({
        minAngle: 90 + this.maxPitchAdvice,
        maxAngle: 120,
        type: AdviceType.caution,
        state,
        hideMaxTickmark: true
      });
      advices.push({
        minAngle: 240,
        maxAngle: 270 - this.maxPitchAdvice,
        type: AdviceType.caution,
        state,
        hideMinTickmark: true
      });
      advices.push({
        minAngle: 270 + this.maxPitchAdvice,
        maxAngle: 300,
        type: AdviceType.caution,
        state,
        hideMaxTickmark: true
      });
    }
    if (this.maxRollAdvice !== void 0) {
      const state = this.triggerRollAdvice ? AdviceState.triggered : AdviceState.regular;
      advices.push({
        minAngle: -45,
        maxAngle: -this.maxRollAdvice,
        type: AdviceType.caution,
        state,
        hideMinTickmark: true
      });
      advices.push({
        minAngle: this.maxRollAdvice,
        maxAngle: 45,
        type: AdviceType.caution,
        state,
        hideMaxTickmark: true
      });
      advices.push({
        minAngle: 135,
        maxAngle: 180 - this.maxRollAdvice,
        type: AdviceType.caution,
        state,
        hideMinTickmark: true
      });
      advices.push({
        minAngle: 180 + this.maxRollAdvice,
        maxAngle: 225,
        type: AdviceType.caution,
        state,
        hideMaxTickmark: true
      });
    }
    return advices;
  }
};
ObcPitchRoll.styles = css`
    * {
      box-sizing: border-box;
    }

    .container {
      position: relative;
      width: 100%;
      height: 100%;
    }

    .container > * {
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
    }
  `;
__decorateClass([
  property({ type: Number })
], ObcPitchRoll.prototype, "pitch", 2);
__decorateClass([
  property({ type: Number })
], ObcPitchRoll.prototype, "roll", 2);
__decorateClass([
  property({ type: Number })
], ObcPitchRoll.prototype, "minAvgPitch", 2);
__decorateClass([
  property({ type: Number })
], ObcPitchRoll.prototype, "maxAvgPitch", 2);
__decorateClass([
  property({ type: Number })
], ObcPitchRoll.prototype, "minAvgRoll", 2);
__decorateClass([
  property({ type: Number })
], ObcPitchRoll.prototype, "maxAvgRoll", 2);
__decorateClass([
  property({ type: String })
], ObcPitchRoll.prototype, "vesselImageFore", 2);
__decorateClass([
  property({ type: String })
], ObcPitchRoll.prototype, "vesselImageSide", 2);
__decorateClass([
  property({ type: Number })
], ObcPitchRoll.prototype, "maxPitchAdvice", 2);
__decorateClass([
  property({ type: Number })
], ObcPitchRoll.prototype, "maxRollAdvice", 2);
__decorateClass([
  property({ type: Boolean })
], ObcPitchRoll.prototype, "triggerPitchAdvice", 2);
__decorateClass([
  property({ type: Boolean })
], ObcPitchRoll.prototype, "triggerRollAdvice", 2);
__decorateClass([
  property({ type: String })
], ObcPitchRoll.prototype, "priority", 2);
__decorateClass([
  property({ type: Array, attribute: false })
], ObcPitchRoll.prototype, "priorityElements", 2);
ObcPitchRoll = __decorateClass([
  customElement("obc-pitch-roll")
], ObcPitchRoll);
export {
  ObcPitchRoll,
  PitchRollPriorityElement
};
//# sourceMappingURL=pitch-roll.js.map
