@swell/apps-sdk 1.0.147 → 1.0.149

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/index.cjs CHANGED
@@ -48,7 +48,7 @@ __export(index_exports, {
48
48
  ShopifyCart: () => ShopifyCart,
49
49
  ShopifyCollection: () => ShopifyCollection,
50
50
  ShopifyCollections: () => ShopifyCollections,
51
- ShopifyCompatibility: () => ShopifyCompatibility3,
51
+ ShopifyCompatibility: () => ShopifyCompatibility2,
52
52
  ShopifyCustomer: () => ShopifyCustomer,
53
53
  ShopifyFont: () => ShopifyFont,
54
54
  ShopifyForm: () => ShopifyForm,
@@ -119,6 +119,7 @@ __export(index_exports, {
119
119
  getPage: () => getPage,
120
120
  getPageSections: () => getPageSections,
121
121
  getSectionGroupProp: () => getSectionGroupProp,
122
+ getSectionLocation: () => getSectionLocation,
122
123
  getSectionSettingsFromProps: () => getSectionSettingsFromProps,
123
124
  getThemeSettingsFromProps: () => getThemeSettingsFromProps,
124
125
  isArray: () => isArray2,
@@ -459,7 +460,8 @@ var ForloopDrop = class extends import_liquidjs.Drop {
459
460
  last;
460
461
  rindex;
461
462
  rindex0;
462
- constructor(length, collection, variable) {
463
+ parentloop;
464
+ constructor(length, collection, variable, parent) {
463
465
  super();
464
466
  this.length = length;
465
467
  this.name = `${variable}-${collection}`;
@@ -467,9 +469,10 @@ var ForloopDrop = class extends import_liquidjs.Drop {
467
469
  this.index = 1;
468
470
  this.index0 = 0;
469
471
  this.first = true;
470
- this.last = false;
472
+ this.last = length <= 0;
471
473
  this.rindex = length;
472
474
  this.rindex0 = length - 1;
475
+ this.parentloop = parent ?? null;
473
476
  }
474
477
  next() {
475
478
  this.i += 1;
@@ -676,6 +679,8 @@ var StorefrontResource = class {
676
679
  switch (prop) {
677
680
  // Ignore liquid prop checks
678
681
  case "toLiquid":
682
+ return typeof instance.toLiquid === "function" ? instance.toLiquid : void 0;
683
+ // Ignore liquid prop checks
679
684
  case "next":
680
685
  return;
681
686
  // Indicate props are thenable
@@ -6668,6 +6673,7 @@ function getSectionSettingsFromProps(props, sectionSchema) {
6668
6673
  }
6669
6674
  ),
6670
6675
  id: sectionSchema.id,
6676
+ type: sectionSchema.id,
6671
6677
  blocks: props.Blocks?.filter(
6672
6678
  (propBlock) => Boolean(propBlock.props.compiled?._component)
6673
6679
  ).map((propBlock) => {
@@ -6688,7 +6694,8 @@ function getSectionSettingsFromProps(props, sectionSchema) {
6688
6694
  { $locale: blockProps.$locale }
6689
6695
  ) || {}
6690
6696
  };
6691
- })
6697
+ }),
6698
+ location: getSectionLocation(sectionSchema.id)
6692
6699
  };
6693
6700
  }
6694
6701
  function toEasyblocksFieldId(fieldId) {
@@ -6945,7 +6952,8 @@ async function getLayoutSectionGroups(allSections, renderTemplateSchema) {
6945
6952
  async function getPageSections(sectionGroup, getSchema) {
6946
6953
  const order = Array.isArray(sectionGroup?.order) && sectionGroup.order.length > 0 ? sectionGroup.order : Object.keys(sectionGroup?.sections || {});
6947
6954
  const pageSections = [];
6948
- for (const key of order) {
6955
+ for (let i = 0; i < order.length; ++i) {
6956
+ const key = order[i];
6949
6957
  const section = sectionGroup.sections?.[key];
6950
6958
  if (!section) {
6951
6959
  continue;
@@ -6967,7 +6975,10 @@ async function getPageSections(sectionGroup, getSchema) {
6967
6975
  section: {
6968
6976
  id,
6969
6977
  ...section,
6970
- blocks
6978
+ blocks,
6979
+ index0: i,
6980
+ index: i + 1,
6981
+ location: getSectionLocation(section.type)
6971
6982
  }
6972
6983
  };
6973
6984
  pageSections.push({
@@ -7211,6 +7222,15 @@ function extractSettingsFromForm(form, currentSettings) {
7211
7222
  (0, import_lodash_es3.cloneDeep)(currentSettings)
7212
7223
  );
7213
7224
  }
7225
+ function getSectionLocation(sectionType) {
7226
+ switch (sectionType) {
7227
+ case "header":
7228
+ case "footer":
7229
+ return sectionType;
7230
+ default:
7231
+ return sectionType ? `custom.${sectionType}` : "template";
7232
+ }
7233
+ }
7214
7234
  var SECTION_GROUP_CONTENT = "ContentSections";
7215
7235
  function getSectionGroupProp(sectionId) {
7216
7236
  return `SectionGroup_${sectionId}`;
@@ -8120,19 +8140,19 @@ function getContentModel(swell, name) {
8120
8140
  })
8121
8141
  );
8122
8142
  }
8123
- async function getContentList(swell, type, query) {
8143
+ function getContentList(swell, type, query) {
8124
8144
  return new SwellStorefrontCollection(swell, `content/${type}`, query);
8125
8145
  }
8126
- async function getContentEntry(swell, type, id, query) {
8146
+ function getContentEntry(swell, type, id, query) {
8127
8147
  return new SwellStorefrontRecord(swell, `content/${type}`, id, query);
8128
8148
  }
8129
- async function getPage(swell, id, query) {
8149
+ function getPage(swell, id, query) {
8130
8150
  return getContentEntry(swell, "pages", id, query);
8131
8151
  }
8132
- async function getBlogs(swell, query) {
8152
+ function getBlogs(swell, query) {
8133
8153
  return getContentList(swell, "blogs", query);
8134
8154
  }
8135
- async function getBlog(swell, id, query) {
8155
+ function getBlog(swell, id, query) {
8136
8156
  return getContentEntry(swell, "blogs", id, query);
8137
8157
  }
8138
8158
 
@@ -8942,11 +8962,11 @@ function getRandomId() {
8942
8962
  }
8943
8963
 
8944
8964
  // src/menus.ts
8945
- var import_lodash_es12 = require("lodash-es");
8965
+ var import_lodash_es14 = require("lodash-es");
8946
8966
 
8947
8967
  // src/theme.ts
8948
8968
  var import_json56 = __toESM(require("json5"), 1);
8949
- var import_lodash_es11 = require("lodash-es");
8969
+ var import_lodash_es13 = require("lodash-es");
8950
8970
 
8951
8971
  // src/compatibility/shopify.ts
8952
8972
  var import_lodash_es7 = require("lodash-es");
@@ -14130,7 +14150,7 @@ __export(shopify_objects_exports, {
14130
14150
  });
14131
14151
 
14132
14152
  // src/compatibility/shopify-objects/image.ts
14133
- function ShopifyImage(_instance, image, options = {}, product, variant) {
14153
+ function ShopifyImage(image, options = {}, product, variant) {
14134
14154
  if (image instanceof ShopifyResource) {
14135
14155
  return image.clone();
14136
14156
  }
@@ -14192,7 +14212,7 @@ function ShopifyArticle(instance, blog, blogCategory) {
14192
14212
  id: defer(() => blog.id),
14193
14213
  image: deferWith(
14194
14214
  blog,
14195
- (blog2) => blog2.image ? ShopifyImage(instance, blog2.image) : void 0
14215
+ (blog2) => blog2.image ? ShopifyImage(blog2.image) : void 0
14196
14216
  ),
14197
14217
  metafields: {},
14198
14218
  published_at: deferWith(
@@ -14282,7 +14302,7 @@ function ShopifyBlog(instance, blogCategory) {
14282
14302
  }
14283
14303
 
14284
14304
  // src/compatibility/shopify-objects/media.ts
14285
- function ShopifyMedia(instance, image, options) {
14305
+ function ShopifyMedia(image, options) {
14286
14306
  if (image instanceof ShopifyResource) {
14287
14307
  return image.clone();
14288
14308
  }
@@ -14291,7 +14311,7 @@ function ShopifyMedia(instance, image, options) {
14291
14311
  id: image.id || image.file?.id,
14292
14312
  media_type: options?.media_type ?? "image",
14293
14313
  position: options?.position,
14294
- preview_image: ShopifyImage(instance, image)
14314
+ preview_image: ShopifyImage(image)
14295
14315
  });
14296
14316
  }
14297
14317
 
@@ -14319,19 +14339,19 @@ function ShopifyVariant(instance, variant, productIn, depth = 0) {
14319
14339
  [product, variant],
14320
14340
  (product2, variant2) => {
14321
14341
  const image = variant2.images?.[0] || product2.images?.[0];
14322
- return image ? ShopifyImage(instance, image, {}, product2, variant2) : void 0;
14342
+ return image ? ShopifyImage(image, {}, product2, variant2) : void 0;
14323
14343
  }
14324
14344
  ),
14325
14345
  featured_media: deferWith([product, variant], (product2, variant2) => {
14326
14346
  const image = variant2.images?.[0] || product2.images?.[0];
14327
- return image ? ShopifyMedia(instance, image, { media_type: "image" }) : void 0;
14347
+ return image ? ShopifyMedia(image, { media_type: "image" }) : void 0;
14328
14348
  }),
14329
14349
  id: defer(() => variant.id),
14330
14350
  image: deferWith(
14331
14351
  [product, variant],
14332
14352
  (product2, variant2) => {
14333
14353
  const image = variant2.images?.[0] || product2.images?.[0];
14334
- return image ? ShopifyImage(instance, image, {}, product2, variant2) : void 0;
14354
+ return image ? ShopifyImage(image, {}, product2, variant2) : void 0;
14335
14355
  }
14336
14356
  ),
14337
14357
  incoming: false,
@@ -14483,11 +14503,11 @@ function ShopifyProduct(instance, product, depth = 0) {
14483
14503
  description: defer(() => product.description),
14484
14504
  featured_image: deferWith(product, (product2) => {
14485
14505
  const image = product2.images?.[0];
14486
- return image ? ShopifyImage(instance, image, {}, product2) : void 0;
14506
+ return image ? ShopifyImage(image, {}, product2) : void 0;
14487
14507
  }),
14488
14508
  featured_media: deferWith(product, (product2) => {
14489
14509
  const image = product2.images?.[0];
14490
- return image ? ShopifyMedia(instance, image) : void 0;
14510
+ return image ? ShopifyMedia(image) : void 0;
14491
14511
  }),
14492
14512
  // not used
14493
14513
  first_available_variant: deferWith(product, (product2) => {
@@ -14507,7 +14527,7 @@ function ShopifyProduct(instance, product, depth = 0) {
14507
14527
  return [];
14508
14528
  }
14509
14529
  return product2.images.map(
14510
- (image, index) => ShopifyImage(instance, image, { position: index + 1 }, product2)
14530
+ (image, index) => ShopifyImage(image, { position: index + 1 }, product2)
14511
14531
  );
14512
14532
  }),
14513
14533
  media: deferWith(product, (product2) => {
@@ -14515,7 +14535,7 @@ function ShopifyProduct(instance, product, depth = 0) {
14515
14535
  return [];
14516
14536
  }
14517
14537
  return product2.images.map(
14518
- (image, index) => ShopifyMedia(instance, image, {
14538
+ (image, index) => ShopifyMedia(image, {
14519
14539
  media_type: "image",
14520
14540
  position: index + 1
14521
14541
  })
@@ -14745,7 +14765,7 @@ function ShopifyLineItem(instance, item, cart, options = {}) {
14745
14765
  [item.product, item.variant],
14746
14766
  (product, variant) => {
14747
14767
  const image = product?.images?.[0];
14748
- return image ? ShopifyImage(instance, image, {}, product, variant) : void 0;
14768
+ return image ? ShopifyImage(image, {}, product, variant) : void 0;
14749
14769
  }
14750
14770
  ),
14751
14771
  item_components: (item.bundle_items ?? []).map(
@@ -15151,10 +15171,7 @@ function ShopifyCollection(instance, category) {
15151
15171
  (category2) => convertToShopifySorting(category2.sort_options?.[0].value ?? "")
15152
15172
  ),
15153
15173
  description: defer(() => category.description),
15154
- featured_image: deferWith(
15155
- category,
15156
- (category2) => getFirstImage(instance, category2)
15157
- ),
15174
+ featured_image: deferWith(category, (category2) => getFirstImage(category2)),
15158
15175
  filters: deferWith(
15159
15176
  category,
15160
15177
  (category2) => (category2?.filter_options ?? []).map(
@@ -15163,7 +15180,7 @@ function ShopifyCollection(instance, category) {
15163
15180
  ),
15164
15181
  handle: defer(() => category.slug),
15165
15182
  id: defer(() => category.id),
15166
- image: deferWith(category, (category2) => getFirstImage(instance, category2)),
15183
+ image: deferWith(category, (category2) => getFirstImage(category2)),
15167
15184
  metafields: {},
15168
15185
  next_product: void 0,
15169
15186
  previous_product: void 0,
@@ -15183,9 +15200,9 @@ function ShopifyCollection(instance, category) {
15183
15200
  url: deferWith(category, (category2) => `/collections/${category2.slug}`)
15184
15201
  });
15185
15202
  }
15186
- function getFirstImage(instance, category) {
15203
+ function getFirstImage(category) {
15187
15204
  const image = category.images?.[0];
15188
- return image ? ShopifyImage(instance, image) : void 0;
15205
+ return image ? ShopifyImage(image) : void 0;
15189
15206
  }
15190
15207
  function convertToShopifySorting(value) {
15191
15208
  switch (value) {
@@ -15285,7 +15302,7 @@ function ShopifyAddress(instance, address, account) {
15285
15302
  address,
15286
15303
  (address2) => address2.first_name || account?.first_name
15287
15304
  ),
15288
- id: defer(() => address.id),
15305
+ id: defer(() => address.id || address.account_address_id),
15289
15306
  last_name: deferWith(
15290
15307
  address,
15291
15308
  (address2) => address2.last_name || account?.last_name
@@ -15313,7 +15330,10 @@ function ShopifyAddress(instance, address, account) {
15313
15330
  address2.country
15314
15331
  )
15315
15332
  ),
15316
- url: deferWith(address, (address2) => `/account/addresses/${address2.id}`),
15333
+ url: deferWith(
15334
+ address,
15335
+ (address2) => `/account/addresses/${address2.id || address2.account_address_id}`
15336
+ ),
15317
15337
  zip: defer(() => address.zip)
15318
15338
  });
15319
15339
  }
@@ -15622,7 +15642,10 @@ function ShopifyCustomer(instance, account) {
15622
15642
  ),
15623
15643
  orders_count: defer(() => account.order_count),
15624
15644
  payment_methods: [],
15625
- phone: deferWith(account, (account2) => account2.phone),
15645
+ phone: deferWith(
15646
+ account,
15647
+ (account2) => account2.phone || account2.shipping?.phone || account2.billing?.phone
15648
+ ),
15626
15649
  store_credit_account: deferWith(account, (account2) => ({
15627
15650
  balance: ShopifyMoney(instance, Number(account2.balance))
15628
15651
  })),
@@ -16132,38 +16155,72 @@ function ShopifyShop(instance, store) {
16132
16155
  });
16133
16156
  }
16134
16157
 
16135
- // src/compatibility/drops/object-handles.ts
16158
+ // src/compatibility/drops/all_products.ts
16136
16159
  var import_liquidjs3 = require("liquidjs");
16137
- var ObjectHandlesDrop = class extends import_liquidjs3.Drop {
16160
+ var AllProductsDrop = class extends import_liquidjs3.Drop {
16161
+ #instance;
16138
16162
  #map;
16139
- constructor(map) {
16163
+ constructor(instance) {
16140
16164
  super();
16141
- switch (typeof map) {
16165
+ this.#instance = instance;
16166
+ this.#map = /* @__PURE__ */ new Map();
16167
+ }
16168
+ liquidMethodMissing(key) {
16169
+ switch (typeof key) {
16170
+ case "string": {
16171
+ return this.getProduct(key);
16172
+ }
16142
16173
  case "object": {
16143
- if (map === null) {
16144
- this.#map = /* @__PURE__ */ new Map();
16145
- break;
16174
+ if (key !== null) {
16175
+ const obj = key;
16176
+ const id = obj.handle || obj.id || obj._id;
16177
+ if (isLikePromise(id)) {
16178
+ return id.then((id2) => this.getProduct(id2));
16179
+ }
16180
+ return this.getProduct(id);
16146
16181
  }
16147
- this.#map = new Map(
16148
- map instanceof Map ? map : Object.entries(map)
16149
- );
16150
16182
  break;
16151
16183
  }
16152
16184
  default:
16153
- this.#map = /* @__PURE__ */ new Map();
16154
16185
  break;
16155
16186
  }
16156
16187
  }
16188
+ getProduct(slug) {
16189
+ let resource = this.#map.get(slug);
16190
+ if (resource === void 0 && this.#map.size < 20) {
16191
+ resource = ShopifyProduct(
16192
+ this.#instance,
16193
+ new SwellStorefrontRecord(this.#instance.swell, "products", slug)
16194
+ );
16195
+ this.#map.set(slug, resource);
16196
+ }
16197
+ return resource ?? null;
16198
+ }
16199
+ };
16200
+
16201
+ // src/compatibility/drops/articles.ts
16202
+ var import_liquidjs4 = require("liquidjs");
16203
+ var ArticlesDrop = class extends import_liquidjs4.Drop {
16204
+ #instance;
16205
+ #map;
16206
+ constructor(instance) {
16207
+ super();
16208
+ this.#instance = instance;
16209
+ this.#map = /* @__PURE__ */ new Map();
16210
+ }
16157
16211
  liquidMethodMissing(key) {
16158
16212
  switch (typeof key) {
16159
- case "string":
16160
- return this.#map.get(key);
16213
+ case "string": {
16214
+ return this.getArticle(key);
16215
+ }
16161
16216
  case "object": {
16162
- if (key !== null && "handle" in key) {
16163
- const { handle } = key;
16164
- if (typeof handle === "string") {
16165
- return this.#map.get(handle);
16217
+ if (key !== null) {
16218
+ const obj = key;
16219
+ const id = obj.handle || obj.id || obj._id;
16220
+ if (isLikePromise(id)) {
16221
+ return id.then((id2) => this.getArticle(id2));
16166
16222
  }
16223
+ return this.getArticle(id);
16167
16224
  }
16168
16225
  break;
16169
16226
  }
@@ -16171,13 +16228,71 @@ var ObjectHandlesDrop = class extends import_liquidjs3.Drop {
16171
16228
  break;
16172
16229
  }
16173
16230
  }
16231
+ getArticle(slug) {
16232
+ let resource = this.#map.get(slug);
16233
+ if (resource === void 0) {
16234
+ resource = ShopifyArticle(
16235
+ this.#instance,
16236
+ new SwellStorefrontRecord(this.#instance.swell, "content/blogs", slug)
16237
+ );
16238
+ this.#map.set(slug, resource);
16239
+ }
16240
+ return resource;
16241
+ }
16242
+ };
16243
+
16244
+ // src/compatibility/drops/blogs.ts
16245
+ var import_liquidjs5 = require("liquidjs");
16246
+ var BlogsDrop = class extends import_liquidjs5.Drop {
16247
+ #instance;
16248
+ #map;
16249
+ constructor(instance) {
16250
+ super();
16251
+ this.#instance = instance;
16252
+ this.#map = /* @__PURE__ */ new Map();
16253
+ }
16254
+ liquidMethodMissing(key) {
16255
+ switch (typeof key) {
16256
+ case "string": {
16257
+ return this.getBlog(key);
16258
+ }
16259
+ case "object": {
16260
+ if (key !== null) {
16261
+ const obj = key;
16262
+ const id = obj.handle || obj.id || obj._id;
16263
+ if (isLikePromise(id)) {
16264
+ return id.then((id2) => this.getBlog(id2));
16265
+ }
16266
+ return this.getBlog(id);
16267
+ }
16268
+ break;
16269
+ }
16270
+ default:
16271
+ break;
16272
+ }
16273
+ }
16274
+ getBlog(slug) {
16275
+ let resource = this.#map.get(slug);
16276
+ if (resource === void 0) {
16277
+ resource = ShopifyBlog(
16278
+ this.#instance,
16279
+ new SwellStorefrontRecord(
16280
+ this.#instance.swell,
16281
+ "content/blog-categories",
16282
+ slug
16283
+ )
16284
+ );
16285
+ this.#map.set(slug, resource);
16286
+ }
16287
+ return resource;
16288
+ }
16174
16289
  };
16175
16290
 
16176
16291
  // src/compatibility/drops/collections.ts
16177
- var import_liquidjs4 = require("liquidjs");
16178
- var AllCategoryResource = class extends SwellStorefrontRecord {
16292
+ var import_liquidjs6 = require("liquidjs");
16293
+ var AllCategoryResource = class extends StorefrontResource {
16179
16294
  constructor(instance) {
16180
- super(instance.swell, "categories", "all", {}, () => {
16295
+ super(() => {
16181
16296
  const category = {
16182
16297
  id: "all",
16183
16298
  slug: "all",
@@ -16188,15 +16303,12 @@ var AllCategoryResource = class extends SwellStorefrontRecord {
16188
16303
  });
16189
16304
  }
16190
16305
  };
16191
- var CollectionsDrop = class extends import_liquidjs4.Drop {
16306
+ var CollectionsDrop = class extends import_liquidjs6.Drop {
16192
16307
  #instance;
16193
- #categories;
16194
- #size;
16195
16308
  #map;
16196
16309
  constructor(instance) {
16197
16310
  super();
16198
16311
  this.#instance = instance;
16199
- this.#size = Number.NaN;
16200
16312
  this.#map = /* @__PURE__ */ new Map();
16201
16313
  }
16202
16314
  liquidMethodMissing(key) {
@@ -16241,36 +16353,32 @@ var CollectionsDrop = class extends import_liquidjs4.Drop {
16241
16353
  }
16242
16354
  return resource;
16243
16355
  }
16244
- get size() {
16245
- if (!Number.isFinite(this.#size)) {
16246
- return this.#instance.swell.storefront.get("/categories/:count").then((count) => {
16247
- const size = Number(count ?? 0);
16248
- this.#size = size;
16249
- return size;
16250
- });
16251
- }
16252
- return this.#size;
16253
- }
16254
- [Symbol.iterator]() {
16255
- return this.iterator();
16356
+ };
16357
+ var Collections = class extends SwellStorefrontCollection {
16358
+ #drop;
16359
+ constructor(instance) {
16360
+ super(instance.swell, "categories", {}, async () => {
16361
+ const response = await this._defaultGetter().call(this);
16362
+ if (!response) {
16363
+ return null;
16364
+ }
16365
+ return {
16366
+ ...response,
16367
+ page_count: response.page_count || 0,
16368
+ results: response.results.map(
16369
+ (item) => ShopifyCollection(instance, item)
16370
+ )
16371
+ };
16372
+ });
16373
+ this.#drop = new CollectionsDrop(instance);
16256
16374
  }
16257
- async iterator() {
16258
- if (!this.#categories) {
16259
- this.#categories = await this.#instance.swell.storefront.categories.list().then((res) => {
16260
- return res.results.map(
16261
- (category) => ShopifyCollection(
16262
- this.#instance,
16263
- new SwellStorefrontCategory(this.#instance, category.slug)
16264
- )
16265
- );
16266
- });
16267
- }
16268
- return this.#categories.values();
16375
+ toLiquid() {
16376
+ return this.#drop;
16269
16377
  }
16270
16378
  };
16271
- var SwellStorefrontCategory = class extends SwellStorefrontRecord {
16379
+ var SwellStorefrontCategory = class extends StorefrontResource {
16272
16380
  constructor(instance, id, query) {
16273
- super(instance.swell, "categories", id, query, async () => {
16381
+ super(async () => {
16274
16382
  const category = new SwellStorefrontRecord(
16275
16383
  instance.swell,
16276
16384
  "categories",
@@ -16311,8 +16419,168 @@ var SwellStorefrontProducts = class extends SwellStorefrontCollection {
16311
16419
  }
16312
16420
  };
16313
16421
 
16422
+ // src/compatibility/drops/images.ts
16423
+ var import_liquidjs7 = require("liquidjs");
16424
+ var ImagesDrop = class extends import_liquidjs7.Drop {
16425
+ #instance;
16426
+ #map;
16427
+ constructor(instance) {
16428
+ super();
16429
+ this.#instance = instance;
16430
+ this.#map = /* @__PURE__ */ new Map();
16431
+ }
16432
+ liquidMethodMissing(key) {
16433
+ switch (typeof key) {
16434
+ case "string": {
16435
+ return this.getImage(key);
16436
+ }
16437
+ case "object": {
16438
+ if (key !== null) {
16439
+ const obj = key;
16440
+ const id = obj.handle || obj.id || obj._id;
16441
+ if (isLikePromise(id)) {
16442
+ return id.then((id2) => this.getImage(id2));
16443
+ }
16444
+ return this.getImage(id);
16445
+ }
16446
+ break;
16447
+ }
16448
+ default:
16449
+ break;
16450
+ }
16451
+ }
16452
+ getImage(name) {
16453
+ let resource = this.#map.get(name);
16454
+ if (resource === void 0) {
16455
+ resource = ShopifyImage(new SwellImage(this.#instance.swell, name));
16456
+ this.#map.set(name, resource);
16457
+ }
16458
+ return resource;
16459
+ }
16460
+ };
16461
+ var SwellImage = class extends StorefrontResource {
16462
+ constructor(swell, name) {
16463
+ super(async () => {
16464
+ const files = await swell.get("/:files", {
16465
+ private: { $ne: true },
16466
+ content_type: { $regex: "^image/" },
16467
+ filename: name
16468
+ });
16469
+ const file = files?.results[0] ?? null;
16470
+ if (file === null) {
16471
+ return null;
16472
+ }
16473
+ return { file };
16474
+ });
16475
+ }
16476
+ };
16477
+
16478
+ // src/compatibility/drops/object-handles.ts
16479
+ var import_liquidjs8 = require("liquidjs");
16480
+ var ObjectHandlesDrop = class extends import_liquidjs8.Drop {
16481
+ #map;
16482
+ constructor(map) {
16483
+ super();
16484
+ switch (typeof map) {
16485
+ case "object": {
16486
+ if (map === null) {
16487
+ this.#map = /* @__PURE__ */ new Map();
16488
+ break;
16489
+ }
16490
+ this.#map = new Map(
16491
+ map instanceof Map ? map : Object.entries(map)
16492
+ );
16493
+ break;
16494
+ }
16495
+ default:
16496
+ this.#map = /* @__PURE__ */ new Map();
16497
+ break;
16498
+ }
16499
+ }
16500
+ liquidMethodMissing(key) {
16501
+ switch (typeof key) {
16502
+ case "string":
16503
+ return this.#map.get(key);
16504
+ case "object": {
16505
+ if (key !== null && "handle" in key) {
16506
+ const { handle } = key;
16507
+ if (typeof handle === "string") {
16508
+ return this.#map.get(handle);
16509
+ }
16510
+ }
16511
+ break;
16512
+ }
16513
+ default:
16514
+ break;
16515
+ }
16516
+ }
16517
+ };
16518
+
16519
+ // src/compatibility/drops/pages.ts
16520
+ var import_liquidjs9 = require("liquidjs");
16521
+ var PagesDrop = class extends import_liquidjs9.Drop {
16522
+ #instance;
16523
+ #map;
16524
+ constructor(instance) {
16525
+ super();
16526
+ this.#instance = instance;
16527
+ this.#map = /* @__PURE__ */ new Map();
16528
+ }
16529
+ liquidMethodMissing(key) {
16530
+ switch (typeof key) {
16531
+ case "string": {
16532
+ return this.getPage(key);
16533
+ }
16534
+ case "object": {
16535
+ if (key !== null) {
16536
+ const obj = key;
16537
+ const id = obj.handle || obj.id || obj._id;
16538
+ if (isLikePromise(id)) {
16539
+ return id.then((id2) => this.getPage(id2));
16540
+ }
16541
+ return this.getPage(id);
16542
+ }
16543
+ break;
16544
+ }
16545
+ default:
16546
+ break;
16547
+ }
16548
+ }
16549
+ getPage(slug) {
16550
+ let resource = this.#map.get(slug);
16551
+ if (resource === void 0) {
16552
+ resource = ShopifyPage(
16553
+ this.#instance,
16554
+ new SwellStorefrontRecord(this.#instance.swell, "content/pages", slug)
16555
+ );
16556
+ this.#map.set(slug, resource);
16557
+ }
16558
+ return resource;
16559
+ }
16560
+ };
16561
+ var Pages = class extends SwellStorefrontCollection {
16562
+ #drop;
16563
+ constructor(instance) {
16564
+ super(instance.swell, "content/pages", {}, async () => {
16565
+ const response = await this._defaultGetter().call(this);
16566
+ if (!response) {
16567
+ return null;
16568
+ }
16569
+ return {
16570
+ ...response,
16571
+ page_count: response.page_count || 0,
16572
+ results: response.results.map((page) => ShopifyPage(instance, page))
16573
+ };
16574
+ });
16575
+ this.#drop = new PagesDrop(instance);
16576
+ }
16577
+ toLiquid() {
16578
+ return this.#drop;
16579
+ }
16580
+ };
16581
+
16314
16582
  // src/compatibility/shopify.ts
16315
- var ShopifyCompatibility3 = class {
16583
+ var ShopifyCompatibility2 = class {
16316
16584
  theme;
16317
16585
  swell;
16318
16586
  pageId;
@@ -16333,9 +16601,25 @@ var ShopifyCompatibility3 = class {
16333
16601
  }
16334
16602
  initGlobals(globals) {
16335
16603
  const { request, page } = globals;
16604
+ globals.additional_checkout_buttons = false;
16605
+ globals.all_products = new AllProductsDrop(this);
16606
+ globals.articles = new ArticlesDrop(this);
16607
+ globals.blogs = new BlogsDrop(this);
16608
+ globals.closest = {};
16609
+ globals.collections = new Collections(this);
16610
+ globals.content_for_additional_checkout_buttons = "";
16611
+ globals.content_for_header = "";
16612
+ globals.content_for_index = "";
16613
+ globals.content_for_layout = "";
16614
+ globals.current_page = this.swell.queryParams.page || 1;
16615
+ globals.images = new ImagesDrop(this);
16616
+ globals.linklists = null;
16617
+ globals.localization = null;
16618
+ globals.metaobjects = {};
16336
16619
  globals.page = {
16337
16620
  ...page || void 0
16338
16621
  };
16622
+ globals.pages = new Pages(this);
16339
16623
  globals.request = {
16340
16624
  ...request || void 0,
16341
16625
  design_mode: this.swell.isEditor,
@@ -16343,9 +16627,11 @@ var ShopifyCompatibility3 = class {
16343
16627
  // TODO: Add support for visual section preview
16344
16628
  page_type: page?.id
16345
16629
  };
16346
- globals.collections = new CollectionsDrop(this);
16347
- globals.current_page = this.swell.queryParams.page || 1;
16348
16630
  globals.routes = this.getPageRoutes();
16631
+ globals.scripts = {};
16632
+ globals.shop = null;
16633
+ globals.template = {};
16634
+ globals.theme = {};
16349
16635
  }
16350
16636
  adaptGlobals(globals, prevGlobals) {
16351
16637
  if (globals.page) {
@@ -16366,11 +16652,6 @@ var ShopifyCompatibility3 = class {
16366
16652
  if (globals.menus) {
16367
16653
  globals.linklists = new ObjectHandlesDrop(globals.menus);
16368
16654
  }
16369
- if (globals.geo) {
16370
- const countryOptions = this.getAllCountryOptionTags(globals.geo);
16371
- globals.all_country_option_tags = countryOptions;
16372
- globals.country_option_tags = countryOptions;
16373
- }
16374
16655
  if (globals.store) {
16375
16656
  globals.shop = this.getShopData(globals.store);
16376
16657
  const request = globals.request || prevGlobals.request;
@@ -16882,20 +17163,6 @@ ${injects.join("\n")}</script>`;
16882
17163
  }
16883
17164
  ];
16884
17165
  }
16885
- getAllCountryOptionTags(geoSettings) {
16886
- if (!geoSettings) {
16887
- return "";
16888
- }
16889
- return geoSettings.countries?.map((country) => {
16890
- if (!country) return "";
16891
- const provinces = (geoSettings.states || []).filter((state) => state.country === country.id).map((state) => [state.id, state.name]);
16892
- const provincesEncoded = JSON.stringify(provinces).replace(
16893
- /"/g,
16894
- "&quot;"
16895
- );
16896
- return `<option value="${country.id}" data-provinces="${provincesEncoded}">${country.name}</option>`;
16897
- }).filter(Boolean).join("\n");
16898
- }
16899
17166
  // returns true if this URL is used for script actions
16900
17167
  isScriptFormActionUrl(url) {
16901
17168
  if (!url) {
@@ -16951,25 +17218,41 @@ function ShopifyTemplate(_instance, template) {
16951
17218
  );
16952
17219
  }
16953
17220
 
16954
- // src/compatibility/drops/render.ts
16955
- var import_liquidjs5 = require("liquidjs");
16956
- var RenderDrop = class extends import_liquidjs5.Drop {
17221
+ // src/liquid/drops/render.ts
17222
+ var import_liquidjs10 = require("liquidjs");
17223
+ var import_lodash_es8 = require("lodash-es");
17224
+ var RenderDrop = class extends import_liquidjs10.Drop {
17225
+ #result;
17226
+ #handler;
16957
17227
  constructor(handler) {
16958
17228
  super();
16959
- this.handler = handler;
17229
+ this.#result = void 0;
17230
+ this.#handler = handler;
16960
17231
  }
16961
- valueOf() {
16962
- return this.handler();
17232
+ /**
17233
+ * For `Drop` we usually use `valueOf` to convert the `object` to a `string`.
17234
+ * Use `then` instead of `valueOf` since `valueOf` doesn't work for `Promise`.
17235
+ */
17236
+ then(onfulfilled, onrejected) {
17237
+ if (this.#handler !== import_lodash_es8.noop) {
17238
+ this.#result = Promise.resolve().then(this.#handler).then((result) => {
17239
+ this.#result = result;
17240
+ return this.#result;
17241
+ }).then(onfulfilled, onrejected);
17242
+ this.#handler = import_lodash_es8.noop;
17243
+ return;
17244
+ }
17245
+ onfulfilled(this.#result);
16963
17246
  }
16964
17247
  };
16965
17248
 
16966
17249
  // src/liquid/index.ts
16967
- var import_liquidjs25 = require("liquidjs");
17250
+ var import_liquidjs30 = require("liquidjs");
16968
17251
 
16969
17252
  // src/liquid/tags/assign.ts
16970
- var import_liquidjs6 = require("liquidjs");
17253
+ var import_liquidjs11 = require("liquidjs");
16971
17254
  function bind(_liquidSwell) {
16972
- return class AssignTag extends import_liquidjs6.Tag {
17255
+ return class AssignTag extends import_liquidjs11.Tag {
16973
17256
  key;
16974
17257
  value;
16975
17258
  identifier;
@@ -16981,7 +17264,7 @@ function bind(_liquidSwell) {
16981
17264
  this.tokenizer.skipBlank();
16982
17265
  this.tokenizer.advance();
16983
17266
  try {
16984
- this.value = new import_liquidjs6.Value(this.tokenizer.readFilteredValue(), this.liquid);
17267
+ this.value = new import_liquidjs11.Value(this.tokenizer.readFilteredValue(), this.liquid);
16985
17268
  } catch (e) {
16986
17269
  console.warn(
16987
17270
  `Liquid "assign" tag: ${e instanceof Error ? e.stack : String(e)}`
@@ -17008,9 +17291,9 @@ function bind(_liquidSwell) {
17008
17291
  }
17009
17292
 
17010
17293
  // src/liquid/tags/case.ts
17011
- var import_liquidjs7 = require("liquidjs");
17294
+ var import_liquidjs12 = require("liquidjs");
17012
17295
  function bind2(liquidSwell) {
17013
- return class CaseTag extends import_liquidjs7.Tag {
17296
+ return class CaseTag extends import_liquidjs12.Tag {
17014
17297
  value;
17015
17298
  branches;
17016
17299
  elseTemplates;
@@ -17021,7 +17304,7 @@ function bind2(liquidSwell) {
17021
17304
  const caseVar = this.tokenizer.readValue()?.getText();
17022
17305
  this.isBlock = Boolean(caseVar?.startsWith("block."));
17023
17306
  this.tokenizer.p = begin;
17024
- this.value = new import_liquidjs7.Value(this.tokenizer.readFilteredValue(), this.liquid);
17307
+ this.value = new import_liquidjs12.Value(this.tokenizer.readFilteredValue(), this.liquid);
17025
17308
  this.branches = [];
17026
17309
  this.elseTemplates = [];
17027
17310
  let p = [];
@@ -17059,12 +17342,12 @@ function bind2(liquidSwell) {
17059
17342
  }
17060
17343
  *render(ctx, emitter) {
17061
17344
  const r = this.liquid.renderer;
17062
- const target = (0, import_liquidjs7.toValue)(yield this.value.value(ctx, ctx.opts.lenientIf));
17345
+ const target = (0, import_liquidjs12.toValue)(yield this.value.value(ctx, ctx.opts.lenientIf));
17063
17346
  let branchHit = false;
17064
17347
  let output = "";
17065
17348
  for (const branch of this.branches) {
17066
17349
  for (const valueToken of branch.values) {
17067
- const value = yield (0, import_liquidjs7.evalToken)(valueToken, ctx, ctx.opts.lenientIf);
17350
+ const value = yield (0, import_liquidjs12.evalToken)(valueToken, ctx, ctx.opts.lenientIf);
17068
17351
  if (target === value) {
17069
17352
  const blockOutput = yield r.renderTemplates(branch.templates, ctx);
17070
17353
  output += this.isBlock && liquidSwell.isEditor ? `<span class="swell-block">${blockOutput}</span>` : blockOutput;
@@ -17097,15 +17380,15 @@ function bind2(liquidSwell) {
17097
17380
  }
17098
17381
 
17099
17382
  // src/liquid/tags/comment.ts
17100
- var import_liquidjs8 = require("liquidjs");
17383
+ var import_liquidjs13 = require("liquidjs");
17101
17384
  function bind3(_liquidSwell) {
17102
- return class CommentTag extends import_liquidjs8.Tag {
17385
+ return class CommentTag extends import_liquidjs13.Tag {
17103
17386
  constructor(tagToken, remainTokens, liquid) {
17104
17387
  super(tagToken, remainTokens, liquid);
17105
17388
  let nested = 1;
17106
17389
  while (remainTokens.length > 0) {
17107
17390
  const token = remainTokens.shift();
17108
- if (import_liquidjs8.TypeGuards.isTagToken(token)) {
17391
+ if (import_liquidjs13.TypeGuards.isTagToken(token)) {
17109
17392
  switch (token.name) {
17110
17393
  case "comment":
17111
17394
  nested += 1;
@@ -17130,20 +17413,22 @@ function bind3(_liquidSwell) {
17130
17413
  }
17131
17414
 
17132
17415
  // src/liquid/tags/for.ts
17133
- var import_liquidjs9 = require("liquidjs");
17416
+ var import_liquidjs14 = require("liquidjs");
17134
17417
  var MODIFIERS = Object.freeze(["offset", "limit", "reversed"]);
17135
17418
  function bind4(_liquidSwell) {
17136
- return class ForTag extends import_liquidjs9.ForTag {
17419
+ return class ForTag extends import_liquidjs14.ForTag {
17137
17420
  *render(ctx, emitter) {
17138
17421
  const r = this.liquid.renderer;
17139
- let collection = yield (0, import_liquidjs9.evalToken)(this.collection, ctx);
17422
+ let collection = yield (0, import_liquidjs14.evalToken)(this.collection, ctx);
17140
17423
  collection = yield resolveEnumerable(collection);
17141
17424
  if (!collection.length) {
17142
17425
  yield r.renderTemplates(this.elseTemplates, ctx, emitter);
17143
17426
  return;
17144
17427
  }
17145
17428
  const continueKey = "continue-" + this.variable + "-" + this.collection.getText();
17146
- ctx.push({ continue: ctx.getRegister(continueKey) });
17429
+ ctx.push({
17430
+ continue: ctx.getRegister(continueKey)
17431
+ });
17147
17432
  const hash = yield this.hash.render(ctx);
17148
17433
  ctx.pop();
17149
17434
  const modifiers = this.liquid.options.orderedFilterParameters ? Object.keys(hash).filter((x) => MODIFIERS.includes(x)) : MODIFIERS.filter((x) => hash[x] !== void 0);
@@ -17159,23 +17444,29 @@ function bind4(_liquidSwell) {
17159
17444
  return collection2;
17160
17445
  }
17161
17446
  }, collection);
17162
- ctx.setRegister(continueKey, (hash["offset"] || 0) + collection.length);
17447
+ const length = Math.min(collection.length, 50);
17448
+ const parent = ctx.getRegister("parentloop");
17449
+ ctx.setRegister(continueKey, (hash["offset"] || 0) + length);
17450
+ const forloop = new ForloopDrop(
17451
+ length,
17452
+ this.collection.getText(),
17453
+ this.variable,
17454
+ parent
17455
+ );
17163
17456
  const scope = {
17164
- forloop: new ForloopDrop(
17165
- collection.length,
17166
- this.collection.getText(),
17167
- this.variable
17168
- )
17457
+ forloop
17169
17458
  };
17170
17459
  ctx.push(scope);
17171
- for (const item of collection) {
17172
- scope[this.variable] = item;
17460
+ ctx.setRegister("parentloop", forloop);
17461
+ for (let i = 0; i < length; ++i) {
17462
+ scope[this.variable] = collection[i];
17173
17463
  ctx.continueCalled = ctx.breakCalled = false;
17174
17464
  yield r.renderTemplates(this.templates, ctx, emitter);
17175
17465
  if (ctx.breakCalled) break;
17176
17466
  scope.forloop.next();
17177
17467
  }
17178
17468
  ctx.continueCalled = ctx.breakCalled = false;
17469
+ ctx.setRegister("parentloop", parent);
17179
17470
  ctx.pop();
17180
17471
  }
17181
17472
  };
@@ -17191,10 +17482,10 @@ function limit(arr, count) {
17191
17482
  }
17192
17483
 
17193
17484
  // src/liquid/tags/form.ts
17194
- var import_liquidjs10 = require("liquidjs");
17485
+ var import_liquidjs15 = require("liquidjs");
17195
17486
  var IGNORED_SHOPIFY_FORMS = Object.freeze(["new_comment", "guest_login"]);
17196
17487
  function bind5(liquidSwell) {
17197
- return class FormTag extends import_liquidjs10.Tag {
17488
+ return class FormTag extends import_liquidjs15.Tag {
17198
17489
  formType;
17199
17490
  formConfig;
17200
17491
  templates;
@@ -17208,10 +17499,10 @@ function bind5(liquidSwell) {
17208
17499
  tokenizer.advance();
17209
17500
  this.arg = tokenizer.readValue();
17210
17501
  this.templates = [];
17211
- this.hash = new import_liquidjs10.Hash(this.tokenizer.remaining());
17502
+ this.hash = new import_liquidjs15.Hash(this.tokenizer.remaining());
17212
17503
  while (remainTokens.length > 0) {
17213
17504
  const token2 = remainTokens.shift();
17214
- if (import_liquidjs10.TypeGuards.isTagToken(token2) && token2.name === "endform") {
17505
+ if (import_liquidjs15.TypeGuards.isTagToken(token2) && token2.name === "endform") {
17215
17506
  return;
17216
17507
  }
17217
17508
  this.templates.push(parser.parseToken(token2, remainTokens));
@@ -17229,7 +17520,7 @@ function bind5(liquidSwell) {
17229
17520
  return;
17230
17521
  }
17231
17522
  const r = this.liquid.renderer;
17232
- const arg = yield (0, import_liquidjs10.evalToken)(this.arg, ctx);
17523
+ const arg = yield (0, import_liquidjs15.evalToken)(this.arg, ctx);
17233
17524
  const hash = yield this.hash.render(ctx);
17234
17525
  const scope = ctx.getAll();
17235
17526
  const attrs = " " + Object.entries(hash).reduce((acc, [key, value]) => {
@@ -17284,14 +17575,15 @@ function bind5(liquidSwell) {
17284
17575
  ${html}
17285
17576
  </form>
17286
17577
  `);
17578
+ ctx.pop();
17287
17579
  }
17288
17580
  };
17289
17581
  }
17290
17582
 
17291
17583
  // src/liquid/tags/if.ts
17292
- var import_liquidjs11 = require("liquidjs");
17584
+ var import_liquidjs16 = require("liquidjs");
17293
17585
  function bind6(_liquidSwell) {
17294
- return class IfTag extends import_liquidjs11.Tag {
17586
+ return class IfTag extends import_liquidjs16.Tag {
17295
17587
  branches = [];
17296
17588
  elseTemplates;
17297
17589
  constructor(tagToken, remainTokens, liquid, parser) {
@@ -17300,22 +17592,22 @@ function bind6(_liquidSwell) {
17300
17592
  parser.parseStream(remainTokens).on(
17301
17593
  "start",
17302
17594
  () => this.branches.push({
17303
- value: new import_liquidjs11.Value(
17595
+ value: new import_liquidjs16.Value(
17304
17596
  tagToken.tokenizer.readFilteredValue(),
17305
17597
  this.liquid
17306
17598
  ),
17307
17599
  templates: p = []
17308
17600
  })
17309
17601
  ).on("tag:elsif", (token) => {
17310
- (0, import_liquidjs11.assert)(!this.elseTemplates, "unexpected elsif after else");
17602
+ (0, import_liquidjs16.assert)(!this.elseTemplates, "unexpected elsif after else");
17311
17603
  this.branches.push({
17312
- value: new import_liquidjs11.Value(token.tokenizer.readFilteredValue(), this.liquid),
17604
+ value: new import_liquidjs16.Value(token.tokenizer.readFilteredValue(), this.liquid),
17313
17605
  templates: p = []
17314
17606
  });
17315
17607
  }).on("tag:else", (tag) => {
17316
17608
  if (tag.args.length > 0) {
17317
17609
  this.branches.push({
17318
- value: new import_liquidjs11.Value(tag.tokenizer.readFilteredValue(), this.liquid),
17610
+ value: new import_liquidjs16.Value(tag.tokenizer.readFilteredValue(), this.liquid),
17319
17611
  templates: p = []
17320
17612
  });
17321
17613
  } else {
@@ -17333,7 +17625,7 @@ function bind6(_liquidSwell) {
17333
17625
  const r = this.liquid.renderer;
17334
17626
  for (const { value, templates } of this.branches) {
17335
17627
  const v = yield value.value(ctx, ctx.opts.lenientIf);
17336
- if ((0, import_liquidjs11.isTruthy)(v, ctx)) {
17628
+ if ((0, import_liquidjs16.isTruthy)(v, ctx)) {
17337
17629
  yield r.renderTemplates(templates, ctx, emitter);
17338
17630
  return;
17339
17631
  }
@@ -17354,20 +17646,20 @@ function bind6(_liquidSwell) {
17354
17646
  };
17355
17647
  }
17356
17648
  function assertEmpty(predicate, message = `unexpected ${JSON.stringify(predicate)}`) {
17357
- (0, import_liquidjs11.assert)(!predicate, message);
17649
+ (0, import_liquidjs16.assert)(!predicate, message);
17358
17650
  }
17359
17651
 
17360
17652
  // src/liquid/tags/javascript.ts
17361
- var import_liquidjs12 = require("liquidjs");
17653
+ var import_liquidjs17 = require("liquidjs");
17362
17654
  function bind7(_liquidSwell) {
17363
- return class JavascriptTag extends import_liquidjs12.Tag {
17655
+ return class JavascriptTag extends import_liquidjs17.Tag {
17364
17656
  templates;
17365
17657
  constructor(token, remainTokens, liquid, parser) {
17366
17658
  super(token, remainTokens, liquid);
17367
17659
  this.templates = [];
17368
17660
  while (remainTokens.length > 0) {
17369
17661
  const token2 = remainTokens.shift();
17370
- if (import_liquidjs12.TypeGuards.isTagToken(token2) && token2.name === "endjavascript") {
17662
+ if (import_liquidjs17.TypeGuards.isTagToken(token2) && token2.name === "endjavascript") {
17371
17663
  return;
17372
17664
  }
17373
17665
  this.templates.push(parser.parseToken(token2, remainTokens));
@@ -17385,9 +17677,9 @@ function bind7(_liquidSwell) {
17385
17677
  }
17386
17678
 
17387
17679
  // src/liquid/tags/layout.ts
17388
- var import_liquidjs13 = require("liquidjs");
17680
+ var import_liquidjs18 = require("liquidjs");
17389
17681
  function bind8(liquidSwell) {
17390
- return class LayoutTag extends import_liquidjs13.Tag {
17682
+ return class LayoutTag extends import_liquidjs18.Tag {
17391
17683
  fileName;
17392
17684
  constructor(token, remainTokens, liquid, _parser) {
17393
17685
  super(token, remainTokens, liquid);
@@ -17403,9 +17695,9 @@ function bind8(liquidSwell) {
17403
17695
  }
17404
17696
 
17405
17697
  // src/liquid/tags/paginate.ts
17406
- var import_liquidjs14 = require("liquidjs");
17698
+ var import_liquidjs19 = require("liquidjs");
17407
17699
  function bind9(liquidSwell) {
17408
- return class PaginateTag extends import_liquidjs14.Tag {
17700
+ return class PaginateTag extends import_liquidjs19.Tag {
17409
17701
  collection;
17410
17702
  pageSize;
17411
17703
  templates;
@@ -17420,7 +17712,7 @@ function bind9(liquidSwell) {
17420
17712
  }
17421
17713
  this.templates = [];
17422
17714
  this.collection = collection;
17423
- this.hash = new import_liquidjs14.Hash(this.tokenizer.remaining());
17715
+ this.hash = new import_liquidjs19.Hash(this.tokenizer.remaining());
17424
17716
  const stream = parser.parseStream(remainTokens).on("tag:endpaginate", () => stream.stop()).on("template", (tpl) => {
17425
17717
  this.templates.push(tpl);
17426
17718
  }).on("end", () => {
@@ -17430,10 +17722,10 @@ function bind9(liquidSwell) {
17430
17722
  }
17431
17723
  *render(ctx, emitter) {
17432
17724
  const r = this.liquid.renderer;
17433
- const collection = yield (0, import_liquidjs14.evalToken)(this.collection, ctx);
17434
- const pageSize = Number(yield (0, import_liquidjs14.evalToken)(this.pageSize, ctx));
17725
+ const collection = yield (0, import_liquidjs19.evalToken)(this.collection, ctx);
17726
+ const pageSize = Number(yield (0, import_liquidjs19.evalToken)(this.pageSize, ctx));
17435
17727
  const hash = yield this.hash.render(ctx);
17436
- if (!Number.isNaN(pageSize) && collection instanceof SwellStorefrontCollection && collection.limit != pageSize) {
17728
+ if (!Number.isNaN(pageSize) && collection instanceof SwellStorefrontCollection && collection.limit !== pageSize) {
17437
17729
  yield collection._get({
17438
17730
  limit: pageSize,
17439
17731
  window: hash.window_size || void 0
@@ -17449,15 +17741,18 @@ function bind9(liquidSwell) {
17449
17741
  ctx.push({ paginate });
17450
17742
  }
17451
17743
  yield r.renderTemplates(this.templates, ctx, emitter);
17744
+ if (collection) {
17745
+ ctx.pop();
17746
+ }
17452
17747
  }
17453
17748
  };
17454
17749
  }
17455
17750
 
17456
17751
  // src/liquid/tags/render.ts
17457
- var import_lodash_es8 = require("lodash-es");
17458
- var import_liquidjs15 = require("liquidjs");
17752
+ var import_lodash_es9 = require("lodash-es");
17753
+ var import_liquidjs20 = require("liquidjs");
17459
17754
  function bind10(liquidSwell) {
17460
- return class RenderTag extends import_liquidjs15.RenderTag {
17755
+ return class RenderTag extends import_liquidjs20.RenderTag {
17461
17756
  *render(ctx, emitter) {
17462
17757
  const { liquid, hash } = this;
17463
17758
  const filepath = yield renderFilePath(
@@ -17465,23 +17760,23 @@ function bind10(liquidSwell) {
17465
17760
  ctx,
17466
17761
  liquid
17467
17762
  );
17468
- (0, import_liquidjs15.assert)(filepath, () => `illegal file path "${filepath}"`);
17763
+ (0, import_liquidjs20.assert)(filepath, () => `illegal file path "${filepath}"`);
17469
17764
  const themeConfig = yield liquidSwell.getComponentPath(filepath).then(
17470
17765
  (fileName) => liquidSwell.getThemeConfig(fileName)
17471
17766
  );
17472
17767
  const childCtx = ctx.spawn();
17473
17768
  const scope = childCtx.bottom();
17474
- (0, import_lodash_es8.assign)(scope, yield hash.render(ctx));
17769
+ (0, import_lodash_es9.assign)(scope, yield hash.render(ctx));
17475
17770
  const parentSection = yield ctx._get(["section"]);
17476
- if (parentSection) (0, import_lodash_es8.assign)(scope, { section: parentSection });
17771
+ if (parentSection) (0, import_lodash_es9.assign)(scope, { section: parentSection });
17477
17772
  if (this["with"]) {
17478
17773
  const { value, alias } = this["with"];
17479
17774
  const aliasName = alias || filepath;
17480
- scope[aliasName] = yield (0, import_liquidjs15.evalToken)(value, ctx);
17775
+ scope[aliasName] = yield (0, import_liquidjs20.evalToken)(value, ctx);
17481
17776
  }
17482
17777
  if (this["for"]) {
17483
17778
  const { value, alias } = this["for"];
17484
- let collection = yield (0, import_liquidjs15.evalToken)(value, ctx);
17779
+ let collection = yield (0, import_liquidjs20.evalToken)(value, ctx);
17485
17780
  collection = yield resolveEnumerable(collection);
17486
17781
  scope["forloop"] = new ForloopDrop(
17487
17782
  collection.length,
@@ -17514,13 +17809,13 @@ function* renderFilePath(file, ctx, liquid) {
17514
17809
  default:
17515
17810
  break;
17516
17811
  }
17517
- return yield (0, import_liquidjs15.evalToken)(file, ctx);
17812
+ return yield (0, import_liquidjs20.evalToken)(file, ctx);
17518
17813
  }
17519
17814
 
17520
17815
  // src/liquid/tags/section.ts
17521
- var import_liquidjs16 = require("liquidjs");
17816
+ var import_liquidjs21 = require("liquidjs");
17522
17817
  function bind11(liquidSwell) {
17523
- return class SectionTag extends import_liquidjs16.Tag {
17818
+ return class SectionTag extends import_liquidjs21.Tag {
17524
17819
  fileName;
17525
17820
  constructor(token, remainTokens, liquid, _parser) {
17526
17821
  super(token, remainTokens, liquid);
@@ -17552,7 +17847,8 @@ function bind11(liquidSwell) {
17552
17847
  section: {
17553
17848
  id: this.fileName,
17554
17849
  settings: { ...defaultSettings, blocks: void 0 },
17555
- blocks: defaultSettings.blocks
17850
+ blocks: defaultSettings.blocks,
17851
+ location: "static"
17556
17852
  }
17557
17853
  });
17558
17854
  });
@@ -17570,10 +17866,10 @@ function bind11(liquidSwell) {
17570
17866
  }
17571
17867
 
17572
17868
  // src/liquid/tags/sections.ts
17573
- var import_liquidjs17 = require("liquidjs");
17869
+ var import_liquidjs22 = require("liquidjs");
17574
17870
  var import_json54 = __toESM(require("json5"), 1);
17575
17871
  function bind12(liquidSwell) {
17576
- return class SectionsTag extends import_liquidjs17.Tag {
17872
+ return class SectionsTag extends import_liquidjs22.Tag {
17577
17873
  fileName;
17578
17874
  constructor(token, remainTokens, liquid, _parser) {
17579
17875
  super(token, remainTokens, liquid);
@@ -17612,9 +17908,9 @@ function bind12(liquidSwell) {
17612
17908
  }
17613
17909
 
17614
17910
  // src/liquid/tags/style.ts
17615
- var import_liquidjs18 = require("liquidjs");
17911
+ var import_liquidjs23 = require("liquidjs");
17616
17912
  function bind13(_liquidSwell) {
17617
- return class StyleTag extends import_liquidjs18.Tag {
17913
+ return class StyleTag extends import_liquidjs23.Tag {
17618
17914
  templates;
17619
17915
  hash;
17620
17916
  constructor(token, remainTokens, liquid, parser) {
@@ -17623,7 +17919,7 @@ function bind13(_liquidSwell) {
17623
17919
  const tagBegin = token.begin;
17624
17920
  while (remainTokens.length > 0) {
17625
17921
  const token2 = remainTokens.shift();
17626
- if (import_liquidjs18.TypeGuards.isTagToken(token2) && token2.name === "endstyle") {
17922
+ if (import_liquidjs23.TypeGuards.isTagToken(token2) && token2.name === "endstyle") {
17627
17923
  this.hash = md5(token2.input.slice(tagBegin, token2.end));
17628
17924
  return;
17629
17925
  }
@@ -17646,16 +17942,16 @@ function bind13(_liquidSwell) {
17646
17942
  }
17647
17943
 
17648
17944
  // src/liquid/tags/stylesheet.ts
17649
- var import_liquidjs19 = require("liquidjs");
17945
+ var import_liquidjs24 = require("liquidjs");
17650
17946
  function bind14(_liquidSwell) {
17651
- return class StyleSheetTag extends import_liquidjs19.Tag {
17947
+ return class StyleSheetTag extends import_liquidjs24.Tag {
17652
17948
  templates;
17653
17949
  constructor(token, remainTokens, liquid, parser) {
17654
17950
  super(token, remainTokens, liquid);
17655
17951
  this.templates = [];
17656
17952
  while (remainTokens.length > 0) {
17657
17953
  const token2 = remainTokens.shift();
17658
- if (import_liquidjs19.TypeGuards.isTagToken(token2) && token2.name === "endstylesheet") {
17954
+ if (import_liquidjs24.TypeGuards.isTagToken(token2) && token2.name === "endstylesheet") {
17659
17955
  return;
17660
17956
  }
17661
17957
  this.templates.push(parser.parseToken(token2, remainTokens));
@@ -17671,9 +17967,9 @@ function bind14(_liquidSwell) {
17671
17967
  }
17672
17968
 
17673
17969
  // src/liquid/tags/shopify/include.ts
17674
- var import_liquidjs20 = require("liquidjs");
17970
+ var import_liquidjs25 = require("liquidjs");
17675
17971
  function bind15(liquidSwell) {
17676
- return class IncludeTag extends import_liquidjs20.IncludeTag {
17972
+ return class IncludeTag extends import_liquidjs25.IncludeTag {
17677
17973
  *render(ctx, emitter) {
17678
17974
  const { hash } = this;
17679
17975
  const filepath = yield renderFilePath(
@@ -17681,13 +17977,13 @@ function bind15(liquidSwell) {
17681
17977
  ctx,
17682
17978
  this.liquid
17683
17979
  );
17684
- (0, import_liquidjs20.assert)(filepath, () => `illegal file path "${filepath}"`);
17980
+ (0, import_liquidjs25.assert)(filepath, () => `illegal file path "${filepath}"`);
17685
17981
  const saved = ctx.saveRegister("blocks", "blockMode");
17686
17982
  ctx.setRegister("blocks", {});
17687
17983
  ctx.setRegister("blockMode", 0);
17688
17984
  const scope = yield hash.render(ctx);
17689
17985
  if (this.withVar) {
17690
- scope[filepath] = yield (0, import_liquidjs20.evalToken)(this.withVar, ctx);
17986
+ scope[filepath] = yield (0, import_liquidjs25.evalToken)(this.withVar, ctx);
17691
17987
  }
17692
17988
  ctx.push(ctx.opts.jekyllInclude ? { include: scope } : scope);
17693
17989
  const output = yield liquidSwell.getComponentPath(filepath).then((path) => liquidSwell.getThemeConfig(path)).then((themeConfig) => liquidSwell.renderTemplate(themeConfig, scope));
@@ -17699,10 +17995,10 @@ function bind15(liquidSwell) {
17699
17995
  }
17700
17996
 
17701
17997
  // src/liquid/tags/shopify/schema.ts
17702
- var import_liquidjs21 = require("liquidjs");
17998
+ var import_liquidjs26 = require("liquidjs");
17703
17999
  var import_json55 = __toESM(require("json5"), 1);
17704
18000
  function bind16(liquidSwell) {
17705
- return class SchemaTag extends import_liquidjs21.Tag {
18001
+ return class SchemaTag extends import_liquidjs26.Tag {
17706
18002
  templates;
17707
18003
  constructor(token, remainTokens, liquid, parser) {
17708
18004
  super(token, remainTokens, liquid);
@@ -17735,9 +18031,9 @@ function bind16(liquidSwell) {
17735
18031
  }
17736
18032
 
17737
18033
  // src/liquid/tags/inline_editable.ts
17738
- var import_liquidjs22 = require("liquidjs");
18034
+ var import_liquidjs27 = require("liquidjs");
17739
18035
  function bind17(_liquidSwell) {
17740
- return class InlineEditableTag extends import_liquidjs22.Tag {
18036
+ return class InlineEditableTag extends import_liquidjs27.Tag {
17741
18037
  key;
17742
18038
  value;
17743
18039
  constructor(token, remainTokens, liquid, _parser) {
@@ -17989,12 +18285,12 @@ function bind35(_liquidSwell) {
17989
18285
  }
17990
18286
 
17991
18287
  // src/liquid/filters/embedded_content.ts
17992
- var import_lodash_es9 = require("lodash-es");
18288
+ var import_lodash_es10 = require("lodash-es");
17993
18289
  function bind36(_liquidSwell) {
17994
18290
  return (value, tag = "iframe") => {
17995
18291
  const escapeIframes = value.replaceAll(`<${tag}`, `&lt;${tag}`).replaceAll(`</${tag}`, `&lt;/${tag}`);
17996
18292
  const removeTags = escapeIframes.replaceAll(/<(.*?)>/gi, "");
17997
- const unescaped = (0, import_lodash_es9.unescape)(removeTags);
18293
+ const unescaped = (0, import_lodash_es10.unescape)(removeTags);
17998
18294
  const replaceSpaces = unescaped.replaceAll("&nbsp;", " ");
17999
18295
  return replaceSpaces;
18000
18296
  };
@@ -18069,10 +18365,10 @@ var format_address_default = {
18069
18365
  };
18070
18366
 
18071
18367
  // src/liquid/filters/handleize.ts
18072
- var import_lodash_es10 = require("lodash-es");
18368
+ var import_lodash_es11 = require("lodash-es");
18073
18369
  function bind40(_liquidSwell) {
18074
18370
  return function filterHandleize(handle) {
18075
- return (0, import_lodash_es10.kebabCase)(handle);
18371
+ return (0, import_lodash_es11.kebabCase)(handle);
18076
18372
  };
18077
18373
  }
18078
18374
 
@@ -18797,9 +19093,9 @@ async function resolveAsyncProps(propArg, resolveProps) {
18797
19093
  }
18798
19094
 
18799
19095
  // src/liquid/operators.ts
18800
- var import_liquidjs23 = require("liquidjs");
19096
+ var import_liquidjs28 = require("liquidjs");
18801
19097
  var swellOperators = {
18802
- ...import_liquidjs23.defaultOperators,
19098
+ ...import_liquidjs28.defaultOperators,
18803
19099
  "==": equal,
18804
19100
  "!=": (l, r) => !equal(l, r),
18805
19101
  contains: (l, r) => {
@@ -18826,8 +19122,8 @@ function arrayEqual(lhs, rhs) {
18826
19122
 
18827
19123
  // src/liquid/color.ts
18828
19124
  var import_color = __toESM(require("color"), 1);
18829
- var import_liquidjs24 = require("liquidjs");
18830
- var ThemeColor = class _ThemeColor extends import_liquidjs24.Drop {
19125
+ var import_liquidjs29 = require("liquidjs");
19126
+ var ThemeColor = class _ThemeColor extends import_liquidjs29.Drop {
18831
19127
  color;
18832
19128
  colorValues;
18833
19129
  red;
@@ -18962,7 +19258,7 @@ function isThemeColorLike(value) {
18962
19258
  }
18963
19259
 
18964
19260
  // src/liquid/index.ts
18965
- var LiquidSwell29 = class extends import_liquidjs25.Liquid {
19261
+ var LiquidSwell29 = class extends import_liquidjs30.Liquid {
18966
19262
  theme;
18967
19263
  getThemeConfig;
18968
19264
  getThemeTemplateConfigByType;
@@ -19441,6 +19737,161 @@ var ThemeLoader = class _ThemeLoader {
19441
19737
  }
19442
19738
  };
19443
19739
 
19740
+ // src/globals.ts
19741
+ var import_lodash_es12 = require("lodash-es");
19742
+
19743
+ // src/compatibility/drops/robots-rule.ts
19744
+ var import_liquidjs31 = require("liquidjs");
19745
+ var RobotsRule = class _RobotsRule extends import_liquidjs31.Drop {
19746
+ constructor(directive, value) {
19747
+ super();
19748
+ this.directive = directive;
19749
+ this.value = value;
19750
+ }
19751
+ static from(directive, value) {
19752
+ return new _RobotsRule(directive, value);
19753
+ }
19754
+ valueOf() {
19755
+ return `${this.directive}: ${this.value}
19756
+ `;
19757
+ }
19758
+ };
19759
+
19760
+ // src/globals.ts
19761
+ async function getFirstFilledValue(values) {
19762
+ for (const promise of values) {
19763
+ const value = await promise;
19764
+ if (value) {
19765
+ return value;
19766
+ }
19767
+ }
19768
+ }
19769
+ function getRecordGlobals(theme, record) {
19770
+ const globals = {};
19771
+ globals.handle = new RenderDrop(() => record.slug);
19772
+ globals.page_title = new RenderDrop(
19773
+ () => getFirstFilledValue([
19774
+ record.meta_title,
19775
+ // filled SEO
19776
+ record.name,
19777
+ // all records
19778
+ record.title,
19779
+ // content/pages, content/blogs, content/blog-categories
19780
+ theme.page?.title,
19781
+ // default page title
19782
+ theme.globals.store?.name
19783
+ // fallback to store name
19784
+ ])
19785
+ );
19786
+ globals.page_description = new RenderDrop(
19787
+ () => getFirstFilledValue([
19788
+ record.meta_description,
19789
+ // filled SEO
19790
+ record.description,
19791
+ // product and category
19792
+ record.summary,
19793
+ // content/blogs
19794
+ theme.page?.description
19795
+ ])
19796
+ );
19797
+ globals.page_image = new RenderDrop(
19798
+ () => getFirstFilledValue([
19799
+ record.images,
19800
+ // product and category
19801
+ record.image
19802
+ // article
19803
+ ]).then((images) => {
19804
+ if (typeof images !== "object" || images === null) {
19805
+ return;
19806
+ }
19807
+ const image = Array.isArray(images) ? images[0] : images;
19808
+ return image ? ShopifyImage(image) : void 0;
19809
+ })
19810
+ );
19811
+ return globals;
19812
+ }
19813
+ var POWERED_BY_LINK = '<a target="_blank" rel="nofollow" href="https://www.swell.is/?utm_campaign=poweredby&amp;utm_medium=swell&amp;utm_source=onlinestore">Powered by Swell</a>';
19814
+ function getAllCountryOptionTags(geoSettings) {
19815
+ if (!geoSettings) {
19816
+ return "";
19817
+ }
19818
+ const stateMap = (geoSettings.states || []).reduce((map, state) => {
19819
+ let list = map.get(state.country);
19820
+ if (list === void 0) {
19821
+ list = [];
19822
+ map.set(state.country, list);
19823
+ }
19824
+ list.push(state);
19825
+ return map;
19826
+ }, /* @__PURE__ */ new Map());
19827
+ return (geoSettings.countries || []).map((country) => {
19828
+ if (!country) return "";
19829
+ const provinces = (stateMap.get(country.id) || []).map((state) => [
19830
+ state.id,
19831
+ state.name
19832
+ ]);
19833
+ const provincesEncoded = JSON.stringify(provinces).replace(
19834
+ /"/g,
19835
+ "&quot;"
19836
+ );
19837
+ return `<option value="${country.id}" data-provinces="${provincesEncoded}">${country.name}</option>`;
19838
+ }).filter(Boolean).join("\n");
19839
+ }
19840
+ function getRobotsGlobals(canonicalUrl) {
19841
+ const sitemapUrl = `${(0, import_lodash_es12.trimEnd)(canonicalUrl, "/")}/sitemap.xml`;
19842
+ const defaultRules = [
19843
+ { directive: "Disallow", value: "/admin" },
19844
+ { directive: "Disallow", value: "/cart" },
19845
+ { directive: "Disallow", value: "/account" },
19846
+ { directive: "Disallow", value: "/search" },
19847
+ { directive: "Disallow", value: "/categories/*sort_by*" },
19848
+ { directive: "Disallow", value: "/*/categories/*sort_by*" }
19849
+ ];
19850
+ return {
19851
+ default_groups: [
19852
+ {
19853
+ user_agent: RobotsRule.from("User-agent", "*"),
19854
+ // sitemap: RobotsRule.from('Sitemap', sitemapUrl),
19855
+ rules: defaultRules.map(
19856
+ (rule) => RobotsRule.from(rule.directive, rule.value)
19857
+ )
19858
+ },
19859
+ {
19860
+ user_agent: RobotsRule.from("User-agent", "AhrefsBot"),
19861
+ // sitemap: RobotsRule.from('Sitemap', sitemapUrl),
19862
+ rules: [
19863
+ RobotsRule.from("Crawl-delay", "10"),
19864
+ ...defaultRules.map(
19865
+ (rule) => RobotsRule.from(rule.directive, rule.value)
19866
+ )
19867
+ ]
19868
+ },
19869
+ {
19870
+ user_agent: RobotsRule.from("User-agent", "AhrefsSiteAudit"),
19871
+ // sitemap: RobotsRule.from('Sitemap', sitemapUrl),
19872
+ rules: [
19873
+ RobotsRule.from("Crawl-delay", "10"),
19874
+ ...defaultRules.map(
19875
+ (rule) => RobotsRule.from(rule.directive, rule.value)
19876
+ )
19877
+ ]
19878
+ },
19879
+ {
19880
+ user_agent: RobotsRule.from("User-agent", "Nutch"),
19881
+ rules: [RobotsRule.from("Crawl-delay", "10")]
19882
+ },
19883
+ {
19884
+ user_agent: RobotsRule.from("User-agent", "MJ12bot"),
19885
+ rules: [RobotsRule.from("Crawl-delay", "10")]
19886
+ },
19887
+ {
19888
+ user_agent: RobotsRule.from("User-agent", "Pinterest"),
19889
+ rules: [RobotsRule.from("Crawl-delay", "1")]
19890
+ }
19891
+ ]
19892
+ };
19893
+ }
19894
+
19444
19895
  // src/theme.ts
19445
19896
  var SwellTheme3 = class {
19446
19897
  swell;
@@ -19454,7 +19905,7 @@ var SwellTheme3 = class {
19454
19905
  page;
19455
19906
  pageId;
19456
19907
  shopifyCompatibility = null;
19457
- shopifyCompatibilityClass = ShopifyCompatibility3;
19908
+ shopifyCompatibilityClass = ShopifyCompatibility2;
19458
19909
  shopifyCompatibilityConfig = null;
19459
19910
  formData = {};
19460
19911
  globalData = {};
@@ -19469,7 +19920,7 @@ var SwellTheme3 = class {
19469
19920
  this.globals = globals || {};
19470
19921
  this.forms = forms;
19471
19922
  this.resources = resources;
19472
- this.shopifyCompatibilityClass = shopifyCompatibilityClass || ShopifyCompatibility3;
19923
+ this.shopifyCompatibilityClass = shopifyCompatibilityClass || ShopifyCompatibility2;
19473
19924
  this.liquidSwell = new LiquidSwell29({
19474
19925
  theme: this,
19475
19926
  getThemeConfig: this.getThemeConfig.bind(this),
@@ -19487,8 +19938,10 @@ var SwellTheme3 = class {
19487
19938
  getSwellAppThemeProps(swellConfig) {
19488
19939
  return swellConfig?.storefront?.theme || {};
19489
19940
  }
19490
- async initGlobals(pageId, altTemplate) {
19941
+ async initGlobals(pageId, options) {
19491
19942
  this.pageId = pageId;
19943
+ const pageRecord = options?.pageRecord;
19944
+ const altTemplate = options?.altTemplate;
19492
19945
  const trace = createTraceId();
19493
19946
  logger.debug("[SDK] Theme init start", { page: pageId, trace });
19494
19947
  await this.themeLoader.init(this.themeConfigs || void 0);
@@ -19498,6 +19951,7 @@ var SwellTheme3 = class {
19498
19951
  const { settings, request, page, cart, account, customer } = await this.resolvePageData(store, configs, pageId, altTemplate);
19499
19952
  logger.debug("[SDK] Theme page data load done", { page: pageId, trace });
19500
19953
  this.page = page;
19954
+ const countryOptions = getAllCountryOptionTags(geo);
19501
19955
  const globals = {
19502
19956
  ...this.globalData,
19503
19957
  // return all storefront settings in the store
@@ -19513,10 +19967,24 @@ var SwellTheme3 = class {
19513
19967
  geo,
19514
19968
  configs,
19515
19969
  language: configs?.language,
19970
+ ...pageRecord ? getRecordGlobals(this, pageRecord) : {
19971
+ page_title: page.title,
19972
+ page_description: page.description
19973
+ },
19974
+ all_country_option_tags: countryOptions,
19975
+ country_option_tags: countryOptions,
19516
19976
  canonical_url: `${store.url}${this.swell.url?.pathname || ""}`,
19977
+ powered_by_link: POWERED_BY_LINK,
19517
19978
  // Flag to enable Shopify compatibility in sections and tags/filters
19518
19979
  shopify_compatibility: Boolean(settings.shopify_compatibility)
19519
19980
  };
19981
+ switch (pageId) {
19982
+ case "robots.txt":
19983
+ globals.robots = getRobotsGlobals(globals.canonical_url);
19984
+ break;
19985
+ default:
19986
+ break;
19987
+ }
19520
19988
  if (this.shopifyCompatibility) {
19521
19989
  this.shopifyCompatibility.initGlobals(globals);
19522
19990
  }
@@ -19851,7 +20319,7 @@ var SwellTheme3 = class {
19851
20319
  return languageConfig;
19852
20320
  }
19853
20321
  const localeShortCode = locale.split("-")[0];
19854
- return (0, import_lodash_es11.reduce)(
20322
+ return (0, import_lodash_es13.reduce)(
19855
20323
  languageConfig,
19856
20324
  (acc, value, key) => {
19857
20325
  if (isObject2(value)) {
@@ -19875,15 +20343,15 @@ var SwellTheme3 = class {
19875
20343
  const translationEnd = translationParts.pop();
19876
20344
  const translationPath = translationParts.join(".");
19877
20345
  const translationConfigGlobal = this.globals.language;
19878
- acc[key] = (0, import_lodash_es11.get)(
20346
+ acc[key] = (0, import_lodash_es13.get)(
19879
20347
  translationConfigGlobal,
19880
20348
  `${translationPath}.$locale.${locale}.${translationEnd}`
19881
- ) || (0, import_lodash_es11.get)(
20349
+ ) || (0, import_lodash_es13.get)(
19882
20350
  translationConfigGlobal,
19883
20351
  `${translationPath}.$locale.${localeShortCode}.${translationEnd}`
19884
- ) || (0, import_lodash_es11.get)(translationConfigGlobal, translationKey) || value;
20352
+ ) || (0, import_lodash_es13.get)(translationConfigGlobal, translationKey) || value;
19885
20353
  } else {
19886
- acc[key] = (0, import_lodash_es11.get)(languageConfig, `$locale.${locale}.${key}`) || (0, import_lodash_es11.get)(languageConfig, `$locale.${localeShortCode}.${key}`) || value;
20354
+ acc[key] = (0, import_lodash_es13.get)(languageConfig, `$locale.${locale}.${key}`) || (0, import_lodash_es13.get)(languageConfig, `$locale.${localeShortCode}.${key}`) || value;
19887
20355
  }
19888
20356
  }
19889
20357
  return acc;
@@ -19898,7 +20366,7 @@ var SwellTheme3 = class {
19898
20366
  }
19899
20367
  return this.shopifyCompatibility;
19900
20368
  };
19901
- if (!Object.keys(configs.editor).length && configs.settings_schema) {
20369
+ if (Object.keys(configs.editor).length <= 0 && configs.settings_schema) {
19902
20370
  const store = await this.swell.storefront.settings.get("store");
19903
20371
  configs.editor = shopifyCompatibility().getEditorConfig(
19904
20372
  configs.settings_schema
@@ -19909,13 +20377,13 @@ var SwellTheme3 = class {
19909
20377
  store.locale || "en-US"
19910
20378
  );
19911
20379
  }
19912
- if (!Object.keys(configs.theme).length && configs.settings_data) {
20380
+ if (Object.keys(configs.theme).length <= 0 && configs.settings_data) {
19913
20381
  configs.theme = shopifyCompatibility().getThemeConfig(
19914
20382
  configs.settings_data
19915
20383
  );
19916
20384
  this.themeSettingFilePath = "theme/config/settings_data.json";
19917
20385
  }
19918
- if (!Object.keys(configs.presets).length && configs.settings_data) {
20386
+ if (Object.keys(configs.presets).length <= 0 && configs.settings_data) {
19919
20387
  configs.presets = shopifyCompatibility().getPresetsConfig(
19920
20388
  configs.settings_data
19921
20389
  );
@@ -20107,8 +20575,11 @@ var SwellTheme3 = class {
20107
20575
  }
20108
20576
  return null;
20109
20577
  }
20578
+ async getAssetConfig(assetName) {
20579
+ return await this.getThemeConfig(`theme/assets/${assetName}`) ?? await this.getThemeConfig(`assets/${assetName}`) ?? null;
20580
+ }
20110
20581
  async getAssetUrl(filePath) {
20111
- const assetConfig = await this.getThemeConfig(`theme/assets/${filePath}`) || await this.getThemeConfig(`assets/${filePath}`);
20582
+ const assetConfig = await this.getAssetConfig(filePath);
20112
20583
  const file = assetConfig?.file;
20113
20584
  if (!file) {
20114
20585
  return null;
@@ -20410,13 +20881,42 @@ ${content.slice(pos)}`;
20410
20881
  }
20411
20882
  return "";
20412
20883
  }
20413
- async renderLayout(layoutName, data) {
20884
+ async renderLayout(layoutName, data, contentForLayout, contentForHeader) {
20414
20885
  layoutName = layoutName || this.liquidSwell.layoutName;
20415
20886
  if (layoutName) {
20416
- return this.renderLayoutTemplate(layoutName, data);
20887
+ if (data) {
20888
+ data = await this.renderDataFields(data, [
20889
+ "page_title",
20890
+ "page_description"
20891
+ ]);
20892
+ }
20893
+ return this.renderLayoutTemplate(layoutName, {
20894
+ ...data,
20895
+ content_for_layout: contentForLayout,
20896
+ content_for_header: contentForHeader
20897
+ });
20417
20898
  } else {
20418
- return data?.content_for_layout || "";
20899
+ return contentForLayout || "";
20900
+ }
20901
+ }
20902
+ async renderDataFields(data, fields) {
20903
+ const promises = [];
20904
+ for (const key of fields) {
20905
+ if (typeof data[key] === "string") {
20906
+ promises.push(
20907
+ this.renderTemplateString(data[key], data).then((value) => {
20908
+ if (data) {
20909
+ data[key] = value;
20910
+ }
20911
+ })
20912
+ );
20913
+ }
20419
20914
  }
20915
+ if (promises.length > 0) {
20916
+ data = { ...data };
20917
+ await Promise.all(promises);
20918
+ }
20919
+ return data;
20420
20920
  }
20421
20921
  getContentForHeader() {
20422
20922
  let content = "\n";
@@ -20584,8 +21084,10 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
20584
21084
  const pageLayout = pageSchema.layout || "";
20585
21085
  const pageSectionGroups = [];
20586
21086
  this.pageSectionGroups = pageSectionGroups;
20587
- await this.renderLayout(pageLayout, {
20588
- content_for_layout: new RenderDrop(() => {
21087
+ await this.renderLayout(
21088
+ pageLayout,
21089
+ {},
21090
+ new RenderDrop(() => {
20589
21091
  pageSectionGroups.push({
20590
21092
  prop: SECTION_GROUP_CONTENT,
20591
21093
  label: "Template",
@@ -20594,7 +21096,7 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
20594
21096
  });
20595
21097
  return "";
20596
21098
  })
20597
- });
21099
+ );
20598
21100
  this.pageSectionGroups = null;
20599
21101
  return pageSectionGroups;
20600
21102
  }
@@ -20636,7 +21138,7 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
20636
21138
  return Promise.all(
20637
21139
  sectionConfigs.map(async (sectionConfig, index) => {
20638
21140
  const { section, schema } = sectionConfig;
20639
- const settings = schema?.fields && this.globals ? resolveSectionSettings(this, sectionConfig) : { ...sectionConfig.settings };
21141
+ const settings = schema?.fields && this.globals ? resolveSectionSettings(this, sectionConfig, index) : { ...sectionConfig.settings };
20640
21142
  const templateConfig = await this.getThemeTemplateConfigByType(
20641
21143
  "sections",
20642
21144
  `${section.type}.liquid`
@@ -20650,7 +21152,7 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
20650
21152
  });
20651
21153
  if (settings?.section?.custom_css) {
20652
21154
  output += `<style>${scopeCustomCSS(
20653
- settings?.section.custom_css,
21155
+ settings.section.custom_css,
20654
21156
  sectionConfig.id
20655
21157
  )}</style>`;
20656
21158
  }
@@ -20680,8 +21182,8 @@ ${this.shopifyCompatibility.getContentForHeader()}`;
20680
21182
  const keyParts = key?.split(".") || [];
20681
21183
  const keyName = keyParts.pop() || "";
20682
21184
  const keyPath = keyParts.join(".");
20683
- const langObject = (0, import_lodash_es11.get)(langConfig, keyPath);
20684
- let localeValue = (0, import_lodash_es11.get)(langObject?.[localeCode], keyName) || (0, import_lodash_es11.get)(langObject?.[localeCode.split("-")[0]], keyName) || langObject?.[keyName];
21185
+ const langObject = (0, import_lodash_es13.get)(langConfig, keyPath);
21186
+ let localeValue = (0, import_lodash_es13.get)(langObject?.[localeCode], keyName) || (0, import_lodash_es13.get)(langObject?.[localeCode.split("-")[0]], keyName) || langObject?.[keyName];
20685
21187
  if (data?.count !== void 0 && localeValue?.one) {
20686
21188
  localeValue = data.count === 1 ? localeValue.one : localeValue.other;
20687
21189
  }
@@ -20715,7 +21217,7 @@ var PageNotFound = class extends PageError {
20715
21217
  super(title, status, description);
20716
21218
  }
20717
21219
  };
20718
- function resolveSectionSettings(theme, sectionConfig) {
21220
+ function resolveSectionSettings(theme, sectionConfig, index) {
20719
21221
  const { settings, schema } = sectionConfig;
20720
21222
  if (!schema || !settings?.section?.settings) {
20721
21223
  return settings;
@@ -20746,7 +21248,10 @@ function resolveSectionSettings(theme, sectionConfig) {
20746
21248
  settings.section.settings,
20747
21249
  editorSettings
20748
21250
  ),
20749
- blocks
21251
+ blocks,
21252
+ index0: index,
21253
+ index: typeof index === "number" ? index + 1 : void 0,
21254
+ location: getSectionLocation(settings.section.type)
20750
21255
  }
20751
21256
  };
20752
21257
  }
@@ -20760,7 +21265,7 @@ function fillDefaultThemeSettings(themeSettings, editorSchemaSettings) {
20760
21265
  }
20761
21266
  }
20762
21267
  function resolveThemeSettings(theme, themeSettings, editorSchemaSettings) {
20763
- const settings = (0, import_lodash_es11.cloneDeep)(themeSettings);
21268
+ const settings = (0, import_lodash_es13.cloneDeep)(themeSettings);
20764
21269
  if (settings.$locale) {
20765
21270
  const { locale } = theme.swell.getStorefrontLocalization();
20766
21271
  const localeConfig = settings.$locale[locale] || {};
@@ -20770,16 +21275,16 @@ function resolveThemeSettings(theme, themeSettings, editorSchemaSettings) {
20770
21275
  }
20771
21276
  }
20772
21277
  }
20773
- (0, import_lodash_es11.each)(settings, (value, key) => {
21278
+ (0, import_lodash_es13.each)(settings, (value, key) => {
20774
21279
  const setting = (editorSchemaSettings && findEditorSetting(editorSchemaSettings, key)) ?? null;
20775
21280
  if (isObject2(value) && !(value instanceof StorefrontResource)) {
20776
21281
  switch (setting?.type) {
20777
21282
  case "color_scheme_group": {
20778
- (0, import_lodash_es11.each)(value, (scheme, schemeId) => {
21283
+ (0, import_lodash_es13.each)(value, (scheme, schemeId) => {
20779
21284
  if (isObject2(scheme) && typeof scheme.settings === "object" && scheme.settings) {
20780
21285
  const settings2 = scheme.settings;
20781
- (0, import_lodash_es11.each)(settings2, (colorValue, colorId) => {
20782
- const fieldDef = (0, import_lodash_es11.find)(setting.fields, { id: colorId });
21286
+ (0, import_lodash_es13.each)(settings2, (colorValue, colorId) => {
21287
+ const fieldDef = (0, import_lodash_es13.find)(setting.fields, { id: colorId });
20783
21288
  if (fieldDef?.type === "color" && colorValue) {
20784
21289
  scheme.id = schemeId;
20785
21290
  settings2[colorId] = new ThemeColor(colorValue);
@@ -20830,7 +21335,7 @@ function resolveThemeSettings(theme, themeSettings, editorSchemaSettings) {
20830
21335
  }
20831
21336
  function findThemeSettingsByType(type, themeSettings, editorSchemaSettings) {
20832
21337
  const foundSettings = [];
20833
- (0, import_lodash_es11.each)(themeSettings, (value, key) => {
21338
+ (0, import_lodash_es13.each)(themeSettings, (value, key) => {
20834
21339
  if (isObject2(value) && !(value instanceof ThemeFont) && !(value instanceof StorefrontResource)) {
20835
21340
  foundSettings.push(
20836
21341
  ...findThemeSettingsByType(type, value, editorSchemaSettings)
@@ -20999,7 +21504,7 @@ function isChildItemActive(items) {
20999
21504
  }
21000
21505
  function getMenuItemValueId(value) {
21001
21506
  const fallback = typeof value === "string" ? value : "";
21002
- const slug = (0, import_lodash_es12.get)(value, "id", (0, import_lodash_es12.get)(value, "slug", fallback)) || "";
21507
+ const slug = (0, import_lodash_es14.get)(value, "id", (0, import_lodash_es14.get)(value, "slug", fallback)) || "";
21003
21508
  return slug;
21004
21509
  }
21005
21510
  async function getMenuItemUrlAndResource(theme, menuItem) {
@@ -21380,6 +21885,7 @@ function getResourceQuery(slug, query) {
21380
21885
  getPage,
21381
21886
  getPageSections,
21382
21887
  getSectionGroupProp,
21888
+ getSectionLocation,
21383
21889
  getSectionSettingsFromProps,
21384
21890
  getThemeSettingsFromProps,
21385
21891
  isArray,