arky-sdk 0.2.0 → 0.3.1

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.
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types/index.ts"],"names":["PaymentMethod"],"mappings":";AAuBO,IAAK,aAAA,qBAAAA,cAAAA,KAAL;AACN,EAAAA,eAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,eAAA,YAAA,CAAA,GAAa,aAAA;AACb,EAAAA,eAAA,MAAA,CAAA,GAAO,MAAA;AAHI,EAAA,OAAAA,cAAAA;AAAA,CAAA,EAAA,aAAA,IAAA,EAAA","file":"types.js","sourcesContent":["// Core type definitions\n// All types are exported individually for better tree-shaking\n\n// NEW: Payment structure (matches backend)\nexport interface Payment {\n\tcurrency: string;\n\tmarket: string;\n\tsubtotal: number;\n\tshipping: number;\n\tdiscount: number;\n\ttax: number;\n\ttotal: number;\n\tpromoCodeId?: string;\n\tpromoCode?: string;\n\tpromoType?: string;\n\tpromoValue?: number;\n\tmethod: PaymentMethod;\n\tcustomerId?: string;\n\tpaymentIntentId?: string;\n\tsubscriptionId?: string;\n\tpriceId?: string;\n}\n\nexport enum PaymentMethod {\n\tCash = \"CASH\",\n\tCreditCard = \"CREDIT_CARD\",\n\tFree = \"FREE\",\n}\n\n// Quote line item (from quote engine)\nexport interface QuoteLineItem {\n\titemType: string;\n\tid: string;\n\tname: string;\n\tquantity: number;\n\tunitPrice: number;\n\ttotal: number;\n}\n\n// Promo code validation result\nexport interface PromoCodeValidation {\n\tid: string;\n\tcode: string;\n\tdiscountType: any;\n\tdiscountValue: number;\n\tconditions: any[];\n}\n\n// Quote response from backend (full pricing breakdown)\nexport interface Quote {\n\tcurrency: string;\n\tmarket: string;\n\tsubtotal: number;\n\tshipping: number;\n\tdiscount: number;\n\ttax: number;\n\ttotal: number;\n\tlineItems: QuoteLineItem[];\n\tshippingMethod: ShippingMethod | null;\n\tpromoCode: PromoCodeValidation | null;\n\tpayment: Payment;\n\tchargeAmount: number;\n}\n\n// Market-based price structure (for product variants)\nexport interface Price {\n\tmarket: string;\n\tamount: number;\n\tcompareAt?: number;\n}\n\n// Location structure (for shipping addresses, pickup points, etc.)\nexport interface Location {\n\tcountry?: string | null;\n\taddress?: string | null;\n\tcity?: string | null;\n\tpostalCode?: string | null;\n\tcountryCode?: string | null;\n\tcoordinates?: { lat: number; lon: number } | null;\n}\n\n// Zone structure (logistics grouping - countries, tax rates, shipping methods)\nexport interface Zone {\n\tid: string;\n\tname: string;\n\tcountries: string[]; // Empty array = \"All Countries\"\n\ttaxBps: number;\n\tshippingMethods: ShippingMethod[];\n}\n\n// Cart types\nexport interface EshopCartItem {\n\tid: string;\n\tproductId: string;\n\tvariantId: string;\n\tproductName: string;\n\tproductSlug: string;\n\tvariantAttributes: Record<string, any>;\n\tprice: Price; // Minor units (backend format)\n\tquantity: number;\n\taddedAt: number;\n}\n\nexport interface ReservationCartPart {\n\tid: string;\n\tserviceId: string;\n\tserviceName: string;\n\tdate: string;\n\tfrom: number;\n\tto: number;\n\ttimeText: string;\n\tisMultiDay: boolean;\n\treservationMethod: string;\n\tproviderId?: string;\n\tblocks: any[];\n}\n\n// Payment provider types\nexport interface PaymentProviderConfig {\n\ttype: \"STRIPE\";\n\tpublicKey: string;\n\tsecretKey: string;\n\twebhookSecret: string;\n}\n\n// Market types (business-owned) - camelCase for frontend\nexport interface Market {\n\tid: string;\n\tname: string;\n\tcurrency: string;\n\ttaxMode: \"INCLUSIVE\" | \"EXCLUSIVE\";\n\ttaxBps: number;\n\tpaymentMethods: BusinessPaymentMethod[];\n}\n\nexport interface ShippingMethod {\n id: string;\n type: 'SHIPPING' | 'PICKUP';\n prices: Price[]; // Market-based pricing with free thresholds\n taxable: boolean;\n etaText: string; // e.g., \"3-5 business days\"\n location?: Location; // Pickup address (only for PICKUP type)\n}\n\nexport interface BusinessPaymentMethod {\n\tmethod: PaymentMethod;\n}\n\n// Business types\nexport interface BusinessConfig {\n\torderBlocks?: any[];\n\treservationBlocks?: any[];\n\tmarkets?: Market[];\n\tzones?: Zone[];\n\tpaymentProvider?: PaymentProviderConfig;\n\taiProvider?: any;\n}\n\nexport interface Business {\n\tid: string;\n\tname: string;\n\tconfigs?: BusinessConfig;\n}\n\n// Store state types - Simplified (business data moved to business store)\nexport interface EshopStoreState {\n\tbusinessId: string;\n\tselectedShippingMethodId: string | null;\n\tuserToken: string | null;\n\tprocessingCheckout: boolean;\n\tloading: boolean;\n\terror: string | null;\n\tphoneNumber: string;\n\tphoneError: string | null;\n\tverificationCode: string;\n\tverifyError: string | null;\n}\n\nexport interface Block {\n\tid: string;\n\tkey: string;\n\ttype: string;\n\tproperties?: any;\n\tvalue?: any;\n}\n\n// API Response types\nexport interface ApiResponse<T> {\n success: boolean;\n data?: T;\n error?: string;\n code?: string;\n cursor?: string;\n total?: number;\n}\n\nexport interface PaginatedResponse<T> {\n\tdata: T[];\n\tmeta?: {\n\t\ttotal: number;\n\t\tpage: number;\n\t\tper_page: number;\n\t};\n}\n\n// Newsletter types\nexport interface Newsletter {\n\tid: string;\n\tbusinessId: string;\n\tname: string;\n\tdescription: string;\n\tnewsletterType: \"FREE\" | \"PAID\";\n\tstatuses: any[];\n\tprices: Price[]; // NEW: Market-based pricing\n\tpaymentProduct?: {\n\t\tpriceId: string;\n\t};\n\tunsubscribeRedirectUrl: string;\n\tcreatedAt: number;\n\tupdatedAt: number;\n}\n\n// Legacy types - kept for compatibility\nexport interface MarketConfigClient {\n\tcurrency: string;\n\ttaxMode: string;\n\tdefaultTaxRate: number;\n\tpaymentMethods: string[];\n\tshowTaxIncluded: boolean;\n\tshippingMethods?: ShippingMethod[];\n}\n\nexport interface ReservationStoreState {\n\tcurrentStep: number;\n\ttotalSteps: number;\n\tsteps: Record<number, { name: string; labelKey: string }>;\n\n\t// Calendar data\n\tweekdays: string[];\n\tmonthYear: string;\n\tdays: any[];\n\tcurrent: Date;\n\n\t// Selection state\n\tselectedDate: string | null;\n\tslots: any[];\n\tselectedSlot: any | null;\n\tselectedMethod: string | null;\n\tselectedProvider: any | null;\n\tproviders: any[];\n\n\t// Status flags\n\tloading: boolean;\n\tstartDate: string | null;\n\tendDate: string | null;\n\tisMultiDay: boolean;\n\n\t// Phone verification\n\tphoneNumber: string;\n\tphoneError: string | null;\n\tphoneSuccess: string | null;\n\tverificationCode: string;\n\tverifyError: string | null;\n\tisPhoneVerified: boolean;\n\tisSendingCode: boolean;\n\tisVerifying: boolean;\n\tcodeSentAt: number | null;\n\tcanResendAt: number | null;\n\n\t// Service & config\n\tguestToken: string | null;\n\tservice: any | null;\n\tbusiness: Business | null;\n\tcurrency: string;\n\treservationBlocks: Block[];\n\tapiUrl: string;\n\tbusinessId: string;\n\tstorageUrl: string;\n\ttimezone: string;\n\ttzGroups: any;\n\tparts: ReservationCartPart[];\n\n\t// Payment configuration\n\tallowedPaymentMethods: string[];\n\tpaymentConfig: {\n\t\tprovider: PaymentProviderConfig | null;\n\t\tenabled: boolean;\n\t};\n}\n"]}
1
+ {"version":3,"sources":["../src/types/index.ts"],"names":["PaymentMethod"],"mappings":";AAyBO,IAAK,aAAA,qBAAAA,cAAAA,KAAL;AACN,EAAAA,eAAA,MAAA,CAAA,GAAO,MAAA;AACP,EAAAA,eAAA,YAAA,CAAA,GAAa,aAAA;AACb,EAAAA,eAAA,MAAA,CAAA,GAAO,MAAA;AAHI,EAAA,OAAAA,cAAAA;AAAA,CAAA,EAAA,aAAA,IAAA,EAAA","file":"types.js","sourcesContent":["// Core type definitions\n// All types are exported individually for better tree-shaking\n\nexport * from './api';\n\n// NEW: Payment structure (matches backend)\nexport interface Payment {\n\tcurrency: string;\n\tmarket: string;\n\tsubtotal: number;\n\tshipping: number;\n\tdiscount: number;\n\ttax: number;\n\ttotal: number;\n\tpromoCodeId?: string;\n\tpromoCode?: string;\n\tpromoType?: string;\n\tpromoValue?: number;\n\tmethod: PaymentMethod;\n\tcustomerId?: string;\n\tpaymentIntentId?: string;\n\tsubscriptionId?: string;\n\tpriceId?: string;\n}\n\nexport enum PaymentMethod {\n\tCash = \"CASH\",\n\tCreditCard = \"CREDIT_CARD\",\n\tFree = \"FREE\",\n}\n\n// Quote line item (from quote engine)\nexport interface QuoteLineItem {\n\titemType: string;\n\tid: string;\n\tname: string;\n\tquantity: number;\n\tunitPrice: number;\n\ttotal: number;\n}\n\n// Promo code validation result\nexport interface PromoCodeValidation {\n\tid: string;\n\tcode: string;\n\tdiscountType: any;\n\tdiscountValue: number;\n\tconditions: any[];\n}\n\n// Quote response from backend (full pricing breakdown)\nexport interface Quote {\n\tcurrency: string;\n\tmarket: string;\n\tsubtotal: number;\n\tshipping: number;\n\tdiscount: number;\n\ttax: number;\n\ttotal: number;\n\tlineItems: QuoteLineItem[];\n\tshippingMethod: ShippingMethod | null;\n\tpromoCode: PromoCodeValidation | null;\n\tpayment: Payment;\n\tchargeAmount: number;\n}\n\n// Market-based price structure (for product variants)\nexport interface Price {\n\tmarket: string;\n\tamount: number;\n\tcompareAt?: number;\n}\n\n// Location structure (for shipping addresses, pickup points, etc.)\nexport interface Location {\n\tcountry?: string | null;\n\taddress?: string | null;\n\tcity?: string | null;\n\tpostalCode?: string | null;\n\tcountryCode?: string | null;\n\tcoordinates?: { lat: number; lon: number } | null;\n}\n\n// Zone structure (logistics grouping - countries, tax rates, shipping methods)\nexport interface Zone {\n\tid: string;\n\tname: string;\n\tcountries: string[]; // Empty array = \"All Countries\"\n\ttaxBps: number;\n\tshippingMethods: ShippingMethod[];\n}\n\n// Cart types\nexport interface EshopCartItem {\n\tid: string;\n\tproductId: string;\n\tvariantId: string;\n\tproductName: string;\n\tproductSlug: string;\n\tvariantAttributes: Record<string, any>;\n\tprice: Price; // Minor units (backend format)\n\tquantity: number;\n\taddedAt: number;\n}\n\nexport interface ReservationCartPart {\n\tid: string;\n\tserviceId: string;\n\tserviceName: string;\n\tdate: string;\n\tfrom: number;\n\tto: number;\n\ttimeText: string;\n\tisMultiDay: boolean;\n\treservationMethod: string;\n\tproviderId?: string;\n\tblocks: any[];\n}\n\n// Payment provider types\nexport interface PaymentProviderConfig {\n\ttype: \"STRIPE\";\n\tpublicKey: string;\n\tsecretKey: string;\n\twebhookSecret: string;\n}\n\n// Market types (business-owned) - camelCase for frontend\nexport interface Market {\n\tid: string;\n\tname: string;\n\tcurrency: string;\n\ttaxMode: \"INCLUSIVE\" | \"EXCLUSIVE\";\n\ttaxBps: number;\n\tpaymentMethods: BusinessPaymentMethod[];\n}\n\nexport interface ShippingMethod {\n id: string;\n type: 'SHIPPING' | 'PICKUP';\n prices: Price[]; // Market-based pricing with free thresholds\n taxable: boolean;\n etaText: string; // e.g., \"3-5 business days\"\n location?: Location; // Pickup address (only for PICKUP type)\n}\n\nexport interface BusinessPaymentMethod {\n\tmethod: PaymentMethod;\n}\n\n// Business types\nexport interface BusinessConfig {\n\torderBlocks?: any[];\n\treservationBlocks?: any[];\n\tmarkets?: Market[];\n\tzones?: Zone[];\n\tpaymentProvider?: PaymentProviderConfig;\n\taiProvider?: any;\n}\n\nexport interface Business {\n\tid: string;\n\tname: string;\n\tconfigs?: BusinessConfig;\n}\n\n// Store state types - Simplified (business data moved to business store)\nexport interface EshopStoreState {\n\tbusinessId: string;\n\tselectedShippingMethodId: string | null;\n\tuserToken: string | null;\n\tprocessingCheckout: boolean;\n\tloading: boolean;\n\terror: string | null;\n\tphoneNumber: string;\n\tphoneError: string | null;\n\tverificationCode: string;\n\tverifyError: string | null;\n}\n\nexport interface Block {\n\tid: string;\n\tkey: string;\n\ttype: string;\n\tproperties?: any;\n\tvalue?: any;\n}\n\n// API Response types\nexport interface ApiResponse<T> {\n success: boolean;\n data?: T;\n error?: string;\n cursor?: string;\n total?: number;\n}\n\nexport interface PaginatedResponse<T> {\n\tdata: T[];\n\tmeta?: {\n\t\ttotal: number;\n\t\tpage: number;\n\t\tper_page: number;\n\t};\n}\n\n// Newsletter types\nexport interface Newsletter {\n\tid: string;\n\tbusinessId: string;\n\tname: string;\n\tdescription: string;\n\tnewsletterType: \"FREE\" | \"PAID\";\n\tstatuses: any[];\n\tprices: Price[]; // NEW: Market-based pricing\n\tpaymentProduct?: {\n\t\tpriceId: string;\n\t};\n\tunsubscribeRedirectUrl: string;\n\tcreatedAt: number;\n\tupdatedAt: number;\n}\n\n// Legacy types - kept for compatibility\nexport interface MarketConfigClient {\n\tcurrency: string;\n\ttaxMode: string;\n\tdefaultTaxRate: number;\n\tpaymentMethods: string[];\n\tshowTaxIncluded: boolean;\n\tshippingMethods?: ShippingMethod[];\n}\n\nexport interface ReservationStoreState {\n\tcurrentStep: number;\n\ttotalSteps: number;\n\tsteps: Record<number, { name: string; labelKey: string }>;\n\n\t// Calendar data\n\tweekdays: string[];\n\tmonthYear: string;\n\tdays: any[];\n\tcurrent: Date;\n\n\t// Selection state\n\tselectedDate: string | null;\n\tslots: any[];\n\tselectedSlot: any | null;\n\tselectedMethod: string | null;\n\tselectedProvider: any | null;\n\tproviders: any[];\n\n\t// Status flags\n\tloading: boolean;\n\tstartDate: string | null;\n\tendDate: string | null;\n\tisMultiDay: boolean;\n\n\t// Phone verification\n\tphoneNumber: string;\n\tphoneError: string | null;\n\tphoneSuccess: string | null;\n\tverificationCode: string;\n\tverifyError: string | null;\n\tisPhoneVerified: boolean;\n\tisSendingCode: boolean;\n\tisVerifying: boolean;\n\tcodeSentAt: number | null;\n\tcanResendAt: number | null;\n\n\t// Service & config\n\tguestToken: string | null;\n\tservice: any | null;\n\tbusiness: Business | null;\n\tcurrency: string;\n\treservationBlocks: Block[];\n\tapiUrl: string;\n\tbusinessId: string;\n\tstorageUrl: string;\n\ttimezone: string;\n\ttzGroups: any;\n\tparts: ReservationCartPart[];\n\n\t// Payment configuration\n\tallowedPaymentMethods: string[];\n\tpaymentConfig: {\n\t\tprovider: PaymentProviderConfig | null;\n\t\tenabled: boolean;\n\t};\n}\n"]}
package/dist/utils.cjs CHANGED
@@ -1,14 +1,5 @@
1
1
  'use strict';
2
2
 
3
- // src/config.ts
4
- function getGlobalConfig() {
5
- {
6
- throw new Error(
7
- "Arky SDK not initialized. Call initArky() first."
8
- );
9
- }
10
- }
11
-
12
3
  // src/utils/blocks.ts
13
4
  function getBlockLabel(block, locale = "en") {
14
5
  if (!block) return "";
@@ -139,10 +130,8 @@ var getBlockFromArray = (entry, blockKey, locale = "en") => {
139
130
  return acc;
140
131
  });
141
132
  };
142
- var getImageUrl = (imageBlock, isBlock = true) => {
133
+ var getImageUrl = (imageBlock, isBlock = true, storageUrl = "https://storage.arky.io/dev") => {
143
134
  if (!imageBlock) return null;
144
- const config = getGlobalConfig();
145
- const storageUrl = config.storageUrl || "https://storage.arky.io/dev";
146
135
  const isExternalUrl = (url) => {
147
136
  return url.startsWith("http://") || url.startsWith("https://");
148
137
  };
@@ -188,9 +177,7 @@ function getGalleryThumbnail(gallery) {
188
177
  const res = item.media.resolutions.thumbnail || item.media.resolutions.original;
189
178
  return res?.url || null;
190
179
  }
191
- function thumbnailUrl(service) {
192
- const config = getGlobalConfig();
193
- const storageUrl = config.storageUrl || "";
180
+ function thumbnailUrl(service, storageUrl = "") {
194
181
  const path = getGalleryThumbnail(service.gallery);
195
182
  return path ? `${storageUrl}/${path}` : null;
196
183
  }
@@ -243,7 +230,7 @@ var ERROR_CODES = {
243
230
  "BUSINESS.007": "BUSINESS.BUSINESS_ID_REQUIRED",
244
231
  "BUSINESS.010": "BUSINESS.DESCRIPTION_REQUIRED",
245
232
  "BUSINESS.011": "BUSINESS.SLUG_INVALID",
246
- // Provider errors
233
+ // Provider errors
247
234
  "PROVIDER.001": "PROVIDER.NOT_FOUND",
248
235
  "PROVIDER.002": "PROVIDER.FAILED_TO_CREATE",
249
236
  "PROVIDER.003": "PROVIDER.FAILED_TO_UPDATE",
@@ -293,11 +280,11 @@ var transformErrors = (zodError) => {
293
280
  if (!zodError.issues) return customErrors;
294
281
  zodError.issues.forEach((issue) => {
295
282
  const field = issue.path.join(".");
296
- const message = issue.message;
283
+ const error = issue.message;
297
284
  if (!customErrors.some(
298
- (customError) => customError.field === field && customError.message === message
285
+ (customError) => customError.field === field && customError.error === error
299
286
  )) {
300
- customErrors.push({ field, message });
287
+ customErrors.push({ field, error });
301
288
  }
302
289
  });
303
290
  return customErrors;
@@ -309,7 +296,7 @@ var convertServerErrorToRequestError = (serverError, renameRules) => {
309
296
  const field = renameRules && renameRules[validationError.field] ? renameRules[validationError.field] : validationError.field;
310
297
  return {
311
298
  field,
312
- message: ERROR_CODES[validationError.code] || "Unknown error"
299
+ error: validationError.error || "GENERAL.VALIDATION_ERROR"
313
300
  };
314
301
  })
315
302
  };
@@ -400,15 +387,12 @@ function getCurrencySymbol(currency) {
400
387
  };
401
388
  return currencySymbols[currency.toUpperCase()] || currency;
402
389
  }
390
+ var SYMBOL_AFTER_CURRENCIES = ["SEK", "NOK", "DKK", "PLN", "CZK", "HUF", "RON", "BGN", "HRK"];
391
+ function isSymbolAfterCurrency(currency) {
392
+ return SYMBOL_AFTER_CURRENCIES.includes(currency.toUpperCase());
393
+ }
403
394
 
404
395
  // src/utils/price.ts
405
- var CURRENCY_SYMBOLS = {
406
- "USD": "$",
407
- "EUR": "\u20AC",
408
- "GBP": "\xA3",
409
- "CAD": "C$",
410
- "AUD": "A$"
411
- };
412
396
  var MARKET_CURRENCIES = {
413
397
  "US": "USD",
414
398
  "EU": "EUR",
@@ -422,9 +406,6 @@ function convertToMajor(minorAmount) {
422
406
  function convertToMinor(majorAmount) {
423
407
  return Math.round((majorAmount ?? 0) * 100);
424
408
  }
425
- function getSymbol(currency) {
426
- return CURRENCY_SYMBOLS[currency] || "$";
427
- }
428
409
  function getCurrencyFromMarket(marketId) {
429
410
  return MARKET_CURRENCIES[marketId] || "USD";
430
411
  }
@@ -434,7 +415,10 @@ function formatCurrencyAmount(amount, currency, options = {}) {
434
415
  if (!showSymbols) {
435
416
  return `${roundedAmount} ${currency}`;
436
417
  }
437
- const symbol = customSymbol || getSymbol(currency);
418
+ const symbol = customSymbol || getCurrencySymbol(currency);
419
+ if (isSymbolAfterCurrency(currency)) {
420
+ return `${roundedAmount} ${symbol}`;
421
+ }
438
422
  return `${symbol}${roundedAmount}`;
439
423
  }
440
424
  function formatMinor(amountMinor, currency, options = {}) {
@@ -479,11 +463,11 @@ function getMarketPrice(prices, marketId, businessMarkets, options = {}) {
479
463
  symbol = getCurrencySymbol(currency);
480
464
  } else {
481
465
  currency = getCurrencyFromMarket(price.market);
482
- symbol = getSymbol(currency);
466
+ symbol = getCurrencySymbol(currency);
483
467
  }
484
468
  } else {
485
469
  currency = getCurrencyFromMarket(price.market);
486
- symbol = getSymbol(currency);
470
+ symbol = getCurrencySymbol(currency);
487
471
  }
488
472
  const formattedPrice = formatMinor(price.amount ?? 0, currency, {
489
473
  showSymbols,
@@ -716,7 +700,6 @@ exports.getImageUrl = getImageUrl;
716
700
  exports.getMarketPrice = getMarketPrice;
717
701
  exports.getPriceAmount = getPriceAmount;
718
702
  exports.getSvgContentForAstro = getSvgContentForAstro;
719
- exports.getSymbol = getSymbol;
720
703
  exports.humanize = humanize;
721
704
  exports.injectSvgIntoElement = injectSvgIntoElement;
722
705
  exports.isErrorCode = isErrorCode;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/config.ts","../src/utils/blocks.ts","../src/utils/errors.ts","../src/utils/currency.ts","../src/utils/price.ts","../src/utils/svg.ts","../src/utils/text.ts","../src/utils/timezone.ts","../src/utils/validation.ts"],"names":[],"mappings":";;;AAmBO,SAAS,eAAA,GAA8B;AAC1C,EAAmB;AACf,IAAA,MAAM,IAAI,KAAA;AAAA,MACN;AAAA,KACJ;AAAA,EACJ;AAEJ;;;ACHO,SAAS,aAAA,CAAc,KAAA,EAAY,MAAA,GAAiB,IAAA,EAAc;AACrE,EAAA,IAAI,CAAC,OAAO,OAAO,EAAA;AAEnB,EAAA,IAAI,KAAA,CAAM,YAAY,KAAA,EAAO;AACzB,IAAA,IAAI,OAAO,KAAA,CAAM,UAAA,CAAW,KAAA,KAAU,QAAA,EAAU;AAC5C,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AAEtC,EAAA,IAAI,OAAA,CAAQ,WAAW,CAAA,EAAG;AACtB,IAAA,OAAO,EAAE,OAAA,EAAS,KAAA,EAAO,KAAA,EAAO,0CAAA,EAA2C;AAAA,EAC/E;AAEA,EAAA,OAAO,EAAE,SAAS,IAAA,EAAK;AAC3B;AAGO,SAAS,gBAAA,CAAiB,KAAA,EAAY,SAAA,GAAoB,YAAA,EAAgC;AAC7F,EAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,KAAA,KAAU,MAAA,IAAa,UAAU,EAAA,EAAI;AACvD,IAAA,OAAO,EAAE,OAAA,EAAS,KAAA,EAAO,KAAA,EAAO,CAAA,EAAG,SAAS,CAAA,YAAA,CAAA,EAAe;AAAA,EAC/D;AAEA,EAAA,OAAO,EAAE,SAAS,IAAA,EAAK;AAC3B","file":"utils.cjs","sourcesContent":["// SDK Configuration Types\n\nexport interface ArkyConfig {\n apiUrl: string;\n businessId: string;\n storageUrl?: string;\n auth?: {\n type: 'guest' | 'api-token';\n apiToken?: string;\n };\n}\n\n// Simple global config storage (no module-level exports)\nlet globalConfig: ArkyConfig | null = null;\n\nexport function setGlobalConfig(config: ArkyConfig): void {\n globalConfig = config;\n}\n\nexport function getGlobalConfig(): ArkyConfig {\n if (!globalConfig) {\n throw new Error(\n 'Arky SDK not initialized. Call initArky() first.'\n );\n }\n return globalConfig;\n}\n","// Block utilities (extracted from index.ts)\nimport { getGlobalConfig } from '../config';\n\nexport interface Block {\n id: string;\n key: string;\n type: string;\n properties: any;\n value: any;\n}\n\nexport interface Collection {\n id: string;\n blocks: Block[];\n}\n\nexport interface CollectionEntry {\n id: string;\n collection_id: string;\n blocks: Block[];\n}\n\n\nexport function getBlockLabel(block: any, locale: string = 'en'): string {\n if (!block) return \"\";\n\n if (block.properties?.label) {\n if (typeof block.properties.label === \"object\") {\n return (\n block.properties.label[locale] ||\n block.properties.label.en ||\n Object.values(block.properties.label)[0] ||\n \"\"\n );\n }\n if (typeof block.properties.label === \"string\") {\n return block.properties.label;\n }\n }\n \n // Convert key to readable format\n return block.key?.replace(/_/g, ' ').replace(/\\b\\w/g, (l: string) => l.toUpperCase()) || \"\";\n}\n\n\nexport function formatBlockValue(block: any): string {\n if (!block || block.value === null || block.value === undefined) {\n return \"\";\n }\n\n switch (block.type) {\n case \"BOOLEAN\":\n return block.value ? \"Yes\" : \"No\";\n case \"NUMBER\":\n // Handle date/datetime variants\n if (block.properties?.variant === \"DATE\" || block.properties?.variant === \"DATE_TIME\") {\n try {\n return new Date(block.value).toLocaleDateString();\n } catch (e) {\n return String(block.value);\n }\n }\n return String(block.value);\n case \"RELATIONSHIP\":\n if (Array.isArray(block.value) && block.value.length > 0) {\n const firstValue = block.value[0];\n if (firstValue && firstValue.mimeType) {\n return firstValue.name || firstValue.id || \"Media\";\n }\n return firstValue.title || firstValue.name || firstValue.id || \"Entry\";\n }\n return String(block.value);\n default:\n return String(block.value);\n }\n}\n\nexport function prepareBlocksForSubmission(formData: any): any[] {\n const preparedBlocks = [];\n\n Object.keys(formData).forEach((key) => {\n if (formData[key] !== null && formData[key] !== undefined) {\n preparedBlocks.push({\n key,\n value: [formData[key]],\n });\n }\n });\n\n return preparedBlocks;\n}\n\nexport function extractBlockValues(blocks: any[]): Record<string, any> {\n const values: Record<string, any> = {};\n\n blocks.forEach((block) => {\n if (block.value && block.value.length > 0) {\n values[block.key] = block.value[0];\n } else {\n values[block.key] = null;\n }\n });\n\n return values;\n}\n\n// Extract localized text value from a block, handling multilingual content\nexport function getBlockTextValue(block: any, locale: string = 'en'): string {\n if (!block || !block.value || block.value.length === 0) return '';\n \n const firstValue = block.value[0];\n \n // Handle multilingual object\n if (typeof firstValue === 'object' && firstValue !== null) {\n // Try specified locale first, then 'en', then first available language\n if (firstValue[locale]) return firstValue[locale];\n if (firstValue.en) return firstValue.en;\n const values = Object.values(firstValue);\n return String(values[0] || '');\n }\n \n // Handle simple string\n return String(firstValue);\n}\n\n// Legacy functions for backward compatibility\nexport const getBlockValue = (entry: any, blockKey: string) => {\n if (!entry || !entry.blocks) return null;\n\n const block = entry.blocks.find((f: any) => f.key === blockKey);\n\n if (!block || !block.value || block.value.length === 0) return null;\n\n return block.value[0];\n};\n\nexport const getBlockValues = (entry: any, blockKey: string) => {\n if (!entry || !entry.blocks) return null;\n\n const block = entry.blocks.find((f: any) => f.key === blockKey);\n\n if (!block || !block.value || block.value.length === 0) return null;\n\n return block.value;\n};\n\nfunction unwrapBlock(block: any, locale: string) {\n if (!block?.type || block.value === undefined) return block;\n\n // Nested objects / lists → recurse for every child\n if (block.type === \"BLOCK\") {\n return block.value.map((obj: Record<string, any>) => {\n const parsed: Record<string, any> = {};\n for (const [k, v] of Object.entries(obj)) {\n parsed[k] = unwrapBlock(v, locale);\n }\n return parsed;\n });\n }\n\n // Primitive leaves (text/number/boolean/media …)\n const isLocalized = block.type === \"TEXT\";\n const isList =\n block.properties?.ui === \"list\" ||\n (block.properties?.maxValues ?? 1) > 1 ||\n block.value.length > 1;\n\n if (isList) {\n return isLocalized\n ? block.value.map((v: Record<string, any>) => v[locale] || v[\"en\"])\n : [...block.value];\n }\n\n return isLocalized ? block.value[0][locale] || block.value[0][\"en\"] : block.value[0];\n}\n\nexport const getBlockObjectValues = (entry: any, blockKey: string, locale = \"en\") => {\n if (!entry) {\n return [];\n }\n\n const values = getBlockValues(entry, blockKey); // top‑level list\n\n const parsed = values.map((obj: Record<string, any>) => {\n const res = obj.value.reduce((acc: any, current: any) => {\n acc[current.key] = unwrapBlock(current, locale);\n\n return acc;\n }, {});\n\n return res;\n });\n\n return parsed;\n};\n\nexport const getBlockFromArray = (entry: any, blockKey: string, locale = \"en\") => {\n if (!entry) {\n return [];\n }\n\n const values = getBlockValues(entry, blockKey); // top‑level list\n\n return values.reduce((acc: any, current: any) => {\n acc[current.key] = unwrapBlock(current, locale);\n return acc;\n });\n};\n\nexport const getImageUrl = (imageBlock: any, isBlock = true) => {\n if (!imageBlock) return null;\n\n const config = getGlobalConfig();\n const storageUrl = config.storageUrl || \"https://storage.arky.io/dev\";\n\n // Helper to check if URL is external\n const isExternalUrl = (url: string) => {\n return url.startsWith('http://') || url.startsWith('https://');\n };\n\n // Handle relationship blocks with media\n if (imageBlock.type === 'RELATIONSHIP' && Array.isArray(imageBlock.value)) {\n const mediaValue = imageBlock.value[0];\n if (mediaValue && mediaValue.mimeType) {\n // Handle media with resolutions structure\n if (mediaValue.resolutions && mediaValue.resolutions.original && mediaValue.resolutions.original.url) {\n const url = mediaValue.resolutions.original.url;\n return isExternalUrl(url) ? url : `${storageUrl}/${url}`;\n }\n \n // Handle direct URL on media\n if (mediaValue.url) {\n return isExternalUrl(mediaValue.url) ? mediaValue.url : `${storageUrl}/${mediaValue.url}`;\n }\n }\n return null;\n }\n\n if (isBlock) {\n if (typeof imageBlock === \"string\") {\n // Check if it's already a full URL\n if (isExternalUrl(imageBlock)) {\n return imageBlock;\n }\n return `${storageUrl}/${imageBlock}`;\n }\n\n if (imageBlock.url) {\n // Check if it's already a full URL\n if (isExternalUrl(imageBlock.url)) {\n return imageBlock.url;\n }\n return `${storageUrl}/${imageBlock.url}`;\n }\n }\n\n if (\n imageBlock.resolutions &&\n imageBlock.resolutions.original &&\n imageBlock.resolutions.original.url\n ) {\n const url = imageBlock.resolutions.original.url;\n // Check if it's already a full URL\n if (isExternalUrl(url)) {\n return url;\n }\n return `${storageUrl}/${url}`;\n }\n\n return null;\n};\n\nexport function getGalleryThumbnail(gallery: any) {\n if (!gallery?.length) return null;\n const item = gallery.find((g: any) => g.settings.isThumbnail) || gallery[0];\n const res = item.media.resolutions.thumbnail || item.media.resolutions.original;\n return res?.url || null;\n}\n\n// full URL or null\nexport function thumbnailUrl(service: any) {\n const config = getGlobalConfig();\n const storageUrl = config.storageUrl || \"\";\n const path = getGalleryThumbnail(service.gallery);\n return path ? `${storageUrl}/${path}` : null;\n}\n\nexport const translateMap = (labels: any, lang: string, fallback = \"unknown\") => {\n let parsedLang = \"en\";\n\n if (lang === \"sr\") {\n parsedLang = \"bih\";\n }\n\n if (!labels) {\n return fallback;\n }\n\n const label = labels[parsedLang];\n if (!label) {\n return fallback;\n }\n\n return label;\n};","// Error handling utilities (combined from errorCodes.ts and errorHelpers.ts)\n\n// Comprehensive error code system with both numeric codes and named constants\nexport const ERROR_CODES = {\n // General errors\n \"GENERAL.001\": \"GENERAL.BAD_REQUEST\",\n \"GENERAL.002\": \"GENERAL.VALIDATION_ERROR\",\n \"GENERAL.003\": \"GENERAL.FORBIDDEN_ERROR\",\n \"GENERAL.004\": \"GENERAL.INTERNAL_SERVER_ERROR\",\n \"GENERAL.005\": \"GENERAL.UNAUTHORIZED\",\n \"GENERAL.006\": \"GENERAL.UNAUTHENTICATED\",\n\n // Google/OAuth errors\n \"GOOGLE.001\": \"GOOGLE.INVALID_ORIGIN_URI\",\n \"GOOGLE.002\": \"GOOGLE.INVALID_REDIRECT_URI\",\n \"GOOGLE.003\": \"GOOGLE.FAILED_TO_CALL_API\",\n \"GOOGLE.004\": \"GOOGLE.FAILED_LOGIN\",\n \"GOOGLE.005\": \"GOOGLE.FAILED_LOGOUT\",\n \"GOOGLE.006\": \"GOOGLE.FAILED_REFRESH_TOKEN\",\n \"GOOGLE.007\": \"GOOGLE.INVALID_PROVIDER_PASSED\",\n\n // User errors\n \"USER.001\": \"USER.NOT_FOUND\",\n \"USER.002\": \"USER.FAILED_TO_CREATE\",\n \"USER.003\": \"USER.FAILED_TO_UPDATE\",\n \"USER.004\": \"USER.FAILED_TO_DELETE\",\n \"USER.005\": \"USER.EMAIL_EXISTS\",\n \"USER.006\": \"USER.FAILED_TO_GET_UPLOAD_URL\",\n\n // Business errors\n \"BUSINESS.001\": \"BUSINESS.NOT_FOUND\",\n \"BUSINESS.002\": \"BUSINESS.FAILED_TO_CREATE\",\n \"BUSINESS.003\": \"BUSINESS.FAILED_TO_UPDATE\",\n \"BUSINESS.004\": \"BUSINESS.FAILED_TO_DELETE\",\n \"BUSINESS.005\": \"BUSINESS.FAILED_TO_GET_UPLOAD_URL\",\n \"BUSINESS.006\": \"BUSINESS.NAME_REQUIRED\",\n \"BUSINESS.007\": \"BUSINESS.BUSINESS_ID_REQUIRED\",\n \"BUSINESS.010\": \"BUSINESS.DESCRIPTION_REQUIRED\",\n \"BUSINESS.011\": \"BUSINESS.SLUG_INVALID\",\n\n // Provider errors \n \"PROVIDER.001\": \"PROVIDER.NOT_FOUND\",\n \"PROVIDER.002\": \"PROVIDER.FAILED_TO_CREATE\",\n \"PROVIDER.003\": \"PROVIDER.FAILED_TO_UPDATE\",\n \"PROVIDER.004\": \"PROVIDER.FAILED_TO_DELETE\",\n \"PROVIDER.005\": \"PROVIDER.FAILED_TO_GET_UPLOAD_URL\",\n \"PROVIDER.006\": \"PROVIDER.NAME_REQUIRED\",\n \"PROVIDER.007\": \"PROVIDER.BUSINESS_ID_REQUIRED\",\n \"PROVIDER.008\": \"PROVIDER.DESCRIPTION_REQUIRED\",\n};\n\n// Named error constants for direct access\nexport const ERROR_CONSTANTS = {\n GENERAL: {\n BAD_REQUEST: \"GENERAL.BAD_REQUEST\",\n VALIDATION_ERROR: \"GENERAL.VALIDATION_ERROR\",\n FORBIDDEN_ERROR: \"GENERAL.FORBIDDEN_ERROR\",\n INTERNAL_SERVER_ERROR: \"GENERAL.INTERNAL_SERVER_ERROR\",\n UNAUTHORIZED: \"GENERAL.UNAUTHORIZED\",\n UNAUTHENTICATED: \"GENERAL.UNAUTHENTICATED\",\n },\n USER: {\n NOT_FOUND: \"USER.NOT_FOUND\",\n FAILED_TO_CREATE: \"USER.FAILED_TO_CREATE\",\n FAILED_TO_UPDATE: \"USER.FAILED_TO_UPDATE\",\n FAILED_TO_DELETE: \"USER.FAILED_TO_DELETE\",\n EMAIL_EXISTS: \"USER.EMAIL_EXISTS\",\n FAILED_TO_GET_UPLOAD_URL: \"USER.FAILED_TO_GET_UPLOAD_URL\",\n },\n BUSINESS: {\n NOT_FOUND: \"BUSINESS.NOT_FOUND\",\n FAILED_TO_CREATE: \"BUSINESS.FAILED_TO_CREATE\",\n FAILED_TO_UPDATE: \"BUSINESS.FAILED_TO_UPDATE\",\n FAILED_TO_DELETE: \"BUSINESS.FAILED_TO_DELETE\",\n FAILED_TO_GET_UPLOAD_URL: \"BUSINESS.FAILED_TO_GET_UPLOAD_URL\",\n NAME_REQUIRED: \"BUSINESS.NAME_REQUIRED\",\n BUSINESS_ID_REQUIRED: \"BUSINESS.BUSINESS_ID_REQUIRED\",\n DESCRIPTION_REQUIRED: \"BUSINESS.DESCRIPTION_REQUIRED\",\n SLUG_INVALID: \"BUSINESS.SLUG_INVALID\",\n },\n};\n\nexport type ServerError = {\n error: string;\n reason: string;\n code: string;\n statusCode: number;\n validationErrors: {\n field: string;\n code: string;\n }[];\n};\n\nexport type ValidationError = {\n field: string;\n message: string;\n};\n\nexport type RequestError = {\n validationErrors: ValidationError[];\n};\n\n// Utility functions for error handling\nexport function getErrorMessage(code: string): string {\n return ERROR_CODES[code as keyof typeof ERROR_CODES] || code;\n}\n\nexport function isErrorCode(code: string): boolean {\n return code in ERROR_CODES;\n}\n\n// Note: transformErrors requires zod which is not a dependency\n// If you need zod validation, add it to package.json dependencies\nexport const transformErrors = (zodError: any): ValidationError[] => {\n const customErrors: ValidationError[] = [];\n\n if (!zodError.issues) return customErrors;\n\n zodError.issues.forEach((issue: any) => {\n const field = issue.path.join(\".\");\n const message = issue.message;\n\n if (\n !customErrors.some(\n (customError) => customError.field === field && customError.message === message,\n )\n ) {\n customErrors.push({ field, message });\n }\n });\n\n return customErrors;\n};\n\nexport const convertServerErrorToRequestError = (\n serverError: ServerError,\n renameRules?: { [key: string]: string },\n): RequestError => {\n return {\n ...serverError,\n validationErrors: serverError.validationErrors.map((validationError) => {\n const field =\n renameRules && renameRules[validationError.field]\n ? renameRules[validationError.field]\n : validationError.field;\n\n return {\n field: field,\n message: ERROR_CODES[validationError.code as keyof typeof ERROR_CODES] || \"Unknown error\",\n };\n }),\n };\n};\n\n// Export for backward compatibility\nexport const errors = ERROR_CONSTANTS;\nexport default ERROR_CODES;","/**\n * Maps currency codes to their display symbols\n */\nexport function getCurrencySymbol(currency: string): string {\n const currencySymbols: Record<string, string> = {\n USD: '$',\n EUR: '€',\n GBP: '£',\n CAD: 'C$',\n AUD: 'A$',\n JPY: '¥',\n CHF: 'CHF',\n SEK: 'kr',\n NOK: 'kr',\n DKK: 'kr',\n PLN: 'zł',\n CZK: 'Kč',\n HUF: 'Ft',\n RON: 'lei',\n BGN: 'лв',\n HRK: 'kn',\n RSD: 'дин',\n BAM: 'KM',\n MKD: 'ден',\n ALL: 'L',\n TRY: '₺',\n RUB: '₽',\n UAH: '₴',\n BYN: 'Br',\n CNY: '¥',\n INR: '₹',\n KRW: '₩',\n THB: '฿',\n VND: '₫',\n SGD: 'S$',\n MYR: 'RM',\n IDR: 'Rp',\n PHP: '₱',\n BRL: 'R$',\n ARS: '$',\n CLP: '$',\n COP: '$',\n PEN: 'S/',\n MXN: '$',\n ZAR: 'R',\n EGP: 'E£',\n NGN: '₦',\n KES: 'KSh',\n GHS: '₵',\n MAD: 'DH',\n TND: 'د.ت',\n DZD: 'د.ج',\n LYD: 'ل.د',\n AED: 'د.إ',\n SAR: 'ر.س',\n QAR: 'ر.ق',\n KWD: 'د.ك',\n BHD: 'ب.د',\n OMR: 'ر.ع',\n JOD: 'د.أ',\n LBP: 'ل.ل',\n SYP: 'ل.س',\n IQD: 'ع.د',\n IRR: '﷼',\n AFN: '؋',\n PKR: '₨',\n LKR: '₨',\n NPR: '₨',\n BDT: '৳',\n MMK: 'K',\n LAK: '₭',\n KHR: '៛',\n MNT: '₮',\n KZT: '₸',\n UZS: 'лв',\n KGS: 'лв',\n TJS: 'SM',\n TMT: 'T',\n AZN: '₼',\n GEL: '₾',\n AMD: '֏',\n BYR: 'p.',\n MDL: 'L'\n };\n\n return currencySymbols[currency.toUpperCase()] || currency;\n}\n\n/**\n * Formats a price with the appropriate currency symbol\n */\nexport function formatCurrencyAmount(amount: number, currency: string): string {\n const symbol = getCurrencySymbol(currency);\n const formattedAmount = (amount / 100).toFixed(2);\n\n // For some currencies, symbol goes after the amount\n const symbolAfterCurrencies = ['SEK', 'NOK', 'DKK', 'PLN', 'CZK', 'HUF', 'RON', 'BGN', 'HRK'];\n\n if (symbolAfterCurrencies.includes(currency.toUpperCase())) {\n return `${formattedAmount} ${symbol}`;\n }\n\n return `${symbol}${formattedAmount}`;\n}","// Price formatting utilities - Centralized currency and price operations\nimport type { Payment, PaymentMethod, Price } from '../types';\nimport { getCurrencySymbol } from './currency';\n\n// Market-based currency symbols mapping\nconst CURRENCY_SYMBOLS = {\n 'USD': '$',\n 'EUR': '€',\n 'GBP': '£',\n 'CAD': 'C$',\n 'AUD': 'A$'\n} as const;\n\nconst MARKET_CURRENCIES = {\n 'US': 'USD',\n 'EU': 'EUR',\n 'UK': 'GBP',\n 'CA': 'CAD',\n 'AU': 'AUD'\n} as const;\n\n// Convert minor units (cents) to major units (dollars)\nexport function convertToMajor(minorAmount: number): number {\n return (minorAmount ?? 0) / 100;\n}\n\n// Convert major units to minor units\nexport function convertToMinor(majorAmount: number): number {\n return Math.round((majorAmount ?? 0) * 100);\n}\n\n// Get currency symbol from currency code\nexport function getSymbol(currency: string): string {\n return CURRENCY_SYMBOLS[currency as keyof typeof CURRENCY_SYMBOLS] || '$';\n}\n\n// Get currency from market ID\nexport function getCurrencyFromMarket(marketId: string): string {\n return MARKET_CURRENCIES[marketId as keyof typeof MARKET_CURRENCIES] || 'USD';\n}\n\n// Format currency amount with symbol\nexport function formatCurrencyAmount(\n amount: number,\n currency: string,\n options: {\n showSymbols?: boolean;\n decimalPlaces?: number;\n customSymbol?: string;\n } = {}\n): string {\n const { showSymbols = true, decimalPlaces = 2, customSymbol } = options;\n const roundedAmount = amount.toFixed(decimalPlaces);\n\n if (!showSymbols) {\n return `${roundedAmount} ${currency}`;\n }\n\n const symbol = customSymbol || getSymbol(currency);\n return `${symbol}${roundedAmount}`;\n}\n\n// Format minor units with currency\nexport function formatMinor(\n amountMinor: number,\n currency: string,\n options: {\n showSymbols?: boolean;\n decimalPlaces?: number;\n customSymbol?: string;\n } = {}\n): string {\n const major = convertToMajor(amountMinor);\n return formatCurrencyAmount(major, currency, options);\n}\n\n// Format Payment structure for display\nexport function formatPayment(\n payment: Payment,\n options: {\n showSymbols?: boolean;\n decimalPlaces?: number;\n showBreakdown?: boolean;\n } = {}\n): string {\n if (!payment) return '';\n\n const { showSymbols = true, decimalPlaces = 2, showBreakdown = false } = options;\n\n if (showBreakdown) {\n const subtotal = formatMinor(payment.subtotal, payment.currency, { showSymbols, decimalPlaces });\n const discount = (payment.discount ?? 0) > 0 ? formatMinor(payment.discount, payment.currency, { showSymbols, decimalPlaces }) : null;\n const tax = (payment.tax ?? 0) > 0 ? formatMinor(payment.tax, payment.currency, { showSymbols, decimalPlaces }) : null;\n const total = formatMinor(payment.total, payment.currency, { showSymbols, decimalPlaces });\n\n let result = `Subtotal: ${subtotal}`;\n if (discount) result += `, Discount: -${discount}`;\n if (tax) result += `, Tax: ${tax}`;\n result += `, Total: ${total}`;\n return result;\n }\n\n return formatMinor(payment.total, payment.currency, { showSymbols, decimalPlaces });\n}\n\n// Format market-based prices (from product variants)\nexport function getMarketPrice(\n prices: Price[],\n marketId: string,\n businessMarkets?: any[],\n options: {\n showSymbols?: boolean;\n decimalPlaces?: number;\n showCompareAt?: boolean;\n fallbackMarket?: string;\n } = {}\n): string {\n if (!prices || prices.length === 0) return '';\n\n const {\n showSymbols = true,\n decimalPlaces = 2,\n showCompareAt = true,\n fallbackMarket = 'US',\n } = options;\n\n // Find price for the specific market\n let price = prices.find(p => p.market === marketId);\n\n // Fallback to first available or fallback market\n if (!price) {\n price = prices.find(p => p.market === fallbackMarket) || prices[0];\n }\n\n if (!price) return '';\n\n let currency: string;\n let symbol: string;\n\n // If we have business markets, use the currency directly from market data\n if (businessMarkets) {\n const marketData = businessMarkets.find(m => m.id === price.market || m.code === price.market);\n if (marketData?.currency) {\n currency = marketData.currency;\n symbol = getCurrencySymbol(currency);\n } else {\n currency = getCurrencyFromMarket(price.market);\n symbol = getSymbol(currency);\n }\n } else {\n currency = getCurrencyFromMarket(price.market);\n symbol = getSymbol(currency);\n }\n\n // Format price with custom symbol\n const formattedPrice = formatMinor(price.amount ?? 0, currency, {\n showSymbols,\n decimalPlaces,\n customSymbol: symbol\n });\n\n // Add compare-at price if available\n if (showCompareAt && price.compareAt && price.compareAt > (price.amount ?? 0)) {\n const formattedCompareAt = formatMinor(price.compareAt, currency, {\n showSymbols,\n decimalPlaces,\n customSymbol: symbol\n });\n return `${formattedPrice} was ${formattedCompareAt}`;\n }\n\n return formattedPrice;\n}\n\n// Get price amount from market-based prices (for calculations)\nexport function getPriceAmount(prices: Price[], marketId: string, fallbackMarket: string = 'US'): number {\n if (!prices || prices.length === 0) return 0;\n\n const price = prices.find(p => p.market === marketId) ||\n prices.find(p => p.market === fallbackMarket) ||\n prices[0];\n\n // Amounts are stored in minor units (e.g., cents)\n return price?.amount || 0;\n}\n\n// Create Payment structure for checkout (all amounts in minor units)\nexport function createPaymentForCheckout(\n subtotalMinor: number,\n marketId: string,\n currency: string,\n paymentMethod: any,\n options: {\n discount?: number;\n tax?: number;\n promoCodeId?: string;\n } = {}\n): Payment {\n const { discount = 0, tax = 0, promoCodeId } = options;\n const total = subtotalMinor - discount + tax;\n\n return {\n currency,\n market: marketId,\n subtotal: subtotalMinor,\n shipping: 0,\n discount,\n tax,\n total,\n promoCodeId,\n method: paymentMethod,\n };\n}\n","import { getImageUrl } from \"./blocks\";\n\nexport async function fetchSvgContent(mediaObject: any): Promise<string | null> {\n\tif (!mediaObject) return null;\n\n\tconst svgUrl = getImageUrl(mediaObject, false);\n\n\ttry {\n\t\tconst response = await fetch(svgUrl);\n\n\t\tif (!response.ok) {\n\t\t\tconsole.error(`Failed to fetch SVG: ${response.status} ${response.statusText}`);\n\t\t\treturn null;\n\t\t}\n\n\t\tconst svgContent = await response.text();\n\t\treturn svgContent;\n\t} catch (error) {\n\t\tconsole.error(\"Error fetching SVG:\", error);\n\t\treturn null;\n\t}\n}\n\n/**\n * Server-side helper for Astro components to fetch SVG content during SSR\n *\n * @param mediaObject The media object from the CMS\n * @returns The SVG content as a string, or empty string on failure\n */\nexport async function getSvgContentForAstro(mediaObject: any): Promise<string> {\n\ttry {\n\t\tconst svgContent = await fetchSvgContent(mediaObject);\n\t\treturn svgContent || \"\";\n\t} catch (error) {\n\t\tconsole.error(\"Error getting SVG content for Astro:\", error);\n\t\treturn \"\";\n\t}\n}\n\n/**\n * Client-side helper to fetch and inject SVG content into DOM elements\n *\n * @param mediaObject The media object from the CMS\n * @param targetElement The DOM element to inject the SVG into\n * @param className Optional CSS class to add to the SVG\n */\nexport async function injectSvgIntoElement(\n\tmediaObject: any,\n\ttargetElement: HTMLElement,\n\tclassName?: string,\n): Promise<void> {\n\tif (!targetElement) return;\n\n\ttry {\n\t\tconst svgContent = await fetchSvgContent(mediaObject);\n\n\t\tif (svgContent) {\n\t\t\ttargetElement.innerHTML = svgContent;\n\n\t\t\t// Add class if provided\n\t\t\tif (className) {\n\t\t\t\tconst svgElement = targetElement.querySelector(\"svg\");\n\t\t\t\tif (svgElement) {\n\t\t\t\t\tsvgElement.classList.add(...className.split(\" \"));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tconsole.error(\"Error injecting SVG:\", error);\n\t}\n}","// Define locales inline since we don't have @lib/i18n in SDK\nconst locales = ['en', 'sr-latn'] as const;\nconst localeMap: Record<typeof locales[number], string> = {\n\t'en': 'en-US',\n\t'sr-latn': 'sr-RS'\n};\n\n/**\n * * returns \"slugified\" text.\n * @param text: string - text to slugify\n */\nexport function slugify(text: string): string {\n\treturn text\n\t\t.toString()\n\t\t.toLowerCase() // convert to lowercase\n\t\t.replace(/\\s+/g, \"-\") // replace spaces with -\n\t\t.replace(/[^\\w-]+/g, \"\") // remove all non-word chars\n\t\t.replace(/--+/g, \"-\") // replace multiple dashes with single dash\n\t\t.replace(/^-+/, \"\") // trim dash from start of text\n\t\t.replace(/-+$/, \"\"); // trim dash from end of text\n}\n\n/**\n * * returns \"humanized\" text. runs slugify() and then replaces - with space and upper case first letter of every word, and lower case the rest\n * @param text: string - text to humanize\n */\nexport function humanize(text: string): string {\n\tconst slugifiedText = slugify(text);\n\treturn (\n\t\tslugifiedText\n\t\t\t.replace(/-/g, \" \") // replace \"-\" with space\n\t\t\t// .toLowerCase();\n\t\t\t.replace(\n\t\t\t\t// upper case first letter of every word, and lower case the rest\n\t\t\t\t/\\w\\S*/g,\n\t\t\t\t(w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase(),\n\t\t\t)\n\t);\n}\n\n// --------------------------------------------------------\n/**\n * * returns \"categorified\" text. runs slugify() and then replaces - with space and upper cases everything\n * @param text: string - text to categorify\n * @returns string - categorified text\n */\nexport function categorify(text: string): string {\n\tconst slugifiedText = slugify(text);\n\treturn slugifiedText\n\t\t.replace(/-/g, \" \") // replace \"-\" with space\n\t\t.toUpperCase();\n}\n\n// --------------------------------------------------------\n/**\n * * returns a nicely formatted string of the date passed\n * @param date: string | number | Date - date to format\n * @param locale: string - locale to format the date in\n * @returns string - formatted date\n */\nexport function formatDate(date: string | number | Date, locale: (typeof locales)[number]): string {\n\tlet localeString = \"en-US\";\n\n\tif (locales.includes(locale)) {\n\t\tlocaleString = localeMap[locale];\n\t}\n\n\treturn new Date(date).toLocaleDateString(localeString, {\n\t\ttimeZone: \"UTC\",\n\t\tyear: \"numeric\",\n\t\tmonth: \"short\",\n\t\tday: \"numeric\",\n\t});\n}","// Timezone utilities (moved from Reservation folder)\n\nexport const tzGroups = [\n {\n label: \"US\",\n zones: [\n { label: \"Eastern Time\", value: \"America/New_York\" },\n { label: \"Central Time\", value: \"America/Chicago\" },\n { label: \"Mountain Time\", value: \"America/Denver\" },\n { label: \"Pacific Time\", value: \"America/Los_Angeles\" },\n ],\n },\n {\n label: \"Europe\",\n zones: [\n { label: \"London\", value: \"Europe/London\" },\n { label: \"Paris\", value: \"Europe/Paris\" },\n { label: \"Berlin\", value: \"Europe/Berlin\" },\n { label: \"Rome\", value: \"Europe/Rome\" },\n ],\n },\n {\n label: \"Asia\",\n zones: [\n { label: \"Tokyo\", value: \"Asia/Tokyo\" },\n { label: \"Shanghai\", value: \"Asia/Shanghai\" },\n { label: \"Mumbai\", value: \"Asia/Kolkata\" },\n { label: \"Dubai\", value: \"Asia/Dubai\" },\n ],\n },\n];\n\nexport function findTimeZone(groups: typeof tzGroups): string {\n try {\n const detected = Intl.DateTimeFormat().resolvedOptions().timeZone;\n \n // Check if detected timezone is in our list\n for (const group of groups) {\n for (const zone of group.zones) {\n if (zone.value === detected) {\n return detected;\n }\n }\n }\n \n // Fallback to UTC if not found\n return \"UTC\";\n } catch (e) {\n // Fallback to UTC if detection fails\n return \"UTC\";\n }\n}","// Validation utilities\n\nexport interface ValidationResult {\n isValid: boolean;\n error?: string;\n}\n\n// Phone number validation\nexport function validatePhoneNumber(phone: string): ValidationResult {\n if (!phone) {\n return { isValid: false, error: 'Phone number is required' };\n }\n \n const cleaned = phone.replace(/\\D/g, '');\n \n if (cleaned.length < 8) {\n return { isValid: false, error: 'Phone number is too short' };\n }\n \n if (cleaned.length > 15) {\n return { isValid: false, error: 'Phone number is too long' };\n }\n \n return { isValid: true };\n}\n\n// Email validation\nexport function validateEmail(email: string): ValidationResult {\n if (!email) {\n return { isValid: false, error: 'Email is required' };\n }\n \n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n \n if (!emailRegex.test(email)) {\n return { isValid: false, error: 'Please enter a valid email address' };\n }\n \n return { isValid: true };\n}\n\n// Verification code validation (4-digit codes)\nexport function validateVerificationCode(code: string): ValidationResult {\n if (!code) {\n return { isValid: false, error: 'Verification code is required' };\n }\n \n const cleaned = code.replace(/\\D/g, '');\n \n if (cleaned.length !== 4) {\n return { isValid: false, error: 'Please enter a 4-digit verification code' };\n }\n \n return { isValid: true };\n}\n\n// Generic required field validation\nexport function validateRequired(value: any, fieldName: string = 'This field'): ValidationResult {\n if (value === null || value === undefined || value === '') {\n return { isValid: false, error: `${fieldName} is required` };\n }\n \n return { isValid: true };\n}"]}
1
+ {"version":3,"sources":["../src/utils/blocks.ts","../src/utils/errors.ts","../src/utils/currency.ts","../src/utils/price.ts","../src/utils/svg.ts","../src/utils/text.ts","../src/utils/timezone.ts","../src/utils/validation.ts"],"names":[],"mappings":";;;AAsBO,SAAS,aAAA,CAAc,KAAA,EAAY,MAAA,GAAiB,IAAA,EAAc;AACrE,EAAA,IAAI,CAAC,OAAO,OAAO,EAAA;AAEnB,EAAA,IAAI,KAAA,CAAM,YAAY,KAAA,EAAO;AACzB,IAAA,IAAI,OAAO,KAAA,CAAM,UAAA,CAAW,KAAA,KAAU,QAAA,EAAU;AAC5C,MAAA,OACI,MAAM,UAAA,CAAW,KAAA,CAAM,MAAM,CAAA,IAC7B,MAAM,UAAA,CAAW,KAAA,CAAM,EAAA,IACvB,MAAA,CAAO,OAAO,KAAA,CAAM,UAAA,CAAW,KAAK,CAAA,CAAE,CAAC,CAAA,IACvC,EAAA;AAAA,IAER;AACA,IAAA,IAAI,OAAO,KAAA,CAAM,UAAA,CAAW,KAAA,KAAU,QAAA,EAAU;AAC5C,MAAA,OAAO,MAAM,UAAA,CAAW,KAAA;AAAA,IAC5B;AAAA,EACJ;AAGA,EAAA,OAAO,KAAA,CAAM,GAAA,EAAK,OAAA,CAAQ,IAAA,EAAM,GAAG,CAAA,CAAE,OAAA,CAAQ,OAAA,EAAS,CAAC,CAAA,KAAc,CAAA,CAAE,WAAA,EAAa,CAAA,IAAK,EAAA;AAC7F;AAGO,SAAS,iBAAiB,KAAA,EAAoB;AACjD,EAAA,IAAI,CAAC,KAAA,IAAS,KAAA,CAAM,UAAU,IAAA,IAAQ,KAAA,CAAM,UAAU,MAAA,EAAW;AAC7D,IAAA,OAAO,EAAA;AAAA,EACX;AAEA,EAAA,QAAQ,MAAM,IAAA;AAAM,IAChB,KAAK,SAAA;AACD,MAAA,OAAO,KAAA,CAAM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,CAAC,UAAA,CAAW,IAAA,CAAK,KAAK,CAAA,EAAG;AACzB,IAAA,OAAO,EAAE,OAAA,EAAS,KAAA,EAAO,KAAA,EAAO,oCAAA,EAAqC;AAAA,EACzE;AAEA,EAAA,OAAO,EAAE,SAAS,IAAA,EAAK;AAC3B;AAGO,SAAS,yBAAyB,IAAA,EAAgC;AACrE,EAAA,IAAI,CAAC,IAAA,EAAM;AACP,IAAA,OAAO,EAAE,OAAA,EAAS,KAAA,EAAO,KAAA,EAAO,+BAAA,EAAgC;AAAA,EACpE;AAEA,EAAA,MAAM,OAAA,GAAU,IAAA,CAAK,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AAEtC,EAAA,IAAI,OAAA,CAAQ,WAAW,CAAA,EAAG;AACtB,IAAA,OAAO,EAAE,OAAA,EAAS,KAAA,EAAO,KAAA,EAAO,0CAAA,EAA2C;AAAA,EAC/E;AAEA,EAAA,OAAO,EAAE,SAAS,IAAA,EAAK;AAC3B;AAGO,SAAS,gBAAA,CAAiB,KAAA,EAAY,SAAA,GAAoB,YAAA,EAAgC;AAC7F,EAAA,IAAI,KAAA,KAAU,IAAA,IAAQ,KAAA,KAAU,MAAA,IAAa,UAAU,EAAA,EAAI;AACvD,IAAA,OAAO,EAAE,OAAA,EAAS,KAAA,EAAO,KAAA,EAAO,CAAA,EAAG,SAAS,CAAA,YAAA,CAAA,EAAe;AAAA,EAC/D;AAEA,EAAA,OAAO,EAAE,SAAS,IAAA,EAAK;AAC3B","file":"utils.cjs","sourcesContent":["// Block utilities (extracted from index.ts)\n\nexport interface Block {\n id: string;\n key: string;\n type: string;\n properties: any;\n value: any;\n}\n\nexport interface Collection {\n id: string;\n blocks: Block[];\n}\n\nexport interface CollectionEntry {\n id: string;\n collection_id: string;\n blocks: Block[];\n}\n\n\nexport function getBlockLabel(block: any, locale: string = 'en'): string {\n if (!block) return \"\";\n\n if (block.properties?.label) {\n if (typeof block.properties.label === \"object\") {\n return (\n block.properties.label[locale] ||\n block.properties.label.en ||\n Object.values(block.properties.label)[0] ||\n \"\"\n );\n }\n if (typeof block.properties.label === \"string\") {\n return block.properties.label;\n }\n }\n \n // Convert key to readable format\n return block.key?.replace(/_/g, ' ').replace(/\\b\\w/g, (l: string) => l.toUpperCase()) || \"\";\n}\n\n\nexport function formatBlockValue(block: any): string {\n if (!block || block.value === null || block.value === undefined) {\n return \"\";\n }\n\n switch (block.type) {\n case \"BOOLEAN\":\n return block.value ? \"Yes\" : \"No\";\n case \"NUMBER\":\n // Handle date/datetime variants\n if (block.properties?.variant === \"DATE\" || block.properties?.variant === \"DATE_TIME\") {\n try {\n return new Date(block.value).toLocaleDateString();\n } catch (e) {\n return String(block.value);\n }\n }\n return String(block.value);\n case \"RELATIONSHIP\":\n if (Array.isArray(block.value) && block.value.length > 0) {\n const firstValue = block.value[0];\n if (firstValue && firstValue.mimeType) {\n return firstValue.name || firstValue.id || \"Media\";\n }\n return firstValue.title || firstValue.name || firstValue.id || \"Entry\";\n }\n return String(block.value);\n default:\n return String(block.value);\n }\n}\n\nexport function prepareBlocksForSubmission(formData: any): any[] {\n const preparedBlocks = [];\n\n Object.keys(formData).forEach((key) => {\n if (formData[key] !== null && formData[key] !== undefined) {\n preparedBlocks.push({\n key,\n value: [formData[key]],\n });\n }\n });\n\n return preparedBlocks;\n}\n\nexport function extractBlockValues(blocks: any[]): Record<string, any> {\n const values: Record<string, any> = {};\n\n blocks.forEach((block) => {\n if (block.value && block.value.length > 0) {\n values[block.key] = block.value[0];\n } else {\n values[block.key] = null;\n }\n });\n\n return values;\n}\n\n// Extract localized text value from a block, handling multilingual content\nexport function getBlockTextValue(block: any, locale: string = 'en'): string {\n if (!block || !block.value || block.value.length === 0) return '';\n \n const firstValue = block.value[0];\n \n // Handle multilingual object\n if (typeof firstValue === 'object' && firstValue !== null) {\n // Try specified locale first, then 'en', then first available language\n if (firstValue[locale]) return firstValue[locale];\n if (firstValue.en) return firstValue.en;\n const values = Object.values(firstValue);\n return String(values[0] || '');\n }\n \n // Handle simple string\n return String(firstValue);\n}\n\n// Legacy functions for backward compatibility\nexport const getBlockValue = (entry: any, blockKey: string) => {\n if (!entry || !entry.blocks) return null;\n\n const block = entry.blocks.find((f: any) => f.key === blockKey);\n\n if (!block || !block.value || block.value.length === 0) return null;\n\n return block.value[0];\n};\n\nexport const getBlockValues = (entry: any, blockKey: string) => {\n if (!entry || !entry.blocks) return null;\n\n const block = entry.blocks.find((f: any) => f.key === blockKey);\n\n if (!block || !block.value || block.value.length === 0) return null;\n\n return block.value;\n};\n\nfunction unwrapBlock(block: any, locale: string) {\n if (!block?.type || block.value === undefined) return block;\n\n // Nested objects / lists → recurse for every child\n if (block.type === \"BLOCK\") {\n return block.value.map((obj: Record<string, any>) => {\n const parsed: Record<string, any> = {};\n for (const [k, v] of Object.entries(obj)) {\n parsed[k] = unwrapBlock(v, locale);\n }\n return parsed;\n });\n }\n\n // Primitive leaves (text/number/boolean/media …)\n const isLocalized = block.type === \"TEXT\";\n const isList =\n block.properties?.ui === \"list\" ||\n (block.properties?.maxValues ?? 1) > 1 ||\n block.value.length > 1;\n\n if (isList) {\n return isLocalized\n ? block.value.map((v: Record<string, any>) => v[locale] || v[\"en\"])\n : [...block.value];\n }\n\n return isLocalized ? block.value[0][locale] || block.value[0][\"en\"] : block.value[0];\n}\n\nexport const getBlockObjectValues = (entry: any, blockKey: string, locale = \"en\") => {\n if (!entry) {\n return [];\n }\n\n const values = getBlockValues(entry, blockKey); // top‑level list\n\n const parsed = values.map((obj: Record<string, any>) => {\n const res = obj.value.reduce((acc: any, current: any) => {\n acc[current.key] = unwrapBlock(current, locale);\n\n return acc;\n }, {});\n\n return res;\n });\n\n return parsed;\n};\n\nexport const getBlockFromArray = (entry: any, blockKey: string, locale = \"en\") => {\n if (!entry) {\n return [];\n }\n\n const values = getBlockValues(entry, blockKey); // top‑level list\n\n return values.reduce((acc: any, current: any) => {\n acc[current.key] = unwrapBlock(current, locale);\n return acc;\n });\n};\n\nexport const getImageUrl = (imageBlock: any, isBlock = true, storageUrl: string = \"https://storage.arky.io/dev\") => {\n if (!imageBlock) return null;\n\n // Helper to check if URL is external\n const isExternalUrl = (url: string) => {\n return url.startsWith('http://') || url.startsWith('https://');\n };\n\n // Handle relationship blocks with media\n if (imageBlock.type === 'RELATIONSHIP' && Array.isArray(imageBlock.value)) {\n const mediaValue = imageBlock.value[0];\n if (mediaValue && mediaValue.mimeType) {\n // Handle media with resolutions structure\n if (mediaValue.resolutions && mediaValue.resolutions.original && mediaValue.resolutions.original.url) {\n const url = mediaValue.resolutions.original.url;\n return isExternalUrl(url) ? url : `${storageUrl}/${url}`;\n }\n \n // Handle direct URL on media\n if (mediaValue.url) {\n return isExternalUrl(mediaValue.url) ? mediaValue.url : `${storageUrl}/${mediaValue.url}`;\n }\n }\n return null;\n }\n\n if (isBlock) {\n if (typeof imageBlock === \"string\") {\n // Check if it's already a full URL\n if (isExternalUrl(imageBlock)) {\n return imageBlock;\n }\n return `${storageUrl}/${imageBlock}`;\n }\n\n if (imageBlock.url) {\n // Check if it's already a full URL\n if (isExternalUrl(imageBlock.url)) {\n return imageBlock.url;\n }\n return `${storageUrl}/${imageBlock.url}`;\n }\n }\n\n if (\n imageBlock.resolutions &&\n imageBlock.resolutions.original &&\n imageBlock.resolutions.original.url\n ) {\n const url = imageBlock.resolutions.original.url;\n // Check if it's already a full URL\n if (isExternalUrl(url)) {\n return url;\n }\n return `${storageUrl}/${url}`;\n }\n\n return null;\n};\n\nexport function getGalleryThumbnail(gallery: any) {\n if (!gallery?.length) return null;\n const item = gallery.find((g: any) => g.settings.isThumbnail) || gallery[0];\n const res = item.media.resolutions.thumbnail || item.media.resolutions.original;\n return res?.url || null;\n}\n\n// full URL or null\nexport function thumbnailUrl(service: any, storageUrl: string = \"\") {\n const path = getGalleryThumbnail(service.gallery);\n return path ? `${storageUrl}/${path}` : null;\n}\n\nexport const translateMap = (labels: any, lang: string, fallback = \"unknown\") => {\n let parsedLang = \"en\";\n\n if (lang === \"sr\") {\n parsedLang = \"bih\";\n }\n\n if (!labels) {\n return fallback;\n }\n\n const label = labels[parsedLang];\n if (!label) {\n return fallback;\n }\n\n return label;\n};","// Error handling utilities (combined from errorCodes.ts and errorHelpers.ts)\n\n// Comprehensive error code system with both numeric codes and named constants\nexport const ERROR_CODES = {\n // General errors\n \"GENERAL.001\": \"GENERAL.BAD_REQUEST\",\n \"GENERAL.002\": \"GENERAL.VALIDATION_ERROR\",\n \"GENERAL.003\": \"GENERAL.FORBIDDEN_ERROR\",\n \"GENERAL.004\": \"GENERAL.INTERNAL_SERVER_ERROR\",\n \"GENERAL.005\": \"GENERAL.UNAUTHORIZED\",\n \"GENERAL.006\": \"GENERAL.UNAUTHENTICATED\",\n\n // Google/OAuth errors\n \"GOOGLE.001\": \"GOOGLE.INVALID_ORIGIN_URI\",\n \"GOOGLE.002\": \"GOOGLE.INVALID_REDIRECT_URI\",\n \"GOOGLE.003\": \"GOOGLE.FAILED_TO_CALL_API\",\n \"GOOGLE.004\": \"GOOGLE.FAILED_LOGIN\",\n \"GOOGLE.005\": \"GOOGLE.FAILED_LOGOUT\",\n \"GOOGLE.006\": \"GOOGLE.FAILED_REFRESH_TOKEN\",\n \"GOOGLE.007\": \"GOOGLE.INVALID_PROVIDER_PASSED\",\n\n // User errors\n \"USER.001\": \"USER.NOT_FOUND\",\n \"USER.002\": \"USER.FAILED_TO_CREATE\",\n \"USER.003\": \"USER.FAILED_TO_UPDATE\",\n \"USER.004\": \"USER.FAILED_TO_DELETE\",\n \"USER.005\": \"USER.EMAIL_EXISTS\",\n \"USER.006\": \"USER.FAILED_TO_GET_UPLOAD_URL\",\n\n // Business errors\n \"BUSINESS.001\": \"BUSINESS.NOT_FOUND\",\n \"BUSINESS.002\": \"BUSINESS.FAILED_TO_CREATE\",\n \"BUSINESS.003\": \"BUSINESS.FAILED_TO_UPDATE\",\n \"BUSINESS.004\": \"BUSINESS.FAILED_TO_DELETE\",\n \"BUSINESS.005\": \"BUSINESS.FAILED_TO_GET_UPLOAD_URL\",\n \"BUSINESS.006\": \"BUSINESS.NAME_REQUIRED\",\n \"BUSINESS.007\": \"BUSINESS.BUSINESS_ID_REQUIRED\",\n \"BUSINESS.010\": \"BUSINESS.DESCRIPTION_REQUIRED\",\n \"BUSINESS.011\": \"BUSINESS.SLUG_INVALID\",\n\n // Provider errors\n \"PROVIDER.001\": \"PROVIDER.NOT_FOUND\",\n \"PROVIDER.002\": \"PROVIDER.FAILED_TO_CREATE\",\n \"PROVIDER.003\": \"PROVIDER.FAILED_TO_UPDATE\",\n \"PROVIDER.004\": \"PROVIDER.FAILED_TO_DELETE\",\n \"PROVIDER.005\": \"PROVIDER.FAILED_TO_GET_UPLOAD_URL\",\n \"PROVIDER.006\": \"PROVIDER.NAME_REQUIRED\",\n \"PROVIDER.007\": \"PROVIDER.BUSINESS_ID_REQUIRED\",\n \"PROVIDER.008\": \"PROVIDER.DESCRIPTION_REQUIRED\",\n};\n\n// Named error constants for direct access\nexport const ERROR_CONSTANTS = {\n GENERAL: {\n BAD_REQUEST: \"GENERAL.BAD_REQUEST\",\n VALIDATION_ERROR: \"GENERAL.VALIDATION_ERROR\",\n FORBIDDEN_ERROR: \"GENERAL.FORBIDDEN_ERROR\",\n INTERNAL_SERVER_ERROR: \"GENERAL.INTERNAL_SERVER_ERROR\",\n UNAUTHORIZED: \"GENERAL.UNAUTHORIZED\",\n UNAUTHENTICATED: \"GENERAL.UNAUTHENTICATED\",\n },\n USER: {\n NOT_FOUND: \"USER.NOT_FOUND\",\n FAILED_TO_CREATE: \"USER.FAILED_TO_CREATE\",\n FAILED_TO_UPDATE: \"USER.FAILED_TO_UPDATE\",\n FAILED_TO_DELETE: \"USER.FAILED_TO_DELETE\",\n EMAIL_EXISTS: \"USER.EMAIL_EXISTS\",\n FAILED_TO_GET_UPLOAD_URL: \"USER.FAILED_TO_GET_UPLOAD_URL\",\n },\n BUSINESS: {\n NOT_FOUND: \"BUSINESS.NOT_FOUND\",\n FAILED_TO_CREATE: \"BUSINESS.FAILED_TO_CREATE\",\n FAILED_TO_UPDATE: \"BUSINESS.FAILED_TO_UPDATE\",\n FAILED_TO_DELETE: \"BUSINESS.FAILED_TO_DELETE\",\n FAILED_TO_GET_UPLOAD_URL: \"BUSINESS.FAILED_TO_GET_UPLOAD_URL\",\n NAME_REQUIRED: \"BUSINESS.NAME_REQUIRED\",\n BUSINESS_ID_REQUIRED: \"BUSINESS.BUSINESS_ID_REQUIRED\",\n DESCRIPTION_REQUIRED: \"BUSINESS.DESCRIPTION_REQUIRED\",\n SLUG_INVALID: \"BUSINESS.SLUG_INVALID\",\n },\n};\n\nexport type ServerError = {\n message: string;\n error: string;\n statusCode: number;\n validationErrors: {\n field: string;\n error: string;\n }[];\n};\n\nexport type ValidationError = {\n field: string;\n error: string;\n};\n\nexport type RequestError = {\n validationErrors: ValidationError[];\n};\n\n// Utility functions for error handling\nexport function getErrorMessage(code: string): string {\n return ERROR_CODES[code as keyof typeof ERROR_CODES] || code;\n}\n\nexport function isErrorCode(code: string): boolean {\n return code in ERROR_CODES;\n}\n\nexport const transformErrors = (zodError: any): ValidationError[] => {\n const customErrors: ValidationError[] = [];\n\n if (!zodError.issues) return customErrors;\n\n zodError.issues.forEach((issue: any) => {\n const field = issue.path.join(\".\");\n const error = issue.message;\n\n if (\n !customErrors.some(\n (customError) =>\n customError.field === field && customError.error === error\n )\n ) {\n customErrors.push({ field, error });\n }\n });\n\n return customErrors;\n};\n\nexport const convertServerErrorToRequestError = (\n serverError: ServerError,\n renameRules?: { [key: string]: string }\n): RequestError => {\n return {\n ...serverError,\n validationErrors: serverError.validationErrors.map((validationError) => {\n const field =\n renameRules && renameRules[validationError.field]\n ? renameRules[validationError.field]\n : validationError.field;\n\n return {\n field: field,\n error: validationError.error || \"GENERAL.VALIDATION_ERROR\",\n };\n }),\n };\n};\n\n// Export for backward compatibility\nexport const errors = ERROR_CONSTANTS;\nexport default ERROR_CODES;\n","/**\n * Maps currency codes to their display symbols\n */\nexport function getCurrencySymbol(currency: string): string {\n const currencySymbols: Record<string, string> = {\n USD: '$',\n EUR: '€',\n GBP: '£',\n CAD: 'C$',\n AUD: 'A$',\n JPY: '¥',\n CHF: 'CHF',\n SEK: 'kr',\n NOK: 'kr',\n DKK: 'kr',\n PLN: 'zł',\n CZK: 'Kč',\n HUF: 'Ft',\n RON: 'lei',\n BGN: 'лв',\n HRK: 'kn',\n RSD: 'дин',\n BAM: 'KM',\n MKD: 'ден',\n ALL: 'L',\n TRY: '₺',\n RUB: '₽',\n UAH: '₴',\n BYN: 'Br',\n CNY: '¥',\n INR: '₹',\n KRW: '₩',\n THB: '฿',\n VND: '₫',\n SGD: 'S$',\n MYR: 'RM',\n IDR: 'Rp',\n PHP: '₱',\n BRL: 'R$',\n ARS: '$',\n CLP: '$',\n COP: '$',\n PEN: 'S/',\n MXN: '$',\n ZAR: 'R',\n EGP: 'E£',\n NGN: '₦',\n KES: 'KSh',\n GHS: '₵',\n MAD: 'DH',\n TND: 'د.ت',\n DZD: 'د.ج',\n LYD: 'ل.د',\n AED: 'د.إ',\n SAR: 'ر.س',\n QAR: 'ر.ق',\n KWD: 'د.ك',\n BHD: 'ب.د',\n OMR: 'ر.ع',\n JOD: 'د.أ',\n LBP: 'ل.ل',\n SYP: 'ل.س',\n IQD: 'ع.د',\n IRR: '﷼',\n AFN: '؋',\n PKR: '₨',\n LKR: '₨',\n NPR: '₨',\n BDT: '৳',\n MMK: 'K',\n LAK: '₭',\n KHR: '៛',\n MNT: '₮',\n KZT: '₸',\n UZS: 'лв',\n KGS: 'лв',\n TJS: 'SM',\n TMT: 'T',\n AZN: '₼',\n GEL: '₾',\n AMD: '֏',\n BYR: 'p.',\n MDL: 'L'\n };\n\n return currencySymbols[currency.toUpperCase()] || currency;\n}\n\n/**\n * List of currencies where the symbol appears after the amount\n */\nexport const SYMBOL_AFTER_CURRENCIES = ['SEK', 'NOK', 'DKK', 'PLN', 'CZK', 'HUF', 'RON', 'BGN', 'HRK'];\n\n/**\n * Check if currency symbol should be placed after the amount\n */\nexport function isSymbolAfterCurrency(currency: string): boolean {\n return SYMBOL_AFTER_CURRENCIES.includes(currency.toUpperCase());\n}","// Price formatting utilities - Centralized currency and price operations\nimport type { Payment, PaymentMethod, Price } from '../types';\nimport { getCurrencySymbol, isSymbolAfterCurrency } from './currency';\n\nconst MARKET_CURRENCIES = {\n 'US': 'USD',\n 'EU': 'EUR',\n 'UK': 'GBP',\n 'CA': 'CAD',\n 'AU': 'AUD'\n} as const;\n\n// Convert minor units (cents) to major units (dollars)\nexport function convertToMajor(minorAmount: number): number {\n return (minorAmount ?? 0) / 100;\n}\n\n// Convert major units to minor units\nexport function convertToMinor(majorAmount: number): number {\n return Math.round((majorAmount ?? 0) * 100);\n}\n\n// Get currency from market ID\nexport function getCurrencyFromMarket(marketId: string): string {\n return MARKET_CURRENCIES[marketId as keyof typeof MARKET_CURRENCIES] || 'USD';\n}\n\n// Format currency amount with symbol (locale-aware positioning)\nexport function formatCurrencyAmount(\n amount: number,\n currency: string,\n options: {\n showSymbols?: boolean;\n decimalPlaces?: number;\n customSymbol?: string;\n } = {}\n): string {\n const { showSymbols = true, decimalPlaces = 2, customSymbol } = options;\n const roundedAmount = amount.toFixed(decimalPlaces);\n\n if (!showSymbols) {\n return `${roundedAmount} ${currency}`;\n }\n\n const symbol = customSymbol || getCurrencySymbol(currency);\n\n // Use locale-specific symbol positioning\n if (isSymbolAfterCurrency(currency)) {\n return `${roundedAmount} ${symbol}`;\n }\n\n return `${symbol}${roundedAmount}`;\n}\n\n// Format minor units with currency\nexport function formatMinor(\n amountMinor: number,\n currency: string,\n options: {\n showSymbols?: boolean;\n decimalPlaces?: number;\n customSymbol?: string;\n } = {}\n): string {\n const major = convertToMajor(amountMinor);\n return formatCurrencyAmount(major, currency, options);\n}\n\n// Format Payment structure for display\nexport function formatPayment(\n payment: Payment,\n options: {\n showSymbols?: boolean;\n decimalPlaces?: number;\n showBreakdown?: boolean;\n } = {}\n): string {\n if (!payment) return '';\n\n const { showSymbols = true, decimalPlaces = 2, showBreakdown = false } = options;\n\n if (showBreakdown) {\n const subtotal = formatMinor(payment.subtotal, payment.currency, { showSymbols, decimalPlaces });\n const discount = (payment.discount ?? 0) > 0 ? formatMinor(payment.discount, payment.currency, { showSymbols, decimalPlaces }) : null;\n const tax = (payment.tax ?? 0) > 0 ? formatMinor(payment.tax, payment.currency, { showSymbols, decimalPlaces }) : null;\n const total = formatMinor(payment.total, payment.currency, { showSymbols, decimalPlaces });\n\n let result = `Subtotal: ${subtotal}`;\n if (discount) result += `, Discount: -${discount}`;\n if (tax) result += `, Tax: ${tax}`;\n result += `, Total: ${total}`;\n return result;\n }\n\n return formatMinor(payment.total, payment.currency, { showSymbols, decimalPlaces });\n}\n\n// Format market-based prices (from product variants)\nexport function getMarketPrice(\n prices: Price[],\n marketId: string,\n businessMarkets?: any[],\n options: {\n showSymbols?: boolean;\n decimalPlaces?: number;\n showCompareAt?: boolean;\n fallbackMarket?: string;\n } = {}\n): string {\n if (!prices || prices.length === 0) return '';\n\n const {\n showSymbols = true,\n decimalPlaces = 2,\n showCompareAt = true,\n fallbackMarket = 'US',\n } = options;\n\n // Find price for the specific market\n let price = prices.find(p => p.market === marketId);\n\n // Fallback to first available or fallback market\n if (!price) {\n price = prices.find(p => p.market === fallbackMarket) || prices[0];\n }\n\n if (!price) return '';\n\n let currency: string;\n let symbol: string;\n\n // If we have business markets, use the currency directly from market data\n if (businessMarkets) {\n const marketData = businessMarkets.find(m => m.id === price.market || m.code === price.market);\n if (marketData?.currency) {\n currency = marketData.currency;\n symbol = getCurrencySymbol(currency);\n } else {\n currency = getCurrencyFromMarket(price.market);\n symbol = getCurrencySymbol(currency);\n }\n } else {\n currency = getCurrencyFromMarket(price.market);\n symbol = getCurrencySymbol(currency);\n }\n\n // Format price with custom symbol\n const formattedPrice = formatMinor(price.amount ?? 0, currency, {\n showSymbols,\n decimalPlaces,\n customSymbol: symbol\n });\n\n // Add compare-at price if available\n if (showCompareAt && price.compareAt && price.compareAt > (price.amount ?? 0)) {\n const formattedCompareAt = formatMinor(price.compareAt, currency, {\n showSymbols,\n decimalPlaces,\n customSymbol: symbol\n });\n return `${formattedPrice} was ${formattedCompareAt}`;\n }\n\n return formattedPrice;\n}\n\n// Get price amount from market-based prices (for calculations)\nexport function getPriceAmount(prices: Price[], marketId: string, fallbackMarket: string = 'US'): number {\n if (!prices || prices.length === 0) return 0;\n\n const price = prices.find(p => p.market === marketId) ||\n prices.find(p => p.market === fallbackMarket) ||\n prices[0];\n\n // Amounts are stored in minor units (e.g., cents)\n return price?.amount || 0;\n}\n\n// Create Payment structure for checkout (all amounts in minor units)\nexport function createPaymentForCheckout(\n subtotalMinor: number,\n marketId: string,\n currency: string,\n paymentMethod: any,\n options: {\n discount?: number;\n tax?: number;\n promoCodeId?: string;\n } = {}\n): Payment {\n const { discount = 0, tax = 0, promoCodeId } = options;\n const total = subtotalMinor - discount + tax;\n\n return {\n currency,\n market: marketId,\n subtotal: subtotalMinor,\n shipping: 0,\n discount,\n tax,\n total,\n promoCodeId,\n method: paymentMethod,\n };\n}\n","import { getImageUrl } from \"./blocks\";\n\nexport async function fetchSvgContent(mediaObject: any): Promise<string | null> {\n\tif (!mediaObject) return null;\n\n\tconst svgUrl = getImageUrl(mediaObject, false);\n\n\ttry {\n\t\tconst response = await fetch(svgUrl);\n\n\t\tif (!response.ok) {\n\t\t\tconsole.error(`Failed to fetch SVG: ${response.status} ${response.statusText}`);\n\t\t\treturn null;\n\t\t}\n\n\t\tconst svgContent = await response.text();\n\t\treturn svgContent;\n\t} catch (error) {\n\t\tconsole.error(\"Error fetching SVG:\", error);\n\t\treturn null;\n\t}\n}\n\n/**\n * Server-side helper for Astro components to fetch SVG content during SSR\n *\n * @param mediaObject The media object from the CMS\n * @returns The SVG content as a string, or empty string on failure\n */\nexport async function getSvgContentForAstro(mediaObject: any): Promise<string> {\n\ttry {\n\t\tconst svgContent = await fetchSvgContent(mediaObject);\n\t\treturn svgContent || \"\";\n\t} catch (error) {\n\t\tconsole.error(\"Error getting SVG content for Astro:\", error);\n\t\treturn \"\";\n\t}\n}\n\n/**\n * Client-side helper to fetch and inject SVG content into DOM elements\n *\n * @param mediaObject The media object from the CMS\n * @param targetElement The DOM element to inject the SVG into\n * @param className Optional CSS class to add to the SVG\n */\nexport async function injectSvgIntoElement(\n\tmediaObject: any,\n\ttargetElement: HTMLElement,\n\tclassName?: string,\n): Promise<void> {\n\tif (!targetElement) return;\n\n\ttry {\n\t\tconst svgContent = await fetchSvgContent(mediaObject);\n\n\t\tif (svgContent) {\n\t\t\ttargetElement.innerHTML = svgContent;\n\n\t\t\t// Add class if provided\n\t\t\tif (className) {\n\t\t\t\tconst svgElement = targetElement.querySelector(\"svg\");\n\t\t\t\tif (svgElement) {\n\t\t\t\t\tsvgElement.classList.add(...className.split(\" \"));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} catch (error) {\n\t\tconsole.error(\"Error injecting SVG:\", error);\n\t}\n}","// Define locales inline since we don't have @lib/i18n in SDK\nconst locales = ['en', 'sr-latn'] as const;\nconst localeMap: Record<typeof locales[number], string> = {\n\t'en': 'en-US',\n\t'sr-latn': 'sr-RS'\n};\n\n/**\n * * returns \"slugified\" text.\n * @param text: string - text to slugify\n */\nexport function slugify(text: string): string {\n\treturn text\n\t\t.toString()\n\t\t.toLowerCase() // convert to lowercase\n\t\t.replace(/\\s+/g, \"-\") // replace spaces with -\n\t\t.replace(/[^\\w-]+/g, \"\") // remove all non-word chars\n\t\t.replace(/--+/g, \"-\") // replace multiple dashes with single dash\n\t\t.replace(/^-+/, \"\") // trim dash from start of text\n\t\t.replace(/-+$/, \"\"); // trim dash from end of text\n}\n\n/**\n * * returns \"humanized\" text. runs slugify() and then replaces - with space and upper case first letter of every word, and lower case the rest\n * @param text: string - text to humanize\n */\nexport function humanize(text: string): string {\n\tconst slugifiedText = slugify(text);\n\treturn (\n\t\tslugifiedText\n\t\t\t.replace(/-/g, \" \") // replace \"-\" with space\n\t\t\t// .toLowerCase();\n\t\t\t.replace(\n\t\t\t\t// upper case first letter of every word, and lower case the rest\n\t\t\t\t/\\w\\S*/g,\n\t\t\t\t(w) => w.charAt(0).toUpperCase() + w.slice(1).toLowerCase(),\n\t\t\t)\n\t);\n}\n\n// --------------------------------------------------------\n/**\n * * returns \"categorified\" text. runs slugify() and then replaces - with space and upper cases everything\n * @param text: string - text to categorify\n * @returns string - categorified text\n */\nexport function categorify(text: string): string {\n\tconst slugifiedText = slugify(text);\n\treturn slugifiedText\n\t\t.replace(/-/g, \" \") // replace \"-\" with space\n\t\t.toUpperCase();\n}\n\n// --------------------------------------------------------\n/**\n * * returns a nicely formatted string of the date passed\n * @param date: string | number | Date - date to format\n * @param locale: string - locale to format the date in\n * @returns string - formatted date\n */\nexport function formatDate(date: string | number | Date, locale: (typeof locales)[number]): string {\n\tlet localeString = \"en-US\";\n\n\tif (locales.includes(locale)) {\n\t\tlocaleString = localeMap[locale];\n\t}\n\n\treturn new Date(date).toLocaleDateString(localeString, {\n\t\ttimeZone: \"UTC\",\n\t\tyear: \"numeric\",\n\t\tmonth: \"short\",\n\t\tday: \"numeric\",\n\t});\n}","// Timezone utilities (moved from Reservation folder)\n\nexport const tzGroups = [\n {\n label: \"US\",\n zones: [\n { label: \"Eastern Time\", value: \"America/New_York\" },\n { label: \"Central Time\", value: \"America/Chicago\" },\n { label: \"Mountain Time\", value: \"America/Denver\" },\n { label: \"Pacific Time\", value: \"America/Los_Angeles\" },\n ],\n },\n {\n label: \"Europe\",\n zones: [\n { label: \"London\", value: \"Europe/London\" },\n { label: \"Paris\", value: \"Europe/Paris\" },\n { label: \"Berlin\", value: \"Europe/Berlin\" },\n { label: \"Rome\", value: \"Europe/Rome\" },\n ],\n },\n {\n label: \"Asia\",\n zones: [\n { label: \"Tokyo\", value: \"Asia/Tokyo\" },\n { label: \"Shanghai\", value: \"Asia/Shanghai\" },\n { label: \"Mumbai\", value: \"Asia/Kolkata\" },\n { label: \"Dubai\", value: \"Asia/Dubai\" },\n ],\n },\n];\n\nexport function findTimeZone(groups: typeof tzGroups): string {\n try {\n const detected = Intl.DateTimeFormat().resolvedOptions().timeZone;\n \n // Check if detected timezone is in our list\n for (const group of groups) {\n for (const zone of group.zones) {\n if (zone.value === detected) {\n return detected;\n }\n }\n }\n \n // Fallback to UTC if not found\n return \"UTC\";\n } catch (e) {\n // Fallback to UTC if detection fails\n return \"UTC\";\n }\n}","// Validation utilities\n\nexport interface ValidationResult {\n isValid: boolean;\n error?: string;\n}\n\n// Phone number validation\nexport function validatePhoneNumber(phone: string): ValidationResult {\n if (!phone) {\n return { isValid: false, error: 'Phone number is required' };\n }\n \n const cleaned = phone.replace(/\\D/g, '');\n \n if (cleaned.length < 8) {\n return { isValid: false, error: 'Phone number is too short' };\n }\n \n if (cleaned.length > 15) {\n return { isValid: false, error: 'Phone number is too long' };\n }\n \n return { isValid: true };\n}\n\n// Email validation\nexport function validateEmail(email: string): ValidationResult {\n if (!email) {\n return { isValid: false, error: 'Email is required' };\n }\n \n const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n \n if (!emailRegex.test(email)) {\n return { isValid: false, error: 'Please enter a valid email address' };\n }\n \n return { isValid: true };\n}\n\n// Verification code validation (4-digit codes)\nexport function validateVerificationCode(code: string): ValidationResult {\n if (!code) {\n return { isValid: false, error: 'Verification code is required' };\n }\n \n const cleaned = code.replace(/\\D/g, '');\n \n if (cleaned.length !== 4) {\n return { isValid: false, error: 'Please enter a 4-digit verification code' };\n }\n \n return { isValid: true };\n}\n\n// Generic required field validation\nexport function validateRequired(value: any, fieldName: string = 'This field'): ValidationResult {\n if (value === null || value === undefined || value === '') {\n return { isValid: false, error: `${fieldName} is required` };\n }\n \n return { isValid: true };\n}"]}
package/dist/utils.d.cts CHANGED
@@ -1,9 +1,2 @@
1
- export { X as Block, C as Collection, w as CollectionEntry, E as ERROR_CODES, u as ERROR_CONSTANTS, R as RequestError, S as ServerError, V as ValidationError, W as ValidationResult, m as categorify, H as convertServerErrorToRequestError, J as convertToMajor, K as convertToMinor, U as createPaymentForCheckout, I as errors, z as extractBlockValues, i as fetchSvgContent, o as findTimeZone, x as formatBlockValue, N as formatCurrencyAmount, n as formatDate, O as formatMinor, P as formatPayment, B as getBlockFromArray, g as getBlockLabel, A as getBlockObjectValues, d as getBlockTextValue, e as getBlockValue, f as getBlockValues, M as getCurrencyFromMarket, q as getErrorMessage, D as getGalleryThumbnail, h as getImageUrl, Q as getMarketPrice, T as getPriceAmount, j as getSvgContentForAstro, L as getSymbol, l as humanize, k as injectSvgIntoElement, r as isErrorCode, y as prepareBlocksForSubmission, s as slugify, t as thumbnailUrl, G as transformErrors, F as translateMap, p as tzGroups, a as validateEmail, v as validatePhoneNumber, c as validateRequired, b as validateVerificationCode } from './validation-C9UAYKke.cjs';
1
+ export { Z as Block, C as Collection, i as CollectionEntry, E as ERROR_CODES, x as ERROR_CONSTANTS, R as RequestError, y as ServerError, V as ValidationError, U as ValidationResult, P as categorify, D as convertServerErrorToRequestError, G as convertToMajor, H as convertToMinor, d as createPaymentForCheckout, F as errors, l as extractBlockValues, K as fetchSvgContent, h as findTimeZone, k as formatBlockValue, J as formatCurrencyAmount, Q as formatDate, c as formatMinor, f as formatPayment, r as getBlockFromArray, j as getBlockLabel, q as getBlockObjectValues, m as getBlockTextValue, n as getBlockValue, o as getBlockValues, I as getCurrencyFromMarket, e as getCurrencySymbol, z as getErrorMessage, g as getGalleryThumbnail, s as getImageUrl, a as getMarketPrice, b as getPriceAmount, L as getSvgContentForAstro, O as humanize, M as injectSvgIntoElement, A as isErrorCode, p as prepareBlocksForSubmission, N as slugify, t as thumbnailUrl, B as transformErrors, u as translateMap, T as tzGroups, W as validateEmail, v as validatePhoneNumber, Y as validateRequired, X as validateVerificationCode } from './index-DOEos-hV.cjs';
2
2
  import './types.cjs';
3
-
4
- /**
5
- * Maps currency codes to their display symbols
6
- */
7
- declare function getCurrencySymbol(currency: string): string;
8
-
9
- export { getCurrencySymbol };
package/dist/utils.d.ts CHANGED
@@ -1,9 +1,2 @@
1
- export { X as Block, C as Collection, w as CollectionEntry, E as ERROR_CODES, u as ERROR_CONSTANTS, R as RequestError, S as ServerError, V as ValidationError, W as ValidationResult, m as categorify, H as convertServerErrorToRequestError, J as convertToMajor, K as convertToMinor, U as createPaymentForCheckout, I as errors, z as extractBlockValues, i as fetchSvgContent, o as findTimeZone, x as formatBlockValue, N as formatCurrencyAmount, n as formatDate, O as formatMinor, P as formatPayment, B as getBlockFromArray, g as getBlockLabel, A as getBlockObjectValues, d as getBlockTextValue, e as getBlockValue, f as getBlockValues, M as getCurrencyFromMarket, q as getErrorMessage, D as getGalleryThumbnail, h as getImageUrl, Q as getMarketPrice, T as getPriceAmount, j as getSvgContentForAstro, L as getSymbol, l as humanize, k as injectSvgIntoElement, r as isErrorCode, y as prepareBlocksForSubmission, s as slugify, t as thumbnailUrl, G as transformErrors, F as translateMap, p as tzGroups, a as validateEmail, v as validatePhoneNumber, c as validateRequired, b as validateVerificationCode } from './validation-DIvAzYjG.js';
1
+ export { Z as Block, C as Collection, i as CollectionEntry, E as ERROR_CODES, x as ERROR_CONSTANTS, R as RequestError, y as ServerError, V as ValidationError, U as ValidationResult, P as categorify, D as convertServerErrorToRequestError, G as convertToMajor, H as convertToMinor, d as createPaymentForCheckout, F as errors, l as extractBlockValues, K as fetchSvgContent, h as findTimeZone, k as formatBlockValue, J as formatCurrencyAmount, Q as formatDate, c as formatMinor, f as formatPayment, r as getBlockFromArray, j as getBlockLabel, q as getBlockObjectValues, m as getBlockTextValue, n as getBlockValue, o as getBlockValues, I as getCurrencyFromMarket, e as getCurrencySymbol, z as getErrorMessage, g as getGalleryThumbnail, s as getImageUrl, a as getMarketPrice, b as getPriceAmount, L as getSvgContentForAstro, O as humanize, M as injectSvgIntoElement, A as isErrorCode, p as prepareBlocksForSubmission, N as slugify, t as thumbnailUrl, B as transformErrors, u as translateMap, T as tzGroups, W as validateEmail, v as validatePhoneNumber, Y as validateRequired, X as validateVerificationCode } from './index-DEmVFs0E.js';
2
2
  import './types.js';
3
-
4
- /**
5
- * Maps currency codes to their display symbols
6
- */
7
- declare function getCurrencySymbol(currency: string): string;
8
-
9
- export { getCurrencySymbol };
package/dist/utils.js CHANGED
@@ -1,12 +1,3 @@
1
- // src/config.ts
2
- function getGlobalConfig() {
3
- {
4
- throw new Error(
5
- "Arky SDK not initialized. Call initArky() first."
6
- );
7
- }
8
- }
9
-
10
1
  // src/utils/blocks.ts
11
2
  function getBlockLabel(block, locale = "en") {
12
3
  if (!block) return "";
@@ -137,10 +128,8 @@ var getBlockFromArray = (entry, blockKey, locale = "en") => {
137
128
  return acc;
138
129
  });
139
130
  };
140
- var getImageUrl = (imageBlock, isBlock = true) => {
131
+ var getImageUrl = (imageBlock, isBlock = true, storageUrl = "https://storage.arky.io/dev") => {
141
132
  if (!imageBlock) return null;
142
- const config = getGlobalConfig();
143
- const storageUrl = config.storageUrl || "https://storage.arky.io/dev";
144
133
  const isExternalUrl = (url) => {
145
134
  return url.startsWith("http://") || url.startsWith("https://");
146
135
  };
@@ -186,9 +175,7 @@ function getGalleryThumbnail(gallery) {
186
175
  const res = item.media.resolutions.thumbnail || item.media.resolutions.original;
187
176
  return res?.url || null;
188
177
  }
189
- function thumbnailUrl(service) {
190
- const config = getGlobalConfig();
191
- const storageUrl = config.storageUrl || "";
178
+ function thumbnailUrl(service, storageUrl = "") {
192
179
  const path = getGalleryThumbnail(service.gallery);
193
180
  return path ? `${storageUrl}/${path}` : null;
194
181
  }
@@ -241,7 +228,7 @@ var ERROR_CODES = {
241
228
  "BUSINESS.007": "BUSINESS.BUSINESS_ID_REQUIRED",
242
229
  "BUSINESS.010": "BUSINESS.DESCRIPTION_REQUIRED",
243
230
  "BUSINESS.011": "BUSINESS.SLUG_INVALID",
244
- // Provider errors
231
+ // Provider errors
245
232
  "PROVIDER.001": "PROVIDER.NOT_FOUND",
246
233
  "PROVIDER.002": "PROVIDER.FAILED_TO_CREATE",
247
234
  "PROVIDER.003": "PROVIDER.FAILED_TO_UPDATE",
@@ -291,11 +278,11 @@ var transformErrors = (zodError) => {
291
278
  if (!zodError.issues) return customErrors;
292
279
  zodError.issues.forEach((issue) => {
293
280
  const field = issue.path.join(".");
294
- const message = issue.message;
281
+ const error = issue.message;
295
282
  if (!customErrors.some(
296
- (customError) => customError.field === field && customError.message === message
283
+ (customError) => customError.field === field && customError.error === error
297
284
  )) {
298
- customErrors.push({ field, message });
285
+ customErrors.push({ field, error });
299
286
  }
300
287
  });
301
288
  return customErrors;
@@ -307,7 +294,7 @@ var convertServerErrorToRequestError = (serverError, renameRules) => {
307
294
  const field = renameRules && renameRules[validationError.field] ? renameRules[validationError.field] : validationError.field;
308
295
  return {
309
296
  field,
310
- message: ERROR_CODES[validationError.code] || "Unknown error"
297
+ error: validationError.error || "GENERAL.VALIDATION_ERROR"
311
298
  };
312
299
  })
313
300
  };
@@ -398,15 +385,12 @@ function getCurrencySymbol(currency) {
398
385
  };
399
386
  return currencySymbols[currency.toUpperCase()] || currency;
400
387
  }
388
+ var SYMBOL_AFTER_CURRENCIES = ["SEK", "NOK", "DKK", "PLN", "CZK", "HUF", "RON", "BGN", "HRK"];
389
+ function isSymbolAfterCurrency(currency) {
390
+ return SYMBOL_AFTER_CURRENCIES.includes(currency.toUpperCase());
391
+ }
401
392
 
402
393
  // src/utils/price.ts
403
- var CURRENCY_SYMBOLS = {
404
- "USD": "$",
405
- "EUR": "\u20AC",
406
- "GBP": "\xA3",
407
- "CAD": "C$",
408
- "AUD": "A$"
409
- };
410
394
  var MARKET_CURRENCIES = {
411
395
  "US": "USD",
412
396
  "EU": "EUR",
@@ -420,9 +404,6 @@ function convertToMajor(minorAmount) {
420
404
  function convertToMinor(majorAmount) {
421
405
  return Math.round((majorAmount ?? 0) * 100);
422
406
  }
423
- function getSymbol(currency) {
424
- return CURRENCY_SYMBOLS[currency] || "$";
425
- }
426
407
  function getCurrencyFromMarket(marketId) {
427
408
  return MARKET_CURRENCIES[marketId] || "USD";
428
409
  }
@@ -432,7 +413,10 @@ function formatCurrencyAmount(amount, currency, options = {}) {
432
413
  if (!showSymbols) {
433
414
  return `${roundedAmount} ${currency}`;
434
415
  }
435
- const symbol = customSymbol || getSymbol(currency);
416
+ const symbol = customSymbol || getCurrencySymbol(currency);
417
+ if (isSymbolAfterCurrency(currency)) {
418
+ return `${roundedAmount} ${symbol}`;
419
+ }
436
420
  return `${symbol}${roundedAmount}`;
437
421
  }
438
422
  function formatMinor(amountMinor, currency, options = {}) {
@@ -477,11 +461,11 @@ function getMarketPrice(prices, marketId, businessMarkets, options = {}) {
477
461
  symbol = getCurrencySymbol(currency);
478
462
  } else {
479
463
  currency = getCurrencyFromMarket(price.market);
480
- symbol = getSymbol(currency);
464
+ symbol = getCurrencySymbol(currency);
481
465
  }
482
466
  } else {
483
467
  currency = getCurrencyFromMarket(price.market);
484
- symbol = getSymbol(currency);
468
+ symbol = getCurrencySymbol(currency);
485
469
  }
486
470
  const formattedPrice = formatMinor(price.amount ?? 0, currency, {
487
471
  showSymbols,
@@ -684,6 +668,6 @@ function validateRequired(value, fieldName = "This field") {
684
668
  return { isValid: true };
685
669
  }
686
670
 
687
- export { ERROR_CODES, ERROR_CONSTANTS, categorify, convertServerErrorToRequestError, convertToMajor, convertToMinor, createPaymentForCheckout, errors, extractBlockValues, fetchSvgContent, findTimeZone, formatBlockValue, formatCurrencyAmount, formatDate, formatMinor, formatPayment, getBlockFromArray, getBlockLabel, getBlockObjectValues, getBlockTextValue, getBlockValue, getBlockValues, getCurrencyFromMarket, getCurrencySymbol, getErrorMessage, getGalleryThumbnail, getImageUrl, getMarketPrice, getPriceAmount, getSvgContentForAstro, getSymbol, humanize, injectSvgIntoElement, isErrorCode, prepareBlocksForSubmission, slugify, thumbnailUrl, transformErrors, translateMap, tzGroups, validateEmail, validatePhoneNumber, validateRequired, validateVerificationCode };
671
+ export { ERROR_CODES, ERROR_CONSTANTS, categorify, convertServerErrorToRequestError, convertToMajor, convertToMinor, createPaymentForCheckout, errors, extractBlockValues, fetchSvgContent, findTimeZone, formatBlockValue, formatCurrencyAmount, formatDate, formatMinor, formatPayment, getBlockFromArray, getBlockLabel, getBlockObjectValues, getBlockTextValue, getBlockValue, getBlockValues, getCurrencyFromMarket, getCurrencySymbol, getErrorMessage, getGalleryThumbnail, getImageUrl, getMarketPrice, getPriceAmount, getSvgContentForAstro, humanize, injectSvgIntoElement, isErrorCode, prepareBlocksForSubmission, slugify, thumbnailUrl, transformErrors, translateMap, tzGroups, validateEmail, validatePhoneNumber, validateRequired, validateVerificationCode };
688
672
  //# sourceMappingURL=utils.js.map
689
673
  //# sourceMappingURL=utils.js.map