b23-lib 3.9.8 → 3.9.9

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.
Files changed (61) hide show
  1. package/dist/Auth/index.js +1 -1
  2. package/dist/Auth/index.js.map +1 -1
  3. package/dist/Auth/index.mjs +1 -1
  4. package/dist/Classes/Cart.d.mts +1 -1
  5. package/dist/Classes/Cart.d.ts +1 -1
  6. package/dist/Classes/Cart.js +1 -1
  7. package/dist/Classes/Cart.js.map +1 -1
  8. package/dist/Classes/Cart.mjs +1 -1
  9. package/dist/Classes/Charge.js.map +1 -1
  10. package/dist/Classes/Charge.mjs +1 -1
  11. package/dist/Classes/Coupon.js +1 -1
  12. package/dist/Classes/Coupon.js.map +1 -1
  13. package/dist/Classes/Coupon.mjs +1 -1
  14. package/dist/Classes/Inventory.d.mts +1 -1
  15. package/dist/Classes/Inventory.d.ts +1 -1
  16. package/dist/Classes/Inventory.js +1 -1
  17. package/dist/Classes/Inventory.js.map +1 -1
  18. package/dist/Classes/Inventory.mjs +1 -1
  19. package/dist/Classes/Invoice.d.mts +1 -1
  20. package/dist/Classes/Invoice.d.ts +1 -1
  21. package/dist/Classes/LineItem.d.mts +1 -1
  22. package/dist/Classes/LineItem.d.ts +1 -1
  23. package/dist/Classes/LineItem.js +1 -1
  24. package/dist/Classes/LineItem.js.map +1 -1
  25. package/dist/Classes/LineItem.mjs +1 -1
  26. package/dist/Classes/Order.d.mts +1 -1
  27. package/dist/Classes/Order.d.ts +1 -1
  28. package/dist/Classes/Order.js +1 -1
  29. package/dist/Classes/Order.js.map +1 -1
  30. package/dist/Classes/Order.mjs +1 -1
  31. package/dist/Classes/Product.d.mts +1 -1
  32. package/dist/Classes/Product.d.ts +1 -1
  33. package/dist/Classes/Product.js +1 -1
  34. package/dist/Classes/Product.js.map +1 -1
  35. package/dist/Classes/Product.mjs +1 -1
  36. package/dist/Classes/ShoppingContainer.d.mts +1 -1
  37. package/dist/Classes/ShoppingContainer.d.ts +1 -1
  38. package/dist/Classes/ShoppingContainer.js.map +1 -1
  39. package/dist/Classes/ShoppingContainer.mjs +1 -1
  40. package/dist/Classes/TieredPrice.d.mts +1 -1
  41. package/dist/Classes/TieredPrice.d.ts +1 -1
  42. package/dist/Classes/TieredPrice.js +1 -1
  43. package/dist/Classes/TieredPrice.js.map +1 -1
  44. package/dist/Classes/TieredPrice.mjs +1 -1
  45. package/dist/{TieredPrice-D512SmTC.d.ts → TieredPrice-BDkfC-bt.d.ts} +12 -8
  46. package/dist/{TieredPrice-DtpmvAJJ.d.mts → TieredPrice-Cs3iLEWQ.d.mts} +12 -8
  47. package/dist/{chunk-KFXRFY63.mjs → chunk-4PTWJI6J.mjs} +2 -2
  48. package/dist/{chunk-KFXRFY63.mjs.map → chunk-4PTWJI6J.mjs.map} +1 -1
  49. package/dist/{chunk-A34BAO7J.mjs → chunk-5N2HRXWJ.mjs} +2 -2
  50. package/dist/{chunk-A34BAO7J.mjs.map → chunk-5N2HRXWJ.mjs.map} +1 -1
  51. package/dist/{chunk-UO6WBOEX.mjs → chunk-MBR2GRKU.mjs} +2 -2
  52. package/dist/{chunk-UO6WBOEX.mjs.map → chunk-MBR2GRKU.mjs.map} +1 -1
  53. package/dist/{chunk-56TRG5UD.mjs → chunk-NXDEYUDI.mjs} +2 -2
  54. package/dist/{chunk-56TRG5UD.mjs.map → chunk-NXDEYUDI.mjs.map} +1 -1
  55. package/dist/{chunk-6IGPC7FH.mjs → chunk-SZLAIOMF.mjs} +2 -2
  56. package/dist/{chunk-6IGPC7FH.mjs.map → chunk-SZLAIOMF.mjs.map} +1 -1
  57. package/dist/index.d.mts +1 -1
  58. package/dist/index.d.ts +1 -1
  59. package/dist/index.js.map +1 -1
  60. package/dist/index.mjs +1 -1
  61. package/package.json +1 -1
@@ -307,18 +307,22 @@ type SelectionTieredPriceAttributes = {
307
307
  })[];
308
308
  };
309
309
  type TieredPriceAttributes = VolumenTieredPriceAttributes | SelectionTieredPriceAttributes;
310
- type TieredPriceData = Prettify<{
310
+ type VolumenTieredPriceData = {
311
+ type: PricingType.VOLUME;
311
312
  taxCategory: string;
312
313
  isTaxInclusive: boolean;
313
314
  currency: CurrencyCode;
314
- } & ({
315
- type?: PricingType.VOLUME;
316
315
  baseUnitPrice: PriceData;
317
316
  tiers: PriceTierData[];
318
- } | {
317
+ };
318
+ type SelectionTieredPriceData = {
319
319
  type: PricingType.SELECTION;
320
+ taxCategory: string;
321
+ isTaxInclusive: boolean;
322
+ currency: CurrencyCode;
320
323
  selections: SelectionPricingData[];
321
- })>;
324
+ };
325
+ type TieredPriceData = VolumenTieredPriceData | SelectionTieredPriceData;
322
326
  declare abstract class TieredPriceModel {
323
327
  protected type: PricingType;
324
328
  protected taxCategory: string;
@@ -358,7 +362,7 @@ declare class VolumeTieredPriceModel extends TieredPriceModel {
358
362
  getMinPrice(): PriceModel | null;
359
363
  getMaxPrice(): PriceModel | null;
360
364
  getTiers(): PriceTier[];
361
- getDetails(): TieredPriceData;
365
+ getDetails(): VolumenTieredPriceData;
362
366
  }
363
367
  declare class SelectionTieredPriceModel extends TieredPriceModel {
364
368
  protected currency: CurrencyCode;
@@ -376,7 +380,7 @@ declare class SelectionTieredPriceModel extends TieredPriceModel {
376
380
  getTiers(selectionAttributes?: SelectionAttributes): PriceTier[];
377
381
  getMinPrice(selectionAttributes?: SelectionAttributes): PriceModel | null;
378
382
  getMaxPrice(selectionAttributes?: SelectionAttributes): PriceModel | null;
379
- getDetails(): TieredPriceData;
383
+ getDetails(): SelectionTieredPriceData;
380
384
  }
381
385
 
382
- export { PricingType as P, type SelectionAttributes as S, type TieredPriceData as T, type VariantData as V, ProductModel as a, TieredPriceModel as b, type ProductSpecification as c, type ProductSelectionAttributes as d, type VariantModel as e, type ProductAttributes as f, type ProductData as g, type PriceTier as h, type PriceTierData as i, type SelectionPricingData as j, type SelectionPricing as k, type PriceTierAttributes as l, type VolumenTieredPriceAttributes as m, type SelectionTieredPriceAttributes as n, type TieredPriceAttributes as o, VolumeTieredPriceModel as p, SelectionTieredPriceModel as q };
386
+ export { PricingType as P, type SelectionAttributes as S, type TieredPriceData as T, type VariantData as V, ProductModel as a, TieredPriceModel as b, type ProductSpecification as c, type ProductSelectionAttributes as d, type VariantModel as e, type ProductAttributes as f, type ProductData as g, type PriceTier as h, type PriceTierData as i, type SelectionPricingData as j, type SelectionPricing as k, type PriceTierAttributes as l, type VolumenTieredPriceAttributes as m, type SelectionTieredPriceAttributes as n, type TieredPriceAttributes as o, type VolumenTieredPriceData as p, type SelectionTieredPriceData as q, VolumeTieredPriceModel as r, SelectionTieredPriceModel as s };
@@ -307,18 +307,22 @@ type SelectionTieredPriceAttributes = {
307
307
  })[];
308
308
  };
309
309
  type TieredPriceAttributes = VolumenTieredPriceAttributes | SelectionTieredPriceAttributes;
310
- type TieredPriceData = Prettify<{
310
+ type VolumenTieredPriceData = {
311
+ type: PricingType.VOLUME;
311
312
  taxCategory: string;
312
313
  isTaxInclusive: boolean;
313
314
  currency: CurrencyCode;
314
- } & ({
315
- type?: PricingType.VOLUME;
316
315
  baseUnitPrice: PriceData;
317
316
  tiers: PriceTierData[];
318
- } | {
317
+ };
318
+ type SelectionTieredPriceData = {
319
319
  type: PricingType.SELECTION;
320
+ taxCategory: string;
321
+ isTaxInclusive: boolean;
322
+ currency: CurrencyCode;
320
323
  selections: SelectionPricingData[];
321
- })>;
324
+ };
325
+ type TieredPriceData = VolumenTieredPriceData | SelectionTieredPriceData;
322
326
  declare abstract class TieredPriceModel {
323
327
  protected type: PricingType;
324
328
  protected taxCategory: string;
@@ -358,7 +362,7 @@ declare class VolumeTieredPriceModel extends TieredPriceModel {
358
362
  getMinPrice(): PriceModel | null;
359
363
  getMaxPrice(): PriceModel | null;
360
364
  getTiers(): PriceTier[];
361
- getDetails(): TieredPriceData;
365
+ getDetails(): VolumenTieredPriceData;
362
366
  }
363
367
  declare class SelectionTieredPriceModel extends TieredPriceModel {
364
368
  protected currency: CurrencyCode;
@@ -376,7 +380,7 @@ declare class SelectionTieredPriceModel extends TieredPriceModel {
376
380
  getTiers(selectionAttributes?: SelectionAttributes): PriceTier[];
377
381
  getMinPrice(selectionAttributes?: SelectionAttributes): PriceModel | null;
378
382
  getMaxPrice(selectionAttributes?: SelectionAttributes): PriceModel | null;
379
- getDetails(): TieredPriceData;
383
+ getDetails(): SelectionTieredPriceData;
380
384
  }
381
385
 
382
- export { PricingType as P, type SelectionAttributes as S, type TieredPriceData as T, type VariantData as V, ProductModel as a, TieredPriceModel as b, type ProductSpecification as c, type ProductSelectionAttributes as d, type VariantModel as e, type ProductAttributes as f, type ProductData as g, type PriceTier as h, type PriceTierData as i, type SelectionPricingData as j, type SelectionPricing as k, type PriceTierAttributes as l, type VolumenTieredPriceAttributes as m, type SelectionTieredPriceAttributes as n, type TieredPriceAttributes as o, VolumeTieredPriceModel as p, SelectionTieredPriceModel as q };
386
+ export { PricingType as P, type SelectionAttributes as S, type TieredPriceData as T, type VariantData as V, ProductModel as a, TieredPriceModel as b, type ProductSpecification as c, type ProductSelectionAttributes as d, type VariantModel as e, type ProductAttributes as f, type ProductData as g, type PriceTier as h, type PriceTierData as i, type SelectionPricingData as j, type SelectionPricing as k, type PriceTierAttributes as l, type VolumenTieredPriceAttributes as m, type SelectionTieredPriceAttributes as n, type TieredPriceAttributes as o, type VolumenTieredPriceData as p, type SelectionTieredPriceData as q, VolumeTieredPriceModel as r, SelectionTieredPriceModel as s };
@@ -1,2 +1,2 @@
1
- import {b as b$1}from'./chunk-7RAIVZKB.mjs';import {a}from'./chunk-UIQH5QIR.mjs';import {e as e$1}from'./chunk-PL5HGCWN.mjs';import {h,e,l as l$1,n,m as m$1,o,p,y}from'./chunk-O6BLQQO7.mjs';import {b}from'./chunk-UXZBULDS.mjs';import G from'crypto';var C=new Uint8Array(256),T=C.length;function v(){return T>C.length-16&&(G.randomFillSync(C),T=0),C.slice(T,T+=16)}var R=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function q(r){return typeof r=="string"&&R.test(r)}var $=q;var u=[];for(let r=0;r<256;++r)u.push((r+256).toString(16).slice(1));function x(r,e=0){return u[r[e+0]]+u[r[e+1]]+u[r[e+2]]+u[r[e+3]]+"-"+u[r[e+4]]+u[r[e+5]]+"-"+u[r[e+6]]+u[r[e+7]]+"-"+u[r[e+8]]+u[r[e+9]]+"-"+u[r[e+10]]+u[r[e+11]]+u[r[e+12]]+u[r[e+13]]+u[r[e+14]]+u[r[e+15]]}function j(r){if(!$(r))throw TypeError("Invalid UUID");let e,t=new Uint8Array(16);return t[0]=(e=parseInt(r.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(r.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(r.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(r.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(r.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}var B=j;function Z(r){r=unescape(encodeURIComponent(r));let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}var Y="6ba7b810-9dad-11d1-80b4-00c04fd430c8",F="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function U(r,e,t){function i(n,s,a,c){var p;if(typeof n=="string"&&(n=Z(n)),typeof s=="string"&&(s=B(s)),((p=s)===null||p===void 0?void 0:p.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let o=new Uint8Array(16+n.length);if(o.set(s),o.set(n,s.length),o=t(o),o[6]=o[6]&15|e,o[8]=o[8]&63|128,a){c=c||0;for(let y=0;y<16;++y)a[c+y]=o[y];return a}return x(o)}try{i.name=r;}catch{}return i.DNS=Y,i.URL=F,i}var L={randomUUID:G.randomUUID};function W(r,e,t){if(L.randomUUID&&!e&&!r)return L.randomUUID();r=r||{};let i=r.random||(r.rng||v)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){t=t||0;for(let n=0;n<16;++n)e[t+n]=i[n];return e}return x(i)}var E=W;function J(r){return Array.isArray(r)?r=Buffer.from(r):typeof r=="string"&&(r=Buffer.from(r,"utf8")),G.createHash("sha1").update(r).digest()}var N=J;var _=U("v5",80,N),Q=_;var ee={isUUID:r=>/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(r),isEmail:r=>/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(r),isURL:r=>/^(http|https):\/\/[^ "]+$/.test(r),generateUUID:(r,e)=>e&&r?Q(r,e):E(),generateSearchId:(r,e)=>`${r}#${m.generateSelectionAttributesKey(e)}`,getKeyfromSearchId:r=>{let[e,t]=r.split("#");return {key:e,selectionAttributes:m.parseSelectionAttributesKey(t)}},deepClone(r){return structuredClone(r)}},l=ee;var m=class r extends b{id;key;name;description;slug;brand;pricing;variants;targetGender;attributes;specifications;categories;productType;isActive;searchTags;static productKeyRegex=/^(?!\s)(?!.*\s$)[A-Z0-9-]{4,16}$/;static productSKURegex=/^(?!\s)(?!.*\s$)[A-Z0-9-]{4,16}$/;static generateSelectionAttributesKey(e){if(typeof e!="object")throw new h("Selection attributes must be an object");return Object.keys(e).filter(i=>e[i]!==void 0&&i.toLowerCase()!=="size").sort().map(i=>e[i].name?`${i}:c+${e[i].name}`:`${i}:${e[i]}`).join("|").toLowerCase()}static parseSelectionAttributesKey(e){try{let t={},i=e.split("|");for(let n of i){let[s,a]=n.split(":");a.startsWith("c+")?t[s]={name:a.slice(2)}:t[s]=a;}return t}catch(t){throw new h(t?.message)}}constructor(e$1,t=new Date){super(e$1,t),this.id=e$1.id,this.key=e$1.key,this.name={...e$1.name},this.description={...e$1.description},this.slug={...e$1.slug},this.brand=e$1.brand,this.pricing=Object.keys(e$1.pricing).reduce((n,s)=>(e$1.pricing[s]&&(n[s]=A.create(e$1.pricing[s])),n),{}),this.targetGender=e$1.targetGender,this.attributes=l.deepClone(e$1.attributes),this.specifications=l.deepClone(e$1.specifications),this.categories=l.deepClone(e$1.categories),this.productType=e$1.productType??"GOODS";let i=new Set;this.variants=(e$1.variants||[]).map(n=>{if(!n.selectionAttributes||typeof n.selectionAttributes!="object")throw new h("Selection attributes are required");this.checkSelectionAttributes(n.selectionAttributes);let s=r.generateSelectionAttributesKey(n.selectionAttributes);if(i.has(s))throw new e(s);return i.add(s),{sku:n.sku,selectionAttributes:n.selectionAttributes,images:{primary:new b$1(n.images.primary),gallery:(n.images.gallery||[]).map(a=>new b$1(a))}}}),this.isActive=e$1.isActive,this.searchTags=e$1.searchTags?l.deepClone(e$1.searchTags):{en:[]};}getId(){return this.id}getKey(){return this.key}getName(e){return e?this.name[e]??this.name[e$1[e]]??this.name.en:l.deepClone(this.name)}getDescription(e){return e?this.description[e]??this.description[e$1[e]]??this.description.en:l.deepClone(this.description)}getSlug(e){return e?this.slug[e]??this.slug[e$1[e]]??this.slug.en:l.deepClone(this.slug)}getBrand(){return this.brand}getPriceDetails(e){return e?this.pricing[e]??null:{...this.pricing}}getAttributes(){return l.deepClone(this.attributes)}getVariants(){return this.variants.map(e=>({sku:e.sku,selectionAttributes:l.deepClone(e.selectionAttributes),images:{primary:e.images.primary,gallery:[...e.images.gallery]}}))}getImagesBySelectionAttributes(e){let t=r.generateSelectionAttributesKey(e),i=this.variants.find(n=>r.generateSelectionAttributesKey(n.selectionAttributes)===t);return i?{primary:i.images.primary,gallery:[...i.images.gallery]}:null}getImages(e,t){switch(t){case"PRIMARY":return this.getImagesBySelectionAttributes(e)?.primary??this.variants[0]?.images?.primary;case"GALLERY":return this.getImagesBySelectionAttributes(e)?.gallery??[];default:return this.getImagesBySelectionAttributes(e)??{primary:this.variants[0]?.images?.primary,gallery:[]}}}getIsActive(){return this.isActive}getTargetGender(){return this.targetGender}getCategories(){return l.deepClone(this.categories)}getProductType(){return this.productType}getSpecifications(e){return e?l.deepClone(this.specifications[e]??this.specifications[e$1[e]]??this.specifications.en):l.deepClone(this.specifications)}getSearchTags(e){return e?l.deepClone(this.searchTags[e]??this.searchTags[e$1[e]]??this.searchTags.en):l.deepClone(this.searchTags)}getDetails(){let e=super.getDetails();return {id:this.getId(),key:this.getKey(),name:this.getName(),description:this.getDescription(),slug:this.getSlug(),brand:this.getBrand(),pricing:Object.keys(this.pricing).reduce((t,i)=>(this.pricing[i]&&(t[i]=this.pricing[i]?.getDetails()),t),{}),attributes:this.getAttributes(),variants:this.variants.map(t=>({sku:t.sku,selectionAttributes:l.deepClone(t.selectionAttributes),images:{primary:t.images.primary.getDetails(),gallery:t.images.gallery.map(i=>i.getDetails())}})),isActive:this.getIsActive(),targetGender:this.getTargetGender(),categories:this.getCategories(),productType:this.getProductType(),specifications:this.getSpecifications(),searchTags:this.getSearchTags(),...e}}checkSelectionAttributes(e){if(!e||typeof e!="object")throw new h("Selection attributes are required");Object.keys(this.attributes).forEach(t=>{if(t.toLowerCase()==="size")return;let i=this.attributes[t],n=e[t];if(n===void 0)throw new h(`Selection attribute '${t}' is missing`);if(typeof i=="string"){if(typeof n!="string"||i!==n)throw new h(`Selection attribute '${t}' is invalid`)}else if(Array.isArray(i)){if(i.length>0&&typeof i[0]=="string"){if(typeof n!="string"||!i.includes(n))throw new h(`Selection attribute '${t}' is invalid`)}else if(typeof n!="object"||!("name"in n)||i.findIndex(s=>s.name===n.name)<0)throw new h(`Selection attribute '${t}' is invalid`)}});}getSku(e){let t=r.generateSelectionAttributesKey(e);return this.variants.find(n=>r.generateSelectionAttributesKey(n.selectionAttributes)===t)?.sku}validateSelectionAttribute(e){let t=r.generateSelectionAttributesKey(e);return this.variants.some(i=>r.generateSelectionAttributesKey(i.selectionAttributes)===t)}validateSize(e){return this.attributes.size.includes(e)}};var te=(t=>(t.VOLUME="volume",t.SELECTION="selection",t))(te||{}),A=class{type;taxCategory;isTaxInclusive;static create(e){return e.type==="selection"?new V(e):new z(e)}constructor(e){if(!e.taxCategory)throw new l$1;this.taxCategory=e.taxCategory,this.isTaxInclusive=e.isTaxInclusive??!1,this.type=e.type??"volume";}getType(){return this.type}getTaxCategory(){return this.taxCategory}getIsTaxInclusive(){return this.isTaxInclusive}},z=class extends A{baseUnitPrice;tiers;currency;constructor(e){if(super(e),this.type="volume",!e.baseUnitPrice)throw new n("Base unit price is required for volume pricing.");this.baseUnitPrice=new a(e.baseUnitPrice),this.currency=e.currency??this.baseUnitPrice.getCurrency();let t=(e.tiers??[]).map(c=>({enabled:c.enabled??!0,minQuantity:c.minQuantity,unitPrice:new a(c.unitPrice)})).sort((c,p)=>c.minQuantity-p.minQuantity);if(t.some(c=>c.minQuantity<=0))throw new m$1;let n$1=this.baseUnitPrice.getCurrency()!==this.currency||t.some(c=>c.unitPrice.getCurrency()!==this.currency),s=t.some((c,p)=>p>0&&c.unitPrice.compareTo(t[p-1].unitPrice)>0),a$1=t[0]?.unitPrice.compareTo(this.baseUnitPrice)>0;if(n$1||s||a$1)throw new n("Tiers must share the same currency and must not increase in unit price.");this.tiers=t;}isPriceAvailable(){return this.tiers.filter(e=>e.enabled).length>0}getBaseUnitPrice(){return this.baseUnitPrice}getCurrency(){return this.baseUnitPrice.getCurrency()}getApplicableUnitPrice(e){if(e<=0)throw new o;let t=this.tiers.filter(i=>i.enabled);for(let i=t.length-1;i>=0;i--){let n=t[i];if(e>=n.minQuantity)return n.unitPrice}throw new p(e)}getMinQuantity(){return this.tiers.filter(t=>t.enabled)[0]?.minQuantity??1}getMaxDiscountPercent(){let e=this.tiers.filter(s=>s.enabled);if(!e.length)return 0;let t=Math.min(...e.map(s=>s.unitPrice.getAmount())),i=this.baseUnitPrice.getAmount(),n=(i-t)/i*100;return n>0?n:0}getMinPrice(){let e=this.tiers.filter(t=>t.enabled);return e.length?e[e.length-1].unitPrice:null}getMaxPrice(){let e=this.tiers.filter(t=>t.enabled);return e.length?e[0].unitPrice:null}getTiers(){return this.tiers.map(e=>({enabled:e.enabled,minQuantity:e.minQuantity,unitPrice:e.unitPrice}))}getDetails(){return {type:this.type,taxCategory:this.taxCategory,isTaxInclusive:this.isTaxInclusive,currency:this.currency,baseUnitPrice:this.baseUnitPrice.getDetails(),tiers:this.tiers.map(e=>({enabled:e.enabled,minQuantity:e.minQuantity,unitPrice:e.unitPrice.getDetails()}))}}},V=class extends A{currency;selections;constructor(e){super(e),this.type="selection",this.currency=e.currency,this.selections=(e.selections??[]).map(t=>{if(!t.baseUnitPrice)throw new n("Base unit price is required for each selection.");let i=new a(t.baseUnitPrice),n$1=(t.tiers??[]).map(o=>({enabled:o.enabled??!0,minQuantity:o.minQuantity??1,unitPrice:new a(o.unitPrice)})).sort((o,y)=>o.minQuantity-y.minQuantity);if(n$1.some(o=>o.minQuantity<=0))throw new m$1;let a$1=i.getCurrency()!==this.currency||n$1.some(o=>o.unitPrice.getCurrency()!==this.currency),c=n$1.some((o,y)=>y>0&&o.unitPrice.compareTo(n$1[y-1].unitPrice)>0),p=n$1[0]?.unitPrice.compareTo(i)>0;if(a$1||c||p)throw new n("Tiers must share the same currency and must not increase in unit price within the same selection.");return {selectionAttributes:{...t.selectionAttributes},baseUnitPrice:i,tiers:n$1}});}findMatch(e,t=!1){let i=m.generateSelectionAttributesKey(e),n$1=this.selections.find(s=>m.generateSelectionAttributesKey(s.selectionAttributes)===i);if(!n$1&&t)throw new n("No pricing configuration found for selection variant.");return n$1??null}isPriceAvailable(e){if(!e)return console.warn("Selection attributes are required to check price availability for selection pricing."),!1;let t=this.findMatch(e);return t?t.tiers.filter(i=>i.enabled).length>0:!1}getBaseUnitPrice(e){if(!e)throw new y("Selection attributes are required to get base unit price for selection pricing.");return this.findMatch(e,!0).baseUnitPrice}getCurrency(){return this.currency}getApplicableUnitPrice(e,t){if(e<=0)throw new o;if(!t)throw new y("Selection attributes are required to get applicable unit price for selection pricing.");let n=this.findMatch(t,!0).tiers.filter(s=>s.enabled);for(let s=n.length-1;s>=0;s--){let a=n[s];if(e>=a.minQuantity)return a.unitPrice}throw new p(e)}getMinQuantity(e){if(!e)throw new y("Selection attributes are required to get min quantity for selection pricing.");return this.findMatch(e,!0).tiers.filter(n=>n.enabled)[0]?.minQuantity??1}getMaxDiscountPercent(e){if(!e)throw new y("Selection attributes are required to get max discount for selection pricing.");let t=this.findMatch(e,!0),i=t.tiers.filter(c=>c.enabled);if(!i.length)return 0;let n=Math.min(...i.map(c=>c.unitPrice.getAmount())),s=t.baseUnitPrice.getAmount(),a=(s-n)/s*100;return a>0?a:0}getTiers(e){if(!e)throw new y("Selection attributes are required to get tiers for selection pricing.");return this.findMatch(e,!0).tiers.map(i=>({enabled:i.enabled,minQuantity:i.minQuantity,unitPrice:i.unitPrice}))}getMinPrice(e){if(!e)throw new y("Selection attributes are required to get min price for selection pricing.");let t=this.findMatch(e);if(!t)return null;let i=t.tiers.filter(n=>n.enabled);return i.length?i[i.length-1].unitPrice:null}getMaxPrice(e){if(!e)throw new y("Selection attributes are required to get max price for selection pricing.");let t=this.findMatch(e);if(!t)return null;let i=t.tiers.filter(n=>n.enabled);return i.length?i[0].unitPrice:null}getDetails(){return {type:this.type,taxCategory:this.taxCategory,isTaxInclusive:this.isTaxInclusive,currency:this.currency,selections:this.selections.map(e=>({selectionAttributes:e.selectionAttributes,baseUnitPrice:e.baseUnitPrice.getDetails(),...e.tiers.length>0?{tiers:e.tiers.map(t=>({enabled:t.enabled,minQuantity:t.minQuantity,unitPrice:t.unitPrice.getDetails()}))}:{}}))}}};export{l as a,te as b,A as c,z as d,V as e,m as f};//# sourceMappingURL=chunk-KFXRFY63.mjs.map
2
- //# sourceMappingURL=chunk-KFXRFY63.mjs.map
1
+ import {b as b$1}from'./chunk-7RAIVZKB.mjs';import {a}from'./chunk-UIQH5QIR.mjs';import {e as e$1}from'./chunk-PL5HGCWN.mjs';import {h,e,l as l$1,n,m as m$1,o,p,y}from'./chunk-O6BLQQO7.mjs';import {b}from'./chunk-UXZBULDS.mjs';import G from'crypto';var C=new Uint8Array(256),T=C.length;function v(){return T>C.length-16&&(G.randomFillSync(C),T=0),C.slice(T,T+=16)}var R=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;function q(r){return typeof r=="string"&&R.test(r)}var $=q;var u=[];for(let r=0;r<256;++r)u.push((r+256).toString(16).slice(1));function x(r,e=0){return u[r[e+0]]+u[r[e+1]]+u[r[e+2]]+u[r[e+3]]+"-"+u[r[e+4]]+u[r[e+5]]+"-"+u[r[e+6]]+u[r[e+7]]+"-"+u[r[e+8]]+u[r[e+9]]+"-"+u[r[e+10]]+u[r[e+11]]+u[r[e+12]]+u[r[e+13]]+u[r[e+14]]+u[r[e+15]]}function j(r){if(!$(r))throw TypeError("Invalid UUID");let e,t=new Uint8Array(16);return t[0]=(e=parseInt(r.slice(0,8),16))>>>24,t[1]=e>>>16&255,t[2]=e>>>8&255,t[3]=e&255,t[4]=(e=parseInt(r.slice(9,13),16))>>>8,t[5]=e&255,t[6]=(e=parseInt(r.slice(14,18),16))>>>8,t[7]=e&255,t[8]=(e=parseInt(r.slice(19,23),16))>>>8,t[9]=e&255,t[10]=(e=parseInt(r.slice(24,36),16))/1099511627776&255,t[11]=e/4294967296&255,t[12]=e>>>24&255,t[13]=e>>>16&255,t[14]=e>>>8&255,t[15]=e&255,t}var B=j;function Z(r){r=unescape(encodeURIComponent(r));let e=[];for(let t=0;t<r.length;++t)e.push(r.charCodeAt(t));return e}var Y="6ba7b810-9dad-11d1-80b4-00c04fd430c8",F="6ba7b811-9dad-11d1-80b4-00c04fd430c8";function U(r,e,t){function i(n,s,a,c){var p;if(typeof n=="string"&&(n=Z(n)),typeof s=="string"&&(s=B(s)),((p=s)===null||p===void 0?void 0:p.length)!==16)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");let o=new Uint8Array(16+n.length);if(o.set(s),o.set(n,s.length),o=t(o),o[6]=o[6]&15|e,o[8]=o[8]&63|128,a){c=c||0;for(let y=0;y<16;++y)a[c+y]=o[y];return a}return x(o)}try{i.name=r;}catch{}return i.DNS=Y,i.URL=F,i}var L={randomUUID:G.randomUUID};function W(r,e,t){if(L.randomUUID&&!e&&!r)return L.randomUUID();r=r||{};let i=r.random||(r.rng||v)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){t=t||0;for(let n=0;n<16;++n)e[t+n]=i[n];return e}return x(i)}var E=W;function J(r){return Array.isArray(r)?r=Buffer.from(r):typeof r=="string"&&(r=Buffer.from(r,"utf8")),G.createHash("sha1").update(r).digest()}var N=J;var _=U("v5",80,N),Q=_;var ee={isUUID:r=>/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(r),isEmail:r=>/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(r),isURL:r=>/^(http|https):\/\/[^ "]+$/.test(r),generateUUID:(r,e)=>e&&r?Q(r,e):E(),generateSearchId:(r,e)=>`${r}#${m.generateSelectionAttributesKey(e)}`,getKeyfromSearchId:r=>{let[e,t]=r.split("#");return {key:e,selectionAttributes:m.parseSelectionAttributesKey(t)}},deepClone(r){return structuredClone(r)}},l=ee;var m=class r extends b{id;key;name;description;slug;brand;pricing;variants;targetGender;attributes;specifications;categories;productType;isActive;searchTags;static productKeyRegex=/^(?!\s)(?!.*\s$)[A-Z0-9-]{4,16}$/;static productSKURegex=/^(?!\s)(?!.*\s$)[A-Z0-9-]{4,16}$/;static generateSelectionAttributesKey(e){if(typeof e!="object")throw new h("Selection attributes must be an object");return Object.keys(e).filter(i=>e[i]!==void 0&&i.toLowerCase()!=="size").sort().map(i=>e[i].name?`${i}:c+${e[i].name}`:`${i}:${e[i]}`).join("|").toLowerCase()}static parseSelectionAttributesKey(e){try{let t={},i=e.split("|");for(let n of i){let[s,a]=n.split(":");a.startsWith("c+")?t[s]={name:a.slice(2)}:t[s]=a;}return t}catch(t){throw new h(t?.message)}}constructor(e$1,t=new Date){super(e$1,t),this.id=e$1.id,this.key=e$1.key,this.name={...e$1.name},this.description={...e$1.description},this.slug={...e$1.slug},this.brand=e$1.brand,this.pricing=Object.keys(e$1.pricing).reduce((n,s)=>(e$1.pricing[s]&&(n[s]=S.create(e$1.pricing[s])),n),{}),this.targetGender=e$1.targetGender,this.attributes=l.deepClone(e$1.attributes),this.specifications=l.deepClone(e$1.specifications),this.categories=l.deepClone(e$1.categories),this.productType=e$1.productType??"GOODS";let i=new Set;this.variants=(e$1.variants||[]).map(n=>{if(!n.selectionAttributes||typeof n.selectionAttributes!="object")throw new h("Selection attributes are required");this.checkSelectionAttributes(n.selectionAttributes);let s=r.generateSelectionAttributesKey(n.selectionAttributes);if(i.has(s))throw new e(s);return i.add(s),{sku:n.sku,selectionAttributes:n.selectionAttributes,images:{primary:new b$1(n.images.primary),gallery:(n.images.gallery||[]).map(a=>new b$1(a))}}}),this.isActive=e$1.isActive,this.searchTags=e$1.searchTags?l.deepClone(e$1.searchTags):{en:[]};}getId(){return this.id}getKey(){return this.key}getName(e){return e?this.name[e]??this.name[e$1[e]]??this.name.en:l.deepClone(this.name)}getDescription(e){return e?this.description[e]??this.description[e$1[e]]??this.description.en:l.deepClone(this.description)}getSlug(e){return e?this.slug[e]??this.slug[e$1[e]]??this.slug.en:l.deepClone(this.slug)}getBrand(){return this.brand}getPriceDetails(e){return e?this.pricing[e]??null:{...this.pricing}}getAttributes(){return l.deepClone(this.attributes)}getVariants(){return this.variants.map(e=>({sku:e.sku,selectionAttributes:l.deepClone(e.selectionAttributes),images:{primary:e.images.primary,gallery:[...e.images.gallery]}}))}getImagesBySelectionAttributes(e){let t=r.generateSelectionAttributesKey(e),i=this.variants.find(n=>r.generateSelectionAttributesKey(n.selectionAttributes)===t);return i?{primary:i.images.primary,gallery:[...i.images.gallery]}:null}getImages(e,t){switch(t){case"PRIMARY":return this.getImagesBySelectionAttributes(e)?.primary??this.variants[0]?.images?.primary;case"GALLERY":return this.getImagesBySelectionAttributes(e)?.gallery??[];default:return this.getImagesBySelectionAttributes(e)??{primary:this.variants[0]?.images?.primary,gallery:[]}}}getIsActive(){return this.isActive}getTargetGender(){return this.targetGender}getCategories(){return l.deepClone(this.categories)}getProductType(){return this.productType}getSpecifications(e){return e?l.deepClone(this.specifications[e]??this.specifications[e$1[e]]??this.specifications.en):l.deepClone(this.specifications)}getSearchTags(e){return e?l.deepClone(this.searchTags[e]??this.searchTags[e$1[e]]??this.searchTags.en):l.deepClone(this.searchTags)}getDetails(){let e=super.getDetails();return {id:this.getId(),key:this.getKey(),name:this.getName(),description:this.getDescription(),slug:this.getSlug(),brand:this.getBrand(),pricing:Object.keys(this.pricing).reduce((t,i)=>(this.pricing[i]&&(t[i]=this.pricing[i]?.getDetails()),t),{}),attributes:this.getAttributes(),variants:this.variants.map(t=>({sku:t.sku,selectionAttributes:l.deepClone(t.selectionAttributes),images:{primary:t.images.primary.getDetails(),gallery:t.images.gallery.map(i=>i.getDetails())}})),isActive:this.getIsActive(),targetGender:this.getTargetGender(),categories:this.getCategories(),productType:this.getProductType(),specifications:this.getSpecifications(),searchTags:this.getSearchTags(),...e}}checkSelectionAttributes(e){if(!e||typeof e!="object")throw new h("Selection attributes are required");Object.keys(this.attributes).forEach(t=>{if(t.toLowerCase()==="size")return;let i=this.attributes[t],n=e[t];if(n===void 0)throw new h(`Selection attribute '${t}' is missing`);if(typeof i=="string"){if(typeof n!="string"||i!==n)throw new h(`Selection attribute '${t}' is invalid`)}else if(Array.isArray(i)){if(i.length>0&&typeof i[0]=="string"){if(typeof n!="string"||!i.includes(n))throw new h(`Selection attribute '${t}' is invalid`)}else if(typeof n!="object"||!("name"in n)||i.findIndex(s=>s.name===n.name)<0)throw new h(`Selection attribute '${t}' is invalid`)}});}getSku(e){let t=r.generateSelectionAttributesKey(e);return this.variants.find(n=>r.generateSelectionAttributesKey(n.selectionAttributes)===t)?.sku}validateSelectionAttribute(e){let t=r.generateSelectionAttributesKey(e);return this.variants.some(i=>r.generateSelectionAttributesKey(i.selectionAttributes)===t)}validateSize(e){return this.attributes.size.includes(e)}};var te=(t=>(t.VOLUME="volume",t.SELECTION="selection",t))(te||{}),S=class{type;taxCategory;isTaxInclusive;static create(e){return e.type==="selection"?new V(e):new z(e)}constructor(e){if(!e.taxCategory)throw new l$1;this.taxCategory=e.taxCategory,this.isTaxInclusive=e.isTaxInclusive??!1,this.type=e.type??"volume";}getType(){return this.type}getTaxCategory(){return this.taxCategory}getIsTaxInclusive(){return this.isTaxInclusive}},z=class extends S{baseUnitPrice;tiers;currency;constructor(e){if(super(e),this.type="volume",!e.baseUnitPrice)throw new n("Base unit price is required for volume pricing.");this.baseUnitPrice=new a(e.baseUnitPrice),this.currency=e.currency??this.baseUnitPrice.getCurrency();let t=(e.tiers??[]).map(c=>({enabled:c.enabled??!0,minQuantity:c.minQuantity,unitPrice:new a(c.unitPrice)})).sort((c,p)=>c.minQuantity-p.minQuantity);if(t.some(c=>c.minQuantity<=0))throw new m$1;let n$1=this.baseUnitPrice.getCurrency()!==this.currency||t.some(c=>c.unitPrice.getCurrency()!==this.currency),s=t.some((c,p)=>p>0&&c.unitPrice.compareTo(t[p-1].unitPrice)>0),a$1=t[0]?.unitPrice.compareTo(this.baseUnitPrice)>0;if(n$1||s||a$1)throw new n("Tiers must share the same currency and must not increase in unit price.");this.tiers=t;}isPriceAvailable(){return this.tiers.filter(e=>e.enabled).length>0}getBaseUnitPrice(){return this.baseUnitPrice}getCurrency(){return this.baseUnitPrice.getCurrency()}getApplicableUnitPrice(e){if(e<=0)throw new o;let t=this.tiers.filter(i=>i.enabled);for(let i=t.length-1;i>=0;i--){let n=t[i];if(e>=n.minQuantity)return n.unitPrice}throw new p(e)}getMinQuantity(){return this.tiers.filter(t=>t.enabled)[0]?.minQuantity??1}getMaxDiscountPercent(){let e=this.tiers.filter(s=>s.enabled);if(!e.length)return 0;let t=Math.min(...e.map(s=>s.unitPrice.getAmount())),i=this.baseUnitPrice.getAmount(),n=(i-t)/i*100;return n>0?n:0}getMinPrice(){let e=this.tiers.filter(t=>t.enabled);return e.length?e[e.length-1].unitPrice:null}getMaxPrice(){let e=this.tiers.filter(t=>t.enabled);return e.length?e[0].unitPrice:null}getTiers(){return this.tiers.map(e=>({enabled:e.enabled,minQuantity:e.minQuantity,unitPrice:e.unitPrice}))}getDetails(){return {type:this.type,taxCategory:this.taxCategory,isTaxInclusive:this.isTaxInclusive,currency:this.currency,baseUnitPrice:this.baseUnitPrice.getDetails(),tiers:this.tiers.map(e=>({enabled:e.enabled,minQuantity:e.minQuantity,unitPrice:e.unitPrice.getDetails()}))}}},V=class extends S{currency;selections;constructor(e){super(e),this.type="selection",this.currency=e.currency,this.selections=(e.selections??[]).map(t=>{if(!t.baseUnitPrice)throw new n("Base unit price is required for each selection.");let i=new a(t.baseUnitPrice),n$1=(t.tiers??[]).map(o=>({enabled:o.enabled??!0,minQuantity:o.minQuantity??1,unitPrice:new a(o.unitPrice)})).sort((o,y)=>o.minQuantity-y.minQuantity);if(n$1.some(o=>o.minQuantity<=0))throw new m$1;let a$1=i.getCurrency()!==this.currency||n$1.some(o=>o.unitPrice.getCurrency()!==this.currency),c=n$1.some((o,y)=>y>0&&o.unitPrice.compareTo(n$1[y-1].unitPrice)>0),p=n$1[0]?.unitPrice.compareTo(i)>0;if(a$1||c||p)throw new n("Tiers must share the same currency and must not increase in unit price within the same selection.");return {selectionAttributes:{...t.selectionAttributes},baseUnitPrice:i,tiers:n$1}});}findMatch(e,t=!1){let i=m.generateSelectionAttributesKey(e),n$1=this.selections.find(s=>m.generateSelectionAttributesKey(s.selectionAttributes)===i);if(!n$1&&t)throw new n("No pricing configuration found for selection variant.");return n$1??null}isPriceAvailable(e){if(!e)return console.warn("Selection attributes are required to check price availability for selection pricing."),!1;let t=this.findMatch(e);return t?t.tiers.filter(i=>i.enabled).length>0:!1}getBaseUnitPrice(e){if(!e)throw new y("Selection attributes are required to get base unit price for selection pricing.");return this.findMatch(e,!0).baseUnitPrice}getCurrency(){return this.currency}getApplicableUnitPrice(e,t){if(e<=0)throw new o;if(!t)throw new y("Selection attributes are required to get applicable unit price for selection pricing.");let n=this.findMatch(t,!0).tiers.filter(s=>s.enabled);for(let s=n.length-1;s>=0;s--){let a=n[s];if(e>=a.minQuantity)return a.unitPrice}throw new p(e)}getMinQuantity(e){if(!e)throw new y("Selection attributes are required to get min quantity for selection pricing.");return this.findMatch(e,!0).tiers.filter(n=>n.enabled)[0]?.minQuantity??1}getMaxDiscountPercent(e){if(!e)throw new y("Selection attributes are required to get max discount for selection pricing.");let t=this.findMatch(e,!0),i=t.tiers.filter(c=>c.enabled);if(!i.length)return 0;let n=Math.min(...i.map(c=>c.unitPrice.getAmount())),s=t.baseUnitPrice.getAmount(),a=(s-n)/s*100;return a>0?a:0}getTiers(e){if(!e)throw new y("Selection attributes are required to get tiers for selection pricing.");return this.findMatch(e,!0).tiers.map(i=>({enabled:i.enabled,minQuantity:i.minQuantity,unitPrice:i.unitPrice}))}getMinPrice(e){if(!e)throw new y("Selection attributes are required to get min price for selection pricing.");let t=this.findMatch(e);if(!t)return null;let i=t.tiers.filter(n=>n.enabled);return i.length?i[i.length-1].unitPrice:null}getMaxPrice(e){if(!e)throw new y("Selection attributes are required to get max price for selection pricing.");let t=this.findMatch(e);if(!t)return null;let i=t.tiers.filter(n=>n.enabled);return i.length?i[0].unitPrice:null}getDetails(){return {type:this.type,taxCategory:this.taxCategory,isTaxInclusive:this.isTaxInclusive,currency:this.currency,selections:this.selections.map(e=>({selectionAttributes:e.selectionAttributes,baseUnitPrice:e.baseUnitPrice.getDetails(),...e.tiers.length>0?{tiers:e.tiers.map(t=>({enabled:t.enabled,minQuantity:t.minQuantity,unitPrice:t.unitPrice.getDetails()}))}:{}}))}}};export{l as a,te as b,S as c,z as d,V as e,m as f};//# sourceMappingURL=chunk-4PTWJI6J.mjs.map
2
+ //# sourceMappingURL=chunk-4PTWJI6J.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../node_modules/uuid/dist/esm-node/rng.js","../node_modules/uuid/dist/esm-node/regex.js","../node_modules/uuid/dist/esm-node/validate.js","../node_modules/uuid/dist/esm-node/stringify.js","../node_modules/uuid/dist/esm-node/parse.js","../node_modules/uuid/dist/esm-node/v35.js","../node_modules/uuid/dist/esm-node/native.js","../node_modules/uuid/dist/esm-node/v4.js","../node_modules/uuid/dist/esm-node/sha1.js","../node_modules/uuid/dist/esm-node/v5.js","../src/Utils/index.ts","../src/Classes/Product.ts","../src/Classes/TieredPrice.ts"],"names":["rnds8Pool","poolPtr","rng","crypto","regex_default","validate","uuid","validate_default","byteToHex","i","unsafeStringify","arr","offset","parse","v","parse_default","stringToBytes","str","bytes","DNS","URL","v35","name","version","hashfunc","generateUUID","value","namespace","buf","_namespace","native_default","v4","options","rnds","v4_default","sha1","sha1_default","v5","v5_default","Utils","key","selectionAttributes","ProductModel","searchId","selectionAttributesKey","obj","Utils_default","_ProductModel","BaseModel","SelectionAttributeParseError","attributes","parts","part","error","data","date","acc","country","TieredPriceModel","uniqueSelectionAttributes","variant","DuplicateSelectionAttributeError","ImageInfoModel","image","locale","LocaleLanguageMap","searchKey","match","category","baseDetails","img","allowedAttributeValues","providedValue","c","size","PricingType","SelectionTieredPriceModel","VolumeTieredPriceModel","InvalidTaxCategoryError","InvalidTieredPriceError","PriceModel","tiers","tier","a","b","t","InvalidMinQuantityError","hasDifferentCurrency","hasIrregularPricing","index","basePriceExceedsFirstTier","quantity","InvalidQuantityError","enabledTiers","NoApplicableTierError","minTierPrice","basePrice","discount","selection","baseUnitPrice","throwOnNotFound","InvalidPricingTypeError"],"mappings":"yPACA,IAAMA,CAAY,CAAA,IAAI,WAAW,GAAG,CAAA,CAEhCC,CAAUD,CAAAA,CAAAA,CAAU,OACT,SAARE,CAAAA,EAAuB,CAC5B,OAAID,CA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MAASA,CAAAA,CAAAA,CAAa,CAAC,CAAE,CAAA,SAAA,CAAY,IAC3D,CAEA,YAA8B,CAC5B,OAAO,CACL,IAAM,CAAA,IAAA,CAAK,KACX,WAAa,CAAA,IAAA,CAAK,WAClB,CAAA,cAAA,CAAgB,KAAK,cACrB,CAAA,QAAA,CAAU,KAAK,QACf,CAAA,UAAA,CAAY,KAAK,UAAW,CAAA,GAAA,CAAIK,CAAc,GAAA,CAC5C,oBAAqBA,CAAU,CAAA,mBAAA,CAC/B,aAAeA,CAAAA,CAAAA,CAAU,cAAc,UAAW,EAAA,CAClD,GAAIA,CAAAA,CAAU,MAAM,MAAS,CAAA,CAAA,CAAI,CAC/B,KAAOA,CAAAA,CAAAA,CAAU,MAAM,GAAIhB,CAAAA,CAAAA,GAAS,CAClC,OAAA,CAASA,EAAK,OACd,CAAA,WAAA,CAAaA,EAAK,WAClB,CAAA,SAAA,CAAWA,EAAK,SAAU,CAAA,UAAA,EAC5B,CAAA,CAAE,CACJ,CAAI,CAAA,EACN,CAAE,CAAA,CACJ,CACF,CACF","file":"chunk-KFXRFY63.mjs","sourcesContent":["import crypto from 'crypto';\nconst rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate\n\nlet poolPtr = rnds8Pool.length;\nexport default function rng() {\n if (poolPtr > rnds8Pool.length - 16) {\n crypto.randomFillSync(rnds8Pool);\n poolPtr = 0;\n }\n\n return rnds8Pool.slice(poolPtr, poolPtr += 16);\n}","export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","import validate from './validate.js';\n\nfunction parse(uuid) {\n if (!validate(uuid)) {\n throw TypeError('Invalid UUID');\n }\n\n let v;\n const arr = new Uint8Array(16); // Parse ########-....-....-....-............\n\n arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;\n arr[1] = v >>> 16 & 0xff;\n arr[2] = v >>> 8 & 0xff;\n arr[3] = v & 0xff; // Parse ........-####-....-....-............\n\n arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;\n arr[5] = v & 0xff; // Parse ........-....-####-....-............\n\n arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;\n arr[7] = v & 0xff; // Parse ........-....-....-####-............\n\n arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;\n arr[9] = v & 0xff; // Parse ........-....-....-....-############\n // (Use \"/\" to avoid 32-bit truncation when bit-shifting high-order bytes)\n\n arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;\n arr[11] = v / 0x100000000 & 0xff;\n arr[12] = v >>> 24 & 0xff;\n arr[13] = v >>> 16 & 0xff;\n arr[14] = v >>> 8 & 0xff;\n arr[15] = v & 0xff;\n return arr;\n}\n\nexport default parse;","import { unsafeStringify } from './stringify.js';\nimport parse from './parse.js';\n\nfunction stringToBytes(str) {\n str = unescape(encodeURIComponent(str)); // UTF8 escape\n\n const bytes = [];\n\n for (let i = 0; i < str.length; ++i) {\n bytes.push(str.charCodeAt(i));\n }\n\n return bytes;\n}\n\nexport const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';\nexport const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';\nexport default function v35(name, version, hashfunc) {\n function generateUUID(value, namespace, buf, offset) {\n var _namespace;\n\n if (typeof value === 'string') {\n value = stringToBytes(value);\n }\n\n if (typeof namespace === 'string') {\n namespace = parse(namespace);\n }\n\n if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {\n throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');\n } // Compute hash of namespace and value, Per 4.3\n // Future: Use spread syntax when supported on all platforms, e.g. `bytes =\n // hashfunc([...namespace, ... value])`\n\n\n let bytes = new Uint8Array(16 + value.length);\n bytes.set(namespace);\n bytes.set(value, namespace.length);\n bytes = hashfunc(bytes);\n bytes[6] = bytes[6] & 0x0f | version;\n bytes[8] = bytes[8] & 0x3f | 0x80;\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = bytes[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(bytes);\n } // Function#name is not settable on some platforms (#270)\n\n\n try {\n generateUUID.name = name; // eslint-disable-next-line no-empty\n } catch (err) {} // For CommonJS default export support\n\n\n generateUUID.DNS = DNS;\n generateUUID.URL = URL;\n return generateUUID;\n}","import crypto from 'crypto';\nexport default {\n randomUUID: crypto.randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;","import crypto from 'crypto';\n\nfunction sha1(bytes) {\n if (Array.isArray(bytes)) {\n bytes = Buffer.from(bytes);\n } else if (typeof bytes === 'string') {\n bytes = Buffer.from(bytes, 'utf8');\n }\n\n return crypto.createHash('sha1').update(bytes).digest();\n}\n\nexport default sha1;","import v35 from './v35.js';\nimport sha1 from './sha1.js';\nconst v5 = v35('v5', 0x50, sha1);\nexport default v5;","import { v4 as uuidv4, v5 as uuidv5 } from 'uuid';\r\nimport ProductModel, { SelectionAttributes } from '../Classes/Product';\r\n\r\nconst Utils = {\r\n isUUID: (value: string): boolean => {\r\n const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\r\n return uuidRegex.test(value);\r\n },\r\n\r\n isEmail: (value: string): boolean => {\r\n const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/;\r\n return emailRegex.test(value);\r\n },\r\n\r\n isURL: (value: string): boolean => {\r\n const urlRegex = /^(http|https):\\/\\/[^ \"]+$/;\r\n return urlRegex.test(value);\r\n },\r\n \r\n generateUUID: (value?: string, namespace?: string) => {\r\n if(namespace && value){\r\n return uuidv5(value, namespace);\r\n }\r\n return uuidv4();\r\n },\r\n\r\n generateSearchId: (key: string, selectionAttributes: SelectionAttributes) => {\r\n return `${key}#${ProductModel.generateSelectionAttributesKey(selectionAttributes)}`;\r\n },\r\n\r\n getKeyfromSearchId: (searchId: string) => {\r\n const [key, selectionAttributesKey] = searchId.split('#');\r\n return {\r\n key,\r\n selectionAttributes: ProductModel.parseSelectionAttributesKey(selectionAttributesKey)\r\n }\r\n },\r\n\r\n /**\r\n * Deep clones an object using `structuredClone`. Don't use this on a class instance.\r\n * @param obj - The object to clone.\r\n * @returns A deep clone of the object.\r\n */\r\n deepClone<T>(obj: T): T {\r\n return structuredClone(obj);\r\n }\r\n}\r\n\r\nexport default Utils;\r\n","import Utils from \"../Utils\";\r\nimport BaseModel, { BaseAttributes } from \"./Base\";\r\nimport { Color, LocalizedString, CountryCode, LocaleCode, LocalizedValue, Prettify } from './Common';\r\nimport { GenderCategory, ImageCategory, LocaleLanguageMap, ProductType } from \"./Enum\";\r\nimport { DuplicateSelectionAttributeError, DuplicateSizeError, SelectionAttributeParseError } from \"./Error\";\r\nimport ImageInfoModel, { ImageInfoData } from \"./ImageInfo\";\r\nimport { TieredPriceModel, TieredPriceAttributes, TieredPriceData } from \"./TieredPrice\";\r\n\r\nexport type ProductSelectionAttributes = Prettify<{\r\n color: Color[];\r\n size: string[];\r\n} & {\r\n [key: string]: string | string[] | Color[];\r\n}>;\r\n\r\nexport type SelectionAttributes = {\r\n color: Color;\r\n [key: string]: string | Color;\r\n};\r\n\r\nexport type VariantData = {\r\n sku: string;\r\n selectionAttributes: SelectionAttributes;\r\n images: {\r\n primary: ImageInfoData;\r\n gallery: ImageInfoData[];\r\n };\r\n};\r\n\r\nexport type VariantModel = {\r\n sku: string;\r\n selectionAttributes: SelectionAttributes;\r\n images: {\r\n primary: ImageInfoModel;\r\n gallery: ImageInfoModel[];\r\n };\r\n};\r\n\r\n\r\nexport type ProductSpecification = { [key: string]: string | string[] };\r\n\r\nexport type ProductAttributes = BaseAttributes & {\r\n id: string;\r\n key: string;\r\n\r\n name: LocalizedString;\r\n description: LocalizedString;\r\n slug: LocalizedString;\r\n brand: string;\r\n\r\n pricing: {\r\n [country in CountryCode]?: TieredPriceAttributes;\r\n };\r\n\r\n targetGender: GenderCategory;\r\n attributes: ProductSelectionAttributes;\r\n specifications: LocalizedValue<ProductSpecification>;\r\n categories: string[];\r\n productType?: ProductType;\r\n\r\n variants: VariantData[];\r\n\r\n // Metadata\r\n isActive: boolean;\r\n searchTags?: LocalizedValue<string[]>;\r\n};\r\n\r\nexport type ProductData = Required<ProductAttributes>\r\n\r\nexport default class ProductModel extends BaseModel {\r\n protected id: string;\r\n protected key: string;\r\n\r\n protected name: LocalizedString;\r\n protected description: LocalizedString;\r\n protected slug: LocalizedString;\r\n protected brand: string;\r\n\r\n protected pricing: {\r\n [country in CountryCode]?: TieredPriceModel;\r\n };\r\n\r\n protected variants: VariantModel[];\r\n\r\n protected targetGender: GenderCategory;\r\n protected attributes: ProductSelectionAttributes;\r\n protected specifications: LocalizedValue<ProductSpecification>;\r\n protected categories: string[];\r\n protected productType: ProductType;\r\n\r\n // Metadata\r\n protected isActive: boolean;\r\n\r\n protected searchTags: LocalizedValue<string[]>;\r\n\r\n static productKeyRegex = /^(?!\\s)(?!.*\\s$)[A-Z0-9-]{4,16}$/;\r\n static productSKURegex = /^(?!\\s)(?!.*\\s$)[A-Z0-9-]{4,16}$/;\r\n\r\n /**\r\n * Generates a unique key for checking uniqueness for a given selection attributes.\r\n * Excludes 'size' from the key generation.\r\n * @param selectionAttributes - The selection attributes.\r\n * @returns A string key representing the unique attribute combination.\r\n */\r\n static generateSelectionAttributesKey(selectionAttributes: SelectionAttributes): string {\r\n if (typeof selectionAttributes !== 'object') {\r\n throw new SelectionAttributeParseError('Selection attributes must be an object');\r\n }\r\n\r\n const sortedKeys = Object.keys(selectionAttributes)\r\n .filter(key => selectionAttributes[key] !== undefined && key.toLowerCase() !== 'size')\r\n .sort()\r\n\r\n return sortedKeys.map(key => {\r\n if ((selectionAttributes[key] as Color).name) {\r\n return `${key}:c+${(selectionAttributes[key] as Color).name}`;\r\n }\r\n return `${key}:${selectionAttributes[key]}`;\r\n }).join('|').toLowerCase();\r\n }\r\n\r\n /**\r\n * Parses a selection attributes key into an object.\r\n * @param key - The selection attributes key to parse.\r\n * @returns An object containing the parsed selection attributes.\r\n */\r\n static parseSelectionAttributesKey(key: string): SelectionAttributes {\r\n try {\r\n const attributes: SelectionAttributes = {} as unknown as SelectionAttributes;\r\n const parts = key.split('|');\r\n for (const part of parts) {\r\n const [key, value] = part.split(':');\r\n if (value.startsWith('c+')) {\r\n attributes[key] = { name: value.slice(2) } as Color;\r\n } else {\r\n attributes[key] = value;\r\n }\r\n }\r\n return attributes;\r\n } catch (error: any) {\r\n throw new SelectionAttributeParseError(error?.message);\r\n }\r\n }\r\n\r\n /**\r\n * Creates an instance of ProductModel.\r\n * Initializes properties based on the provided data, creating copies where necessary.\r\n * @param data - The initial product attributes.\r\n * @param date - Optional date for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: ProductAttributes, date: Date = new Date()) {\r\n super(data, date);\r\n\r\n this.id = data.id;\r\n this.key = data.key;\r\n\r\n this.name = { ...data.name };\r\n this.description = { ...data.description };\r\n this.slug = { ...data.slug };\r\n this.brand = data.brand;\r\n\r\n this.pricing = (Object.keys(data.pricing) as CountryCode[]).reduce((acc, country) => {\r\n if (data.pricing[country]) {\r\n acc[country] = TieredPriceModel.create(data.pricing[country] as TieredPriceAttributes);\r\n }\r\n return acc;\r\n }, {} as { [country in CountryCode]?: TieredPriceModel });\r\n\r\n this.targetGender = data.targetGender;\r\n this.attributes = Utils.deepClone(data.attributes);\r\n this.specifications = Utils.deepClone(data.specifications);\r\n this.categories = Utils.deepClone(data.categories);\r\n this.productType = data.productType ?? ProductType.GOODS;\r\n\r\n const uniqueSelectionAttributes = new Set<string>();\r\n this.variants = (data.variants || []).map(variant => {\r\n if (!variant.selectionAttributes || typeof variant.selectionAttributes !== 'object') {\r\n throw new SelectionAttributeParseError('Selection attributes are required');\r\n }\r\n\r\n this.checkSelectionAttributes(variant.selectionAttributes);\r\n const key = ProductModel.generateSelectionAttributesKey(variant.selectionAttributes);\r\n if (uniqueSelectionAttributes.has(key)) {\r\n throw new DuplicateSelectionAttributeError(key);\r\n }\r\n uniqueSelectionAttributes.add(key);\r\n return {\r\n sku: variant.sku,\r\n selectionAttributes: variant.selectionAttributes,\r\n images: {\r\n primary: new ImageInfoModel(variant.images.primary),\r\n gallery: (variant.images.gallery || []).map(image => new ImageInfoModel(image))\r\n }\r\n };\r\n });\r\n\r\n this.isActive = data.isActive;\r\n this.searchTags = data.searchTags ? Utils.deepClone(data.searchTags) : { en: [] };\r\n }\r\n\r\n /**\r\n * Gets the base Product ID.\r\n * @returns Product ID.\r\n */\r\n getId(): string {\r\n return this.id;\r\n }\r\n\r\n /**\r\n * Gets the user-friendly product key.\r\n * @returns Product Key.\r\n */\r\n getKey(): string {\r\n return this.key;\r\n }\r\n\r\n /**\r\n * Gets the full localized product name object.\r\n * @returns A copy of the LocalizedString object for the name.\r\n */\r\n getName(): LocalizedString\r\n /**\r\n * Gets the product name for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The name string for the specified locale.\r\n */\r\n getName(locale: LocaleCode): string\r\n getName(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.name[locale] ?? this.name[LocaleLanguageMap[locale]] ?? this.name.en;\r\n } else {\r\n return Utils.deepClone(this.name);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the full localized product description object.\r\n * @returns A copy of the LocalizedString object for the description.\r\n */\r\n getDescription(): LocalizedString\r\n /**\r\n * Gets the product description for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The description string for the specified locale.\r\n */\r\n getDescription(locale: LocaleCode): string\r\n getDescription(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.description[locale] ?? this.description[LocaleLanguageMap[locale]] ?? this.description.en;\r\n } else {\r\n return Utils.deepClone(this.description);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the full localized product slug object.\r\n * @returns A copy of the LocalizedString object for the slug.\r\n */\r\n getSlug(): LocalizedString\r\n /**\r\n * Gets the product slug for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The slug string for the specified locale.\r\n */\r\n getSlug(locale: LocaleCode): string\r\n getSlug(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.slug[locale] ?? this.slug[LocaleLanguageMap[locale]] ?? this.slug.en;\r\n } else {\r\n return Utils.deepClone(this.slug);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the brand associated with the product.\r\n * @returns The brand name string.\r\n */\r\n getBrand(): string {\r\n return this.brand;\r\n }\r\n\r\n /**\r\n * Gets the tiered price details for the product.\r\n * @returns Pricing details mapped by country.\r\n */\r\n getPriceDetails(): { [country in CountryCode]?: TieredPriceModel }\r\n /**\r\n * Gets the tiered price details for a specific country.\r\n * @param country - The country code.\r\n * @returns The tiered price model for the country, or null if not found.\r\n */\r\n getPriceDetails(country: CountryCode): TieredPriceModel | null\r\n getPriceDetails(country?: CountryCode): { [country in CountryCode]?: TieredPriceModel } | TieredPriceModel | null {\r\n if (country) {\r\n return this.pricing[country] ?? null;\r\n }\r\n return { ...this.pricing };\r\n }\r\n\r\n /**\r\n * Gets the variant-specific attributes (color, sizes). Returns copies.\r\n * @returns Product Attributes.\r\n */\r\n getAttributes(): ProductSelectionAttributes {\r\n return Utils.deepClone(this.attributes);\r\n }\r\n\r\n\r\n /**\r\n * Gets the variant-specific attributes (color, sizes). Returns copies.\r\n * @returns Product Attributes.\r\n */\r\n getVariants(): VariantModel[] {\r\n return this.variants.map(variant => ({\r\n sku: variant.sku,\r\n selectionAttributes: Utils.deepClone(variant.selectionAttributes),\r\n images: {\r\n primary: variant.images.primary,\r\n gallery: [...variant.images.gallery]\r\n }\r\n }));\r\n }\r\n\r\n /**\r\n * Gets the images for a specific selection attribute combination.\r\n * @param selectionAttributes - The selection attributes to search for.\r\n * @returns The matching image set or null if not found.\r\n */\r\n private getImagesBySelectionAttributes(selectionAttributes: SelectionAttributes): { primary: ImageInfoModel; gallery: ImageInfoModel[] } | null {\r\n const searchKey = ProductModel.generateSelectionAttributesKey(selectionAttributes);\r\n\r\n const match = this.variants.find(variant =>\r\n ProductModel.generateSelectionAttributesKey(variant.selectionAttributes) === searchKey\r\n );\r\n\r\n return match ? {\r\n primary: match.images.primary,\r\n gallery: [...match.images.gallery]\r\n } : null;\r\n }\r\n\r\n /**\r\n * Gets the images for a specific selection attribute combination.\r\n * @param selectionAttributes - The selection attributes to search for.\r\n * @returns The matching image set or null if not found.\r\n */\r\n getImages(selectionAttributes: SelectionAttributes): { primary: ImageInfoModel; gallery: ImageInfoModel[] }\r\n getImages(selectionAttributes: SelectionAttributes, category: ImageCategory.PRIMARY): ImageInfoModel\r\n getImages(selectionAttributes: SelectionAttributes, category: ImageCategory.GALLERY): ImageInfoModel[]\r\n getImages(selectionAttributes: SelectionAttributes, category?: ImageCategory): { primary: ImageInfoModel; gallery: ImageInfoModel[] } | ImageInfoModel | ImageInfoModel[] {\r\n switch (category) {\r\n case ImageCategory.PRIMARY:\r\n return this.getImagesBySelectionAttributes(selectionAttributes)?.primary ?? this.variants[0]?.images?.primary;\r\n case ImageCategory.GALLERY:\r\n return this.getImagesBySelectionAttributes(selectionAttributes)?.gallery ?? [];\r\n default:\r\n return this.getImagesBySelectionAttributes(selectionAttributes) ?? { primary: this.variants[0]?.images?.primary, gallery: [] };\r\n }\r\n }\r\n\r\n\r\n /**\r\n * Checks if the product is active.\r\n * @returns True if the product is active, false otherwise.\r\n */\r\n getIsActive(): boolean {\r\n return this.isActive;\r\n }\r\n\r\n /**\r\n * Gets the target gender category for the product.\r\n * @returns The GenderCategory enum value.\r\n */\r\n getTargetGender(): GenderCategory {\r\n return this.targetGender;\r\n }\r\n\r\n /**\r\n * Gets the list of categories the product belongs to. Returns a copy.\r\n * @returns An array of category.\r\n */\r\n getCategories(): string[] {\r\n return Utils.deepClone(this.categories);\r\n }\r\n\r\n /**\r\n * Gets the product type.\r\n * @returns ProductType.\r\n */\r\n getProductType(): ProductType {\r\n return this.productType;\r\n }\r\n\r\n /**\r\n * Gets the full localized product specifications object.\r\n * @returns Product Specifications\r\n */\r\n getSpecifications(): LocalizedValue<ProductSpecification>\r\n /**\r\n * Gets the product specifications for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The ProductSpecification object for the specified locale, or undefined if not found.\r\n */\r\n getSpecifications(locale: LocaleCode): ProductSpecification\r\n getSpecifications(locale?: LocaleCode): LocalizedValue<ProductSpecification> | ProductSpecification {\r\n if (locale) {\r\n return Utils.deepClone(this.specifications[locale] ?? this.specifications[LocaleLanguageMap[locale]] ?? this.specifications.en);\r\n } else {\r\n return Utils.deepClone(this.specifications);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the localized list of search tags. Returns a copy.\r\n * @returns Localized array of search tags.\r\n */\r\n getSearchTags(): LocalizedValue<string[]>\r\n /**\r\n * Gets the search tags for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The array of search tags for the specified locale, or undefined if not found.\r\n */\r\n getSearchTags(locale: LocaleCode): string[]\r\n getSearchTags(locale?: LocaleCode): LocalizedValue<string[]> | string[] {\r\n if (locale) {\r\n return Utils.deepClone(this.searchTags[locale] ?? this.searchTags[LocaleLanguageMap[locale]] ?? this.searchTags.en);\r\n } else {\r\n return Utils.deepClone(this.searchTags);\r\n }\r\n }\r\n\r\n /**\r\n *\r\n * @returns ProductData\r\n */\r\n getDetails(): ProductData {\r\n const baseDetails = super.getDetails();\r\n return {\r\n id: this.getId(),\r\n key: this.getKey(),\r\n name: this.getName(),\r\n description: this.getDescription(),\r\n slug: this.getSlug(),\r\n brand: this.getBrand(),\r\n pricing: (Object.keys(this.pricing) as CountryCode[]).reduce((acc, country) => {\r\n if (this.pricing[country]) {\r\n acc[country] = this.pricing[country]?.getDetails();\r\n }\r\n return acc;\r\n }, {} as { [country in CountryCode]: TieredPriceData }),\r\n attributes: this.getAttributes(),\r\n variants: this.variants.map(v => ({\r\n sku: v.sku,\r\n selectionAttributes: Utils.deepClone(v.selectionAttributes),\r\n images: {\r\n primary: v.images.primary.getDetails(),\r\n gallery: v.images.gallery.map(img => img.getDetails())\r\n }\r\n })),\r\n isActive: this.getIsActive(),\r\n targetGender: this.getTargetGender(),\r\n categories: this.getCategories(),\r\n productType: this.getProductType(),\r\n specifications: this.getSpecifications(),\r\n searchTags: this.getSearchTags(),\r\n ...baseDetails\r\n };\r\n }\r\n\r\n /**\r\n * Checks if the provided selection attributes are valid for the product.\r\n * @param selectionAttributes The selection attributes to validate.\r\n * @throws {SelectionAttributeParseError} If the selection attributes are invalid.\r\n */\r\n checkSelectionAttributes(selectionAttributes: SelectionAttributes): void {\r\n if (!selectionAttributes || typeof selectionAttributes !== 'object') {\r\n throw new SelectionAttributeParseError('Selection attributes are required');\r\n }\r\n\r\n Object.keys(this.attributes).forEach(key => {\r\n if(key.toLowerCase() === 'size') return;\r\n \r\n const allowedAttributeValues = this.attributes[key];\r\n const providedValue = selectionAttributes[key];\r\n\r\n if (providedValue === undefined) {\r\n throw new SelectionAttributeParseError(`Selection attribute '${key}' is missing`);\r\n }\r\n\r\n if (typeof allowedAttributeValues === 'string') {\r\n if (typeof providedValue !== 'string' || allowedAttributeValues !== providedValue) {\r\n throw new SelectionAttributeParseError(`Selection attribute '${key}' is invalid`);\r\n }\r\n } else if (Array.isArray(allowedAttributeValues)) {\r\n if (allowedAttributeValues.length > 0 && typeof allowedAttributeValues[0] === 'string') {\r\n if (typeof providedValue !== 'string' || !(allowedAttributeValues as string[]).includes(providedValue)) {\r\n throw new SelectionAttributeParseError(`Selection attribute '${key}' is invalid`);\r\n }\r\n } else {\r\n // Color validation\r\n if (\r\n typeof providedValue !== 'object' ||\r\n !('name' in providedValue) ||\r\n (allowedAttributeValues as Color[]).findIndex(c => c.name === (providedValue as Color).name) < 0\r\n ) {\r\n throw new SelectionAttributeParseError(`Selection attribute '${key}' is invalid`);\r\n }\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Gets the SKU of the variant matching the selection attributes.\r\n * @param selectionAttributes - The selection attributes to search for.\r\n * @returns The SKU string, or undefined if no matching variant is found.\r\n */\r\n public getSku(selectionAttributes: SelectionAttributes): string | undefined {\r\n const searchKey = ProductModel.generateSelectionAttributesKey(selectionAttributes);\r\n const match = this.variants.find(variant =>\r\n ProductModel.generateSelectionAttributesKey(variant.selectionAttributes) === searchKey\r\n );\r\n return match?.sku;\r\n }\r\n\r\n /**\r\n * Validates if the provided selection attributes exist for this product.\r\n * @param selectionAttributes - The attributes to validate.\r\n * @returns True if a valid selection attribute exists, false otherwise.\r\n */\r\n validateSelectionAttribute(selectionAttributes: SelectionAttributes): boolean {\r\n const searchKey = ProductModel.generateSelectionAttributesKey(selectionAttributes);\r\n\r\n return this.variants.some(variant => ProductModel.generateSelectionAttributesKey(variant.selectionAttributes) === searchKey);\r\n }\r\n\r\n /**\r\n * Validates if a specific size is available for this product.\r\n * @param size - The size to check.\r\n * @returns True if the size exists in the product's attributes, false otherwise.\r\n */\r\n validateSize(size: string): boolean {\r\n return this.attributes.size.includes(size);\r\n }\r\n}\r\n","import PriceModel, { PriceData } from \"./Price\";\nimport type { SelectionAttributes } from \"./Product\";\nimport ProductModel from \"./Product\";\nimport {\n InvalidTaxCategoryError,\n InvalidMinQuantityError,\n InvalidTieredPriceError,\n InvalidQuantityError,\n InvalidPricingTypeError,\n NoApplicableTierError\n} from \"./Error\";\nimport { CountryCode, CurrencyCode, Prettify } from \"./Common\";\n\nexport enum PricingType {\n VOLUME = 'volume',\n SELECTION = 'selection',\n}\n\n/**\n * Represents a pricing tier based on a minimum purchase quantity.\n */\nexport type PriceTier = {\n enabled: boolean;\n minQuantity: number;\n unitPrice: PriceModel;\n};\n\nexport type PriceTierData = {\n enabled: boolean;\n minQuantity: number;\n unitPrice: PriceData;\n};\n\n/**\n * Represents the configuration for a specific selection variant.\n */\nexport type SelectionPricingData = {\n selectionAttributes: SelectionAttributes;\n baseUnitPrice: PriceData;\n tiers?: PriceTierData[];\n};\n\nexport type SelectionPricing = {\n selectionAttributes: SelectionAttributes;\n baseUnitPrice: PriceModel;\n tiers: PriceTier[];\n};\n\nexport type PriceTierAttributes = Prettify<Omit<PriceTierData, 'enabled'> & { enabled?: boolean }>;\n\n/**\n * Represents the attributes required for tiered pricing.\n */\nexport type VolumenTieredPriceAttributes = {\n type?: PricingType.VOLUME;\n taxCategory: string;\n isTaxInclusive?: boolean;\n currency?: CurrencyCode;\n baseUnitPrice: PriceData;\n tiers: PriceTierAttributes[];\n}\n\nexport type SelectionTieredPriceAttributes = {\n type: PricingType.SELECTION;\n taxCategory: string;\n isTaxInclusive?: boolean;\n currency: CurrencyCode;\n selections: (Omit<SelectionPricingData, 'tiers'> & { tiers?: PriceTierAttributes[] })[];\n}\n\nexport type TieredPriceAttributes = VolumenTieredPriceAttributes | SelectionTieredPriceAttributes;\n\nexport type TieredPriceData = Prettify<{\n taxCategory: string;\n isTaxInclusive: boolean;\n currency: CurrencyCode;\n} & ({\n type?: PricingType.VOLUME;\n baseUnitPrice: PriceData;\n tiers: PriceTierData[];\n} | {\n type: PricingType.SELECTION;\n selections: SelectionPricingData[];\n})>;\n\nexport abstract class TieredPriceModel {\n protected type: PricingType;\n protected taxCategory: string;\n protected isTaxInclusive: boolean;\n\n /** \n * Factory method to instantiate the correct concrete TieredPriceModel implementation.\n */\n static create(data: TieredPriceAttributes): TieredPriceModel {\n if (data.type === PricingType.SELECTION) {\n return new SelectionTieredPriceModel(data);\n }\n return new VolumeTieredPriceModel(data);\n }\n\n constructor(data: TieredPriceAttributes) {\n if (!data.taxCategory) {\n throw new InvalidTaxCategoryError();\n }\n this.taxCategory = data.taxCategory;\n this.isTaxInclusive = data.isTaxInclusive ?? false;\n this.type = data.type ?? PricingType.VOLUME;\n }\n\n getType(): PricingType {\n return this.type;\n }\n\n getTaxCategory(): string {\n return this.taxCategory;\n }\n\n getIsTaxInclusive(): boolean {\n return this.isTaxInclusive;\n }\n\n abstract isPriceAvailable(selectionAttributes?: SelectionAttributes): boolean;\n abstract getBaseUnitPrice(selectionAttributes?: SelectionAttributes): PriceModel;\n abstract getDetails(): TieredPriceData;\n abstract getCurrency(): CurrencyCode;\n abstract getApplicableUnitPrice(quantity: number, selectionAttributes?: SelectionAttributes): PriceModel;\n abstract getMinQuantity(selectionAttributes?: SelectionAttributes): number;\n abstract getMaxDiscountPercent(selectionAttributes?: SelectionAttributes): number;\n abstract getTiers(selectionAttributes?: SelectionAttributes): PriceTier[];\n abstract getMinPrice(selectionAttributes?: SelectionAttributes): PriceModel | null;\n abstract getMaxPrice(selectionAttributes?: SelectionAttributes): PriceModel | null;\n}\n\nexport class VolumeTieredPriceModel extends TieredPriceModel {\n protected baseUnitPrice: PriceModel;\n protected tiers: PriceTier[];\n protected currency: CurrencyCode;\n\n constructor(data: Extract<TieredPriceAttributes, { type?: PricingType.VOLUME }>) {\n super(data);\n this.type = PricingType.VOLUME;\n \n if (!data.baseUnitPrice) {\n throw new InvalidTieredPriceError(\"Base unit price is required for volume pricing.\");\n }\n this.baseUnitPrice = new PriceModel(data.baseUnitPrice);\n this.currency = data.currency ?? this.baseUnitPrice.getCurrency();\n\n const tiers = (data.tiers ?? [])\n .map(tier => ({\n enabled: tier.enabled ?? true,\n minQuantity: tier.minQuantity,\n unitPrice: new PriceModel(tier.unitPrice),\n }))\n .sort((a, b) => a.minQuantity - b.minQuantity);\n\n const hasInvalidMinQuantity = tiers.some(t => t.minQuantity <= 0);\n if (hasInvalidMinQuantity) {\n throw new InvalidMinQuantityError();\n }\n\n const hasDifferentCurrency = this.baseUnitPrice.getCurrency() !== this.currency || tiers.some(\n t => t.unitPrice.getCurrency() !== this.currency\n );\n const hasIrregularPricing = tiers.some(\n (tier, index) =>\n index > 0 &&\n tier.unitPrice.compareTo(tiers[index - 1].unitPrice) > 0\n );\n const basePriceExceedsFirstTier = tiers[0]?.unitPrice.compareTo(this.baseUnitPrice) > 0;\n\n if (hasDifferentCurrency || hasIrregularPricing || basePriceExceedsFirstTier) {\n throw new InvalidTieredPriceError(\n \"Tiers must share the same currency and must not increase in unit price.\"\n );\n }\n\n this.tiers = tiers;\n }\n\n isPriceAvailable(): boolean {\n return this.tiers.filter(t => t.enabled).length > 0;\n }\n\n getBaseUnitPrice(): PriceModel {\n return this.baseUnitPrice;\n }\n\n getCurrency(): CurrencyCode {\n return this.baseUnitPrice.getCurrency();\n }\n\n getApplicableUnitPrice(quantity: number): PriceModel {\n if (quantity <= 0) {\n throw new InvalidQuantityError();\n }\n\n const enabledTiers = this.tiers.filter(t => t.enabled);\n for (let i = enabledTiers.length - 1; i >= 0; i--) {\n const tier = enabledTiers[i];\n if (quantity >= tier.minQuantity) {\n return tier.unitPrice;\n }\n }\n\n throw new NoApplicableTierError(quantity);\n }\n\n getMinQuantity(): number {\n const enabledTiers = this.tiers.filter(tier => tier.enabled);\n return enabledTiers[0]?.minQuantity ?? 1;\n }\n\n getMaxDiscountPercent(): number {\n const enabledTiers = this.tiers.filter(tier => tier.enabled);\n if (!enabledTiers.length) return 0;\n \n const minTierPrice = Math.min(...enabledTiers.map(t => t.unitPrice.getAmount()));\n const basePrice = this.baseUnitPrice.getAmount();\n \n const discount = ((basePrice - minTierPrice) / basePrice) * 100;\n return discount > 0 ? discount : 0;\n }\n\n getMinPrice(): PriceModel | null {\n const enabledTiers = this.tiers.filter(tier => tier.enabled);\n return enabledTiers.length ? enabledTiers[enabledTiers.length - 1].unitPrice : null;\n }\n\n getMaxPrice(): PriceModel | null {\n const enabledTiers = this.tiers.filter(tier => tier.enabled);\n return enabledTiers.length ? enabledTiers[0].unitPrice : null;\n }\n\n getTiers(): PriceTier[] {\n return this.tiers.map(tier => ({\n enabled: tier.enabled,\n minQuantity: tier.minQuantity,\n unitPrice: tier.unitPrice\n }));\n }\n\n getDetails(): TieredPriceData {\n return {\n type: this.type as PricingType.VOLUME,\n taxCategory: this.taxCategory,\n isTaxInclusive: this.isTaxInclusive,\n currency: this.currency,\n baseUnitPrice: this.baseUnitPrice.getDetails(),\n tiers: this.tiers.map(tier => ({\n enabled: tier.enabled,\n minQuantity: tier.minQuantity,\n unitPrice: tier.unitPrice.getDetails()\n }))\n };\n }\n}\n\nexport class SelectionTieredPriceModel extends TieredPriceModel {\n protected currency: CurrencyCode;\n protected selections: SelectionPricing[];\n\n constructor(data: Extract<TieredPriceAttributes, { type: PricingType.SELECTION }>) {\n super(data);\n this.type = PricingType.SELECTION;\n this.currency = data.currency;\n\n this.selections = (data.selections ?? []).map(selection => {\n if (!selection.baseUnitPrice) {\n throw new InvalidTieredPriceError(\"Base unit price is required for each selection.\");\n }\n const baseUnitPrice = new PriceModel(selection.baseUnitPrice);\n\n const tiers = (selection.tiers ?? [])\n .map(tier => ({\n enabled: tier.enabled ?? true,\n minQuantity: tier.minQuantity ?? 1,\n unitPrice: new PriceModel(tier.unitPrice),\n }))\n .sort((a, b) => a.minQuantity - b.minQuantity);\n\n const hasInvalidMinQuantity = tiers.some(t => t.minQuantity <= 0);\n if (hasInvalidMinQuantity) {\n throw new InvalidMinQuantityError();\n }\n\n const hasDifferentCurrency = baseUnitPrice.getCurrency() !== this.currency || tiers.some(\n t => t.unitPrice.getCurrency() !== this.currency\n );\n const hasIrregularPricing = tiers.some(\n (tier, index) =>\n index > 0 &&\n tier.unitPrice.compareTo(tiers[index - 1].unitPrice) > 0\n );\n const basePriceExceedsFirstTier = tiers[0]?.unitPrice.compareTo(baseUnitPrice) > 0;\n\n if (hasDifferentCurrency || hasIrregularPricing || basePriceExceedsFirstTier) {\n throw new InvalidTieredPriceError(\n \"Tiers must share the same currency and must not increase in unit price within the same selection.\"\n );\n }\n\n return {\n selectionAttributes: { ...selection.selectionAttributes },\n baseUnitPrice,\n tiers\n };\n });\n }\n\n protected findMatch(selectionAttributes: SelectionAttributes, throwOnNotFound = false): SelectionPricing | null {\n const key = ProductModel.generateSelectionAttributesKey(selectionAttributes);\n const match = this.selections.find(\n s => ProductModel.generateSelectionAttributesKey(s.selectionAttributes) === key\n );\n if (!match && throwOnNotFound) {\n throw new InvalidTieredPriceError(\"No pricing configuration found for selection variant.\");\n }\n return match ?? null;\n }\n\n isPriceAvailable(selectionAttributes?: SelectionAttributes): boolean {\n if(!selectionAttributes) {\n console.warn('Selection attributes are required to check price availability for selection pricing.');\n return false;\n }\n const match = this.findMatch(selectionAttributes);\n return match ? match.tiers.filter(t => t.enabled).length > 0 : false;\n }\n\n getBaseUnitPrice(selectionAttributes?: SelectionAttributes): PriceModel {\n if (!selectionAttributes) {\n throw new InvalidPricingTypeError(\"Selection attributes are required to get base unit price for selection pricing.\");\n }\n const match = this.findMatch(selectionAttributes, true)!;\n return match.baseUnitPrice;\n }\n\n getCurrency(): CurrencyCode {\n return this.currency;\n }\n\n getApplicableUnitPrice(quantity: number, selectionAttributes?: SelectionAttributes): PriceModel {\n if (quantity <= 0) {\n throw new InvalidQuantityError();\n }\n if (!selectionAttributes) {\n throw new InvalidPricingTypeError(\"Selection attributes are required to get applicable unit price for selection pricing.\");\n }\n \n const match = this.findMatch(selectionAttributes, true)!;\n\n const enabledTiers = match.tiers.filter(t => t.enabled);\n for (let i = enabledTiers.length - 1; i >= 0; i--) {\n const tier = enabledTiers[i];\n if (quantity >= tier.minQuantity) {\n return tier.unitPrice;\n }\n }\n throw new NoApplicableTierError(quantity);\n }\n\n getMinQuantity(selectionAttributes?: SelectionAttributes): number {\n if (!selectionAttributes) {\n throw new InvalidPricingTypeError(\"Selection attributes are required to get min quantity for selection pricing.\");\n }\n const match = this.findMatch(selectionAttributes, true)!;\n const enabledTiers = match.tiers.filter(t => t.enabled);\n return enabledTiers[0]?.minQuantity ?? 1;\n }\n\n getMaxDiscountPercent(selectionAttributes?: SelectionAttributes): number {\n if (!selectionAttributes) {\n throw new InvalidPricingTypeError(\"Selection attributes are required to get max discount for selection pricing.\");\n }\n const match = this.findMatch(selectionAttributes, true)!;\n\n const enabledTiers = match.tiers.filter(t => t.enabled);\n if (!enabledTiers.length) return 0;\n\n const minTierPrice = Math.min(...enabledTiers.map(t => t.unitPrice.getAmount()));\n const basePrice = match.baseUnitPrice.getAmount();\n \n const discount = ((basePrice - minTierPrice) / basePrice) * 100;\n return discount > 0 ? discount : 0;\n }\n\n getTiers(selectionAttributes?: SelectionAttributes): PriceTier[] {\n if (!selectionAttributes) {\n throw new InvalidPricingTypeError(\"Selection attributes are required to get tiers for selection pricing.\");\n }\n const match = this.findMatch(selectionAttributes, true)!;\n return match.tiers.map(tier => ({\n enabled: tier.enabled,\n minQuantity: tier.minQuantity,\n unitPrice: tier.unitPrice\n }));\n }\n\n getMinPrice(selectionAttributes?: SelectionAttributes): PriceModel | null {\n if (!selectionAttributes) {\n throw new InvalidPricingTypeError(\"Selection attributes are required to get min price for selection pricing.\");\n }\n const match = this.findMatch(selectionAttributes);\n if (!match) return null;\n const enabledTiers = match.tiers.filter(t => t.enabled);\n return enabledTiers.length ? enabledTiers[enabledTiers.length - 1].unitPrice : null;\n }\n\n getMaxPrice(selectionAttributes?: SelectionAttributes): PriceModel | null {\n if (!selectionAttributes) {\n throw new InvalidPricingTypeError(\"Selection attributes are required to get max price for selection pricing.\");\n }\n const match = this.findMatch(selectionAttributes);\n if (!match) return null;\n const enabledTiers = match.tiers.filter(t => t.enabled);\n return enabledTiers.length ? enabledTiers[0].unitPrice : null;\n }\n\n getDetails(): TieredPriceData {\n return {\n type: this.type as PricingType.SELECTION,\n taxCategory: this.taxCategory,\n isTaxInclusive: this.isTaxInclusive,\n currency: this.currency,\n selections: this.selections.map(selection => ({\n selectionAttributes: selection.selectionAttributes,\n baseUnitPrice: selection.baseUnitPrice.getDetails(),\n ...(selection.tiers.length > 0 ? {\n tiers: selection.tiers.map(tier => ({\n enabled: tier.enabled,\n minQuantity: tier.minQuantity,\n unitPrice: tier.unitPrice.getDetails()\n }))\n } : {})\n }))\n };\n }\n}\n"]}
1
+ {"version":3,"sources":["../node_modules/uuid/dist/esm-node/rng.js","../node_modules/uuid/dist/esm-node/regex.js","../node_modules/uuid/dist/esm-node/validate.js","../node_modules/uuid/dist/esm-node/stringify.js","../node_modules/uuid/dist/esm-node/parse.js","../node_modules/uuid/dist/esm-node/v35.js","../node_modules/uuid/dist/esm-node/native.js","../node_modules/uuid/dist/esm-node/v4.js","../node_modules/uuid/dist/esm-node/sha1.js","../node_modules/uuid/dist/esm-node/v5.js","../src/Utils/index.ts","../src/Classes/Product.ts","../src/Classes/TieredPrice.ts"],"names":["rnds8Pool","poolPtr","rng","crypto","regex_default","validate","uuid","validate_default","byteToHex","i","unsafeStringify","arr","offset","parse","v","parse_default","stringToBytes","str","bytes","DNS","URL","v35","name","version","hashfunc","generateUUID","value","namespace","buf","_namespace","native_default","v4","options","rnds","v4_default","sha1","sha1_default","v5","v5_default","Utils","key","selectionAttributes","ProductModel","searchId","selectionAttributesKey","obj","Utils_default","_ProductModel","BaseModel","SelectionAttributeParseError","attributes","parts","part","error","data","date","acc","country","TieredPriceModel","uniqueSelectionAttributes","variant","DuplicateSelectionAttributeError","ImageInfoModel","image","locale","LocaleLanguageMap","searchKey","match","category","baseDetails","img","allowedAttributeValues","providedValue","c","size","PricingType","SelectionTieredPriceModel","VolumeTieredPriceModel","InvalidTaxCategoryError","InvalidTieredPriceError","PriceModel","tiers","tier","a","b","t","InvalidMinQuantityError","hasDifferentCurrency","hasIrregularPricing","index","basePriceExceedsFirstTier","quantity","InvalidQuantityError","enabledTiers","NoApplicableTierError","minTierPrice","basePrice","discount","selection","baseUnitPrice","throwOnNotFound","InvalidPricingTypeError"],"mappings":"yPACA,IAAMA,CAAY,CAAA,IAAI,WAAW,GAAG,CAAA,CAEhCC,CAAUD,CAAAA,CAAAA,CAAU,OACT,SAARE,CAAAA,EAAuB,CAC5B,OAAID,CAAAA,CAAUD,EAAU,MAAS,CAAA,EAAA,GAC/BG,CAAO,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AAY,IAC3D,CAEA,YAAuC,CACrC,OAAO,CACL,IAAM,CAAA,IAAA,CAAK,KACX,WAAa,CAAA,IAAA,CAAK,WAClB,CAAA,cAAA,CAAgB,KAAK,cACrB,CAAA,QAAA,CAAU,KAAK,QACf,CAAA,UAAA,CAAY,KAAK,UAAW,CAAA,GAAA,CAAIK,CAAc,GAAA,CAC5C,oBAAqBA,CAAU,CAAA,mBAAA,CAC/B,aAAeA,CAAAA,CAAAA,CAAU,cAAc,UAAW,EAAA,CAClD,GAAIA,CAAAA,CAAU,MAAM,MAAS,CAAA,CAAA,CAAI,CAC/B,KAAOA,CAAAA,CAAAA,CAAU,MAAM,GAAIhB,CAAAA,CAAAA,GAAS,CAClC,OAAA,CAASA,EAAK,OACd,CAAA,WAAA,CAAaA,EAAK,WAClB,CAAA,SAAA,CAAWA,EAAK,SAAU,CAAA,UAAA,EAC5B,CAAA,CAAE,CACJ,CAAI,CAAA,EACN,CAAE,CAAA,CACJ,CACF,CACF","file":"chunk-4PTWJI6J.mjs","sourcesContent":["import crypto from 'crypto';\nconst rnds8Pool = new Uint8Array(256); // # of random values to pre-allocate\n\nlet poolPtr = rnds8Pool.length;\nexport default function rng() {\n if (poolPtr > rnds8Pool.length - 16) {\n crypto.randomFillSync(rnds8Pool);\n poolPtr = 0;\n }\n\n return rnds8Pool.slice(poolPtr, poolPtr += 16);\n}","export default /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;","import REGEX from './regex.js';\n\nfunction validate(uuid) {\n return typeof uuid === 'string' && REGEX.test(uuid);\n}\n\nexport default validate;","import validate from './validate.js';\n/**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n\nconst byteToHex = [];\n\nfor (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n}\n\nexport function unsafeStringify(arr, offset = 0) {\n // Note: Be careful editing this code! It's been tuned for performance\n // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434\n return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];\n}\n\nfunction stringify(arr, offset = 0) {\n const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one\n // of the following:\n // - One or more input array values don't map to a hex octet (leading to\n // \"undefined\" in the uuid)\n // - Invalid input values for the RFC `version` or `variant` fields\n\n if (!validate(uuid)) {\n throw TypeError('Stringified UUID is invalid');\n }\n\n return uuid;\n}\n\nexport default stringify;","import validate from './validate.js';\n\nfunction parse(uuid) {\n if (!validate(uuid)) {\n throw TypeError('Invalid UUID');\n }\n\n let v;\n const arr = new Uint8Array(16); // Parse ########-....-....-....-............\n\n arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;\n arr[1] = v >>> 16 & 0xff;\n arr[2] = v >>> 8 & 0xff;\n arr[3] = v & 0xff; // Parse ........-####-....-....-............\n\n arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;\n arr[5] = v & 0xff; // Parse ........-....-####-....-............\n\n arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;\n arr[7] = v & 0xff; // Parse ........-....-....-####-............\n\n arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;\n arr[9] = v & 0xff; // Parse ........-....-....-....-############\n // (Use \"/\" to avoid 32-bit truncation when bit-shifting high-order bytes)\n\n arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;\n arr[11] = v / 0x100000000 & 0xff;\n arr[12] = v >>> 24 & 0xff;\n arr[13] = v >>> 16 & 0xff;\n arr[14] = v >>> 8 & 0xff;\n arr[15] = v & 0xff;\n return arr;\n}\n\nexport default parse;","import { unsafeStringify } from './stringify.js';\nimport parse from './parse.js';\n\nfunction stringToBytes(str) {\n str = unescape(encodeURIComponent(str)); // UTF8 escape\n\n const bytes = [];\n\n for (let i = 0; i < str.length; ++i) {\n bytes.push(str.charCodeAt(i));\n }\n\n return bytes;\n}\n\nexport const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';\nexport const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';\nexport default function v35(name, version, hashfunc) {\n function generateUUID(value, namespace, buf, offset) {\n var _namespace;\n\n if (typeof value === 'string') {\n value = stringToBytes(value);\n }\n\n if (typeof namespace === 'string') {\n namespace = parse(namespace);\n }\n\n if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {\n throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');\n } // Compute hash of namespace and value, Per 4.3\n // Future: Use spread syntax when supported on all platforms, e.g. `bytes =\n // hashfunc([...namespace, ... value])`\n\n\n let bytes = new Uint8Array(16 + value.length);\n bytes.set(namespace);\n bytes.set(value, namespace.length);\n bytes = hashfunc(bytes);\n bytes[6] = bytes[6] & 0x0f | version;\n bytes[8] = bytes[8] & 0x3f | 0x80;\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = bytes[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(bytes);\n } // Function#name is not settable on some platforms (#270)\n\n\n try {\n generateUUID.name = name; // eslint-disable-next-line no-empty\n } catch (err) {} // For CommonJS default export support\n\n\n generateUUID.DNS = DNS;\n generateUUID.URL = URL;\n return generateUUID;\n}","import crypto from 'crypto';\nexport default {\n randomUUID: crypto.randomUUID\n};","import native from './native.js';\nimport rng from './rng.js';\nimport { unsafeStringify } from './stringify.js';\n\nfunction v4(options, buf, offset) {\n if (native.randomUUID && !buf && !options) {\n return native.randomUUID();\n }\n\n options = options || {};\n const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`\n\n rnds[6] = rnds[6] & 0x0f | 0x40;\n rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided\n\n if (buf) {\n offset = offset || 0;\n\n for (let i = 0; i < 16; ++i) {\n buf[offset + i] = rnds[i];\n }\n\n return buf;\n }\n\n return unsafeStringify(rnds);\n}\n\nexport default v4;","import crypto from 'crypto';\n\nfunction sha1(bytes) {\n if (Array.isArray(bytes)) {\n bytes = Buffer.from(bytes);\n } else if (typeof bytes === 'string') {\n bytes = Buffer.from(bytes, 'utf8');\n }\n\n return crypto.createHash('sha1').update(bytes).digest();\n}\n\nexport default sha1;","import v35 from './v35.js';\nimport sha1 from './sha1.js';\nconst v5 = v35('v5', 0x50, sha1);\nexport default v5;","import { v4 as uuidv4, v5 as uuidv5 } from 'uuid';\r\nimport ProductModel, { SelectionAttributes } from '../Classes/Product';\r\n\r\nconst Utils = {\r\n isUUID: (value: string): boolean => {\r\n const uuidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;\r\n return uuidRegex.test(value);\r\n },\r\n\r\n isEmail: (value: string): boolean => {\r\n const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$/;\r\n return emailRegex.test(value);\r\n },\r\n\r\n isURL: (value: string): boolean => {\r\n const urlRegex = /^(http|https):\\/\\/[^ \"]+$/;\r\n return urlRegex.test(value);\r\n },\r\n \r\n generateUUID: (value?: string, namespace?: string) => {\r\n if(namespace && value){\r\n return uuidv5(value, namespace);\r\n }\r\n return uuidv4();\r\n },\r\n\r\n generateSearchId: (key: string, selectionAttributes: SelectionAttributes) => {\r\n return `${key}#${ProductModel.generateSelectionAttributesKey(selectionAttributes)}`;\r\n },\r\n\r\n getKeyfromSearchId: (searchId: string) => {\r\n const [key, selectionAttributesKey] = searchId.split('#');\r\n return {\r\n key,\r\n selectionAttributes: ProductModel.parseSelectionAttributesKey(selectionAttributesKey)\r\n }\r\n },\r\n\r\n /**\r\n * Deep clones an object using `structuredClone`. Don't use this on a class instance.\r\n * @param obj - The object to clone.\r\n * @returns A deep clone of the object.\r\n */\r\n deepClone<T>(obj: T): T {\r\n return structuredClone(obj);\r\n }\r\n}\r\n\r\nexport default Utils;\r\n","import Utils from \"../Utils\";\r\nimport BaseModel, { BaseAttributes } from \"./Base\";\r\nimport { Color, LocalizedString, CountryCode, LocaleCode, LocalizedValue, Prettify } from './Common';\r\nimport { GenderCategory, ImageCategory, LocaleLanguageMap, ProductType } from \"./Enum\";\r\nimport { DuplicateSelectionAttributeError, DuplicateSizeError, SelectionAttributeParseError } from \"./Error\";\r\nimport ImageInfoModel, { ImageInfoData } from \"./ImageInfo\";\r\nimport { TieredPriceModel, TieredPriceAttributes, TieredPriceData } from \"./TieredPrice\";\r\n\r\nexport type ProductSelectionAttributes = Prettify<{\r\n color: Color[];\r\n size: string[];\r\n} & {\r\n [key: string]: string | string[] | Color[];\r\n}>;\r\n\r\nexport type SelectionAttributes = {\r\n color: Color;\r\n [key: string]: string | Color;\r\n};\r\n\r\nexport type VariantData = {\r\n sku: string;\r\n selectionAttributes: SelectionAttributes;\r\n images: {\r\n primary: ImageInfoData;\r\n gallery: ImageInfoData[];\r\n };\r\n};\r\n\r\nexport type VariantModel = {\r\n sku: string;\r\n selectionAttributes: SelectionAttributes;\r\n images: {\r\n primary: ImageInfoModel;\r\n gallery: ImageInfoModel[];\r\n };\r\n};\r\n\r\n\r\nexport type ProductSpecification = { [key: string]: string | string[] };\r\n\r\nexport type ProductAttributes = BaseAttributes & {\r\n id: string;\r\n key: string;\r\n\r\n name: LocalizedString;\r\n description: LocalizedString;\r\n slug: LocalizedString;\r\n brand: string;\r\n\r\n pricing: {\r\n [country in CountryCode]?: TieredPriceAttributes;\r\n };\r\n\r\n targetGender: GenderCategory;\r\n attributes: ProductSelectionAttributes;\r\n specifications: LocalizedValue<ProductSpecification>;\r\n categories: string[];\r\n productType?: ProductType;\r\n\r\n variants: VariantData[];\r\n\r\n // Metadata\r\n isActive: boolean;\r\n searchTags?: LocalizedValue<string[]>;\r\n};\r\n\r\nexport type ProductData = Required<ProductAttributes>\r\n\r\nexport default class ProductModel extends BaseModel {\r\n protected id: string;\r\n protected key: string;\r\n\r\n protected name: LocalizedString;\r\n protected description: LocalizedString;\r\n protected slug: LocalizedString;\r\n protected brand: string;\r\n\r\n protected pricing: {\r\n [country in CountryCode]?: TieredPriceModel;\r\n };\r\n\r\n protected variants: VariantModel[];\r\n\r\n protected targetGender: GenderCategory;\r\n protected attributes: ProductSelectionAttributes;\r\n protected specifications: LocalizedValue<ProductSpecification>;\r\n protected categories: string[];\r\n protected productType: ProductType;\r\n\r\n // Metadata\r\n protected isActive: boolean;\r\n\r\n protected searchTags: LocalizedValue<string[]>;\r\n\r\n static productKeyRegex = /^(?!\\s)(?!.*\\s$)[A-Z0-9-]{4,16}$/;\r\n static productSKURegex = /^(?!\\s)(?!.*\\s$)[A-Z0-9-]{4,16}$/;\r\n\r\n /**\r\n * Generates a unique key for checking uniqueness for a given selection attributes.\r\n * Excludes 'size' from the key generation.\r\n * @param selectionAttributes - The selection attributes.\r\n * @returns A string key representing the unique attribute combination.\r\n */\r\n static generateSelectionAttributesKey(selectionAttributes: SelectionAttributes): string {\r\n if (typeof selectionAttributes !== 'object') {\r\n throw new SelectionAttributeParseError('Selection attributes must be an object');\r\n }\r\n\r\n const sortedKeys = Object.keys(selectionAttributes)\r\n .filter(key => selectionAttributes[key] !== undefined && key.toLowerCase() !== 'size')\r\n .sort()\r\n\r\n return sortedKeys.map(key => {\r\n if ((selectionAttributes[key] as Color).name) {\r\n return `${key}:c+${(selectionAttributes[key] as Color).name}`;\r\n }\r\n return `${key}:${selectionAttributes[key]}`;\r\n }).join('|').toLowerCase();\r\n }\r\n\r\n /**\r\n * Parses a selection attributes key into an object.\r\n * @param key - The selection attributes key to parse.\r\n * @returns An object containing the parsed selection attributes.\r\n */\r\n static parseSelectionAttributesKey(key: string): SelectionAttributes {\r\n try {\r\n const attributes: SelectionAttributes = {} as unknown as SelectionAttributes;\r\n const parts = key.split('|');\r\n for (const part of parts) {\r\n const [key, value] = part.split(':');\r\n if (value.startsWith('c+')) {\r\n attributes[key] = { name: value.slice(2) } as Color;\r\n } else {\r\n attributes[key] = value;\r\n }\r\n }\r\n return attributes;\r\n } catch (error: any) {\r\n throw new SelectionAttributeParseError(error?.message);\r\n }\r\n }\r\n\r\n /**\r\n * Creates an instance of ProductModel.\r\n * Initializes properties based on the provided data, creating copies where necessary.\r\n * @param data - The initial product attributes.\r\n * @param date - Optional date for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: ProductAttributes, date: Date = new Date()) {\r\n super(data, date);\r\n\r\n this.id = data.id;\r\n this.key = data.key;\r\n\r\n this.name = { ...data.name };\r\n this.description = { ...data.description };\r\n this.slug = { ...data.slug };\r\n this.brand = data.brand;\r\n\r\n this.pricing = (Object.keys(data.pricing) as CountryCode[]).reduce((acc, country) => {\r\n if (data.pricing[country]) {\r\n acc[country] = TieredPriceModel.create(data.pricing[country] as TieredPriceAttributes);\r\n }\r\n return acc;\r\n }, {} as { [country in CountryCode]?: TieredPriceModel });\r\n\r\n this.targetGender = data.targetGender;\r\n this.attributes = Utils.deepClone(data.attributes);\r\n this.specifications = Utils.deepClone(data.specifications);\r\n this.categories = Utils.deepClone(data.categories);\r\n this.productType = data.productType ?? ProductType.GOODS;\r\n\r\n const uniqueSelectionAttributes = new Set<string>();\r\n this.variants = (data.variants || []).map(variant => {\r\n if (!variant.selectionAttributes || typeof variant.selectionAttributes !== 'object') {\r\n throw new SelectionAttributeParseError('Selection attributes are required');\r\n }\r\n\r\n this.checkSelectionAttributes(variant.selectionAttributes);\r\n const key = ProductModel.generateSelectionAttributesKey(variant.selectionAttributes);\r\n if (uniqueSelectionAttributes.has(key)) {\r\n throw new DuplicateSelectionAttributeError(key);\r\n }\r\n uniqueSelectionAttributes.add(key);\r\n return {\r\n sku: variant.sku,\r\n selectionAttributes: variant.selectionAttributes,\r\n images: {\r\n primary: new ImageInfoModel(variant.images.primary),\r\n gallery: (variant.images.gallery || []).map(image => new ImageInfoModel(image))\r\n }\r\n };\r\n });\r\n\r\n this.isActive = data.isActive;\r\n this.searchTags = data.searchTags ? Utils.deepClone(data.searchTags) : { en: [] };\r\n }\r\n\r\n /**\r\n * Gets the base Product ID.\r\n * @returns Product ID.\r\n */\r\n getId(): string {\r\n return this.id;\r\n }\r\n\r\n /**\r\n * Gets the user-friendly product key.\r\n * @returns Product Key.\r\n */\r\n getKey(): string {\r\n return this.key;\r\n }\r\n\r\n /**\r\n * Gets the full localized product name object.\r\n * @returns A copy of the LocalizedString object for the name.\r\n */\r\n getName(): LocalizedString\r\n /**\r\n * Gets the product name for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The name string for the specified locale.\r\n */\r\n getName(locale: LocaleCode): string\r\n getName(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.name[locale] ?? this.name[LocaleLanguageMap[locale]] ?? this.name.en;\r\n } else {\r\n return Utils.deepClone(this.name);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the full localized product description object.\r\n * @returns A copy of the LocalizedString object for the description.\r\n */\r\n getDescription(): LocalizedString\r\n /**\r\n * Gets the product description for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The description string for the specified locale.\r\n */\r\n getDescription(locale: LocaleCode): string\r\n getDescription(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.description[locale] ?? this.description[LocaleLanguageMap[locale]] ?? this.description.en;\r\n } else {\r\n return Utils.deepClone(this.description);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the full localized product slug object.\r\n * @returns A copy of the LocalizedString object for the slug.\r\n */\r\n getSlug(): LocalizedString\r\n /**\r\n * Gets the product slug for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The slug string for the specified locale.\r\n */\r\n getSlug(locale: LocaleCode): string\r\n getSlug(locale?: LocaleCode): LocalizedString | string {\r\n if (locale) {\r\n return this.slug[locale] ?? this.slug[LocaleLanguageMap[locale]] ?? this.slug.en;\r\n } else {\r\n return Utils.deepClone(this.slug);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the brand associated with the product.\r\n * @returns The brand name string.\r\n */\r\n getBrand(): string {\r\n return this.brand;\r\n }\r\n\r\n /**\r\n * Gets the tiered price details for the product.\r\n * @returns Pricing details mapped by country.\r\n */\r\n getPriceDetails(): { [country in CountryCode]?: TieredPriceModel }\r\n /**\r\n * Gets the tiered price details for a specific country.\r\n * @param country - The country code.\r\n * @returns The tiered price model for the country, or null if not found.\r\n */\r\n getPriceDetails(country: CountryCode): TieredPriceModel | null\r\n getPriceDetails(country?: CountryCode): { [country in CountryCode]?: TieredPriceModel } | TieredPriceModel | null {\r\n if (country) {\r\n return this.pricing[country] ?? null;\r\n }\r\n return { ...this.pricing };\r\n }\r\n\r\n /**\r\n * Gets the variant-specific attributes (color, sizes). Returns copies.\r\n * @returns Product Attributes.\r\n */\r\n getAttributes(): ProductSelectionAttributes {\r\n return Utils.deepClone(this.attributes);\r\n }\r\n\r\n\r\n /**\r\n * Gets the variant-specific attributes (color, sizes). Returns copies.\r\n * @returns Product Attributes.\r\n */\r\n getVariants(): VariantModel[] {\r\n return this.variants.map(variant => ({\r\n sku: variant.sku,\r\n selectionAttributes: Utils.deepClone(variant.selectionAttributes),\r\n images: {\r\n primary: variant.images.primary,\r\n gallery: [...variant.images.gallery]\r\n }\r\n }));\r\n }\r\n\r\n /**\r\n * Gets the images for a specific selection attribute combination.\r\n * @param selectionAttributes - The selection attributes to search for.\r\n * @returns The matching image set or null if not found.\r\n */\r\n private getImagesBySelectionAttributes(selectionAttributes: SelectionAttributes): { primary: ImageInfoModel; gallery: ImageInfoModel[] } | null {\r\n const searchKey = ProductModel.generateSelectionAttributesKey(selectionAttributes);\r\n\r\n const match = this.variants.find(variant =>\r\n ProductModel.generateSelectionAttributesKey(variant.selectionAttributes) === searchKey\r\n );\r\n\r\n return match ? {\r\n primary: match.images.primary,\r\n gallery: [...match.images.gallery]\r\n } : null;\r\n }\r\n\r\n /**\r\n * Gets the images for a specific selection attribute combination.\r\n * @param selectionAttributes - The selection attributes to search for.\r\n * @returns The matching image set or null if not found.\r\n */\r\n getImages(selectionAttributes: SelectionAttributes): { primary: ImageInfoModel; gallery: ImageInfoModel[] }\r\n getImages(selectionAttributes: SelectionAttributes, category: ImageCategory.PRIMARY): ImageInfoModel\r\n getImages(selectionAttributes: SelectionAttributes, category: ImageCategory.GALLERY): ImageInfoModel[]\r\n getImages(selectionAttributes: SelectionAttributes, category?: ImageCategory): { primary: ImageInfoModel; gallery: ImageInfoModel[] } | ImageInfoModel | ImageInfoModel[] {\r\n switch (category) {\r\n case ImageCategory.PRIMARY:\r\n return this.getImagesBySelectionAttributes(selectionAttributes)?.primary ?? this.variants[0]?.images?.primary;\r\n case ImageCategory.GALLERY:\r\n return this.getImagesBySelectionAttributes(selectionAttributes)?.gallery ?? [];\r\n default:\r\n return this.getImagesBySelectionAttributes(selectionAttributes) ?? { primary: this.variants[0]?.images?.primary, gallery: [] };\r\n }\r\n }\r\n\r\n\r\n /**\r\n * Checks if the product is active.\r\n * @returns True if the product is active, false otherwise.\r\n */\r\n getIsActive(): boolean {\r\n return this.isActive;\r\n }\r\n\r\n /**\r\n * Gets the target gender category for the product.\r\n * @returns The GenderCategory enum value.\r\n */\r\n getTargetGender(): GenderCategory {\r\n return this.targetGender;\r\n }\r\n\r\n /**\r\n * Gets the list of categories the product belongs to. Returns a copy.\r\n * @returns An array of category.\r\n */\r\n getCategories(): string[] {\r\n return Utils.deepClone(this.categories);\r\n }\r\n\r\n /**\r\n * Gets the product type.\r\n * @returns ProductType.\r\n */\r\n getProductType(): ProductType {\r\n return this.productType;\r\n }\r\n\r\n /**\r\n * Gets the full localized product specifications object.\r\n * @returns Product Specifications\r\n */\r\n getSpecifications(): LocalizedValue<ProductSpecification>\r\n /**\r\n * Gets the product specifications for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The ProductSpecification object for the specified locale, or undefined if not found.\r\n */\r\n getSpecifications(locale: LocaleCode): ProductSpecification\r\n getSpecifications(locale?: LocaleCode): LocalizedValue<ProductSpecification> | ProductSpecification {\r\n if (locale) {\r\n return Utils.deepClone(this.specifications[locale] ?? this.specifications[LocaleLanguageMap[locale]] ?? this.specifications.en);\r\n } else {\r\n return Utils.deepClone(this.specifications);\r\n }\r\n }\r\n\r\n /**\r\n * Gets the localized list of search tags. Returns a copy.\r\n * @returns Localized array of search tags.\r\n */\r\n getSearchTags(): LocalizedValue<string[]>\r\n /**\r\n * Gets the search tags for a specific locale, falling back to English ('en').\r\n * @param locale - The desired locale code.\r\n * @returns The array of search tags for the specified locale, or undefined if not found.\r\n */\r\n getSearchTags(locale: LocaleCode): string[]\r\n getSearchTags(locale?: LocaleCode): LocalizedValue<string[]> | string[] {\r\n if (locale) {\r\n return Utils.deepClone(this.searchTags[locale] ?? this.searchTags[LocaleLanguageMap[locale]] ?? this.searchTags.en);\r\n } else {\r\n return Utils.deepClone(this.searchTags);\r\n }\r\n }\r\n\r\n /**\r\n *\r\n * @returns ProductData\r\n */\r\n getDetails(): ProductData {\r\n const baseDetails = super.getDetails();\r\n return {\r\n id: this.getId(),\r\n key: this.getKey(),\r\n name: this.getName(),\r\n description: this.getDescription(),\r\n slug: this.getSlug(),\r\n brand: this.getBrand(),\r\n pricing: (Object.keys(this.pricing) as CountryCode[]).reduce((acc, country) => {\r\n if (this.pricing[country]) {\r\n acc[country] = this.pricing[country]?.getDetails();\r\n }\r\n return acc;\r\n }, {} as { [country in CountryCode]: TieredPriceData }),\r\n attributes: this.getAttributes(),\r\n variants: this.variants.map(v => ({\r\n sku: v.sku,\r\n selectionAttributes: Utils.deepClone(v.selectionAttributes),\r\n images: {\r\n primary: v.images.primary.getDetails(),\r\n gallery: v.images.gallery.map(img => img.getDetails())\r\n }\r\n })),\r\n isActive: this.getIsActive(),\r\n targetGender: this.getTargetGender(),\r\n categories: this.getCategories(),\r\n productType: this.getProductType(),\r\n specifications: this.getSpecifications(),\r\n searchTags: this.getSearchTags(),\r\n ...baseDetails\r\n };\r\n }\r\n\r\n /**\r\n * Checks if the provided selection attributes are valid for the product.\r\n * @param selectionAttributes The selection attributes to validate.\r\n * @throws {SelectionAttributeParseError} If the selection attributes are invalid.\r\n */\r\n checkSelectionAttributes(selectionAttributes: SelectionAttributes): void {\r\n if (!selectionAttributes || typeof selectionAttributes !== 'object') {\r\n throw new SelectionAttributeParseError('Selection attributes are required');\r\n }\r\n\r\n Object.keys(this.attributes).forEach(key => {\r\n if(key.toLowerCase() === 'size') return;\r\n \r\n const allowedAttributeValues = this.attributes[key];\r\n const providedValue = selectionAttributes[key];\r\n\r\n if (providedValue === undefined) {\r\n throw new SelectionAttributeParseError(`Selection attribute '${key}' is missing`);\r\n }\r\n\r\n if (typeof allowedAttributeValues === 'string') {\r\n if (typeof providedValue !== 'string' || allowedAttributeValues !== providedValue) {\r\n throw new SelectionAttributeParseError(`Selection attribute '${key}' is invalid`);\r\n }\r\n } else if (Array.isArray(allowedAttributeValues)) {\r\n if (allowedAttributeValues.length > 0 && typeof allowedAttributeValues[0] === 'string') {\r\n if (typeof providedValue !== 'string' || !(allowedAttributeValues as string[]).includes(providedValue)) {\r\n throw new SelectionAttributeParseError(`Selection attribute '${key}' is invalid`);\r\n }\r\n } else {\r\n // Color validation\r\n if (\r\n typeof providedValue !== 'object' ||\r\n !('name' in providedValue) ||\r\n (allowedAttributeValues as Color[]).findIndex(c => c.name === (providedValue as Color).name) < 0\r\n ) {\r\n throw new SelectionAttributeParseError(`Selection attribute '${key}' is invalid`);\r\n }\r\n }\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Gets the SKU of the variant matching the selection attributes.\r\n * @param selectionAttributes - The selection attributes to search for.\r\n * @returns The SKU string, or undefined if no matching variant is found.\r\n */\r\n public getSku(selectionAttributes: SelectionAttributes): string | undefined {\r\n const searchKey = ProductModel.generateSelectionAttributesKey(selectionAttributes);\r\n const match = this.variants.find(variant =>\r\n ProductModel.generateSelectionAttributesKey(variant.selectionAttributes) === searchKey\r\n );\r\n return match?.sku;\r\n }\r\n\r\n /**\r\n * Validates if the provided selection attributes exist for this product.\r\n * @param selectionAttributes - The attributes to validate.\r\n * @returns True if a valid selection attribute exists, false otherwise.\r\n */\r\n validateSelectionAttribute(selectionAttributes: SelectionAttributes): boolean {\r\n const searchKey = ProductModel.generateSelectionAttributesKey(selectionAttributes);\r\n\r\n return this.variants.some(variant => ProductModel.generateSelectionAttributesKey(variant.selectionAttributes) === searchKey);\r\n }\r\n\r\n /**\r\n * Validates if a specific size is available for this product.\r\n * @param size - The size to check.\r\n * @returns True if the size exists in the product's attributes, false otherwise.\r\n */\r\n validateSize(size: string): boolean {\r\n return this.attributes.size.includes(size);\r\n }\r\n}\r\n","import PriceModel, { PriceData } from \"./Price\";\nimport type { SelectionAttributes } from \"./Product\";\nimport ProductModel from \"./Product\";\nimport {\n InvalidTaxCategoryError,\n InvalidMinQuantityError,\n InvalidTieredPriceError,\n InvalidQuantityError,\n InvalidPricingTypeError,\n NoApplicableTierError\n} from \"./Error\";\nimport { CountryCode, CurrencyCode, Prettify } from \"./Common\";\n\nexport enum PricingType {\n VOLUME = 'volume',\n SELECTION = 'selection',\n}\n\n/**\n * Represents a pricing tier based on a minimum purchase quantity.\n */\nexport type PriceTier = {\n enabled: boolean;\n minQuantity: number;\n unitPrice: PriceModel;\n};\n\nexport type PriceTierData = {\n enabled: boolean;\n minQuantity: number;\n unitPrice: PriceData;\n};\n\n/**\n * Represents the configuration for a specific selection variant.\n */\nexport type SelectionPricingData = {\n selectionAttributes: SelectionAttributes;\n baseUnitPrice: PriceData;\n tiers?: PriceTierData[];\n};\n\nexport type SelectionPricing = {\n selectionAttributes: SelectionAttributes;\n baseUnitPrice: PriceModel;\n tiers: PriceTier[];\n};\n\nexport type PriceTierAttributes = Prettify<Omit<PriceTierData, 'enabled'> & { enabled?: boolean }>;\n\n/**\n * Represents the attributes required for tiered pricing.\n */\nexport type VolumenTieredPriceAttributes = {\n type?: PricingType.VOLUME;\n taxCategory: string;\n isTaxInclusive?: boolean;\n currency?: CurrencyCode;\n baseUnitPrice: PriceData;\n tiers: PriceTierAttributes[];\n}\n\nexport type SelectionTieredPriceAttributes = {\n type: PricingType.SELECTION;\n taxCategory: string;\n isTaxInclusive?: boolean;\n currency: CurrencyCode;\n selections: (Omit<SelectionPricingData, 'tiers'> & { tiers?: PriceTierAttributes[] })[];\n}\n\nexport type TieredPriceAttributes = VolumenTieredPriceAttributes | SelectionTieredPriceAttributes;\n\nexport type VolumenTieredPriceData = {\n type: PricingType.VOLUME;\n taxCategory: string;\n isTaxInclusive: boolean;\n currency: CurrencyCode;\n baseUnitPrice: PriceData;\n tiers: PriceTierData[];\n};\n\nexport type SelectionTieredPriceData = {\n type: PricingType.SELECTION;\n taxCategory: string;\n isTaxInclusive: boolean;\n currency: CurrencyCode;\n selections: SelectionPricingData[];\n}\n\nexport type TieredPriceData = VolumenTieredPriceData | SelectionTieredPriceData;\n\nexport abstract class TieredPriceModel {\n protected type: PricingType;\n protected taxCategory: string;\n protected isTaxInclusive: boolean;\n\n /** \n * Factory method to instantiate the correct concrete TieredPriceModel implementation.\n */\n static create(data: TieredPriceAttributes): TieredPriceModel {\n if (data.type === PricingType.SELECTION) {\n return new SelectionTieredPriceModel(data);\n }\n return new VolumeTieredPriceModel(data);\n }\n\n constructor(data: TieredPriceAttributes) {\n if (!data.taxCategory) {\n throw new InvalidTaxCategoryError();\n }\n this.taxCategory = data.taxCategory;\n this.isTaxInclusive = data.isTaxInclusive ?? false;\n this.type = data.type ?? PricingType.VOLUME;\n }\n\n getType(): PricingType {\n return this.type;\n }\n\n getTaxCategory(): string {\n return this.taxCategory;\n }\n\n getIsTaxInclusive(): boolean {\n return this.isTaxInclusive;\n }\n\n abstract isPriceAvailable(selectionAttributes?: SelectionAttributes): boolean;\n abstract getBaseUnitPrice(selectionAttributes?: SelectionAttributes): PriceModel;\n abstract getDetails(): TieredPriceData;\n abstract getCurrency(): CurrencyCode;\n abstract getApplicableUnitPrice(quantity: number, selectionAttributes?: SelectionAttributes): PriceModel;\n abstract getMinQuantity(selectionAttributes?: SelectionAttributes): number;\n abstract getMaxDiscountPercent(selectionAttributes?: SelectionAttributes): number;\n abstract getTiers(selectionAttributes?: SelectionAttributes): PriceTier[];\n abstract getMinPrice(selectionAttributes?: SelectionAttributes): PriceModel | null;\n abstract getMaxPrice(selectionAttributes?: SelectionAttributes): PriceModel | null;\n}\n\nexport class VolumeTieredPriceModel extends TieredPriceModel {\n protected baseUnitPrice: PriceModel;\n protected tiers: PriceTier[];\n protected currency: CurrencyCode;\n\n constructor(data: Extract<TieredPriceAttributes, { type?: PricingType.VOLUME }>) {\n super(data);\n this.type = PricingType.VOLUME;\n \n if (!data.baseUnitPrice) {\n throw new InvalidTieredPriceError(\"Base unit price is required for volume pricing.\");\n }\n this.baseUnitPrice = new PriceModel(data.baseUnitPrice);\n this.currency = data.currency ?? this.baseUnitPrice.getCurrency();\n\n const tiers = (data.tiers ?? [])\n .map(tier => ({\n enabled: tier.enabled ?? true,\n minQuantity: tier.minQuantity,\n unitPrice: new PriceModel(tier.unitPrice),\n }))\n .sort((a, b) => a.minQuantity - b.minQuantity);\n\n const hasInvalidMinQuantity = tiers.some(t => t.minQuantity <= 0);\n if (hasInvalidMinQuantity) {\n throw new InvalidMinQuantityError();\n }\n\n const hasDifferentCurrency = this.baseUnitPrice.getCurrency() !== this.currency || tiers.some(\n t => t.unitPrice.getCurrency() !== this.currency\n );\n const hasIrregularPricing = tiers.some(\n (tier, index) =>\n index > 0 &&\n tier.unitPrice.compareTo(tiers[index - 1].unitPrice) > 0\n );\n const basePriceExceedsFirstTier = tiers[0]?.unitPrice.compareTo(this.baseUnitPrice) > 0;\n\n if (hasDifferentCurrency || hasIrregularPricing || basePriceExceedsFirstTier) {\n throw new InvalidTieredPriceError(\n \"Tiers must share the same currency and must not increase in unit price.\"\n );\n }\n\n this.tiers = tiers;\n }\n\n isPriceAvailable(): boolean {\n return this.tiers.filter(t => t.enabled).length > 0;\n }\n\n getBaseUnitPrice(): PriceModel {\n return this.baseUnitPrice;\n }\n\n getCurrency(): CurrencyCode {\n return this.baseUnitPrice.getCurrency();\n }\n\n getApplicableUnitPrice(quantity: number): PriceModel {\n if (quantity <= 0) {\n throw new InvalidQuantityError();\n }\n\n const enabledTiers = this.tiers.filter(t => t.enabled);\n for (let i = enabledTiers.length - 1; i >= 0; i--) {\n const tier = enabledTiers[i];\n if (quantity >= tier.minQuantity) {\n return tier.unitPrice;\n }\n }\n\n throw new NoApplicableTierError(quantity);\n }\n\n getMinQuantity(): number {\n const enabledTiers = this.tiers.filter(tier => tier.enabled);\n return enabledTiers[0]?.minQuantity ?? 1;\n }\n\n getMaxDiscountPercent(): number {\n const enabledTiers = this.tiers.filter(tier => tier.enabled);\n if (!enabledTiers.length) return 0;\n \n const minTierPrice = Math.min(...enabledTiers.map(t => t.unitPrice.getAmount()));\n const basePrice = this.baseUnitPrice.getAmount();\n \n const discount = ((basePrice - minTierPrice) / basePrice) * 100;\n return discount > 0 ? discount : 0;\n }\n\n getMinPrice(): PriceModel | null {\n const enabledTiers = this.tiers.filter(tier => tier.enabled);\n return enabledTiers.length ? enabledTiers[enabledTiers.length - 1].unitPrice : null;\n }\n\n getMaxPrice(): PriceModel | null {\n const enabledTiers = this.tiers.filter(tier => tier.enabled);\n return enabledTiers.length ? enabledTiers[0].unitPrice : null;\n }\n\n getTiers(): PriceTier[] {\n return this.tiers.map(tier => ({\n enabled: tier.enabled,\n minQuantity: tier.minQuantity,\n unitPrice: tier.unitPrice\n }));\n }\n\n getDetails(): VolumenTieredPriceData {\n return {\n type: this.type as PricingType.VOLUME,\n taxCategory: this.taxCategory,\n isTaxInclusive: this.isTaxInclusive,\n currency: this.currency,\n baseUnitPrice: this.baseUnitPrice.getDetails(),\n tiers: this.tiers.map(tier => ({\n enabled: tier.enabled,\n minQuantity: tier.minQuantity,\n unitPrice: tier.unitPrice.getDetails()\n }))\n };\n }\n}\n\nexport class SelectionTieredPriceModel extends TieredPriceModel {\n protected currency: CurrencyCode;\n protected selections: SelectionPricing[];\n\n constructor(data: Extract<TieredPriceAttributes, { type: PricingType.SELECTION }>) {\n super(data);\n this.type = PricingType.SELECTION;\n this.currency = data.currency;\n\n this.selections = (data.selections ?? []).map(selection => {\n if (!selection.baseUnitPrice) {\n throw new InvalidTieredPriceError(\"Base unit price is required for each selection.\");\n }\n const baseUnitPrice = new PriceModel(selection.baseUnitPrice);\n\n const tiers = (selection.tiers ?? [])\n .map(tier => ({\n enabled: tier.enabled ?? true,\n minQuantity: tier.minQuantity ?? 1,\n unitPrice: new PriceModel(tier.unitPrice),\n }))\n .sort((a, b) => a.minQuantity - b.minQuantity);\n\n const hasInvalidMinQuantity = tiers.some(t => t.minQuantity <= 0);\n if (hasInvalidMinQuantity) {\n throw new InvalidMinQuantityError();\n }\n\n const hasDifferentCurrency = baseUnitPrice.getCurrency() !== this.currency || tiers.some(\n t => t.unitPrice.getCurrency() !== this.currency\n );\n const hasIrregularPricing = tiers.some(\n (tier, index) =>\n index > 0 &&\n tier.unitPrice.compareTo(tiers[index - 1].unitPrice) > 0\n );\n const basePriceExceedsFirstTier = tiers[0]?.unitPrice.compareTo(baseUnitPrice) > 0;\n\n if (hasDifferentCurrency || hasIrregularPricing || basePriceExceedsFirstTier) {\n throw new InvalidTieredPriceError(\n \"Tiers must share the same currency and must not increase in unit price within the same selection.\"\n );\n }\n\n return {\n selectionAttributes: { ...selection.selectionAttributes },\n baseUnitPrice,\n tiers\n };\n });\n }\n\n protected findMatch(selectionAttributes: SelectionAttributes, throwOnNotFound = false): SelectionPricing | null {\n const key = ProductModel.generateSelectionAttributesKey(selectionAttributes);\n const match = this.selections.find(\n s => ProductModel.generateSelectionAttributesKey(s.selectionAttributes) === key\n );\n if (!match && throwOnNotFound) {\n throw new InvalidTieredPriceError(\"No pricing configuration found for selection variant.\");\n }\n return match ?? null;\n }\n\n isPriceAvailable(selectionAttributes?: SelectionAttributes): boolean {\n if(!selectionAttributes) {\n console.warn('Selection attributes are required to check price availability for selection pricing.');\n return false;\n }\n const match = this.findMatch(selectionAttributes);\n return match ? match.tiers.filter(t => t.enabled).length > 0 : false;\n }\n\n getBaseUnitPrice(selectionAttributes?: SelectionAttributes): PriceModel {\n if (!selectionAttributes) {\n throw new InvalidPricingTypeError(\"Selection attributes are required to get base unit price for selection pricing.\");\n }\n const match = this.findMatch(selectionAttributes, true)!;\n return match.baseUnitPrice;\n }\n\n getCurrency(): CurrencyCode {\n return this.currency;\n }\n\n getApplicableUnitPrice(quantity: number, selectionAttributes?: SelectionAttributes): PriceModel {\n if (quantity <= 0) {\n throw new InvalidQuantityError();\n }\n if (!selectionAttributes) {\n throw new InvalidPricingTypeError(\"Selection attributes are required to get applicable unit price for selection pricing.\");\n }\n \n const match = this.findMatch(selectionAttributes, true)!;\n\n const enabledTiers = match.tiers.filter(t => t.enabled);\n for (let i = enabledTiers.length - 1; i >= 0; i--) {\n const tier = enabledTiers[i];\n if (quantity >= tier.minQuantity) {\n return tier.unitPrice;\n }\n }\n throw new NoApplicableTierError(quantity);\n }\n\n getMinQuantity(selectionAttributes?: SelectionAttributes): number {\n if (!selectionAttributes) {\n throw new InvalidPricingTypeError(\"Selection attributes are required to get min quantity for selection pricing.\");\n }\n const match = this.findMatch(selectionAttributes, true)!;\n const enabledTiers = match.tiers.filter(t => t.enabled);\n return enabledTiers[0]?.minQuantity ?? 1;\n }\n\n getMaxDiscountPercent(selectionAttributes?: SelectionAttributes): number {\n if (!selectionAttributes) {\n throw new InvalidPricingTypeError(\"Selection attributes are required to get max discount for selection pricing.\");\n }\n const match = this.findMatch(selectionAttributes, true)!;\n\n const enabledTiers = match.tiers.filter(t => t.enabled);\n if (!enabledTiers.length) return 0;\n\n const minTierPrice = Math.min(...enabledTiers.map(t => t.unitPrice.getAmount()));\n const basePrice = match.baseUnitPrice.getAmount();\n \n const discount = ((basePrice - minTierPrice) / basePrice) * 100;\n return discount > 0 ? discount : 0;\n }\n\n getTiers(selectionAttributes?: SelectionAttributes): PriceTier[] {\n if (!selectionAttributes) {\n throw new InvalidPricingTypeError(\"Selection attributes are required to get tiers for selection pricing.\");\n }\n const match = this.findMatch(selectionAttributes, true)!;\n return match.tiers.map(tier => ({\n enabled: tier.enabled,\n minQuantity: tier.minQuantity,\n unitPrice: tier.unitPrice\n }));\n }\n\n getMinPrice(selectionAttributes?: SelectionAttributes): PriceModel | null {\n if (!selectionAttributes) {\n throw new InvalidPricingTypeError(\"Selection attributes are required to get min price for selection pricing.\");\n }\n const match = this.findMatch(selectionAttributes);\n if (!match) return null;\n const enabledTiers = match.tiers.filter(t => t.enabled);\n return enabledTiers.length ? enabledTiers[enabledTiers.length - 1].unitPrice : null;\n }\n\n getMaxPrice(selectionAttributes?: SelectionAttributes): PriceModel | null {\n if (!selectionAttributes) {\n throw new InvalidPricingTypeError(\"Selection attributes are required to get max price for selection pricing.\");\n }\n const match = this.findMatch(selectionAttributes);\n if (!match) return null;\n const enabledTiers = match.tiers.filter(t => t.enabled);\n return enabledTiers.length ? enabledTiers[0].unitPrice : null;\n }\n\n getDetails(): SelectionTieredPriceData {\n return {\n type: this.type as PricingType.SELECTION,\n taxCategory: this.taxCategory,\n isTaxInclusive: this.isTaxInclusive,\n currency: this.currency,\n selections: this.selections.map(selection => ({\n selectionAttributes: selection.selectionAttributes,\n baseUnitPrice: selection.baseUnitPrice.getDetails(),\n ...(selection.tiers.length > 0 ? {\n tiers: selection.tiers.map(tier => ({\n enabled: tier.enabled,\n minQuantity: tier.minQuantity,\n unitPrice: tier.unitPrice.getDetails()\n }))\n } : {})\n }))\n };\n }\n}\n"]}
@@ -1,2 +1,2 @@
1
- import {a as a$4,b}from'./chunk-MPKIC2MS.mjs';import {a as a$2}from'./chunk-EZ35IKUA.mjs';import {a as a$3}from'./chunk-KFXRFY63.mjs';import {a as a$1}from'./chunk-UIQH5QIR.mjs';import {e}from'./chunk-PL5HGCWN.mjs';import {w,k,x}from'./chunk-O6BLQQO7.mjs';import {a}from'./chunk-UXZBULDS.mjs';var A=class extends a{id;name;type;category;impact;pricing;lineItemId;total;constructor(t){if(super(t),this.id=t.id,this.name=t.name,this.type=t.type,this.category=t.category,this.impact=t.impact,this.lineItemId=t.lineItemId,this.pricing={baseChargeAmount:new a$1(t.pricing.baseChargeAmount),taxCategory:t.pricing.taxCategory,applicableTaxRule:t.pricing.applicableTaxRule.map(e=>new a$2(e))},this.validateTaxRules(this.pricing.applicableTaxRule),this.impact==="SUBTRACT"&&this.type!=="ADJUSTMENT")throw new w("SUBTRACT impact is only allowed for ADJUSTMENT charge");this.total={chargeAmount:new a$1(t.total.chargeAmount),discountTotal:new a$1(t.total.discountTotal),discountBreakdown:Object.fromEntries(Object.entries(t.total.discountBreakdown).map(([e,a])=>[e,new a$1(a)])),netChargeAmount:new a$1(t.total.netChargeAmount),taxBreakdown:Object.fromEntries(Object.entries(t.total.taxBreakdown).map(([e,a])=>[e,{rate:a.rate,taxableAmount:new a$1(a.taxableAmount),taxAmount:new a$1(a.taxAmount),system:a.system,subSystem:a.subSystem}])),taxTotal:new a$1(t.total.taxTotal),grandTotal:new a$1(t.total.grandTotal)};}getId(){return this.id}getName(t){return t?a$3.deepClone(this.name[t]??this.name[e[t]]??this.name.en):a$3.deepClone(this.name)}getCategory(){return this.category}getType(){return this.type}getImpact(){return this.impact}getLineItemId(){return this.lineItemId}getPricing(){return {baseChargeAmount:this.pricing.baseChargeAmount,taxCategory:this.pricing.taxCategory,applicableTaxRule:[...this.pricing.applicableTaxRule]}}getTotal(){return {chargeAmount:this.total.chargeAmount,discountTotal:this.total.discountTotal,discountBreakdown:{...this.total.discountBreakdown},netChargeAmount:this.total.netChargeAmount,taxTotal:this.total.taxTotal,taxBreakdown:Object.fromEntries(Object.entries(this.total.taxBreakdown).map(([t,e])=>[t,{rate:e.rate,taxableAmount:e.taxableAmount,taxAmount:e.taxAmount,system:e.system,subSystem:e.subSystem}])),grandTotal:this.total.grandTotal}}getApplicableTaxRules(){return [...this.pricing.applicableTaxRule]}updateTax(t){if(this.type==="ADJUSTMENT"&&t.length>0)throw new w("Adjustment charges cannot apply tax rules.");t.forEach(e=>{if(!e.appliesTo(this.pricing.taxCategory,e.getCountry()))throw new k}),this.validateTaxRules(t),this.pricing.applicableTaxRule=t,this.calculateTotals();}validateTaxRules(t){if(this.impact==="SUBTRACT"&&t.some(a=>a.getRate()>0))throw new x("Subtractive charges cannot have positive tax rates.");let e=new Set;for(let a=0;a<t.length;a++){let r=t[a].getTaxRuleId();if(e.has(r))throw new x("Duplicate tax rule ID found: "+r);e.add(r);for(let g=a+1;g<t.length;g++){let u=t[a],l=t[g],m=u.getMinPrice(),i=u.getMaxPrice(),p=u.getExcludeMin(),o=u.getExcludeMax(),n=l.getMinPrice(),c=l.getMaxPrice(),T=l.getExcludeMin(),b=l.getExcludeMax(),D=(()=>{if(!i)return !1;let d=i.compareTo(n);return d<0||d===0&&(o||T)})(),B=(()=>{if(!c)return !1;let d=c.compareTo(m);return d<0||d===0&&(b||p)})();if(!(D||B)&&!(m.compareTo(n)===0&&p===T&&o===b&&(!i&&!c||i&&c&&i.compareTo(c)===0)))throw new x(`Overlapping rules found: [${u.getTaxRuleId()}: ${p?"(":"["}${m.getAmount()}-${i?.getAmount()??"Infinity"}${o?")":"]"}] and [${l.getTaxRuleId()}: ${T?"(":"["}${n.getAmount()}-${c?.getAmount()??"Infinity"}${b?")":"]"}]`)}}}updateDiscounts(t){let e={};t.forEach(a=>{e[a.coupon.getCode()]=a.amount;}),this.total.discountBreakdown=e,this.calculateTotals();}calculateTotals(){let t=this.pricing.baseChargeAmount.zero(),e=this.pricing.baseChargeAmount,a=Object.values(this.total.discountBreakdown).reduce((o,n)=>o.add(n),t),r=e.subtract(a),g={};if(this.pricing.applicableTaxRule.reduce((o,n)=>o+n.getApplicableTaxRate(r),0)<=0){this.total={chargeAmount:e,discountTotal:a,discountBreakdown:this.total.discountBreakdown,netChargeAmount:r,taxTotal:t,taxBreakdown:{},grandTotal:r};return}let l=a$4(r,this.pricing.applicableTaxRule),m=b(l,r,this.pricing.applicableTaxRule),i=t;m.forEach(o=>{let n=this.pricing.applicableTaxRule.find(c=>c.getTaxRuleId()===o.ruleId);g[o.ruleId]={rate:o.rate,taxableAmount:l,taxAmount:o.taxAmount,system:n.getTaxSystem(),subSystem:n.getTaxSubSystem()},i=i.add(o.taxAmount);});let p=r;this.total={chargeAmount:e,discountTotal:a,discountBreakdown:this.total.discountBreakdown,netChargeAmount:r,taxBreakdown:g,taxTotal:i,grandTotal:p};}getDetails(){return {id:this.id,name:a$3.deepClone(this.name),type:this.type,category:this.category,pricing:{baseChargeAmount:this.pricing.baseChargeAmount.getDetails(),taxCategory:this.pricing.taxCategory,applicableTaxRule:this.pricing.applicableTaxRule.map(e=>e.getDetails())},impact:this.impact,lineItemId:this.lineItemId,total:{chargeAmount:this.total.chargeAmount.getDetails(),discountTotal:this.total.discountTotal.getDetails(),discountBreakdown:Object.fromEntries(Object.entries(this.total.discountBreakdown).map(([e,a])=>[e,a.getDetails()])),netChargeAmount:this.total.netChargeAmount.getDetails(),taxBreakdown:Object.fromEntries(Object.entries(this.total.taxBreakdown).map(([e,a])=>[e,{rate:a.rate,taxableAmount:a.taxableAmount.getDetails(),taxAmount:a.taxAmount.getDetails(),system:a.system,subSystem:a.subSystem}])),taxTotal:this.total.taxTotal.getDetails(),grandTotal:this.total.grandTotal.getDetails()},customFields:this.getAllCustomFields()}}};export{A as a};//# sourceMappingURL=chunk-A34BAO7J.mjs.map
2
- //# sourceMappingURL=chunk-A34BAO7J.mjs.map
1
+ import {a as a$4,b}from'./chunk-MPKIC2MS.mjs';import {a as a$2}from'./chunk-EZ35IKUA.mjs';import {a as a$3}from'./chunk-4PTWJI6J.mjs';import {a as a$1}from'./chunk-UIQH5QIR.mjs';import {e}from'./chunk-PL5HGCWN.mjs';import {w,k,x}from'./chunk-O6BLQQO7.mjs';import {a}from'./chunk-UXZBULDS.mjs';var A=class extends a{id;name;type;category;impact;pricing;lineItemId;total;constructor(t){if(super(t),this.id=t.id,this.name=t.name,this.type=t.type,this.category=t.category,this.impact=t.impact,this.lineItemId=t.lineItemId,this.pricing={baseChargeAmount:new a$1(t.pricing.baseChargeAmount),taxCategory:t.pricing.taxCategory,applicableTaxRule:t.pricing.applicableTaxRule.map(e=>new a$2(e))},this.validateTaxRules(this.pricing.applicableTaxRule),this.impact==="SUBTRACT"&&this.type!=="ADJUSTMENT")throw new w("SUBTRACT impact is only allowed for ADJUSTMENT charge");this.total={chargeAmount:new a$1(t.total.chargeAmount),discountTotal:new a$1(t.total.discountTotal),discountBreakdown:Object.fromEntries(Object.entries(t.total.discountBreakdown).map(([e,a])=>[e,new a$1(a)])),netChargeAmount:new a$1(t.total.netChargeAmount),taxBreakdown:Object.fromEntries(Object.entries(t.total.taxBreakdown).map(([e,a])=>[e,{rate:a.rate,taxableAmount:new a$1(a.taxableAmount),taxAmount:new a$1(a.taxAmount),system:a.system,subSystem:a.subSystem}])),taxTotal:new a$1(t.total.taxTotal),grandTotal:new a$1(t.total.grandTotal)};}getId(){return this.id}getName(t){return t?a$3.deepClone(this.name[t]??this.name[e[t]]??this.name.en):a$3.deepClone(this.name)}getCategory(){return this.category}getType(){return this.type}getImpact(){return this.impact}getLineItemId(){return this.lineItemId}getPricing(){return {baseChargeAmount:this.pricing.baseChargeAmount,taxCategory:this.pricing.taxCategory,applicableTaxRule:[...this.pricing.applicableTaxRule]}}getTotal(){return {chargeAmount:this.total.chargeAmount,discountTotal:this.total.discountTotal,discountBreakdown:{...this.total.discountBreakdown},netChargeAmount:this.total.netChargeAmount,taxTotal:this.total.taxTotal,taxBreakdown:Object.fromEntries(Object.entries(this.total.taxBreakdown).map(([t,e])=>[t,{rate:e.rate,taxableAmount:e.taxableAmount,taxAmount:e.taxAmount,system:e.system,subSystem:e.subSystem}])),grandTotal:this.total.grandTotal}}getApplicableTaxRules(){return [...this.pricing.applicableTaxRule]}updateTax(t){if(this.type==="ADJUSTMENT"&&t.length>0)throw new w("Adjustment charges cannot apply tax rules.");t.forEach(e=>{if(!e.appliesTo(this.pricing.taxCategory,e.getCountry()))throw new k}),this.validateTaxRules(t),this.pricing.applicableTaxRule=t,this.calculateTotals();}validateTaxRules(t){if(this.impact==="SUBTRACT"&&t.some(a=>a.getRate()>0))throw new x("Subtractive charges cannot have positive tax rates.");let e=new Set;for(let a=0;a<t.length;a++){let r=t[a].getTaxRuleId();if(e.has(r))throw new x("Duplicate tax rule ID found: "+r);e.add(r);for(let g=a+1;g<t.length;g++){let u=t[a],l=t[g],m=u.getMinPrice(),i=u.getMaxPrice(),p=u.getExcludeMin(),o=u.getExcludeMax(),n=l.getMinPrice(),c=l.getMaxPrice(),T=l.getExcludeMin(),b=l.getExcludeMax(),D=(()=>{if(!i)return !1;let d=i.compareTo(n);return d<0||d===0&&(o||T)})(),B=(()=>{if(!c)return !1;let d=c.compareTo(m);return d<0||d===0&&(b||p)})();if(!(D||B)&&!(m.compareTo(n)===0&&p===T&&o===b&&(!i&&!c||i&&c&&i.compareTo(c)===0)))throw new x(`Overlapping rules found: [${u.getTaxRuleId()}: ${p?"(":"["}${m.getAmount()}-${i?.getAmount()??"Infinity"}${o?")":"]"}] and [${l.getTaxRuleId()}: ${T?"(":"["}${n.getAmount()}-${c?.getAmount()??"Infinity"}${b?")":"]"}]`)}}}updateDiscounts(t){let e={};t.forEach(a=>{e[a.coupon.getCode()]=a.amount;}),this.total.discountBreakdown=e,this.calculateTotals();}calculateTotals(){let t=this.pricing.baseChargeAmount.zero(),e=this.pricing.baseChargeAmount,a=Object.values(this.total.discountBreakdown).reduce((o,n)=>o.add(n),t),r=e.subtract(a),g={};if(this.pricing.applicableTaxRule.reduce((o,n)=>o+n.getApplicableTaxRate(r),0)<=0){this.total={chargeAmount:e,discountTotal:a,discountBreakdown:this.total.discountBreakdown,netChargeAmount:r,taxTotal:t,taxBreakdown:{},grandTotal:r};return}let l=a$4(r,this.pricing.applicableTaxRule),m=b(l,r,this.pricing.applicableTaxRule),i=t;m.forEach(o=>{let n=this.pricing.applicableTaxRule.find(c=>c.getTaxRuleId()===o.ruleId);g[o.ruleId]={rate:o.rate,taxableAmount:l,taxAmount:o.taxAmount,system:n.getTaxSystem(),subSystem:n.getTaxSubSystem()},i=i.add(o.taxAmount);});let p=r;this.total={chargeAmount:e,discountTotal:a,discountBreakdown:this.total.discountBreakdown,netChargeAmount:r,taxBreakdown:g,taxTotal:i,grandTotal:p};}getDetails(){return {id:this.id,name:a$3.deepClone(this.name),type:this.type,category:this.category,pricing:{baseChargeAmount:this.pricing.baseChargeAmount.getDetails(),taxCategory:this.pricing.taxCategory,applicableTaxRule:this.pricing.applicableTaxRule.map(e=>e.getDetails())},impact:this.impact,lineItemId:this.lineItemId,total:{chargeAmount:this.total.chargeAmount.getDetails(),discountTotal:this.total.discountTotal.getDetails(),discountBreakdown:Object.fromEntries(Object.entries(this.total.discountBreakdown).map(([e,a])=>[e,a.getDetails()])),netChargeAmount:this.total.netChargeAmount.getDetails(),taxBreakdown:Object.fromEntries(Object.entries(this.total.taxBreakdown).map(([e,a])=>[e,{rate:a.rate,taxableAmount:a.taxableAmount.getDetails(),taxAmount:a.taxAmount.getDetails(),system:a.system,subSystem:a.subSystem}])),taxTotal:this.total.taxTotal.getDetails(),grandTotal:this.total.grandTotal.getDetails()},customFields:this.getAllCustomFields()}}};export{A as a};//# sourceMappingURL=chunk-5N2HRXWJ.mjs.map
2
+ //# sourceMappingURL=chunk-5N2HRXWJ.mjs.map