{"version":3,"file":"Shipping.js","sources":["requirejs/Shipping.js"],"sourcesContent":["define([\"require\", \"exports\", \"jquery\", \"knockout\", \"UI/Context\", \"moment-timezone\"], function (require, exports, $, ko, ctx, moment) {\n \"use strict\";\n Object.defineProperty(exports, \"__esModule\", { value: true });\n exports.ShipToAccountViewModel = exports.Shipment = exports.ShipmentContainer = void 0;\n class ShipmentContainer {\n constructor(data) {\n this.UpdateShipmentsByShipCompleteMethod = (cartItems) => {\n var currentShipmentMethods = ko.utils.arrayMap(this.Shipments(), shipment => {\n return { Items: ko.utils.arrayMap(shipment.CartItems(), ci => ci.Id()), ShippingMethod: shipment.ShippingMethod(), IsSaturdayDelivery: shipment.IsSaturdayDelivery() };\n });\n const singleItemShipments = this.Shipments().filter(shipment => shipment.ContainsSingleShipmentItems());\n const singleShipmentItems = cartItems.filter(cartItem => !!~singleItemShipments.indexOf(cartItem.Shipment()));\n this.Shipments([]);\n var shipments = [];\n cartItems.sort((a, b) => {\n var d1 = a.EstShipDate();\n var d2 = b.EstShipDate();\n if (d1 == null)\n return 1;\n if (d2 == null)\n return -1;\n if (d1.toDateString() == d2.toDateString())\n return 0;\n return d1.getTime() > d2.getTime() ? 1 : -1;\n });\n cartItems = cartItems.filter(cartItem => !~singleShipmentItems.indexOf(cartItem));\n switch (this.ShipCompleteMethod()) {\n case \"Individual\":\n ko.utils.arrayForEach(cartItems, ci => {\n var ship = ko.utils.arrayFirst(shipments, shipment => shipment.CanShip(ci) && shipment.ShipsOnSameDayAs(ci));\n if (ship != null) {\n ship.CartItems.push(ci);\n }\n else {\n ship = new Shipment({\n CartItems: [ci],\n ShipSetCode: \"SC\" + (shipments.length + 1)\n }, this);\n shipments.push(ship);\n }\n });\n break;\n case \"ShipComplete\":\n var expeditedItems = ko.utils.arrayFilter(cartItems, ci => {\n var date = ci.EstShipDate();\n return ci.IsExpedited() && date != null;\n });\n var anyExpeditedItems = expeditedItems.length > 0;\n if (!anyExpeditedItems || this.UndoAllExpeditedItems()) {\n shipments.push(new Shipment({\n CartItems: cartItems,\n ShipSetCode: \"SC\" + (shipments.length + 1)\n }, this));\n }\n else {\n var nonExpeditedItems = ko.utils.arrayFilter(cartItems, ci => $.inArray(ci, expeditedItems) == -1).reverse();\n ko.utils.arrayForEach(expeditedItems, ci => {\n var shipment = ko.utils.arrayFirst(shipments, shipment => shipment.CanShip(ci) && (shipment.ShipsOnSameDayAs(ci) || shipment.EstimatedShipDate() == null));\n if (shipment != null) {\n shipment.CartItems.push(ci);\n }\n else {\n shipments.push(new Shipment({\n CartItems: [ci],\n ShipSetCode: \"SC\" + (shipments.length + 1)\n }, this));\n }\n });\n var sc_itemsNotPairedUpWithExpeditedShipments = new Array();\n ko.utils.arrayForEach(nonExpeditedItems, ci => {\n var shipment = ko.utils.arrayFirst(shipments, shipment => shipment.CanShip(ci));\n if (shipment != null) {\n shipment.CartItems.push(ci);\n }\n else {\n sc_itemsNotPairedUpWithExpeditedShipments.push(ci);\n }\n });\n if (sc_itemsNotPairedUpWithExpeditedShipments.length > 0)\n shipments.push(new Shipment({\n CartItems: sc_itemsNotPairedUpWithExpeditedShipments,\n ShipSetCode: \"SC\" + (shipments.length + 1)\n }, this));\n }\n break;\n case \"PartialShipComplete\":\n var co = this.OrderCutOffDate();\n var firstShipmentCartItems = ko.utils.arrayFilter(cartItems, ci => {\n var date = ci.EstShipDate();\n if (date == null) {\n return false;\n }\n if (ci.ShipmentGroupingRestriction() == 'GROUND-ONLY'\n && (currentShipmentMethods.length == 0 || currentShipmentMethods[0].ShippingMethod == null || !currentShipmentMethods[0].ShippingMethod.IsGround)) {\n return false;\n }\n return date.toDateString() == co.toDateString();\n });\n ko.utils.arrayForEach(firstShipmentCartItems, ci => {\n var shipment = ko.utils.arrayFirst(shipments, shipment => shipment.CanShip(ci));\n if (shipment != null) {\n shipment.CartItems.push(ci);\n }\n else {\n shipments.push(new Shipment({\n CartItems: [ci],\n ShipSetCode: \"SC\" + (shipments.length + 1)\n }, this));\n }\n });\n var secondShipmentItems = ko.utils.arrayFilter(cartItems, ci => $.inArray(ci, firstShipmentCartItems) == -1).reverse();\n if (!this.UndoAllExpeditedItems()) {\n var expeditedItems = ko.utils.arrayFilter(secondShipmentItems, item => item.IsExpedited());\n ko.utils.arrayForEach(expeditedItems, ci => {\n var shipment = ko.utils.arrayFirst(shipments, shipment => shipment.CanShip(ci) &&\n (shipment.ShipsAfter(ci) ||\n shipment.ShipsOnSameDayAs(ci) ||\n shipment.EstimatedShipDate() == null));\n if (shipment != null) {\n shipment.CartItems.push(ci);\n }\n else {\n shipments.push(new Shipment({\n CartItems: [ci],\n ShipSetCode: \"SC\" + (shipments.length + 1)\n }, this));\n }\n });\n var possiblyThirdShipmentItems = ko.utils\n .arrayFilter(secondShipmentItems, ci => $.inArray(ci, expeditedItems) == -1).reverse();\n var elligibleShipments = [];\n ko.utils.arrayForEach(shipments, x => {\n if (firstShipmentCartItems.length == 0 || x != shipments[0]) {\n elligibleShipments.push(x);\n }\n });\n var p_itemsNotPairedUpWithExpeditedShipments = new Array();\n ko.utils.arrayForEach(possiblyThirdShipmentItems, ci => {\n var shipment = ko.utils.arrayFirst(elligibleShipments, shipment => shipment.CanShip(ci) &&\n (shipment.ShipsAfter(ci) ||\n shipment.ShipsOnSameDayAs(ci) ||\n shipment.EstimatedShipDate() == null));\n if (shipment != null) {\n shipment.CartItems.push(ci);\n }\n else {\n p_itemsNotPairedUpWithExpeditedShipments.push(ci);\n }\n });\n if (p_itemsNotPairedUpWithExpeditedShipments.length > 0)\n shipments.push(new Shipment({\n CartItems: p_itemsNotPairedUpWithExpeditedShipments,\n ShipSetCode: \"SC\" + (shipments.length + 1)\n }, this));\n }\n else if (secondShipmentItems.length > 0) {\n shipments.push(new Shipment({\n CartItems: secondShipmentItems,\n ShipSetCode: \"SC\" + (shipments.length + 1)\n }, this));\n }\n break;\n }\n for (let singleShipmentItem of singleShipmentItems) {\n shipments.push(new Shipment({\n CartItems: [singleShipmentItem],\n ShipSetCode: \"SC\" + (shipments.length + 1),\n ContainsSingleShipmentItems: true\n }, this));\n }\n if (currentShipmentMethods.length > 0) {\n ko.utils.arrayForEach(shipments, shipment => {\n var ci = shipment.CartItems().sort((a, b) => {\n if (a.EstShipDate() == null && b.EstShipDate() == null)\n return $.inArray(a, shipment.CartItems()) > $.inArray(b, shipment.CartItems()) ? 1 : -1;\n if (a.EstShipDate() == null)\n return 1;\n if (b.EstShipDate() == null)\n return -1;\n if (a.EstShipDate().toDateString() == b.EstShipDate().toDateString())\n return $.inArray(a, shipment.CartItems()) > $.inArray(b, shipment.CartItems()) ? 1 : -1;\n return a.EstShipDate() > b.EstShipDate() ? 1 : -1;\n })[0];\n var cs = ko.utils.arrayFirst(currentShipmentMethods, csm => $.inArray(ci.Id(), csm.Items) != -1);\n if (cs) {\n shipment.ShippingMethod(cs.ShippingMethod);\n shipment.IsSaturdayDelivery(cs.IsSaturdayDelivery);\n }\n });\n }\n this.Shipments(shipments);\n };\n this.OnShippingOptionsResponse = data.OnShippingOptionsResponse;\n this.GetOrderedShipments = data.GetOrderedShipments;\n this.GetShipmentsObservable = data.GetShipmentsObservable;\n this.GetDropShip = data.GetDropShip;\n this.GetShipToAccountNumber = data.GetShipToAccountNumber;\n this.GetShippingPromoCode = data.GetShippingPromoCode;\n this.GetPaymentMethod = data.GetPaymentMethod;\n this.GetOracleLocationId = data.GetOracleLocationId;\n this.GetIsPickupLocation = data.GetIsPickupLocation;\n this.Shipments = data.Shipments;\n this.ShipCompleteMethod = data.ShipCompleteMethod;\n this.OrderCutOffDate = data.OrderCutOffDate;\n this.UndoAllExpeditedItems = data.UndoAllExpeditedItems;\n this.CartType = data.CartType;\n this.CartSessionId = data.CartSessionId;\n this.GetStullerPayTermsOptions = data.GetStullerPayTermsOptions;\n }\n }\n exports.ShipmentContainer = ShipmentContainer;\n class Shipment {\n constructor(data, parent) {\n this.ShippingOptionsUrl = '/checkout/shipping/';\n this.MapShippingResponse = (value) => {\n if (value != null) {\n ko.utils.arrayForEach(value.GroupedShippingOptions, gso => ko.utils.arrayForEach(gso.ShippingOptions, so => so.UniqueCarrierName = so.ServiceLevel + '|' +\n (so.IsGround == null ? 'NULL' : so.IsGround.toString()) + '|' + so.IsSaturday.toString()));\n }\n };\n this.FindShippingOption = (response) => {\n return Shipment.FindShippingOption(response, this.ShippingMethod(), this.IsSaturdayDelivery());\n };\n this.LoadShipping = (fetchSingleMethodOnly, preserveCurrentShippingMethod) => {\n if (fetchSingleMethodOnly && this.ShippingMethod() == null)\n return;\n if (this.CartItems().length == 0) {\n this.ShippingOptionsResponse(null);\n return;\n }\n this.DoLoadShippingOptions(fetchSingleMethodOnly, preserveCurrentShippingMethod);\n };\n this.LoadEstimateForShippingMethod = () => {\n this.LoadShipping(true, true);\n };\n this.LoadShippingOptions = (preserveCurrentShippingMethod) => {\n this.LoadShipping(false, preserveCurrentShippingMethod);\n };\n this.DoLoadShippingOptions = (fetchSingleMethodOnly, preserveCurrentShippingMethod, items) => {\n this.ShippingOptionsLoading(true);\n var data = this.GetShippingRequestData(fetchSingleMethodOnly, preserveCurrentShippingMethod, items);\n if (data.request.cartDetails.length === 0 || data.request.paymentMethod === \"\" || data.request.paymentMethod === null) {\n this.ShippingOptionsLoading(false);\n return;\n }\n var serializeData = JSON.stringify(data);\n $.ajax({\n type: \"POST\",\n url: this.ShippingOptionsUrl,\n data: serializeData,\n contentType: \"application/json\",\n dataType: \"json\"\n }).done((response) => {\n if (serializeData === JSON.stringify(this.GetShippingRequestData(fetchSingleMethodOnly, preserveCurrentShippingMethod, items))) {\n this.ShippingOptionsLoading(false);\n this.ShippingOptionsResponse(response);\n }\n });\n };\n this.HasAnyExpeditedItems = () => {\n return ko.utils.arrayFirst(this.CartItems(), cartItem => cartItem.IsExpedited()) != null;\n };\n this.CanShip = (cartItem) => {\n var shipmentShipsAfterCartItem = this.ShipsAfter(cartItem);\n var shipmentShipsBeforeCartItem = this.ShipsBefore(cartItem);\n if ((this.HasAnyExpeditedItems() && shipmentShipsBeforeCartItem) || (cartItem.IsExpedited() && shipmentShipsAfterCartItem)) {\n return false;\n }\n if (this.ShipmentGroupingRestriction() == cartItem.ShipmentGroupingRestriction() || cartItem.ShipmentGroupingRestriction() == null) {\n return true;\n }\n if (this.ShippingMethod() == null)\n return true;\n if (this.ShipmentGroupingRestriction() != null)\n return false;\n if (this.ShippingMethod().IsGround == null)\n return true;\n if (this.ShippingMethod().IsGround && cartItem.ShipmentGroupingRestriction() == 'GROUND-ONLY')\n return true;\n if (!this.ShippingMethod().IsGround && cartItem.ShipmentGroupingRestriction() == 'AIR-ONLY')\n return true;\n return false;\n };\n this.ShipsBefore = (cartItem) => {\n return !this.ShipsAfter(cartItem) && !this.ShipsOnSameDayAs(cartItem);\n };\n this.ShipsOnSameDayAs = (cartItem) => {\n if (this.EstimatedShipDate() == null)\n return null;\n if (cartItem.EstShipDate() == null)\n return null;\n return cartItem.EstShipDate().toDateString() == this.EstimatedShipDate().toDateString();\n };\n this.ShipsAfter = (cartItem) => {\n if (this.EstimatedShipDate() == null)\n return null;\n if (cartItem.EstShipDate() == null)\n return null;\n if (this.EstimatedShipDate().toDateString() == cartItem.EstShipDate().toDateString())\n return false;\n return this.EstimatedShipDate().getTime() > cartItem.EstShipDate().getTime();\n };\n this.GetNextShipSetCode = (shipmentContainer) => {\n var shipments = shipmentContainer.GetOrderedShipments();\n if (shipments == null)\n return null;\n if (shipments.length == 0)\n return \"SC1\";\n var getMaxIndex = () => {\n var values = ko.utils.arrayMap(ko.utils.arrayFilter(shipments, shipment => shipment.ShipSetCode() != null), shipment => parseInt(shipment.ShipSetCode().replace('SC', '')));\n var index = Math.max.apply(null, values) + 1;\n return index;\n };\n ko.utils.arrayForEach(shipments, shipment => {\n if (shipment.ShipSetCode() == null) {\n shipment.ShipSetCode(\"SC\" + getMaxIndex());\n }\n });\n return \"SC\" + getMaxIndex();\n };\n this.MapShipmentToOrderShipment = () => {\n var shipment = this;\n var dto = ko.mapping.toJS(shipment);\n delete dto.ShippingOptionsResponse;\n delete dto.ShippingWarnings;\n dto.CartItems = ko.utils.arrayMap(shipment.CartItems(), ci => ci.Id());\n return dto;\n };\n this.Context = ctx.default;\n this.Parent = parent;\n data = $.extend({\n EstimatedDeliveryDate: null,\n EstimatedShipDate: null,\n QuotedShippingCharge: null,\n ShippingMethod: null,\n IsSaturdayDelivery: false,\n CartItems: [],\n ShippingWarnings: [],\n ShippingOptionsResponse: null,\n ShipSetCode: null,\n ContainsSingleShipmentItems: false\n }, data);\n if (data.ShipSetCode == null)\n data.ShipSetCode = this.GetNextShipSetCode(parent);\n ko.mapping.fromJS(data, {\n ignore: [\"CartItems\"],\n ShippingMethod: {\n create: opts => ko.observable(opts.data)\n }\n }, this);\n this.CartItems = ko.observableArray(data.CartItems);\n this.ShippingOptionsLoading = ko.observable(false);\n this.ShippingOptionsResponseObservable = ko.observable(null);\n this.ShippingOptionsResponse = ko.computed({\n read: () => this.ShippingOptionsResponseObservable(),\n write: value => {\n this.MapShippingResponse(value);\n this.ShippingOptionsResponseObservable(value);\n },\n owner: this\n });\n //without this, checkout breaks with error 'checkout.FirstInvalidStepIndex is not a function'. Perhaps when we update knockout this will not be necessary.\n this.ShippingOptionsResponse();\n this.ShippingOptionsResponse(data.ShippingOptionsResponse);\n this.ShippingOptionsResponse.subscribe(value => {\n if (this.ShippingMethod() == null || this.ShippingOptionsResponse() == null)\n return;\n var shippingOption = this.FindShippingOption(this.ShippingOptionsResponse());\n if (shippingOption == null) {\n this.ShippingMethod(null);\n this.IsSaturdayDelivery(false);\n }\n if (parent.OnShippingOptionsResponse != null) {\n parent.OnShippingOptionsResponse();\n }\n });\n this.EstimatedShipDate = ko.computed(() => {\n if (this.ShippingOptionsResponse() == null || this.ShippingOptionsResponse().ShipDate == null) {\n var filteredItems = ko.utils.arrayFilter(this.CartItems(), ci => ci.EstShipDate() != null);\n if (filteredItems.length > 0 &&\n ko.utils.arrayFirst(this.CartItems(), ci => ci.EstShipDate() == null) == null) {\n var items = ko.utils.arrayMap(filteredItems, ci => {\n return ci.EstShipDate().getTime();\n });\n var maxDateTime = Math.max.apply(null, items);\n return new Date(maxDateTime);\n }\n return null;\n }\n return new Date(this.ShippingOptionsResponse().ShipDate);\n }, this);\n this.EstimatedShipDateText = ko.computed(() => {\n if (this.ShippingOptionsResponse() == null) {\n if (this.EstimatedShipDate() != null) {\n return moment(this.EstimatedShipDate().toLocaleDateString(\"en-US\", { timeZone: \"America/Chicago\" })).locale(ctx.default.CurrentCultureName()).calendar(null, {\n sameDay: \"[Today]\",\n nextDay: \"dddd, MMMM D\",\n nextWeek: \"dddd, MMMM D\",\n sameElse: \"dddd, MMMM D\"\n });\n }\n return null;\n }\n return this.ShippingOptionsResponse().ShipDateString;\n }, this);\n this.MaxCartShipDateValue = ko.computed(() => {\n var date = null;\n $.each(this.CartItems(), (i, ci) => {\n if (ci.EstShipDate() == null) {\n date = null;\n return false;\n }\n if (date == null) {\n date = ci.EstShipDate();\n }\n else if (ci.EstShipDate().getTime() > date.getTime()) {\n date = ci.EstShipDate();\n }\n });\n return date;\n }, this);\n this.ShipmentGroupingRestriction = ko.computed(() => {\n var item = ko.utils.arrayFirst(this.CartItems(), ci => ci.ShipmentGroupingRestriction() != null);\n if (item == null)\n return null;\n return item.ShipmentGroupingRestriction();\n }, this);\n this.SelectedShippingOption = ko.computed(() => {\n if (this.ShippingOptionsResponse() == null)\n return null;\n this.ShippingWarnings.removeAll();\n return this.FindShippingOption(this.ShippingOptionsResponse());\n }, this);\n this.SelectedShippingOptionIcon = ko.computed(() => {\n var carrier = null;\n if (this.SelectedShippingOption() != null) {\n carrier = this.SelectedShippingOption().Carrier;\n }\n else if (this.ShippingMethod() != null) {\n carrier = this.ShippingMethod().Carrier;\n }\n if (carrier == null)\n return null;\n var icon = ko.utils.arrayFirst(this.ShippingIcons, x => x.Carrier == carrier.toLowerCase());\n if (icon == null)\n return null;\n return icon.Icon;\n }, this);\n this.UniqueCarrierName = ko.computed({\n write: value => {\n if (value == null) {\n this.ShippingMethod(null);\n this.IsSaturdayDelivery(false);\n return;\n }\n var parts = value.split('|');\n this.ShippingMethod({ Method: parts[0], IsGround: parts[1] == 'true' ? true : (parts[1] == 'false' ? false : null) });\n this.IsSaturdayDelivery(parts[2] == \"true\");\n },\n read: () => this.ShippingMethod() == null ? null : (this.ShippingMethod().Method + '|'\n + (this.ShippingMethod().IsGround == null ? \"NULL\" : this.ShippingMethod().IsGround.toString())\n + '|' + this.IsSaturdayDelivery().toString()),\n owner: this\n });\n this.EstimatedDeliveryDate = ko.computed(() => this.SelectedShippingOption() == null ? null : this.SelectedShippingOption().DeliveryDateDate, this);\n this.QuotedShippingCharge = ko.computed(() => this.SelectedShippingOption() == null ? null : this.SelectedShippingOption().Charge, this);\n this.ShipmentName = ko.computed(() => {\n var shipments = parent.GetOrderedShipments();\n if ($.inArray(this, shipments) == -1) {\n return \"Create New Shipment\";\n }\n return 'Shipment #' + ($.inArray(this, shipments) + 1).toString();\n }, this);\n this.CartItems.subscribe(value => {\n triggerCartUpdatedEvent();\n var restrictions = [];\n ko.utils.arrayForEach(this.CartItems(), ci => ko.utils.arrayForEach(ci.ShipMethodRestrictions() || [], r => {\n if (r != null)\n restrictions.push(r);\n }));\n this.ShippingWarnings(ko.utils.arrayGetDistinctValues(restrictions).sort());\n });\n this.ShippingMethodDescription = ko.computed(() => {\n if (this.SelectedShippingOption() != null) {\n return this.SelectedShippingOption().LongDescription;\n }\n if (this.ShippingMethod() != null)\n return this.ShippingMethod().Description;\n return null;\n }, this);\n this.ShipmentDescription = ko.computed(() => {\n var name = this.ShipmentName();\n if (name == \"Create New Shipment\")\n return name;\n if (this.EstimatedShipDate() == null) {\n return name;\n }\n return name + \" - Ships \" + moment(this.EstimatedShipDate().toLocaleDateString(\"en-US\", { timeZone: \"America/Chicago\" })).locale(ctx.default.CurrentCultureName())\n .calendar(null, {\n sameDay: \"[Today]\",\n nextDay: \"[Tomorrow]\",\n nextWeek: \"[on] dddd, MMMM D\",\n sameElse: \"[on] dddd, MMMM D\"\n });\n }, this);\n this.IsNewShipment = ko.computed(() => {\n return this.ShipmentDescription() == \"Create New Shipment\";\n }, this);\n this.ShippingOptionsResponseIsForMethodOnly = ko.computed(() => {\n if (this.ShippingOptionsResponse() == null || this.ShippingOptionsResponse().GroupedShippingOptions == null || this.ShippingOptionsResponse().GroupedShippingOptions.length == 0)\n return null;\n if (this.ShippingOptionsResponse().GroupedShippingOptions.length == 1 && this.ShippingOptionsResponse().GroupedShippingOptions[0].ShippingOptions.length == 1 && this.ShippingMethod() != null && this.ShippingOptionsResponse().GroupedShippingOptions[0].ShippingOptions[0].ServiceLevel == this.ShippingMethod().Method)\n return true;\n return false;\n }, this);\n this.ShippingMethod.subscribe((shippingMethod) => {\n if (this.Parent.CartType() == 'StullerPay')\n this.Parent.GetStullerPayTermsOptions(this.Parent.GetShipToAccountNumber(), shippingMethod === null || shippingMethod === void 0 ? void 0 : shippingMethod.Method);\n });\n }\n static FindShippingOption(response, shippingMethod, isSaturdayDelivery) {\n if (shippingMethod == null || shippingMethod.Method == null)\n return null;\n var shippingOption = null;\n ko.utils.arrayForEach(response.GroupedShippingOptions, gso => ko.utils.arrayForEach(gso.ShippingOptions, so => {\n if (so.ServiceLevel == shippingMethod.Method && so.IsSaturday == isSaturdayDelivery)\n shippingOption = so;\n }));\n return shippingOption;\n }\n GetShippingRequestData(fetchSingleMethodOnly, preserveCurrentShippingMethod, items) {\n items = this.CartItems().concat(items || []);\n var cartDetails = ko.utils.arrayMap(items, ci => {\n return {\n EstShipDate: ci.EstShipDate(),\n CartDetailId: ci.Id == null ? null : ci.Id(),\n AddToCart: ci.AddToCartData == null ? null : ko.mapping.toJS(ci.AddToCartData())\n };\n });\n return {\n request: {\n dropShip: this.Parent.GetDropShip() == null ? null : ko.mapping.toJS(this.Parent.GetDropShip()),\n shipToAccountNumber: this.Parent.GetIsPickupLocation() ? 'STULLER PICK UP' : this.Parent.GetShipToAccountNumber(),\n promoCode: this.Parent.GetShippingPromoCode(),\n paymentMethod: this.Parent.GetPaymentMethod(),\n cartDetails: cartDetails,\n initialShippingMethod: preserveCurrentShippingMethod && this.ShippingMethod() != null ? this.ShippingMethod().Method : null,\n initialIsSaturdayDelivery: preserveCurrentShippingMethod ? this.IsSaturdayDelivery() : null,\n fetchSingleMethodOnly: fetchSingleMethodOnly,\n oracleLocationId: this.Parent.GetOracleLocationId(),\n cartSessionId: this.Parent.CartSessionId(),\n cartType: this.Parent.CartType()\n }\n };\n }\n static Sort(shipments) {\n return shipments.sort((a, b) => {\n if (a.MaxCartShipDateValue() == null && b.MaxCartShipDateValue() == null) {\n return $.inArray(a, shipments) > $.inArray(b, shipments) ? 1 : -1;\n }\n if (a.MaxCartShipDateValue() == null)\n return 1;\n if (b.MaxCartShipDateValue() == null)\n return -1;\n if (a.MaxCartShipDateValue().toDateString() == b.MaxCartShipDateValue().toDateString()) {\n return $.inArray(a, shipments) > $.inArray(b, shipments) ? 1 : -1;\n }\n return a.MaxCartShipDateValue() > b.MaxCartShipDateValue() ? 1 : -1;\n });\n }\n static GetCartItemShipmentComputed(shipmentContainer, cartItem) {\n return ko.computed({\n read: () => ko.utils.arrayFirst(shipmentContainer.GetOrderedShipments(), shipment => $.inArray(cartItem, shipment.CartItems()) != -1),\n write: value => {\n if (value == cartItem.Shipment()) {\n return;\n }\n var shipments = shipmentContainer.GetShipmentsObservable();\n var currentShipment = cartItem.Shipment();\n var removeFromCurrentShipment = () => {\n if (currentShipment == null)\n return;\n currentShipment.CartItems.remove(cartItem);\n if (currentShipment.CartItems().length == 0) {\n shipments.remove(currentShipment);\n return;\n }\n currentShipment.LoadShippingOptions(false);\n };\n removeFromCurrentShipment();\n if (value != null) {\n value.CartItems.push(cartItem);\n value.LoadShippingOptions(false);\n return;\n }\n if (cartItem.EstShipDate() == null) {\n var shipment = new Shipment({ CartItems: [cartItem] }, shipmentContainer);\n if (currentShipment != null)\n shipment.ShippingMethod(currentShipment.ShippingMethod());\n shipments.push(shipment);\n shipment.LoadShippingOptions(false);\n return;\n }\n var shipment = new Shipment({ CartItems: [cartItem] }, shipmentContainer);\n if (currentShipment != null)\n shipment.ShippingMethod(currentShipment.ShippingMethod());\n shipments.push(shipment);\n shipment.LoadShippingOptions(false);\n },\n owner: this\n });\n }\n }\n exports.Shipment = Shipment;\n Shipment.prototype.ShippingIcons = [\n { Carrier: 'fedex', Icon: '//meteor.stullercloud.com/das/44690923?fmt=smart-alpha' },\n { Carrier: 'ups', Icon: '//meteor.stullercloud.com/das/44690922?fmt=smart-alpha' },\n { Carrier: 'usps', Icon: '//meteor.stullercloud.com/das/44690924?fmt=smart-alpha' },\n { Carrier: 'purolator', Icon: '//meteor.stullercloud.com/das/44690929?fmt=png' },\n { Carrier: 'old dominion', Icon: '//meteor.stullercloud.com/das/44690926?fmt=smart-alpha' }\n ];\n class ShipToAccountViewModel {\n constructor(data) {\n ko.mapping.fromJS(data, {}, this);\n }\n }\n exports.ShipToAccountViewModel = ShipToAccountViewModel;\n});\n//# sourceMappingURL=Shipping.js.map"],"names":["define","require","exports","$","ko","ctx","moment","Object","defineProperty","value","ShipToAccountViewModel","Shipment","ShipmentContainer","constructor","data","this","UpdateShipmentsByShipCompleteMethod","currentShipmentMethods","utils","arrayMap","Shipments","shipment","Items","CartItems","ci","Id","ShippingMethod","IsSaturdayDelivery","singleItemShipments","filter","ContainsSingleShipmentItems","singleShipmentItems","cartItems","cartItem","indexOf","sc_itemsNotPairedUpWithExpeditedShipments","singleShipmentItem","shipments","sort","a","b","d1","EstShipDate","d2","toDateString","getTime","ShipCompleteMethod","arrayForEach","ship","arrayFirst","CanShip","ShipsOnSameDayAs","push","ShipSetCode","length","expeditedItems","arrayFilter","date","IsExpedited","UndoAllExpeditedItems","nonExpeditedItems","inArray","reverse","EstimatedShipDate","Array","elligibleShipments","p_itemsNotPairedUpWithExpeditedShipments","co","OrderCutOffDate","firstShipmentCartItems","ShipmentGroupingRestriction","IsGround","secondShipmentItems","item","ShipsAfter","possiblyThirdShipmentItems","x","cs","csm","OnShippingOptionsResponse","GetOrderedShipments","GetShipmentsObservable","GetDropShip","GetShipToAccountNumber","GetShippingPromoCode","GetPaymentMethod","GetOracleLocationId","GetIsPickupLocation","CartType","CartSessionId","GetStullerPayTermsOptions","parent","ShippingOptionsUrl","MapShippingResponse","GroupedShippingOptions","gso","ShippingOptions","so","UniqueCarrierName","ServiceLevel","toString","IsSaturday","FindShippingOption","response","LoadShipping","fetchSingleMethodOnly","preserveCurrentShippingMethod","ShippingOptionsResponse","DoLoadShippingOptions","LoadEstimateForShippingMethod","LoadShippingOptions","items","ShippingOptionsLoading","serializeData","GetShippingRequestData","request","cartDetails","paymentMethod","JSON","stringify","ajax","type","url","contentType","dataType","done","HasAnyExpeditedItems","shipmentShipsAfterCartItem","shipmentShipsBeforeCartItem","ShipsBefore","GetNextShipSetCode","shipmentContainer","getMaxIndex","values","parseInt","replace","Math","max","apply","MapShipmentToOrderShipment","dto","mapping","toJS","ShippingWarnings","Context","default","Parent","extend","EstimatedDeliveryDate","QuotedShippingCharge","fromJS","ignore","create","opts","observable","observableArray","ShippingOptionsResponseObservable","computed","read","write","owner","subscribe","maxDateTime","ShipDate","filteredItems","Date","EstimatedShipDateText","toLocaleDateString","timeZone","locale","CurrentCultureName","calendar","sameDay","nextDay","nextWeek","sameElse","ShipDateString","MaxCartShipDateValue","each","i","SelectedShippingOption","removeAll","SelectedShippingOptionIcon","carrier","Carrier","icon","ShippingIcons","toLowerCase","Icon","parts","split","Method","DeliveryDateDate","Charge","ShipmentName","triggerCartUpdatedEvent","restrictions","ShipMethodRestrictions","r","arrayGetDistinctValues","ShippingMethodDescription","LongDescription","Description","ShipmentDescription","name","IsNewShipment","ShippingOptionsResponseIsForMethodOnly","shippingMethod","isSaturdayDelivery","shippingOption","concat","CartDetailId","AddToCart","AddToCartData","dropShip","shipToAccountNumber","promoCode","initialShippingMethod","initialIsSaturdayDelivery","oracleLocationId","cartSessionId","cartType","Sort","GetCartItemShipmentComputed","currentShipment","remove","prototype"],"mappings":"AAAAA,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