@salla.sa/twilight-components 2.14.426 → 2.14.428

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (443) hide show
  1. package/dist/cjs/{filepond-510sQtuo.js → filepond-D_s3HvDq.js} +1 -1
  2. package/dist/cjs/{filepond-plugin-file-poster-z-1MNuz4.js → filepond-plugin-file-poster-C4iOlG0w.js} +1 -1
  3. package/dist/cjs/{filepond-plugin-file-validate-size-EWd1gmbO.js → filepond-plugin-file-validate-size-tdAA3isk.js} +1 -1
  4. package/dist/cjs/{filepond-plugin-file-validate-type-BCBt19mU.js → filepond-plugin-file-validate-type-D9weHJX2.js} +1 -1
  5. package/dist/cjs/{filepond-plugin-image-edit-iNAVaPwf.js → filepond-plugin-image-edit-Cue4gd69.js} +1 -1
  6. package/dist/cjs/{filepond-plugin-image-exif-orientation-DiM84jbH.js → filepond-plugin-image-exif-orientation-DtvYPP0B.js} +1 -1
  7. package/dist/cjs/{filepond-plugin-image-preview-sigbMp9v.js → filepond-plugin-image-preview-CCEpCBgC.js} +1 -1
  8. package/dist/cjs/{functions-B5bzFKvW.js → functions-DXx6pLur.js} +1 -1
  9. package/dist/cjs/{index-Caamiwh6.js → index-CJ1hA4la.js} +6 -6
  10. package/dist/cjs/{index-Lg5EBRS3.js → index-Dotxdipd.js} +1 -1
  11. package/dist/cjs/loader.cjs.js +2 -2
  12. package/dist/cjs/salla-accordion-body_2.cjs.entry.js +1 -1
  13. package/dist/cjs/salla-accordion_6.cjs.entry.js +2 -2
  14. package/dist/cjs/salla-add-product-button_5.cjs.entry.js +3 -3
  15. package/dist/cjs/salla-advertisement.cjs.entry.js +1 -1
  16. package/dist/cjs/salla-alert_2.cjs.entry.js +1 -1
  17. package/dist/cjs/salla-app-install-alert.cjs.entry.js +1 -1
  18. package/dist/cjs/salla-apps-icons.cjs.entry.js +1 -1
  19. package/dist/cjs/salla-badge.cjs.entry.js +1 -1
  20. package/dist/cjs/salla-booking-field_7.cjs.entry.js +17 -17
  21. package/dist/cjs/{salla-bullet-delivery.cjs.entry.js → salla-bullet-delivery_2.cjs.entry.js} +635 -140
  22. package/dist/cjs/salla-cart-coupons.cjs.entry.js +2 -2
  23. package/dist/cjs/salla-cart-item-offers_2.cjs.entry.js +2 -2
  24. package/dist/cjs/salla-comment-form_8.cjs.entry.js +8 -8
  25. package/dist/cjs/salla-conditional-offer.cjs.entry.js +1 -1
  26. package/dist/cjs/salla-contacts.cjs.entry.js +1 -1
  27. package/dist/cjs/salla-cookies-bar.cjs.entry.js +1 -1
  28. package/dist/cjs/salla-count-down.cjs.entry.js +2 -2
  29. package/dist/cjs/salla-custom-fields.cjs.entry.js +1 -1
  30. package/dist/cjs/salla-delivery-promise.cjs.entry.js +43 -17
  31. package/dist/cjs/salla-edit-order-button.cjs.entry.js +1 -1
  32. package/dist/cjs/salla-filters-widget.cjs.entry.js +3 -3
  33. package/dist/cjs/salla-filters.cjs.entry.js +2 -2
  34. package/dist/cjs/salla-fulfillment-methods.cjs.entry.js +2 -2
  35. package/dist/cjs/salla-gifting.cjs.entry.js +3 -3
  36. package/dist/cjs/salla-hook.cjs.entry.js +2 -2
  37. package/dist/cjs/salla-infinite-scroll.cjs.entry.js +1 -1
  38. package/dist/cjs/salla-installment.cjs.entry.js +1 -1
  39. package/dist/cjs/salla-list-tile.cjs.entry.js +2 -2
  40. package/dist/cjs/salla-localization-modal.cjs.entry.js +2 -2
  41. package/dist/cjs/salla-login-modal.cjs.entry.js +1 -1
  42. package/dist/cjs/salla-loyalty-banner.cjs.entry.js +2 -2
  43. package/dist/cjs/salla-loyalty-hero_2.cjs.entry.js +8 -8
  44. package/dist/cjs/salla-loyalty-panel.cjs.entry.js +3 -3
  45. package/dist/cjs/salla-loyalty-prize-item.cjs.entry.js +2 -2
  46. package/dist/cjs/salla-loyalty-program.cjs.entry.js +3 -3
  47. package/dist/cjs/salla-loyalty-reward.cjs.entry.js +4 -4
  48. package/dist/cjs/salla-loyalty.cjs.entry.js +1 -1
  49. package/dist/cjs/salla-maintenance-alert.cjs.entry.js +2 -2
  50. package/dist/cjs/salla-map.cjs.entry.js +4 -4
  51. package/dist/cjs/salla-menu.cjs.entry.js +1 -1
  52. package/dist/cjs/salla-metadata.cjs.entry.js +1 -1
  53. package/dist/cjs/salla-multiple-bundle-product-cart_2.cjs.entry.js +4 -4
  54. package/dist/cjs/salla-multiple-bundle-product-options-modal_2.cjs.entry.js +6 -6
  55. package/dist/cjs/salla-multiple-bundle-product.cjs.entry.js +2 -2
  56. package/dist/cjs/salla-next-order-coupon.cjs.entry.js +4 -2
  57. package/dist/cjs/salla-notification-item.cjs.entry.js +2 -2
  58. package/dist/cjs/salla-notifications.cjs.entry.js +1 -1
  59. package/dist/cjs/salla-offer-modal.cjs.entry.js +2 -2
  60. package/dist/cjs/salla-offer.cjs.entry.js +1 -1
  61. package/dist/cjs/salla-order-details-multiple-bundle-product.cjs.entry.js +1 -1
  62. package/dist/cjs/salla-order-details-options.cjs.entry.js +1 -1
  63. package/dist/cjs/salla-order-details.cjs.entry.js +2 -2
  64. package/dist/cjs/salla-order-edit-item.cjs.entry.js +1 -1
  65. package/dist/cjs/salla-order-edit-product-card.cjs.entry.js +2 -2
  66. package/dist/cjs/salla-order-edit.cjs.entry.js +1 -1
  67. package/dist/cjs/salla-order-summary.cjs.entry.js +2 -2
  68. package/dist/cjs/salla-order-totals-card.cjs.entry.js +1 -1
  69. package/dist/cjs/salla-orders.cjs.entry.js +1 -1
  70. package/dist/cjs/salla-payments.cjs.entry.js +3 -3
  71. package/dist/cjs/salla-placeholder.cjs.entry.js +2 -2
  72. package/dist/cjs/salla-price-range.cjs.entry.js +3 -3
  73. package/dist/cjs/salla-product-card_2.cjs.entry.js +6 -6
  74. package/dist/cjs/salla-product-size-guide.cjs.entry.js +3 -3
  75. package/dist/cjs/salla-products-list.cjs.entry.js +1 -1
  76. package/dist/cjs/salla-progress-bar.cjs.entry.js +1 -1
  77. package/dist/cjs/salla-quick-order.cjs.entry.js +1 -1
  78. package/dist/cjs/salla-rating-modal.cjs.entry.js +1 -1
  79. package/dist/cjs/salla-reward-action_4.cjs.entry.js +11 -11
  80. package/dist/cjs/salla-scopes.cjs.entry.js +2 -2
  81. package/dist/cjs/salla-search.cjs.entry.js +6 -6
  82. package/dist/cjs/salla-skeleton.cjs.entry.js +2 -2
  83. package/dist/cjs/salla-slider.cjs.entry.js +1 -1
  84. package/dist/cjs/salla-social-share.cjs.entry.js +2 -2
  85. package/dist/cjs/salla-social.cjs.entry.js +2 -2
  86. package/dist/cjs/salla-tab-content_3.cjs.entry.js +4 -4
  87. package/dist/cjs/salla-tiered-offer.cjs.entry.js +1 -1
  88. package/dist/cjs/salla-tooltip.cjs.entry.js +2 -2
  89. package/dist/cjs/salla-trust-badges.cjs.entry.js +1 -1
  90. package/dist/cjs/salla-user-menu.cjs.entry.js +1 -1
  91. package/dist/cjs/salla-user-profile.cjs.entry.js +1 -1
  92. package/dist/cjs/salla-user-settings.cjs.entry.js +2 -2
  93. package/dist/cjs/salla-verify.cjs.entry.js +1 -1
  94. package/dist/cjs/salla-wallet.cjs.entry.js +1 -1
  95. package/dist/cjs/{tracked-promise-DMAN9eMT.js → tracked-promise-CXsGcQwa.js} +1 -1
  96. package/dist/cjs/twilight.cjs.js +2 -2
  97. package/dist/cjs/{vanilla-picker-JE6Ow90L.js → vanilla-picker-BSVxRBEK.js} +1 -1
  98. package/dist/collection/collection-manifest.json +7 -0
  99. package/dist/collection/components/salla-bullet-delivery/api-service.js +80 -13
  100. package/dist/collection/components/salla-bullet-delivery/salla-bullet-delivery.css +5 -0
  101. package/dist/collection/components/salla-bullet-delivery/salla-bullet-delivery.js +344 -120
  102. package/dist/collection/components/salla-cart-coupons/salla-cart-coupons.js +1 -1
  103. package/dist/collection/components/salla-cart-summary/salla-cart-summary.js +1 -1
  104. package/dist/collection/components/salla-color-picker/salla-color-picker.js +1 -1
  105. package/dist/collection/components/salla-comment-form/salla-comment-form.js +1 -1
  106. package/dist/collection/components/salla-comments/salla-comment-item.js +3 -3
  107. package/dist/collection/components/salla-conditional-fields/salla-conditional-fields.js +1 -1
  108. package/dist/collection/components/salla-count-down/salla-count-down.js +1 -1
  109. package/dist/collection/components/salla-datetime-picker/salla-datetime-picker.js +1 -1
  110. package/dist/collection/components/salla-delivery-promise/delivery-promise-api.js +4 -5
  111. package/dist/collection/components/salla-delivery-promise/salla-delivery-promise.js +40 -12
  112. package/dist/collection/components/salla-file-upload/salla-file-upload.js +2 -2
  113. package/dist/collection/components/salla-filters/salla-filters.js +1 -1
  114. package/dist/collection/components/salla-filters-widget/salla-filters-widget.js +2 -2
  115. package/dist/collection/components/salla-fulfillment-methods/salla-fulfillment-methods.js +1 -1
  116. package/dist/collection/components/salla-gifting/salla-gifting.js +2 -2
  117. package/dist/collection/components/salla-hook/salla-hook.js +1 -1
  118. package/dist/collection/components/salla-list-tile/salla-list-tile.js +1 -1
  119. package/dist/collection/components/salla-loading/salla-loading.js +1 -1
  120. package/dist/collection/components/salla-localization-modal/salla-localization-modal.js +1 -1
  121. package/dist/collection/components/salla-loyalty/salla-loyalty-prize-item.js +1 -1
  122. package/dist/collection/components/salla-loyalty-program/salla-loyalty-hero.js +3 -3
  123. package/dist/collection/components/salla-loyalty-program/salla-loyalty-point.js +3 -3
  124. package/dist/collection/components/salla-loyalty-program/salla-loyalty-reward.js +2 -2
  125. package/dist/collection/components/salla-loyalty-program/salla-reward-action.js +1 -1
  126. package/dist/collection/components/salla-loyalty-program/salla-reward-card.js +1 -1
  127. package/dist/collection/components/salla-loyalty-program/salla-reward-details.js +3 -3
  128. package/dist/collection/components/salla-loyalty-program/salla-reward-exchange.js +3 -3
  129. package/dist/collection/components/salla-maintenance-alert/salla-maintenance-alert.js +1 -1
  130. package/dist/collection/components/salla-map/salla-map.js +3 -3
  131. package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-cart.js +1 -1
  132. package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-details.js +2 -2
  133. package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-options-modal.js +4 -4
  134. package/dist/collection/components/salla-multiple-bundle-product/components/salla-multiple-bundle-product-slider.js +1 -1
  135. package/dist/collection/components/salla-multiple-bundle-product/salla-multiple-bundle-product.js +1 -1
  136. package/dist/collection/components/salla-next-order-coupon/salla-next-order-coupon.js +3 -1
  137. package/dist/collection/components/salla-notifications/salla-notification-item.js +1 -1
  138. package/dist/collection/components/salla-offer-modal/salla-offer-modal.js +1 -1
  139. package/dist/collection/components/salla-order-details/salla-order-details.js +1 -1
  140. package/dist/collection/components/salla-order-edit/salla-order-edit-product-card.js +1 -1
  141. package/dist/collection/components/salla-order-summary/salla-order-summary.js +1 -1
  142. package/dist/collection/components/salla-payments/salla-payments.js +2 -2
  143. package/dist/collection/components/salla-placeholder/salla-placeholder.js +1 -1
  144. package/dist/collection/components/salla-price-range/salla-price-range.js +2 -2
  145. package/dist/collection/components/salla-product-availability/salla-product-availability.js +1 -1
  146. package/dist/collection/components/salla-product-card/salla-product-card.js +5 -5
  147. package/dist/collection/components/salla-product-size-guide/salla-product-size-guide.js +2 -2
  148. package/dist/collection/components/salla-quantity-input/salla-quantity-input.js +1 -1
  149. package/dist/collection/components/salla-quick-buy/salla-quick-buy.js +1 -1
  150. package/dist/collection/components/salla-review-card/salla-review-card.js +1 -1
  151. package/dist/collection/components/salla-reviews/salla-reviews.js +1 -1
  152. package/dist/collection/components/salla-reviews-page/salla-reviews-page.js +1 -1
  153. package/dist/collection/components/salla-scopes/salla-scopes.js +1 -1
  154. package/dist/collection/components/salla-search/salla-search.js +5 -5
  155. package/dist/collection/components/salla-searchable-dropdown/interfaces.js +1 -0
  156. package/dist/collection/components/salla-searchable-dropdown/salla-searchable-dropdown.js +566 -0
  157. package/dist/collection/components/salla-skeleton/salla-skeleton.js +1 -1
  158. package/dist/collection/components/salla-social/salla-social.js +1 -1
  159. package/dist/collection/components/salla-social-share/salla-social-share.js +1 -1
  160. package/dist/collection/components/salla-tabs/salla-tab-content.js +1 -1
  161. package/dist/collection/components/salla-tabs/salla-tab-header.js +1 -1
  162. package/dist/collection/components/salla-tabs/salla-tabs.js +1 -1
  163. package/dist/collection/components/salla-tel-input/salla-tel-input.js +1 -1
  164. package/dist/collection/components/salla-tooltip/salla-tooltip.js +1 -1
  165. package/dist/collection/components/salla-user-settings/salla-user-settings.js +1 -1
  166. package/dist/components/index.js +2 -2
  167. package/dist/components/salla-bullet-delivery.js +445 -148
  168. package/dist/components/salla-cart-coupons.js +1 -1
  169. package/dist/components/salla-cart-summary.js +1 -1
  170. package/dist/components/salla-color-picker2.js +1 -1
  171. package/dist/components/salla-comment-form2.js +1 -1
  172. package/dist/components/salla-comment-item2.js +3 -3
  173. package/dist/components/salla-conditional-fields2.js +1 -1
  174. package/dist/components/salla-count-down2.js +1 -1
  175. package/dist/components/salla-datetime-picker2.js +1 -1
  176. package/dist/components/salla-delivery-promise.js +42 -16
  177. package/dist/components/salla-file-upload2.js +2 -2
  178. package/dist/components/salla-filters-widget2.js +2 -2
  179. package/dist/components/salla-filters.js +1 -1
  180. package/dist/components/salla-fulfillment-methods.js +1 -1
  181. package/dist/components/salla-gifting.js +2 -2
  182. package/dist/components/salla-hook.js +1 -1
  183. package/dist/components/salla-list-tile2.js +1 -1
  184. package/dist/components/salla-loading2.js +1 -1
  185. package/dist/components/salla-localization-modal.js +1 -1
  186. package/dist/components/salla-loyalty-hero2.js +3 -3
  187. package/dist/components/salla-loyalty-point2.js +3 -3
  188. package/dist/components/salla-loyalty-prize-item.js +1 -1
  189. package/dist/components/salla-loyalty-reward.js +2 -2
  190. package/dist/components/salla-maintenance-alert.js +1 -1
  191. package/dist/components/salla-map2.js +3 -3
  192. package/dist/components/salla-multiple-bundle-product-cart2.js +1 -1
  193. package/dist/components/salla-multiple-bundle-product-details2.js +2 -2
  194. package/dist/components/salla-multiple-bundle-product-options-modal2.js +4 -4
  195. package/dist/components/salla-multiple-bundle-product-slider2.js +1 -1
  196. package/dist/components/salla-multiple-bundle-product.js +1 -1
  197. package/dist/components/salla-next-order-coupon.js +3 -1
  198. package/dist/components/salla-notification-item2.js +1 -1
  199. package/dist/components/salla-offer-modal.js +1 -1
  200. package/dist/components/salla-order-details.js +1 -1
  201. package/dist/components/salla-order-edit-product-card.js +1 -1
  202. package/dist/components/salla-order-summary.js +1 -1
  203. package/dist/components/salla-payments.js +2 -2
  204. package/dist/components/salla-placeholder2.js +1 -1
  205. package/dist/components/salla-price-range2.js +2 -2
  206. package/dist/components/salla-product-availability2.js +1 -1
  207. package/dist/components/salla-product-card2.js +5 -5
  208. package/dist/components/salla-product-size-guide.js +2 -2
  209. package/dist/components/salla-quantity-input2.js +1 -1
  210. package/dist/components/salla-quick-buy2.js +1 -1
  211. package/dist/components/salla-review-card2.js +1 -1
  212. package/dist/components/salla-reviews-page.js +1 -1
  213. package/dist/components/salla-reviews.js +1 -1
  214. package/dist/components/salla-reward-action2.js +1 -1
  215. package/dist/components/salla-reward-card2.js +1 -1
  216. package/dist/components/salla-reward-details2.js +3 -3
  217. package/dist/components/salla-reward-exchange2.js +3 -3
  218. package/dist/components/salla-scopes.js +1 -1
  219. package/dist/components/salla-search.js +5 -5
  220. package/dist/components/salla-searchable-dropdown.d.ts +11 -0
  221. package/dist/components/salla-searchable-dropdown.js +9 -0
  222. package/dist/components/salla-searchable-dropdown2.js +255 -0
  223. package/dist/components/salla-skeleton2.js +1 -1
  224. package/dist/components/salla-social-share.js +1 -1
  225. package/dist/components/salla-social.js +1 -1
  226. package/dist/components/salla-tab-content2.js +1 -1
  227. package/dist/components/salla-tab-header2.js +1 -1
  228. package/dist/components/salla-tabs2.js +1 -1
  229. package/dist/components/salla-tel-input2.js +1 -1
  230. package/dist/components/salla-tooltip2.js +1 -1
  231. package/dist/components/salla-user-settings.js +1 -1
  232. package/dist/esm/{filepond-Dsmh37s8.js → filepond-EbHhfQ2h.js} +1 -1
  233. package/dist/esm/{filepond-plugin-file-poster-D_DbNtTu.js → filepond-plugin-file-poster-NI3abP58.js} +1 -1
  234. package/dist/esm/{filepond-plugin-file-validate-size-TmlZBEB7.js → filepond-plugin-file-validate-size-B6y95YaS.js} +1 -1
  235. package/dist/esm/{filepond-plugin-file-validate-type-CsP3KOU8.js → filepond-plugin-file-validate-type-DFmkHdVr.js} +1 -1
  236. package/dist/esm/{filepond-plugin-image-edit-CUu5Zp6h.js → filepond-plugin-image-edit-pwPBfksJ.js} +1 -1
  237. package/dist/esm/{filepond-plugin-image-exif-orientation-BOQOVJ6l.js → filepond-plugin-image-exif-orientation-jJpoA9Lm.js} +1 -1
  238. package/dist/esm/{filepond-plugin-image-preview-DHbbDW9K.js → filepond-plugin-image-preview-ClEFsrPa.js} +1 -1
  239. package/dist/esm/{functions-DcLenERt.js → functions-CGUgaH8t.js} +1 -1
  240. package/dist/esm/{index-BO4PufG1.js → index-D36ugbw7.js} +6 -6
  241. package/dist/esm/{index-D2X1w3bP.js → index-zaYTVmuU.js} +1 -1
  242. package/dist/esm/loader.js +3 -3
  243. package/dist/esm/salla-accordion-body_2.entry.js +1 -1
  244. package/dist/esm/salla-accordion_6.entry.js +2 -2
  245. package/dist/esm/salla-add-product-button_5.entry.js +3 -3
  246. package/dist/esm/salla-advertisement.entry.js +1 -1
  247. package/dist/esm/salla-alert_2.entry.js +1 -1
  248. package/dist/esm/salla-app-install-alert.entry.js +1 -1
  249. package/dist/esm/salla-apps-icons.entry.js +1 -1
  250. package/dist/esm/salla-badge.entry.js +1 -1
  251. package/dist/esm/salla-booking-field_7.entry.js +17 -17
  252. package/dist/esm/{salla-bullet-delivery.entry.js → salla-bullet-delivery_2.entry.js} +635 -141
  253. package/dist/esm/salla-cart-coupons.entry.js +2 -2
  254. package/dist/esm/salla-cart-item-offers_2.entry.js +2 -2
  255. package/dist/esm/salla-comment-form_8.entry.js +8 -8
  256. package/dist/esm/salla-conditional-offer.entry.js +1 -1
  257. package/dist/esm/salla-contacts.entry.js +1 -1
  258. package/dist/esm/salla-cookies-bar.entry.js +1 -1
  259. package/dist/esm/salla-count-down.entry.js +2 -2
  260. package/dist/esm/salla-custom-fields.entry.js +1 -1
  261. package/dist/esm/salla-delivery-promise.entry.js +43 -17
  262. package/dist/esm/salla-edit-order-button.entry.js +1 -1
  263. package/dist/esm/salla-filters-widget.entry.js +3 -3
  264. package/dist/esm/salla-filters.entry.js +2 -2
  265. package/dist/esm/salla-fulfillment-methods.entry.js +2 -2
  266. package/dist/esm/salla-gifting.entry.js +3 -3
  267. package/dist/esm/salla-hook.entry.js +2 -2
  268. package/dist/esm/salla-infinite-scroll.entry.js +1 -1
  269. package/dist/esm/salla-installment.entry.js +1 -1
  270. package/dist/esm/salla-list-tile.entry.js +2 -2
  271. package/dist/esm/salla-localization-modal.entry.js +2 -2
  272. package/dist/esm/salla-login-modal.entry.js +1 -1
  273. package/dist/esm/salla-loyalty-banner.entry.js +2 -2
  274. package/dist/esm/salla-loyalty-hero_2.entry.js +8 -8
  275. package/dist/esm/salla-loyalty-panel.entry.js +3 -3
  276. package/dist/esm/salla-loyalty-prize-item.entry.js +2 -2
  277. package/dist/esm/salla-loyalty-program.entry.js +3 -3
  278. package/dist/esm/salla-loyalty-reward.entry.js +4 -4
  279. package/dist/esm/salla-loyalty.entry.js +1 -1
  280. package/dist/esm/salla-maintenance-alert.entry.js +2 -2
  281. package/dist/esm/salla-map.entry.js +4 -4
  282. package/dist/esm/salla-menu.entry.js +1 -1
  283. package/dist/esm/salla-metadata.entry.js +1 -1
  284. package/dist/esm/salla-multiple-bundle-product-cart_2.entry.js +4 -4
  285. package/dist/esm/salla-multiple-bundle-product-options-modal_2.entry.js +6 -6
  286. package/dist/esm/salla-multiple-bundle-product.entry.js +2 -2
  287. package/dist/esm/salla-next-order-coupon.entry.js +4 -2
  288. package/dist/esm/salla-notification-item.entry.js +2 -2
  289. package/dist/esm/salla-notifications.entry.js +1 -1
  290. package/dist/esm/salla-offer-modal.entry.js +2 -2
  291. package/dist/esm/salla-offer.entry.js +1 -1
  292. package/dist/esm/salla-order-details-multiple-bundle-product.entry.js +1 -1
  293. package/dist/esm/salla-order-details-options.entry.js +1 -1
  294. package/dist/esm/salla-order-details.entry.js +2 -2
  295. package/dist/esm/salla-order-edit-item.entry.js +1 -1
  296. package/dist/esm/salla-order-edit-product-card.entry.js +2 -2
  297. package/dist/esm/salla-order-edit.entry.js +1 -1
  298. package/dist/esm/salla-order-summary.entry.js +2 -2
  299. package/dist/esm/salla-order-totals-card.entry.js +1 -1
  300. package/dist/esm/salla-orders.entry.js +1 -1
  301. package/dist/esm/salla-payments.entry.js +3 -3
  302. package/dist/esm/salla-placeholder.entry.js +2 -2
  303. package/dist/esm/salla-price-range.entry.js +3 -3
  304. package/dist/esm/salla-product-card_2.entry.js +6 -6
  305. package/dist/esm/salla-product-size-guide.entry.js +3 -3
  306. package/dist/esm/salla-products-list.entry.js +1 -1
  307. package/dist/esm/salla-progress-bar.entry.js +1 -1
  308. package/dist/esm/salla-quick-order.entry.js +1 -1
  309. package/dist/esm/salla-rating-modal.entry.js +1 -1
  310. package/dist/esm/salla-reward-action_4.entry.js +11 -11
  311. package/dist/esm/salla-scopes.entry.js +2 -2
  312. package/dist/esm/salla-search.entry.js +6 -6
  313. package/dist/esm/salla-skeleton.entry.js +2 -2
  314. package/dist/esm/salla-slider.entry.js +1 -1
  315. package/dist/esm/salla-social-share.entry.js +2 -2
  316. package/dist/esm/salla-social.entry.js +2 -2
  317. package/dist/esm/salla-tab-content_3.entry.js +4 -4
  318. package/dist/esm/salla-tiered-offer.entry.js +1 -1
  319. package/dist/esm/salla-tooltip.entry.js +2 -2
  320. package/dist/esm/salla-trust-badges.entry.js +1 -1
  321. package/dist/esm/salla-user-menu.entry.js +1 -1
  322. package/dist/esm/salla-user-profile.entry.js +1 -1
  323. package/dist/esm/salla-user-settings.entry.js +2 -2
  324. package/dist/esm/salla-verify.entry.js +1 -1
  325. package/dist/esm/salla-wallet.entry.js +1 -1
  326. package/dist/esm/{tracked-promise-lbX3p7Ew.js → tracked-promise-27t68d0-.js} +1 -1
  327. package/dist/esm/twilight.js +3 -3
  328. package/dist/esm/{vanilla-picker-Cv5WcsNp.js → vanilla-picker-9f5m-cXz.js} +1 -1
  329. package/dist/twilight/{p-707cbf67.entry.js → p-00d6d5a7.entry.js} +1 -1
  330. package/dist/twilight/{p-0590b074.entry.js → p-06cc942b.entry.js} +1 -1
  331. package/dist/twilight/{p-3b116cce.entry.js → p-09428ac3.entry.js} +1 -1
  332. package/dist/twilight/p-09f1e7a3.entry.js +4 -0
  333. package/dist/twilight/{p-130f9860.entry.js → p-0e95604c.entry.js} +1 -1
  334. package/dist/twilight/{p-01af13c0.entry.js → p-11e4f88a.entry.js} +1 -1
  335. package/dist/twilight/{p-bb3be480.entry.js → p-1485beda.entry.js} +1 -1
  336. package/dist/twilight/{p-b18ef799.entry.js → p-18200aa4.entry.js} +1 -1
  337. package/dist/twilight/{p-235fe9c8.entry.js → p-19d93cc0.entry.js} +1 -1
  338. package/dist/twilight/{p-f99e1d01.entry.js → p-1ce63a18.entry.js} +1 -1
  339. package/dist/twilight/{p-dbaf2730.entry.js → p-1e06982a.entry.js} +1 -1
  340. package/dist/twilight/{p-e3b22019.entry.js → p-1f81ad02.entry.js} +1 -1
  341. package/dist/twilight/{p-e7c672a0.entry.js → p-204c0e9d.entry.js} +1 -1
  342. package/dist/twilight/{p-cd7fe259.entry.js → p-2286b9bd.entry.js} +1 -1
  343. package/dist/twilight/{p-b809a1c4.entry.js → p-2da26159.entry.js} +1 -1
  344. package/dist/twilight/{p-2cadcc9c.entry.js → p-2eac3905.entry.js} +1 -1
  345. package/dist/twilight/{p-98667c47.entry.js → p-338919cf.entry.js} +1 -1
  346. package/dist/twilight/{p-1ffac611.entry.js → p-38fb52dd.entry.js} +1 -1
  347. package/dist/twilight/{p-53fb98d5.entry.js → p-406d9fb5.entry.js} +1 -1
  348. package/dist/twilight/{p-7f12b845.entry.js → p-40a195c9.entry.js} +1 -1
  349. package/dist/twilight/p-41cd57e8.entry.js +4 -0
  350. package/dist/twilight/{p-bd1b9a48.entry.js → p-430c9160.entry.js} +1 -1
  351. package/dist/twilight/{p-a8ab7c46.entry.js → p-434aac8a.entry.js} +1 -1
  352. package/dist/twilight/{p-0a3e12b2.entry.js → p-4383e32a.entry.js} +1 -1
  353. package/dist/twilight/{p-05dc2f10.entry.js → p-45594bda.entry.js} +1 -1
  354. package/dist/twilight/p-49df1e46.entry.js +4 -0
  355. package/dist/twilight/{p-53d1424f.entry.js → p-4b7bba26.entry.js} +1 -1
  356. package/dist/twilight/{p-33708f2c.entry.js → p-4f7f6ada.entry.js} +1 -1
  357. package/dist/twilight/p-502acc91.entry.js +4 -0
  358. package/dist/twilight/{p-39280ec0.entry.js → p-54343a8e.entry.js} +1 -1
  359. package/dist/twilight/{p-a679c3b3.entry.js → p-5a6a4e59.entry.js} +1 -1
  360. package/dist/twilight/{p-448d8f41.entry.js → p-5bfa1bb7.entry.js} +1 -1
  361. package/dist/twilight/{p-6f08afa5.entry.js → p-5de03536.entry.js} +1 -1
  362. package/dist/twilight/{p-d9a7a0f6.entry.js → p-5dede492.entry.js} +1 -1
  363. package/dist/twilight/{p-cc629d48.entry.js → p-67218c7a.entry.js} +1 -1
  364. package/dist/twilight/{p-cf1789e5.entry.js → p-6a3e7c04.entry.js} +1 -1
  365. package/dist/twilight/{p-0e8d9d0f.entry.js → p-6da10576.entry.js} +1 -1
  366. package/dist/twilight/{p-e5bb3294.entry.js → p-6e1cdc82.entry.js} +1 -1
  367. package/dist/twilight/{p-BvUtr46H.js → p-7ETNA5wV.js} +1 -1
  368. package/dist/twilight/{p-b5663539.entry.js → p-7b663a9e.entry.js} +1 -1
  369. package/dist/twilight/p-7c620aae.entry.js +4 -0
  370. package/dist/twilight/p-7ef82df0.entry.js +4 -0
  371. package/dist/twilight/{p-c01fad3c.entry.js → p-7f19448e.entry.js} +1 -1
  372. package/dist/twilight/p-845c79a1.entry.js +4 -0
  373. package/dist/twilight/{p-a4e30480.entry.js → p-88c5737c.entry.js} +1 -1
  374. package/dist/twilight/{p-c04393ca.entry.js → p-895d6644.entry.js} +1 -1
  375. package/dist/twilight/{p-3582127a.entry.js → p-897d98b8.entry.js} +1 -1
  376. package/dist/twilight/{p-6e296143.entry.js → p-8fd38f8d.entry.js} +1 -1
  377. package/dist/twilight/{p-14903d46.entry.js → p-92d2ddb2.entry.js} +1 -1
  378. package/dist/twilight/{p-8ef579f8.entry.js → p-946b77c0.entry.js} +1 -1
  379. package/dist/twilight/{p-c1317994.entry.js → p-96292e66.entry.js} +1 -1
  380. package/dist/twilight/{p-890c1a92.entry.js → p-9a404557.entry.js} +1 -1
  381. package/dist/twilight/{p-80804925.entry.js → p-9a5f0f9d.entry.js} +1 -1
  382. package/dist/twilight/{p-46971762.entry.js → p-9a860c81.entry.js} +1 -1
  383. package/dist/twilight/{p-c37b818b.entry.js → p-9cc9e423.entry.js} +1 -1
  384. package/dist/twilight/{p-DDuo_I0r.js → p-BB7A2YQb.js} +1 -1
  385. package/dist/twilight/{p-D2dA64xR.js → p-BQPueUNn.js} +1 -1
  386. package/dist/twilight/{p-DjuY9Jnz.js → p-Bt0u20rl.js} +1 -1
  387. package/dist/twilight/{p-B86BGqoz.js → p-CFB0tgem.js} +1 -1
  388. package/dist/twilight/{p-LERSCyEP.js → p-CgXDyb0S.js} +1 -1
  389. package/dist/twilight/{p-BO4PufG1.js → p-D36ugbw7.js} +1 -1
  390. package/dist/twilight/{p-qKfSvDcI.js → p-DB4vHa_X.js} +1 -1
  391. package/dist/twilight/{p-2wfOtzjM.js → p-DLc4JI_x.js} +1 -1
  392. package/dist/twilight/{p-BspFf4Kn.js → p-DTXdHzRd.js} +1 -1
  393. package/dist/twilight/{p-ff880134.entry.js → p-a5d068e0.entry.js} +1 -1
  394. package/dist/twilight/{p-918ff81e.entry.js → p-a61cb79d.entry.js} +1 -1
  395. package/dist/twilight/p-a7c808b6.entry.js +4 -0
  396. package/dist/twilight/{p-d78e892c.entry.js → p-a9b9d4db.entry.js} +1 -1
  397. package/dist/twilight/p-abe816ab.entry.js +4 -0
  398. package/dist/twilight/{p-b7a8d181.entry.js → p-acc58cef.entry.js} +1 -1
  399. package/dist/twilight/{p-f793dbbd.entry.js → p-ad77def2.entry.js} +1 -1
  400. package/dist/twilight/{p-4ea85ab2.entry.js → p-aeaefc51.entry.js} +1 -1
  401. package/dist/twilight/{p-4d13a6df.entry.js → p-b0d6e0dd.entry.js} +1 -1
  402. package/dist/twilight/{p-39373cca.entry.js → p-b582862d.entry.js} +1 -1
  403. package/dist/twilight/{p-fb227bbc.entry.js → p-b7e1dedf.entry.js} +1 -1
  404. package/dist/twilight/p-b852909a.entry.js +4 -0
  405. package/dist/twilight/{p-41d1f2e9.entry.js → p-bf91ba77.entry.js} +1 -1
  406. package/dist/twilight/{p-3c8180cd.entry.js → p-d4fd8316.entry.js} +1 -1
  407. package/dist/twilight/{p-03c6a8bb.entry.js → p-d7b03f6f.entry.js} +1 -1
  408. package/dist/twilight/{p-50062444.entry.js → p-d8fdf8ab.entry.js} +1 -1
  409. package/dist/twilight/{p-870f473c.entry.js → p-dfaa2d2f.entry.js} +1 -1
  410. package/dist/twilight/{p-0e185c70.entry.js → p-e416b6e5.entry.js} +1 -1
  411. package/dist/twilight/{p-227164b2.entry.js → p-e51d3f9d.entry.js} +1 -1
  412. package/dist/twilight/{p-a7350994.entry.js → p-e5605bd2.entry.js} +1 -1
  413. package/dist/twilight/{p-bd318fd3.entry.js → p-e5695c64.entry.js} +1 -1
  414. package/dist/twilight/{p-ab401a6c.entry.js → p-e73ab17f.entry.js} +1 -1
  415. package/dist/twilight/p-e78c99c3.entry.js +4 -0
  416. package/dist/twilight/{p-86fb7a69.entry.js → p-eca295a4.entry.js} +1 -1
  417. package/dist/twilight/{p-abce7f63.entry.js → p-edbd5f07.entry.js} +1 -1
  418. package/dist/twilight/{p-a5d5b2d7.entry.js → p-f6058fee.entry.js} +1 -1
  419. package/dist/twilight/{p-315a4d3b.entry.js → p-f74ac87f.entry.js} +1 -1
  420. package/dist/twilight/{p-19251e7b.entry.js → p-f97d12f4.entry.js} +1 -1
  421. package/dist/twilight/{p-0b0b6963.entry.js → p-fd75e7df.entry.js} +1 -1
  422. package/dist/twilight/{p-BNErtjcV.js → p-mGTS4AOS.js} +1 -1
  423. package/dist/twilight/{p-jl56eEwg.js → p-puXyXCsy.js} +1 -1
  424. package/dist/twilight/twilight.esm.js +1 -1
  425. package/dist/types/components/salla-bullet-delivery/api-service.d.ts +6 -5
  426. package/dist/types/components/salla-bullet-delivery/salla-bullet-delivery.d.ts +38 -6
  427. package/dist/types/components/salla-delivery-promise/delivery-promise-api.d.ts +1 -1
  428. package/dist/types/components/salla-delivery-promise/salla-delivery-promise.d.ts +2 -0
  429. package/dist/types/components/salla-searchable-dropdown/interfaces.d.ts +5 -0
  430. package/dist/types/components/salla-searchable-dropdown/salla-searchable-dropdown.d.ts +47 -0
  431. package/dist/types/components.d.ts +135 -0
  432. package/package.json +5 -5
  433. package/dist/twilight/p-06a2c350.entry.js +0 -4
  434. package/dist/twilight/p-3823e4e9.entry.js +0 -4
  435. package/dist/twilight/p-40156b58.entry.js +0 -4
  436. package/dist/twilight/p-572ef0b9.entry.js +0 -4
  437. package/dist/twilight/p-7f6f712b.entry.js +0 -4
  438. package/dist/twilight/p-8a8ebb7a.entry.js +0 -4
  439. package/dist/twilight/p-93b869f8.entry.js +0 -4
  440. package/dist/twilight/p-b7146f11.entry.js +0 -4
  441. package/dist/twilight/p-cb254a12.entry.js +0 -4
  442. package/dist/twilight/p-e6b3b54f.entry.js +0 -4
  443. package/dist/twilight/p-feb4e5ed.entry.js +0 -4
@@ -3,10 +3,10 @@
3
3
  */
4
4
  'use strict';
5
5
 
6
- var index = require('./index-Caamiwh6.js');
7
- var search = require('./search-c7Aa7lM9.js');
8
- var location = require('./location-DIyESLuI.js');
6
+ var index = require('./index-CJ1hA4la.js');
9
7
  var keyboard_arrow_right = require('./keyboard_arrow_right-BayM_Il2.js');
8
+ var location = require('./location-DIyESLuI.js');
9
+ var search = require('./search-c7Aa7lM9.js');
10
10
 
11
11
  /**
12
12
  * API Service for salla-bullet-delivery component
@@ -26,6 +26,19 @@ async function withApiErrorHandling(fn, fallback, logLabel) {
26
26
  return fallback;
27
27
  }
28
28
  }
29
+ const apiCache = new Map();
30
+ const CACHE_TTL = 5 * 60 * 1000;
31
+ function getCached(key) {
32
+ const entry = apiCache.get(key);
33
+ if (!entry || Date.now() - entry.timestamp > CACHE_TTL) {
34
+ apiCache.delete(key);
35
+ return null;
36
+ }
37
+ return entry.data;
38
+ }
39
+ function setCache(key, data) {
40
+ apiCache.set(key, { data, timestamp: Date.now() });
41
+ }
29
42
  /** Uses country code from API (e.g. 'SA'). */
30
43
  const isSaudiArabia = (countryCode) => String(countryCode).toUpperCase() === 'SA';
31
44
  /**
@@ -37,53 +50,94 @@ const bulletDeliveryAPI = {
37
50
  * Get available countries from Salla shipping API
38
51
  * @param forBranch - when true, use for_branch=1 (e.g. for pickup/branches tab)
39
52
  */
40
- async getCountries(forBranch = false) {
41
- return withApiErrorHandling(async () => {
42
- const data = (await salla.api.request("shipping/countries", { params: { for_branch: forBranch ? 1 : 0 } }))?.data ?? [];
53
+ async getCountries(forBranch = false, query) {
54
+ const cacheKey = !query?.trim() ? `countries_${forBranch ? 1 : 0}` : null;
55
+ if (cacheKey) {
56
+ const cached = getCached(cacheKey);
57
+ if (cached)
58
+ return cached;
59
+ }
60
+ const result = await withApiErrorHandling(async () => {
61
+ const params = { for_branch: forBranch ? 1 : 0 };
62
+ if (forBranch) {
63
+ params.for_allocation = 1;
64
+ }
65
+ if (query?.trim())
66
+ params.query = query.trim();
67
+ const data = (await salla.api.request("shipping/countries", { params }))?.data ?? [];
43
68
  return data.map((c) => ({ id: c.id, code: c.code, name: c.name, has_regions: isSaudiArabia(c.code) }));
44
69
  }, [], 'Error getting countries');
70
+ if (cacheKey && result.length > 0)
71
+ setCache(cacheKey, result);
72
+ return result;
45
73
  },
46
74
  /**
47
75
  * Get regions for a country from Salla shipping API
48
76
  * Endpoint: GET /shipping/countries/<COUNTRY_ID>/region
49
77
  */
50
- async getRegions(countryId) {
78
+ async getRegions(countryId, query) {
51
79
  if (!validId(countryId)) {
52
80
  console.warn(`${API_LOG_PREFIX}: getRegions called without valid country_id`);
53
81
  return [];
54
82
  }
55
- return withApiErrorHandling(async () => {
56
- const data = (await salla.api.request(`shipping/countries/${countryId}/regions`))?.data ?? [];
83
+ const cacheKey = !query?.trim() ? `regions_${countryId}` : null;
84
+ if (cacheKey) {
85
+ const cached = getCached(cacheKey);
86
+ if (cached)
87
+ return cached;
88
+ }
89
+ const result = await withApiErrorHandling(async () => {
90
+ const params = {};
91
+ if (query?.trim())
92
+ params.query = query.trim();
93
+ const data = (await salla.api.request(`shipping/countries/${countryId}/regions`, { params }))?.data ?? [];
57
94
  return data.map((r) => ({ id: r.id, name: r.name, code: r.code, country_id: Number(countryId) }));
58
95
  }, [], 'Error fetching regions');
96
+ if (cacheKey && result.length > 0)
97
+ setCache(cacheKey, result);
98
+ return result;
59
99
  },
60
100
  /**
61
101
  * Get cities from Salla shipping API
62
102
  * @param regionId - Optional; when provided (e.g. for SA), cities are filtered by region
63
103
  */
64
- async getCities(countryId, regionId) {
104
+ async getCities(countryId, regionId, query) {
65
105
  if (!validId(countryId)) {
66
106
  console.warn(`${API_LOG_PREFIX}: getCities called without valid country_id`);
67
107
  return [];
68
108
  }
69
- return withApiErrorHandling(async () => {
109
+ const cacheKey = !query?.trim() ? `cities_${countryId}_${regionId || 'all'}` : null;
110
+ if (cacheKey) {
111
+ const cached = getCached(cacheKey);
112
+ if (cached)
113
+ return cached;
114
+ }
115
+ const result = await withApiErrorHandling(async () => {
70
116
  const params = { for_branch: 0, country_id: countryId };
71
117
  if (regionId)
72
118
  params.region_id = regionId;
119
+ if (query?.trim())
120
+ params.query = query.trim();
73
121
  const data = (await salla.api.request("shipping/cities", { params }))?.data ?? [];
74
122
  return data.map((c) => ({ id: c.id, name: c.name, country_id: countryId, ...(c.region_id != null && { region_id: c.region_id }) }));
75
123
  }, [], 'Error fetching cities');
124
+ if (cacheKey && result.length > 0)
125
+ setCache(cacheKey, result);
126
+ return result;
76
127
  },
77
128
  /**
78
129
  * Get districts from Salla shipping API
79
130
  */
80
- async getDistricts(cityId) {
131
+ async getDistricts(cityId, query) {
81
132
  if (!validId(cityId)) {
82
133
  console.warn(`${API_LOG_PREFIX}: getDistricts called without valid city_id`);
83
134
  return [];
84
135
  }
85
136
  return withApiErrorHandling(async () => {
86
- const raw = (await salla.api.request("shipping/districts", { params: { for_branch: 0, city_id: cityId } }))?.data;
137
+ const params = { for_branch: 0, city_id: cityId };
138
+ if (query?.trim())
139
+ params.query = query.trim();
140
+ const raw = (await salla.api.request("shipping/districts", { params }))?.data;
87
141
  const list = Array.isArray(raw) ? raw : (Array.isArray(raw?.districts) ? raw.districts : []);
88
142
  return list.map((d) => ({ id: d.id, name: d.name, name_en: d.name_en, city_id: cityId }));
89
143
  }, [], 'Error fetching districts');
@@ -95,7 +149,14 @@ const bulletDeliveryAPI = {
95
149
  }, [], 'Error fetching user addresses');
96
150
  },
97
151
  async getBranches({ query, lat, lng, country_id, per_page = 20 } = {}) {
98
- return withApiErrorHandling(async () => {
152
+ const hasSearchParams = query?.trim()?.length >= 2 || lat || lng;
153
+ const cacheKey = !hasSearchParams && country_id ? `branches_${country_id}` : null;
154
+ if (cacheKey) {
155
+ const cached = getCached(cacheKey);
156
+ if (cached)
157
+ return cached;
158
+ }
159
+ const result = await withApiErrorHandling(async () => {
99
160
  const params = { per_page };
100
161
  if (query?.trim().length >= 2)
101
162
  params.query = query;
@@ -108,6 +169,9 @@ const bulletDeliveryAPI = {
108
169
  const res = await salla.api.request("branches", { params });
109
170
  return (Array.isArray(res?.data) ? res.data : []);
110
171
  }, [], 'Error fetching branches');
172
+ if (cacheKey && result.length > 0)
173
+ setCache(cacheKey, result);
174
+ return result;
111
175
  },
112
176
  async saveAddressLocation(payload) {
113
177
  return withApiErrorHandling(async () => {
@@ -119,7 +183,7 @@ const bulletDeliveryAPI = {
119
183
  },
120
184
  async setDeliveryScope(scopeId) {
121
185
  return withApiErrorHandling(async () => {
122
- await salla.scope.change({ id: scopeId });
186
+ await salla.api.withoutNotifier(() => salla.scope.change({ id: scopeId }));
123
187
  salla.storage.set("scope", { ...(salla.storage.get("scope") || {}), id: scopeId });
124
188
  return true;
125
189
  }, false, 'Error setting delivery scope');
@@ -127,7 +191,7 @@ const bulletDeliveryAPI = {
127
191
  async allocateScope(payload) {
128
192
  const errMsg = (d) => d?.error?.message ?? d?.message ?? 'Failed to allocate scope';
129
193
  try {
130
- const response = await salla.api.request("scopes/allocation", payload, 'post');
194
+ const response = await salla.api.withoutNotifier(() => salla.api.request("scopes/allocation", payload, 'post'));
131
195
  // SDK resolves with { data } and throws on non-2xx; any resolved value is success
132
196
  const data = response?.data ?? response;
133
197
  return { success: true, data: data };
@@ -139,6 +203,9 @@ const bulletDeliveryAPI = {
139
203
  }
140
204
  },
141
205
  };
206
+ function clearApiCache() {
207
+ apiCache.clear();
208
+ }
142
209
 
143
210
  /**
144
211
  * Helper functions for salla-bullet-delivery component
@@ -246,16 +313,10 @@ const GEO_ERROR_MESSAGES = {
246
313
  };
247
314
  const getGeolocationErrorMessage = (errorCode) => GEO_ERROR_MESSAGES[errorCode] ?? 'An error occurred while detecting location';
248
315
 
249
- var Store = `<svg width="15" height="14" viewBox="0 0 15 14" fill="none" xmlns="http://www.w3.org/2000/svg">
250
- <path
251
- d="M1.14453 5.83032L1.14453 9.16486C1.14453 11.0511 1.14453 11.9943 1.73032 12.5803C2.3161 13.1663 3.25891 13.1663 5.14453 13.1663L9.14453 13.1663C11.0301 13.1663 11.9729 13.1663 12.5587 12.5803C13.1445 11.9943 13.1445 11.0511 13.1445 9.16486V5.83032"
252
- stroke="currentcolor" stroke-linecap="round" />
253
- <path
254
- d="M9.14453 10.1619C8.68846 10.5667 7.9624 10.8285 7.14453 10.8285C6.32666 10.8285 5.60059 10.5667 5.14453 10.1619"
255
- stroke="currentcolor" stroke-linecap="round" />
316
+ var GetDirections = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
256
317
  <path
257
- d="M5.90256 4.44533C5.71455 5.12426 5.03086 6.29542 3.73185 6.46516C2.58488 6.61502 1.71497 6.11437 1.49277 5.90504C1.24779 5.7353 0.689441 5.19216 0.552703 4.85269C0.415966 4.51322 0.575492 3.77771 0.689441 3.47785L1.14495 2.15892C1.25615 1.82765 1.51646 1.04411 1.78334 0.779094C2.05022 0.514073 2.59054 0.502543 2.81294 0.502543L7.48329 0.502543C8.68543 0.519525 11.3139 0.491824 11.8335 0.502545C12.3532 0.513266 12.6654 0.948828 12.7565 1.13553C13.5318 3.01341 13.8333 4.08889 13.8333 4.54717C13.7321 5.03605 13.3133 5.95787 11.8335 6.36332C10.2956 6.7847 9.42363 5.96509 9.15007 5.65043M5.27015 5.65044C5.48665 5.91635 6.16578 6.45158 7.15029 6.46516C8.1348 6.47873 8.98485 5.79188 9.28681 5.44676C9.37227 5.34492 9.55687 5.04279 9.7483 4.44533"
258
- stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" />
318
+ d="M7.94798 3.19336C11.1309 2.1083 12.7223 1.56578 13.5783 2.42174C14.4342 3.27771 13.8917 4.86914 12.8066 8.05201L12.0678 10.2195C11.2344 12.6639 10.8178 13.8861 10.131 13.9872C9.94631 14.0144 9.75517 13.9981 9.57248 13.9394C8.89297 13.7212 8.53377 12.4326 7.81538 9.8553C7.65604 9.28364 7.57637 8.99781 7.39494 8.7795C7.34228 8.71614 7.28386 8.65772 7.2205 8.60506C7.00219 8.42363 6.71636 8.34396 6.1447 8.18462C3.56741 7.46623 2.27876 7.10703 2.0606 6.42752C2.00195 6.24483 1.98558 6.05369 2.01277 5.86903C2.11392 5.18221 3.33613 4.76556 5.78054 3.93225L7.94798 3.19336Z"
319
+ stroke="#555555" stroke-width="1.2" />
259
320
  </svg>
260
321
  `;
261
322
 
@@ -309,17 +370,30 @@ var MiniMap = `<svg width="35" height="35" viewBox="0 0 35 35" fill="none" xmlns
309
370
  </svg>
310
371
  `;
311
372
 
312
- var GetDirections = `<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
373
+ var Store = `<svg width="15" height="14" viewBox="0 0 15 14" fill="none" xmlns="http://www.w3.org/2000/svg">
313
374
  <path
314
- d="M7.94798 3.19336C11.1309 2.1083 12.7223 1.56578 13.5783 2.42174C14.4342 3.27771 13.8917 4.86914 12.8066 8.05201L12.0678 10.2195C11.2344 12.6639 10.8178 13.8861 10.131 13.9872C9.94631 14.0144 9.75517 13.9981 9.57248 13.9394C8.89297 13.7212 8.53377 12.4326 7.81538 9.8553C7.65604 9.28364 7.57637 8.99781 7.39494 8.7795C7.34228 8.71614 7.28386 8.65772 7.2205 8.60506C7.00219 8.42363 6.71636 8.34396 6.1447 8.18462C3.56741 7.46623 2.27876 7.10703 2.0606 6.42752C2.00195 6.24483 1.98558 6.05369 2.01277 5.86903C2.11392 5.18221 3.33613 4.76556 5.78054 3.93225L7.94798 3.19336Z"
315
- stroke="#555555" stroke-width="1.2" />
375
+ d="M1.14453 5.83032L1.14453 9.16486C1.14453 11.0511 1.14453 11.9943 1.73032 12.5803C2.3161 13.1663 3.25891 13.1663 5.14453 13.1663L9.14453 13.1663C11.0301 13.1663 11.9729 13.1663 12.5587 12.5803C13.1445 11.9943 13.1445 11.0511 13.1445 9.16486V5.83032"
376
+ stroke="currentcolor" stroke-linecap="round" />
377
+ <path
378
+ d="M9.14453 10.1619C8.68846 10.5667 7.9624 10.8285 7.14453 10.8285C6.32666 10.8285 5.60059 10.5667 5.14453 10.1619"
379
+ stroke="currentcolor" stroke-linecap="round" />
380
+ <path
381
+ d="M5.90256 4.44533C5.71455 5.12426 5.03086 6.29542 3.73185 6.46516C2.58488 6.61502 1.71497 6.11437 1.49277 5.90504C1.24779 5.7353 0.689441 5.19216 0.552703 4.85269C0.415966 4.51322 0.575492 3.77771 0.689441 3.47785L1.14495 2.15892C1.25615 1.82765 1.51646 1.04411 1.78334 0.779094C2.05022 0.514073 2.59054 0.502543 2.81294 0.502543L7.48329 0.502543C8.68543 0.519525 11.3139 0.491824 11.8335 0.502545C12.3532 0.513266 12.6654 0.948828 12.7565 1.13553C13.5318 3.01341 13.8333 4.08889 13.8333 4.54717C13.7321 5.03605 13.3133 5.95787 11.8335 6.36332C10.2956 6.7847 9.42363 5.96509 9.15007 5.65043M5.27015 5.65044C5.48665 5.91635 6.16578 6.45158 7.15029 6.46516C8.1348 6.47873 8.98485 5.79188 9.28681 5.44676C9.37227 5.34492 9.55687 5.04279 9.7483 4.44533"
382
+ stroke="currentcolor" stroke-linecap="round" stroke-linejoin="round" />
316
383
  </svg>
317
384
  `;
318
385
 
319
- const sallaBulletDeliveryCss = "@supports (interpolate-size: allow-keywords) and (block-size: calc-size(auto, size)) {\n .s-bullet-delivery .s-bullet-delivery-modal .s-modal-body, .s-bullet-delivery-inner {\n @apply [interpolate-size:allow-keywords];\n }\n .s-bullet-delivery .s-bullet-delivery-modal .s-modal-body {\n @apply [overflow:clip] [transition:block-size_500ms_ease];\n }\n .s-bullet-delivery-inner {\n @apply [overflow:clip] [transition:block-size_500ms_ease];\n block-size: calc-size(auto, size);\n }\n}\n\n@keyframes s-bullet-delivery-fade-in {\n from {\n opacity: 0;\n transform: translateY(6px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}";
386
+ const sallaBulletDeliveryCss = "@supports (interpolate-size: allow-keywords) and (block-size: calc-size(auto, size)) {\n .s-bullet-delivery .s-bullet-delivery-modal .s-modal-body, .s-bullet-delivery-inner {\n @apply [interpolate-size:allow-keywords];\n }\n .s-bullet-delivery .s-bullet-delivery-modal .s-modal-body {\n @apply [overflow:clip] [transition:block-size_500ms_ease];\n }\n .s-bullet-delivery-inner {\n @apply [overflow:clip] [transition:block-size_500ms_ease];\n block-size: calc-size(auto, size);\n }\n}\n\n/* Allow searchable dropdown popover to paint outside the modal body */\n.s-bullet-delivery .s-bullet-delivery-modal .s-modal-body:has(.s-searchable-dropdown--open) {\n overflow: visible !important;\n}\n\n@keyframes s-bullet-delivery-fade-in {\n from {\n opacity: 0;\n transform: translateY(6px);\n }\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}";
320
387
 
321
388
  const BRANCH_SEARCH_DEBOUNCE_MS = 1000;
322
389
  const GEOLOCATION_TIMEOUT = 10000;
390
+ const DEBUG_KEY = 'salla-bullet-delivery-debug';
391
+ const OVERRIDE_IP_KEY = 'salla-bullet-delivery-override-ip';
392
+ function log(message, data) {
393
+ if (localStorage.getItem(DEBUG_KEY)) {
394
+ data !== undefined ? console.log(message, data) : console.log(message);
395
+ }
396
+ }
323
397
  const SallaBulletDelivery = class {
324
398
  constructor(hostRef) {
325
399
  index.registerInstance(this, hostRef);
@@ -332,6 +406,11 @@ const SallaBulletDelivery = class {
332
406
  this.pendingCartSubmitPromise = null;
333
407
  this.cartSubmitConfirmationPending = false;
334
408
  this.branchSearchDebounceTimer = null;
409
+ this.countrySearchTimer = null;
410
+ this.regionSearchTimer = null;
411
+ this.citySearchTimer = null;
412
+ this.districtSearchTimer = null;
413
+ this.citySearchCounter = 0;
335
414
  this.componentReady = false;
336
415
  this.pendingOpen = false;
337
416
  this.tabChanging = false;
@@ -358,7 +437,6 @@ const SallaBulletDelivery = class {
358
437
  /** True after saved addresses have been loaded (lazy: only when address tab is shown). */
359
438
  this.savedAddressesLoaded = false;
360
439
  // Core state
361
- this.loading = true;
362
440
  this.activeTab = "address";
363
441
  this.isLoggedIn = false;
364
442
  this.viewMode = "main";
@@ -384,6 +462,7 @@ const SallaBulletDelivery = class {
384
462
  this.selectedBranch = null;
385
463
  this.branchSearchQuery = "";
386
464
  // Loading states
465
+ this.loadingCountries = false;
387
466
  this.loadingCities = false;
388
467
  this.loadingDistricts = false;
389
468
  this.loadingBranches = false;
@@ -392,11 +471,95 @@ const SallaBulletDelivery = class {
392
471
  this.savingAddress = false;
393
472
  this.loadingSavedAddresses = false;
394
473
  this.showCartWillBeClearedBanner = false;
474
+ // Searchable dropdown state
475
+ this.countrySearchQuery = '';
476
+ this.regionSearchQuery = '';
477
+ this.citySearchQuery = '';
478
+ this.districtSearchQuery = '';
479
+ this.searchingCountries = false;
480
+ this.searchingRegions = false;
481
+ this.searchingCities = false;
482
+ this.searchingDistricts = false;
483
+ this.displayedCountries = [];
484
+ this.displayedRegions = [];
485
+ this.displayedCities = [];
486
+ this.displayedDistricts = [];
395
487
  /** Shown when scopes/allocation returns 422 (address outside delivery coverage). Only on delivery tab. */
396
488
  this.allocationOutOfCoverageMessage = null;
397
489
  this.newAddressForm = {
398
490
  ...SallaBulletDelivery.INITIAL_ADDRESS_FORM,
399
491
  };
492
+ this.handleCountrySearch = (query) => {
493
+ this.countrySearchQuery = query;
494
+ return;
495
+ };
496
+ this.handleRegionSearch = (query) => {
497
+ this.regionSearchQuery = query;
498
+ return;
499
+ };
500
+ this.handleCitySearch = (query) => {
501
+ this.citySearchQuery = query;
502
+ if (this.citySearchTimer)
503
+ clearTimeout(this.citySearchTimer);
504
+ if (!query.trim()) {
505
+ this.displayedCities = this.cities;
506
+ this.searchingCities = false;
507
+ return;
508
+ }
509
+ if (query.trim().length < SallaBulletDelivery.DROPDOWN_SEARCH_MIN_CHARS)
510
+ return;
511
+ const requestId = ++this.citySearchCounter;
512
+ this.citySearchTimer = setTimeout(async () => {
513
+ this.searchingCities = true;
514
+ try {
515
+ const isSA = isSaudiArabia(this.selectedCountry?.code ?? '');
516
+ const regionId = isSA ? this.selectedRegion?.id : undefined;
517
+ const results = await bulletDeliveryAPI.getCities(this.selectedCountry?.id, regionId, query);
518
+ if (requestId === this.citySearchCounter) {
519
+ this.displayedCities = results;
520
+ }
521
+ }
522
+ catch {
523
+ if (requestId === this.citySearchCounter) {
524
+ this.displayedCities = this.cities;
525
+ }
526
+ }
527
+ finally {
528
+ if (requestId === this.citySearchCounter) {
529
+ this.searchingCities = false;
530
+ }
531
+ }
532
+ }, SallaBulletDelivery.DROPDOWN_SEARCH_DEBOUNCE_MS);
533
+ };
534
+ this.handleDistrictSearch = (query) => {
535
+ this.districtSearchQuery = query;
536
+ return;
537
+ };
538
+ this.handleCountryDropdownClosed = () => {
539
+ this.countrySearchQuery = '';
540
+ this.displayedCountries = this.countries;
541
+ this.searchingCountries = false;
542
+ };
543
+ this.handleRegionDropdownClosed = () => {
544
+ this.regionSearchQuery = '';
545
+ this.displayedRegions = this.regions;
546
+ this.searchingRegions = false;
547
+ };
548
+ this.handleCityDropdownClosed = () => {
549
+ this.citySearchQuery = '';
550
+ if (this.citySearchTimer) {
551
+ clearTimeout(this.citySearchTimer);
552
+ this.citySearchTimer = null;
553
+ }
554
+ ++this.citySearchCounter;
555
+ this.displayedCities = this.cities;
556
+ this.searchingCities = false;
557
+ };
558
+ this.handleDistrictDropdownClosed = () => {
559
+ this.districtSearchQuery = '';
560
+ this.displayedDistricts = this.districts;
561
+ this.searchingDistricts = false;
562
+ };
400
563
  /**
401
564
  * Submit add-address form: create address via API then switch back to list.
402
565
  */
@@ -435,10 +598,61 @@ const SallaBulletDelivery = class {
435
598
  this.savingAddress = false;
436
599
  }
437
600
  };
601
+ this.handleCountrySelected = (item) => {
602
+ const country = this.countries.find(c => String(c.id) === String(item.id)) || item;
603
+ const isCountrySwitch = this.selectedCountry &&
604
+ country &&
605
+ this.selectedCountry.code !== country.code;
606
+ this.showCartWillBeClearedBanner = !!isCountrySwitch;
607
+ this.countrySearchQuery = '';
608
+ this.displayedCountries = this.countries;
609
+ this.applyCountryChange(country || null);
610
+ };
611
+ this.handleRegionSelected = (item) => {
612
+ const region = this.regions.find(r => String(r.id) === String(item.id)) || item;
613
+ this.selectedRegion = region || null;
614
+ this.regionSearchQuery = '';
615
+ this.displayedRegions = this.regions;
616
+ this.updateNewAddressForm({
617
+ region_id: region?.id,
618
+ city_id: undefined,
619
+ district_id: undefined,
620
+ city: undefined,
621
+ district: undefined,
622
+ });
623
+ if (region && this.selectedCountry) {
624
+ this.loadCities(this.selectedCountry.id, region.id);
625
+ }
626
+ };
627
+ this.handleCitySelected = (item) => {
628
+ const isSA = isSaudiArabia(this.selectedCountry?.code ?? '');
629
+ const city = this.cities.find(c => String(c.id) === String(item.id)) || item;
630
+ this.selectedCity = city || null;
631
+ this.selectedDistrict = null;
632
+ this.districtName = "";
633
+ this.citySearchQuery = '';
634
+ this.displayedCities = this.cities;
635
+ if (city) {
636
+ this.updateNewAddressForm({ city: city, district: undefined });
637
+ if (isSA) {
638
+ this.loadDistricts(city.id);
639
+ }
640
+ }
641
+ };
642
+ this.handleDistrictSelected = (item) => {
643
+ const district = this.districts.find(d => String(d.id) === String(item.id)) || item;
644
+ this.selectedDistrict = district || null;
645
+ this.districtName = "";
646
+ this.districtSearchQuery = '';
647
+ this.displayedDistricts = this.districts;
648
+ if (district) {
649
+ this.updateNewAddressForm({ district });
650
+ }
651
+ };
438
652
  }
439
- /** Whether to show delivery + pickup tabs. From store.settings.bullet_delivery.supports_pickup */
653
+ /** Whether to show delivery + pickup tabs. From store.shipping.support_pickup */
440
654
  get supportsPickup() {
441
- return !!Salla.config.get("store.settings.bullet_delivery.supports_pickup");
655
+ return Boolean(Salla.config.get("store.shipping.support_pickup"));
442
656
  }
443
657
  /** The modal opening strategy: 'first_visit' | 'on_cart_click' | 'after_add_to_cart' */
444
658
  get openingType() {
@@ -457,10 +671,9 @@ const SallaBulletDelivery = class {
457
671
  this.pendingOpen = true;
458
672
  return;
459
673
  }
460
- // Reset state and set loading before opening
674
+ // Reset state before opening
461
675
  this.resetState();
462
- this.loading = true;
463
- // Open modal immediately to show skeleton/loading state
676
+ // Open modal immediately — fields render right away with inline loading
464
677
  this.modal.open();
465
678
  Salla.event.dispatch("salla::bullet-delivery.modal.opened");
466
679
  try {
@@ -481,11 +694,16 @@ const SallaBulletDelivery = class {
481
694
  this.activeTab = "address";
482
695
  }
483
696
  // Load countries always; load saved addresses only when address tab is active (lazy tab data).
697
+ if (this.isLoggedIn && this.activeTab === "address") {
698
+ this.loadingSavedAddresses = true;
699
+ }
484
700
  await Promise.all([
485
701
  this.loadCountries(hasStoredAddressIds),
486
702
  this.isLoggedIn && this.activeTab === "address"
487
703
  ? this.loadSavedAddresses().then(() => {
488
704
  this.savedAddressesLoaded = true;
705
+ }).finally(() => {
706
+ this.loadingSavedAddresses = false;
489
707
  })
490
708
  : Promise.resolve(),
491
709
  ]);
@@ -523,9 +741,6 @@ const SallaBulletDelivery = class {
523
741
  console.error("SallaBulletDelivery: Error loading data", e);
524
742
  }
525
743
  finally {
526
- // Only hide loading after all data is loaded and UI is ready
527
- this.loading = false;
528
- this.modal?.stopLoading();
529
744
  this.overrideScopeSwitchUI();
530
745
  }
531
746
  }
@@ -560,12 +775,13 @@ const SallaBulletDelivery = class {
560
775
  this.branches = [];
561
776
  this.filteredBranches = [];
562
777
  this.newAddressForm = { ...SallaBulletDelivery.INITIAL_ADDRESS_FORM };
563
- // Reset new state variables
564
778
  this.showCartWillBeClearedBanner = false;
565
779
  this.allocationOutOfCoverageMessage = null;
566
780
  this.locationError = "";
567
781
  this.savedAddressesLoaded = false;
568
782
  this.loadingSavedAddresses = false;
783
+ this.loadingCountries = false;
784
+ this.resetSearchState();
569
785
  }
570
786
  getIntentStorage() {
571
787
  const rememberLastSession = Boolean(Salla.config.get("store.settings.bullet_delivery.settings.remember_last_session"));
@@ -692,10 +908,14 @@ const SallaBulletDelivery = class {
692
908
  ? bulletDeliveryAPI.getDistricts(Number(cityId))
693
909
  : Promise.resolve([]),
694
910
  ]);
695
- if (isSA)
911
+ if (isSA) {
696
912
  this.regions = regions;
913
+ this.displayedRegions = this.regions;
914
+ }
697
915
  this.cities = cities;
916
+ this.displayedCities = this.cities;
698
917
  this.districts = districts;
918
+ this.displayedDistricts = this.districts;
699
919
  this.loadingCities = false;
700
920
  this.loadingRegions = false;
701
921
  this.loadingDistricts = false;
@@ -738,41 +958,117 @@ const SallaBulletDelivery = class {
738
958
  const storage = this.getShownStorage();
739
959
  storage.set(this.sessionShownKey, true);
740
960
  }
961
+ getIPLocationConfig() {
962
+ const configPath = "store.shipping.delivery_location";
963
+ const ipAddress = {
964
+ countryId: Salla.config.get(`${configPath}.country_id`),
965
+ regionId: Salla.config.get(`${configPath}.region_id`),
966
+ cityId: Salla.config.get(`${configPath}.city_id`),
967
+ districtId: Salla.config.get(`${configPath}.district_id`),
968
+ };
969
+ return localStorage.getItem(OVERRIDE_IP_KEY) ?
970
+ JSON.parse(localStorage.getItem(OVERRIDE_IP_KEY)) : ipAddress;
971
+ }
741
972
  async loadCountries(skipEagerSubFetch = false) {
973
+ this.loadingCountries = true;
742
974
  const forBranch = this.activeTab === "branch";
743
- this.countries = await bulletDeliveryAPI.getCountries(forBranch);
744
- // Preselect country from bullet_delivery.customer_location.country (SA | EG | ...)
745
- const configCountryCode = Salla.config.get("store.settings.bullet_delivery.customer_location.country");
746
- const countryToSelect = configCountryCode && this.countries.length > 0
747
- ? this.countries.find((c) => String(c.code).toUpperCase() ===
748
- String(configCountryCode).toUpperCase())
749
- : null;
750
- if (countryToSelect) {
751
- this.selectedCountry = countryToSelect;
752
- this.updateNewAddressForm({
753
- country_id: Number(this.selectedCountry.id),
754
- });
755
- // Skip eager sub-fetches when stored intent IDs exist — prefillFromSessionStorage
756
- // will fire regions/cities/districts in parallel using the stored IDs directly.
757
- if (!skipEagerSubFetch) {
758
- if (isSaudiArabia(this.selectedCountry.code)) {
759
- await this.loadRegions(this.selectedCountry.id);
760
- }
761
- else {
762
- await this.loadCities(this.selectedCountry.id);
975
+ try {
976
+ this.countries = await bulletDeliveryAPI.getCountries(forBranch);
977
+ this.displayedCountries = this.countries;
978
+ const { countryId: configCountryId, regionId: configRegionId, cityId: configCityId, districtId: configDistrictId } = this.getIPLocationConfig();
979
+ log("getIPLocationConfig", this.getIPLocationConfig());
980
+ const countryToSelect = configCountryId && this.countries.length > 0
981
+ ? this.countries.find((c) => String(c.id) === String(configCountryId))
982
+ : null;
983
+ if (countryToSelect) {
984
+ this.selectedCountry = countryToSelect;
985
+ this.updateNewAddressForm({
986
+ country_id: Number(this.selectedCountry.id),
987
+ });
988
+ // Skip eager sub-fetches when stored intent IDs exist prefillFromSessionStorage
989
+ // will fire regions/cities/districts in parallel using the stored IDs directly.
990
+ if (!skipEagerSubFetch) {
991
+ const hasIPLocationIds = configRegionId != null ||
992
+ configCityId != null ||
993
+ configDistrictId != null;
994
+ if (hasIPLocationIds) {
995
+ await this.prefillFromIPLocation(countryToSelect, {
996
+ regionId: configRegionId,
997
+ cityId: configCityId,
998
+ districtId: configDistrictId,
999
+ });
1000
+ }
1001
+ else if (isSaudiArabia(this.selectedCountry.code)) {
1002
+ await this.loadRegions(this.selectedCountry.id);
1003
+ }
1004
+ else {
1005
+ await this.loadCities(this.selectedCountry.id);
1006
+ }
763
1007
  }
764
1008
  }
765
1009
  }
1010
+ finally {
1011
+ this.loadingCountries = false;
1012
+ }
1013
+ }
1014
+ async prefillFromIPLocation(country, ids) {
1015
+ const isSA = isSaudiArabia(country.code);
1016
+ const { regionId, cityId, districtId } = ids;
1017
+ const [regions, cities, districts] = await Promise.all([
1018
+ isSA ? bulletDeliveryAPI.getRegions(country.id) : Promise.resolve([]),
1019
+ bulletDeliveryAPI.getCities(country.id, isSA && regionId != null ? regionId : undefined),
1020
+ cityId != null
1021
+ ? bulletDeliveryAPI.getDistricts(Number(cityId))
1022
+ : Promise.resolve([]),
1023
+ ]);
1024
+ if (isSA) {
1025
+ this.regions = regions;
1026
+ this.displayedRegions = this.regions;
1027
+ }
1028
+ this.cities = cities;
1029
+ this.displayedCities = this.cities;
1030
+ this.districts = districts;
1031
+ this.displayedDistricts = this.districts;
1032
+ this.loadingRegions = false;
1033
+ this.loadingCities = false;
1034
+ this.loadingDistricts = false;
1035
+ if (isSA && regionId != null) {
1036
+ const region = this.regions.find((r) => String(r.id) === String(regionId));
1037
+ if (region) {
1038
+ this.selectedRegion = region;
1039
+ this.updateNewAddressForm({ region_id: region.id });
1040
+ }
1041
+ }
1042
+ if (cityId != null && this.cities.length > 0) {
1043
+ const city = this.cities.find((c) => String(c.id) === String(cityId));
1044
+ if (city) {
1045
+ this.selectedCity = city;
1046
+ this.updateNewAddressForm({ city_id: city.id, city });
1047
+ }
1048
+ }
1049
+ if (districtId != null && this.districts.length > 0) {
1050
+ const district = this.findPrefillDistrict(districtId);
1051
+ if (district) {
1052
+ this.selectedDistrict = district;
1053
+ this.updateNewAddressForm({
1054
+ district_id: district.id,
1055
+ district,
1056
+ });
1057
+ }
1058
+ }
766
1059
  }
767
1060
  async loadCities(countryId, regionId) {
768
1061
  this.loadingCities = true;
769
1062
  this.cities = [];
1063
+ this.displayedCities = [];
770
1064
  this.districts = [];
1065
+ this.displayedDistricts = [];
771
1066
  this.selectedCity = null;
772
1067
  this.selectedDistrict = null;
773
1068
  this.districtName = "";
774
1069
  try {
775
1070
  this.cities = await bulletDeliveryAPI.getCities(countryId, regionId);
1071
+ this.displayedCities = this.cities;
776
1072
  }
777
1073
  finally {
778
1074
  this.loadingCities = false;
@@ -781,10 +1077,12 @@ const SallaBulletDelivery = class {
781
1077
  async loadDistricts(cityId) {
782
1078
  this.loadingDistricts = true;
783
1079
  this.districts = [];
1080
+ this.displayedDistricts = [];
784
1081
  this.selectedDistrict = null;
785
1082
  this.districtName = "";
786
1083
  try {
787
1084
  this.districts = await bulletDeliveryAPI.getDistricts(cityId);
1085
+ this.displayedDistricts = this.districts;
788
1086
  }
789
1087
  finally {
790
1088
  this.loadingDistricts = false;
@@ -865,7 +1163,6 @@ const SallaBulletDelivery = class {
865
1163
  }
866
1164
  async loadSavedAddresses() {
867
1165
  this.savedAddresses = await bulletDeliveryAPI.getSavedAddresses();
868
- // If session address exists (guest intent before login), select it by default
869
1166
  const intent = this.getStoredIntent();
870
1167
  const hasSessionAddress = hasSessionAddressIntent(intent);
871
1168
  if (hasSessionAddress) {
@@ -873,13 +1170,11 @@ const SallaBulletDelivery = class {
873
1170
  this.selectedSavedAddress = null;
874
1171
  }
875
1172
  else {
876
- // Select default address if available and valid
877
1173
  const defaultAddress = this.savedAddresses.find((a) => a.is_default && a.is_in_coverage !== false);
878
1174
  if (defaultAddress) {
879
1175
  this.selectedSavedAddress = defaultAddress;
880
1176
  }
881
1177
  else {
882
- // Select first valid address
883
1178
  const validAddress = this.savedAddresses.find((a) => a.is_in_coverage !== false);
884
1179
  if (validAddress) {
885
1180
  this.selectedSavedAddress = validAddress;
@@ -891,12 +1186,22 @@ const SallaBulletDelivery = class {
891
1186
  this.selectedCountry = newCountry;
892
1187
  this.selectedRegion = null;
893
1188
  this.regions = [];
1189
+ this.displayedRegions = [];
894
1190
  this.cities = [];
1191
+ this.displayedCities = [];
895
1192
  this.districts = [];
1193
+ this.displayedDistricts = [];
896
1194
  this.selectedCity = null;
897
1195
  this.selectedDistrict = null;
898
1196
  this.districtName = "";
899
1197
  this.allocationOutOfCoverageMessage = null;
1198
+ this.regionSearchQuery = '';
1199
+ this.citySearchQuery = '';
1200
+ this.districtSearchQuery = '';
1201
+ this.searchingRegions = false;
1202
+ this.searchingCities = false;
1203
+ this.searchingDistricts = false;
1204
+ this.clearSearchTimers();
900
1205
  if (this.selectedCountry) {
901
1206
  this.updateNewAddressForm({
902
1207
  country_id: Number(this.selectedCountry.id),
@@ -920,14 +1225,18 @@ const SallaBulletDelivery = class {
920
1225
  async loadRegions(countryId) {
921
1226
  this.loadingRegions = true;
922
1227
  this.regions = [];
1228
+ this.displayedRegions = [];
923
1229
  this.selectedRegion = null;
924
1230
  this.cities = [];
1231
+ this.displayedCities = [];
925
1232
  this.districts = [];
1233
+ this.displayedDistricts = [];
926
1234
  this.selectedCity = null;
927
1235
  this.selectedDistrict = null;
928
1236
  this.districtName = "";
929
1237
  try {
930
1238
  this.regions = await bulletDeliveryAPI.getRegions(countryId);
1239
+ this.displayedRegions = this.regions;
931
1240
  }
932
1241
  finally {
933
1242
  this.loadingRegions = false;
@@ -1004,6 +1313,29 @@ const SallaBulletDelivery = class {
1004
1313
  }
1005
1314
  }, BRANCH_SEARCH_DEBOUNCE_MS);
1006
1315
  }
1316
+ clearSearchTimers() {
1317
+ [this.countrySearchTimer, this.regionSearchTimer, this.citySearchTimer, this.districtSearchTimer]
1318
+ .forEach(t => {
1319
+ if (t)
1320
+ clearTimeout(t);
1321
+ });
1322
+ this.countrySearchTimer = this.regionSearchTimer = this.citySearchTimer = this.districtSearchTimer = null;
1323
+ }
1324
+ resetSearchState() {
1325
+ this.countrySearchQuery = '';
1326
+ this.regionSearchQuery = '';
1327
+ this.citySearchQuery = '';
1328
+ this.districtSearchQuery = '';
1329
+ this.searchingCountries = false;
1330
+ this.searchingRegions = false;
1331
+ this.searchingCities = false;
1332
+ this.searchingDistricts = false;
1333
+ this.displayedCountries = [];
1334
+ this.displayedRegions = [];
1335
+ this.displayedCities = [];
1336
+ this.displayedDistricts = [];
1337
+ this.clearSearchTimers();
1338
+ }
1007
1339
  async loadBranchesWithLocation(lat, lng) {
1008
1340
  this.loadingBranches = true;
1009
1341
  try {
@@ -1128,14 +1460,26 @@ const SallaBulletDelivery = class {
1128
1460
  this.activeTab = tab;
1129
1461
  this.showCartWillBeClearedBanner = false;
1130
1462
  this.allocationOutOfCoverageMessage = null;
1131
- // Reload countries with for_branch=1 for pickup tab, for_branch=0 for delivery tab
1463
+ this.resetSearchState();
1132
1464
  const forBranch = tab === "branch";
1133
1465
  this.countries = await bulletDeliveryAPI.getCountries(forBranch);
1466
+ this.displayedCountries = this.countries;
1134
1467
  const previousCountryId = this.selectedCountry?.id;
1135
1468
  if (previousCountryId !== undefined && previousCountryId !== null) {
1136
1469
  this.selectedCountry =
1137
1470
  this.countries.find((c) => c.id === previousCountryId) || null;
1138
1471
  }
1472
+ // Fallback to IP-detected country when carry-over fails
1473
+ if (!this.selectedCountry) {
1474
+ const { countryId: configCountryId } = this.getIPLocationConfig();
1475
+ if (configCountryId && this.countries.length > 0) {
1476
+ this.selectedCountry =
1477
+ this.countries.find((c) => String(c.id) === String(configCountryId)) || null;
1478
+ }
1479
+ if (!this.selectedCountry && this.countries.length === 1) {
1480
+ this.selectedCountry = this.countries[0];
1481
+ }
1482
+ }
1139
1483
  // Load appropriate data when switching tabs if country is selected
1140
1484
  if (this.selectedCountry) {
1141
1485
  if (tab === "branch") {
@@ -1385,7 +1729,6 @@ const SallaBulletDelivery = class {
1385
1729
  (this.activeTab === "address"
1386
1730
  ? Salla.lang.get("pages.checkout.address_out_of_coverage")
1387
1731
  : Salla.lang.get("pages.checkout.failed_to_set_pickup"));
1388
- Salla.notify?.error(errorMessage);
1389
1732
  this.allocationOutOfCoverageMessage = errorMessage;
1390
1733
  this.confirmBtn?.stop();
1391
1734
  this.confirming = false;
@@ -1430,6 +1773,7 @@ const SallaBulletDelivery = class {
1430
1773
  this.setStoredIntent(result);
1431
1774
  if (allocatedScopeId) {
1432
1775
  await bulletDeliveryAPI.setDeliveryScope(allocatedScopeId);
1776
+ clearApiCache();
1433
1777
  }
1434
1778
  const allocationConfirmedPayload = {
1435
1779
  ...result,
@@ -1532,12 +1876,6 @@ const SallaBulletDelivery = class {
1532
1876
  wrapper.append(info, btn);
1533
1877
  return wrapper;
1534
1878
  }
1535
- renderSkeleton() {
1536
- return (index.h("div", { slot: "loading", class: "s-bullet-delivery-skeleton" }, index.h("div", { class: "s-bullet-delivery-skeleton-header" }, index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-title", height: "28px", width: "68%" }), index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-subtitle", height: "18px", width: "84%" })), index.h("div", { class: {
1537
- "s-bullet-delivery-skeleton-tabs": true,
1538
- "s-bullet-delivery-skeleton-tabs--single": !this.supportsPickup,
1539
- } }, index.h("div", { class: "s-bullet-delivery-skeleton-tab" }, index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-tab-icon", height: "32px", width: "32px" }), index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-tab-label", height: "18px", width: "92px" })), this.supportsPickup && (index.h("div", { class: "s-bullet-delivery-skeleton-tab" }, index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-tab-icon", height: "32px", width: "32px" }), index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-tab-label", height: "18px", width: "84px" })))), index.h("div", { class: "s-bullet-delivery-skeleton-content" }, index.h("div", { class: "s-bullet-delivery-skeleton-field" }, index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-field-label", height: "16px", width: "96px" }), index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-field-control", height: "56px", width: "100%" })), index.h("div", { class: "s-bullet-delivery-skeleton-field" }, index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-field-label", height: "16px", width: "104px" }), index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-field-control", height: "56px", width: "100%" })), index.h("div", { class: "s-bullet-delivery-skeleton-field" }, index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-field-label", height: "16px", width: "88px" }), index.h("salla-skeleton", { class: "s-bullet-delivery-skeleton-field-control", height: "56px", width: "100%" }))), index.h("div", { class: "s-bullet-delivery-skeleton-footer" }, index.h("salla-skeleton", { height: "52px", width: "100%" }))));
1540
- }
1541
1879
  renderTabs() {
1542
1880
  // Show tabs only when pickup is supported; otherwise delivery-only view with no tabs
1543
1881
  if (!this.supportsPickup)
@@ -1559,56 +1897,22 @@ const SallaBulletDelivery = class {
1559
1897
  return this.renderAlert(message);
1560
1898
  }
1561
1899
  renderCountrySelect() {
1562
- return (index.h("div", { class: "s-bullet-delivery-field" }, index.h("label", { class: "s-bullet-delivery-label", htmlFor: "bullet-delivery-country" }, Salla.lang.get("blocks.buy_as_gift.receiver_country"), index.h("span", { class: "text-red-500" }, " *")), index.h("select", { id: "bullet-delivery-country", class: "form-input", onChange: (e) => {
1563
- const select = e.target;
1564
- const countryId = Number.parseInt(select.value);
1565
- const country = this.countries.find((c) => c.id === countryId);
1566
- // A "switch" means the user already had a country and picked a different one
1567
- const isCountrySwitch = this.selectedCountry &&
1568
- country &&
1569
- this.selectedCountry.code !== country.code;
1570
- // Show the info banner whenever a country is changed to a different one
1571
- this.showCartWillBeClearedBanner = !!isCountrySwitch;
1572
- this.applyCountryChange(country || null);
1573
- } }, index.h("option", { value: "", disabled: true, selected: !this.selectedCountry }, Salla.lang.get("pages.checkout.select_country")), this.countries.map((country) => (index.h("option", { key: country.id, value: country.id, selected: this.selectedCountry?.id === country.id }, country.name))))));
1574
- }
1575
- renderSelectLoader() {
1576
- return (index.h("span", { class: "s-bullet-delivery-select-loader", "aria-hidden": "true" }, index.h("salla-skeleton", { height: "16px", width: "16px" })));
1577
- }
1578
- renderLoadingLabel(label, htmlFor, isLoading = false, isRequired = true) {
1579
- return (index.h("label", { class: "s-bullet-delivery-label", htmlFor: htmlFor }, index.h("span", { class: "s-bullet-delivery-label-content" }, index.h("span", null, label, isRequired && index.h("span", { class: "text-red-500" }, " *")), isLoading && this.renderSelectLoader())));
1900
+ return (index.h("div", { class: "s-bullet-delivery-field" }, index.h("salla-searchable-dropdown", { label: Salla.lang.get("blocks.buy_as_gift.receiver_country"), placeholder: Salla.lang.get("pages.checkout.select_country"), items: this.displayedCountries, selectedItem: this.selectedCountry, loading: this.loadingCountries, searching: this.searchingCountries, disabled: this.countries.length <= 1, required: true, inputId: "bullet-delivery-country", searchQuery: this.countrySearchQuery, clientSearch: true, onItemSelected: (e) => this.handleCountrySelected(e.detail), onSearchInput: (e) => this.handleCountrySearch(e.detail), onDropdownClosed: () => this.handleCountryDropdownClosed() })));
1580
1901
  }
1581
1902
  /** Region select (SA only): shown when SA is selected; city and district disabled until region selected. */
1582
1903
  renderRegionSelect() {
1583
1904
  const isSA = isSaudiArabia(this.selectedCountry?.code ?? '');
1584
1905
  if (!isSA || !this.selectedCountry)
1585
1906
  return null;
1586
- return (index.h("div", { class: "s-bullet-delivery-field" }, this.renderLoadingLabel(Salla.lang.get("pages.checkout.region_field"), "bullet-delivery-region", this.loadingRegions), index.h("select", { id: "bullet-delivery-region", class: "form-input", disabled: this.loadingRegions || this.regions.length === 0, onChange: (e) => {
1587
- const select = e.target;
1588
- const regionId = Number.parseInt(select.value);
1589
- const region = this.regions.find((r) => r.id === regionId);
1590
- this.selectedRegion = region || null;
1591
- this.updateNewAddressForm({
1592
- region_id: region?.id,
1593
- city_id: undefined,
1594
- district_id: undefined,
1595
- city: undefined,
1596
- district: undefined,
1597
- });
1598
- if (region && this.selectedCountry) {
1599
- this.loadCities(this.selectedCountry.id, region.id);
1600
- }
1601
- } }, index.h("option", { value: "", disabled: true, selected: !this.selectedRegion }, Salla.lang.get("pages.checkout.select_region")), this.regions.map((region) => (index.h("option", { key: region.id, value: region.id, selected: this.selectedRegion?.id === region.id }, region.name))))));
1907
+ return (index.h("div", { class: "s-bullet-delivery-field" }, index.h("salla-searchable-dropdown", { label: Salla.lang.get("pages.checkout.region_field"), placeholder: Salla.lang.get("pages.checkout.select_region"), items: this.displayedRegions, selectedItem: this.selectedRegion, loading: this.loadingRegions, searching: this.searchingRegions, disabled: this.loadingRegions || this.regions.length === 0, required: true, inputId: "bullet-delivery-region", searchQuery: this.regionSearchQuery, clientSearch: true, onItemSelected: (e) => this.handleRegionSelected(e.detail), onSearchInput: (e) => this.handleRegionSearch(e.detail), onDropdownClosed: () => this.handleRegionDropdownClosed() })));
1602
1908
  }
1603
1909
  renderCityDistrictSelects() {
1604
- // Guest form: region + district only for SA; other countries get country + city only
1605
1910
  const isSA = isSaudiArabia(this.selectedCountry?.code ?? '');
1606
1911
  const showDistrict = isSA;
1607
1912
  const showDistrictInput = showDistrict &&
1608
1913
  this.selectedCity &&
1609
1914
  !this.loadingDistricts &&
1610
1915
  this.districts.length === 0;
1611
- // For SA: city disabled until region selected; for non-SA: city disabled until country selected
1612
1916
  const cityDisabled = !this.selectedCountry ||
1613
1917
  (isSA && !this.selectedRegion) ||
1614
1918
  this.loadingCities ||
@@ -1617,39 +1921,11 @@ const SallaBulletDelivery = class {
1617
1921
  (isSA && !this.selectedRegion) ||
1618
1922
  !this.selectedCity ||
1619
1923
  this.loadingDistricts;
1620
- return (index.h("div", { class: "s-bullet-delivery-field-row" }, index.h("div", { class: "s-bullet-delivery-field" }, this.renderLoadingLabel(Salla.lang.get("blocks.buy_as_gift.receiver_city"), "bullet-delivery-city", this.loadingCities), index.h("select", { id: "bullet-delivery-city", class: "form-input", disabled: cityDisabled, onChange: (e) => {
1621
- const select = e.target;
1622
- const cityId = Number.parseInt(select.value);
1623
- const city = this.cities.find((c) => c.id === cityId);
1624
- this.selectedCity = city || null;
1625
- this.selectedDistrict = null;
1626
- this.districtName = "";
1627
- if (city) {
1628
- this.updateNewAddressForm({ city: city, district: undefined });
1629
- if (showDistrict) {
1630
- this.loadDistricts(city.id);
1631
- }
1632
- }
1633
- } }, index.h("option", { value: "", disabled: true, selected: !this.selectedCity }, Salla.lang.get("pages.checkout.select_city")), this.cities.map((city) => (index.h("option", { key: city.id, value: city.id, selected: this.selectedCity?.id === city.id }, city.name))))), showDistrict && (index.h("div", { class: "s-bullet-delivery-field" }, this.renderLoadingLabel(Salla.lang.get("pages.checkout.district_field"), "bullet-delivery-district", this.loadingDistricts && !showDistrictInput), showDistrictInput ? (index.h("input", { id: "bullet-delivery-district", type: "text", class: "form-input", placeholder: Salla.lang.get("pages.checkout.select_district"), value: this.districtName, disabled: districtDisabled, onInput: (e) => {
1924
+ return (index.h("div", { class: "s-bullet-delivery-field-row" }, index.h("div", { class: "s-bullet-delivery-field" }, index.h("salla-searchable-dropdown", { label: Salla.lang.get("blocks.buy_as_gift.receiver_city"), placeholder: Salla.lang.get("pages.checkout.select_city"), items: this.displayedCities, selectedItem: this.selectedCity, loading: this.loadingCities, searching: this.searchingCities, disabled: cityDisabled, required: true, inputId: "bullet-delivery-city", searchQuery: this.citySearchQuery, onItemSelected: (e) => this.handleCitySelected(e.detail), onSearchInput: (e) => this.handleCitySearch(e.detail), onDropdownClosed: () => this.handleCityDropdownClosed(), dropUp: true })), showDistrict && (index.h("div", { class: "s-bullet-delivery-field" }, showDistrictInput ? (index.h("div", null, index.h("label", { class: "s-bullet-delivery-label", htmlFor: "bullet-delivery-district" }, Salla.lang.get("pages.checkout.district_field"), index.h("span", { class: "text-red-500" }, " *")), index.h("input", { id: "bullet-delivery-district", type: "text", class: "form-input", placeholder: Salla.lang.get("pages.checkout.select_district"), value: this.districtName, disabled: districtDisabled, onInput: (e) => {
1634
1925
  const input = e.target;
1635
1926
  this.districtName = input.value;
1636
1927
  this.updateNewAddressForm({ district: undefined });
1637
- } })) : (index.h("select", { id: "bullet-delivery-district", class: "form-input", disabled: districtDisabled || this.districts.length === 0, onChange: (e) => {
1638
- const select = e.target;
1639
- const districtId = Number.parseInt(select.value);
1640
- const district = this.districts.find((d) => d.id === districtId);
1641
- this.selectedDistrict = district || null;
1642
- this.districtName = "";
1643
- if (district) {
1644
- this.updateNewAddressForm({ district });
1645
- }
1646
- } }, index.h("option", { value: "", disabled: true, selected: !this.selectedDistrict }, Salla.lang.get("pages.checkout.select_district")), this.districts.map((district) => {
1647
- const langCode = Salla.config.get("user.language_code");
1648
- const label = langCode === "ar"
1649
- ? district.name
1650
- : (district.name_en ?? district.name);
1651
- return (index.h("option", { key: district.id, value: district.id, selected: this.selectedDistrict?.id === district.id }, label));
1652
- })))))));
1928
+ } }))) : (index.h("salla-searchable-dropdown", { label: Salla.lang.get("pages.checkout.district_field"), placeholder: Salla.lang.get("pages.checkout.select_district"), items: this.displayedDistricts, selectedItem: this.selectedDistrict, loading: this.loadingDistricts, searching: this.searchingDistricts, disabled: districtDisabled || this.districts.length === 0, required: true, inputId: "bullet-delivery-district", searchQuery: this.districtSearchQuery, clientSearch: true, onItemSelected: (e) => this.handleDistrictSelected(e.detail), onSearchInput: (e) => this.handleDistrictSearch(e.detail), onDropdownClosed: () => this.handleDistrictDropdownClosed(), dropUp: true }))))));
1653
1929
  }
1654
1930
  renderSavedAddressesEmptyState() {
1655
1931
  return (index.h("div", { class: "s-bullet-delivery-saved-addresses-empty" }, index.h("div", { class: "s-bullet-delivery-saved-addresses-empty-icon", "aria-hidden": "true" }, index.h("svg", { width: "28", height: "28", viewBox: "0 0 28 29", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, index.h("title", null, "No Saved Adresses"), index.h("path", { d: "M20.16 0C21.4613 0 22.6773 0.341333 23.808 1.024C24.9387 1.70667 25.8347 2.61333 26.496 3.744C27.1787 4.91733 27.52 6.18667 27.52 7.552C27.52 9.45067 26.8267 11.232 25.44 12.896C24.4587 14.0907 23.0827 15.2427 21.312 16.352H21.28C20.9387 16.5653 20.5653 16.672 20.16 16.672C19.7547 16.672 19.3813 16.5653 19.04 16.352H19.008C17.2373 15.2213 15.8613 14.0693 14.88 12.896C13.4933 11.232 12.8 9.45067 12.8 7.552C12.8 6.18667 13.1413 4.91733 13.824 3.744C14.4853 2.61333 15.3813 1.70667 16.512 1.024C17.6427 0.341333 18.8587 0 20.16 0ZM11.488 1.984C9.67467 2.368 8.04267 3.14667 6.592 4.32C5.14133 5.49333 4.01067 6.92267 3.2 8.608C2.34667 10.3573 1.92 12.224 1.92 14.208C1.92 14.72 1.952 15.2427 2.016 15.776L2.08 15.744C2.57067 15.488 2.94933 15.3067 3.216 15.2C3.48267 15.0933 3.73867 15.0933 3.984 15.2C4.22933 15.3067 4.4 15.488 4.496 15.744C4.592 16 4.58667 16.256 4.48 16.512C4.37333 16.768 4.19733 16.9493 3.952 17.056C3.70667 17.1627 3.36 17.3227 2.912 17.536L2.656 17.664C2.57067 17.7067 2.48533 17.7387 2.4 17.76C2.89067 19.4667 3.70133 20.9973 4.832 22.352C5.96267 23.7067 7.296 24.7573 8.832 25.504C10.432 26.272 12.1173 26.656 13.888 26.656C15.4667 26.656 16.9813 26.3467 18.432 25.728C19.8187 25.1307 21.0667 24.288 22.176 23.2C21.92 23.0507 21.7653 22.8373 21.712 22.56C21.6587 22.2827 21.7013 22.0267 21.84 21.792C21.9787 21.5573 22.176 21.408 22.432 21.344C22.8373 21.2587 23.2 21.12 23.52 20.928C23.6907 20.8427 23.8613 20.8 24.032 20.8C24.8 19.5413 25.3333 18.176 25.632 16.704C25.6747 16.4267 25.808 16.2133 26.032 16.064C26.256 15.9147 26.496 15.8667 26.752 15.92C27.008 15.9733 27.2107 16.1173 27.36 16.352C27.5093 16.5867 27.552 16.832 27.488 17.088C27.0613 19.2853 26.1973 21.264 24.896 23.024C23.5947 24.784 22.0053 26.1547 20.128 27.136C18.1653 28.16 16.0853 28.672 13.888 28.672C11.3707 28.672 9.03467 28.0107 6.88 26.688C4.78933 25.408 3.12533 23.68 1.888 21.504C0.629333 19.264 0 16.832 0 14.208C0 11.904 0.490667 9.73867 1.472 7.712C2.41067 5.74933 3.728 4.09067 5.424 2.736C7.12 1.38133 9.01333 0.48 11.104 0.032C11.36 -0.032 11.6 0.0106667 11.824 0.16C12.048 0.309333 12.1867 0.522667 12.24 0.8C12.2933 1.07733 12.2453 1.328 12.096 1.552C11.9467 1.776 11.744 1.92 11.488 1.984ZM14.72 7.552C14.72 8.96 15.2533 10.304 16.32 11.584C17.1733 12.5867 18.3893 13.6 19.968 14.624C20.032 14.6453 20.096 14.656 20.16 14.656C20.224 14.656 20.288 14.6453 20.352 14.624C21.9307 13.6213 23.1467 12.608 24 11.584C25.0667 10.304 25.6 8.96 25.6 7.552C25.6 6.57067 25.3547 5.65333 24.864 4.8C24.3733 3.94667 23.7067 3.26933 22.864 2.768C22.0213 2.26667 21.12 2.016 20.16 2.016C19.2 2.016 18.2987 2.26667 17.456 2.768C16.6133 3.26933 15.9467 3.94667 15.456 4.8C14.9653 5.65333 14.72 6.57067 14.72 7.552ZM17.28 7.68C17.28 6.848 17.5627 6.13867 18.128 5.552C18.6933 4.96533 19.3707 4.672 20.16 4.672C20.9493 4.672 21.6267 4.96533 22.192 5.552C22.7573 6.13867 23.04 6.848 23.04 7.68C23.04 8.512 22.7573 9.216 22.192 9.792C21.6267 10.368 20.9493 10.656 20.16 10.656C19.3707 10.656 18.6933 10.368 18.128 9.792C17.5627 9.216 17.28 8.512 17.28 7.68ZM6.752 14.688C7.62667 14.7733 8.53333 15.0293 9.472 15.456C9.70667 15.5627 9.87733 15.744 9.984 16C10.0907 16.256 10.0907 16.512 9.984 16.768C9.87733 17.024 9.70133 17.2 9.456 17.296C9.21067 17.392 8.97067 17.3867 8.736 17.28C7.94667 16.9387 7.22133 16.736 6.56 16.672C6.28267 16.6293 6.064 16.5013 5.904 16.288C5.744 16.0747 5.68 15.8293 5.712 15.552C5.744 15.2747 5.86133 15.0507 6.064 14.88C6.26667 14.7093 6.496 14.6453 6.752 14.688ZM17.6 20.544C18.304 20.864 18.976 21.0987 19.616 21.248C19.872 21.312 20.0693 21.4613 20.208 21.696C20.3467 21.9307 20.3893 22.1813 20.336 22.448C20.2827 22.7147 20.144 22.9227 19.92 23.072C19.696 23.2213 19.4453 23.264 19.168 23.2C18.4213 23.0293 17.632 22.752 16.8 22.368C16.5653 22.2613 16.4 22.08 16.304 21.824C16.208 21.568 16.2133 21.312 16.32 21.056C16.4267 20.8 16.6027 20.624 16.848 20.528C17.0933 20.432 17.344 20.4373 17.6 20.544ZM12.832 17.44C13.0027 17.568 13.248 17.7493 13.568 17.984L14.496 18.688C14.7093 18.8587 14.8373 19.0773 14.88 19.344C14.9227 19.6107 14.8693 19.856 14.72 20.08C14.5707 20.304 14.368 20.4427 14.112 20.496C13.856 20.5493 13.6107 20.5013 13.376 20.352L11.744 19.072C11.5307 18.9227 11.4027 18.7093 11.36 18.432C11.3173 18.1547 11.3707 17.904 11.52 17.68C11.6693 17.456 11.872 17.3227 12.128 17.28C12.384 17.2373 12.6187 17.2907 12.832 17.44ZM20.16 8.672C20.416 8.672 20.64 8.576 20.832 8.384C21.024 8.192 21.12 7.95733 21.12 7.68C21.12 7.40267 21.024 7.16267 20.832 6.96C20.64 6.75733 20.416 6.656 20.16 6.656C19.904 6.656 19.68 6.75733 19.488 6.96C19.296 7.16267 19.2 7.40267 19.2 7.68C19.2 7.95733 19.296 8.192 19.488 8.384C19.68 8.576 19.904 8.672 20.16 8.672Z", fill: "#666666" }))), index.h("p", { class: "s-bullet-delivery-saved-addresses-empty-title" }, Salla.lang.get("pages.checkout.no_saved_addresses")), index.h("p", { class: "s-bullet-delivery-saved-addresses-empty-desc" }, Salla.lang.get("pages.checkout.add_address_simplify_shipping")), index.h("salla-button", { onClick: () => this.handleAddNewAddress(), onKeyUp: () => this.handleAddNewAddress() }, Salla.lang.get("pages.checkout.add_new_address"))));
@@ -1825,7 +2101,8 @@ const SallaBulletDelivery = class {
1825
2101
  const submitLabel = this.savingAddress
1826
2102
  ? Salla.lang.get("pages.checkout.loading")
1827
2103
  : Salla.lang.get("pages.checkout.confirm_address");
1828
- return (index.h("div", { class: "s-bullet-delivery-add-address" }, index.h("div", { class: "s-bullet-delivery-add-address-header" }, index.h("button", { type: "button", class: "s-bullet-delivery-add-address-title", onClick: () => this.handleBackToAddressList(), onKeyDown: (e) => e.key === "Enter" && this.handleBackToAddressList() }, index.h("span", { innerHTML: this.isRTL ? keyboard_arrow_right.ArrowRightIcon : keyboard_arrow_right.ArrowLeftIcon, "aria-hidden": "true" }), index.h("span", { class: "s-bullet-delivery-add-address-title-text" }, title))), index.h("form", { class: "s-bullet-delivery-add-address-form", onSubmit: (e) => this.handleSubmitAddAddress(e) }, this.renderGuestDeliveryForm(), index.h("div", { class: "s-bullet-delivery-form-actions s-bullet-delivery-form-actions--single" }, index.h("salla-button", { type: "submit", loading: this.savingAddress, disabled: !canSubmit || this.savingAddress, class: "s-bullet-delivery-add-address-submit" }, submitLabel)))));
2104
+ const hasAddressesToGoBack = this.savedAddresses.length > 0 || hasSessionAddressIntent(this.getStoredIntent());
2105
+ return (index.h("div", { class: "s-bullet-delivery-add-address" }, index.h("div", { class: "s-bullet-delivery-add-address-header" }, hasAddressesToGoBack ? (index.h("button", { type: "button", class: "s-bullet-delivery-add-address-title", onClick: () => this.handleBackToAddressList(), onKeyDown: (e) => e.key === "Enter" && this.handleBackToAddressList() }, index.h("span", { innerHTML: this.isRTL ? keyboard_arrow_right.ArrowRightIcon : keyboard_arrow_right.ArrowLeftIcon, "aria-hidden": "true" }), index.h("span", { class: "s-bullet-delivery-add-address-title-text" }, title))) : (index.h("span", { class: "s-bullet-delivery-add-address-title" }, index.h("span", { class: "s-bullet-delivery-add-address-title-text" }, title)))), index.h("form", { class: "s-bullet-delivery-add-address-form", onSubmit: (e) => this.handleSubmitAddAddress(e) }, this.renderGuestDeliveryForm(), index.h("div", { class: "s-bullet-delivery-form-actions s-bullet-delivery-form-actions--single" }, index.h("salla-button", { type: "submit", loading: this.savingAddress, disabled: !canSubmit || this.savingAddress, class: "s-bullet-delivery-add-address-submit" }, submitLabel)))));
1829
2106
  }
1830
2107
  renderFooter() {
1831
2108
  const showAddAddressInFooter = this.activeTab === "address" && this.isLoggedIn;
@@ -1968,9 +2245,9 @@ const SallaBulletDelivery = class {
1968
2245
  }
1969
2246
  }
1970
2247
  render() {
1971
- return (index.h(index.Host, { key: '8ca46eeae00aea840c260c599b10c7c544da1edc', class: "s-bullet-delivery" }, index.h("salla-modal", { key: '6197fa0b5f3d0a3479d37d9d54a2fe977a632215', ref: (modal) => {
2248
+ return (index.h(index.Host, { key: '0daead232faa6590712faef140ab694b3324960e', class: "s-bullet-delivery" }, index.h("salla-modal", { key: '4f318a88c10b524d5f6b71a46cb93535d4b25a82', ref: (modal) => {
1972
2249
  this.modal = modal;
1973
- }, isClosable: !this.isRequired && !this.shouldForceNonClosable(), class: "s-bullet-delivery-modal", isLoading: this.loading, width: "sm" }, this.loading ? (this.renderSkeleton()) : (index.h("div", { class: "s-bullet-delivery-inner" }, this.viewMode === "main" && this.renderMainView(), this.viewMode === "add-address" && this.renderAddAddressForm())))));
2250
+ }, isClosable: !this.isRequired && !this.shouldForceNonClosable(), class: "s-bullet-delivery-modal", width: "sm" }, index.h("div", { key: '66f3d844ce325e47bfb52f941c038339f3f0cf6c', class: "s-bullet-delivery-inner" }, this.viewMode === "main" && this.renderMainView(), this.viewMode === "add-address" && this.renderAddAddressForm()))));
1974
2251
  }
1975
2252
  componentDidLoad() {
1976
2253
  // Mark component as ready
@@ -2069,6 +2346,224 @@ SallaBulletDelivery.INITIAL_ADDRESS_FORM = {
2069
2346
  postal_code: undefined,
2070
2347
  description: undefined,
2071
2348
  };
2349
+ SallaBulletDelivery.DROPDOWN_SEARCH_DEBOUNCE_MS = 400;
2350
+ SallaBulletDelivery.DROPDOWN_SEARCH_MIN_CHARS = 2;
2072
2351
  SallaBulletDelivery.style = sallaBulletDeliveryCss;
2073
2352
 
2353
+ const SallaSearchableDropdown = class {
2354
+ constructor(hostRef) {
2355
+ index.registerInstance(this, hostRef);
2356
+ this.itemSelected = index.createEvent(this, "itemSelected");
2357
+ this.searchInput = index.createEvent(this, "searchInput");
2358
+ this.dropdownOpened = index.createEvent(this, "dropdownOpened");
2359
+ this.dropdownClosed = index.createEvent(this, "dropdownClosed");
2360
+ this.placeholder = '';
2361
+ this.items = [];
2362
+ this.selectedItem = null;
2363
+ this.loading = false;
2364
+ this.searching = false;
2365
+ this.disabled = false;
2366
+ this.required = false;
2367
+ this.noResultsText = '';
2368
+ this.inputId = '';
2369
+ this.searchQuery = '';
2370
+ this.clientSearch = false;
2371
+ this.dropUp = false;
2372
+ this.isOpen = false;
2373
+ this.focusedIndex = -1;
2374
+ this.clientSearchQuery = '';
2375
+ this.scrollableAncestor = null;
2376
+ this.handleTriggerClick = () => {
2377
+ if (this.isOpen) {
2378
+ this.close();
2379
+ }
2380
+ else {
2381
+ this.open();
2382
+ }
2383
+ };
2384
+ this.handleTriggerKeyDown = (e) => {
2385
+ if (e.key === 'Enter' || e.key === ' ' || e.key === 'ArrowDown') {
2386
+ e.preventDefault();
2387
+ if (!this.isOpen)
2388
+ this.open();
2389
+ }
2390
+ else if (e.key === 'Escape') {
2391
+ this.close();
2392
+ }
2393
+ };
2394
+ this.handleSearchInputChange = (e) => {
2395
+ const value = e.target.value;
2396
+ if (this.clientSearch) {
2397
+ this.clientSearchQuery = value;
2398
+ }
2399
+ this.searchInput.emit(value);
2400
+ this.focusedIndex = -1;
2401
+ };
2402
+ this.handleSearchKeyDown = (e) => {
2403
+ const visibleItems = this.filteredItems;
2404
+ const itemCount = visibleItems.length;
2405
+ switch (e.key) {
2406
+ case 'ArrowDown':
2407
+ e.preventDefault();
2408
+ this.focusedIndex = itemCount > 0
2409
+ ? (this.focusedIndex + 1) % itemCount
2410
+ : -1;
2411
+ this.scrollFocusedIntoView();
2412
+ break;
2413
+ case 'ArrowUp':
2414
+ e.preventDefault();
2415
+ this.focusedIndex = itemCount > 0
2416
+ ? (this.focusedIndex - 1 + itemCount) % itemCount
2417
+ : -1;
2418
+ this.scrollFocusedIntoView();
2419
+ break;
2420
+ case 'Enter':
2421
+ e.preventDefault();
2422
+ if (this.focusedIndex >= 0 && this.focusedIndex < itemCount) {
2423
+ this.selectItem(visibleItems[this.focusedIndex]);
2424
+ }
2425
+ break;
2426
+ case 'Escape':
2427
+ e.preventDefault();
2428
+ this.close();
2429
+ break;
2430
+ }
2431
+ };
2432
+ }
2433
+ connectedCallback() {
2434
+ this.boundHandleClickOutside = this.handleClickOutside.bind(this);
2435
+ document.addEventListener('mousedown', this.boundHandleClickOutside);
2436
+ }
2437
+ disconnectedCallback() {
2438
+ document.removeEventListener('mousedown', this.boundHandleClickOutside);
2439
+ if (this.scrollableAncestor) {
2440
+ this.scrollableAncestor.style.overflow = '';
2441
+ this.scrollableAncestor = null;
2442
+ }
2443
+ }
2444
+ onItemsChange() {
2445
+ this.focusedIndex = -1;
2446
+ }
2447
+ normalizeArabic(text) {
2448
+ return text.replace(/[أإآا]/g, 'ا');
2449
+ }
2450
+ get filteredItems() {
2451
+ if (!this.clientSearch || !this.clientSearchQuery.trim()) {
2452
+ return this.items;
2453
+ }
2454
+ const query = this.normalizeArabic(this.clientSearchQuery.trim().toLowerCase());
2455
+ return this.items.filter(item => {
2456
+ const normalizedName = this.normalizeArabic(item.name.toLowerCase());
2457
+ const normalizedNameEn = item.name_en ? item.name_en.toLowerCase() : '';
2458
+ return normalizedName.includes(query) || normalizedNameEn.includes(query);
2459
+ });
2460
+ }
2461
+ getDisplayName(item) {
2462
+ const lang = salla?.config?.get('user.language_code');
2463
+ if (lang && lang !== 'ar' && item.name_en?.trim()) {
2464
+ return item.name_en.trim();
2465
+ }
2466
+ return item.name;
2467
+ }
2468
+ handleClickOutside(e) {
2469
+ if (!this.isOpen)
2470
+ return;
2471
+ const target = e.target;
2472
+ if (!this.host.contains(target)) {
2473
+ this.close();
2474
+ }
2475
+ }
2476
+ findScrollableAncestor() {
2477
+ let el = this.host.parentElement;
2478
+ while (el) {
2479
+ const style = getComputedStyle(el);
2480
+ const overflowY = style.overflowY;
2481
+ if (overflowY === 'auto' || overflowY === 'scroll' || overflowY === 'hidden' || style.overflow === 'clip') {
2482
+ return el;
2483
+ }
2484
+ el = el.parentElement;
2485
+ }
2486
+ return null;
2487
+ }
2488
+ open() {
2489
+ if (this.disabled || this.loading)
2490
+ return;
2491
+ this.isOpen = true;
2492
+ this.focusedIndex = -1;
2493
+ this.scrollableAncestor = this.findScrollableAncestor();
2494
+ if (this.scrollableAncestor) {
2495
+ this.scrollableAncestor.style.overflow = 'visible';
2496
+ }
2497
+ this.dropdownOpened.emit();
2498
+ requestAnimationFrame(() => this.searchInputRef?.focus());
2499
+ }
2500
+ close() {
2501
+ if (!this.isOpen)
2502
+ return;
2503
+ this.isOpen = false;
2504
+ this.focusedIndex = -1;
2505
+ this.clientSearchQuery = '';
2506
+ if (this.scrollableAncestor) {
2507
+ this.scrollableAncestor.style.overflow = '';
2508
+ this.scrollableAncestor = null;
2509
+ }
2510
+ this.dropdownClosed.emit();
2511
+ }
2512
+ scrollFocusedIntoView() {
2513
+ if (this.focusedIndex < 0)
2514
+ return;
2515
+ requestAnimationFrame(() => {
2516
+ const listEl = this.panelRef?.querySelector('.s-searchable-dropdown-list');
2517
+ const focused = listEl?.children[this.focusedIndex];
2518
+ focused?.scrollIntoView({ block: 'nearest' });
2519
+ });
2520
+ }
2521
+ selectItem(item) {
2522
+ this.itemSelected.emit(item);
2523
+ this.close();
2524
+ }
2525
+ render() {
2526
+ const hasSelection = this.selectedItem != null;
2527
+ const listboxId = `${this.inputId}-listbox`;
2528
+ return (index.h(index.Host, { key: '1e413d4391362f274223724ab37f5842a196f936', class: "s-searchable-dropdown" }, index.h("div", { key: 'c1c0b595a458db8918bc7c72b949cd514d764613', class: { 's-searchable-dropdown': true, 's-searchable-dropdown--open': this.isOpen } }, this.label && (index.h("label", { key: '576831e0383f561d5512792cb52d1c6d40156015', class: "s-searchable-dropdown-label", htmlFor: this.inputId }, this.label, this.required && index.h("span", { key: '290e1edb52971f5af6c6555f82ad595e97c9994d', class: "s-searchable-dropdown-required" }, " *"))), index.h("div", { key: 'e3c9aaea5697839e67aab1b91d07cb825ee76c7b', class: {
2529
+ 's-searchable-dropdown-trigger': true,
2530
+ 's-searchable-dropdown-trigger--disabled': this.disabled || this.loading,
2531
+ 's-searchable-dropdown-trigger--open': this.isOpen,
2532
+ }, role: "combobox", "aria-expanded": this.isOpen ? 'true' : 'false', "aria-haspopup": "listbox", "aria-controls": listboxId, "aria-disabled": this.disabled || this.loading ? 'true' : 'false', tabIndex: this.disabled || this.loading ? -1 : 0, onClick: this.handleTriggerClick, onKeyDown: this.handleTriggerKeyDown }, hasSelection ? (index.h("span", { class: "s-searchable-dropdown-trigger-text" }, this.getDisplayName(this.selectedItem))) : (index.h("span", { class: "s-searchable-dropdown-trigger-placeholder" }, this.placeholder)), index.h("i", { key: 'f1e95e38ebffc358a9045f0fd38dd205eb2a14bb', class: {
2533
+ 'sicon-keyboard_arrow_down': true,
2534
+ 's-searchable-dropdown-trigger-icon': true,
2535
+ 's-searchable-dropdown-trigger-icon--open': this.isOpen,
2536
+ }, "aria-hidden": "true" })), this.isOpen && (index.h("div", { key: 'a5c6b4650d8de5467c1d53e67700168a0795ff0b', class: {
2537
+ 's-searchable-dropdown-panel': true,
2538
+ 's-searchable-dropdown-panel--up': this.dropUp,
2539
+ }, ref: (el) => (this.panelRef = el) }, index.h("div", { key: '5ddf73d6d8cb96881ac6f94ef25a9f58b883a6c0', class: "s-searchable-dropdown-search-wrap" }, index.h("i", { key: 'ec52897c25962c6d1e84986f25bdac2dd8ecdac0', class: "sicon-search s-searchable-dropdown-search-icon", "aria-hidden": "true" }), index.h("input", { key: 'e14dd7a0dae605dd37782cdd8c235e875105fcc9', ref: (el) => (this.searchInputRef = el), id: this.inputId, type: "text", class: "s-searchable-dropdown-search-input", placeholder: this.placeholder, value: this.clientSearch ? this.clientSearchQuery : this.searchQuery, onInput: this.handleSearchInputChange, onKeyDown: this.handleSearchKeyDown, autocomplete: "off", "aria-autocomplete": "list", "aria-expanded": this.isOpen ? 'true' : 'false', "aria-controls": listboxId })), index.h("div", { key: '80daad72643001e400a9ff43444bbad5077ffa2d', id: listboxId, class: "s-searchable-dropdown-list s-scrollbar", role: "listbox" }, this.renderListContent()))))));
2540
+ }
2541
+ renderListContent() {
2542
+ if (this.searching || this.loading) {
2543
+ return (index.h("div", { class: "s-searchable-dropdown-loading" }, index.h("svg", { class: "s-searchable-dropdown-spinner", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, index.h("circle", { cx: "12", cy: "12", r: "10", stroke: "currentColor", "stroke-width": "3", "stroke-linecap": "round", opacity: "0.25" }), index.h("path", { d: "M12 2a10 10 0 0 1 10 10", stroke: "currentColor", "stroke-width": "3", "stroke-linecap": "round" }))));
2544
+ }
2545
+ const visibleItems = this.filteredItems;
2546
+ if (visibleItems.length === 0) {
2547
+ return (index.h("div", { class: "s-searchable-dropdown-empty" }, this.noResultsText || salla?.lang?.get('common.elements.no_options') || 'No results found'));
2548
+ }
2549
+ return visibleItems.map((item, index$1) => {
2550
+ const isSelected = this.selectedItem?.id === item.id;
2551
+ const isFocused = this.focusedIndex === index$1;
2552
+ return (index.h("button", { key: item.id, type: "button", role: "option", class: {
2553
+ 's-searchable-dropdown-item': true,
2554
+ 's-searchable-dropdown-item--selected': isSelected,
2555
+ 's-searchable-dropdown-item--focused': isFocused && !isSelected,
2556
+ }, "aria-selected": isSelected ? 'true' : 'false', onClick: () => this.selectItem(item) }, index.h("span", { class: {
2557
+ 's-searchable-dropdown-item-name': true,
2558
+ 's-searchable-dropdown-item-name--selected': isSelected,
2559
+ } }, this.getDisplayName(item)), isSelected && (index.h("i", { class: "sicon-check s-searchable-dropdown-item-check", "aria-hidden": "true" }))));
2560
+ });
2561
+ }
2562
+ get host() { return index.getElement(this); }
2563
+ static get watchers() { return {
2564
+ "items": ["onItemsChange"]
2565
+ }; }
2566
+ };
2567
+
2074
2568
  exports.salla_bullet_delivery = SallaBulletDelivery;
2569
+ exports.salla_searchable_dropdown = SallaSearchableDropdown;