text: import { __decorate } from "tslib";
  import { Component, EventEmitter, Input, Output } from '@angular/core';
  import { PromotionLocation } from '@spartacus/core';
  import { PromotionService } from '../../../../shared/services/promotion/promotion.service';
  var CartItemComponent = /** @class */ (function () {
      function CartItemComponent(promotionService) {
          this.promotionService = promotionService;
          this.compact = false;
          this.readonly = false;
          this.view = new EventEmitter();
          this.promotionLocation = PromotionLocation.ActiveCart;
          // TODO: evaluate whether this is generic enough
          this.options = {
              isSaveForLater: false,
              optionalBtn: null,
          };
      }
      CartItemComponent.prototype.ngOnInit = function () {
          this.appliedProductPromotions$ = this.promotionService.getProductPromotionForEntry(this.item, this.promotionLocation);
      };
      CartItemComponent.prototype.isProductOutOfStock = function (product) {
          // TODO Move stocklevelstatuses across the app to an enum
          return (product &&
              product.stock &&
              product.stock.stockLevelStatus === 'outOfStock');
      };
      CartItemComponent.prototype.removeItem = function () {
          this.quantityControl.setValue(0);
          this.quantityControl.markAsDirty();
      };
      CartItemComponent.prototype.viewItem = function () {
          this.view.emit();
      };
      CartItemComponent.ctorParameters = function () { return [
          { type: PromotionService }
      ]; };
      __decorate([
          Input()
      ], CartItemComponent.prototype, "compact", void 0);
      __decorate([
          Input()
      ], CartItemComponent.prototype, "item", void 0);
      __decorate([
          Input()
      ], CartItemComponent.prototype, "readonly", void 0);
      __decorate([
          Input()
      ], CartItemComponent.prototype, "quantityControl", void 0);
      __decorate([
          Output()
      ], CartItemComponent.prototype, "view", void 0);
      __decorate([
          Input()
      ], CartItemComponent.prototype, "promotionLocation", void 0);
      __decorate([
          Input()
      ], CartItemComponent.prototype, "options", void 0);
      CartItemComponent = __decorate([
          Component({
              selector: 'cx-cart-item',
              template: "<div [ngClass]=\"compact ? 'cx-compact row' : 'row'\">\r\n  <!-- Item Image -->\r\n  <div class=\"col-2 cx-image-container\">\r\n    <a\r\n      [routerLink]=\"{ cxRoute: 'product', params: item.product } | cxUrl\"\r\n      (click)=\"viewItem()\"\r\n      tabindex=\"-1\"\r\n    >\r\n      <cx-media [container]=\"item.product.images?.PRIMARY\"></cx-media>\r\n    </a>\r\n  </div>\r\n  <!-- Item Information -->\r\n  <div class=\"cx-info col-10\">\r\n    <div class=\"cx-info-container row\">\r\n      <!-- Item Description -->\r\n      <div [ngClass]=\"compact ? '' : ' col-md-3 col-lg-3 col-xl-5'\">\r\n        <div *ngIf=\"item.product.name\" class=\"cx-name\">\r\n          <a\r\n            class=\"cx-link\"\r\n            [routerLink]=\"{ cxRoute: 'product', params: item.product } | cxUrl\"\r\n            (click)=\"viewItem()\"\r\n            >{{ item.product.name }}</a\r\n          >\r\n        </div>\r\n        <div *ngIf=\"item.product.code\" class=\"cx-code\">\r\n          {{ 'cartItems.id' | cxTranslate }} {{ item.product.code }}\r\n        </div>\r\n        <!-- Variants -->\r\n        <ng-container *ngIf=\"item.product.baseOptions?.length\">\r\n          <div\r\n            *ngFor=\"\r\n              let variant of item.product.baseOptions[0]?.selected\r\n                ?.variantOptionQualifiers\r\n            \"\r\n            class=\"cx-property\"\r\n          >\r\n            <div class=\"cx-label\" *ngIf=\"variant.name && variant.value\">\r\n              {{ variant.name }}: {{ variant.value }}\r\n            </div>\r\n          </div>\r\n        </ng-container>\r\n      </div>\r\n      <!-- Item Price -->\r\n      <div\r\n        *ngIf=\"item.basePrice\"\r\n        class=\"cx-price\"\r\n        [ngClass]=\"compact ? '' : ' col-md-3 col-lg-3 col-xl-2'\"\r\n      >\r\n        <div\r\n          class=\"cx-label\"\r\n          [ngClass]=\"compact ? '' : ' d-block d-md-none d-lg-none d-xl-none'\"\r\n        >\r\n          {{ 'cartItems.itemPrice' | cxTranslate }}\r\n        </div>\r\n        <div *ngIf=\"item.basePrice\" class=\"cx-value\">\r\n          {{ item.basePrice?.formattedValue }}\r\n        </div>\r\n      </div>\r\n      <!-- Item Quantity -->\r\n      <div class=\"cx-quantity\" [ngClass]=\"compact ? '' : ' col-3'\">\r\n        <div\r\n          class=\"cx-label\"\r\n          [ngClass]=\"compact ? '' : ' d-block d-md-none d-lg-none d-xl-none'\"\r\n          placement=\"left\"\r\n          title=\"{{ 'cartItems.quantityTitle' | cxTranslate }}\"\r\n        >\r\n          {{ 'cartItems.quantity' | cxTranslate }}\r\n        </div>\r\n        <div class=\"cx-value\">\r\n          <cx-item-counter\r\n            [control]=\"quantityControl\"\r\n            [readonly]=\"!item.updateable || readonly || options.isSaveForLater\"\r\n            [max]=\"item.product.stock?.stockLevel || 1000\"\r\n            [allowZero]=\"true\"\r\n          >\r\n          </cx-item-counter>\r\n        </div>\r\n      </div>\r\n      <!-- Total -->\r\n      <ng-container *ngIf=\"options.isSaveForLater; else total\">\r\n        <div\r\n          class=\"cx-total\"\r\n          [ngClass]=\"compact ? '' : ' col-md-3 col-lg-3 col-xl-2'\"\r\n        >\r\n          <div\r\n            class=\"cx-label\"\r\n            [ngClass]=\"compact ? '' : ' d-block d-md-none d-lg-none d-xl-none'\"\r\n          >\r\n            {{ 'saveForLaterItems.stock' | cxTranslate }}\r\n          </div>\r\n          <div\r\n            *ngIf=\"item.product?.stock?.stockLevel >= 0; else forceInstock\"\r\n            class=\"cx-value\"\r\n          >\r\n            {{ item.product.stock.stockLevel }}\r\n          </div>\r\n          <ng-template #forceInstock\r\n            ><div class=\"cx-value\">\r\n              {{ 'saveForLaterItems.forceInStock' | cxTranslate }}\r\n            </div></ng-template\r\n          >\r\n        </div>\r\n      </ng-container>\r\n    </div>\r\n    <!-- Availability -->\r\n    <div\r\n      *ngIf=\"isProductOutOfStock(item.product)\"\r\n      class=\"cx-availability col-12\"\r\n    >\r\n      {{ 'productSummary.outOfStock' | cxTranslate }}\r\n    </div>\r\n    <!-- Promotion -->\r\n\r\n    <ng-container\r\n      *ngIf=\"appliedProductPromotions$ | async as appliedProductPromotions\"\r\n    >\r\n      <cx-promotions [promotions]=\"appliedProductPromotions\"></cx-promotions>\r\n    </ng-container>\r\n\r\n    <!-- Actions -->\r\n    <div\r\n      *ngIf=\"(!readonly || options.isSaveForLater) && item.updateable\"\r\n      class=\"cx-actions col-12\"\r\n    >\r\n      <ng-container *ngIf=\"!isProductOutOfStock(item.product)\">\r\n        <ng-container\r\n          *ngTemplateOutlet=\"\r\n            options.optionalBtn;\r\n            context: {\r\n              $implicit: { loading: quantityControl.disabled, item: item }\r\n            }\r\n          \"\r\n        ></ng-container>\r\n      </ng-container>\r\n\r\n      <div class=\"col-md-3 cx-remove-btn\">\r\n        <button\r\n          class=\"link cx-action-link\"\r\n          [disabled]=\"quantityControl.disabled\"\r\n          (click)=\"removeItem()\"\r\n        >\r\n          {{ 'common.remove' | cxTranslate }}\r\n        </button>\r\n      </div>\r\n    </div>\r\n  </div>\r\n</div>\r\n\r\n<ng-template #total>\r\n  <div\r\n    *ngIf=\"item.totalPrice\"\r\n    class=\"cx-total\"\r\n    [ngClass]=\"compact ? '' : ' col-md-3 col-xl-2'\"\r\n  >\r\n    <div\r\n      class=\"cx-label\"\r\n      [ngClass]=\"compact ? '' : ' d-block d-md-none d-lg-none d-xl-none'\"\r\n    >\r\n      {{ 'cartItems.total' | cxTranslate }}\r\n    </div>\r\n    <div class=\"cx-value\">{{ item.totalPrice.formattedValue }}</div>\r\n  </div>\r\n</ng-template>\r\n"
          })
      ], CartItemComponent);
      return CartItemComponent;
  }());
  export { CartItemComponent };
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2FydC1pdGVtLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BzcGFydGFjdXMvc3RvcmVmcm9udC8iLCJzb3VyY2VzIjpbImNtcy1jb21wb25lbnRzL2NhcnQvY2FydC1zaGFyZWQvY2FydC1pdGVtL2NhcnQtaXRlbS5jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLE9BQU8sRUFBRSxTQUFTLEVBQUUsWUFBWSxFQUFFLEtBQUssRUFBVSxNQUFNLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFFL0UsT0FBTyxFQUFFLGlCQUFpQ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