@ancon/wildcat-utils 1.20.16 → 1.20.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("@ancon/wildcat-types"),f=require("./getCheckoutItemsMappedByTicketItemStatus.js");var g=(e=>(e.YourOrderIsBeingProcessed="yourOrderIsBeingProcessed",e.YourOrderWasCancelled="yourOrderWasCancelled",e.ProcessingPayment="processingPayment",e.YourOrderIsBeingPrepared="yourOrderIsBeingPrepared",e.YourOrderIsReadyToCollect="yourOrderIsReadyToCollect",e.YourOrderHasBeenCompleted="yourOrderHasBeenCompleted",e.YourOrderWillArriveAtYourTable="yourOrderWillArriveAtYourTable",e.ModifiedDeliveryStartTime="modifiedDeliveryStartTime",e.ModifiedPickUpTime="modifiedPickUpTime",e.YourOrderHasBeenAcceptedEstimatedDeliveryStartTime="yourOrderHasBeenAcceptedEstimatedDeliveryStartTime",e.YourOrderHasBeenAcceptedEstimatedTime="yourOrderHasBeenAcceptedEstimatedTime",e.YourOrderHasBeenAcceptedPickupTime="yourOrderHasBeenAcceptedPickupTime",e.DeliveryWasCompleted="deliveryWasCompleted",e.OneItemIsReadyToCollect="oneItemIsReadyToCollect",e.MultipleItemsAreReadyToCollect="multipleItemsAreReadyToCollect",e.EnjoyMealWhileOtherItemsBeingPrepared="enjoyMealWhileOtherItemsBeingPrepared",e))(g||{});function C(e){switch(e){case r.CheckoutStatus.Created:case r.CheckoutStatus.Ready:case r.CheckoutStatus.Processing:case r.CheckoutStatus.Authorized:return"yourOrderIsBeingProcessed";case r.CheckoutStatus.Canceled:return"yourOrderWasCancelled";case r.CheckoutStatus.Received:return"processingPayment";case r.CheckoutStatus.ReadyToCollect:return"yourOrderIsReadyToCollect";default:return null}}function m(e){switch(e){case r.TicketStatus.Pending:case r.TicketStatus.PendingAccept:return"yourOrderIsBeingProcessed";case r.TicketStatus.Preparing:return"yourOrderIsBeingPrepared";case r.TicketStatus.Ready:return"yourOrderIsReadyToCollect";case r.TicketStatus.Closed:return"yourOrderHasBeenCompleted";case r.TicketStatus.Canceled:return"yourOrderWasCancelled";default:throw new Error(`Unhandled ticket status "${e}" in getTranslationKeyByTicketStatus()`)}}function T(e,{checkoutStatus:i,ticketStatus:a,customersFetchTableOrders:o}){const d=(e==null?void 0:e.orderFormat)===r.OrderFormat.Delivery,t=(e==null?void 0:e.orderFormat)===r.OrderFormat.TakeAway,l=(e==null?void 0:e.orderFormat)===r.OrderFormat.TableOrder;if(d||t||l&&!o)return!1;const u=i!=null,c=a!=null;if(u){const n=i===r.CheckoutStatus.Captured,s=i===r.CheckoutStatus.InProgress;return n||s}if(c){const n=a===r.TicketStatus.Preparing,s=a===r.TicketStatus.Ready;return n||s}return!1}function P(e,{checkoutStatus:i,ticketStatus:a,customersFetchTableOrders:o,pickupTimeUpdated:d},t){if(T(e,{checkoutStatus:i,ticketStatus:a,customersFetchTableOrders:o})){if(t.ready>0)return t.ready===t.all?["yourOrderIsReadyToCollect"]:t.ready<2?["oneItemIsReadyToCollect"]:["multipleItemsAreReadyToCollect",{count:t.ready}];if(t.done>0&&t.done<t.all)return["enjoyMealWhileOtherItemsBeingPrepared",{count:Math.max(0,t.all-t.done-t.ready)}]}if(a!=null)return[m(a)];const l=C(i);if(l)return[l];const u=i===r.CheckoutStatus.Captured,c=i===r.CheckoutStatus.InProgress,n=i===r.CheckoutStatus.Done,s=(e==null?void 0:e.orderFormat)===r.OrderFormat.EatIn,p=(e==null?void 0:e.orderFormat)===r.OrderFormat.TakeAway,O=(e==null?void 0:e.orderFormat)===r.OrderFormat.TableOrder,y=(e==null?void 0:e.orderFormat)===r.OrderFormat.Delivery;if(u)return O&&!o?["yourOrderWillArriveAtYourTable"]:y?d?["modifiedDeliveryStartTime"]:["yourOrderHasBeenAcceptedEstimatedDeliveryStartTime"]:d?["modifiedPickUpTime"]:["yourOrderHasBeenAcceptedPickupTime"];if(c){if(y)return d?["modifiedDeliveryStartTime"]:["yourOrderHasBeenAcceptedEstimatedDeliveryStartTime"];if(s||p){if(t.ready===t.all)return["yourOrderIsReadyToCollect"];if(t.done===t.all)return["yourOrderHasBeenCompleted"]}return O?t.ready===t.all?o?["yourOrderIsReadyToCollect"]:["yourOrderWillArriveAtYourTable"]:t.done===t.all?o?["yourOrderHasBeenCompleted"]:["yourOrderWillArriveAtYourTable"]:d?["modifiedPickUpTime"]:o?["yourOrderIsBeingPrepared"]:["yourOrderWillArriveAtYourTable"]:d?["modifiedPickUpTime"]:["yourOrderIsBeingPrepared"]}if(n)return s||p?["yourOrderHasBeenCompleted"]:y?["deliveryWasCompleted"]:["yourOrderHasBeenCompleted"];throw new Error("Could not resolve translation key in getTranslationKey()")}const h={yourOrderIsBeingProcessed:()=>({title:"Your order is being processed"}),yourOrderWasCancelled:()=>({title:"Your order was canceled",message:"Sorry. Your order could not go through."}),processingPayment:()=>({title:"Processing payment",message:"Please wait while your payment is being processed"}),yourOrderIsBeingPrepared:()=>({title:"Your order is now being prepared!",message:"We will let you know when it is ready for pickup."}),yourOrderIsReadyToCollect:()=>({title:"Your order is ready to be collected!",message:"Please go ahead and show this screen at the collection point"}),yourOrderHasBeenCompleted:()=>({title:"Enjoy your meal!",message:"Your order has been completed!"}),yourOrderWillArriveAtYourTable:()=>({title:"Your order has been accepted!",message:"It will arrive at your table shortly"}),modifiedDeliveryStartTime:()=>({title:"Your delivery time was modified",message:"Delivery will start at approximately 00:00."}),modifiedPickUpTime:()=>({title:"Your pickup time was modified",message:"Pickup time: 00:00"}),yourOrderHasBeenAcceptedEstimatedDeliveryStartTime:()=>({title:"Your order has been accepted",message:"Estimated delivery start time: 00:00"}),yourOrderHasBeenAcceptedEstimatedTime:()=>({title:"Your order has been accepted",message:"Estimated time: 00:00"}),yourOrderHasBeenAcceptedPickupTime:()=>({title:"Your order has been accepted",message:"Pickup time: 00:00"}),deliveryWasCompleted:()=>({title:"Your order was completed",message:"Enjoy your meal!"}),oneItemIsReadyToCollect:()=>({title:"One item is ready to pick up!",message:"Please allow cashier or waiter to confirm that the prepared item has been successfully issued."}),multipleItemsAreReadyToCollect:()=>({title:"Multiple items are ready to pick up!",message:"Please allow cashier or waiter to confirm that the prepared items have been successfully issued."}),enjoyMealWhileOtherItemsBeingPrepared:({meta:e})=>({title:"Enjoy your meal while the rest of the items are being prepared!",message:`${e.count} more items are being prepared`})};function I(e,i,a=h){const o=f((e==null?void 0:e.items)??[]),[d,t]=P(e,i,{all:o.all.length,ready:o.ready.length,done:o.done.length}),l=a[d]({key:d,meta:t});if(!l)throw new Error("Could not resolve translation in getOrderStatusTexts()");return[l,d]}exports.TranslationKey=g;exports.default=I;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("@ancon/wildcat-types"),f=require("./getCheckoutItemsMappedByTicketItemStatus.js");var g=(e=>(e.YourOrderIsBeingProcessed="yourOrderIsBeingProcessed",e.YourOrderWasCancelled="yourOrderWasCancelled",e.ProcessingPayment="processingPayment",e.YourOrderIsBeingPrepared="yourOrderIsBeingPrepared",e.YourOrderIsReadyToCollect="yourOrderIsReadyToCollect",e.YourOrderHasBeenCompleted="yourOrderHasBeenCompleted",e.YourOrderWillArriveAtYourTable="yourOrderWillArriveAtYourTable",e.ModifiedDeliveryStartTime="modifiedDeliveryStartTime",e.ModifiedPickUpTime="modifiedPickUpTime",e.YourOrderHasBeenAcceptedEstimatedDeliveryStartTime="yourOrderHasBeenAcceptedEstimatedDeliveryStartTime",e.YourOrderHasBeenAcceptedEstimatedTime="yourOrderHasBeenAcceptedEstimatedTime",e.YourOrderHasBeenAcceptedPickupTime="yourOrderHasBeenAcceptedPickupTime",e.DeliveryWasCompleted="deliveryWasCompleted",e.OneItemIsReadyToCollect="oneItemIsReadyToCollect",e.MultipleItemsAreReadyToCollect="multipleItemsAreReadyToCollect",e.EnjoyMealWhileOtherItemsBeingPrepared="enjoyMealWhileOtherItemsBeingPrepared",e))(g||{});function m(e){switch(e){case r.CheckoutStatus.Created:case r.CheckoutStatus.Ready:case r.CheckoutStatus.Processing:case r.CheckoutStatus.Authorized:return"yourOrderIsBeingProcessed";case r.CheckoutStatus.Canceled:return"yourOrderWasCancelled";case r.CheckoutStatus.Received:return"processingPayment";case r.CheckoutStatus.ReadyToCollect:return"yourOrderIsReadyToCollect";default:return null}}function C(e){switch(e){case r.TicketStatus.Pending:case r.TicketStatus.PendingAccept:return"yourOrderIsBeingProcessed";case r.TicketStatus.Preparing:return"yourOrderIsBeingPrepared";case r.TicketStatus.Ready:return"yourOrderIsReadyToCollect";case r.TicketStatus.Closed:return"yourOrderHasBeenCompleted";case r.TicketStatus.Canceled:return"yourOrderWasCancelled";default:throw new Error(`Unhandled ticket status "${e}" in getTranslationKeyByTicketStatus()`)}}function T(e,{checkoutStatus:i,ticketStatus:a,customersFetchTableOrders:o}){const d=(e==null?void 0:e.orderFormat)===r.OrderFormat.Delivery,t=(e==null?void 0:e.orderFormat)===r.OrderFormat.TakeAway,l=(e==null?void 0:e.orderFormat)===r.OrderFormat.TableOrder;if(d||t||l&&!o)return!1;const u=i!=null,c=a!=null;if(u){const n=i===r.CheckoutStatus.Captured,s=i===r.CheckoutStatus.InProgress;return n||s}if(c){const n=a===r.TicketStatus.Preparing,s=a===r.TicketStatus.Ready;return n||s}return!1}function P(e,{checkoutStatus:i,ticketStatus:a,customersFetchTableOrders:o,pickupTimeUpdated:d},t){if(T(e,{checkoutStatus:i,ticketStatus:a,customersFetchTableOrders:o})){if(t.ready>0)return t.ready<2?["oneItemIsReadyToCollect"]:["multipleItemsAreReadyToCollect",{count:t.ready}];if(t.done>0&&t.done<t.all)return["enjoyMealWhileOtherItemsBeingPrepared",{count:Math.max(0,t.all-t.done-t.ready)}]}if(a!=null)return[C(a)];const l=m(i);if(l)return[l];const u=i===r.CheckoutStatus.Captured,c=i===r.CheckoutStatus.InProgress,n=i===r.CheckoutStatus.Done,s=(e==null?void 0:e.orderFormat)===r.OrderFormat.EatIn,p=(e==null?void 0:e.orderFormat)===r.OrderFormat.TakeAway,O=(e==null?void 0:e.orderFormat)===r.OrderFormat.TableOrder,y=(e==null?void 0:e.orderFormat)===r.OrderFormat.Delivery;if(u)return O&&!o?["yourOrderWillArriveAtYourTable"]:y?d?["modifiedDeliveryStartTime"]:["yourOrderHasBeenAcceptedEstimatedDeliveryStartTime"]:d?["modifiedPickUpTime"]:["yourOrderHasBeenAcceptedPickupTime"];if(c){if(y)return d?["modifiedDeliveryStartTime"]:["yourOrderHasBeenAcceptedEstimatedDeliveryStartTime"];if(s||p){if(t.ready===t.all)return["yourOrderIsReadyToCollect"];if(t.done===t.all)return["yourOrderHasBeenCompleted"]}return O?t.ready===t.all?o?["yourOrderIsReadyToCollect"]:["yourOrderWillArriveAtYourTable"]:t.done===t.all?o?["yourOrderHasBeenCompleted"]:["yourOrderWillArriveAtYourTable"]:d?["modifiedPickUpTime"]:o?["yourOrderIsBeingPrepared"]:["yourOrderWillArriveAtYourTable"]:d?["modifiedPickUpTime"]:["yourOrderIsBeingPrepared"]}if(n)return s||p?["yourOrderHasBeenCompleted"]:y?["deliveryWasCompleted"]:["yourOrderHasBeenCompleted"];throw new Error("Could not resolve translation key in getTranslationKey()")}const h={yourOrderIsBeingProcessed:()=>({title:"Your order is being processed"}),yourOrderWasCancelled:()=>({title:"Your order was canceled",message:"Sorry. Your order could not go through."}),processingPayment:()=>({title:"Processing payment",message:"Please wait while your payment is being processed"}),yourOrderIsBeingPrepared:()=>({title:"Your order is now being prepared!",message:"We will let you know when it is ready for pickup."}),yourOrderIsReadyToCollect:()=>({title:"Your order is ready to be collected!",message:"Please go ahead and show this screen at the collection point"}),yourOrderHasBeenCompleted:()=>({title:"Enjoy your meal!",message:"Your order has been completed!"}),yourOrderWillArriveAtYourTable:()=>({title:"Your order has been accepted!",message:"It will arrive at your table shortly"}),modifiedDeliveryStartTime:()=>({title:"Your delivery time was modified",message:"Delivery will start at approximately 00:00."}),modifiedPickUpTime:()=>({title:"Your pickup time was modified",message:"Pickup time: 00:00"}),yourOrderHasBeenAcceptedEstimatedDeliveryStartTime:()=>({title:"Your order has been accepted",message:"Estimated delivery start time: 00:00"}),yourOrderHasBeenAcceptedEstimatedTime:()=>({title:"Your order has been accepted",message:"Estimated time: 00:00"}),yourOrderHasBeenAcceptedPickupTime:()=>({title:"Your order has been accepted",message:"Pickup time: 00:00"}),deliveryWasCompleted:()=>({title:"Your order was completed",message:"Enjoy your meal!"}),oneItemIsReadyToCollect:()=>({title:"One item is ready to pick up!",message:"Please allow cashier or waiter to confirm that the prepared item has been successfully issued."}),multipleItemsAreReadyToCollect:()=>({title:"Multiple items are ready to pick up!",message:"Please allow cashier or waiter to confirm that the prepared items have been successfully issued."}),enjoyMealWhileOtherItemsBeingPrepared:({meta:e})=>({title:"Enjoy your meal while the rest of the items are being prepared!",message:`${e.count} more items are being prepared`})};function I(e,i,a=h){const o=f((e==null?void 0:e.items)??[]),[d,t]=P(e,i,{all:o.all.length,ready:o.ready.length,done:o.done.length}),l=a[d]({key:d,meta:t});if(!l)throw new Error("Could not resolve translation in getOrderStatusTexts()");return[l,d]}exports.TranslationKey=g;exports.default=I;
@@ -1,7 +1,7 @@
1
1
  import { CheckoutStatus as t, OrderFormat as s, TicketStatus as a } from "@ancon/wildcat-types";
2
2
  import m from "./getCheckoutItemsMappedByTicketItemStatus.mjs";
3
- var C = /* @__PURE__ */ ((e) => (e.YourOrderIsBeingProcessed = "yourOrderIsBeingProcessed", e.YourOrderWasCancelled = "yourOrderWasCancelled", e.ProcessingPayment = "processingPayment", e.YourOrderIsBeingPrepared = "yourOrderIsBeingPrepared", e.YourOrderIsReadyToCollect = "yourOrderIsReadyToCollect", e.YourOrderHasBeenCompleted = "yourOrderHasBeenCompleted", e.YourOrderWillArriveAtYourTable = "yourOrderWillArriveAtYourTable", e.ModifiedDeliveryStartTime = "modifiedDeliveryStartTime", e.ModifiedPickUpTime = "modifiedPickUpTime", e.YourOrderHasBeenAcceptedEstimatedDeliveryStartTime = "yourOrderHasBeenAcceptedEstimatedDeliveryStartTime", e.YourOrderHasBeenAcceptedEstimatedTime = "yourOrderHasBeenAcceptedEstimatedTime", e.YourOrderHasBeenAcceptedPickupTime = "yourOrderHasBeenAcceptedPickupTime", e.DeliveryWasCompleted = "deliveryWasCompleted", e.OneItemIsReadyToCollect = "oneItemIsReadyToCollect", e.MultipleItemsAreReadyToCollect = "multipleItemsAreReadyToCollect", e.EnjoyMealWhileOtherItemsBeingPrepared = "enjoyMealWhileOtherItemsBeingPrepared", e))(C || {});
4
- function P(e) {
3
+ var P = /* @__PURE__ */ ((e) => (e.YourOrderIsBeingProcessed = "yourOrderIsBeingProcessed", e.YourOrderWasCancelled = "yourOrderWasCancelled", e.ProcessingPayment = "processingPayment", e.YourOrderIsBeingPrepared = "yourOrderIsBeingPrepared", e.YourOrderIsReadyToCollect = "yourOrderIsReadyToCollect", e.YourOrderHasBeenCompleted = "yourOrderHasBeenCompleted", e.YourOrderWillArriveAtYourTable = "yourOrderWillArriveAtYourTable", e.ModifiedDeliveryStartTime = "modifiedDeliveryStartTime", e.ModifiedPickUpTime = "modifiedPickUpTime", e.YourOrderHasBeenAcceptedEstimatedDeliveryStartTime = "yourOrderHasBeenAcceptedEstimatedDeliveryStartTime", e.YourOrderHasBeenAcceptedEstimatedTime = "yourOrderHasBeenAcceptedEstimatedTime", e.YourOrderHasBeenAcceptedPickupTime = "yourOrderHasBeenAcceptedPickupTime", e.DeliveryWasCompleted = "deliveryWasCompleted", e.OneItemIsReadyToCollect = "oneItemIsReadyToCollect", e.MultipleItemsAreReadyToCollect = "multipleItemsAreReadyToCollect", e.EnjoyMealWhileOtherItemsBeingPrepared = "enjoyMealWhileOtherItemsBeingPrepared", e))(P || {});
4
+ function C(e) {
5
5
  switch (e) {
6
6
  case t.Created:
7
7
  case t.Ready:
@@ -45,12 +45,12 @@ function T(e, {
45
45
  const d = (e == null ? void 0 : e.orderFormat) === s.Delivery, r = (e == null ? void 0 : e.orderFormat) === s.TakeAway, n = (e == null ? void 0 : e.orderFormat) === s.TableOrder;
46
46
  if (d || r || n && !o)
47
47
  return !1;
48
- const y = i != null, p = l != null;
49
- if (y) {
48
+ const p = i != null, y = l != null;
49
+ if (p) {
50
50
  const u = i === t.Captured, c = i === t.InProgress;
51
51
  return u || c;
52
52
  }
53
- if (p) {
53
+ if (y) {
54
54
  const u = l === a.Preparing, c = l === a.Ready;
55
55
  return u || c;
56
56
  }
@@ -68,7 +68,7 @@ function B(e, {
68
68
  customersFetchTableOrders: o
69
69
  })) {
70
70
  if (r.ready > 0)
71
- return r.ready === r.all ? ["yourOrderIsReadyToCollect"] : r.ready < 2 ? ["oneItemIsReadyToCollect"] : [
71
+ return r.ready < 2 ? ["oneItemIsReadyToCollect"] : [
72
72
  "multipleItemsAreReadyToCollect",
73
73
  { count: r.ready }
74
74
  ];
@@ -80,13 +80,13 @@ function B(e, {
80
80
  }
81
81
  if (l != null)
82
82
  return [I(l)];
83
- const n = P(i);
83
+ const n = C(i);
84
84
  if (n)
85
85
  return [n];
86
- const y = i === t.Captured, p = i === t.InProgress, u = i === t.Done, c = (e == null ? void 0 : e.orderFormat) === s.EatIn, g = (e == null ? void 0 : e.orderFormat) === s.TakeAway, O = (e == null ? void 0 : e.orderFormat) === s.TableOrder, f = (e == null ? void 0 : e.orderFormat) === s.Delivery;
87
- if (y)
86
+ const p = i === t.Captured, y = i === t.InProgress, u = i === t.Done, c = (e == null ? void 0 : e.orderFormat) === s.EatIn, g = (e == null ? void 0 : e.orderFormat) === s.TakeAway, O = (e == null ? void 0 : e.orderFormat) === s.TableOrder, f = (e == null ? void 0 : e.orderFormat) === s.Delivery;
87
+ if (p)
88
88
  return O && !o ? ["yourOrderWillArriveAtYourTable"] : f ? d ? ["modifiedDeliveryStartTime"] : ["yourOrderHasBeenAcceptedEstimatedDeliveryStartTime"] : d ? ["modifiedPickUpTime"] : ["yourOrderHasBeenAcceptedPickupTime"];
89
- if (p) {
89
+ if (y) {
90
90
  if (f)
91
91
  return d ? ["modifiedDeliveryStartTime"] : ["yourOrderHasBeenAcceptedEstimatedDeliveryStartTime"];
92
92
  if (c || g) {
@@ -179,6 +179,6 @@ function w(e, i, l = h) {
179
179
  return [n, d];
180
180
  }
181
181
  export {
182
- C as TranslationKey,
182
+ P as TranslationKey,
183
183
  w as default
184
184
  };
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("moment"),g=require("./types.js"),d=require("./constants.js"),M=require("./getOutletCurrentActiveOperatingHour.js"),v=require("./getMomentFromDateAndTimeString.js"),k=require("./searchNextOpeningMoment.js");require("@ancon/wildcat-types");const D={0:127,1:1,2:2,3:4,4:8,5:16,6:32,7:64};function S(o,e){const a=o.isSame(e,"d"),n={[e.format(d.OutletMapKeyFormatter)]:{intervals:[],exception:null,metadata:{dayOfWeek:D[e.isoWeekday()]}}};for(let i=a?1:0;i<d.OutletTimelineDayCount;i+=1){const s=c(o).add(i,"d");n[s.format(d.OutletMapKeyFormatter)]={intervals:[],exception:null,metadata:{dayOfWeek:D[s.isoWeekday()]}}}return n}function W(o,e){const a=c().utcOffset(),t=c(e.fromDate).utc(!1).subtract(a,"minutes"),n=c(e.toDate).utc(!1).subtract(a,"minutes");if(!t.isSame(n,"d"))Object.keys(o).forEach(s=>{const r=c(s);if(r.isSame(t,"d")||r.isSame(n,"d")||r.isBetween(t,n)){const l=o[s],u=l.exception?l.exception.position:0;e.position>u&&(l.exception=e)}});else{const s=t.format(d.OutletMapKeyFormatter),r=o[s];if(r){const y=r.exception?r.exception.position:0;e.position>y&&(r.exception=e)}}}function E(o,e){Object.keys(o).forEach(a=>{const t=o[a],{dayOfWeek:n}=t.metadata,{dayOfWeek:i}=e;(n&i)===n&&t.intervals.push(e)})}function K(o,e,a){const t=S(e,a);return o.forEach(n=>{n.type===g.OperatingHourType.Exception?W(t,n):E(t,n)}),t}function x(o,e,a,t,n){const i=K(o,a,t),s=t.format(d.OutletMapKeyFormatter),r=M(s,i[s],t)!==null,y=e;let l=null,u=null;if(e){const m=a.format(d.OutletMapKeyFormatter),p=M(m,i[m],a);if(p){const[f,O]=p.duration.split(":").map(Number);u=v(m,p.start),l=u.clone().add(f,"hours").add(O,"minutes")}}else u=k(i,a,n);if(!e&&!u){const m=o.filter(f=>f.state&&c(f.toDate).isAfter(a)),[p]=m.sort((f,O)=>t.valueOf()-(c(f.toDate).valueOf()-c(O.toDate).valueOf()));if(p)return x(o,e,c(p.toDate),t)}return{closingTime:l,openingTime:u,openDuringSpecifiedTime:y,openNow:r}}exports.DaysOfWeekMap=D;exports.default=x;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("moment"),g=require("./types.js"),d=require("./constants.js"),M=require("./getOutletCurrentActiveOperatingHour.js"),v=require("./getMomentFromDateAndTimeString.js"),k=require("./searchNextOpeningMoment.js");require("@ancon/wildcat-types");const D={0:127,1:1,2:2,3:4,4:8,5:16,6:32,7:64};function S(n,t){const a=n.isSame(t,"d"),o={[t.format(d.OutletMapKeyFormatter)]:{intervals:[],exception:null,metadata:{dayOfWeek:D[t.isoWeekday()]}}};for(let i=a?1:0;i<d.OutletTimelineDayCount;i+=1){const s=c(n).add(i,"d");o[s.format(d.OutletMapKeyFormatter)]={intervals:[],exception:null,metadata:{dayOfWeek:D[s.isoWeekday()]}}}return o}function W(n,t){const a=c().utcOffset(),e=c(t.fromDate).utc(!1).subtract(a,"minutes"),o=c(t.toDate).utc(!1).subtract(a,"minutes");if(!e.isSame(o,"d"))Object.keys(n).forEach(s=>{const r=c(s);if(r.isSame(e,"d")||r.isSame(o,"d")||r.isBetween(e,o)){const l=n[s],u=l.exception?l.exception.position:0;t.position>u&&(l.exception=t)}});else{const s=e.format(d.OutletMapKeyFormatter),r=n[s];if(r){const y=r.exception?r.exception.position:0;t.position>y&&(r.exception=t)}}}function E(n,t){Object.keys(n).forEach(a=>{const e=n[a],{dayOfWeek:o}=e.metadata,{dayOfWeek:i}=t;(o&i)===o&&e.intervals.push(t)})}function K(n,t,a){const e=S(t,a);return n.forEach(o=>{o.type===g.OperatingHourType.Exception?W(e,o):E(e,o)}),e}function x(n,t,a,e,o){const i=K(n,a,e),s=e.format(d.OutletMapKeyFormatter),r=M(s,i[s],e)!==null,y=t;let l=null,u=null;if(t){const m=a.format(d.OutletMapKeyFormatter),p=M(m,i[m],a);if(p){const[f,O]=p.duration.split(":").map(Number);u=v(m,p.start),l=u.clone().add(f,"hours").add(O,"minutes")}}else u=k(i,a,o);if(!t&&!u){const m=n.filter(f=>f.state&&c(f.toDate).isAfter(a)),[p]=m.sort((f,O)=>e.valueOf()-(c(f.toDate).valueOf()-c(O.toDate).valueOf()));if(p)return x(n,t,c(p.toDate),e,o)}return{closingTime:l,openingTime:u,openDuringSpecifiedTime:y,openNow:r}}exports.DaysOfWeekMap=D;exports.default=x;
@@ -15,8 +15,8 @@ const x = {
15
15
  6: 32,
16
16
  7: 64
17
17
  };
18
- function S(o, t) {
19
- const a = o.isSame(t, "d"), n = {
18
+ function S(n, t) {
19
+ const a = n.isSame(t, "d"), o = {
20
20
  [t.format(d)]: {
21
21
  intervals: [],
22
22
  exception: null,
@@ -24,51 +24,51 @@ function S(o, t) {
24
24
  }
25
25
  };
26
26
  for (let i = a ? 1 : 0; i < k; i += 1) {
27
- const s = c(o).add(i, "d");
28
- n[s.format(d)] = {
27
+ const s = c(n).add(i, "d");
28
+ o[s.format(d)] = {
29
29
  intervals: [],
30
30
  exception: null,
31
31
  metadata: { dayOfWeek: x[s.isoWeekday()] }
32
32
  };
33
33
  }
34
- return n;
34
+ return o;
35
35
  }
36
- function W(o, t) {
37
- const a = c().utcOffset(), e = c(t.fromDate).utc(!1).subtract(a, "minutes"), n = c(t.toDate).utc(!1).subtract(a, "minutes");
36
+ function W(n, t) {
37
+ const a = c().utcOffset(), e = c(t.fromDate).utc(!1).subtract(a, "minutes"), o = c(t.toDate).utc(!1).subtract(a, "minutes");
38
38
  if (!e.isSame(
39
- n,
39
+ o,
40
40
  "d"
41
41
  ))
42
- Object.keys(o).forEach((s) => {
42
+ Object.keys(n).forEach((s) => {
43
43
  const r = c(s);
44
- if (r.isSame(e, "d") || r.isSame(n, "d") || r.isBetween(e, n)) {
45
- const f = o[s], p = f.exception ? f.exception.position : 0;
44
+ if (r.isSame(e, "d") || r.isSame(o, "d") || r.isBetween(e, o)) {
45
+ const f = n[s], p = f.exception ? f.exception.position : 0;
46
46
  t.position > p && (f.exception = t);
47
47
  }
48
48
  });
49
49
  else {
50
- const s = e.format(d), r = o[s];
50
+ const s = e.format(d), r = n[s];
51
51
  if (r) {
52
52
  const y = r.exception ? r.exception.position : 0;
53
53
  t.position > y && (r.exception = t);
54
54
  }
55
55
  }
56
56
  }
57
- function E(o, t) {
58
- Object.keys(o).forEach((a) => {
59
- const e = o[a], { dayOfWeek: n } = e.metadata, { dayOfWeek: i } = t;
60
- (n & i) === n && e.intervals.push(t);
57
+ function E(n, t) {
58
+ Object.keys(n).forEach((a) => {
59
+ const e = n[a], { dayOfWeek: o } = e.metadata, { dayOfWeek: i } = t;
60
+ (o & i) === o && e.intervals.push(t);
61
61
  });
62
62
  }
63
- function I(o, t, a) {
63
+ function I(n, t, a) {
64
64
  const e = S(t, a);
65
- return o.forEach((n) => {
66
- n.type === g.Exception ? W(e, n) : E(e, n);
65
+ return n.forEach((o) => {
66
+ o.type === g.Exception ? W(e, o) : E(e, o);
67
67
  }), e;
68
68
  }
69
- function h(o, t, a, e, n) {
69
+ function h(n, t, a, e, o) {
70
70
  const i = I(
71
- o,
71
+ n,
72
72
  a,
73
73
  e
74
74
  ), s = e.format(d), r = D(
@@ -94,20 +94,21 @@ function h(o, t, a, e, n) {
94
94
  p = M(
95
95
  i,
96
96
  a,
97
- n
97
+ o
98
98
  );
99
99
  if (!t && !p) {
100
- const u = o.filter(
100
+ const u = n.filter(
101
101
  (m) => m.state && c(m.toDate).isAfter(a)
102
102
  ), [l] = u.sort(
103
103
  (m, O) => e.valueOf() - (c(m.toDate).valueOf() - c(O.toDate).valueOf())
104
104
  );
105
105
  if (l)
106
106
  return h(
107
- o,
107
+ n,
108
108
  t,
109
109
  c(l.toDate),
110
- e
110
+ e,
111
+ o
111
112
  );
112
113
  }
113
114
  return { closingTime: f, openingTime: p, openDuringSpecifiedTime: y, openNow: r };
@@ -1 +1 @@
1
- "use strict";const m=require("moment"),p=require("@ancon/wildcat-types"),c=require("./constants.js"),a=require("./getMomentFromDateAndTimeString.js");function O(i){const[e]=i.split(":").map(Number)??[];return e??0}function d(i,e,r="00:00:00"){const[t,o]=r.split(":"),n=i.clone().add(t,"hour").add(o,"minute").date()-e.date();return n!==0?i.subtract(n,"day"):i}function g(i){let e=null;const{intervals:r,exception:t}=i;if(t){const{state:o}=t;o||(e=t)}else{const o=r.sort((n,s)=>O(n.start)-O(s.start)),[u]=o;return u}return e}function h(i,e,r){var o,u;const t=[];if(e.exception){if(e.exception.state===p.OutletState.Open){const n=a(i,e.exception.start);r.isBefore(n)&&t.push({interval:e.exception,moment:n})}}else for(let n=0;n<e.intervals.length;n+=1){const s=e.intervals[n],l=a(i,s.start);r.isBefore(l)&&t.push({interval:s,moment:l})}return t.length<2?((o=t[0])==null?void 0:o.interval)??null:((u=t.sort((n,s)=>n.moment-r-(s.moment-r))[0])==null?void 0:u.interval)??null}function x(i,e,r){let t=null;const o=m(e).format(c.OutletMapKeyFormatter),u=h(o,i[o],e);if(u&&(t=a(o,u.start),t=d(t,e,r)),!t)for(let n=1;n<c.OutletTimelineDayCount;n+=1){const s=m(e).add(n,"d"),l=s.format(c.OutletMapKeyFormatter),y=i[l],f=g(y);if(f){t=a(l,f.start),t=d(t,s,r);break}}return t}module.exports=x;
1
+ "use strict";const m=require("moment"),y=require("@ancon/wildcat-types"),c=require("./constants.js"),a=require("./getMomentFromDateAndTimeString.js");function O(i){const[e]=i.split(":").map(Number)??[];return e??0}function p(i,e,r="00:00:00"){const[t,o]=r.split(":"),n=i.clone().add(t,"hour").add(o,"minute").date()-e.date();return n!==0?i.subtract(n,"day"):i}function g(i){let e=null;const{intervals:r,exception:t}=i;if(t){const{state:o}=t;o||(e=t)}else{const o=r.sort((n,s)=>O(n.start)-O(s.start)),[u]=o;return u}return e}function h(i,e,r){var o,u;const t=[];if(e.exception){if(e.exception.state===y.OutletState.Open){const n=a(i,e.exception.start);r.isBefore(n)&&t.push({interval:e.exception,moment:n})}}else for(let n=0;n<e.intervals.length;n+=1){const s=e.intervals[n],l=a(i,s.start);r.isBefore(l)&&t.push({interval:s,moment:l})}return t.length<2?((o=t[0])==null?void 0:o.interval)??null:((u=t.sort((n,s)=>n.moment-r-(s.moment-r))[0])==null?void 0:u.interval)??null}function x(i,e,r){let t=null;const o=m(e).format(c.OutletMapKeyFormatter),u=h(o,i[o],e);if(u&&(t=a(o,u.start)),!t)for(let n=1;n<c.OutletTimelineDayCount;n+=1){const s=m(e).add(n,"d"),l=s.format(c.OutletMapKeyFormatter),d=i[l],f=g(d);if(f){t=a(l,f.start),t=p(t,s,r);break}}return t}module.exports=x;
@@ -1,36 +1,36 @@
1
- import c from "moment";
2
- import { OutletState as y } from "@ancon/wildcat-types";
3
- import { OutletMapKeyFormatter as m, OutletTimelineDayCount as g } from "./constants.mjs";
1
+ import m from "moment";
2
+ import { OutletState as d } from "@ancon/wildcat-types";
3
+ import { OutletMapKeyFormatter as c, OutletTimelineDayCount as y } from "./constants.mjs";
4
4
  import a from "./getMomentFromDateAndTimeString.mjs";
5
- function O(i) {
6
- const [e] = i.split(":").map(Number) ?? [];
5
+ function O(o) {
6
+ const [e] = o.split(":").map(Number) ?? [];
7
7
  return e ?? 0;
8
8
  }
9
- function p(i, e, r = "00:00:00") {
10
- const [t, o] = r.split(":"), n = i.clone().add(t, "hour").add(o, "minute").date() - e.date();
11
- return n !== 0 ? i.subtract(n, "day") : i;
9
+ function g(o, e, r = "00:00:00") {
10
+ const [t, i] = r.split(":"), n = o.clone().add(t, "hour").add(i, "minute").date() - e.date();
11
+ return n !== 0 ? o.subtract(n, "day") : o;
12
12
  }
13
- function h(i) {
13
+ function h(o) {
14
14
  let e = null;
15
- const { intervals: r, exception: t } = i;
15
+ const { intervals: r, exception: t } = o;
16
16
  if (t) {
17
- const { state: o } = t;
18
- o || (e = t);
17
+ const { state: i } = t;
18
+ i || (e = t);
19
19
  } else {
20
- const o = r.sort(
20
+ const i = r.sort(
21
21
  (n, s) => O(n.start) - O(s.start)
22
- ), [l] = o;
22
+ ), [l] = i;
23
23
  return l;
24
24
  }
25
25
  return e;
26
26
  }
27
- function x(i, e, r) {
28
- var o, l;
27
+ function x(o, e, r) {
28
+ var i, l;
29
29
  const t = [];
30
30
  if (e.exception) {
31
- if (e.exception.state === y.Open) {
31
+ if (e.exception.state === d.Open) {
32
32
  const n = a(
33
- i,
33
+ o,
34
34
  e.exception.start
35
35
  );
36
36
  r.isBefore(n) && t.push({
@@ -41,37 +41,33 @@ function x(i, e, r) {
41
41
  } else
42
42
  for (let n = 0; n < e.intervals.length; n += 1) {
43
43
  const s = e.intervals[n], u = a(
44
- i,
44
+ o,
45
45
  s.start
46
46
  );
47
47
  r.isBefore(u) && t.push({ interval: s, moment: u });
48
48
  }
49
- return t.length < 2 ? ((o = t[0]) == null ? void 0 : o.interval) ?? null : ((l = t.sort(
49
+ return t.length < 2 ? ((i = t[0]) == null ? void 0 : i.interval) ?? null : ((l = t.sort(
50
50
  (n, s) => n.moment - r - (s.moment - r)
51
51
  )[0]) == null ? void 0 : l.interval) ?? null;
52
52
  }
53
- function b(i, e, r) {
53
+ function b(o, e, r) {
54
54
  let t = null;
55
- const o = c(e).format(m), l = x(
56
- o,
57
- i[o],
55
+ const i = m(e).format(c), l = x(
56
+ i,
57
+ o[i],
58
58
  e
59
59
  );
60
60
  if (l && (t = a(
61
- o,
61
+ i,
62
62
  l.start
63
- ), t = p(
64
- t,
65
- e,
66
- r
67
63
  )), !t)
68
- for (let n = 1; n < g; n += 1) {
69
- const s = c(e).add(n, "d"), u = s.format(m), d = i[u], f = h(d);
64
+ for (let n = 1; n < y; n += 1) {
65
+ const s = m(e).add(n, "d"), u = s.format(c), p = o[u], f = h(p);
70
66
  if (f) {
71
67
  t = a(
72
68
  u,
73
69
  f.start
74
- ), t = p(
70
+ ), t = g(
75
71
  t,
76
72
  s,
77
73
  r
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancon/wildcat-utils",
3
- "version": "1.20.16",
3
+ "version": "1.20.18",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",