@salla.sa/twilight-components 1.0.22 → 1.0.23

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 (33) hide show
  1. package/dist/cjs/index.cjs.js +2 -2
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/salla-button_5.cjs.entry.js +17 -17
  4. package/dist/cjs/{salla-login-c438bb35.js → salla-login-6229ec94.js} +1 -1
  5. package/dist/cjs/{salla-search-45173394.js → salla-search-eb0112c0.js} +16 -23
  6. package/dist/cjs/salla-search.cjs.entry.js +1 -1
  7. package/dist/cjs/twilight-components.cjs.js +1 -1
  8. package/dist/collection/components/salla-login/salla-login.css +15 -2
  9. package/dist/collection/components/salla-login/salla-login.js +1 -1
  10. package/dist/collection/components/salla-modal/salla-modal.js +20 -19
  11. package/dist/collection/components/salla-search/salla-search.css +1 -0
  12. package/dist/collection/components/salla-search/salla-search.js +19 -62
  13. package/dist/collection/components/salla-search/search-response.js +1 -0
  14. package/dist/esm/index.js +2 -2
  15. package/dist/esm/loader.js +1 -1
  16. package/dist/esm/salla-button_5.entry.js +17 -17
  17. package/dist/esm/{salla-login-dd957742.js → salla-login-c368f5b3.js} +1 -1
  18. package/dist/esm/{salla-search-5e691ebb.js → salla-search-57bd45eb.js} +16 -23
  19. package/dist/esm/salla-search.entry.js +1 -1
  20. package/dist/esm/twilight-components.js +1 -1
  21. package/dist/twilight-components/index.esm.js +1 -1
  22. package/dist/twilight-components/p-47f3d098.entry.js +1 -0
  23. package/dist/twilight-components/p-48931f49.entry.js +1 -0
  24. package/dist/twilight-components/{p-3a4d963e.js → p-4d329f0d.js} +1 -1
  25. package/dist/twilight-components/p-e7edc889.js +1 -0
  26. package/dist/twilight-components/twilight-components.esm.js +1 -1
  27. package/dist/types/components/salla-search/salla-search.d.ts +2 -7
  28. package/dist/types/components/salla-search/search-response.d.ts +18 -0
  29. package/dist/types/components.d.ts +0 -16
  30. package/package.json +1 -1
  31. package/dist/twilight-components/p-1deb8111.entry.js +0 -1
  32. package/dist/twilight-components/p-5b2eb87d.entry.js +0 -1
  33. package/dist/twilight-components/p-81a61f4e.js +0 -1
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const sallaLogin = require('./salla-login-c438bb35.js');
6
- const sallaSearch = require('./salla-search-45173394.js');
5
+ const sallaLogin = require('./salla-login-6229ec94.js');
6
+ const sallaSearch = require('./salla-search-eb0112c0.js');
7
7
  require('./index-714023c8.js');
8
8
  require('./Helper-fcea994c.js');
9
9
 
@@ -14,7 +14,7 @@ const patchEsm = () => {
14
14
  const defineCustomElements = (win, options) => {
15
15
  if (typeof window === 'undefined') return Promise.resolve();
16
16
  return patchEsm().then(() => {
17
- return index.bootstrapLazy([["salla-button_5.cjs",[[0,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"loginTypeTitle":[1,"login-type-title"],"loginText":[1,"login-text"],"smsLabel":[1,"sms-label"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"enterText":[1,"enter-text"],"bySMSText":[1,"by-s-m-s-text"],"byEmailText":[1,"by-email-text"],"backText":[1,"back-text"],"show":[64]},[[0,"verified","onVerified"],[0,"backClicked","onbackClicked"]]],[0,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[1],"by":[1],"backText":[1,"back-text"],"autoReload":[4,"auto-reload"],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"phone":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"getValues":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization.cjs",[[4,"salla-localization",{"languagesTitle":[1,"languages-title"],"currenciesTitle":[1,"currencies-title"],"ok":[1],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer.cjs",[[0,"salla-offer",{"offer":[32],"show":[64]}]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"buttonText":[1,"button-text"],"countryCode":[1,"country-code"],"subscribeText":[1,"subscribe-text"],"cancelText":[1,"cancel-text"],"subTitle":[1,"sub-title"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"mobilePlaceholder":[1,"mobile-placeholder"],"emailPlaceholder":[1,"email-placeholder"],"productId":[2,"product-id"],"subscribedMessage":[1,"subscribed-message"],"isSubscribed":[1028,"is-subscribed"],"submit":[64]}]]],["salla-rating.cjs",[[0,"salla-rating",{"order":[32],"show":[64],"hide":[64]}]]],["salla-search.cjs",[[0,"salla-search",{"placeholder":[1],"noResultsText":[1,"no-results-text"],"results":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]]]]], options);
17
+ return index.bootstrapLazy([["salla-button_5.cjs",[[0,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"loginTypeTitle":[1,"login-type-title"],"loginText":[1,"login-text"],"smsLabel":[1,"sms-label"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"enterText":[1,"enter-text"],"bySMSText":[1,"by-s-m-s-text"],"byEmailText":[1,"by-email-text"],"backText":[1,"back-text"],"show":[64]},[[0,"verified","onVerified"],[0,"backClicked","onbackClicked"]]],[0,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[1],"by":[1],"backText":[1,"back-text"],"autoReload":[4,"auto-reload"],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"phone":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"getValues":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization.cjs",[[4,"salla-localization",{"languagesTitle":[1,"languages-title"],"currenciesTitle":[1,"currencies-title"],"ok":[1],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer.cjs",[[0,"salla-offer",{"offer":[32],"show":[64]}]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"buttonText":[1,"button-text"],"countryCode":[1,"country-code"],"subscribeText":[1,"subscribe-text"],"cancelText":[1,"cancel-text"],"subTitle":[1,"sub-title"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"mobilePlaceholder":[1,"mobile-placeholder"],"emailPlaceholder":[1,"email-placeholder"],"productId":[2,"product-id"],"subscribedMessage":[1,"subscribed-message"],"isSubscribed":[1028,"is-subscribed"],"submit":[64]}]]],["salla-rating.cjs",[[0,"salla-rating",{"order":[32],"show":[64],"hide":[64]}]]],["salla-search.cjs",[[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  const index = require('./index-714023c8.js');
6
6
  const Helper = require('./Helper-fcea994c.js');
7
- const sallaLogin = require('./salla-login-c438bb35.js');
7
+ const sallaLogin = require('./salla-login-6229ec94.js');
8
8
 
9
9
  const sallaButtonCss = ":host{display:block}";
10
10
 
@@ -160,22 +160,22 @@ const SallaModal = class {
160
160
  :
161
161
  [index.h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
162
162
  index.h("button", { class: "s-modal-close", onClick: () => this.closeModal(), type: "button" }, index.h("span", { class: "sicon-cancel" }))
163
- : '', this.error || this.success || this.icon
164
- ? index.h("div", { class: {
165
- 's-modal-icon': true,
166
- 's-modal-bg-error': this.error,
167
- 's-modal-bg-success': this.success,
168
- 's-modal-bg-normal': !this.error && !this.success,
169
- 's-modal-bg-primary': this.primary
170
- } }, index.h("i", { class: {
171
- [this.icon]: true,
172
- 's-modal-text-error': this.error,
173
- 's-modal-text-success': this.success,
174
- } }))
175
- : this.imageIcon ?
176
- index.h("img", { class: "s-modal-header-img", src: this.imageIcon })
177
- : '', this.title || this.subTitle ?
178
- index.h("div", { class: "s-modal-header-content" }, index.h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }), index.h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle }))
163
+ : '', this.title || this.subTitle ?
164
+ index.h("div", { class: "s-modal-header-inner" }, this.error || this.success || this.icon
165
+ ? index.h("div", { class: {
166
+ 's-modal-icon': true,
167
+ 's-modal-bg-error': this.error,
168
+ 's-modal-bg-success': this.success,
169
+ 's-modal-bg-normal': !this.error && !this.success,
170
+ 's-modal-bg-primary': this.primary
171
+ } }, index.h("i", { class: {
172
+ [this.icon]: true,
173
+ 's-modal-text-error': this.error,
174
+ 's-modal-text-success': this.success,
175
+ } }))
176
+ : this.imageIcon ?
177
+ index.h("img", { class: "s-modal-header-img", src: this.imageIcon })
178
+ : '', index.h("div", { class: "s-modal-header-content" }, index.h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }), index.h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle })))
179
179
  : ''),
180
180
  index.h("slot", null),
181
181
  index.h("slot", { name: "footer" })
@@ -3,7 +3,7 @@
3
3
  const index = require('./index-714023c8.js');
4
4
  const Helper = require('./Helper-fcea994c.js');
5
5
 
6
- const sallaLoginCss = "salla-verify{display:block}";
6
+ const sallaLoginCss = "salla-verify{display:block}#salla-login .s-modal-body{overflow:inherit}";
7
7
 
8
8
  const SallaLogin = class {
9
9
  constructor(hostRef) {
@@ -3,30 +3,25 @@
3
3
  const index = require('./index-714023c8.js');
4
4
  const Helper = require('./Helper-fcea994c.js');
5
5
 
6
- const sallaSearchCss = "#s-search-modal .s-modal-wrapper{align-items:flex-start;padding:0}#s-search-modal .s-modal-spacer{display:inline}#s-search-modal .s-modal-body{padding:0;max-width:90%;margin-top:3.2rem}#s-search-modal .s-modal-close{top:1rem}";
6
+ const sallaSearchCss = "#s-search-modal .s-modal-wrapper{align-items:flex-start;padding:0}#s-search-modal .s-modal-spacer{display:inline}#s-search-modal .s-modal-body{padding:0;max-width:90%;margin-top:3.2rem;border-radius:0.5rem}#s-search-modal .s-modal-close{top:1rem}";
7
7
 
8
8
  const SallaSearch = class {
9
9
  constructor(hostRef) {
10
10
  index.registerInstance(this, hostRef);
11
11
  var _a;
12
- this.results = [];
13
- /**
14
- * Override search placeholder.
15
- */
16
- this.placeholder = salla.lang.get('blocks.header.search_placeholder');
17
- /**
18
- * Override no results error message.
19
- */
20
- this.noResultsText = salla.lang.get('common.elements.no_options');
21
12
  Helper.Helper.setHost(this.host);
22
13
  this.productSlot = ((_a = Helper.Helper.getElement('[slot="product"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || this.getDefaultProductSlot();
14
+ salla.event.on('languages::translations.loaded', () => {
15
+ this.placeholder = salla.lang.get('blocks.header.search_placeholder');
16
+ this.noResultsText = salla.lang.get('common.elements.no_options');
17
+ });
23
18
  }
24
19
  onModalOpen() {
25
20
  this.modal.querySelector('.s-search-input').focus();
26
21
  }
27
22
  onModalClose() {
28
23
  this.modal.querySelector('.s-search-input').value = '';
29
- this.results = [];
24
+ this.results = undefined;
30
25
  this.afterSearching();
31
26
  }
32
27
  getDefaultProductSlot() {
@@ -41,7 +36,7 @@ const SallaSearch = class {
41
36
  search(e) {
42
37
  Helper.Helper.hideElement(this.noResults);
43
38
  if (e.target.value.length === 0) {
44
- this.results = [];
39
+ this.results = undefined;
45
40
  this.afterSearching();
46
41
  return;
47
42
  }
@@ -51,26 +46,24 @@ const SallaSearch = class {
51
46
  //run loading spinner or stop it
52
47
  Helper.Helper.toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
53
48
  salla.search.api.search(e.target.value)
54
- .then(response => this.results = response.results)
55
- .catch(err => err !== 'Query Same As Previous!' ? this.results = [] : null)
49
+ .then(response => this.results = response)
50
+ .catch(err => err !== 'Query Same As Previous!' ? this.results = undefined : null)
56
51
  .finally(() => this.afterSearching(/*isEmpty*/ false));
57
52
  }
58
53
  afterSearching(isEmpty = true) {
59
- this.noResults.style.display = isEmpty || this.results.length > 0 ? 'none' : 'block';
60
- Helper.Helper.toggleElement(this.container, 's-search-container-open', 'no-results', () => this.results.length)
54
+ var _a;
55
+ this.noResults.style.display = isEmpty || ((_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length) > 0 ? 'none' : 'block';
56
+ Helper.Helper.toggleElement(this.container, 's-search-container-open', 'no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
61
57
  .toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
62
58
  salla.search.api.previousQuery = ''; //avoid having error 'Query Same As Previous' after reopen modal;
63
59
  }
64
60
  render() {
65
61
  var _a;
66
62
  return (index.h("salla-modal", { position: "top", id: "s-search-modal", ref: modal => this.modal = modal }, index.h("div", { class: "s-search-container", ref: container => this.container = container }, index.h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e) }), index.h("span", { class: "s-search-icon" }, index.h("i", { class: "sicon-search", ref: el => this.searchIcon = el })), index.h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
67
- _a.map(item => {
68
- var _a;
69
- return index.h("a", { href: item.url, class: "s-search-product", innerHTML: this.productSlot
70
- .replace(/\{name\}/g, item.title)
71
- .replace(/\{price\}/g, (_a = item.price) === null || _a === void 0 ? void 0 : _a.after) //todo:: get discounted price too
72
- .replace(/\{image\}/g, item.thumb) });
73
- }), index.h("p", { ref: el => this.noResults = el, class: "s-search-no-results" }, this.noResultsText)))));
63
+ _a.data.map(item => index.h("a", { href: item.url, class: "s-search-product", innerHTML: this.productSlot
64
+ .replace(/\{name\}/g, item.name)
65
+ .replace(/\{price\}/g, item.price) //todo:: get discounted price too
66
+ .replace(/\{image\}/g, item.image_url) })), index.h("p", { ref: el => this.noResults = el, class: "s-search-no-results" }, this.noResultsText)))));
74
67
  }
75
68
  /**
76
69
  * Run it one time after load
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const sallaSearch = require('./salla-search-45173394.js');
5
+ const sallaSearch = require('./salla-search-eb0112c0.js');
6
6
  require('./index-714023c8.js');
7
7
  require('./Helper-fcea994c.js');
8
8
 
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["salla-button_5.cjs",[[0,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"loginTypeTitle":[1,"login-type-title"],"loginText":[1,"login-text"],"smsLabel":[1,"sms-label"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"enterText":[1,"enter-text"],"bySMSText":[1,"by-s-m-s-text"],"byEmailText":[1,"by-email-text"],"backText":[1,"back-text"],"show":[64]},[[0,"verified","onVerified"],[0,"backClicked","onbackClicked"]]],[0,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[1],"by":[1],"backText":[1,"back-text"],"autoReload":[4,"auto-reload"],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"phone":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"getValues":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization.cjs",[[4,"salla-localization",{"languagesTitle":[1,"languages-title"],"currenciesTitle":[1,"currencies-title"],"ok":[1],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer.cjs",[[0,"salla-offer",{"offer":[32],"show":[64]}]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"buttonText":[1,"button-text"],"countryCode":[1,"country-code"],"subscribeText":[1,"subscribe-text"],"cancelText":[1,"cancel-text"],"subTitle":[1,"sub-title"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"mobilePlaceholder":[1,"mobile-placeholder"],"emailPlaceholder":[1,"email-placeholder"],"productId":[2,"product-id"],"subscribedMessage":[1,"subscribed-message"],"isSubscribed":[1028,"is-subscribed"],"submit":[64]}]]],["salla-rating.cjs",[[0,"salla-rating",{"order":[32],"show":[64],"hide":[64]}]]],["salla-search.cjs",[[0,"salla-search",{"placeholder":[1],"noResultsText":[1,"no-results-text"],"results":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]]]]], options);
18
+ return index.bootstrapLazy([["salla-button_5.cjs",[[0,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"loginTypeTitle":[1,"login-type-title"],"loginText":[1,"login-text"],"smsLabel":[1,"sms-label"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"enterText":[1,"enter-text"],"bySMSText":[1,"by-s-m-s-text"],"byEmailText":[1,"by-email-text"],"backText":[1,"back-text"],"show":[64]},[[0,"verified","onVerified"],[0,"backClicked","onbackClicked"]]],[0,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[1],"by":[1],"backText":[1,"back-text"],"autoReload":[4,"auto-reload"],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"phone":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"getValues":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-branches.cjs",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization.cjs",[[4,"salla-localization",{"languagesTitle":[1,"languages-title"],"currenciesTitle":[1,"currencies-title"],"ok":[1],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer.cjs",[[0,"salla-offer",{"offer":[32],"show":[64]}]]],["salla-product-availability.cjs",[[4,"salla-product-availability",{"channels":[1],"buttonText":[1,"button-text"],"countryCode":[1,"country-code"],"subscribeText":[1,"subscribe-text"],"cancelText":[1,"cancel-text"],"subTitle":[1,"sub-title"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"mobilePlaceholder":[1,"mobile-placeholder"],"emailPlaceholder":[1,"email-placeholder"],"productId":[2,"product-id"],"subscribedMessage":[1,"subscribed-message"],"isSubscribed":[1028,"is-subscribed"],"submit":[64]}]]],["salla-rating.cjs",[[0,"salla-rating",{"order":[32],"show":[64],"hide":[64]}]]],["salla-search.cjs",[[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]]]]], options);
19
19
  });
@@ -1,3 +1,16 @@
1
- salla-verify{
2
- display: block;
1
+ /**
2
+ * Initial Variables
3
+ */
4
+ /**
5
+ * Functions
6
+ */
7
+ /**
8
+ * Delivered variables
9
+ */
10
+ salla-verify {
11
+ display: block;
12
+ }
13
+
14
+ #salla-login .s-modal-body {
15
+ overflow: inherit;
3
16
  }
@@ -155,7 +155,7 @@ export class SallaLogin {
155
155
  }
156
156
  static get is() { return "salla-login"; }
157
157
  static get originalStyleUrls() { return {
158
- "$": ["salla-login.css"]
158
+ "$": ["salla-login.scss"]
159
159
  }; }
160
160
  static get styleUrls() { return {
161
161
  "$": ["salla-login.css"]
@@ -91,26 +91,27 @@ export class SallaModal {
91
91
  h("button", { class: "s-modal-close", onClick: () => this.closeModal(), type: "button" },
92
92
  h("span", { class: "sicon-cancel" }))
93
93
  : '',
94
- this.error || this.success || this.icon
95
- ? h("div", { class: {
96
- 's-modal-icon': true,
97
- 's-modal-bg-error': this.error,
98
- 's-modal-bg-success': this.success,
99
- 's-modal-bg-normal': !this.error && !this.success,
100
- 's-modal-bg-primary': this.primary
101
- } },
102
- h("i", { class: {
103
- [this.icon]: true,
104
- 's-modal-text-error': this.error,
105
- 's-modal-text-success': this.success,
106
- } }))
107
- : this.imageIcon ?
108
- h("img", { class: "s-modal-header-img", src: this.imageIcon })
109
- : '',
110
94
  this.title || this.subTitle ?
111
- h("div", { class: "s-modal-header-content" },
112
- h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }),
113
- h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle }))
95
+ h("div", { class: "s-modal-header-inner" },
96
+ this.error || this.success || this.icon
97
+ ? h("div", { class: {
98
+ 's-modal-icon': true,
99
+ 's-modal-bg-error': this.error,
100
+ 's-modal-bg-success': this.success,
101
+ 's-modal-bg-normal': !this.error && !this.success,
102
+ 's-modal-bg-primary': this.primary
103
+ } },
104
+ h("i", { class: {
105
+ [this.icon]: true,
106
+ 's-modal-text-error': this.error,
107
+ 's-modal-text-success': this.success,
108
+ } }))
109
+ : this.imageIcon ?
110
+ h("img", { class: "s-modal-header-img", src: this.imageIcon })
111
+ : '',
112
+ h("div", { class: "s-modal-header-content" },
113
+ h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }),
114
+ h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle })))
114
115
  : ''),
115
116
  h("slot", null),
116
117
  h("slot", { name: "footer" })
@@ -18,6 +18,7 @@
18
18
  padding: 0;
19
19
  max-width: 90%;
20
20
  margin-top: 3.2rem;
21
+ border-radius: 0.5rem;
21
22
  }
22
23
  #s-search-modal .s-modal-close {
23
24
  top: 1rem;
@@ -1,26 +1,21 @@
1
- import { Component, h, Prop, State, Element, Listen } from '@stencil/core';
1
+ import { Component, h, State, Element, Listen } from '@stencil/core';
2
2
  import Helper from "../../Helpers/Helper";
3
3
  export class SallaSearch {
4
4
  constructor() {
5
5
  var _a;
6
- this.results = [];
7
- /**
8
- * Override search placeholder.
9
- */
10
- this.placeholder = salla.lang.get('blocks.header.search_placeholder');
11
- /**
12
- * Override no results error message.
13
- */
14
- this.noResultsText = salla.lang.get('common.elements.no_options');
15
6
  Helper.setHost(this.host);
16
7
  this.productSlot = ((_a = Helper.getElement('[slot="product"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || this.getDefaultProductSlot();
8
+ salla.event.on('languages::translations.loaded', () => {
9
+ this.placeholder = salla.lang.get('blocks.header.search_placeholder');
10
+ this.noResultsText = salla.lang.get('common.elements.no_options');
11
+ });
17
12
  }
18
13
  onModalOpen() {
19
14
  this.modal.querySelector('.s-search-input').focus();
20
15
  }
21
16
  onModalClose() {
22
17
  this.modal.querySelector('.s-search-input').value = '';
23
- this.results = [];
18
+ this.results = undefined;
24
19
  this.afterSearching();
25
20
  }
26
21
  getDefaultProductSlot() {
@@ -35,7 +30,7 @@ export class SallaSearch {
35
30
  search(e) {
36
31
  Helper.hideElement(this.noResults);
37
32
  if (e.target.value.length === 0) {
38
- this.results = [];
33
+ this.results = undefined;
39
34
  this.afterSearching();
40
35
  return;
41
36
  }
@@ -45,13 +40,14 @@ export class SallaSearch {
45
40
  //run loading spinner or stop it
46
41
  Helper.toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
47
42
  salla.search.api.search(e.target.value)
48
- .then(response => this.results = response.results)
49
- .catch(err => err !== 'Query Same As Previous!' ? this.results = [] : null)
43
+ .then(response => this.results = response)
44
+ .catch(err => err !== 'Query Same As Previous!' ? this.results = undefined : null)
50
45
  .finally(() => this.afterSearching(/*isEmpty*/ false));
51
46
  }
52
47
  afterSearching(isEmpty = true) {
53
- this.noResults.style.display = isEmpty || this.results.length > 0 ? 'none' : 'block';
54
- Helper.toggleElement(this.container, 's-search-container-open', 'no-results', () => this.results.length)
48
+ var _a;
49
+ this.noResults.style.display = isEmpty || ((_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length) > 0 ? 'none' : 'block';
50
+ Helper.toggleElement(this.container, 's-search-container-open', 'no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
55
51
  .toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
56
52
  salla.search.api.previousQuery = ''; //avoid having error 'Query Same As Previous' after reopen modal;
57
53
  }
@@ -63,13 +59,10 @@ export class SallaSearch {
63
59
  h("span", { class: "s-search-icon" },
64
60
  h("i", { class: "sicon-search", ref: el => this.searchIcon = el })),
65
61
  h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
66
- _a.map(item => {
67
- var _a;
68
- return h("a", { href: item.url, class: "s-search-product", innerHTML: this.productSlot
69
- .replace(/\{name\}/g, item.title)
70
- .replace(/\{price\}/g, (_a = item.price) === null || _a === void 0 ? void 0 : _a.after) //todo:: get discounted price too
71
- .replace(/\{image\}/g, item.thumb) });
72
- }),
62
+ _a.data.map(item => h("a", { href: item.url, class: "s-search-product", innerHTML: this.productSlot
63
+ .replace(/\{name\}/g, item.name)
64
+ .replace(/\{price\}/g, item.price) //todo:: get discounted price too
65
+ .replace(/\{image\}/g, item.image_url) })),
73
66
  h("p", { ref: el => this.noResults = el, class: "s-search-no-results" }, this.noResultsText)))));
74
67
  }
75
68
  /**
@@ -85,46 +78,10 @@ export class SallaSearch {
85
78
  static get styleUrls() { return {
86
79
  "$": ["salla-search.css"]
87
80
  }; }
88
- static get properties() { return {
89
- "placeholder": {
90
- "type": "string",
91
- "mutable": false,
92
- "complexType": {
93
- "original": "string",
94
- "resolved": "string",
95
- "references": {}
96
- },
97
- "required": false,
98
- "optional": false,
99
- "docs": {
100
- "tags": [],
101
- "text": "Override search placeholder."
102
- },
103
- "attribute": "placeholder",
104
- "reflect": false,
105
- "defaultValue": "salla.lang.get('blocks.header.search_placeholder')"
106
- },
107
- "noResultsText": {
108
- "type": "string",
109
- "mutable": false,
110
- "complexType": {
111
- "original": "string",
112
- "resolved": "string",
113
- "references": {}
114
- },
115
- "required": false,
116
- "optional": false,
117
- "docs": {
118
- "tags": [],
119
- "text": "Override no results error message."
120
- },
121
- "attribute": "no-results-text",
122
- "reflect": false,
123
- "defaultValue": "salla.lang.get('common.elements.no_options')"
124
- }
125
- }; }
126
81
  static get states() { return {
127
- "results": {}
82
+ "results": {},
83
+ "placeholder": {},
84
+ "noResultsText": {}
128
85
  }; }
129
86
  static get elementRef() { return "host"; }
130
87
  static get listeners() { return [{
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { S as SallaLogin } from './salla-login-dd957742.js';
2
- export { S as SallaSearch } from './salla-search-5e691ebb.js';
1
+ export { S as SallaLogin } from './salla-login-c368f5b3.js';
2
+ export { S as SallaSearch } from './salla-search-57bd45eb.js';
3
3
  import './index-a1bf769d.js';
4
4
  import './Helper-d07ebbc7.js';
@@ -10,7 +10,7 @@ const patchEsm = () => {
10
10
  const defineCustomElements = (win, options) => {
11
11
  if (typeof window === 'undefined') return Promise.resolve();
12
12
  return patchEsm().then(() => {
13
- return bootstrapLazy([["salla-button_5",[[0,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"loginTypeTitle":[1,"login-type-title"],"loginText":[1,"login-text"],"smsLabel":[1,"sms-label"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"enterText":[1,"enter-text"],"bySMSText":[1,"by-s-m-s-text"],"byEmailText":[1,"by-email-text"],"backText":[1,"back-text"],"show":[64]},[[0,"verified","onVerified"],[0,"backClicked","onbackClicked"]]],[0,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[1],"by":[1],"backText":[1,"back-text"],"autoReload":[4,"auto-reload"],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"phone":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"getValues":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-branches",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization",[[4,"salla-localization",{"languagesTitle":[1,"languages-title"],"currenciesTitle":[1,"currencies-title"],"ok":[1],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer",[[0,"salla-offer",{"offer":[32],"show":[64]}]]],["salla-product-availability",[[4,"salla-product-availability",{"channels":[1],"buttonText":[1,"button-text"],"countryCode":[1,"country-code"],"subscribeText":[1,"subscribe-text"],"cancelText":[1,"cancel-text"],"subTitle":[1,"sub-title"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"mobilePlaceholder":[1,"mobile-placeholder"],"emailPlaceholder":[1,"email-placeholder"],"productId":[2,"product-id"],"subscribedMessage":[1,"subscribed-message"],"isSubscribed":[1028,"is-subscribed"],"submit":[64]}]]],["salla-rating",[[0,"salla-rating",{"order":[32],"show":[64],"hide":[64]}]]],["salla-search",[[0,"salla-search",{"placeholder":[1],"noResultsText":[1,"no-results-text"],"results":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]]]]], options);
13
+ return bootstrapLazy([["salla-button_5",[[0,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"loginTypeTitle":[1,"login-type-title"],"loginText":[1,"login-text"],"smsLabel":[1,"sms-label"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"enterText":[1,"enter-text"],"bySMSText":[1,"by-s-m-s-text"],"byEmailText":[1,"by-email-text"],"backText":[1,"back-text"],"show":[64]},[[0,"verified","onVerified"],[0,"backClicked","onbackClicked"]]],[0,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[1],"by":[1],"backText":[1,"back-text"],"autoReload":[4,"auto-reload"],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"phone":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"getValues":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-branches",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization",[[4,"salla-localization",{"languagesTitle":[1,"languages-title"],"currenciesTitle":[1,"currencies-title"],"ok":[1],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer",[[0,"salla-offer",{"offer":[32],"show":[64]}]]],["salla-product-availability",[[4,"salla-product-availability",{"channels":[1],"buttonText":[1,"button-text"],"countryCode":[1,"country-code"],"subscribeText":[1,"subscribe-text"],"cancelText":[1,"cancel-text"],"subTitle":[1,"sub-title"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"mobilePlaceholder":[1,"mobile-placeholder"],"emailPlaceholder":[1,"email-placeholder"],"productId":[2,"product-id"],"subscribedMessage":[1,"subscribed-message"],"isSubscribed":[1028,"is-subscribed"],"submit":[64]}]]],["salla-rating",[[0,"salla-rating",{"order":[32],"show":[64],"hide":[64]}]]],["salla-search",[[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]]]]], options);
14
14
  });
15
15
  };
16
16
 
@@ -1,6 +1,6 @@
1
1
  import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-a1bf769d.js';
2
2
  import { H as Helper } from './Helper-d07ebbc7.js';
3
- export { S as salla_login } from './salla-login-dd957742.js';
3
+ export { S as salla_login } from './salla-login-c368f5b3.js';
4
4
 
5
5
  const sallaButtonCss = ":host{display:block}";
6
6
 
@@ -156,22 +156,22 @@ const SallaModal = class {
156
156
  :
157
157
  [h("div", { class: { 's-modal-header': true, 's-modal-is-center': this.icon != '' || this.imageIcon != '' } }, this.isClosable ?
158
158
  h("button", { class: "s-modal-close", onClick: () => this.closeModal(), type: "button" }, h("span", { class: "sicon-cancel" }))
159
- : '', this.error || this.success || this.icon
160
- ? h("div", { class: {
161
- 's-modal-icon': true,
162
- 's-modal-bg-error': this.error,
163
- 's-modal-bg-success': this.success,
164
- 's-modal-bg-normal': !this.error && !this.success,
165
- 's-modal-bg-primary': this.primary
166
- } }, h("i", { class: {
167
- [this.icon]: true,
168
- 's-modal-text-error': this.error,
169
- 's-modal-text-success': this.success,
170
- } }))
171
- : this.imageIcon ?
172
- h("img", { class: "s-modal-header-img", src: this.imageIcon })
173
- : '', this.title || this.subTitle ?
174
- h("div", { class: "s-modal-header-content" }, h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }), h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle }))
159
+ : '', this.title || this.subTitle ?
160
+ h("div", { class: "s-modal-header-inner" }, this.error || this.success || this.icon
161
+ ? h("div", { class: {
162
+ 's-modal-icon': true,
163
+ 's-modal-bg-error': this.error,
164
+ 's-modal-bg-success': this.success,
165
+ 's-modal-bg-normal': !this.error && !this.success,
166
+ 's-modal-bg-primary': this.primary
167
+ } }, h("i", { class: {
168
+ [this.icon]: true,
169
+ 's-modal-text-error': this.error,
170
+ 's-modal-text-success': this.success,
171
+ } }))
172
+ : this.imageIcon ?
173
+ h("img", { class: "s-modal-header-img", src: this.imageIcon })
174
+ : '', h("div", { class: "s-modal-header-content" }, h("div", { class: { 's-modal-title': true, 's-modal-title-below': this.subTitleFirst }, innerHTML: this.title }), h("p", { class: { 's-modal-sub-title': true }, innerHTML: this.subTitle })))
175
175
  : ''),
176
176
  h("slot", null),
177
177
  h("slot", { name: "footer" })
@@ -1,7 +1,7 @@
1
1
  import { r as registerInstance, h, g as getElement } from './index-a1bf769d.js';
2
2
  import { H as Helper } from './Helper-d07ebbc7.js';
3
3
 
4
- const sallaLoginCss = "salla-verify{display:block}";
4
+ const sallaLoginCss = "salla-verify{display:block}#salla-login .s-modal-body{overflow:inherit}";
5
5
 
6
6
  const SallaLogin = class {
7
7
  constructor(hostRef) {
@@ -1,30 +1,25 @@
1
1
  import { r as registerInstance, h, g as getElement } from './index-a1bf769d.js';
2
2
  import { H as Helper } from './Helper-d07ebbc7.js';
3
3
 
4
- const sallaSearchCss = "#s-search-modal .s-modal-wrapper{align-items:flex-start;padding:0}#s-search-modal .s-modal-spacer{display:inline}#s-search-modal .s-modal-body{padding:0;max-width:90%;margin-top:3.2rem}#s-search-modal .s-modal-close{top:1rem}";
4
+ const sallaSearchCss = "#s-search-modal .s-modal-wrapper{align-items:flex-start;padding:0}#s-search-modal .s-modal-spacer{display:inline}#s-search-modal .s-modal-body{padding:0;max-width:90%;margin-top:3.2rem;border-radius:0.5rem}#s-search-modal .s-modal-close{top:1rem}";
5
5
 
6
6
  const SallaSearch = class {
7
7
  constructor(hostRef) {
8
8
  registerInstance(this, hostRef);
9
9
  var _a;
10
- this.results = [];
11
- /**
12
- * Override search placeholder.
13
- */
14
- this.placeholder = salla.lang.get('blocks.header.search_placeholder');
15
- /**
16
- * Override no results error message.
17
- */
18
- this.noResultsText = salla.lang.get('common.elements.no_options');
19
10
  Helper.setHost(this.host);
20
11
  this.productSlot = ((_a = Helper.getElement('[slot="product"]')) === null || _a === void 0 ? void 0 : _a.innerHTML) || this.getDefaultProductSlot();
12
+ salla.event.on('languages::translations.loaded', () => {
13
+ this.placeholder = salla.lang.get('blocks.header.search_placeholder');
14
+ this.noResultsText = salla.lang.get('common.elements.no_options');
15
+ });
21
16
  }
22
17
  onModalOpen() {
23
18
  this.modal.querySelector('.s-search-input').focus();
24
19
  }
25
20
  onModalClose() {
26
21
  this.modal.querySelector('.s-search-input').value = '';
27
- this.results = [];
22
+ this.results = undefined;
28
23
  this.afterSearching();
29
24
  }
30
25
  getDefaultProductSlot() {
@@ -39,7 +34,7 @@ const SallaSearch = class {
39
34
  search(e) {
40
35
  Helper.hideElement(this.noResults);
41
36
  if (e.target.value.length === 0) {
42
- this.results = [];
37
+ this.results = undefined;
43
38
  this.afterSearching();
44
39
  return;
45
40
  }
@@ -49,26 +44,24 @@ const SallaSearch = class {
49
44
  //run loading spinner or stop it
50
45
  Helper.toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => true);
51
46
  salla.search.api.search(e.target.value)
52
- .then(response => this.results = response.results)
53
- .catch(err => err !== 'Query Same As Previous!' ? this.results = [] : null)
47
+ .then(response => this.results = response)
48
+ .catch(err => err !== 'Query Same As Previous!' ? this.results = undefined : null)
54
49
  .finally(() => this.afterSearching(/*isEmpty*/ false));
55
50
  }
56
51
  afterSearching(isEmpty = true) {
57
- this.noResults.style.display = isEmpty || this.results.length > 0 ? 'none' : 'block';
58
- Helper.toggleElement(this.container, 's-search-container-open', 'no-results', () => this.results.length)
52
+ var _a;
53
+ this.noResults.style.display = isEmpty || ((_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length) > 0 ? 'none' : 'block';
54
+ Helper.toggleElement(this.container, 's-search-container-open', 'no-results', () => { var _a; return (_a = this.results) === null || _a === void 0 ? void 0 : _a.data.length; })
59
55
  .toggleElement(this.searchIcon, 's-search-spinner-loader', 'sicon-search', () => false); //stop searching anime
60
56
  salla.search.api.previousQuery = ''; //avoid having error 'Query Same As Previous' after reopen modal;
61
57
  }
62
58
  render() {
63
59
  var _a;
64
60
  return (h("salla-modal", { position: "top", id: "s-search-modal", ref: modal => this.modal = modal }, h("div", { class: "s-search-container", ref: container => this.container = container }, h("input", { class: "s-search-input", type: "text", placeholder: this.placeholder, onInput: e => this.search(e) }), h("span", { class: "s-search-icon" }, h("i", { class: "sicon-search", ref: el => this.searchIcon = el })), h("div", { class: "s-search-results" }, (_a = this.results) === null || _a === void 0 ? void 0 :
65
- _a.map(item => {
66
- var _a;
67
- return h("a", { href: item.url, class: "s-search-product", innerHTML: this.productSlot
68
- .replace(/\{name\}/g, item.title)
69
- .replace(/\{price\}/g, (_a = item.price) === null || _a === void 0 ? void 0 : _a.after) //todo:: get discounted price too
70
- .replace(/\{image\}/g, item.thumb) });
71
- }), h("p", { ref: el => this.noResults = el, class: "s-search-no-results" }, this.noResultsText)))));
61
+ _a.data.map(item => h("a", { href: item.url, class: "s-search-product", innerHTML: this.productSlot
62
+ .replace(/\{name\}/g, item.name)
63
+ .replace(/\{price\}/g, item.price) //todo:: get discounted price too
64
+ .replace(/\{image\}/g, item.image_url) })), h("p", { ref: el => this.noResults = el, class: "s-search-no-results" }, this.noResultsText)))));
72
65
  }
73
66
  /**
74
67
  * Run it one time after load
@@ -1,3 +1,3 @@
1
- export { S as salla_search } from './salla-search-5e691ebb.js';
1
+ export { S as salla_search } from './salla-search-57bd45eb.js';
2
2
  import './index-a1bf769d.js';
3
3
  import './Helper-d07ebbc7.js';
@@ -13,5 +13,5 @@ const patchBrowser = () => {
13
13
  };
14
14
 
15
15
  patchBrowser().then(options => {
16
- return bootstrapLazy([["salla-button_5",[[0,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"loginTypeTitle":[1,"login-type-title"],"loginText":[1,"login-text"],"smsLabel":[1,"sms-label"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"enterText":[1,"enter-text"],"bySMSText":[1,"by-s-m-s-text"],"byEmailText":[1,"by-email-text"],"backText":[1,"back-text"],"show":[64]},[[0,"verified","onVerified"],[0,"backClicked","onbackClicked"]]],[0,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[1],"by":[1],"backText":[1,"back-text"],"autoReload":[4,"auto-reload"],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"phone":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"getValues":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-branches",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization",[[4,"salla-localization",{"languagesTitle":[1,"languages-title"],"currenciesTitle":[1,"currencies-title"],"ok":[1],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer",[[0,"salla-offer",{"offer":[32],"show":[64]}]]],["salla-product-availability",[[4,"salla-product-availability",{"channels":[1],"buttonText":[1,"button-text"],"countryCode":[1,"country-code"],"subscribeText":[1,"subscribe-text"],"cancelText":[1,"cancel-text"],"subTitle":[1,"sub-title"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"mobilePlaceholder":[1,"mobile-placeholder"],"emailPlaceholder":[1,"email-placeholder"],"productId":[2,"product-id"],"subscribedMessage":[1,"subscribed-message"],"isSubscribed":[1028,"is-subscribed"],"submit":[64]}]]],["salla-rating",[[0,"salla-rating",{"order":[32],"show":[64],"hide":[64]}]]],["salla-search",[[0,"salla-search",{"placeholder":[1],"noResultsText":[1,"no-results-text"],"results":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]]]]], options);
16
+ return bootstrapLazy([["salla-button_5",[[0,"salla-login",{"isEmailAllowed":[4,"is-email-allowed"],"loginTypeTitle":[1,"login-type-title"],"loginText":[1,"login-text"],"smsLabel":[1,"sms-label"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"enterText":[1,"enter-text"],"bySMSText":[1,"by-s-m-s-text"],"byEmailText":[1,"by-email-text"],"backText":[1,"back-text"],"show":[64]},[[0,"verified","onVerified"],[0,"backClicked","onbackClicked"]]],[0,"salla-verify",{"withoutModal":[4,"without-modal"],"url":[1],"by":[1],"backText":[1,"back-text"],"autoReload":[4,"auto-reload"],"getCode":[64],"show":[64]}],[0,"salla-tel-input",{"phone":[1025],"countryCode":[1025,"country-code"],"countryKey":[1025,"country-key"],"getValues":[64]}],[4,"salla-button",{"btnStyle":[513,"btn-style"],"loading":[516],"disabled":[516],"loaderPosition":[1,"loader-position"],"wide":[4],"load":[64],"stop":[64],"disable":[64],"enable":[64]}],[4,"salla-modal",{"error":[4],"success":[4],"primary":[4],"isClosable":[1028,"is-closable"],"width":[513],"position":[513],"visible":[516],"isLoading":[1540,"is-loading"],"subTitleFirst":[4,"sub-title-first"],"subTitle":[1,"sub-title"],"icon":[1],"imageIcon":[1,"image-icon"],"title":[32],"show":[64],"hide":[64],"setTitle":[64],"loading":[64],"stopLoading":[64]}]]],["salla-branches",[[4,"salla-branches",{"position":[1],"displayAs":[1,"display-as"],"browseProductsFrom":[1,"browse-products-from"],"branches":[16],"current":[1026],"open":[32],"selected":[32],"isOpenedBefore":[32],"show":[64],"hide":[64]}]]],["salla-localization",[[4,"salla-localization",{"languagesTitle":[1,"languages-title"],"currenciesTitle":[1,"currencies-title"],"ok":[1],"show":[64],"hide":[64],"submit":[64]}]]],["salla-offer",[[0,"salla-offer",{"offer":[32],"show":[64]}]]],["salla-product-availability",[[4,"salla-product-availability",{"channels":[1],"buttonText":[1,"button-text"],"countryCode":[1,"country-code"],"subscribeText":[1,"subscribe-text"],"cancelText":[1,"cancel-text"],"subTitle":[1,"sub-title"],"mobileLabel":[1,"mobile-label"],"emailLabel":[1,"email-label"],"mobilePlaceholder":[1,"mobile-placeholder"],"emailPlaceholder":[1,"email-placeholder"],"productId":[2,"product-id"],"subscribedMessage":[1,"subscribed-message"],"isSubscribed":[1028,"is-subscribed"],"submit":[64]}]]],["salla-rating",[[0,"salla-rating",{"order":[32],"show":[64],"hide":[64]}]]],["salla-search",[[0,"salla-search",{"results":[32],"placeholder":[32],"noResultsText":[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]]]]], options);
17
17
  });
@@ -1 +1 @@
1
- export{S as SallaLogin}from"./p-3a4d963e.js";export{S as SallaSearch}from"./p-81a61f4e.js";import"./p-6a5be894.js";import"./p-47f17d3b.js";
1
+ export{S as SallaLogin}from"./p-4d329f0d.js";export{S as SallaSearch}from"./p-e7edc889.js";import"./p-6a5be894.js";import"./p-47f17d3b.js";
@@ -0,0 +1 @@
1
+ export{S as salla_search}from"./p-e7edc889.js";import"./p-6a5be894.js";import"./p-47f17d3b.js";
@@ -0,0 +1 @@
1
+ import{r as i,h as t,H as s,g as e,c as a}from"./p-6a5be894.js";import{H as n}from"./p-47f17d3b.js";export{S as salla_login}from"./p-4d329f0d.js";const r=class{constructor(t){i(this,t),this.btnStyle="primary",this.loading=!1,this.disabled=!1,this.loaderPosition="before",this.wide=!1,this.hostAttributes={};for(let i=0;i<this.host.attributes.length;i++)this.hostAttributes[this.host.attributes[i].name]=this.host.attributes[i].value;this.hostAttributes.type=this.hostAttributes.type||"button",this.hostAttributes.class+=" s-button-btn btn--has-loading s-button-"+this.btnStyle+(this.wide?" s-button-wide ":"")+" loader-"+this.loaderPosition+("before"==this.loaderPosition?" s-button-loader-after":""),delete this.hostAttributes["btn-style"],delete this.hostAttributes.id,this.wide&&this.host.classList.add("s-button-wide")}async load(){return"center"==this.loaderPosition&&this.text.classList.add("s-button-hide"),this.host.setAttribute("loading",""),this.host}async stop(){return this.host.removeAttribute("loading"),this.host}async disable(){this.host.setAttribute("disabled","")}async enable(){this.host.removeAttribute("disabled")}handleVisible(i,t){this.btn.classList.remove("btn-"+t),this.btn.classList.add("btn-"+i)}handleLoading(i){n.toggleElement(this.btn,"btn--is-loading","btn--no-loading",(()=>i))}render(){return t(s,{class:"s-button-host-tag"},t("button",Object.assign({ref:i=>this.btn=i,disabled:this.disabled},this.hostAttributes),t("span",{class:"s-button-text",ref:i=>this.text=i},t("slot",null)),this.loading?t("span",{class:{"s-button-loader":!0,"s-button-loader-start":"start"===this.loaderPosition,"s-button-loader-end":"end"===this.loaderPosition,"s-button-loader-center":"center"===this.loaderPosition}}):""))}get host(){return e(this)}static get watchers(){return{btnStyle:["handleVisible"],loading:["handleLoading"]}}};r.style=":host{display:block}";const o=class{constructor(t){var s;i(this,t),this.modalOpened=a(this,"modalOpened",7),this.modalClosed=a(this,"modalClosed",7),this.error=!1,this.success=!1,this.primary=!1,this.isClosable=!0,this.width="md",this.position="middel",this.visible=!1,this.isLoading=!1,this.subTitleFirst=!1,this.subTitle="",this.icon="",this.imageIcon="",n.setHost(this.host),salla.event.on("modal::open",(i=>i.dataset.target==this.host.id&&this.show())),salla.event.on("modal::close",(i=>i.dataset.target==this.host.id&&this.hide())),this.title=this.host.title,this.host.removeAttribute("title"),null===(s=n.getElement("[slot=body]"))||void 0===s||s.classList.add("s-modal-body","s-modal-"+this.width)}handleVisible(i){if(!i)return this.toggleModal(!1),void this.modalClosed.emit();this.host.classList.remove("hidden"),setTimeout((()=>this.toggleModal(!0))),this.modalOpened.emit()}async show(){return this.host.setAttribute("visible",""),this.host}async hide(){return this.host.removeAttribute("visible"),this.host}async setTitle(i){return this.title=i,this.host}async loading(){return this.isLoading=!0,this.host}async stopLoading(){return this.isLoading=!1,this.host}toggleModal(i){n.toggleElement(this.host.querySelector("[slot=body]")||this.host,"s-modal-entering","s-modal-leaving",(()=>i)).toggleElement(this.overlay,"s-modal-entering","s-modal-overlay-leaving",(()=>i)).toggleElement(document.body,"modal-is-open","modal-is-closed",(()=>i)),i||setTimeout((()=>this.host.classList.add("hidden")),350)}closeModal(){this.isClosable&&this.host.removeAttribute("visible")}render(){return this.host.id=this.host.id||"salla-modal",t(s,{class:"s-modal-container hidden","aria-modal":"true",role:"dialog"},t("div",{class:"s-modal-wrapper"},t("div",{class:"s-modal-overlay",ref:i=>this.overlay=i,onClick:()=>this.closeModal()}),t("span",{class:"s-modal-spacer s-modal-align-"+this.position},"​"),t("div",{class:"s-modal-body s-modal-align-"+this.position+" s-modal-"+this.width,slot:"body"},this.isLoading?t("span",null,"Loading..."):[t("div",{class:{"s-modal-header":!0,"s-modal-is-center":""!=this.icon||""!=this.imageIcon}},this.isClosable?t("button",{class:"s-modal-close",onClick:()=>this.closeModal(),type:"button"},t("span",{class:"sicon-cancel"})):"",this.title||this.subTitle?t("div",{class:"s-modal-header-inner"},this.error||this.success||this.icon?t("div",{class:{"s-modal-icon":!0,"s-modal-bg-error":this.error,"s-modal-bg-success":this.success,"s-modal-bg-normal":!this.error&&!this.success,"s-modal-bg-primary":this.primary}},t("i",{class:{[this.icon]:!0,"s-modal-text-error":this.error,"s-modal-text-success":this.success}})):this.imageIcon?t("img",{class:"s-modal-header-img",src:this.imageIcon}):"",t("div",{class:"s-modal-header-content"},t("div",{class:{"s-modal-title":!0,"s-modal-title-below":this.subTitleFirst},innerHTML:this.title}),t("p",{class:{"s-modal-sub-title":!0},innerHTML:this.subTitle}))):""),t("slot",null),t("slot",{name:"footer"})])))}get host(){return e(this)}static get watchers(){return{visible:["handleVisible"]}}};var h,l=(function(i){var t;t=function(i){return function(){for(var t=[["Afghanistan (‫افغانستان‬‎)","af","93"],["Albania (Shqipëri)","al","355"],["Algeria (‫الجزائر‬‎)","dz","213"],["American Samoa","as","1",5,["684"]],["Andorra","ad","376"],["Angola","ao","244"],["Anguilla","ai","1",6,["264"]],["Antigua and Barbuda","ag","1",7,["268"]],["Argentina","ar","54"],["Armenia (Հայաստան)","am","374"],["Aruba","aw","297"],["Ascension Island","ac","247"],["Australia","au","61",0],["Austria (Österreich)","at","43"],["Azerbaijan (Azərbaycan)","az","994"],["Bahamas","bs","1",8,["242"]],["Bahrain (‫البحرين‬‎)","bh","973"],["Bangladesh (বাংলাদেশ)","bd","880"],["Barbados","bb","1",9,["246"]],["Belarus (Беларусь)","by","375"],["Belgium (België)","be","32"],["Belize","bz","501"],["Benin (Bénin)","bj","229"],["Bermuda","bm","1",10,["441"]],["Bhutan (འབྲུག)","bt","975"],["Bolivia","bo","591"],["Bosnia and Herzegovina (Босна и Херцеговина)","ba","387"],["Botswana","bw","267"],["Brazil (Brasil)","br","55"],["British Indian Ocean Territory","io","246"],["British Virgin Islands","vg","1",11,["284"]],["Brunei","bn","673"],["Bulgaria (България)","bg","359"],["Burkina Faso","bf","226"],["Burundi (Uburundi)","bi","257"],["Cambodia (កម្ពុជា)","kh","855"],["Cameroon (Cameroun)","cm","237"],["Canada","ca","1",1,["204","226","236","249","250","289","306","343","365","387","403","416","418","431","437","438","450","506","514","519","548","579","581","587","604","613","639","647","672","705","709","742","778","780","782","807","819","825","867","873","902","905"]],["Cape Verde (Kabu Verdi)","cv","238"],["Caribbean Netherlands","bq","599",1,["3","4","7"]],["Cayman Islands","ky","1",12,["345"]],["Central African Republic (République centrafricaine)","cf","236"],["Chad (Tchad)","td","235"],["Chile","cl","56"],["China (中国)","cn","86"],["Christmas Island","cx","61",2,["89164"]],["Cocos (Keeling) Islands","cc","61",1,["89162"]],["Colombia","co","57"],["Comoros (‫جزر القمر‬‎)","km","269"],["Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)","cd","243"],["Congo (Republic) (Congo-Brazzaville)","cg","242"],["Cook Islands","ck","682"],["Costa Rica","cr","506"],["Côte d’Ivoire","ci","225"],["Croatia (Hrvatska)","hr","385"],["Cuba","cu","53"],["Curaçao","cw","599",0],["Cyprus (Κύπρος)","cy","357"],["Czech Republic (Česká republika)","cz","420"],["Denmark (Danmark)","dk","45"],["Djibouti","dj","253"],["Dominica","dm","1",13,["767"]],["Dominican Republic (República Dominicana)","do","1",2,["809","829","849"]],["Ecuador","ec","593"],["Egypt (‫مصر‬‎)","eg","20"],["El Salvador","sv","503"],["Equatorial Guinea (Guinea Ecuatorial)","gq","240"],["Eritrea","er","291"],["Estonia (Eesti)","ee","372"],["Eswatini","sz","268"],["Ethiopia","et","251"],["Falkland Islands (Islas Malvinas)","fk","500"],["Faroe Islands (Føroyar)","fo","298"],["Fiji","fj","679"],["Finland (Suomi)","fi","358",0],["France","fr","33"],["French Guiana (Guyane française)","gf","594"],["French Polynesia (Polynésie française)","pf","689"],["Gabon","ga","241"],["Gambia","gm","220"],["Georgia (საქართველო)","ge","995"],["Germany (Deutschland)","de","49"],["Ghana (Gaana)","gh","233"],["Gibraltar","gi","350"],["Greece (Ελλάδα)","gr","30"],["Greenland (Kalaallit Nunaat)","gl","299"],["Grenada","gd","1",14,["473"]],["Guadeloupe","gp","590",0],["Guam","gu","1",15,["671"]],["Guatemala","gt","502"],["Guernsey","gg","44",1,["1481","7781","7839","7911"]],["Guinea (Guinée)","gn","224"],["Guinea-Bissau (Guiné Bissau)","gw","245"],["Guyana","gy","592"],["Haiti","ht","509"],["Honduras","hn","504"],["Hong Kong (香港)","hk","852"],["Hungary (Magyarország)","hu","36"],["Iceland (Ísland)","is","354"],["India (भारत)","in","91"],["Indonesia","id","62"],["Iran (‫ایران‬‎)","ir","98"],["Iraq (‫العراق‬‎)","iq","964"],["Ireland","ie","353"],["Isle of Man","im","44",2,["1624","74576","7524","7924","7624"]],["Israel (‫ישראל‬‎)","il","972"],["Italy (Italia)","it","39",0],["Jamaica","jm","1",4,["876","658"]],["Japan (日本)","jp","81"],["Jersey","je","44",3,["1534","7509","7700","7797","7829","7937"]],["Jordan (‫الأردن‬‎)","jo","962"],["Kazakhstan (Казахстан)","kz","7",1,["33","7"]],["Kenya","ke","254"],["Kiribati","ki","686"],["Kosovo","xk","383"],["Kuwait (‫الكويت‬‎)","kw","965"],["Kyrgyzstan (Кыргызстан)","kg","996"],["Laos (ລາວ)","la","856"],["Latvia (Latvija)","lv","371"],["Lebanon (‫لبنان‬‎)","lb","961"],["Lesotho","ls","266"],["Liberia","lr","231"],["Libya (‫ليبيا‬‎)","ly","218"],["Liechtenstein","li","423"],["Lithuania (Lietuva)","lt","370"],["Luxembourg","lu","352"],["Macau (澳門)","mo","853"],["North Macedonia (Македонија)","mk","389"],["Madagascar (Madagasikara)","mg","261"],["Malawi","mw","265"],["Malaysia","my","60"],["Maldives","mv","960"],["Mali","ml","223"],["Malta","mt","356"],["Marshall Islands","mh","692"],["Martinique","mq","596"],["Mauritania (‫موريتانيا‬‎)","mr","222"],["Mauritius (Moris)","mu","230"],["Mayotte","yt","262",1,["269","639"]],["Mexico (México)","mx","52"],["Micronesia","fm","691"],["Moldova (Republica Moldova)","md","373"],["Monaco","mc","377"],["Mongolia (Монгол)","mn","976"],["Montenegro (Crna Gora)","me","382"],["Montserrat","ms","1",16,["664"]],["Morocco (‫المغرب‬‎)","ma","212",0],["Mozambique (Moçambique)","mz","258"],["Myanmar (Burma) (မြန်မာ)","mm","95"],["Namibia (Namibië)","na","264"],["Nauru","nr","674"],["Nepal (नेपाल)","np","977"],["Netherlands (Nederland)","nl","31"],["New Caledonia (Nouvelle-Calédonie)","nc","687"],["New Zealand","nz","64"],["Nicaragua","ni","505"],["Niger (Nijar)","ne","227"],["Nigeria","ng","234"],["Niue","nu","683"],["Norfolk Island","nf","672"],["North Korea (조선 민주주의 인민 공화국)","kp","850"],["Northern Mariana Islands","mp","1",17,["670"]],["Norway (Norge)","no","47",0],["Oman (‫عُمان‬‎)","om","968"],["Pakistan (‫پاکستان‬‎)","pk","92"],["Palau","pw","680"],["Palestine (‫فلسطين‬‎)","ps","970"],["Panama (Panamá)","pa","507"],["Papua New Guinea","pg","675"],["Paraguay","py","595"],["Peru (Perú)","pe","51"],["Philippines","ph","63"],["Poland (Polska)","pl","48"],["Portugal","pt","351"],["Puerto Rico","pr","1",3,["787","939"]],["Qatar (‫قطر‬‎)","qa","974"],["Réunion (La Réunion)","re","262",0],["Romania (România)","ro","40"],["Russia (Россия)","ru","7",0],["Rwanda","rw","250"],["Saint Barthélemy","bl","590",1],["Saint Helena","sh","290"],["Saint Kitts and Nevis","kn","1",18,["869"]],["Saint Lucia","lc","1",19,["758"]],["Saint Martin (Saint-Martin (partie française))","mf","590",2],["Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)","pm","508"],["Saint Vincent and the Grenadines","vc","1",20,["784"]],["Samoa","ws","685"],["San Marino","sm","378"],["São Tomé and Príncipe (São Tomé e Príncipe)","st","239"],["Saudi Arabia (‫المملكة العربية السعودية‬‎)","sa","966"],["Senegal (Sénégal)","sn","221"],["Serbia (Србија)","rs","381"],["Seychelles","sc","248"],["Sierra Leone","sl","232"],["Singapore","sg","65"],["Sint Maarten","sx","1",21,["721"]],["Slovakia (Slovensko)","sk","421"],["Slovenia (Slovenija)","si","386"],["Solomon Islands","sb","677"],["Somalia (Soomaaliya)","so","252"],["South Africa","za","27"],["South Korea (대한민국)","kr","82"],["South Sudan (‫جنوب السودان‬‎)","ss","211"],["Spain (España)","es","34"],["Sri Lanka (ශ්‍රී ලංකාව)","lk","94"],["Sudan (‫السودان‬‎)","sd","249"],["Suriname","sr","597"],["Svalbard and Jan Mayen","sj","47",1,["79"]],["Sweden (Sverige)","se","46"],["Switzerland (Schweiz)","ch","41"],["Syria (‫سوريا‬‎)","sy","963"],["Taiwan (台灣)","tw","886"],["Tajikistan","tj","992"],["Tanzania","tz","255"],["Thailand (ไทย)","th","66"],["Timor-Leste","tl","670"],["Togo","tg","228"],["Tokelau","tk","690"],["Tonga","to","676"],["Trinidad and Tobago","tt","1",22,["868"]],["Tunisia (‫تونس‬‎)","tn","216"],["Turkey (Türkiye)","tr","90"],["Turkmenistan","tm","993"],["Turks and Caicos Islands","tc","1",23,["649"]],["Tuvalu","tv","688"],["U.S. Virgin Islands","vi","1",24,["340"]],["Uganda","ug","256"],["Ukraine (Україна)","ua","380"],["United Arab Emirates (‫الإمارات العربية المتحدة‬‎)","ae","971"],["United Kingdom","gb","44",0],["United States","us","1",0],["Uruguay","uy","598"],["Uzbekistan (Oʻzbekiston)","uz","998"],["Vanuatu","vu","678"],["Vatican City (Città del Vaticano)","va","39",1,["06698"]],["Venezuela","ve","58"],["Vietnam (Việt Nam)","vn","84"],["Wallis and Futuna (Wallis-et-Futuna)","wf","681"],["Western Sahara (‫الصحراء الغربية‬‎)","eh","212",1,["5288","5289"]],["Yemen (‫اليمن‬‎)","ye","967"],["Zambia","zm","260"],["Zimbabwe","zw","263"],["Åland Islands","ax","358",1,["18"]]],s=0;s<t.length;s++){var e=t[s];t[s]={name:e[0],iso2:e[1],dialCode:e[2],priority:e[3]||0,areaCodes:e[4]||null}}function a(i,t){for(var s=0;s<t.length;s++){var e=t[s];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}var n={getInstance:function(i){var t=i.getAttribute("data-intl-tel-input-id");return window.intlTelInputGlobals.instances[t]},instances:{},documentReady:function(){return"complete"===document.readyState}};"object"==typeof window&&(window.intlTelInputGlobals=n);var r=0,o={allowDropdown:!0,autoHideDialCode:!0,autoPlaceholder:"polite",customContainer:"",customPlaceholder:null,dropdownContainer:null,excludeCountries:[],formatOnDisplay:!0,geoIpLookup:null,hiddenInput:"",initialCountry:"",localizedCountries:null,nationalMode:!0,onlyCountries:[],placeholderNumberType:"MOBILE",preferredCountries:["us","gb"],separateDialCode:!1,utilsScript:""},h=["800","822","833","844","855","866","877","880","881","882","883","884","885","886","887","888","889"],l=function(i,t){for(var s=Object.keys(i),e=0;e<s.length;e++)t(s[e],i[s[e]])},u=function(i){l(window.intlTelInputGlobals.instances,(function(t){window.intlTelInputGlobals.instances[t][i]()}))},d=function(){function s(i,t){var e=this;!function(i,t){if(!(i instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),this.id=r++,this.telInput=i,this.activeItem=null,this.highlightedItem=null;var a=t||{};this.options={},l(o,(function(i,t){e.options[i]=a.hasOwnProperty(i)?a[i]:t})),this.hadInitialPlaceholder=Boolean(i.getAttribute("placeholder"))}var e,n;return e=s,(n=[{key:"_init",value:function(){var i=this;if(this.options.nationalMode&&(this.options.autoHideDialCode=!1),this.options.separateDialCode&&(this.options.autoHideDialCode=this.options.nationalMode=!1),this.isMobile=/Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),this.isMobile&&(document.body.classList.add("iti-mobile"),this.options.dropdownContainer||(this.options.dropdownContainer=document.body)),"undefined"!=typeof Promise){var t=new Promise((function(t,s){i.resolveAutoCountryPromise=t,i.rejectAutoCountryPromise=s})),s=new Promise((function(t,s){i.resolveUtilsScriptPromise=t,i.rejectUtilsScriptPromise=s}));this.promise=Promise.all([t,s])}else this.resolveAutoCountryPromise=this.rejectAutoCountryPromise=function(){},this.resolveUtilsScriptPromise=this.rejectUtilsScriptPromise=function(){};this.selectedCountryData={},this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners(),this._initRequests()}},{key:"_processCountryData",value:function(){this._processAllCountries(),this._processCountryCodes(),this._processPreferredCountries(),this.options.localizedCountries&&this._translateCountriesByLocale(),(this.options.onlyCountries.length||this.options.localizedCountries)&&this.countries.sort(this._countryNameSort)}},{key:"_addCountryCode",value:function(t,s,e){s.length>this.countryCodeMaxLen&&(this.countryCodeMaxLen=s.length),this.countryCodes.hasOwnProperty(s)||(this.countryCodes[s]=[]);for(var a=0;a<this.countryCodes[s].length;a++)if(this.countryCodes[s][a]===t)return;this.countryCodes[s][e!==i?e:this.countryCodes[s].length]=t}},{key:"_processAllCountries",value:function(){if(this.options.onlyCountries.length){var i=this.options.onlyCountries.map((function(i){return i.toLowerCase()}));this.countries=t.filter((function(t){return i.indexOf(t.iso2)>-1}))}else if(this.options.excludeCountries.length){var s=this.options.excludeCountries.map((function(i){return i.toLowerCase()}));this.countries=t.filter((function(i){return-1===s.indexOf(i.iso2)}))}else this.countries=t}},{key:"_translateCountriesByLocale",value:function(){for(var i=0;i<this.countries.length;i++){var t=this.countries[i].iso2.toLowerCase();this.options.localizedCountries.hasOwnProperty(t)&&(this.countries[i].name=this.options.localizedCountries[t])}}},{key:"_countryNameSort",value:function(i,t){return i.name.localeCompare(t.name)}},{key:"_processCountryCodes",value:function(){this.countryCodeMaxLen=0,this.dialCodes={},this.countryCodes={};for(var i=0;i<this.countries.length;i++){var t=this.countries[i];this.dialCodes[t.dialCode]||(this.dialCodes[t.dialCode]=!0),this._addCountryCode(t.iso2,t.dialCode,t.priority)}for(var s=0;s<this.countries.length;s++){var e=this.countries[s];if(e.areaCodes)for(var a=this.countryCodes[e.dialCode][0],n=0;n<e.areaCodes.length;n++){for(var r=e.areaCodes[n],o=1;o<r.length;o++){var h=e.dialCode+r.substr(0,o);this._addCountryCode(a,h),this._addCountryCode(e.iso2,h)}this._addCountryCode(e.iso2,e.dialCode+r)}}}},{key:"_processPreferredCountries",value:function(){this.preferredCountries=[];for(var i=0;i<this.options.preferredCountries.length;i++){var t=this.options.preferredCountries[i].toLowerCase(),s=this._getCountryData(t,!1,!0);s&&this.preferredCountries.push(s)}}},{key:"_createEl",value:function(i,t,s){var e=document.createElement(i);return t&&l(t,(function(i,t){return e.setAttribute(i,t)})),s&&s.appendChild(e),e}},{key:"_generateMarkup",value:function(){this.telInput.hasAttribute("autocomplete")||this.telInput.form&&this.telInput.form.hasAttribute("autocomplete")||this.telInput.setAttribute("autocomplete","off");var i="iti";this.options.allowDropdown&&(i+=" iti--allow-dropdown"),this.options.separateDialCode&&(i+=" iti--separate-dial-code"),this.options.customContainer&&(i+=" ",i+=this.options.customContainer);var t=this._createEl("div",{class:i});if(this.telInput.parentNode.insertBefore(t,this.telInput),this.flagsContainer=this._createEl("div",{class:"iti__flag-container"},t),t.appendChild(this.telInput),this.selectedFlag=this._createEl("div",{class:"iti__selected-flag",role:"combobox","aria-controls":"iti-".concat(this.id,"__country-listbox"),"aria-owns":"iti-".concat(this.id,"__country-listbox"),"aria-expanded":"false"},this.flagsContainer),this.selectedFlagInner=this._createEl("div",{class:"iti__flag"},this.selectedFlag),this.options.separateDialCode&&(this.selectedDialCode=this._createEl("div",{class:"iti__selected-dial-code"},this.selectedFlag)),this.options.allowDropdown&&(this.selectedFlag.setAttribute("tabindex","0"),this.dropdownArrow=this._createEl("div",{class:"iti__arrow"},this.selectedFlag),this.countryList=this._createEl("ul",{class:"iti__country-list iti__hide",id:"iti-".concat(this.id,"__country-listbox"),role:"listbox","aria-label":"List of countries"}),this.preferredCountries.length&&(this._appendListItems(this.preferredCountries,"iti__preferred",!0),this._createEl("li",{class:"iti__divider",role:"separator","aria-disabled":"true"},this.countryList)),this._appendListItems(this.countries,"iti__standard"),this.options.dropdownContainer?(this.dropdown=this._createEl("div",{class:"iti iti--container"}),this.dropdown.appendChild(this.countryList)):this.flagsContainer.appendChild(this.countryList)),this.options.hiddenInput){var s=this.options.hiddenInput,e=this.telInput.getAttribute("name");if(e){var a=e.lastIndexOf("[");-1!==a&&(s="".concat(e.substr(0,a),"[").concat(s,"]"))}this.hiddenInput=this._createEl("input",{type:"hidden",name:s}),t.appendChild(this.hiddenInput)}}},{key:"_appendListItems",value:function(i,t,s){for(var e="",a=0;a<i.length;a++){var n=i[a],r=s?"-preferred":"";e+="<li class='iti__country ".concat(t,"' tabIndex='-1' id='iti-").concat(this.id,"__item-").concat(n.iso2).concat(r,"' role='option' data-dial-code='").concat(n.dialCode,"' data-country-code='").concat(n.iso2,"' aria-selected='false'>"),e+="<div class='iti__flag-box'><div class='iti__flag iti__".concat(n.iso2,"'></div></div>"),e+="<span class='iti__country-name'>".concat(n.name,"</span>"),e+="<span class='iti__dial-code'>+".concat(n.dialCode,"</span>"),e+="</li>"}this.countryList.insertAdjacentHTML("beforeend",e)}},{key:"_setInitialState",value:function(){var i=this.telInput.getAttribute("value"),t=this.telInput.value,s=!i||"+"!==i.charAt(0)||t&&"+"===t.charAt(0)?t:i,e=this._getDialCode(s),a=this._isRegionlessNanp(s),n=this.options,r=n.initialCountry,o=n.nationalMode,h=n.autoHideDialCode,l=n.separateDialCode;e&&!a?this._updateFlagFromNumber(s):"auto"!==r&&(r?this._setFlag(r.toLowerCase()):e&&a?this._setFlag("us"):(this.defaultCountry=this.preferredCountries.length?this.preferredCountries[0].iso2:this.countries[0].iso2,s||this._setFlag(this.defaultCountry)),s||o||h||l||(this.telInput.value="+".concat(this.selectedCountryData.dialCode))),s&&this._updateValFromNumber(s)}},{key:"_initListeners",value:function(){this._initKeyListeners(),this.options.autoHideDialCode&&this._initBlurListeners(),this.options.allowDropdown&&this._initDropdownListeners(),this.hiddenInput&&this._initHiddenInputListener()}},{key:"_initHiddenInputListener",value:function(){var i=this;this._handleHiddenInputSubmit=function(){i.hiddenInput.value=i.getNumber()},this.telInput.form&&this.telInput.form.addEventListener("submit",this._handleHiddenInputSubmit)}},{key:"_getClosestLabel",value:function(){for(var i=this.telInput;i&&"LABEL"!==i.tagName;)i=i.parentNode;return i}},{key:"_initDropdownListeners",value:function(){var i=this;this._handleLabelClick=function(t){i.countryList.classList.contains("iti__hide")?i.telInput.focus():t.preventDefault()};var t=this._getClosestLabel();t&&t.addEventListener("click",this._handleLabelClick),this._handleClickSelectedFlag=function(){!i.countryList.classList.contains("iti__hide")||i.telInput.disabled||i.telInput.readOnly||i._showDropdown()},this.selectedFlag.addEventListener("click",this._handleClickSelectedFlag),this._handleFlagsContainerKeydown=function(t){i.countryList.classList.contains("iti__hide")&&-1!==["ArrowUp","Up","ArrowDown","Down"," ","Enter"].indexOf(t.key)&&(t.preventDefault(),t.stopPropagation(),i._showDropdown()),"Tab"===t.key&&i._closeDropdown()},this.flagsContainer.addEventListener("keydown",this._handleFlagsContainerKeydown)}},{key:"_initRequests",value:function(){var i=this;this.options.utilsScript&&!window.intlTelInputUtils?window.intlTelInputGlobals.documentReady()?window.intlTelInputGlobals.loadUtils(this.options.utilsScript):window.addEventListener("load",(function(){window.intlTelInputGlobals.loadUtils(i.options.utilsScript)})):this.resolveUtilsScriptPromise(),"auto"===this.options.initialCountry?this._loadAutoCountry():this.resolveAutoCountryPromise()}},{key:"_loadAutoCountry",value:function(){window.intlTelInputGlobals.autoCountry?this.handleAutoCountry():window.intlTelInputGlobals.startedLoadingAutoCountry||(window.intlTelInputGlobals.startedLoadingAutoCountry=!0,"function"==typeof this.options.geoIpLookup&&this.options.geoIpLookup((function(i){window.intlTelInputGlobals.autoCountry=i.toLowerCase(),setTimeout((function(){return u("handleAutoCountry")}))}),(function(){return u("rejectAutoCountryPromise")})))}},{key:"_initKeyListeners",value:function(){var i=this;this._handleKeyupEvent=function(){i._updateFlagFromNumber(i.telInput.value)&&i._triggerCountryChange()},this.telInput.addEventListener("keyup",this._handleKeyupEvent),this._handleClipboardEvent=function(){setTimeout(i._handleKeyupEvent)},this.telInput.addEventListener("cut",this._handleClipboardEvent),this.telInput.addEventListener("paste",this._handleClipboardEvent)}},{key:"_cap",value:function(i){var t=this.telInput.getAttribute("maxlength");return t&&i.length>t?i.substr(0,t):i}},{key:"_initBlurListeners",value:function(){var i=this;this._handleSubmitOrBlurEvent=function(){i._removeEmptyDialCode()},this.telInput.form&&this.telInput.form.addEventListener("submit",this._handleSubmitOrBlurEvent),this.telInput.addEventListener("blur",this._handleSubmitOrBlurEvent)}},{key:"_removeEmptyDialCode",value:function(){if("+"===this.telInput.value.charAt(0)){var i=this._getNumeric(this.telInput.value);i&&this.selectedCountryData.dialCode!==i||(this.telInput.value="")}}},{key:"_getNumeric",value:function(i){return i.replace(/\D/g,"")}},{key:"_trigger",value:function(i){var t=document.createEvent("Event");t.initEvent(i,!0,!0),this.telInput.dispatchEvent(t)}},{key:"_showDropdown",value:function(){this.countryList.classList.remove("iti__hide"),this.selectedFlag.setAttribute("aria-expanded","true"),this._setDropdownPosition(),this.activeItem&&(this._highlightListItem(this.activeItem,!1),this._scrollTo(this.activeItem,!0)),this._bindDropdownListeners(),this.dropdownArrow.classList.add("iti__arrow--up"),this._trigger("open:countrydropdown")}},{key:"_toggleClass",value:function(i,t,s){s&&!i.classList.contains(t)?i.classList.add(t):!s&&i.classList.contains(t)&&i.classList.remove(t)}},{key:"_setDropdownPosition",value:function(){var i=this;if(this.options.dropdownContainer&&this.options.dropdownContainer.appendChild(this.dropdown),!this.isMobile){var t=this.telInput.getBoundingClientRect(),s=window.pageYOffset||document.documentElement.scrollTop,e=t.top+s,a=this.countryList.offsetHeight,n=e+this.telInput.offsetHeight+a<s+window.innerHeight,r=e-a>s;this._toggleClass(this.countryList,"iti__country-list--dropup",!n&&r),this.options.dropdownContainer&&(this.dropdown.style.top="".concat(e+(!n&&r?0:this.telInput.offsetHeight),"px"),this.dropdown.style.left="".concat(t.left+document.body.scrollLeft,"px"),this._handleWindowScroll=function(){return i._closeDropdown()},window.addEventListener("scroll",this._handleWindowScroll))}}},{key:"_getClosestListItem",value:function(i){for(var t=i;t&&t!==this.countryList&&!t.classList.contains("iti__country");)t=t.parentNode;return t===this.countryList?null:t}},{key:"_bindDropdownListeners",value:function(){var i=this;this._handleMouseoverCountryList=function(t){var s=i._getClosestListItem(t.target);s&&i._highlightListItem(s,!1)},this.countryList.addEventListener("mouseover",this._handleMouseoverCountryList),this._handleClickCountryList=function(t){var s=i._getClosestListItem(t.target);s&&i._selectListItem(s)},this.countryList.addEventListener("click",this._handleClickCountryList);var t=!0;this._handleClickOffToClose=function(){t||i._closeDropdown(),t=!1},document.documentElement.addEventListener("click",this._handleClickOffToClose);var s="",e=null;this._handleKeydownOnDropdown=function(t){t.preventDefault(),"ArrowUp"===t.key||"Up"===t.key||"ArrowDown"===t.key||"Down"===t.key?i._handleUpDownKey(t.key):"Enter"===t.key?i._handleEnterKey():"Escape"===t.key?i._closeDropdown():/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(t.key)&&(e&&clearTimeout(e),s+=t.key.toLowerCase(),i._searchForCountry(s),e=setTimeout((function(){s=""}),1e3))},document.addEventListener("keydown",this._handleKeydownOnDropdown)}},{key:"_handleUpDownKey",value:function(i){var t="ArrowUp"===i||"Up"===i?this.highlightedItem.previousElementSibling:this.highlightedItem.nextElementSibling;t&&(t.classList.contains("iti__divider")&&(t="ArrowUp"===i||"Up"===i?t.previousElementSibling:t.nextElementSibling),this._highlightListItem(t,!0))}},{key:"_handleEnterKey",value:function(){this.highlightedItem&&this._selectListItem(this.highlightedItem)}},{key:"_searchForCountry",value:function(i){for(var t=0;t<this.countries.length;t++)if(this._startsWith(this.countries[t].name,i)){var s=this.countryList.querySelector("#iti-".concat(this.id,"__item-").concat(this.countries[t].iso2));this._highlightListItem(s,!1),this._scrollTo(s,!0);break}}},{key:"_startsWith",value:function(i,t){return i.substr(0,t.length).toLowerCase()===t}},{key:"_updateValFromNumber",value:function(i){var t=i;if(this.options.formatOnDisplay&&window.intlTelInputUtils&&this.selectedCountryData){var s=!this.options.separateDialCode&&(this.options.nationalMode||"+"!==t.charAt(0)),e=intlTelInputUtils.numberFormat;t=intlTelInputUtils.formatNumber(t,this.selectedCountryData.iso2,s?e.NATIONAL:e.INTERNATIONAL)}t=this._beforeSetNumber(t),this.telInput.value=t}},{key:"_updateFlagFromNumber",value:function(i){var t=i,s=this.selectedCountryData.dialCode;t&&this.options.nationalMode&&"1"===s&&"+"!==t.charAt(0)&&("1"!==t.charAt(0)&&(t="1".concat(t)),t="+".concat(t)),this.options.separateDialCode&&s&&"+"!==t.charAt(0)&&(t="+".concat(s).concat(t));var e=this._getDialCode(t,!0),a=this._getNumeric(t),n=null;if(e){var r=this.countryCodes[this._getNumeric(e)],o=-1!==r.indexOf(this.selectedCountryData.iso2)&&a.length<=e.length-1;if(!("1"===s&&this._isRegionlessNanp(a)||o))for(var h=0;h<r.length;h++)if(r[h]){n=r[h];break}}else"+"===t.charAt(0)&&a.length?n="":t&&"+"!==t||(n=this.defaultCountry);return null!==n&&this._setFlag(n)}},{key:"_isRegionlessNanp",value:function(i){var t=this._getNumeric(i);if("1"===t.charAt(0)){var s=t.substr(1,3);return-1!==h.indexOf(s)}return!1}},{key:"_highlightListItem",value:function(i,t){var s=this.highlightedItem;s&&s.classList.remove("iti__highlight"),this.highlightedItem=i,this.highlightedItem.classList.add("iti__highlight"),t&&this.highlightedItem.focus()}},{key:"_getCountryData",value:function(i,s,e){for(var a=s?t:this.countries,n=0;n<a.length;n++)if(a[n].iso2===i)return a[n];if(e)return null;throw new Error("No country data for '".concat(i,"'"))}},{key:"_setFlag",value:function(i){var t=this.selectedCountryData.iso2?this.selectedCountryData:{};this.selectedCountryData=i?this._getCountryData(i,!1,!1):{},this.selectedCountryData.iso2&&(this.defaultCountry=this.selectedCountryData.iso2),this.selectedFlagInner.setAttribute("class","iti__flag iti__".concat(i));var s=i?"".concat(this.selectedCountryData.name,": +").concat(this.selectedCountryData.dialCode):"Unknown";if(this.selectedFlag.setAttribute("title",s),this.options.separateDialCode){var e=this.selectedCountryData.dialCode?"+".concat(this.selectedCountryData.dialCode):"";this.selectedDialCode.innerHTML=e;var a=this.selectedFlag.offsetWidth||this._getHiddenSelectedFlagWidth();this.telInput.style.paddingLeft="".concat(a+6,"px")}if(this._updatePlaceholder(),this.options.allowDropdown){var n=this.activeItem;if(n&&(n.classList.remove("iti__active"),n.setAttribute("aria-selected","false")),i){var r=this.countryList.querySelector("#iti-".concat(this.id,"__item-").concat(i,"-preferred"))||this.countryList.querySelector("#iti-".concat(this.id,"__item-").concat(i));r.setAttribute("aria-selected","true"),r.classList.add("iti__active"),this.activeItem=r,this.selectedFlag.setAttribute("aria-activedescendant",r.getAttribute("id"))}}return t.iso2!==i}},{key:"_getHiddenSelectedFlagWidth",value:function(){var i=this.telInput.parentNode.cloneNode();i.style.visibility="hidden",document.body.appendChild(i);var t=this.flagsContainer.cloneNode();i.appendChild(t);var s=this.selectedFlag.cloneNode(!0);t.appendChild(s);var e=s.offsetWidth;return i.parentNode.removeChild(i),e}},{key:"_updatePlaceholder",value:function(){if(window.intlTelInputUtils&&("aggressive"===this.options.autoPlaceholder||!this.hadInitialPlaceholder&&"polite"===this.options.autoPlaceholder)){var i=intlTelInputUtils.numberType[this.options.placeholderNumberType],t=this.selectedCountryData.iso2?intlTelInputUtils.getExampleNumber(this.selectedCountryData.iso2,this.options.nationalMode,i):"";t=this._beforeSetNumber(t),"function"==typeof this.options.customPlaceholder&&(t=this.options.customPlaceholder(t,this.selectedCountryData)),this.telInput.setAttribute("placeholder",t)}}},{key:"_selectListItem",value:function(i){var t=this._setFlag(i.getAttribute("data-country-code"));this._closeDropdown(),this._updateDialCode(i.getAttribute("data-dial-code"),!0),this.telInput.focus();var s=this.telInput.value.length;this.telInput.setSelectionRange(s,s),t&&this._triggerCountryChange()}},{key:"_closeDropdown",value:function(){this.countryList.classList.add("iti__hide"),this.selectedFlag.setAttribute("aria-expanded","false"),this.dropdownArrow.classList.remove("iti__arrow--up"),document.removeEventListener("keydown",this._handleKeydownOnDropdown),document.documentElement.removeEventListener("click",this._handleClickOffToClose),this.countryList.removeEventListener("mouseover",this._handleMouseoverCountryList),this.countryList.removeEventListener("click",this._handleClickCountryList),this.options.dropdownContainer&&(this.isMobile||window.removeEventListener("scroll",this._handleWindowScroll),this.dropdown.parentNode&&this.dropdown.parentNode.removeChild(this.dropdown)),this._trigger("close:countrydropdown")}},{key:"_scrollTo",value:function(i,t){var s=this.countryList,e=window.pageYOffset||document.documentElement.scrollTop,a=s.offsetHeight,n=s.getBoundingClientRect().top+e,r=n+a,o=i.offsetHeight,h=i.getBoundingClientRect().top+e,l=h+o,u=h-n+s.scrollTop,d=a/2-o/2;h<n?(t&&(u-=d),s.scrollTop=u):l>r&&(t&&(u+=d),s.scrollTop=u-(a-o))}},{key:"_updateDialCode",value:function(i,t){var s,e=this.telInput.value,a="+".concat(i);if("+"===e.charAt(0)){var n=this._getDialCode(e);s=n?e.replace(n,a):a}else{if(this.options.nationalMode||this.options.separateDialCode)return;if(e)s=a+e;else{if(!t&&this.options.autoHideDialCode)return;s=a}}this.telInput.value=s}},{key:"_getDialCode",value:function(i,t){var s="";if("+"===i.charAt(0))for(var e="",a=0;a<i.length;a++){var n=i.charAt(a);if(!isNaN(parseInt(n,10))){if(e+=n,t)this.countryCodes[e]&&(s=i.substr(0,a+1));else if(this.dialCodes[e]){s=i.substr(0,a+1);break}if(e.length===this.countryCodeMaxLen)break}}return s}},{key:"_getFullNumber",value:function(){var i=this.telInput.value.trim(),t=this.selectedCountryData.dialCode,s=this._getNumeric(i);return(this.options.separateDialCode&&"+"!==i.charAt(0)&&t&&s?"+".concat(t):"")+i}},{key:"_beforeSetNumber",value:function(i){var t=i;if(this.options.separateDialCode){var s=this._getDialCode(t);s&&(s="+".concat(this.selectedCountryData.dialCode),t=t.substr(" "===t[s.length]||"-"===t[s.length]?s.length+1:s.length))}return this._cap(t)}},{key:"_triggerCountryChange",value:function(){this._trigger("countrychange")}},{key:"handleAutoCountry",value:function(){"auto"===this.options.initialCountry&&(this.defaultCountry=window.intlTelInputGlobals.autoCountry,this.telInput.value||this.setCountry(this.defaultCountry),this.resolveAutoCountryPromise())}},{key:"handleUtils",value:function(){window.intlTelInputUtils&&(this.telInput.value&&this._updateValFromNumber(this.telInput.value),this._updatePlaceholder()),this.resolveUtilsScriptPromise()}},{key:"destroy",value:function(){var i=this.telInput.form;if(this.options.allowDropdown){this._closeDropdown(),this.selectedFlag.removeEventListener("click",this._handleClickSelectedFlag),this.flagsContainer.removeEventListener("keydown",this._handleFlagsContainerKeydown);var t=this._getClosestLabel();t&&t.removeEventListener("click",this._handleLabelClick)}this.hiddenInput&&i&&i.removeEventListener("submit",this._handleHiddenInputSubmit),this.options.autoHideDialCode&&(i&&i.removeEventListener("submit",this._handleSubmitOrBlurEvent),this.telInput.removeEventListener("blur",this._handleSubmitOrBlurEvent)),this.telInput.removeEventListener("keyup",this._handleKeyupEvent),this.telInput.removeEventListener("cut",this._handleClipboardEvent),this.telInput.removeEventListener("paste",this._handleClipboardEvent),this.telInput.removeAttribute("data-intl-tel-input-id");var s=this.telInput.parentNode;s.parentNode.insertBefore(this.telInput,s),s.parentNode.removeChild(s),delete window.intlTelInputGlobals.instances[this.id]}},{key:"getExtension",value:function(){return window.intlTelInputUtils?intlTelInputUtils.getExtension(this._getFullNumber(),this.selectedCountryData.iso2):""}},{key:"getNumber",value:function(i){if(window.intlTelInputUtils){var t=this.selectedCountryData.iso2;return intlTelInputUtils.formatNumber(this._getFullNumber(),t,i)}return""}},{key:"getNumberType",value:function(){return window.intlTelInputUtils?intlTelInputUtils.getNumberType(this._getFullNumber(),this.selectedCountryData.iso2):-99}},{key:"getSelectedCountryData",value:function(){return this.selectedCountryData}},{key:"getValidationError",value:function(){if(window.intlTelInputUtils){var i=this.selectedCountryData.iso2;return intlTelInputUtils.getValidationError(this._getFullNumber(),i)}return-99}},{key:"isValidNumber",value:function(){var i=this._getFullNumber().trim();return window.intlTelInputUtils?intlTelInputUtils.isValidNumber(i,this.options.nationalMode?this.selectedCountryData.iso2:""):null}},{key:"setCountry",value:function(i){var t=i.toLowerCase();this.selectedFlagInner.classList.contains("iti__".concat(t))||(this._setFlag(t),this._updateDialCode(this.selectedCountryData.dialCode,!1),this._triggerCountryChange())}},{key:"setNumber",value:function(i){var t=this._updateFlagFromNumber(i);this._updateValFromNumber(i),t&&this._triggerCountryChange()}},{key:"setPlaceholderNumberType",value:function(i){this.options.placeholderNumberType=i,this._updatePlaceholder()}}])&&a(e.prototype,n),s}();n.getCountryData=function(){return t};var c=function(i,t,s){var e=document.createElement("script");e.onload=function(){u("handleUtils"),t&&t()},e.onerror=function(){u("rejectUtilsScriptPromise"),s&&s()},e.className="iti-load-utils",e.async=!0,e.src=i,document.body.appendChild(e)};return n.loadUtils=function(i){if(!window.intlTelInputUtils&&!window.intlTelInputGlobals.startedLoadingUtilsScript){if(window.intlTelInputGlobals.startedLoadingUtilsScript=!0,"undefined"!=typeof Promise)return new Promise((function(t,s){return c(i,t,s)}));c(i)}return null},n.defaults=o,n.version="17.0.15",function(i,t){var s=new d(i,t);return s._init(),i.setAttribute("data-intl-tel-input-id",s.id),window.intlTelInputGlobals.instances[s.id]=s,s}}()},i.exports?i.exports=t():window.intlTelInput=t()}(h={path:undefined,exports:{},require:function(){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}()}}),h.exports);const u=class{constructor(t){i(this,t),this.countryCode="SA",this.countryKey="+966",n.setHost(this.host)}async getValues(){return this.phone=this.phoneInput.value,this.countryCode=this.countryCodeInput.value,this.countryKey=this.countryKeyInput.value,{phone:this.phoneInput.value,countryCode:this.countryCodeInput.value,countryKey:this.countryKeyInput.value}}initTelInput(){salla.document.event.onKeyup(".tel-input",(i=>salla.helpers.digitsOnly(i.target))),document.querySelectorAll(".tel-input").forEach((i=>{salla.helpers.digitsOnly(i);let t=l(i,{initialCountry:i.dataset.code||"sa",preferredCountries:["sa","ae","kw","bh","qa","iq","om","ye","eg","jo","sy","ps","sd","lb","dz","tn","ma","ly"],formatOnDisplay:!1,separateDialCode:!0,autoPlaceholder:"aggressive",utilsScript:"https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.12/js/utils.min.js"});i.addEventListener("countrychange",(()=>{let i=t.getSelectedCountryData();this.host.querySelectorAll(".country_code").forEach((t=>t.value=i.iso2.toUpperCase())),this.host.querySelectorAll(".country_key").forEach((t=>{t.value=("+"+i.dialCode).replace("++","+")}))}))}))}render(){return t(s,null,t("input",{type:"tel",name:"mobile","data-code":this.countryCode,value:this.phone,ref:i=>this.phoneInput=i,class:"s-tel-input-control tel-input s-ltr"}),t("input",{type:"hidden",name:"country_code",value:this.countryCode,ref:i=>this.countryCodeInput=i,class:"country_code"}),t("input",{type:"hidden",name:"country_key",value:this.countryKey,ref:i=>this.countryKeyInput=i,class:"country_key"}))}componentDidRender(){this.initTelInput()}get host(){return e(this)}},d=class{constructor(t){i(this,t),this.verified=a(this,"verified",7),this.backClicked=a(this,"backClicked",7),this.url="profile/verify-mobile",this.by="sms",this.autoReload=!0,n.setHost(this.host),this.withoutModal?this.modal={show:()=>"",hide:()=>""}:salla.event.on("profile::verify.mobile",(i=>this.show(i)))}async getCode(){return this.code.value}componentDidLoad(){return n.on("input",".s-verify-input",(i=>salla.helpers.digitsOnly(i.target))),n.onKeyUp(".s-verify-input",(i=>{var t,s,e,a;let n=i.keyCode||i.charCode;i.target.value?(null===(t=i.target.nextElementSibling)||void 0===t||t.focus(),null===(s=i.target.nextElementSibling)||void 0===s||s.select()):[8,46].includes(n)&&(null===(e=i.target.previousElementSibling)||void 0===e||e.focus(),null===(a=i.target.previousElementSibling)||void 0===a||a.select()),this.toggleOTPSubmit()})),n.on("paste",".s-verify-input",(i=>{let t=i.clipboardData.getData("text").toArabicDigits().replace(/[^0-9.]/g,"").replace("..",".");this.otpInputs.forEach(((i,s)=>i.value=t[s]||"")),this.toggleOTPSubmit(),setTimeout((()=>this.otpInputs[3].focus()),100)})),this.modal.show()}async show(i){this.data=i,this.resendTimer(),this.otpInputs=document.querySelectorAll(".s-verify-input"),this.reset()}toggleOTPSubmit(){let i=[];if(this.otpInputs.forEach((t=>t.value&&i.push(t.value))),this.code.value=i.join(""),4===i.length)return this.btn.removeAttribute("disabled"),void this.btn.click();this.btn.setAttribute("disabled","")}reset(){this.otpInputs.forEach((i=>i.value="")),this.code.value="",this.otpInputs[0].focus()}resendTimer(){n.showElement(this.resendMessage).hideElement(this.resend);let i=30,t=setInterval((()=>{-1===i?(clearTimeout(t),n.hideElement(this.resendMessage).showElement(this.resend)):(this.timer.innerHTML=`${i>=10?i:"0"+i} : 00`,i--)}),1e3)}resendCode(){return this.btn.stop().then((()=>this.btn.disable())).then((()=>{this.otpInputs.forEach((i=>i.value="")),this.otpInputs[0].focus()})).then((()=>salla.api.auth.resend(Object.assign({resend_by:this.by},this.data)))).then((()=>this.resendTimer())).catch((()=>this.resendTimer()))}submit(){return this.btn.load().then((()=>this.btn.disable())).then((()=>salla.document.api.request(this.url,Object.assign({code:this.code.value},this.data)))).then((i=>this.verified.emit(i))).then((()=>this.btn.stop()&&this.btn.disable())).then((()=>this.modal.hide())).then((()=>this.autoReload&&window.location.reload())).catch((()=>this.btn.stop()&&this.btn.enable()&&this.reset()))}render(){return this.withoutModal?this.myBody():t("salla-modal",{id:"s-verify",ref:i=>this.modal=i,title:salla.lang.get("pages.profile.verify_title")},this.myBody())}myBody(){return[t("div",{class:"s-verify-message",innerHTML:salla.lang.get("pages.profile.verify_message")}),t("input",{type:"hidden",name:"code",maxlength:"4",required:!0,ref:i=>this.code=i}),t("div",{class:"s-verify-codes",dir:"ltr"},[1,2,3,4].map((()=>t("input",{type:"text",maxlength:"1",class:"s-verify-input",required:!0})))),t("div",{slot:"footer",class:"s-verify-footer"},t("salla-button",{class:"s-verify-submit",disabled:!0,onClick:()=>this.submit(),ref:i=>this.btn=i},salla.lang.get("pages.profile.verify")),t("p",{class:"s-verify-resend-message",ref:i=>this.resendMessage=i},salla.lang.get("blocks.header.resend_after"),t("b",{class:"s-verify-timer",ref:i=>this.timer=i})),t("a",{href:"#",class:"s-verify-resend",onClick:()=>this.resendCode(),ref:i=>this.resend=i},salla.lang.get("blocks.comments.submit")),this.backText?t("a",{href:"#",class:"s-verify-resend",onClick:()=>this.backClicked.emit()},this.backText):"")]}get host(){return e(this)}};export{r as salla_button,o as salla_modal,u as salla_tel_input,d as salla_verify}
@@ -1 +1 @@
1
- import{r as s,h as i,g as t}from"./p-6a5be894.js";import{H as l}from"./p-47f17d3b.js";const e=class{constructor(i){s(this,i),this.regType="phone",this.isEmailAllowed=!0,this.loginTypeTitle=salla.lang.get("blocks.header.select_login_way"),this.loginText=salla.lang.get("blocks.header.login"),this.smsLabel=salla.lang.get("blocks.header.sms"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.emailLabel=salla.lang.get("common.elements.email"),this.enterText=salla.lang.get("blocks.header.enter"),this.bySMSText=salla.lang.get("blocks.header.login_by_sms"),this.byEmailText=salla.lang.get("blocks.header.login_by_email"),this.backText=salla.lang.get("common.elements.back"),this.title=this.host.title||salla.lang.get("blocks.header.login"),this.host.removeAttribute("title"),salla.auth.event.onVerificationFailed((()=>{}))}onVerified(s){if(s.detail.case){if("new_customer"===s.detail.case)return this.showTab(this.tab5);if("redirect"===salla.auth.event.getTypeActionOnVerified())return s.redirect_url?window.location.href=s.redirect_url:void window.location.reload()}else console.log("verified but without case!")}onbackClicked(){this.showTab("phone"==this.regType?this.tab2:this.tab3)}async show(){return this.showTab(this.isEmailAllowed?this.tab1:this.tab2),this.modal.show()}showTab(s){[this.tab1,this.tab2,this.tab3,this.tab4,this.tab5].map((i=>l.toggleElement(i,"visible","hidden",(()=>i==s)))),setTimeout((()=>{[this.tab1,this.tab2,this.tab3,this.tab4,this.tab5].map((i=>l.toggleElement(i,"s-login-active","s-login-unactive",(()=>i==s))))}),200),setTimeout((()=>{this.host.querySelector(".s-login-wrapper").setAttribute("style","height:"+(null==s?void 0:s.scrollHeight)+"px")})),[this.tab2,this.tab3].includes(s)&&(this.regType=s===this.tab2?"phone":"email");let i=s==this.tab5;return i&&this.firstName.focus(),this.modal.setTitle(i?salla.lang.get("common.titles.registration"):this.title),i||l.toggleElement(this.regMobileBlock,"s-hidden","s-block",(()=>"phone"===this.regType)).toggleElement(this.regEmailBlock,"s-hidden","s-block",(()=>"email"===this.regType)),this}loginByEmail(){if(!l.isValidEmail(this.email.value))return this.email.classList.add("s-has-error"),void(this.email.nextElementSibling.innerText="* "+salla.lang.get("common.elements.email_is_valid"));this.email.nextElementSibling.innerText="",this.email.classList.remove("s-has-error"),salla.auth.api.login({type:"email",email:this.email.value}).then((()=>this.showTab(this.tab4))).then((()=>(this.tab4.by="email")&&(this.tab4.url="auth/email/verify"))).then((()=>this.tab4.show({email:this.email.value})))}async loginBySMS(){const{phone:s,countryCode:i}=await this.loginTelInput.getValues();if(s.length<6)return this.loginTelInput.classList.add("s-has-error"),void(this.loginTelInput.nextElementSibling.innerText="* "+salla.lang.get("mobile_app.strings.incorrect_mobile"));this.loginTelInput.nextElementSibling.innerText="",this.loginTelInput.classList.remove("s-has-error"),salla.auth.api.login({type:"mobile",phone:s,country_code:i}).then((()=>this.showTab(this.tab4))).then((()=>(this.tab4.by="sms")&&(this.tab4.url="auth/mobile/verify"))).then((()=>this.tab4.show({phone:s,country_code:i})))}typing({target:s}){"tel"===s.type&&salla.helpers.digitsOnly(s),s.classList.remove("s-has-error"),s.nextElementSibling.innerText=""}async newUser(){const{phone:s,countryCode:i,countryKey:t}=await this.regTelInput.getValues();this.tab4.getCode().then((l=>salla.auth.api.register({first_name:this.firstName.value,last_name:this.lastName.value,phone:s||this.loginTelInput.phone,email:this.regEmail.value||this.email.value,country_code:i,country_key:t,code:l,verified_by:this.regType}))).then((()=>window.location.reload()))}render(){return i("salla-modal",{id:"salla-login",title:this.title,ref:s=>this.modal=s,width:"xs"},i("div",{class:"s-login-wrapper"},this.isEmailAllowed?i("div",{class:"s-login-tab",ref:s=>this.tab1=s},i("p",{class:"s-login-sub-title"},this.loginTypeTitle),i("a",{href:"#",class:"s-login-main-btn",onClick:()=>this.showTab(this.tab2)},i("i",{class:"s-login-main-btn-icon sicon-phone"}),i("span",{class:"s-login-main-btn-text"},this.smsLabel),i("i",{class:"main-btn-arrow sicon-keyboard_arrow_left"})),i("a",{href:"#",class:"s-login-main-btn",onClick:()=>this.showTab(this.tab3)},i("i",{class:"s-login-main-btn-icon sicon-mail"}),i("span",{class:"s-login-main-btn-text"},this.emailLabel),i("i",{class:"main-btn-arrow sicon-keyboard_arrow_left"}))):"",i("div",{class:"s-login-tab",ref:s=>this.tab2=s},i("label",{class:"s-login-label"},this.mobileLabel),i("salla-tel-input",{phone:"",ref:s=>this.loginTelInput=s}),i("span",{class:"s-login-error-message"}),i("salla-button",{wide:!0,onClick:()=>this.loginBySMS()},this.enterText),this.isEmailAllowed?i("a",{href:"#",onClick:()=>this.showTab(this.tab3),class:"s-login-link"},this.byEmailText):""),this.isEmailAllowed?i("div",{class:"s-login-tab",ref:s=>this.tab3=s},i("label",{class:"s-login-label"},this.emailLabel),i("input",{onChange:()=>this.loginByEmail(),type:"email",ref:s=>this.email=s,onInput:this.typing,placeholder:"your@email.com",class:"s-login-input s-ltr"}),i("span",{class:"s-login-error-message"}),i("salla-button",{wide:!0,onClick:()=>this.loginByEmail()},this.enterText),i("a",{href:"#",onClick:()=>this.showTab(this.tab2),class:"s-login-link"},this.bySMSText)):"",i("salla-verify",{"without-modal":!0,ref:s=>this.tab4=s,autoReload:!1,"back-text":this.backText}),i("div",{ref:s=>this.tab5=s},i("label",{class:"s-login-label"},salla.lang.get("blocks.header.your_name")),i("input",{type:"text",class:"s-login-input",ref:s=>this.firstName=s,placeholder:salla.lang.get("pages.profile.first_name")}),i("label",{class:"s-login-label"},salla.lang.get("pages.profile.last_name")),i("input",{type:"text",class:"s-login-input",ref:s=>this.lastName=s,placeholder:salla.lang.get("pages.profile.last_name")}),i("div",{ref:s=>this.regMobileBlock=s},i("label",{class:"s-login-label"},this.mobileLabel),i("salla-tel-input",{phone:"",ref:s=>this.regTelInput=s}),i("span",{class:"s-login-error-message"})),i("div",{ref:s=>this.regEmailBlock=s},i("label",{class:"s-login-label"},this.emailLabel),i("input",{type:"email",ref:s=>this.regEmail=s,onInput:this.typing,placeholder:"your@email.com",class:"s-login-input s-ltr"}),i("span",{class:"s-login-error-message"})),i("salla-button",{wide:!0,onClick:()=>this.newUser()},salla.lang.get("blocks.header.register")))))}get host(){return t(this)}};e.style="salla-verify{display:block}";export{e as S}
1
+ import{r as s,h as i,g as t}from"./p-6a5be894.js";import{H as l}from"./p-47f17d3b.js";const e=class{constructor(i){s(this,i),this.regType="phone",this.isEmailAllowed=!0,this.loginTypeTitle=salla.lang.get("blocks.header.select_login_way"),this.loginText=salla.lang.get("blocks.header.login"),this.smsLabel=salla.lang.get("blocks.header.sms"),this.mobileLabel=salla.lang.get("common.elements.mobile"),this.emailLabel=salla.lang.get("common.elements.email"),this.enterText=salla.lang.get("blocks.header.enter"),this.bySMSText=salla.lang.get("blocks.header.login_by_sms"),this.byEmailText=salla.lang.get("blocks.header.login_by_email"),this.backText=salla.lang.get("common.elements.back"),this.title=this.host.title||salla.lang.get("blocks.header.login"),this.host.removeAttribute("title"),salla.auth.event.onVerificationFailed((()=>{}))}onVerified(s){if(s.detail.case){if("new_customer"===s.detail.case)return this.showTab(this.tab5);if("redirect"===salla.auth.event.getTypeActionOnVerified())return s.redirect_url?window.location.href=s.redirect_url:void window.location.reload()}else console.log("verified but without case!")}onbackClicked(){this.showTab("phone"==this.regType?this.tab2:this.tab3)}async show(){return this.showTab(this.isEmailAllowed?this.tab1:this.tab2),this.modal.show()}showTab(s){[this.tab1,this.tab2,this.tab3,this.tab4,this.tab5].map((i=>l.toggleElement(i,"visible","hidden",(()=>i==s)))),setTimeout((()=>{[this.tab1,this.tab2,this.tab3,this.tab4,this.tab5].map((i=>l.toggleElement(i,"s-login-active","s-login-unactive",(()=>i==s))))}),200),setTimeout((()=>{this.host.querySelector(".s-login-wrapper").setAttribute("style","height:"+(null==s?void 0:s.scrollHeight)+"px")})),[this.tab2,this.tab3].includes(s)&&(this.regType=s===this.tab2?"phone":"email");let i=s==this.tab5;return i&&this.firstName.focus(),this.modal.setTitle(i?salla.lang.get("common.titles.registration"):this.title),i||l.toggleElement(this.regMobileBlock,"s-hidden","s-block",(()=>"phone"===this.regType)).toggleElement(this.regEmailBlock,"s-hidden","s-block",(()=>"email"===this.regType)),this}loginByEmail(){if(!l.isValidEmail(this.email.value))return this.email.classList.add("s-has-error"),void(this.email.nextElementSibling.innerText="* "+salla.lang.get("common.elements.email_is_valid"));this.email.nextElementSibling.innerText="",this.email.classList.remove("s-has-error"),salla.auth.api.login({type:"email",email:this.email.value}).then((()=>this.showTab(this.tab4))).then((()=>(this.tab4.by="email")&&(this.tab4.url="auth/email/verify"))).then((()=>this.tab4.show({email:this.email.value})))}async loginBySMS(){const{phone:s,countryCode:i}=await this.loginTelInput.getValues();if(s.length<6)return this.loginTelInput.classList.add("s-has-error"),void(this.loginTelInput.nextElementSibling.innerText="* "+salla.lang.get("mobile_app.strings.incorrect_mobile"));this.loginTelInput.nextElementSibling.innerText="",this.loginTelInput.classList.remove("s-has-error"),salla.auth.api.login({type:"mobile",phone:s,country_code:i}).then((()=>this.showTab(this.tab4))).then((()=>(this.tab4.by="sms")&&(this.tab4.url="auth/mobile/verify"))).then((()=>this.tab4.show({phone:s,country_code:i})))}typing({target:s}){"tel"===s.type&&salla.helpers.digitsOnly(s),s.classList.remove("s-has-error"),s.nextElementSibling.innerText=""}async newUser(){const{phone:s,countryCode:i,countryKey:t}=await this.regTelInput.getValues();this.tab4.getCode().then((l=>salla.auth.api.register({first_name:this.firstName.value,last_name:this.lastName.value,phone:s||this.loginTelInput.phone,email:this.regEmail.value||this.email.value,country_code:i,country_key:t,code:l,verified_by:this.regType}))).then((()=>window.location.reload()))}render(){return i("salla-modal",{id:"salla-login",title:this.title,ref:s=>this.modal=s,width:"xs"},i("div",{class:"s-login-wrapper"},this.isEmailAllowed?i("div",{class:"s-login-tab",ref:s=>this.tab1=s},i("p",{class:"s-login-sub-title"},this.loginTypeTitle),i("a",{href:"#",class:"s-login-main-btn",onClick:()=>this.showTab(this.tab2)},i("i",{class:"s-login-main-btn-icon sicon-phone"}),i("span",{class:"s-login-main-btn-text"},this.smsLabel),i("i",{class:"main-btn-arrow sicon-keyboard_arrow_left"})),i("a",{href:"#",class:"s-login-main-btn",onClick:()=>this.showTab(this.tab3)},i("i",{class:"s-login-main-btn-icon sicon-mail"}),i("span",{class:"s-login-main-btn-text"},this.emailLabel),i("i",{class:"main-btn-arrow sicon-keyboard_arrow_left"}))):"",i("div",{class:"s-login-tab",ref:s=>this.tab2=s},i("label",{class:"s-login-label"},this.mobileLabel),i("salla-tel-input",{phone:"",ref:s=>this.loginTelInput=s}),i("span",{class:"s-login-error-message"}),i("salla-button",{wide:!0,onClick:()=>this.loginBySMS()},this.enterText),this.isEmailAllowed?i("a",{href:"#",onClick:()=>this.showTab(this.tab3),class:"s-login-link"},this.byEmailText):""),this.isEmailAllowed?i("div",{class:"s-login-tab",ref:s=>this.tab3=s},i("label",{class:"s-login-label"},this.emailLabel),i("input",{onChange:()=>this.loginByEmail(),type:"email",ref:s=>this.email=s,onInput:this.typing,placeholder:"your@email.com",class:"s-login-input s-ltr"}),i("span",{class:"s-login-error-message"}),i("salla-button",{wide:!0,onClick:()=>this.loginByEmail()},this.enterText),i("a",{href:"#",onClick:()=>this.showTab(this.tab2),class:"s-login-link"},this.bySMSText)):"",i("salla-verify",{"without-modal":!0,ref:s=>this.tab4=s,autoReload:!1,"back-text":this.backText}),i("div",{ref:s=>this.tab5=s},i("label",{class:"s-login-label"},salla.lang.get("blocks.header.your_name")),i("input",{type:"text",class:"s-login-input",ref:s=>this.firstName=s,placeholder:salla.lang.get("pages.profile.first_name")}),i("label",{class:"s-login-label"},salla.lang.get("pages.profile.last_name")),i("input",{type:"text",class:"s-login-input",ref:s=>this.lastName=s,placeholder:salla.lang.get("pages.profile.last_name")}),i("div",{ref:s=>this.regMobileBlock=s},i("label",{class:"s-login-label"},this.mobileLabel),i("salla-tel-input",{phone:"",ref:s=>this.regTelInput=s}),i("span",{class:"s-login-error-message"})),i("div",{ref:s=>this.regEmailBlock=s},i("label",{class:"s-login-label"},this.emailLabel),i("input",{type:"email",ref:s=>this.regEmail=s,onInput:this.typing,placeholder:"your@email.com",class:"s-login-input s-ltr"}),i("span",{class:"s-login-error-message"})),i("salla-button",{wide:!0,onClick:()=>this.newUser()},salla.lang.get("blocks.header.register")))))}get host(){return t(this)}};e.style="salla-verify{display:block}#salla-login .s-modal-body{overflow:inherit}";export{e as S}
@@ -0,0 +1 @@
1
+ import{r as s,h as a,g as i}from"./p-6a5be894.js";import{H as e}from"./p-47f17d3b.js";const r=class{constructor(a){var i;s(this,a),e.setHost(this.host),this.productSlot=(null===(i=e.getElement('[slot="product"]'))||void 0===i?void 0:i.innerHTML)||this.getDefaultProductSlot(),salla.event.on("languages::translations.loaded",(()=>{this.placeholder=salla.lang.get("blocks.header.search_placeholder"),this.noResultsText=salla.lang.get("common.elements.no_options")}))}onModalOpen(){this.modal.querySelector(".s-search-input").focus()}onModalClose(){this.modal.querySelector(".s-search-input").value="",this.results=void 0,this.afterSearching()}getDefaultProductSlot(){return'<div class="s-search-product-image-container"> <img class="s-search-product-image" src="{image}" alt="{name}"/></div><div class="s-search-product-details"> <div class="s-search-product-name">{name}</div> <div class="s-search-product-price">{price}</div></div>'}search(s){if(e.hideElement(this.noResults),0===s.target.value.length)return this.results=void 0,void this.afterSearching();s.target.value.length<=2||(e.toggleElement(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!0)),salla.search.api.search(s.target.value).then((s=>this.results=s)).catch((s=>"Query Same As Previous!"!==s?this.results=void 0:null)).finally((()=>this.afterSearching(!1))))}afterSearching(s=!0){var a;this.noResults.style.display=s||(null===(a=this.results)||void 0===a?void 0:a.data.length)>0?"none":"block",e.toggleElement(this.container,"s-search-container-open","no-results",(()=>{var s;return null===(s=this.results)||void 0===s?void 0:s.data.length})).toggleElement(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!1)),salla.search.api.previousQuery=""}render(){var s;return a("salla-modal",{position:"top",id:"s-search-modal",ref:s=>this.modal=s},a("div",{class:"s-search-container",ref:s=>this.container=s},a("input",{class:"s-search-input",type:"text",placeholder:this.placeholder,onInput:s=>this.search(s)}),a("span",{class:"s-search-icon"},a("i",{class:"sicon-search",ref:s=>this.searchIcon=s})),a("div",{class:"s-search-results"},null===(s=this.results)||void 0===s?void 0:s.data.map((s=>a("a",{href:s.url,class:"s-search-product",innerHTML:this.productSlot.replace(/\{name\}/g,s.name).replace(/\{price\}/g,s.price).replace(/\{image\}/g,s.image_url)}))),a("p",{ref:s=>this.noResults=s,class:"s-search-no-results"},this.noResultsText))))}componentDidLoad(){this.afterSearching()}get host(){return i(this)}};r.style="#s-search-modal .s-modal-wrapper{align-items:flex-start;padding:0}#s-search-modal .s-modal-spacer{display:inline}#s-search-modal .s-modal-body{padding:0;max-width:90%;margin-top:3.2rem;border-radius:0.5rem}#s-search-modal .s-modal-close{top:1rem}";export{r as S}
@@ -1 +1 @@
1
- import{p as e,b as l}from"./p-6a5be894.js";(()=>{const l=import.meta.url,t={};return""!==l&&(t.resourcesUrl=new URL(".",l).href),e(t)})().then((e=>l([["p-5b2eb87d",[[0,"salla-login",{isEmailAllowed:[4,"is-email-allowed"],loginTypeTitle:[1,"login-type-title"],loginText:[1,"login-text"],smsLabel:[1,"sms-label"],mobileLabel:[1,"mobile-label"],emailLabel:[1,"email-label"],enterText:[1,"enter-text"],bySMSText:[1,"by-s-m-s-text"],byEmailText:[1,"by-email-text"],backText:[1,"back-text"],show:[64]},[[0,"verified","onVerified"],[0,"backClicked","onbackClicked"]]],[0,"salla-verify",{withoutModal:[4,"without-modal"],url:[1],by:[1],backText:[1,"back-text"],autoReload:[4,"auto-reload"],getCode:[64],show:[64]}],[0,"salla-tel-input",{phone:[1025],countryCode:[1025,"country-code"],countryKey:[1025,"country-key"],getValues:[64]}],[4,"salla-button",{btnStyle:[513,"btn-style"],loading:[516],disabled:[516],loaderPosition:[1,"loader-position"],wide:[4],load:[64],stop:[64],disable:[64],enable:[64]}],[4,"salla-modal",{error:[4],success:[4],primary:[4],isClosable:[1028,"is-closable"],width:[513],position:[513],visible:[516],isLoading:[1540,"is-loading"],subTitleFirst:[4,"sub-title-first"],subTitle:[1,"sub-title"],icon:[1],imageIcon:[1,"image-icon"],title:[32],show:[64],hide:[64],setTitle:[64],loading:[64],stopLoading:[64]}]]],["p-da73fc9b",[[4,"salla-branches",{position:[1],displayAs:[1,"display-as"],browseProductsFrom:[1,"browse-products-from"],branches:[16],current:[1026],open:[32],selected:[32],isOpenedBefore:[32],show:[64],hide:[64]}]]],["p-1a6d8171",[[4,"salla-localization",{languagesTitle:[1,"languages-title"],currenciesTitle:[1,"currencies-title"],ok:[1],show:[64],hide:[64],submit:[64]}]]],["p-7fbdf746",[[0,"salla-offer",{offer:[32],show:[64]}]]],["p-7fe5d346",[[4,"salla-product-availability",{channels:[1],buttonText:[1,"button-text"],countryCode:[1,"country-code"],subscribeText:[1,"subscribe-text"],cancelText:[1,"cancel-text"],subTitle:[1,"sub-title"],mobileLabel:[1,"mobile-label"],emailLabel:[1,"email-label"],mobilePlaceholder:[1,"mobile-placeholder"],emailPlaceholder:[1,"email-placeholder"],productId:[2,"product-id"],subscribedMessage:[1,"subscribed-message"],isSubscribed:[1028,"is-subscribed"],submit:[64]}]]],["p-ce991664",[[0,"salla-rating",{order:[32],show:[64],hide:[64]}]]],["p-1deb8111",[[0,"salla-search",{placeholder:[1],noResultsText:[1,"no-results-text"],results:[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]]]]],e)));
1
+ import{p as e,b as l}from"./p-6a5be894.js";(()=>{const l=import.meta.url,a={};return""!==l&&(a.resourcesUrl=new URL(".",l).href),e(a)})().then((e=>l([["p-48931f49",[[0,"salla-login",{isEmailAllowed:[4,"is-email-allowed"],loginTypeTitle:[1,"login-type-title"],loginText:[1,"login-text"],smsLabel:[1,"sms-label"],mobileLabel:[1,"mobile-label"],emailLabel:[1,"email-label"],enterText:[1,"enter-text"],bySMSText:[1,"by-s-m-s-text"],byEmailText:[1,"by-email-text"],backText:[1,"back-text"],show:[64]},[[0,"verified","onVerified"],[0,"backClicked","onbackClicked"]]],[0,"salla-verify",{withoutModal:[4,"without-modal"],url:[1],by:[1],backText:[1,"back-text"],autoReload:[4,"auto-reload"],getCode:[64],show:[64]}],[0,"salla-tel-input",{phone:[1025],countryCode:[1025,"country-code"],countryKey:[1025,"country-key"],getValues:[64]}],[4,"salla-button",{btnStyle:[513,"btn-style"],loading:[516],disabled:[516],loaderPosition:[1,"loader-position"],wide:[4],load:[64],stop:[64],disable:[64],enable:[64]}],[4,"salla-modal",{error:[4],success:[4],primary:[4],isClosable:[1028,"is-closable"],width:[513],position:[513],visible:[516],isLoading:[1540,"is-loading"],subTitleFirst:[4,"sub-title-first"],subTitle:[1,"sub-title"],icon:[1],imageIcon:[1,"image-icon"],title:[32],show:[64],hide:[64],setTitle:[64],loading:[64],stopLoading:[64]}]]],["p-da73fc9b",[[4,"salla-branches",{position:[1],displayAs:[1,"display-as"],browseProductsFrom:[1,"browse-products-from"],branches:[16],current:[1026],open:[32],selected:[32],isOpenedBefore:[32],show:[64],hide:[64]}]]],["p-1a6d8171",[[4,"salla-localization",{languagesTitle:[1,"languages-title"],currenciesTitle:[1,"currencies-title"],ok:[1],show:[64],hide:[64],submit:[64]}]]],["p-7fbdf746",[[0,"salla-offer",{offer:[32],show:[64]}]]],["p-7fe5d346",[[4,"salla-product-availability",{channels:[1],buttonText:[1,"button-text"],countryCode:[1,"country-code"],subscribeText:[1,"subscribe-text"],cancelText:[1,"cancel-text"],subTitle:[1,"sub-title"],mobileLabel:[1,"mobile-label"],emailLabel:[1,"email-label"],mobilePlaceholder:[1,"mobile-placeholder"],emailPlaceholder:[1,"email-placeholder"],productId:[2,"product-id"],subscribedMessage:[1,"subscribed-message"],isSubscribed:[1028,"is-subscribed"],submit:[64]}]]],["p-ce991664",[[0,"salla-rating",{order:[32],show:[64],hide:[64]}]]],["p-47f3d098",[[0,"salla-search",{results:[32],placeholder:[32],noResultsText:[32]},[[0,"modalOpened","onModalOpen"],[0,"modalClosed","onModalClose"]]]]]],e)));
@@ -1,4 +1,5 @@
1
1
  import { HTMLStencilElement } from '../../stencil-public-runtime';
2
+ import SearchResponse from "./search-response";
2
3
  export declare class SallaSearch {
3
4
  constructor();
4
5
  private readonly productSlot;
@@ -7,14 +8,8 @@ export declare class SallaSearch {
7
8
  private searchIcon;
8
9
  private noResults;
9
10
  host: HTMLStencilElement;
10
- results: any[];
11
- /**
12
- * Override search placeholder.
13
- */
11
+ results: SearchResponse | undefined;
14
12
  placeholder: string;
15
- /**
16
- * Override no results error message.
17
- */
18
13
  noResultsText: string;
19
14
  onModalOpen(): void;
20
15
  onModalClose(): void;
@@ -0,0 +1,18 @@
1
+ export default interface SearchResponse {
2
+ status: number;
3
+ success: boolean;
4
+ data: Array<{
5
+ id: string;
6
+ name: string;
7
+ price: string;
8
+ image_url: string;
9
+ url: string;
10
+ }>;
11
+ features: {
12
+ sorting: boolean;
13
+ };
14
+ sort_options: Array<{
15
+ id: 'ourSuggest' | 'bestSell' | 'topRated' | 'priceFromTopToLow' | 'priceFromLowToTop';
16
+ name: 'مقترحاتنا' | 'الاكثر مبيعا' | 'الاعلى تقيماً' | 'السعر من الاعلى إلى الاقل' | 'السعر من الاقل إلى الاعلى';
17
+ }>;
18
+ }
@@ -90,14 +90,6 @@ export namespace Components {
90
90
  "show": () => Promise<NodeJS.Timeout>;
91
91
  }
92
92
  interface SallaSearch {
93
- /**
94
- * Override no results error message.
95
- */
96
- "noResultsText": string;
97
- /**
98
- * Override search placeholder.
99
- */
100
- "placeholder": string;
101
93
  }
102
94
  interface SallaTelInput {
103
95
  "countryCode": string;
@@ -267,14 +259,6 @@ declare namespace LocalJSX {
267
259
  interface SallaRating {
268
260
  }
269
261
  interface SallaSearch {
270
- /**
271
- * Override no results error message.
272
- */
273
- "noResultsText"?: string;
274
- /**
275
- * Override search placeholder.
276
- */
277
- "placeholder"?: string;
278
262
  }
279
263
  interface SallaTelInput {
280
264
  "countryCode"?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salla.sa/twilight-components",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "twilight",
@@ -1 +0,0 @@
1
- export{S as salla_search}from"./p-81a61f4e.js";import"./p-6a5be894.js";import"./p-47f17d3b.js";
@@ -1 +0,0 @@
1
- import{r as i,h as t,H as s,g as e,c as a}from"./p-6a5be894.js";import{H as n}from"./p-47f17d3b.js";export{S as salla_login}from"./p-3a4d963e.js";const r=class{constructor(t){i(this,t),this.btnStyle="primary",this.loading=!1,this.disabled=!1,this.loaderPosition="before",this.wide=!1,this.hostAttributes={};for(let i=0;i<this.host.attributes.length;i++)this.hostAttributes[this.host.attributes[i].name]=this.host.attributes[i].value;this.hostAttributes.type=this.hostAttributes.type||"button",this.hostAttributes.class+=" s-button-btn btn--has-loading s-button-"+this.btnStyle+(this.wide?" s-button-wide ":"")+" loader-"+this.loaderPosition+("before"==this.loaderPosition?" s-button-loader-after":""),delete this.hostAttributes["btn-style"],delete this.hostAttributes.id,this.wide&&this.host.classList.add("s-button-wide")}async load(){return"center"==this.loaderPosition&&this.text.classList.add("s-button-hide"),this.host.setAttribute("loading",""),this.host}async stop(){return this.host.removeAttribute("loading"),this.host}async disable(){this.host.setAttribute("disabled","")}async enable(){this.host.removeAttribute("disabled")}handleVisible(i,t){this.btn.classList.remove("btn-"+t),this.btn.classList.add("btn-"+i)}handleLoading(i){n.toggleElement(this.btn,"btn--is-loading","btn--no-loading",(()=>i))}render(){return t(s,{class:"s-button-host-tag"},t("button",Object.assign({ref:i=>this.btn=i,disabled:this.disabled},this.hostAttributes),t("span",{class:"s-button-text",ref:i=>this.text=i},t("slot",null)),this.loading?t("span",{class:{"s-button-loader":!0,"s-button-loader-start":"start"===this.loaderPosition,"s-button-loader-end":"end"===this.loaderPosition,"s-button-loader-center":"center"===this.loaderPosition}}):""))}get host(){return e(this)}static get watchers(){return{btnStyle:["handleVisible"],loading:["handleLoading"]}}};r.style=":host{display:block}";const o=class{constructor(t){var s;i(this,t),this.modalOpened=a(this,"modalOpened",7),this.modalClosed=a(this,"modalClosed",7),this.error=!1,this.success=!1,this.primary=!1,this.isClosable=!0,this.width="md",this.position="middel",this.visible=!1,this.isLoading=!1,this.subTitleFirst=!1,this.subTitle="",this.icon="",this.imageIcon="",n.setHost(this.host),salla.event.on("modal::open",(i=>i.dataset.target==this.host.id&&this.show())),salla.event.on("modal::close",(i=>i.dataset.target==this.host.id&&this.hide())),this.title=this.host.title,this.host.removeAttribute("title"),null===(s=n.getElement("[slot=body]"))||void 0===s||s.classList.add("s-modal-body","s-modal-"+this.width)}handleVisible(i){if(!i)return this.toggleModal(!1),void this.modalClosed.emit();this.host.classList.remove("hidden"),setTimeout((()=>this.toggleModal(!0))),this.modalOpened.emit()}async show(){return this.host.setAttribute("visible",""),this.host}async hide(){return this.host.removeAttribute("visible"),this.host}async setTitle(i){return this.title=i,this.host}async loading(){return this.isLoading=!0,this.host}async stopLoading(){return this.isLoading=!1,this.host}toggleModal(i){n.toggleElement(this.host.querySelector("[slot=body]")||this.host,"s-modal-entering","s-modal-leaving",(()=>i)).toggleElement(this.overlay,"s-modal-entering","s-modal-overlay-leaving",(()=>i)).toggleElement(document.body,"modal-is-open","modal-is-closed",(()=>i)),i||setTimeout((()=>this.host.classList.add("hidden")),350)}closeModal(){this.isClosable&&this.host.removeAttribute("visible")}render(){return this.host.id=this.host.id||"salla-modal",t(s,{class:"s-modal-container hidden","aria-modal":"true",role:"dialog"},t("div",{class:"s-modal-wrapper"},t("div",{class:"s-modal-overlay",ref:i=>this.overlay=i,onClick:()=>this.closeModal()}),t("span",{class:"s-modal-spacer s-modal-align-"+this.position},"​"),t("div",{class:"s-modal-body s-modal-align-"+this.position+" s-modal-"+this.width,slot:"body"},this.isLoading?t("span",null,"Loading..."):[t("div",{class:{"s-modal-header":!0,"s-modal-is-center":""!=this.icon||""!=this.imageIcon}},this.isClosable?t("button",{class:"s-modal-close",onClick:()=>this.closeModal(),type:"button"},t("span",{class:"sicon-cancel"})):"",this.error||this.success||this.icon?t("div",{class:{"s-modal-icon":!0,"s-modal-bg-error":this.error,"s-modal-bg-success":this.success,"s-modal-bg-normal":!this.error&&!this.success,"s-modal-bg-primary":this.primary}},t("i",{class:{[this.icon]:!0,"s-modal-text-error":this.error,"s-modal-text-success":this.success}})):this.imageIcon?t("img",{class:"s-modal-header-img",src:this.imageIcon}):"",this.title||this.subTitle?t("div",{class:"s-modal-header-content"},t("div",{class:{"s-modal-title":!0,"s-modal-title-below":this.subTitleFirst},innerHTML:this.title}),t("p",{class:{"s-modal-sub-title":!0},innerHTML:this.subTitle})):""),t("slot",null),t("slot",{name:"footer"})])))}get host(){return e(this)}static get watchers(){return{visible:["handleVisible"]}}};var h,l=(function(i){var t;t=function(i){return function(){for(var t=[["Afghanistan (‫افغانستان‬‎)","af","93"],["Albania (Shqipëri)","al","355"],["Algeria (‫الجزائر‬‎)","dz","213"],["American Samoa","as","1",5,["684"]],["Andorra","ad","376"],["Angola","ao","244"],["Anguilla","ai","1",6,["264"]],["Antigua and Barbuda","ag","1",7,["268"]],["Argentina","ar","54"],["Armenia (Հայաստան)","am","374"],["Aruba","aw","297"],["Ascension Island","ac","247"],["Australia","au","61",0],["Austria (Österreich)","at","43"],["Azerbaijan (Azərbaycan)","az","994"],["Bahamas","bs","1",8,["242"]],["Bahrain (‫البحرين‬‎)","bh","973"],["Bangladesh (বাংলাদেশ)","bd","880"],["Barbados","bb","1",9,["246"]],["Belarus (Беларусь)","by","375"],["Belgium (België)","be","32"],["Belize","bz","501"],["Benin (Bénin)","bj","229"],["Bermuda","bm","1",10,["441"]],["Bhutan (འབྲུག)","bt","975"],["Bolivia","bo","591"],["Bosnia and Herzegovina (Босна и Херцеговина)","ba","387"],["Botswana","bw","267"],["Brazil (Brasil)","br","55"],["British Indian Ocean Territory","io","246"],["British Virgin Islands","vg","1",11,["284"]],["Brunei","bn","673"],["Bulgaria (България)","bg","359"],["Burkina Faso","bf","226"],["Burundi (Uburundi)","bi","257"],["Cambodia (កម្ពុជា)","kh","855"],["Cameroon (Cameroun)","cm","237"],["Canada","ca","1",1,["204","226","236","249","250","289","306","343","365","387","403","416","418","431","437","438","450","506","514","519","548","579","581","587","604","613","639","647","672","705","709","742","778","780","782","807","819","825","867","873","902","905"]],["Cape Verde (Kabu Verdi)","cv","238"],["Caribbean Netherlands","bq","599",1,["3","4","7"]],["Cayman Islands","ky","1",12,["345"]],["Central African Republic (République centrafricaine)","cf","236"],["Chad (Tchad)","td","235"],["Chile","cl","56"],["China (中国)","cn","86"],["Christmas Island","cx","61",2,["89164"]],["Cocos (Keeling) Islands","cc","61",1,["89162"]],["Colombia","co","57"],["Comoros (‫جزر القمر‬‎)","km","269"],["Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)","cd","243"],["Congo (Republic) (Congo-Brazzaville)","cg","242"],["Cook Islands","ck","682"],["Costa Rica","cr","506"],["Côte d’Ivoire","ci","225"],["Croatia (Hrvatska)","hr","385"],["Cuba","cu","53"],["Curaçao","cw","599",0],["Cyprus (Κύπρος)","cy","357"],["Czech Republic (Česká republika)","cz","420"],["Denmark (Danmark)","dk","45"],["Djibouti","dj","253"],["Dominica","dm","1",13,["767"]],["Dominican Republic (República Dominicana)","do","1",2,["809","829","849"]],["Ecuador","ec","593"],["Egypt (‫مصر‬‎)","eg","20"],["El Salvador","sv","503"],["Equatorial Guinea (Guinea Ecuatorial)","gq","240"],["Eritrea","er","291"],["Estonia (Eesti)","ee","372"],["Eswatini","sz","268"],["Ethiopia","et","251"],["Falkland Islands (Islas Malvinas)","fk","500"],["Faroe Islands (Føroyar)","fo","298"],["Fiji","fj","679"],["Finland (Suomi)","fi","358",0],["France","fr","33"],["French Guiana (Guyane française)","gf","594"],["French Polynesia (Polynésie française)","pf","689"],["Gabon","ga","241"],["Gambia","gm","220"],["Georgia (საქართველო)","ge","995"],["Germany (Deutschland)","de","49"],["Ghana (Gaana)","gh","233"],["Gibraltar","gi","350"],["Greece (Ελλάδα)","gr","30"],["Greenland (Kalaallit Nunaat)","gl","299"],["Grenada","gd","1",14,["473"]],["Guadeloupe","gp","590",0],["Guam","gu","1",15,["671"]],["Guatemala","gt","502"],["Guernsey","gg","44",1,["1481","7781","7839","7911"]],["Guinea (Guinée)","gn","224"],["Guinea-Bissau (Guiné Bissau)","gw","245"],["Guyana","gy","592"],["Haiti","ht","509"],["Honduras","hn","504"],["Hong Kong (香港)","hk","852"],["Hungary (Magyarország)","hu","36"],["Iceland (Ísland)","is","354"],["India (भारत)","in","91"],["Indonesia","id","62"],["Iran (‫ایران‬‎)","ir","98"],["Iraq (‫العراق‬‎)","iq","964"],["Ireland","ie","353"],["Isle of Man","im","44",2,["1624","74576","7524","7924","7624"]],["Israel (‫ישראל‬‎)","il","972"],["Italy (Italia)","it","39",0],["Jamaica","jm","1",4,["876","658"]],["Japan (日本)","jp","81"],["Jersey","je","44",3,["1534","7509","7700","7797","7829","7937"]],["Jordan (‫الأردن‬‎)","jo","962"],["Kazakhstan (Казахстан)","kz","7",1,["33","7"]],["Kenya","ke","254"],["Kiribati","ki","686"],["Kosovo","xk","383"],["Kuwait (‫الكويت‬‎)","kw","965"],["Kyrgyzstan (Кыргызстан)","kg","996"],["Laos (ລາວ)","la","856"],["Latvia (Latvija)","lv","371"],["Lebanon (‫لبنان‬‎)","lb","961"],["Lesotho","ls","266"],["Liberia","lr","231"],["Libya (‫ليبيا‬‎)","ly","218"],["Liechtenstein","li","423"],["Lithuania (Lietuva)","lt","370"],["Luxembourg","lu","352"],["Macau (澳門)","mo","853"],["North Macedonia (Македонија)","mk","389"],["Madagascar (Madagasikara)","mg","261"],["Malawi","mw","265"],["Malaysia","my","60"],["Maldives","mv","960"],["Mali","ml","223"],["Malta","mt","356"],["Marshall Islands","mh","692"],["Martinique","mq","596"],["Mauritania (‫موريتانيا‬‎)","mr","222"],["Mauritius (Moris)","mu","230"],["Mayotte","yt","262",1,["269","639"]],["Mexico (México)","mx","52"],["Micronesia","fm","691"],["Moldova (Republica Moldova)","md","373"],["Monaco","mc","377"],["Mongolia (Монгол)","mn","976"],["Montenegro (Crna Gora)","me","382"],["Montserrat","ms","1",16,["664"]],["Morocco (‫المغرب‬‎)","ma","212",0],["Mozambique (Moçambique)","mz","258"],["Myanmar (Burma) (မြန်မာ)","mm","95"],["Namibia (Namibië)","na","264"],["Nauru","nr","674"],["Nepal (नेपाल)","np","977"],["Netherlands (Nederland)","nl","31"],["New Caledonia (Nouvelle-Calédonie)","nc","687"],["New Zealand","nz","64"],["Nicaragua","ni","505"],["Niger (Nijar)","ne","227"],["Nigeria","ng","234"],["Niue","nu","683"],["Norfolk Island","nf","672"],["North Korea (조선 민주주의 인민 공화국)","kp","850"],["Northern Mariana Islands","mp","1",17,["670"]],["Norway (Norge)","no","47",0],["Oman (‫عُمان‬‎)","om","968"],["Pakistan (‫پاکستان‬‎)","pk","92"],["Palau","pw","680"],["Palestine (‫فلسطين‬‎)","ps","970"],["Panama (Panamá)","pa","507"],["Papua New Guinea","pg","675"],["Paraguay","py","595"],["Peru (Perú)","pe","51"],["Philippines","ph","63"],["Poland (Polska)","pl","48"],["Portugal","pt","351"],["Puerto Rico","pr","1",3,["787","939"]],["Qatar (‫قطر‬‎)","qa","974"],["Réunion (La Réunion)","re","262",0],["Romania (România)","ro","40"],["Russia (Россия)","ru","7",0],["Rwanda","rw","250"],["Saint Barthélemy","bl","590",1],["Saint Helena","sh","290"],["Saint Kitts and Nevis","kn","1",18,["869"]],["Saint Lucia","lc","1",19,["758"]],["Saint Martin (Saint-Martin (partie française))","mf","590",2],["Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)","pm","508"],["Saint Vincent and the Grenadines","vc","1",20,["784"]],["Samoa","ws","685"],["San Marino","sm","378"],["São Tomé and Príncipe (São Tomé e Príncipe)","st","239"],["Saudi Arabia (‫المملكة العربية السعودية‬‎)","sa","966"],["Senegal (Sénégal)","sn","221"],["Serbia (Србија)","rs","381"],["Seychelles","sc","248"],["Sierra Leone","sl","232"],["Singapore","sg","65"],["Sint Maarten","sx","1",21,["721"]],["Slovakia (Slovensko)","sk","421"],["Slovenia (Slovenija)","si","386"],["Solomon Islands","sb","677"],["Somalia (Soomaaliya)","so","252"],["South Africa","za","27"],["South Korea (대한민국)","kr","82"],["South Sudan (‫جنوب السودان‬‎)","ss","211"],["Spain (España)","es","34"],["Sri Lanka (ශ්‍රී ලංකාව)","lk","94"],["Sudan (‫السودان‬‎)","sd","249"],["Suriname","sr","597"],["Svalbard and Jan Mayen","sj","47",1,["79"]],["Sweden (Sverige)","se","46"],["Switzerland (Schweiz)","ch","41"],["Syria (‫سوريا‬‎)","sy","963"],["Taiwan (台灣)","tw","886"],["Tajikistan","tj","992"],["Tanzania","tz","255"],["Thailand (ไทย)","th","66"],["Timor-Leste","tl","670"],["Togo","tg","228"],["Tokelau","tk","690"],["Tonga","to","676"],["Trinidad and Tobago","tt","1",22,["868"]],["Tunisia (‫تونس‬‎)","tn","216"],["Turkey (Türkiye)","tr","90"],["Turkmenistan","tm","993"],["Turks and Caicos Islands","tc","1",23,["649"]],["Tuvalu","tv","688"],["U.S. Virgin Islands","vi","1",24,["340"]],["Uganda","ug","256"],["Ukraine (Україна)","ua","380"],["United Arab Emirates (‫الإمارات العربية المتحدة‬‎)","ae","971"],["United Kingdom","gb","44",0],["United States","us","1",0],["Uruguay","uy","598"],["Uzbekistan (Oʻzbekiston)","uz","998"],["Vanuatu","vu","678"],["Vatican City (Città del Vaticano)","va","39",1,["06698"]],["Venezuela","ve","58"],["Vietnam (Việt Nam)","vn","84"],["Wallis and Futuna (Wallis-et-Futuna)","wf","681"],["Western Sahara (‫الصحراء الغربية‬‎)","eh","212",1,["5288","5289"]],["Yemen (‫اليمن‬‎)","ye","967"],["Zambia","zm","260"],["Zimbabwe","zw","263"],["Åland Islands","ax","358",1,["18"]]],s=0;s<t.length;s++){var e=t[s];t[s]={name:e[0],iso2:e[1],dialCode:e[2],priority:e[3]||0,areaCodes:e[4]||null}}function a(i,t){for(var s=0;s<t.length;s++){var e=t[s];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(i,e.key,e)}}var n={getInstance:function(i){var t=i.getAttribute("data-intl-tel-input-id");return window.intlTelInputGlobals.instances[t]},instances:{},documentReady:function(){return"complete"===document.readyState}};"object"==typeof window&&(window.intlTelInputGlobals=n);var r=0,o={allowDropdown:!0,autoHideDialCode:!0,autoPlaceholder:"polite",customContainer:"",customPlaceholder:null,dropdownContainer:null,excludeCountries:[],formatOnDisplay:!0,geoIpLookup:null,hiddenInput:"",initialCountry:"",localizedCountries:null,nationalMode:!0,onlyCountries:[],placeholderNumberType:"MOBILE",preferredCountries:["us","gb"],separateDialCode:!1,utilsScript:""},h=["800","822","833","844","855","866","877","880","881","882","883","884","885","886","887","888","889"],l=function(i,t){for(var s=Object.keys(i),e=0;e<s.length;e++)t(s[e],i[s[e]])},u=function(i){l(window.intlTelInputGlobals.instances,(function(t){window.intlTelInputGlobals.instances[t][i]()}))},d=function(){function s(i,t){var e=this;!function(i,t){if(!(i instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),this.id=r++,this.telInput=i,this.activeItem=null,this.highlightedItem=null;var a=t||{};this.options={},l(o,(function(i,t){e.options[i]=a.hasOwnProperty(i)?a[i]:t})),this.hadInitialPlaceholder=Boolean(i.getAttribute("placeholder"))}var e,n;return e=s,(n=[{key:"_init",value:function(){var i=this;if(this.options.nationalMode&&(this.options.autoHideDialCode=!1),this.options.separateDialCode&&(this.options.autoHideDialCode=this.options.nationalMode=!1),this.isMobile=/Android.+Mobile|webOS|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent),this.isMobile&&(document.body.classList.add("iti-mobile"),this.options.dropdownContainer||(this.options.dropdownContainer=document.body)),"undefined"!=typeof Promise){var t=new Promise((function(t,s){i.resolveAutoCountryPromise=t,i.rejectAutoCountryPromise=s})),s=new Promise((function(t,s){i.resolveUtilsScriptPromise=t,i.rejectUtilsScriptPromise=s}));this.promise=Promise.all([t,s])}else this.resolveAutoCountryPromise=this.rejectAutoCountryPromise=function(){},this.resolveUtilsScriptPromise=this.rejectUtilsScriptPromise=function(){};this.selectedCountryData={},this._processCountryData(),this._generateMarkup(),this._setInitialState(),this._initListeners(),this._initRequests()}},{key:"_processCountryData",value:function(){this._processAllCountries(),this._processCountryCodes(),this._processPreferredCountries(),this.options.localizedCountries&&this._translateCountriesByLocale(),(this.options.onlyCountries.length||this.options.localizedCountries)&&this.countries.sort(this._countryNameSort)}},{key:"_addCountryCode",value:function(t,s,e){s.length>this.countryCodeMaxLen&&(this.countryCodeMaxLen=s.length),this.countryCodes.hasOwnProperty(s)||(this.countryCodes[s]=[]);for(var a=0;a<this.countryCodes[s].length;a++)if(this.countryCodes[s][a]===t)return;this.countryCodes[s][e!==i?e:this.countryCodes[s].length]=t}},{key:"_processAllCountries",value:function(){if(this.options.onlyCountries.length){var i=this.options.onlyCountries.map((function(i){return i.toLowerCase()}));this.countries=t.filter((function(t){return i.indexOf(t.iso2)>-1}))}else if(this.options.excludeCountries.length){var s=this.options.excludeCountries.map((function(i){return i.toLowerCase()}));this.countries=t.filter((function(i){return-1===s.indexOf(i.iso2)}))}else this.countries=t}},{key:"_translateCountriesByLocale",value:function(){for(var i=0;i<this.countries.length;i++){var t=this.countries[i].iso2.toLowerCase();this.options.localizedCountries.hasOwnProperty(t)&&(this.countries[i].name=this.options.localizedCountries[t])}}},{key:"_countryNameSort",value:function(i,t){return i.name.localeCompare(t.name)}},{key:"_processCountryCodes",value:function(){this.countryCodeMaxLen=0,this.dialCodes={},this.countryCodes={};for(var i=0;i<this.countries.length;i++){var t=this.countries[i];this.dialCodes[t.dialCode]||(this.dialCodes[t.dialCode]=!0),this._addCountryCode(t.iso2,t.dialCode,t.priority)}for(var s=0;s<this.countries.length;s++){var e=this.countries[s];if(e.areaCodes)for(var a=this.countryCodes[e.dialCode][0],n=0;n<e.areaCodes.length;n++){for(var r=e.areaCodes[n],o=1;o<r.length;o++){var h=e.dialCode+r.substr(0,o);this._addCountryCode(a,h),this._addCountryCode(e.iso2,h)}this._addCountryCode(e.iso2,e.dialCode+r)}}}},{key:"_processPreferredCountries",value:function(){this.preferredCountries=[];for(var i=0;i<this.options.preferredCountries.length;i++){var t=this.options.preferredCountries[i].toLowerCase(),s=this._getCountryData(t,!1,!0);s&&this.preferredCountries.push(s)}}},{key:"_createEl",value:function(i,t,s){var e=document.createElement(i);return t&&l(t,(function(i,t){return e.setAttribute(i,t)})),s&&s.appendChild(e),e}},{key:"_generateMarkup",value:function(){this.telInput.hasAttribute("autocomplete")||this.telInput.form&&this.telInput.form.hasAttribute("autocomplete")||this.telInput.setAttribute("autocomplete","off");var i="iti";this.options.allowDropdown&&(i+=" iti--allow-dropdown"),this.options.separateDialCode&&(i+=" iti--separate-dial-code"),this.options.customContainer&&(i+=" ",i+=this.options.customContainer);var t=this._createEl("div",{class:i});if(this.telInput.parentNode.insertBefore(t,this.telInput),this.flagsContainer=this._createEl("div",{class:"iti__flag-container"},t),t.appendChild(this.telInput),this.selectedFlag=this._createEl("div",{class:"iti__selected-flag",role:"combobox","aria-controls":"iti-".concat(this.id,"__country-listbox"),"aria-owns":"iti-".concat(this.id,"__country-listbox"),"aria-expanded":"false"},this.flagsContainer),this.selectedFlagInner=this._createEl("div",{class:"iti__flag"},this.selectedFlag),this.options.separateDialCode&&(this.selectedDialCode=this._createEl("div",{class:"iti__selected-dial-code"},this.selectedFlag)),this.options.allowDropdown&&(this.selectedFlag.setAttribute("tabindex","0"),this.dropdownArrow=this._createEl("div",{class:"iti__arrow"},this.selectedFlag),this.countryList=this._createEl("ul",{class:"iti__country-list iti__hide",id:"iti-".concat(this.id,"__country-listbox"),role:"listbox","aria-label":"List of countries"}),this.preferredCountries.length&&(this._appendListItems(this.preferredCountries,"iti__preferred",!0),this._createEl("li",{class:"iti__divider",role:"separator","aria-disabled":"true"},this.countryList)),this._appendListItems(this.countries,"iti__standard"),this.options.dropdownContainer?(this.dropdown=this._createEl("div",{class:"iti iti--container"}),this.dropdown.appendChild(this.countryList)):this.flagsContainer.appendChild(this.countryList)),this.options.hiddenInput){var s=this.options.hiddenInput,e=this.telInput.getAttribute("name");if(e){var a=e.lastIndexOf("[");-1!==a&&(s="".concat(e.substr(0,a),"[").concat(s,"]"))}this.hiddenInput=this._createEl("input",{type:"hidden",name:s}),t.appendChild(this.hiddenInput)}}},{key:"_appendListItems",value:function(i,t,s){for(var e="",a=0;a<i.length;a++){var n=i[a],r=s?"-preferred":"";e+="<li class='iti__country ".concat(t,"' tabIndex='-1' id='iti-").concat(this.id,"__item-").concat(n.iso2).concat(r,"' role='option' data-dial-code='").concat(n.dialCode,"' data-country-code='").concat(n.iso2,"' aria-selected='false'>"),e+="<div class='iti__flag-box'><div class='iti__flag iti__".concat(n.iso2,"'></div></div>"),e+="<span class='iti__country-name'>".concat(n.name,"</span>"),e+="<span class='iti__dial-code'>+".concat(n.dialCode,"</span>"),e+="</li>"}this.countryList.insertAdjacentHTML("beforeend",e)}},{key:"_setInitialState",value:function(){var i=this.telInput.getAttribute("value"),t=this.telInput.value,s=!i||"+"!==i.charAt(0)||t&&"+"===t.charAt(0)?t:i,e=this._getDialCode(s),a=this._isRegionlessNanp(s),n=this.options,r=n.initialCountry,o=n.nationalMode,h=n.autoHideDialCode,l=n.separateDialCode;e&&!a?this._updateFlagFromNumber(s):"auto"!==r&&(r?this._setFlag(r.toLowerCase()):e&&a?this._setFlag("us"):(this.defaultCountry=this.preferredCountries.length?this.preferredCountries[0].iso2:this.countries[0].iso2,s||this._setFlag(this.defaultCountry)),s||o||h||l||(this.telInput.value="+".concat(this.selectedCountryData.dialCode))),s&&this._updateValFromNumber(s)}},{key:"_initListeners",value:function(){this._initKeyListeners(),this.options.autoHideDialCode&&this._initBlurListeners(),this.options.allowDropdown&&this._initDropdownListeners(),this.hiddenInput&&this._initHiddenInputListener()}},{key:"_initHiddenInputListener",value:function(){var i=this;this._handleHiddenInputSubmit=function(){i.hiddenInput.value=i.getNumber()},this.telInput.form&&this.telInput.form.addEventListener("submit",this._handleHiddenInputSubmit)}},{key:"_getClosestLabel",value:function(){for(var i=this.telInput;i&&"LABEL"!==i.tagName;)i=i.parentNode;return i}},{key:"_initDropdownListeners",value:function(){var i=this;this._handleLabelClick=function(t){i.countryList.classList.contains("iti__hide")?i.telInput.focus():t.preventDefault()};var t=this._getClosestLabel();t&&t.addEventListener("click",this._handleLabelClick),this._handleClickSelectedFlag=function(){!i.countryList.classList.contains("iti__hide")||i.telInput.disabled||i.telInput.readOnly||i._showDropdown()},this.selectedFlag.addEventListener("click",this._handleClickSelectedFlag),this._handleFlagsContainerKeydown=function(t){i.countryList.classList.contains("iti__hide")&&-1!==["ArrowUp","Up","ArrowDown","Down"," ","Enter"].indexOf(t.key)&&(t.preventDefault(),t.stopPropagation(),i._showDropdown()),"Tab"===t.key&&i._closeDropdown()},this.flagsContainer.addEventListener("keydown",this._handleFlagsContainerKeydown)}},{key:"_initRequests",value:function(){var i=this;this.options.utilsScript&&!window.intlTelInputUtils?window.intlTelInputGlobals.documentReady()?window.intlTelInputGlobals.loadUtils(this.options.utilsScript):window.addEventListener("load",(function(){window.intlTelInputGlobals.loadUtils(i.options.utilsScript)})):this.resolveUtilsScriptPromise(),"auto"===this.options.initialCountry?this._loadAutoCountry():this.resolveAutoCountryPromise()}},{key:"_loadAutoCountry",value:function(){window.intlTelInputGlobals.autoCountry?this.handleAutoCountry():window.intlTelInputGlobals.startedLoadingAutoCountry||(window.intlTelInputGlobals.startedLoadingAutoCountry=!0,"function"==typeof this.options.geoIpLookup&&this.options.geoIpLookup((function(i){window.intlTelInputGlobals.autoCountry=i.toLowerCase(),setTimeout((function(){return u("handleAutoCountry")}))}),(function(){return u("rejectAutoCountryPromise")})))}},{key:"_initKeyListeners",value:function(){var i=this;this._handleKeyupEvent=function(){i._updateFlagFromNumber(i.telInput.value)&&i._triggerCountryChange()},this.telInput.addEventListener("keyup",this._handleKeyupEvent),this._handleClipboardEvent=function(){setTimeout(i._handleKeyupEvent)},this.telInput.addEventListener("cut",this._handleClipboardEvent),this.telInput.addEventListener("paste",this._handleClipboardEvent)}},{key:"_cap",value:function(i){var t=this.telInput.getAttribute("maxlength");return t&&i.length>t?i.substr(0,t):i}},{key:"_initBlurListeners",value:function(){var i=this;this._handleSubmitOrBlurEvent=function(){i._removeEmptyDialCode()},this.telInput.form&&this.telInput.form.addEventListener("submit",this._handleSubmitOrBlurEvent),this.telInput.addEventListener("blur",this._handleSubmitOrBlurEvent)}},{key:"_removeEmptyDialCode",value:function(){if("+"===this.telInput.value.charAt(0)){var i=this._getNumeric(this.telInput.value);i&&this.selectedCountryData.dialCode!==i||(this.telInput.value="")}}},{key:"_getNumeric",value:function(i){return i.replace(/\D/g,"")}},{key:"_trigger",value:function(i){var t=document.createEvent("Event");t.initEvent(i,!0,!0),this.telInput.dispatchEvent(t)}},{key:"_showDropdown",value:function(){this.countryList.classList.remove("iti__hide"),this.selectedFlag.setAttribute("aria-expanded","true"),this._setDropdownPosition(),this.activeItem&&(this._highlightListItem(this.activeItem,!1),this._scrollTo(this.activeItem,!0)),this._bindDropdownListeners(),this.dropdownArrow.classList.add("iti__arrow--up"),this._trigger("open:countrydropdown")}},{key:"_toggleClass",value:function(i,t,s){s&&!i.classList.contains(t)?i.classList.add(t):!s&&i.classList.contains(t)&&i.classList.remove(t)}},{key:"_setDropdownPosition",value:function(){var i=this;if(this.options.dropdownContainer&&this.options.dropdownContainer.appendChild(this.dropdown),!this.isMobile){var t=this.telInput.getBoundingClientRect(),s=window.pageYOffset||document.documentElement.scrollTop,e=t.top+s,a=this.countryList.offsetHeight,n=e+this.telInput.offsetHeight+a<s+window.innerHeight,r=e-a>s;this._toggleClass(this.countryList,"iti__country-list--dropup",!n&&r),this.options.dropdownContainer&&(this.dropdown.style.top="".concat(e+(!n&&r?0:this.telInput.offsetHeight),"px"),this.dropdown.style.left="".concat(t.left+document.body.scrollLeft,"px"),this._handleWindowScroll=function(){return i._closeDropdown()},window.addEventListener("scroll",this._handleWindowScroll))}}},{key:"_getClosestListItem",value:function(i){for(var t=i;t&&t!==this.countryList&&!t.classList.contains("iti__country");)t=t.parentNode;return t===this.countryList?null:t}},{key:"_bindDropdownListeners",value:function(){var i=this;this._handleMouseoverCountryList=function(t){var s=i._getClosestListItem(t.target);s&&i._highlightListItem(s,!1)},this.countryList.addEventListener("mouseover",this._handleMouseoverCountryList),this._handleClickCountryList=function(t){var s=i._getClosestListItem(t.target);s&&i._selectListItem(s)},this.countryList.addEventListener("click",this._handleClickCountryList);var t=!0;this._handleClickOffToClose=function(){t||i._closeDropdown(),t=!1},document.documentElement.addEventListener("click",this._handleClickOffToClose);var s="",e=null;this._handleKeydownOnDropdown=function(t){t.preventDefault(),"ArrowUp"===t.key||"Up"===t.key||"ArrowDown"===t.key||"Down"===t.key?i._handleUpDownKey(t.key):"Enter"===t.key?i._handleEnterKey():"Escape"===t.key?i._closeDropdown():/^[a-zA-ZÀ-ÿа-яА-Я ]$/.test(t.key)&&(e&&clearTimeout(e),s+=t.key.toLowerCase(),i._searchForCountry(s),e=setTimeout((function(){s=""}),1e3))},document.addEventListener("keydown",this._handleKeydownOnDropdown)}},{key:"_handleUpDownKey",value:function(i){var t="ArrowUp"===i||"Up"===i?this.highlightedItem.previousElementSibling:this.highlightedItem.nextElementSibling;t&&(t.classList.contains("iti__divider")&&(t="ArrowUp"===i||"Up"===i?t.previousElementSibling:t.nextElementSibling),this._highlightListItem(t,!0))}},{key:"_handleEnterKey",value:function(){this.highlightedItem&&this._selectListItem(this.highlightedItem)}},{key:"_searchForCountry",value:function(i){for(var t=0;t<this.countries.length;t++)if(this._startsWith(this.countries[t].name,i)){var s=this.countryList.querySelector("#iti-".concat(this.id,"__item-").concat(this.countries[t].iso2));this._highlightListItem(s,!1),this._scrollTo(s,!0);break}}},{key:"_startsWith",value:function(i,t){return i.substr(0,t.length).toLowerCase()===t}},{key:"_updateValFromNumber",value:function(i){var t=i;if(this.options.formatOnDisplay&&window.intlTelInputUtils&&this.selectedCountryData){var s=!this.options.separateDialCode&&(this.options.nationalMode||"+"!==t.charAt(0)),e=intlTelInputUtils.numberFormat;t=intlTelInputUtils.formatNumber(t,this.selectedCountryData.iso2,s?e.NATIONAL:e.INTERNATIONAL)}t=this._beforeSetNumber(t),this.telInput.value=t}},{key:"_updateFlagFromNumber",value:function(i){var t=i,s=this.selectedCountryData.dialCode;t&&this.options.nationalMode&&"1"===s&&"+"!==t.charAt(0)&&("1"!==t.charAt(0)&&(t="1".concat(t)),t="+".concat(t)),this.options.separateDialCode&&s&&"+"!==t.charAt(0)&&(t="+".concat(s).concat(t));var e=this._getDialCode(t,!0),a=this._getNumeric(t),n=null;if(e){var r=this.countryCodes[this._getNumeric(e)],o=-1!==r.indexOf(this.selectedCountryData.iso2)&&a.length<=e.length-1;if(!("1"===s&&this._isRegionlessNanp(a)||o))for(var h=0;h<r.length;h++)if(r[h]){n=r[h];break}}else"+"===t.charAt(0)&&a.length?n="":t&&"+"!==t||(n=this.defaultCountry);return null!==n&&this._setFlag(n)}},{key:"_isRegionlessNanp",value:function(i){var t=this._getNumeric(i);if("1"===t.charAt(0)){var s=t.substr(1,3);return-1!==h.indexOf(s)}return!1}},{key:"_highlightListItem",value:function(i,t){var s=this.highlightedItem;s&&s.classList.remove("iti__highlight"),this.highlightedItem=i,this.highlightedItem.classList.add("iti__highlight"),t&&this.highlightedItem.focus()}},{key:"_getCountryData",value:function(i,s,e){for(var a=s?t:this.countries,n=0;n<a.length;n++)if(a[n].iso2===i)return a[n];if(e)return null;throw new Error("No country data for '".concat(i,"'"))}},{key:"_setFlag",value:function(i){var t=this.selectedCountryData.iso2?this.selectedCountryData:{};this.selectedCountryData=i?this._getCountryData(i,!1,!1):{},this.selectedCountryData.iso2&&(this.defaultCountry=this.selectedCountryData.iso2),this.selectedFlagInner.setAttribute("class","iti__flag iti__".concat(i));var s=i?"".concat(this.selectedCountryData.name,": +").concat(this.selectedCountryData.dialCode):"Unknown";if(this.selectedFlag.setAttribute("title",s),this.options.separateDialCode){var e=this.selectedCountryData.dialCode?"+".concat(this.selectedCountryData.dialCode):"";this.selectedDialCode.innerHTML=e;var a=this.selectedFlag.offsetWidth||this._getHiddenSelectedFlagWidth();this.telInput.style.paddingLeft="".concat(a+6,"px")}if(this._updatePlaceholder(),this.options.allowDropdown){var n=this.activeItem;if(n&&(n.classList.remove("iti__active"),n.setAttribute("aria-selected","false")),i){var r=this.countryList.querySelector("#iti-".concat(this.id,"__item-").concat(i,"-preferred"))||this.countryList.querySelector("#iti-".concat(this.id,"__item-").concat(i));r.setAttribute("aria-selected","true"),r.classList.add("iti__active"),this.activeItem=r,this.selectedFlag.setAttribute("aria-activedescendant",r.getAttribute("id"))}}return t.iso2!==i}},{key:"_getHiddenSelectedFlagWidth",value:function(){var i=this.telInput.parentNode.cloneNode();i.style.visibility="hidden",document.body.appendChild(i);var t=this.flagsContainer.cloneNode();i.appendChild(t);var s=this.selectedFlag.cloneNode(!0);t.appendChild(s);var e=s.offsetWidth;return i.parentNode.removeChild(i),e}},{key:"_updatePlaceholder",value:function(){if(window.intlTelInputUtils&&("aggressive"===this.options.autoPlaceholder||!this.hadInitialPlaceholder&&"polite"===this.options.autoPlaceholder)){var i=intlTelInputUtils.numberType[this.options.placeholderNumberType],t=this.selectedCountryData.iso2?intlTelInputUtils.getExampleNumber(this.selectedCountryData.iso2,this.options.nationalMode,i):"";t=this._beforeSetNumber(t),"function"==typeof this.options.customPlaceholder&&(t=this.options.customPlaceholder(t,this.selectedCountryData)),this.telInput.setAttribute("placeholder",t)}}},{key:"_selectListItem",value:function(i){var t=this._setFlag(i.getAttribute("data-country-code"));this._closeDropdown(),this._updateDialCode(i.getAttribute("data-dial-code"),!0),this.telInput.focus();var s=this.telInput.value.length;this.telInput.setSelectionRange(s,s),t&&this._triggerCountryChange()}},{key:"_closeDropdown",value:function(){this.countryList.classList.add("iti__hide"),this.selectedFlag.setAttribute("aria-expanded","false"),this.dropdownArrow.classList.remove("iti__arrow--up"),document.removeEventListener("keydown",this._handleKeydownOnDropdown),document.documentElement.removeEventListener("click",this._handleClickOffToClose),this.countryList.removeEventListener("mouseover",this._handleMouseoverCountryList),this.countryList.removeEventListener("click",this._handleClickCountryList),this.options.dropdownContainer&&(this.isMobile||window.removeEventListener("scroll",this._handleWindowScroll),this.dropdown.parentNode&&this.dropdown.parentNode.removeChild(this.dropdown)),this._trigger("close:countrydropdown")}},{key:"_scrollTo",value:function(i,t){var s=this.countryList,e=window.pageYOffset||document.documentElement.scrollTop,a=s.offsetHeight,n=s.getBoundingClientRect().top+e,r=n+a,o=i.offsetHeight,h=i.getBoundingClientRect().top+e,l=h+o,u=h-n+s.scrollTop,d=a/2-o/2;h<n?(t&&(u-=d),s.scrollTop=u):l>r&&(t&&(u+=d),s.scrollTop=u-(a-o))}},{key:"_updateDialCode",value:function(i,t){var s,e=this.telInput.value,a="+".concat(i);if("+"===e.charAt(0)){var n=this._getDialCode(e);s=n?e.replace(n,a):a}else{if(this.options.nationalMode||this.options.separateDialCode)return;if(e)s=a+e;else{if(!t&&this.options.autoHideDialCode)return;s=a}}this.telInput.value=s}},{key:"_getDialCode",value:function(i,t){var s="";if("+"===i.charAt(0))for(var e="",a=0;a<i.length;a++){var n=i.charAt(a);if(!isNaN(parseInt(n,10))){if(e+=n,t)this.countryCodes[e]&&(s=i.substr(0,a+1));else if(this.dialCodes[e]){s=i.substr(0,a+1);break}if(e.length===this.countryCodeMaxLen)break}}return s}},{key:"_getFullNumber",value:function(){var i=this.telInput.value.trim(),t=this.selectedCountryData.dialCode,s=this._getNumeric(i);return(this.options.separateDialCode&&"+"!==i.charAt(0)&&t&&s?"+".concat(t):"")+i}},{key:"_beforeSetNumber",value:function(i){var t=i;if(this.options.separateDialCode){var s=this._getDialCode(t);s&&(s="+".concat(this.selectedCountryData.dialCode),t=t.substr(" "===t[s.length]||"-"===t[s.length]?s.length+1:s.length))}return this._cap(t)}},{key:"_triggerCountryChange",value:function(){this._trigger("countrychange")}},{key:"handleAutoCountry",value:function(){"auto"===this.options.initialCountry&&(this.defaultCountry=window.intlTelInputGlobals.autoCountry,this.telInput.value||this.setCountry(this.defaultCountry),this.resolveAutoCountryPromise())}},{key:"handleUtils",value:function(){window.intlTelInputUtils&&(this.telInput.value&&this._updateValFromNumber(this.telInput.value),this._updatePlaceholder()),this.resolveUtilsScriptPromise()}},{key:"destroy",value:function(){var i=this.telInput.form;if(this.options.allowDropdown){this._closeDropdown(),this.selectedFlag.removeEventListener("click",this._handleClickSelectedFlag),this.flagsContainer.removeEventListener("keydown",this._handleFlagsContainerKeydown);var t=this._getClosestLabel();t&&t.removeEventListener("click",this._handleLabelClick)}this.hiddenInput&&i&&i.removeEventListener("submit",this._handleHiddenInputSubmit),this.options.autoHideDialCode&&(i&&i.removeEventListener("submit",this._handleSubmitOrBlurEvent),this.telInput.removeEventListener("blur",this._handleSubmitOrBlurEvent)),this.telInput.removeEventListener("keyup",this._handleKeyupEvent),this.telInput.removeEventListener("cut",this._handleClipboardEvent),this.telInput.removeEventListener("paste",this._handleClipboardEvent),this.telInput.removeAttribute("data-intl-tel-input-id");var s=this.telInput.parentNode;s.parentNode.insertBefore(this.telInput,s),s.parentNode.removeChild(s),delete window.intlTelInputGlobals.instances[this.id]}},{key:"getExtension",value:function(){return window.intlTelInputUtils?intlTelInputUtils.getExtension(this._getFullNumber(),this.selectedCountryData.iso2):""}},{key:"getNumber",value:function(i){if(window.intlTelInputUtils){var t=this.selectedCountryData.iso2;return intlTelInputUtils.formatNumber(this._getFullNumber(),t,i)}return""}},{key:"getNumberType",value:function(){return window.intlTelInputUtils?intlTelInputUtils.getNumberType(this._getFullNumber(),this.selectedCountryData.iso2):-99}},{key:"getSelectedCountryData",value:function(){return this.selectedCountryData}},{key:"getValidationError",value:function(){if(window.intlTelInputUtils){var i=this.selectedCountryData.iso2;return intlTelInputUtils.getValidationError(this._getFullNumber(),i)}return-99}},{key:"isValidNumber",value:function(){var i=this._getFullNumber().trim();return window.intlTelInputUtils?intlTelInputUtils.isValidNumber(i,this.options.nationalMode?this.selectedCountryData.iso2:""):null}},{key:"setCountry",value:function(i){var t=i.toLowerCase();this.selectedFlagInner.classList.contains("iti__".concat(t))||(this._setFlag(t),this._updateDialCode(this.selectedCountryData.dialCode,!1),this._triggerCountryChange())}},{key:"setNumber",value:function(i){var t=this._updateFlagFromNumber(i);this._updateValFromNumber(i),t&&this._triggerCountryChange()}},{key:"setPlaceholderNumberType",value:function(i){this.options.placeholderNumberType=i,this._updatePlaceholder()}}])&&a(e.prototype,n),s}();n.getCountryData=function(){return t};var c=function(i,t,s){var e=document.createElement("script");e.onload=function(){u("handleUtils"),t&&t()},e.onerror=function(){u("rejectUtilsScriptPromise"),s&&s()},e.className="iti-load-utils",e.async=!0,e.src=i,document.body.appendChild(e)};return n.loadUtils=function(i){if(!window.intlTelInputUtils&&!window.intlTelInputGlobals.startedLoadingUtilsScript){if(window.intlTelInputGlobals.startedLoadingUtilsScript=!0,"undefined"!=typeof Promise)return new Promise((function(t,s){return c(i,t,s)}));c(i)}return null},n.defaults=o,n.version="17.0.15",function(i,t){var s=new d(i,t);return s._init(),i.setAttribute("data-intl-tel-input-id",s.id),window.intlTelInputGlobals.instances[s.id]=s,s}}()},i.exports?i.exports=t():window.intlTelInput=t()}(h={path:undefined,exports:{},require:function(){return function(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}()}}),h.exports);const u=class{constructor(t){i(this,t),this.countryCode="SA",this.countryKey="+966",n.setHost(this.host)}async getValues(){return this.phone=this.phoneInput.value,this.countryCode=this.countryCodeInput.value,this.countryKey=this.countryKeyInput.value,{phone:this.phoneInput.value,countryCode:this.countryCodeInput.value,countryKey:this.countryKeyInput.value}}initTelInput(){salla.document.event.onKeyup(".tel-input",(i=>salla.helpers.digitsOnly(i.target))),document.querySelectorAll(".tel-input").forEach((i=>{salla.helpers.digitsOnly(i);let t=l(i,{initialCountry:i.dataset.code||"sa",preferredCountries:["sa","ae","kw","bh","qa","iq","om","ye","eg","jo","sy","ps","sd","lb","dz","tn","ma","ly"],formatOnDisplay:!1,separateDialCode:!0,autoPlaceholder:"aggressive",utilsScript:"https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.12/js/utils.min.js"});i.addEventListener("countrychange",(()=>{let i=t.getSelectedCountryData();this.host.querySelectorAll(".country_code").forEach((t=>t.value=i.iso2.toUpperCase())),this.host.querySelectorAll(".country_key").forEach((t=>{t.value=("+"+i.dialCode).replace("++","+")}))}))}))}render(){return t(s,null,t("input",{type:"tel",name:"mobile","data-code":this.countryCode,value:this.phone,ref:i=>this.phoneInput=i,class:"s-tel-input-control tel-input s-ltr"}),t("input",{type:"hidden",name:"country_code",value:this.countryCode,ref:i=>this.countryCodeInput=i,class:"country_code"}),t("input",{type:"hidden",name:"country_key",value:this.countryKey,ref:i=>this.countryKeyInput=i,class:"country_key"}))}componentDidRender(){this.initTelInput()}get host(){return e(this)}},d=class{constructor(t){i(this,t),this.verified=a(this,"verified",7),this.backClicked=a(this,"backClicked",7),this.url="profile/verify-mobile",this.by="sms",this.autoReload=!0,n.setHost(this.host),this.withoutModal?this.modal={show:()=>"",hide:()=>""}:salla.event.on("profile::verify.mobile",(i=>this.show(i)))}async getCode(){return this.code.value}componentDidLoad(){return n.on("input",".s-verify-input",(i=>salla.helpers.digitsOnly(i.target))),n.onKeyUp(".s-verify-input",(i=>{var t,s,e,a;let n=i.keyCode||i.charCode;i.target.value?(null===(t=i.target.nextElementSibling)||void 0===t||t.focus(),null===(s=i.target.nextElementSibling)||void 0===s||s.select()):[8,46].includes(n)&&(null===(e=i.target.previousElementSibling)||void 0===e||e.focus(),null===(a=i.target.previousElementSibling)||void 0===a||a.select()),this.toggleOTPSubmit()})),n.on("paste",".s-verify-input",(i=>{let t=i.clipboardData.getData("text").toArabicDigits().replace(/[^0-9.]/g,"").replace("..",".");this.otpInputs.forEach(((i,s)=>i.value=t[s]||"")),this.toggleOTPSubmit(),setTimeout((()=>this.otpInputs[3].focus()),100)})),this.modal.show()}async show(i){this.data=i,this.resendTimer(),this.otpInputs=document.querySelectorAll(".s-verify-input"),this.reset()}toggleOTPSubmit(){let i=[];if(this.otpInputs.forEach((t=>t.value&&i.push(t.value))),this.code.value=i.join(""),4===i.length)return this.btn.removeAttribute("disabled"),void this.btn.click();this.btn.setAttribute("disabled","")}reset(){this.otpInputs.forEach((i=>i.value="")),this.code.value="",this.otpInputs[0].focus()}resendTimer(){n.showElement(this.resendMessage).hideElement(this.resend);let i=30,t=setInterval((()=>{-1===i?(clearTimeout(t),n.hideElement(this.resendMessage).showElement(this.resend)):(this.timer.innerHTML=`${i>=10?i:"0"+i} : 00`,i--)}),1e3)}resendCode(){return this.btn.stop().then((()=>this.btn.disable())).then((()=>{this.otpInputs.forEach((i=>i.value="")),this.otpInputs[0].focus()})).then((()=>salla.api.auth.resend(Object.assign({resend_by:this.by},this.data)))).then((()=>this.resendTimer())).catch((()=>this.resendTimer()))}submit(){return this.btn.load().then((()=>this.btn.disable())).then((()=>salla.document.api.request(this.url,Object.assign({code:this.code.value},this.data)))).then((i=>this.verified.emit(i))).then((()=>this.btn.stop()&&this.btn.disable())).then((()=>this.modal.hide())).then((()=>this.autoReload&&window.location.reload())).catch((()=>this.btn.stop()&&this.btn.enable()&&this.reset()))}render(){return this.withoutModal?this.myBody():t("salla-modal",{id:"s-verify",ref:i=>this.modal=i,title:salla.lang.get("pages.profile.verify_title")},this.myBody())}myBody(){return[t("div",{class:"s-verify-message",innerHTML:salla.lang.get("pages.profile.verify_message")}),t("input",{type:"hidden",name:"code",maxlength:"4",required:!0,ref:i=>this.code=i}),t("div",{class:"s-verify-codes",dir:"ltr"},[1,2,3,4].map((()=>t("input",{type:"text",maxlength:"1",class:"s-verify-input",required:!0})))),t("div",{slot:"footer",class:"s-verify-footer"},t("salla-button",{class:"s-verify-submit",disabled:!0,onClick:()=>this.submit(),ref:i=>this.btn=i},salla.lang.get("pages.profile.verify")),t("p",{class:"s-verify-resend-message",ref:i=>this.resendMessage=i},salla.lang.get("blocks.header.resend_after"),t("b",{class:"s-verify-timer",ref:i=>this.timer=i})),t("a",{href:"#",class:"s-verify-resend",onClick:()=>this.resendCode(),ref:i=>this.resend=i},salla.lang.get("blocks.comments.submit")),this.backText?t("a",{href:"#",class:"s-verify-resend",onClick:()=>this.backClicked.emit()},this.backText):"")]}get host(){return e(this)}};export{r as salla_button,o as salla_modal,u as salla_tel_input,d as salla_verify}
@@ -1 +0,0 @@
1
- import{r as s,h as a,g as e}from"./p-6a5be894.js";import{H as i}from"./p-47f17d3b.js";const r=class{constructor(a){var e;s(this,a),this.results=[],this.placeholder=salla.lang.get("blocks.header.search_placeholder"),this.noResultsText=salla.lang.get("common.elements.no_options"),i.setHost(this.host),this.productSlot=(null===(e=i.getElement('[slot="product"]'))||void 0===e?void 0:e.innerHTML)||this.getDefaultProductSlot()}onModalOpen(){this.modal.querySelector(".s-search-input").focus()}onModalClose(){this.modal.querySelector(".s-search-input").value="",this.results=[],this.afterSearching()}getDefaultProductSlot(){return'<div class="s-search-product-image-container"> <img class="s-search-product-image" src="{image}" alt="{name}"/></div><div class="s-search-product-details"> <div class="s-search-product-name">{name}</div> <div class="s-search-product-price">{price}</div></div>'}search(s){if(i.hideElement(this.noResults),0===s.target.value.length)return this.results=[],void this.afterSearching();s.target.value.length<=2||(i.toggleElement(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!0)),salla.search.api.search(s.target.value).then((s=>this.results=s.results)).catch((s=>"Query Same As Previous!"!==s?this.results=[]:null)).finally((()=>this.afterSearching(!1))))}afterSearching(s=!0){this.noResults.style.display=s||this.results.length>0?"none":"block",i.toggleElement(this.container,"s-search-container-open","no-results",(()=>this.results.length)).toggleElement(this.searchIcon,"s-search-spinner-loader","sicon-search",(()=>!1)),salla.search.api.previousQuery=""}render(){var s;return a("salla-modal",{position:"top",id:"s-search-modal",ref:s=>this.modal=s},a("div",{class:"s-search-container",ref:s=>this.container=s},a("input",{class:"s-search-input",type:"text",placeholder:this.placeholder,onInput:s=>this.search(s)}),a("span",{class:"s-search-icon"},a("i",{class:"sicon-search",ref:s=>this.searchIcon=s})),a("div",{class:"s-search-results"},null===(s=this.results)||void 0===s?void 0:s.map((s=>{var e;return a("a",{href:s.url,class:"s-search-product",innerHTML:this.productSlot.replace(/\{name\}/g,s.title).replace(/\{price\}/g,null===(e=s.price)||void 0===e?void 0:e.after).replace(/\{image\}/g,s.thumb)})})),a("p",{ref:s=>this.noResults=s,class:"s-search-no-results"},this.noResultsText))))}componentDidLoad(){this.afterSearching()}get host(){return e(this)}};r.style="#s-search-modal .s-modal-wrapper{align-items:flex-start;padding:0}#s-search-modal .s-modal-spacer{display:inline}#s-search-modal .s-modal-body{padding:0;max-width:90%;margin-top:3.2rem}#s-search-modal .s-modal-close{top:1rem}";export{r as S}