@salla.sa/twilight-components 1.3.0 → 1.4.0

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 (35) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/{salla-branches_22.cjs.entry.js → salla-button_23.cjs.entry.js} +1557 -89
  4. package/dist/cjs/twilight-components.cjs.js +2 -2
  5. package/dist/collection/collection-manifest.json +3 -2
  6. package/dist/collection/components/salla-scopes/interfaces.js +8 -0
  7. package/dist/collection/components/salla-scopes/salla-scopes.css +27 -0
  8. package/dist/collection/components/salla-scopes/salla-scopes.js +256 -0
  9. package/dist/collection/components/salla-social-share/interfaces.js +11 -0
  10. package/dist/collection/components/salla-social-share/salla-social-share.css +0 -0
  11. package/dist/collection/components/salla-social-share/salla-social-share.js +165 -0
  12. package/dist/components/index.d.ts +2 -1
  13. package/dist/components/index.js +2 -1
  14. package/dist/components/{salla-branches.d.ts → salla-scopes.d.ts} +4 -4
  15. package/dist/components/salla-scopes.js +206 -0
  16. package/dist/components/salla-social-share.d.ts +11 -0
  17. package/dist/components/salla-social-share.js +1460 -0
  18. package/dist/esm/loader.js +2 -2
  19. package/dist/esm/{salla-branches_22.entry.js → salla-button_23.entry.js} +1557 -90
  20. package/dist/esm/twilight-components.js +2 -2
  21. package/dist/twilight-components/p-d65e71f2.entry.js +4 -0
  22. package/dist/twilight-components/twilight-components.esm.js +1 -1
  23. package/dist/types/components/salla-scopes/interfaces.d.ts +19 -0
  24. package/dist/types/components/salla-scopes/salla-scopes.d.ts +39 -0
  25. package/dist/types/components/salla-social-share/interfaces.d.ts +7 -0
  26. package/dist/types/components/salla-social-share/salla-social-share.d.ts +23 -0
  27. package/dist/types/components.d.ts +64 -25
  28. package/example/assets/tailwind.css +329 -120
  29. package/example/index.html +4 -4
  30. package/package.json +3 -2
  31. package/dist/collection/components/salla-branches/salla-branches.css +0 -4
  32. package/dist/collection/components/salla-branches/salla-branches.js +0 -239
  33. package/dist/components/salla-branches.js +0 -141
  34. package/dist/twilight-components/p-ff70bbc9.entry.js +0 -4
  35. package/dist/types/components/salla-branches/salla-branches.d.ts +0 -24
@@ -1,96 +1,9 @@
1
1
  /*!
2
2
  * Crafted with ❤ by Salla
3
3
  */
4
- import { r as registerInstance, h, g as getElement, H as Host, c as createEvent } from './index-4e30ffd0.js';
4
+ import { r as registerInstance, h, H as Host, g as getElement, c as createEvent } from './index-4e30ffd0.js';
5
5
  import { H as Helper } from './Helper-e1d414a5.js';
6
-
7
- const sallaBranchesCss = "";
8
-
9
- const SallaBranches = class {
10
- constructor(hostRef) {
11
- registerInstance(this, hostRef);
12
- this.open = true;
13
- this.isOpenedBefore = salla.storage.get("branch-choosed-before");
14
- this.displayAs = 'default'; //todo:: change it to boolean, isPopup default false
15
- this.browseProductsFrom = 'all'; //todo:: get better name
16
- this.branches = [
17
- { id: 1, name: 'فرع الرياض', open: true, available: true, limited: false, tag: 'متوفر' },
18
- { id: 2, name: 'فرع جدة', open: false, available: false, limited: false, tag: 'غير متوفر' },
19
- { id: 3, name: 'فرع مكة', open: true, available: true, limited: false, tag: 'متوفر' },
20
- { id: 4, name: 'فرع المدينة', open: true, available: true, limited: false, tag: 'متوفر' },
21
- { id: 5, name: 'فرع جازان', open: true, available: true, limited: true, tag: 'الكمية محدودة' }
22
- ];
23
- this.current = 1;
24
- this.currentBranch = (prop) => {
25
- return this.branches.filter((el) => el.id == this.current)[0][prop];
26
- };
27
- this.statusColor = (branch = null) => {
28
- return branch ?
29
- branch.limited ? 's-branches-color-red' : branch.available ? 's-branches-color-green' : 's-branches-color-gray'
30
- :
31
- this.currentBranch('limited') ? 's-branches-color-red' : this.currentBranch('available') ? 's-branches-color-green' : 's-branches-color-gray';
32
- };
33
- this.isChoiceable = () => {
34
- return (this.browseProductsFrom !== 'all' && this.position == 'single') || this.position == 'header';
35
- };
36
- this.formTitle = () => {
37
- return this.isChoiceable() ?
38
- 'توفر المنتج في الفروع الآخرى'
39
- : 'التسوق من فرع آخر';
40
- };
41
- salla.event.on('branches::show', btn => btn.dataset.target == this.host.id && this.show());
42
- salla.lang.onLoaded(() => { var _a; return (_a = this.btn) === null || _a === void 0 ? void 0 : _a.setText(salla.lang.get('common.elements.ok')); });
43
- }
44
- //todo:: add description for all @methods
45
- async show() {
46
- var _a;
47
- return (_a = this.modal) === null || _a === void 0 ? void 0 : _a.open();
48
- }
49
- async hide() {
50
- var _a;
51
- return (_a = this.modal) === null || _a === void 0 ? void 0 : _a.close();
52
- }
53
- handelChange(event) {
54
- this.selected = event.target.value;
55
- }
56
- handleSubmit() {
57
- this.btn.load().then(() => {
58
- setTimeout(() => location.reload(), 2000);
59
- });
60
- salla.storage.set("branch-choosed-before", true);
61
- this.show();
62
- setTimeout(() => {
63
- this.current = this.selected;
64
- }, 300);
65
- }
66
- render() {
67
- return (h("salla-modal", { icon: "sicon-store-alt", "modal-title": "\u0641\u0631\u0639 \u0627\u0644\u0631\u064A\u0627\u0636", "sub-title": "\u0623\u0646\u062A \u0627\u0644\u0622\u0646 \u062A\u062A\u0635\u0641\u062D \u0627\u0644\u0645\u062A\u062C\u0631 \u0645\u0646", "sub-title-first": true,
68
- // is-closable={!this.isOpenedBefore && this.displayAs == 'popup' ? 'false' : 'true'}
69
- ref: (modal) => this.modal = modal, width: "sm", id: "s-branches-modal", class: "s-hidden" }, h("h4", { class: "s-branches-title" }, this.formTitle()), this.branches.length <= 5 ?
70
- h("div", { class: "s-branches-space-v" }, this.branches.map((branch) => h("div", { class: "s-branches-input-wrap" }, h("input", { id: this.position + '_branch_' + branch.id, disabled: !branch.open && this.isChoiceable(), name: "lang", type: "radio", value: branch.id, onChange: (event) => this.handelChange(event), class: {
71
- 's-branches-input': true,
72
- 'opacity-50': !branch.open,
73
- 's-hidden': !this.isChoiceable()
74
- }, checked: this.current == branch.id }), h("label", { htmlFor: this.position + '_branch_' + branch.id, class: {
75
- 's-branches-label': true,
76
- 's-branches-clickable': this.isChoiceable()
77
- } }, h("span", { class: { 's-branches-is-closed': !branch.open } }, branch.name), this.isChoiceable() ?
78
- h("small", { class: "s-branches-closed-badge" }, branch.open ? '' : 'مُغلق')
79
- :
80
- h("span", { class: this.statusColor(branch) }, branch.tag)))))
81
- :
82
- h("select", { class: "s-branches-select", onInput: (event) => this.handelChange(event) }, this.branches.map(branch => (h("option", { value: branch.id, disabled: !branch.open, selected: this.selected == branch.id }, branch.name, " ", branch.open ? '' : '- مُغلق')))), this.isChoiceable() ?
83
- h("slot", { name: "footer" }, h("salla-button", { ref: btn => this.btn = btn, onClick: () => this.handleSubmit(), class: "s-branches-submit", width: "wide" }, salla.lang.get('common.elements.ok')))
84
- : ''));
85
- }
86
- componentDidRender() {
87
- if (!this.isOpenedBefore && this.displayAs == 'popup') {
88
- this.show();
89
- }
90
- }
91
- get host() { return getElement(this); }
92
- };
93
- SallaBranches.style = sallaBranchesCss;
6
+ import 'https://static.addtoany.com/menu/page.js';
94
7
 
95
8
  const sallaButtonCss = "";
96
9
 
@@ -1590,6 +1503,139 @@ const SallaRatingStars = class {
1590
1503
  };
1591
1504
  SallaRatingStars.style = sallaRatingStarsCss;
1592
1505
 
1506
+ const StoreAlt = `<!-- Generated by IcoMoon.io -->
1507
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
1508
+ <title>store-alt</title>
1509
+ <path d="M6.667 24h5.333c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333h-5.333c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333zM31.86 10.071l-4-8c-0.227-0.452-0.688-0.737-1.193-0.737h-21.333c-0.505 0-0.967 0.285-1.193 0.737l-4 8c-0.092 0.184-0.14 0.389-0.14 0.596v18.667c0 0.737 0.597 1.333 1.333 1.333h29.333c0.736 0 1.333-0.596 1.333-1.333v-18.667c0-0.207-0.048-0.412-0.14-0.596zM6.157 4h19.685l3.333 6.667h-26.352zM24 28h-5.333v-9.333h5.333zM29.333 28h-2.667v-10.667c0-0.737-0.597-1.333-1.333-1.333h-8c-0.736 0-1.333 0.596-1.333 1.333v10.667h-13.333v-14.667h26.667zM6.667 18.667h5.333c0.736 0 1.333-0.596 1.333-1.333s-0.597-1.333-1.333-1.333h-5.333c-0.736 0-1.333 0.596-1.333 1.333s0.597 1.333 1.333 1.333z"></path>
1510
+ </svg>
1511
+ `;
1512
+
1513
+ const Search = `<!-- Generated by IcoMoon.io -->
1514
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
1515
+ <title>search</title>
1516
+ <path d="M30.276 28.391l-7.576-7.576c1.644-2.053 2.633-4.652 2.633-7.481 0-6.616-5.384-12-12-12s-12 5.384-12 12 5.384 12 12 12c2.829 0 5.428-0.989 7.481-2.633l7.576 7.576c0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391c0.521-0.521 0.521-1.364 0-1.885zM13.333 22.667c-5.147 0-9.333-4.187-9.333-9.333s4.187-9.333 9.333-9.333 9.333 4.187 9.333 9.333-4.187 9.333-9.333 9.333z"></path>
1517
+ </svg>
1518
+ `;
1519
+
1520
+ var ModeType;
1521
+ (function (ModeType) {
1522
+ ModeType["DEFAULT"] = "default";
1523
+ ModeType["AVAILABILITY"] = "availability";
1524
+ })(ModeType || (ModeType = {}));
1525
+
1526
+ const sallaScopesCss = ".s-scopes-availability-content{display:flex;justify-content:center;align-items:center}.s-scopes-container::-webkit-scrollbar{width:5px}.s-scopes-container::-webkit-scrollbar-track{background-color:#eee}.s-scopes-container::-webkit-scrollbar-thumb{background-color:var(--color-primary);border-radius:10px;-webkit-border-radius:10px;-moz-border-radius:10px;-ms-border-radius:10px;-o-border-radius:10px}.s-scopes-placeholder{flex:0 0 85%}";
1527
+
1528
+ const SallaScopees = class {
1529
+ constructor(hostRef) {
1530
+ registerInstance(this, hostRef);
1531
+ this.mode = ModeType.DEFAULT;
1532
+ this.scopes = [];
1533
+ this.originalScopesList = [];
1534
+ this.isDefault = true;
1535
+ /**
1536
+ * Dictates when to show the searchfield
1537
+ */
1538
+ this.searchFieldToggler = 6;
1539
+ this.getFormTitle = () => {
1540
+ var _a;
1541
+ if (((_a = this.originalScopesList) === null || _a === void 0 ? void 0 : _a.length) < 2)
1542
+ return "";
1543
+ return this.isDefault ?
1544
+ this.shoppingFromAnotherBranch :
1545
+ this.searchForAvailabilityInOtherBranch;
1546
+ };
1547
+ salla.event.on('scopes::open', ({ mode = null, product_id = null }) => {
1548
+ if (!!mode)
1549
+ this.mode = mode;
1550
+ this.isDefault = !mode || mode == ModeType.DEFAULT;
1551
+ this.open(mode, product_id);
1552
+ });
1553
+ salla.lang.onLoaded(() => {
1554
+ this.branchNotFound = salla.lang.get("blocks.scope.branch_looking_for_not_found");
1555
+ this.ourServiceIsNotFound = salla.lang.get("blocks.scope.our_services_not_available_in_this_branch");
1556
+ this.searchForAvailabilityInOtherBranch = salla.lang.get('blocks.scope.search_for_availability_in_other_branches');
1557
+ this.shoppingFromAnotherBranch = salla.lang.get("blocks.scope.shopping_from_another_branch");
1558
+ this.nowBrowsingFrom = salla.lang.get('blocks.scope.you_are_browse_store_from');
1559
+ this.confirmButton = salla.lang.get('common.elements.confirm');
1560
+ this.scopeSearchPlaceholder = salla.lang.get('blocks.scope.searching_for_a_branch');
1561
+ });
1562
+ }
1563
+ async close() {
1564
+ var _a;
1565
+ return await ((_a = this.modal) === null || _a === void 0 ? void 0 : _a.close());
1566
+ }
1567
+ async open(mode = ModeType.DEFAULT, product_id = null) {
1568
+ this.modal.open();
1569
+ return await (mode == ModeType.AVAILABILITY ? salla.scope.getProductAvailability(product_id) : salla.scope.get())
1570
+ .then((resp) => {
1571
+ if (mode == ModeType.AVAILABILITY) {
1572
+ this.setScopeValues(resp.data);
1573
+ }
1574
+ else {
1575
+ this.setScopeValues(resp.data.scopes);
1576
+ }
1577
+ }).catch(e => console.log(e))
1578
+ .finally(() => {
1579
+ this.modal.stopLoading();
1580
+ });
1581
+ }
1582
+ async handleSubmit() {
1583
+ let payload = { 'scope_id': this.current_scope.id };
1584
+ this.changeBtn.load();
1585
+ return await salla.scope.change(payload)
1586
+ .then(() => {
1587
+ window.location.reload();
1588
+ }).catch(e => console.log(e))
1589
+ .finally(() => {
1590
+ this.changeBtn.stop();
1591
+ });
1592
+ }
1593
+ setScopeValues(value) {
1594
+ this.scopes = value;
1595
+ this.originalScopesList = value;
1596
+ if (value.length == 1) {
1597
+ this.current_scope = value[0];
1598
+ this.selected_scope = value[0];
1599
+ }
1600
+ else {
1601
+ this.current_scope = value.find(scope => scope.selected);
1602
+ this.selected_scope = value.find(scope => scope.selected);
1603
+ }
1604
+ }
1605
+ handleSearchFieldTyping(e) {
1606
+ let value = e.target.value.toLocaleLowerCase();
1607
+ if (!!value) {
1608
+ this.scopes = this.originalScopesList.filter(scope => scope.name.toLowerCase().includes(value));
1609
+ }
1610
+ else {
1611
+ this.scopes = this.originalScopesList;
1612
+ }
1613
+ }
1614
+ handleScopeSelection(event) {
1615
+ this.current_scope = this.scopes.find(scope => scope.id == event.target.value);
1616
+ }
1617
+ placeholderContent() {
1618
+ return h("salla-placeholder", { alignment: "center", class: "s-scopes-placeholder" }, h("span", { slot: "title" }, this.branchNotFound), h("span", { slot: "description" }, this.ourServiceIsNotFound));
1619
+ }
1620
+ defaultContent() {
1621
+ return [h("div", { class: "s-scopes-container" }, this.scopes.map((scope) => h("div", { class: "s-scopes-input-wrap", "data-position": this.position }, h("input", { id: `${this.position} + '_scope_' + ${scope.id}`, name: "lang", type: "radio", value: scope.id, onChange: (event) => this.handleScopeSelection(event), class: "s-scopes-input", checked: !!this.current_scope && this.current_scope.id == scope.id }), h("label", { htmlFor: this.position + '_scope_' + scope.id, class: "s-scopes-label s-scopes-clickable" }, h("span", null, scope.name))))), this.footerContent()];
1622
+ }
1623
+ availabilityContent() {
1624
+ return h("div", { class: "s-scopes-container" }, this.scopes.map((scope) => h("div", { class: "s-scopes-input-wrap", "data-position": this.position }, h("h2", { class: { "s-scopes-label": true, "s-scopes-clickable": this.isDefault } }, h("span", null, scope.name)), h("h2", { style: { 'color': scope.availability.color }, class: `s-scopes-${scope.availability.key}` }, scope.availability.label))));
1625
+ }
1626
+ footerContent() {
1627
+ return h("div", { class: "s-scopes-footer" }, h("slot", { name: "footer" }, h("salla-button", { ref: btn => this.changeBtn = btn, disabled: !this.current_scope, onClick: () => this.handleSubmit(), class: "s-scopes-submit", "loader-position": "center", width: "wide" }, this.confirmButton)));
1628
+ }
1629
+ render() {
1630
+ return (h(Host, null, h("salla-modal", { ref: modal => this.modal = modal, id: "s-scopes-modal", class: "s-scopes-modal", isLoading: true }, h("salla-list-tile", { class: this.originalScopesList.length ? "s-scopes-header block" : "s-hidden" }, h("div", { slot: "icon", class: "s-scopes-header-icon", innerHTML: StoreAlt }), h("div", { slot: "title", class: "s-scopes-header-title" }, this.nowBrowsingFrom, " "), h("div", { slot: "subtitle", class: "s-scopes-header-subtitle" }, !!this.selected_scope ? this.selected_scope.name : "")), h("div", { class: "s-scopes-wrap" }, !!this.originalScopesList.length && h("h4", { class: "s-scopes-title" }, this.getFormTitle()), this.originalScopesList.length > this.searchFieldToggler ?
1631
+ h("div", { class: "s-scopes-search-wrapper" }, h("div", { class: "s-scopes-search-icon", innerHTML: Search }), h("input", { type: "text", class: "s-scopes-search-input", onInput: e => this.handleSearchFieldTyping(e), placeholder: this.scopeSearchPlaceholder }))
1632
+ : "", this.scopes.length < 2 ?
1633
+ this.placeholderContent()
1634
+ : this.isDefault ? this.defaultContent() : this.availabilityContent()))));
1635
+ }
1636
+ };
1637
+ SallaScopees.style = sallaScopesCss;
1638
+
1593
1639
  const sallaSearchCss = "";
1594
1640
 
1595
1641
  const SallaSearch = class {
@@ -1691,6 +1737,1427 @@ const SallaSearch = class {
1691
1737
  };
1692
1738
  SallaSearch.style = sallaSearchCss;
1693
1739
 
1740
+ /*
1741
+ * anime.js v3.2.1
1742
+ * (c) 2020 Julian Garnier
1743
+ * Released under the MIT license
1744
+ * animejs.com
1745
+ */
1746
+
1747
+ // Defaults
1748
+
1749
+ var defaultInstanceSettings = {
1750
+ update: null,
1751
+ begin: null,
1752
+ loopBegin: null,
1753
+ changeBegin: null,
1754
+ change: null,
1755
+ changeComplete: null,
1756
+ loopComplete: null,
1757
+ complete: null,
1758
+ loop: 1,
1759
+ direction: 'normal',
1760
+ autoplay: true,
1761
+ timelineOffset: 0
1762
+ };
1763
+
1764
+ var defaultTweenSettings = {
1765
+ duration: 1000,
1766
+ delay: 0,
1767
+ endDelay: 0,
1768
+ easing: 'easeOutElastic(1, .5)',
1769
+ round: 0
1770
+ };
1771
+
1772
+ var validTransforms = ['translateX', 'translateY', 'translateZ', 'rotate', 'rotateX', 'rotateY', 'rotateZ', 'scale', 'scaleX', 'scaleY', 'scaleZ', 'skew', 'skewX', 'skewY', 'perspective', 'matrix', 'matrix3d'];
1773
+
1774
+ // Caching
1775
+
1776
+ var cache = {
1777
+ CSS: {},
1778
+ springs: {}
1779
+ };
1780
+
1781
+ // Utils
1782
+
1783
+ function minMax(val, min, max) {
1784
+ return Math.min(Math.max(val, min), max);
1785
+ }
1786
+
1787
+ function stringContains(str, text) {
1788
+ return str.indexOf(text) > -1;
1789
+ }
1790
+
1791
+ function applyArguments(func, args) {
1792
+ return func.apply(null, args);
1793
+ }
1794
+
1795
+ var is$1 = {
1796
+ arr: function (a) { return Array.isArray(a); },
1797
+ obj: function (a) { return stringContains(Object.prototype.toString.call(a), 'Object'); },
1798
+ pth: function (a) { return is$1.obj(a) && a.hasOwnProperty('totalLength'); },
1799
+ svg: function (a) { return a instanceof SVGElement; },
1800
+ inp: function (a) { return a instanceof HTMLInputElement; },
1801
+ dom: function (a) { return a.nodeType || is$1.svg(a); },
1802
+ str: function (a) { return typeof a === 'string'; },
1803
+ fnc: function (a) { return typeof a === 'function'; },
1804
+ und: function (a) { return typeof a === 'undefined'; },
1805
+ nil: function (a) { return is$1.und(a) || a === null; },
1806
+ hex: function (a) { return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(a); },
1807
+ rgb: function (a) { return /^rgb/.test(a); },
1808
+ hsl: function (a) { return /^hsl/.test(a); },
1809
+ col: function (a) { return (is$1.hex(a) || is$1.rgb(a) || is$1.hsl(a)); },
1810
+ key: function (a) { return !defaultInstanceSettings.hasOwnProperty(a) && !defaultTweenSettings.hasOwnProperty(a) && a !== 'targets' && a !== 'keyframes'; },
1811
+ };
1812
+
1813
+ // Easings
1814
+
1815
+ function parseEasingParameters(string) {
1816
+ var match = /\(([^)]+)\)/.exec(string);
1817
+ return match ? match[1].split(',').map(function (p) { return parseFloat(p); }) : [];
1818
+ }
1819
+
1820
+ // Spring solver inspired by Webkit Copyright © 2016 Apple Inc. All rights reserved. https://webkit.org/demos/spring/spring.js
1821
+
1822
+ function spring(string, duration) {
1823
+
1824
+ var params = parseEasingParameters(string);
1825
+ var mass = minMax(is$1.und(params[0]) ? 1 : params[0], .1, 100);
1826
+ var stiffness = minMax(is$1.und(params[1]) ? 100 : params[1], .1, 100);
1827
+ var damping = minMax(is$1.und(params[2]) ? 10 : params[2], .1, 100);
1828
+ var velocity = minMax(is$1.und(params[3]) ? 0 : params[3], .1, 100);
1829
+ var w0 = Math.sqrt(stiffness / mass);
1830
+ var zeta = damping / (2 * Math.sqrt(stiffness * mass));
1831
+ var wd = zeta < 1 ? w0 * Math.sqrt(1 - zeta * zeta) : 0;
1832
+ var a = 1;
1833
+ var b = zeta < 1 ? (zeta * w0 + -velocity) / wd : -velocity + w0;
1834
+
1835
+ function solver(t) {
1836
+ var progress = duration ? (duration * t) / 1000 : t;
1837
+ if (zeta < 1) {
1838
+ progress = Math.exp(-progress * zeta * w0) * (a * Math.cos(wd * progress) + b * Math.sin(wd * progress));
1839
+ } else {
1840
+ progress = (a + b * progress) * Math.exp(-progress * w0);
1841
+ }
1842
+ if (t === 0 || t === 1) { return t; }
1843
+ return 1 - progress;
1844
+ }
1845
+
1846
+ function getDuration() {
1847
+ var cached = cache.springs[string];
1848
+ if (cached) { return cached; }
1849
+ var frame = 1/6;
1850
+ var elapsed = 0;
1851
+ var rest = 0;
1852
+ while(true) {
1853
+ elapsed += frame;
1854
+ if (solver(elapsed) === 1) {
1855
+ rest++;
1856
+ if (rest >= 16) { break; }
1857
+ } else {
1858
+ rest = 0;
1859
+ }
1860
+ }
1861
+ var duration = elapsed * frame * 1000;
1862
+ cache.springs[string] = duration;
1863
+ return duration;
1864
+ }
1865
+
1866
+ return duration ? solver : getDuration;
1867
+
1868
+ }
1869
+
1870
+ // Basic steps easing implementation https://developer.mozilla.org/fr/docs/Web/CSS/transition-timing-function
1871
+
1872
+ function steps(steps) {
1873
+ if ( steps === void 0 ) steps = 10;
1874
+
1875
+ return function (t) { return Math.ceil((minMax(t, 0.000001, 1)) * steps) * (1 / steps); };
1876
+ }
1877
+
1878
+ // BezierEasing https://github.com/gre/bezier-easing
1879
+
1880
+ var bezier = (function () {
1881
+
1882
+ var kSplineTableSize = 11;
1883
+ var kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
1884
+
1885
+ function A(aA1, aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1 }
1886
+ function B(aA1, aA2) { return 3.0 * aA2 - 6.0 * aA1 }
1887
+ function C(aA1) { return 3.0 * aA1 }
1888
+
1889
+ function calcBezier(aT, aA1, aA2) { return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT }
1890
+ function getSlope(aT, aA1, aA2) { return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1) }
1891
+
1892
+ function binarySubdivide(aX, aA, aB, mX1, mX2) {
1893
+ var currentX, currentT, i = 0;
1894
+ do {
1895
+ currentT = aA + (aB - aA) / 2.0;
1896
+ currentX = calcBezier(currentT, mX1, mX2) - aX;
1897
+ if (currentX > 0.0) { aB = currentT; } else { aA = currentT; }
1898
+ } while (Math.abs(currentX) > 0.0000001 && ++i < 10);
1899
+ return currentT;
1900
+ }
1901
+
1902
+ function newtonRaphsonIterate(aX, aGuessT, mX1, mX2) {
1903
+ for (var i = 0; i < 4; ++i) {
1904
+ var currentSlope = getSlope(aGuessT, mX1, mX2);
1905
+ if (currentSlope === 0.0) { return aGuessT; }
1906
+ var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
1907
+ aGuessT -= currentX / currentSlope;
1908
+ }
1909
+ return aGuessT;
1910
+ }
1911
+
1912
+ function bezier(mX1, mY1, mX2, mY2) {
1913
+
1914
+ if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) { return; }
1915
+ var sampleValues = new Float32Array(kSplineTableSize);
1916
+
1917
+ if (mX1 !== mY1 || mX2 !== mY2) {
1918
+ for (var i = 0; i < kSplineTableSize; ++i) {
1919
+ sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
1920
+ }
1921
+ }
1922
+
1923
+ function getTForX(aX) {
1924
+
1925
+ var intervalStart = 0;
1926
+ var currentSample = 1;
1927
+ var lastSample = kSplineTableSize - 1;
1928
+
1929
+ for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
1930
+ intervalStart += kSampleStepSize;
1931
+ }
1932
+
1933
+ --currentSample;
1934
+
1935
+ var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
1936
+ var guessForT = intervalStart + dist * kSampleStepSize;
1937
+ var initialSlope = getSlope(guessForT, mX1, mX2);
1938
+
1939
+ if (initialSlope >= 0.001) {
1940
+ return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
1941
+ } else if (initialSlope === 0.0) {
1942
+ return guessForT;
1943
+ } else {
1944
+ return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
1945
+ }
1946
+
1947
+ }
1948
+
1949
+ return function (x) {
1950
+ if (mX1 === mY1 && mX2 === mY2) { return x; }
1951
+ if (x === 0 || x === 1) { return x; }
1952
+ return calcBezier(getTForX(x), mY1, mY2);
1953
+ }
1954
+
1955
+ }
1956
+
1957
+ return bezier;
1958
+
1959
+ })();
1960
+
1961
+ var penner = (function () {
1962
+
1963
+ // Based on jQuery UI's implemenation of easing equations from Robert Penner (http://www.robertpenner.com/easing)
1964
+
1965
+ var eases = { linear: function () { return function (t) { return t; }; } };
1966
+
1967
+ var functionEasings = {
1968
+ Sine: function () { return function (t) { return 1 - Math.cos(t * Math.PI / 2); }; },
1969
+ Circ: function () { return function (t) { return 1 - Math.sqrt(1 - t * t); }; },
1970
+ Back: function () { return function (t) { return t * t * (3 * t - 2); }; },
1971
+ Bounce: function () { return function (t) {
1972
+ var pow2, b = 4;
1973
+ while (t < (( pow2 = Math.pow(2, --b)) - 1) / 11) {}
1974
+ return 1 / Math.pow(4, 3 - b) - 7.5625 * Math.pow(( pow2 * 3 - 2 ) / 22 - t, 2)
1975
+ }; },
1976
+ Elastic: function (amplitude, period) {
1977
+ if ( amplitude === void 0 ) amplitude = 1;
1978
+ if ( period === void 0 ) period = .5;
1979
+
1980
+ var a = minMax(amplitude, 1, 10);
1981
+ var p = minMax(period, .1, 2);
1982
+ return function (t) {
1983
+ return (t === 0 || t === 1) ? t :
1984
+ -a * Math.pow(2, 10 * (t - 1)) * Math.sin((((t - 1) - (p / (Math.PI * 2) * Math.asin(1 / a))) * (Math.PI * 2)) / p);
1985
+ }
1986
+ }
1987
+ };
1988
+
1989
+ var baseEasings = ['Quad', 'Cubic', 'Quart', 'Quint', 'Expo'];
1990
+
1991
+ baseEasings.forEach(function (name, i) {
1992
+ functionEasings[name] = function () { return function (t) { return Math.pow(t, i + 2); }; };
1993
+ });
1994
+
1995
+ Object.keys(functionEasings).forEach(function (name) {
1996
+ var easeIn = functionEasings[name];
1997
+ eases['easeIn' + name] = easeIn;
1998
+ eases['easeOut' + name] = function (a, b) { return function (t) { return 1 - easeIn(a, b)(1 - t); }; };
1999
+ eases['easeInOut' + name] = function (a, b) { return function (t) { return t < 0.5 ? easeIn(a, b)(t * 2) / 2 :
2000
+ 1 - easeIn(a, b)(t * -2 + 2) / 2; }; };
2001
+ eases['easeOutIn' + name] = function (a, b) { return function (t) { return t < 0.5 ? (1 - easeIn(a, b)(1 - t * 2)) / 2 :
2002
+ (easeIn(a, b)(t * 2 - 1) + 1) / 2; }; };
2003
+ });
2004
+
2005
+ return eases;
2006
+
2007
+ })();
2008
+
2009
+ function parseEasings(easing, duration) {
2010
+ if (is$1.fnc(easing)) { return easing; }
2011
+ var name = easing.split('(')[0];
2012
+ var ease = penner[name];
2013
+ var args = parseEasingParameters(easing);
2014
+ switch (name) {
2015
+ case 'spring' : return spring(easing, duration);
2016
+ case 'cubicBezier' : return applyArguments(bezier, args);
2017
+ case 'steps' : return applyArguments(steps, args);
2018
+ default : return applyArguments(ease, args);
2019
+ }
2020
+ }
2021
+
2022
+ // Strings
2023
+
2024
+ function selectString(str) {
2025
+ try {
2026
+ var nodes = document.querySelectorAll(str);
2027
+ return nodes;
2028
+ } catch(e) {
2029
+ return;
2030
+ }
2031
+ }
2032
+
2033
+ // Arrays
2034
+
2035
+ function filterArray(arr, callback) {
2036
+ var len = arr.length;
2037
+ var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
2038
+ var result = [];
2039
+ for (var i = 0; i < len; i++) {
2040
+ if (i in arr) {
2041
+ var val = arr[i];
2042
+ if (callback.call(thisArg, val, i, arr)) {
2043
+ result.push(val);
2044
+ }
2045
+ }
2046
+ }
2047
+ return result;
2048
+ }
2049
+
2050
+ function flattenArray(arr) {
2051
+ return arr.reduce(function (a, b) { return a.concat(is$1.arr(b) ? flattenArray(b) : b); }, []);
2052
+ }
2053
+
2054
+ function toArray(o) {
2055
+ if (is$1.arr(o)) { return o; }
2056
+ if (is$1.str(o)) { o = selectString(o) || o; }
2057
+ if (o instanceof NodeList || o instanceof HTMLCollection) { return [].slice.call(o); }
2058
+ return [o];
2059
+ }
2060
+
2061
+ function arrayContains(arr, val) {
2062
+ return arr.some(function (a) { return a === val; });
2063
+ }
2064
+
2065
+ // Objects
2066
+
2067
+ function cloneObject(o) {
2068
+ var clone = {};
2069
+ for (var p in o) { clone[p] = o[p]; }
2070
+ return clone;
2071
+ }
2072
+
2073
+ function replaceObjectProps(o1, o2) {
2074
+ var o = cloneObject(o1);
2075
+ for (var p in o1) { o[p] = o2.hasOwnProperty(p) ? o2[p] : o1[p]; }
2076
+ return o;
2077
+ }
2078
+
2079
+ function mergeObjects(o1, o2) {
2080
+ var o = cloneObject(o1);
2081
+ for (var p in o2) { o[p] = is$1.und(o1[p]) ? o2[p] : o1[p]; }
2082
+ return o;
2083
+ }
2084
+
2085
+ // Colors
2086
+
2087
+ function rgbToRgba(rgbValue) {
2088
+ var rgb = /rgb\((\d+,\s*[\d]+,\s*[\d]+)\)/g.exec(rgbValue);
2089
+ return rgb ? ("rgba(" + (rgb[1]) + ",1)") : rgbValue;
2090
+ }
2091
+
2092
+ function hexToRgba(hexValue) {
2093
+ var rgx = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
2094
+ var hex = hexValue.replace(rgx, function (m, r, g, b) { return r + r + g + g + b + b; } );
2095
+ var rgb = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
2096
+ var r = parseInt(rgb[1], 16);
2097
+ var g = parseInt(rgb[2], 16);
2098
+ var b = parseInt(rgb[3], 16);
2099
+ return ("rgba(" + r + "," + g + "," + b + ",1)");
2100
+ }
2101
+
2102
+ function hslToRgba(hslValue) {
2103
+ var hsl = /hsl\((\d+),\s*([\d.]+)%,\s*([\d.]+)%\)/g.exec(hslValue) || /hsla\((\d+),\s*([\d.]+)%,\s*([\d.]+)%,\s*([\d.]+)\)/g.exec(hslValue);
2104
+ var h = parseInt(hsl[1], 10) / 360;
2105
+ var s = parseInt(hsl[2], 10) / 100;
2106
+ var l = parseInt(hsl[3], 10) / 100;
2107
+ var a = hsl[4] || 1;
2108
+ function hue2rgb(p, q, t) {
2109
+ if (t < 0) { t += 1; }
2110
+ if (t > 1) { t -= 1; }
2111
+ if (t < 1/6) { return p + (q - p) * 6 * t; }
2112
+ if (t < 1/2) { return q; }
2113
+ if (t < 2/3) { return p + (q - p) * (2/3 - t) * 6; }
2114
+ return p;
2115
+ }
2116
+ var r, g, b;
2117
+ if (s == 0) {
2118
+ r = g = b = l;
2119
+ } else {
2120
+ var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
2121
+ var p = 2 * l - q;
2122
+ r = hue2rgb(p, q, h + 1/3);
2123
+ g = hue2rgb(p, q, h);
2124
+ b = hue2rgb(p, q, h - 1/3);
2125
+ }
2126
+ return ("rgba(" + (r * 255) + "," + (g * 255) + "," + (b * 255) + "," + a + ")");
2127
+ }
2128
+
2129
+ function colorToRgb(val) {
2130
+ if (is$1.rgb(val)) { return rgbToRgba(val); }
2131
+ if (is$1.hex(val)) { return hexToRgba(val); }
2132
+ if (is$1.hsl(val)) { return hslToRgba(val); }
2133
+ }
2134
+
2135
+ // Units
2136
+
2137
+ function getUnit(val) {
2138
+ var split = /[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?(%|px|pt|em|rem|in|cm|mm|ex|ch|pc|vw|vh|vmin|vmax|deg|rad|turn)?$/.exec(val);
2139
+ if (split) { return split[1]; }
2140
+ }
2141
+
2142
+ function getTransformUnit(propName) {
2143
+ if (stringContains(propName, 'translate') || propName === 'perspective') { return 'px'; }
2144
+ if (stringContains(propName, 'rotate') || stringContains(propName, 'skew')) { return 'deg'; }
2145
+ }
2146
+
2147
+ // Values
2148
+
2149
+ function getFunctionValue(val, animatable) {
2150
+ if (!is$1.fnc(val)) { return val; }
2151
+ return val(animatable.target, animatable.id, animatable.total);
2152
+ }
2153
+
2154
+ function getAttribute(el, prop) {
2155
+ return el.getAttribute(prop);
2156
+ }
2157
+
2158
+ function convertPxToUnit(el, value, unit) {
2159
+ var valueUnit = getUnit(value);
2160
+ if (arrayContains([unit, 'deg', 'rad', 'turn'], valueUnit)) { return value; }
2161
+ var cached = cache.CSS[value + unit];
2162
+ if (!is$1.und(cached)) { return cached; }
2163
+ var baseline = 100;
2164
+ var tempEl = document.createElement(el.tagName);
2165
+ var parentEl = (el.parentNode && (el.parentNode !== document)) ? el.parentNode : document.body;
2166
+ parentEl.appendChild(tempEl);
2167
+ tempEl.style.position = 'absolute';
2168
+ tempEl.style.width = baseline + unit;
2169
+ var factor = baseline / tempEl.offsetWidth;
2170
+ parentEl.removeChild(tempEl);
2171
+ var convertedUnit = factor * parseFloat(value);
2172
+ cache.CSS[value + unit] = convertedUnit;
2173
+ return convertedUnit;
2174
+ }
2175
+
2176
+ function getCSSValue(el, prop, unit) {
2177
+ if (prop in el.style) {
2178
+ var uppercasePropName = prop.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
2179
+ var value = el.style[prop] || getComputedStyle(el).getPropertyValue(uppercasePropName) || '0';
2180
+ return unit ? convertPxToUnit(el, value, unit) : value;
2181
+ }
2182
+ }
2183
+
2184
+ function getAnimationType(el, prop) {
2185
+ if (is$1.dom(el) && !is$1.inp(el) && (!is$1.nil(getAttribute(el, prop)) || (is$1.svg(el) && el[prop]))) { return 'attribute'; }
2186
+ if (is$1.dom(el) && arrayContains(validTransforms, prop)) { return 'transform'; }
2187
+ if (is$1.dom(el) && (prop !== 'transform' && getCSSValue(el, prop))) { return 'css'; }
2188
+ if (el[prop] != null) { return 'object'; }
2189
+ }
2190
+
2191
+ function getElementTransforms(el) {
2192
+ if (!is$1.dom(el)) { return; }
2193
+ var str = el.style.transform || '';
2194
+ var reg = /(\w+)\(([^)]*)\)/g;
2195
+ var transforms = new Map();
2196
+ var m; while (m = reg.exec(str)) { transforms.set(m[1], m[2]); }
2197
+ return transforms;
2198
+ }
2199
+
2200
+ function getTransformValue(el, propName, animatable, unit) {
2201
+ var defaultVal = stringContains(propName, 'scale') ? 1 : 0 + getTransformUnit(propName);
2202
+ var value = getElementTransforms(el).get(propName) || defaultVal;
2203
+ if (animatable) {
2204
+ animatable.transforms.list.set(propName, value);
2205
+ animatable.transforms['last'] = propName;
2206
+ }
2207
+ return unit ? convertPxToUnit(el, value, unit) : value;
2208
+ }
2209
+
2210
+ function getOriginalTargetValue(target, propName, unit, animatable) {
2211
+ switch (getAnimationType(target, propName)) {
2212
+ case 'transform': return getTransformValue(target, propName, animatable, unit);
2213
+ case 'css': return getCSSValue(target, propName, unit);
2214
+ case 'attribute': return getAttribute(target, propName);
2215
+ default: return target[propName] || 0;
2216
+ }
2217
+ }
2218
+
2219
+ function getRelativeValue(to, from) {
2220
+ var operator = /^(\*=|\+=|-=)/.exec(to);
2221
+ if (!operator) { return to; }
2222
+ var u = getUnit(to) || 0;
2223
+ var x = parseFloat(from);
2224
+ var y = parseFloat(to.replace(operator[0], ''));
2225
+ switch (operator[0][0]) {
2226
+ case '+': return x + y + u;
2227
+ case '-': return x - y + u;
2228
+ case '*': return x * y + u;
2229
+ }
2230
+ }
2231
+
2232
+ function validateValue(val, unit) {
2233
+ if (is$1.col(val)) { return colorToRgb(val); }
2234
+ if (/\s/g.test(val)) { return val; }
2235
+ var originalUnit = getUnit(val);
2236
+ var unitLess = originalUnit ? val.substr(0, val.length - originalUnit.length) : val;
2237
+ if (unit) { return unitLess + unit; }
2238
+ return unitLess;
2239
+ }
2240
+
2241
+ // getTotalLength() equivalent for circle, rect, polyline, polygon and line shapes
2242
+ // adapted from https://gist.github.com/SebLambla/3e0550c496c236709744
2243
+
2244
+ function getDistance(p1, p2) {
2245
+ return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
2246
+ }
2247
+
2248
+ function getCircleLength(el) {
2249
+ return Math.PI * 2 * getAttribute(el, 'r');
2250
+ }
2251
+
2252
+ function getRectLength(el) {
2253
+ return (getAttribute(el, 'width') * 2) + (getAttribute(el, 'height') * 2);
2254
+ }
2255
+
2256
+ function getLineLength(el) {
2257
+ return getDistance(
2258
+ {x: getAttribute(el, 'x1'), y: getAttribute(el, 'y1')},
2259
+ {x: getAttribute(el, 'x2'), y: getAttribute(el, 'y2')}
2260
+ );
2261
+ }
2262
+
2263
+ function getPolylineLength(el) {
2264
+ var points = el.points;
2265
+ var totalLength = 0;
2266
+ var previousPos;
2267
+ for (var i = 0 ; i < points.numberOfItems; i++) {
2268
+ var currentPos = points.getItem(i);
2269
+ if (i > 0) { totalLength += getDistance(previousPos, currentPos); }
2270
+ previousPos = currentPos;
2271
+ }
2272
+ return totalLength;
2273
+ }
2274
+
2275
+ function getPolygonLength(el) {
2276
+ var points = el.points;
2277
+ return getPolylineLength(el) + getDistance(points.getItem(points.numberOfItems - 1), points.getItem(0));
2278
+ }
2279
+
2280
+ // Path animation
2281
+
2282
+ function getTotalLength(el) {
2283
+ if (el.getTotalLength) { return el.getTotalLength(); }
2284
+ switch(el.tagName.toLowerCase()) {
2285
+ case 'circle': return getCircleLength(el);
2286
+ case 'rect': return getRectLength(el);
2287
+ case 'line': return getLineLength(el);
2288
+ case 'polyline': return getPolylineLength(el);
2289
+ case 'polygon': return getPolygonLength(el);
2290
+ }
2291
+ }
2292
+
2293
+ function setDashoffset(el) {
2294
+ var pathLength = getTotalLength(el);
2295
+ el.setAttribute('stroke-dasharray', pathLength);
2296
+ return pathLength;
2297
+ }
2298
+
2299
+ // Motion path
2300
+
2301
+ function getParentSvgEl(el) {
2302
+ var parentEl = el.parentNode;
2303
+ while (is$1.svg(parentEl)) {
2304
+ if (!is$1.svg(parentEl.parentNode)) { break; }
2305
+ parentEl = parentEl.parentNode;
2306
+ }
2307
+ return parentEl;
2308
+ }
2309
+
2310
+ function getParentSvg(pathEl, svgData) {
2311
+ var svg = svgData || {};
2312
+ var parentSvgEl = svg.el || getParentSvgEl(pathEl);
2313
+ var rect = parentSvgEl.getBoundingClientRect();
2314
+ var viewBoxAttr = getAttribute(parentSvgEl, 'viewBox');
2315
+ var width = rect.width;
2316
+ var height = rect.height;
2317
+ var viewBox = svg.viewBox || (viewBoxAttr ? viewBoxAttr.split(' ') : [0, 0, width, height]);
2318
+ return {
2319
+ el: parentSvgEl,
2320
+ viewBox: viewBox,
2321
+ x: viewBox[0] / 1,
2322
+ y: viewBox[1] / 1,
2323
+ w: width,
2324
+ h: height,
2325
+ vW: viewBox[2],
2326
+ vH: viewBox[3]
2327
+ }
2328
+ }
2329
+
2330
+ function getPath(path, percent) {
2331
+ var pathEl = is$1.str(path) ? selectString(path)[0] : path;
2332
+ var p = percent || 100;
2333
+ return function(property) {
2334
+ return {
2335
+ property: property,
2336
+ el: pathEl,
2337
+ svg: getParentSvg(pathEl),
2338
+ totalLength: getTotalLength(pathEl) * (p / 100)
2339
+ }
2340
+ }
2341
+ }
2342
+
2343
+ function getPathProgress(path, progress, isPathTargetInsideSVG) {
2344
+ function point(offset) {
2345
+ if ( offset === void 0 ) offset = 0;
2346
+
2347
+ var l = progress + offset >= 1 ? progress + offset : 0;
2348
+ return path.el.getPointAtLength(l);
2349
+ }
2350
+ var svg = getParentSvg(path.el, path.svg);
2351
+ var p = point();
2352
+ var p0 = point(-1);
2353
+ var p1 = point(+1);
2354
+ var scaleX = isPathTargetInsideSVG ? 1 : svg.w / svg.vW;
2355
+ var scaleY = isPathTargetInsideSVG ? 1 : svg.h / svg.vH;
2356
+ switch (path.property) {
2357
+ case 'x': return (p.x - svg.x) * scaleX;
2358
+ case 'y': return (p.y - svg.y) * scaleY;
2359
+ case 'angle': return Math.atan2(p1.y - p0.y, p1.x - p0.x) * 180 / Math.PI;
2360
+ }
2361
+ }
2362
+
2363
+ // Decompose value
2364
+
2365
+ function decomposeValue(val, unit) {
2366
+ // const rgx = /-?\d*\.?\d+/g; // handles basic numbers
2367
+ // const rgx = /[+-]?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g; // handles exponents notation
2368
+ var rgx = /[+-]?\d*\.?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?/g; // handles exponents notation
2369
+ var value = validateValue((is$1.pth(val) ? val.totalLength : val), unit) + '';
2370
+ return {
2371
+ original: value,
2372
+ numbers: value.match(rgx) ? value.match(rgx).map(Number) : [0],
2373
+ strings: (is$1.str(val) || unit) ? value.split(rgx) : []
2374
+ }
2375
+ }
2376
+
2377
+ // Animatables
2378
+
2379
+ function parseTargets(targets) {
2380
+ var targetsArray = targets ? (flattenArray(is$1.arr(targets) ? targets.map(toArray) : toArray(targets))) : [];
2381
+ return filterArray(targetsArray, function (item, pos, self) { return self.indexOf(item) === pos; });
2382
+ }
2383
+
2384
+ function getAnimatables(targets) {
2385
+ var parsed = parseTargets(targets);
2386
+ return parsed.map(function (t, i) {
2387
+ return {target: t, id: i, total: parsed.length, transforms: { list: getElementTransforms(t) } };
2388
+ });
2389
+ }
2390
+
2391
+ // Properties
2392
+
2393
+ function normalizePropertyTweens(prop, tweenSettings) {
2394
+ var settings = cloneObject(tweenSettings);
2395
+ // Override duration if easing is a spring
2396
+ if (/^spring/.test(settings.easing)) { settings.duration = spring(settings.easing); }
2397
+ if (is$1.arr(prop)) {
2398
+ var l = prop.length;
2399
+ var isFromTo = (l === 2 && !is$1.obj(prop[0]));
2400
+ if (!isFromTo) {
2401
+ // Duration divided by the number of tweens
2402
+ if (!is$1.fnc(tweenSettings.duration)) { settings.duration = tweenSettings.duration / l; }
2403
+ } else {
2404
+ // Transform [from, to] values shorthand to a valid tween value
2405
+ prop = {value: prop};
2406
+ }
2407
+ }
2408
+ var propArray = is$1.arr(prop) ? prop : [prop];
2409
+ return propArray.map(function (v, i) {
2410
+ var obj = (is$1.obj(v) && !is$1.pth(v)) ? v : {value: v};
2411
+ // Default delay value should only be applied to the first tween
2412
+ if (is$1.und(obj.delay)) { obj.delay = !i ? tweenSettings.delay : 0; }
2413
+ // Default endDelay value should only be applied to the last tween
2414
+ if (is$1.und(obj.endDelay)) { obj.endDelay = i === propArray.length - 1 ? tweenSettings.endDelay : 0; }
2415
+ return obj;
2416
+ }).map(function (k) { return mergeObjects(k, settings); });
2417
+ }
2418
+
2419
+
2420
+ function flattenKeyframes(keyframes) {
2421
+ var propertyNames = filterArray(flattenArray(keyframes.map(function (key) { return Object.keys(key); })), function (p) { return is$1.key(p); })
2422
+ .reduce(function (a,b) { if (a.indexOf(b) < 0) { a.push(b); } return a; }, []);
2423
+ var properties = {};
2424
+ var loop = function ( i ) {
2425
+ var propName = propertyNames[i];
2426
+ properties[propName] = keyframes.map(function (key) {
2427
+ var newKey = {};
2428
+ for (var p in key) {
2429
+ if (is$1.key(p)) {
2430
+ if (p == propName) { newKey.value = key[p]; }
2431
+ } else {
2432
+ newKey[p] = key[p];
2433
+ }
2434
+ }
2435
+ return newKey;
2436
+ });
2437
+ };
2438
+
2439
+ for (var i = 0; i < propertyNames.length; i++) loop( i );
2440
+ return properties;
2441
+ }
2442
+
2443
+ function getProperties(tweenSettings, params) {
2444
+ var properties = [];
2445
+ var keyframes = params.keyframes;
2446
+ if (keyframes) { params = mergeObjects(flattenKeyframes(keyframes), params); }
2447
+ for (var p in params) {
2448
+ if (is$1.key(p)) {
2449
+ properties.push({
2450
+ name: p,
2451
+ tweens: normalizePropertyTweens(params[p], tweenSettings)
2452
+ });
2453
+ }
2454
+ }
2455
+ return properties;
2456
+ }
2457
+
2458
+ // Tweens
2459
+
2460
+ function normalizeTweenValues(tween, animatable) {
2461
+ var t = {};
2462
+ for (var p in tween) {
2463
+ var value = getFunctionValue(tween[p], animatable);
2464
+ if (is$1.arr(value)) {
2465
+ value = value.map(function (v) { return getFunctionValue(v, animatable); });
2466
+ if (value.length === 1) { value = value[0]; }
2467
+ }
2468
+ t[p] = value;
2469
+ }
2470
+ t.duration = parseFloat(t.duration);
2471
+ t.delay = parseFloat(t.delay);
2472
+ return t;
2473
+ }
2474
+
2475
+ function normalizeTweens(prop, animatable) {
2476
+ var previousTween;
2477
+ return prop.tweens.map(function (t) {
2478
+ var tween = normalizeTweenValues(t, animatable);
2479
+ var tweenValue = tween.value;
2480
+ var to = is$1.arr(tweenValue) ? tweenValue[1] : tweenValue;
2481
+ var toUnit = getUnit(to);
2482
+ var originalValue = getOriginalTargetValue(animatable.target, prop.name, toUnit, animatable);
2483
+ var previousValue = previousTween ? previousTween.to.original : originalValue;
2484
+ var from = is$1.arr(tweenValue) ? tweenValue[0] : previousValue;
2485
+ var fromUnit = getUnit(from) || getUnit(originalValue);
2486
+ var unit = toUnit || fromUnit;
2487
+ if (is$1.und(to)) { to = previousValue; }
2488
+ tween.from = decomposeValue(from, unit);
2489
+ tween.to = decomposeValue(getRelativeValue(to, from), unit);
2490
+ tween.start = previousTween ? previousTween.end : 0;
2491
+ tween.end = tween.start + tween.delay + tween.duration + tween.endDelay;
2492
+ tween.easing = parseEasings(tween.easing, tween.duration);
2493
+ tween.isPath = is$1.pth(tweenValue);
2494
+ tween.isPathTargetInsideSVG = tween.isPath && is$1.svg(animatable.target);
2495
+ tween.isColor = is$1.col(tween.from.original);
2496
+ if (tween.isColor) { tween.round = 1; }
2497
+ previousTween = tween;
2498
+ return tween;
2499
+ });
2500
+ }
2501
+
2502
+ // Tween progress
2503
+
2504
+ var setProgressValue = {
2505
+ css: function (t, p, v) { return t.style[p] = v; },
2506
+ attribute: function (t, p, v) { return t.setAttribute(p, v); },
2507
+ object: function (t, p, v) { return t[p] = v; },
2508
+ transform: function (t, p, v, transforms, manual) {
2509
+ transforms.list.set(p, v);
2510
+ if (p === transforms.last || manual) {
2511
+ var str = '';
2512
+ transforms.list.forEach(function (value, prop) { str += prop + "(" + value + ") "; });
2513
+ t.style.transform = str;
2514
+ }
2515
+ }
2516
+ };
2517
+
2518
+ // Set Value helper
2519
+
2520
+ function setTargetsValue(targets, properties) {
2521
+ var animatables = getAnimatables(targets);
2522
+ animatables.forEach(function (animatable) {
2523
+ for (var property in properties) {
2524
+ var value = getFunctionValue(properties[property], animatable);
2525
+ var target = animatable.target;
2526
+ var valueUnit = getUnit(value);
2527
+ var originalValue = getOriginalTargetValue(target, property, valueUnit, animatable);
2528
+ var unit = valueUnit || getUnit(originalValue);
2529
+ var to = getRelativeValue(validateValue(value, unit), originalValue);
2530
+ var animType = getAnimationType(target, property);
2531
+ setProgressValue[animType](target, property, to, animatable.transforms, true);
2532
+ }
2533
+ });
2534
+ }
2535
+
2536
+ // Animations
2537
+
2538
+ function createAnimation(animatable, prop) {
2539
+ var animType = getAnimationType(animatable.target, prop.name);
2540
+ if (animType) {
2541
+ var tweens = normalizeTweens(prop, animatable);
2542
+ var lastTween = tweens[tweens.length - 1];
2543
+ return {
2544
+ type: animType,
2545
+ property: prop.name,
2546
+ animatable: animatable,
2547
+ tweens: tweens,
2548
+ duration: lastTween.end,
2549
+ delay: tweens[0].delay,
2550
+ endDelay: lastTween.endDelay
2551
+ }
2552
+ }
2553
+ }
2554
+
2555
+ function getAnimations(animatables, properties) {
2556
+ return filterArray(flattenArray(animatables.map(function (animatable) {
2557
+ return properties.map(function (prop) {
2558
+ return createAnimation(animatable, prop);
2559
+ });
2560
+ })), function (a) { return !is$1.und(a); });
2561
+ }
2562
+
2563
+ // Create Instance
2564
+
2565
+ function getInstanceTimings(animations, tweenSettings) {
2566
+ var animLength = animations.length;
2567
+ var getTlOffset = function (anim) { return anim.timelineOffset ? anim.timelineOffset : 0; };
2568
+ var timings = {};
2569
+ timings.duration = animLength ? Math.max.apply(Math, animations.map(function (anim) { return getTlOffset(anim) + anim.duration; })) : tweenSettings.duration;
2570
+ timings.delay = animLength ? Math.min.apply(Math, animations.map(function (anim) { return getTlOffset(anim) + anim.delay; })) : tweenSettings.delay;
2571
+ timings.endDelay = animLength ? timings.duration - Math.max.apply(Math, animations.map(function (anim) { return getTlOffset(anim) + anim.duration - anim.endDelay; })) : tweenSettings.endDelay;
2572
+ return timings;
2573
+ }
2574
+
2575
+ var instanceID = 0;
2576
+
2577
+ function createNewInstance(params) {
2578
+ var instanceSettings = replaceObjectProps(defaultInstanceSettings, params);
2579
+ var tweenSettings = replaceObjectProps(defaultTweenSettings, params);
2580
+ var properties = getProperties(tweenSettings, params);
2581
+ var animatables = getAnimatables(params.targets);
2582
+ var animations = getAnimations(animatables, properties);
2583
+ var timings = getInstanceTimings(animations, tweenSettings);
2584
+ var id = instanceID;
2585
+ instanceID++;
2586
+ return mergeObjects(instanceSettings, {
2587
+ id: id,
2588
+ children: [],
2589
+ animatables: animatables,
2590
+ animations: animations,
2591
+ duration: timings.duration,
2592
+ delay: timings.delay,
2593
+ endDelay: timings.endDelay
2594
+ });
2595
+ }
2596
+
2597
+ // Core
2598
+
2599
+ var activeInstances = [];
2600
+
2601
+ var engine = (function () {
2602
+ var raf;
2603
+
2604
+ function play() {
2605
+ if (!raf && (!isDocumentHidden() || !anime.suspendWhenDocumentHidden) && activeInstances.length > 0) {
2606
+ raf = requestAnimationFrame(step);
2607
+ }
2608
+ }
2609
+ function step(t) {
2610
+ // memo on algorithm issue:
2611
+ // dangerous iteration over mutable `activeInstances`
2612
+ // (that collection may be updated from within callbacks of `tick`-ed animation instances)
2613
+ var activeInstancesLength = activeInstances.length;
2614
+ var i = 0;
2615
+ while (i < activeInstancesLength) {
2616
+ var activeInstance = activeInstances[i];
2617
+ if (!activeInstance.paused) {
2618
+ activeInstance.tick(t);
2619
+ i++;
2620
+ } else {
2621
+ activeInstances.splice(i, 1);
2622
+ activeInstancesLength--;
2623
+ }
2624
+ }
2625
+ raf = i > 0 ? requestAnimationFrame(step) : undefined;
2626
+ }
2627
+
2628
+ function handleVisibilityChange() {
2629
+ if (!anime.suspendWhenDocumentHidden) { return; }
2630
+
2631
+ if (isDocumentHidden()) {
2632
+ // suspend ticks
2633
+ raf = cancelAnimationFrame(raf);
2634
+ } else { // is back to active tab
2635
+ // first adjust animations to consider the time that ticks were suspended
2636
+ activeInstances.forEach(
2637
+ function (instance) { return instance ._onDocumentVisibility(); }
2638
+ );
2639
+ engine();
2640
+ }
2641
+ }
2642
+ if (typeof document !== 'undefined') {
2643
+ document.addEventListener('visibilitychange', handleVisibilityChange);
2644
+ }
2645
+
2646
+ return play;
2647
+ })();
2648
+
2649
+ function isDocumentHidden() {
2650
+ return !!document && document.hidden;
2651
+ }
2652
+
2653
+ // Public Instance
2654
+
2655
+ function anime(params) {
2656
+ if ( params === void 0 ) params = {};
2657
+
2658
+
2659
+ var startTime = 0, lastTime = 0, now = 0;
2660
+ var children, childrenLength = 0;
2661
+ var resolve = null;
2662
+
2663
+ function makePromise(instance) {
2664
+ var promise = window.Promise && new Promise(function (_resolve) { return resolve = _resolve; });
2665
+ instance.finished = promise;
2666
+ return promise;
2667
+ }
2668
+
2669
+ var instance = createNewInstance(params);
2670
+ makePromise(instance);
2671
+
2672
+ function toggleInstanceDirection() {
2673
+ var direction = instance.direction;
2674
+ if (direction !== 'alternate') {
2675
+ instance.direction = direction !== 'normal' ? 'normal' : 'reverse';
2676
+ }
2677
+ instance.reversed = !instance.reversed;
2678
+ children.forEach(function (child) { return child.reversed = instance.reversed; });
2679
+ }
2680
+
2681
+ function adjustTime(time) {
2682
+ return instance.reversed ? instance.duration - time : time;
2683
+ }
2684
+
2685
+ function resetTime() {
2686
+ startTime = 0;
2687
+ lastTime = adjustTime(instance.currentTime) * (1 / anime.speed);
2688
+ }
2689
+
2690
+ function seekChild(time, child) {
2691
+ if (child) { child.seek(time - child.timelineOffset); }
2692
+ }
2693
+
2694
+ function syncInstanceChildren(time) {
2695
+ if (!instance.reversePlayback) {
2696
+ for (var i = 0; i < childrenLength; i++) { seekChild(time, children[i]); }
2697
+ } else {
2698
+ for (var i$1 = childrenLength; i$1--;) { seekChild(time, children[i$1]); }
2699
+ }
2700
+ }
2701
+
2702
+ function setAnimationsProgress(insTime) {
2703
+ var i = 0;
2704
+ var animations = instance.animations;
2705
+ var animationsLength = animations.length;
2706
+ while (i < animationsLength) {
2707
+ var anim = animations[i];
2708
+ var animatable = anim.animatable;
2709
+ var tweens = anim.tweens;
2710
+ var tweenLength = tweens.length - 1;
2711
+ var tween = tweens[tweenLength];
2712
+ // Only check for keyframes if there is more than one tween
2713
+ if (tweenLength) { tween = filterArray(tweens, function (t) { return (insTime < t.end); })[0] || tween; }
2714
+ var elapsed = minMax(insTime - tween.start - tween.delay, 0, tween.duration) / tween.duration;
2715
+ var eased = isNaN(elapsed) ? 1 : tween.easing(elapsed);
2716
+ var strings = tween.to.strings;
2717
+ var round = tween.round;
2718
+ var numbers = [];
2719
+ var toNumbersLength = tween.to.numbers.length;
2720
+ var progress = (void 0);
2721
+ for (var n = 0; n < toNumbersLength; n++) {
2722
+ var value = (void 0);
2723
+ var toNumber = tween.to.numbers[n];
2724
+ var fromNumber = tween.from.numbers[n] || 0;
2725
+ if (!tween.isPath) {
2726
+ value = fromNumber + (eased * (toNumber - fromNumber));
2727
+ } else {
2728
+ value = getPathProgress(tween.value, eased * toNumber, tween.isPathTargetInsideSVG);
2729
+ }
2730
+ if (round) {
2731
+ if (!(tween.isColor && n > 2)) {
2732
+ value = Math.round(value * round) / round;
2733
+ }
2734
+ }
2735
+ numbers.push(value);
2736
+ }
2737
+ // Manual Array.reduce for better performances
2738
+ var stringsLength = strings.length;
2739
+ if (!stringsLength) {
2740
+ progress = numbers[0];
2741
+ } else {
2742
+ progress = strings[0];
2743
+ for (var s = 0; s < stringsLength; s++) {
2744
+ var b = strings[s + 1];
2745
+ var n$1 = numbers[s];
2746
+ if (!isNaN(n$1)) {
2747
+ if (!b) {
2748
+ progress += n$1 + ' ';
2749
+ } else {
2750
+ progress += n$1 + b;
2751
+ }
2752
+ }
2753
+ }
2754
+ }
2755
+ setProgressValue[anim.type](animatable.target, anim.property, progress, animatable.transforms);
2756
+ anim.currentValue = progress;
2757
+ i++;
2758
+ }
2759
+ }
2760
+
2761
+ function setCallback(cb) {
2762
+ if (instance[cb] && !instance.passThrough) { instance[cb](instance); }
2763
+ }
2764
+
2765
+ function countIteration() {
2766
+ if (instance.remaining && instance.remaining !== true) {
2767
+ instance.remaining--;
2768
+ }
2769
+ }
2770
+
2771
+ function setInstanceProgress(engineTime) {
2772
+ var insDuration = instance.duration;
2773
+ var insDelay = instance.delay;
2774
+ var insEndDelay = insDuration - instance.endDelay;
2775
+ var insTime = adjustTime(engineTime);
2776
+ instance.progress = minMax((insTime / insDuration) * 100, 0, 100);
2777
+ instance.reversePlayback = insTime < instance.currentTime;
2778
+ if (children) { syncInstanceChildren(insTime); }
2779
+ if (!instance.began && instance.currentTime > 0) {
2780
+ instance.began = true;
2781
+ setCallback('begin');
2782
+ }
2783
+ if (!instance.loopBegan && instance.currentTime > 0) {
2784
+ instance.loopBegan = true;
2785
+ setCallback('loopBegin');
2786
+ }
2787
+ if (insTime <= insDelay && instance.currentTime !== 0) {
2788
+ setAnimationsProgress(0);
2789
+ }
2790
+ if ((insTime >= insEndDelay && instance.currentTime !== insDuration) || !insDuration) {
2791
+ setAnimationsProgress(insDuration);
2792
+ }
2793
+ if (insTime > insDelay && insTime < insEndDelay) {
2794
+ if (!instance.changeBegan) {
2795
+ instance.changeBegan = true;
2796
+ instance.changeCompleted = false;
2797
+ setCallback('changeBegin');
2798
+ }
2799
+ setCallback('change');
2800
+ setAnimationsProgress(insTime);
2801
+ } else {
2802
+ if (instance.changeBegan) {
2803
+ instance.changeCompleted = true;
2804
+ instance.changeBegan = false;
2805
+ setCallback('changeComplete');
2806
+ }
2807
+ }
2808
+ instance.currentTime = minMax(insTime, 0, insDuration);
2809
+ if (instance.began) { setCallback('update'); }
2810
+ if (engineTime >= insDuration) {
2811
+ lastTime = 0;
2812
+ countIteration();
2813
+ if (!instance.remaining) {
2814
+ instance.paused = true;
2815
+ if (!instance.completed) {
2816
+ instance.completed = true;
2817
+ setCallback('loopComplete');
2818
+ setCallback('complete');
2819
+ if (!instance.passThrough && 'Promise' in window) {
2820
+ resolve();
2821
+ makePromise(instance);
2822
+ }
2823
+ }
2824
+ } else {
2825
+ startTime = now;
2826
+ setCallback('loopComplete');
2827
+ instance.loopBegan = false;
2828
+ if (instance.direction === 'alternate') {
2829
+ toggleInstanceDirection();
2830
+ }
2831
+ }
2832
+ }
2833
+ }
2834
+
2835
+ instance.reset = function() {
2836
+ var direction = instance.direction;
2837
+ instance.passThrough = false;
2838
+ instance.currentTime = 0;
2839
+ instance.progress = 0;
2840
+ instance.paused = true;
2841
+ instance.began = false;
2842
+ instance.loopBegan = false;
2843
+ instance.changeBegan = false;
2844
+ instance.completed = false;
2845
+ instance.changeCompleted = false;
2846
+ instance.reversePlayback = false;
2847
+ instance.reversed = direction === 'reverse';
2848
+ instance.remaining = instance.loop;
2849
+ children = instance.children;
2850
+ childrenLength = children.length;
2851
+ for (var i = childrenLength; i--;) { instance.children[i].reset(); }
2852
+ if (instance.reversed && instance.loop !== true || (direction === 'alternate' && instance.loop === 1)) { instance.remaining++; }
2853
+ setAnimationsProgress(instance.reversed ? instance.duration : 0);
2854
+ };
2855
+
2856
+ // internal method (for engine) to adjust animation timings before restoring engine ticks (rAF)
2857
+ instance._onDocumentVisibility = resetTime;
2858
+
2859
+ // Set Value helper
2860
+
2861
+ instance.set = function(targets, properties) {
2862
+ setTargetsValue(targets, properties);
2863
+ return instance;
2864
+ };
2865
+
2866
+ instance.tick = function(t) {
2867
+ now = t;
2868
+ if (!startTime) { startTime = now; }
2869
+ setInstanceProgress((now + (lastTime - startTime)) * anime.speed);
2870
+ };
2871
+
2872
+ instance.seek = function(time) {
2873
+ setInstanceProgress(adjustTime(time));
2874
+ };
2875
+
2876
+ instance.pause = function() {
2877
+ instance.paused = true;
2878
+ resetTime();
2879
+ };
2880
+
2881
+ instance.play = function() {
2882
+ if (!instance.paused) { return; }
2883
+ if (instance.completed) { instance.reset(); }
2884
+ instance.paused = false;
2885
+ activeInstances.push(instance);
2886
+ resetTime();
2887
+ engine();
2888
+ };
2889
+
2890
+ instance.reverse = function() {
2891
+ toggleInstanceDirection();
2892
+ instance.completed = instance.reversed ? false : true;
2893
+ resetTime();
2894
+ };
2895
+
2896
+ instance.restart = function() {
2897
+ instance.reset();
2898
+ instance.play();
2899
+ };
2900
+
2901
+ instance.remove = function(targets) {
2902
+ var targetsArray = parseTargets(targets);
2903
+ removeTargetsFromInstance(targetsArray, instance);
2904
+ };
2905
+
2906
+ instance.reset();
2907
+
2908
+ if (instance.autoplay) { instance.play(); }
2909
+
2910
+ return instance;
2911
+
2912
+ }
2913
+
2914
+ // Remove targets from animation
2915
+
2916
+ function removeTargetsFromAnimations(targetsArray, animations) {
2917
+ for (var a = animations.length; a--;) {
2918
+ if (arrayContains(targetsArray, animations[a].animatable.target)) {
2919
+ animations.splice(a, 1);
2920
+ }
2921
+ }
2922
+ }
2923
+
2924
+ function removeTargetsFromInstance(targetsArray, instance) {
2925
+ var animations = instance.animations;
2926
+ var children = instance.children;
2927
+ removeTargetsFromAnimations(targetsArray, animations);
2928
+ for (var c = children.length; c--;) {
2929
+ var child = children[c];
2930
+ var childAnimations = child.animations;
2931
+ removeTargetsFromAnimations(targetsArray, childAnimations);
2932
+ if (!childAnimations.length && !child.children.length) { children.splice(c, 1); }
2933
+ }
2934
+ if (!animations.length && !children.length) { instance.pause(); }
2935
+ }
2936
+
2937
+ function removeTargetsFromActiveInstances(targets) {
2938
+ var targetsArray = parseTargets(targets);
2939
+ for (var i = activeInstances.length; i--;) {
2940
+ var instance = activeInstances[i];
2941
+ removeTargetsFromInstance(targetsArray, instance);
2942
+ }
2943
+ }
2944
+
2945
+ // Stagger helpers
2946
+
2947
+ function stagger(val, params) {
2948
+ if ( params === void 0 ) params = {};
2949
+
2950
+ var direction = params.direction || 'normal';
2951
+ var easing = params.easing ? parseEasings(params.easing) : null;
2952
+ var grid = params.grid;
2953
+ var axis = params.axis;
2954
+ var fromIndex = params.from || 0;
2955
+ var fromFirst = fromIndex === 'first';
2956
+ var fromCenter = fromIndex === 'center';
2957
+ var fromLast = fromIndex === 'last';
2958
+ var isRange = is$1.arr(val);
2959
+ var val1 = isRange ? parseFloat(val[0]) : parseFloat(val);
2960
+ var val2 = isRange ? parseFloat(val[1]) : 0;
2961
+ var unit = getUnit(isRange ? val[1] : val) || 0;
2962
+ var start = params.start || 0 + (isRange ? val1 : 0);
2963
+ var values = [];
2964
+ var maxValue = 0;
2965
+ return function (el, i, t) {
2966
+ if (fromFirst) { fromIndex = 0; }
2967
+ if (fromCenter) { fromIndex = (t - 1) / 2; }
2968
+ if (fromLast) { fromIndex = t - 1; }
2969
+ if (!values.length) {
2970
+ for (var index = 0; index < t; index++) {
2971
+ if (!grid) {
2972
+ values.push(Math.abs(fromIndex - index));
2973
+ } else {
2974
+ var fromX = !fromCenter ? fromIndex%grid[0] : (grid[0]-1)/2;
2975
+ var fromY = !fromCenter ? Math.floor(fromIndex/grid[0]) : (grid[1]-1)/2;
2976
+ var toX = index%grid[0];
2977
+ var toY = Math.floor(index/grid[0]);
2978
+ var distanceX = fromX - toX;
2979
+ var distanceY = fromY - toY;
2980
+ var value = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
2981
+ if (axis === 'x') { value = -distanceX; }
2982
+ if (axis === 'y') { value = -distanceY; }
2983
+ values.push(value);
2984
+ }
2985
+ maxValue = Math.max.apply(Math, values);
2986
+ }
2987
+ if (easing) { values = values.map(function (val) { return easing(val / maxValue) * maxValue; }); }
2988
+ if (direction === 'reverse') { values = values.map(function (val) { return axis ? (val < 0) ? val * -1 : -val : Math.abs(maxValue - val); }); }
2989
+ }
2990
+ var spacing = isRange ? (val2 - val1) / maxValue : val1;
2991
+ return start + (spacing * (Math.round(values[i] * 100) / 100)) + unit;
2992
+ }
2993
+ }
2994
+
2995
+ // Timeline
2996
+
2997
+ function timeline(params) {
2998
+ if ( params === void 0 ) params = {};
2999
+
3000
+ var tl = anime(params);
3001
+ tl.duration = 0;
3002
+ tl.add = function(instanceParams, timelineOffset) {
3003
+ var tlIndex = activeInstances.indexOf(tl);
3004
+ var children = tl.children;
3005
+ if (tlIndex > -1) { activeInstances.splice(tlIndex, 1); }
3006
+ function passThrough(ins) { ins.passThrough = true; }
3007
+ for (var i = 0; i < children.length; i++) { passThrough(children[i]); }
3008
+ var insParams = mergeObjects(instanceParams, replaceObjectProps(defaultTweenSettings, params));
3009
+ insParams.targets = insParams.targets || params.targets;
3010
+ var tlDuration = tl.duration;
3011
+ insParams.autoplay = false;
3012
+ insParams.direction = tl.direction;
3013
+ insParams.timelineOffset = is$1.und(timelineOffset) ? tlDuration : getRelativeValue(timelineOffset, tlDuration);
3014
+ passThrough(tl);
3015
+ tl.seek(insParams.timelineOffset);
3016
+ var ins = anime(insParams);
3017
+ passThrough(ins);
3018
+ children.push(ins);
3019
+ var timings = getInstanceTimings(children, params);
3020
+ tl.delay = timings.delay;
3021
+ tl.endDelay = timings.endDelay;
3022
+ tl.duration = timings.duration;
3023
+ tl.seek(0);
3024
+ tl.reset();
3025
+ if (tl.autoplay) { tl.play(); }
3026
+ return tl;
3027
+ };
3028
+ return tl;
3029
+ }
3030
+
3031
+ anime.version = '3.2.1';
3032
+ anime.speed = 1;
3033
+ // TODO:#review: naming, documentation
3034
+ anime.suspendWhenDocumentHidden = true;
3035
+ anime.running = activeInstances;
3036
+ anime.remove = removeTargetsFromActiveInstances;
3037
+ anime.get = getOriginalTargetValue;
3038
+ anime.set = setTargetsValue;
3039
+ anime.convertPx = convertPxToUnit;
3040
+ anime.path = getPath;
3041
+ anime.setDashoffset = setDashoffset;
3042
+ anime.stagger = stagger;
3043
+ anime.timeline = timeline;
3044
+ anime.easing = parseEasings;
3045
+ anime.penner = penner;
3046
+ anime.random = function (min, max) { return Math.floor(Math.random() * (max - min + 1)) + min; };
3047
+
3048
+ const facebook = `<!-- Generated by IcoMoon.io -->
3049
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
3050
+ <title>facebook</title>
3051
+ <path d="M19 32h-6c-0.552 0-1-0.448-1-1v0-13h-3c-0.552 0-1-0.448-1-1v0-5c0-0.552 0.448-1 1-1v0h3v-4c0-3.866 3.134-7 7-7v0h4c0.552 0 1 0.448 1 1v0 5c0 0.552-0.448 1-1 1v0h-2c-0.552 0-1 0.448-1 1v0 3h5c0.552 0 1 0.448 1 1 0 0.134-0.026 0.262-0.074 0.379l0.002-0.007-2 5c-0.152 0.371-0.51 0.628-0.928 0.628h-3v13c0 0.552-0.448 1-1 1v0zM14 30h4v-13c0-0.552 0.448-1 1-1v0h3.324l1.2-3h-4.524c-0.552 0-1-0.448-1-1v0-4c0-1.657 1.343-3 3-3v0h1v-3h-3c-2.761 0-5 2.239-5 5v0 5c0 0.552-0.448 1-1 1v0h-3v3h3c0.552 0 1 0.448 1 1v0z"></path>
3052
+ </svg>
3053
+ `;
3054
+
3055
+ const twitter = `<!-- Generated by IcoMoon.io -->
3056
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
3057
+ <title>twitter</title>
3058
+ <path d="M10.436 30c-0.012 0-0.026 0-0.041 0-3.691 0-7.129-1.088-10.009-2.961l0.071 0.043c-0.279-0.181-0.46-0.49-0.46-0.842 0-0.123 0.022-0.24 0.063-0.349l-0.002 0.007c0.148-0.387 0.516-0.657 0.948-0.657 0.042 0 0.083 0.003 0.123 0.007l-0.005-0c0.399 0.049 0.86 0.077 1.328 0.077 1.836 0 3.57-0.432 5.108-1.199l-0.066 0.030c-1.941-0.823-3.42-2.412-4.079-4.377l-0.015-0.051c-0.033-0.095-0.053-0.205-0.053-0.32 0-0.255 0.096-0.488 0.253-0.665l-0.001 0.001 0.062-0.062c-1.511-1.323-2.46-3.254-2.462-5.408v-0c0-0 0-0.001 0-0.001 0-0.374 0.194-0.703 0.488-0.89l0.004-0.003c0.115-0.070 0.25-0.121 0.393-0.145l0.007-0.001c-0.534-0.978-0.848-2.141-0.848-3.379 0-1.329 0.362-2.574 0.994-3.641l-0.018 0.033c0.176-0.301 0.498-0.501 0.866-0.501 0.312 0 0.591 0.143 0.774 0.367l0.001 0.002c2.627 3.213 6.397 5.405 10.682 5.953l0.082 0.009c0-0.098 0-0.2 0-0.302 0-0.001 0-0.002 0-0.002 0-3.949 3.201-7.15 7.15-7.15 1.852 0 3.54 0.704 4.81 1.86l-0.006-0.005c1.165-0.288 2.19-0.719 3.127-1.282l-0.051 0.028c0.146-0.088 0.323-0.141 0.512-0.141 0.552 0 1 0.448 1 1 0 0.109-0.017 0.214-0.050 0.312l0.002-0.007c-0.151 0.464-0.324 0.861-0.531 1.237l0.019-0.037c0.117-0.052 0.253-0.082 0.396-0.082 0.552 0 1 0.448 1 1 0 0.208-0.064 0.401-0.172 0.561l0.002-0.004c-0.812 1.212-1.772 2.247-2.87 3.114l-0.028 0.022c0 0.1 0 0.2 0 0.306 0 0.051 0.001 0.111 0.001 0.171 0 10.12-8.204 18.324-18.324 18.324-0.062 0-0.124-0-0.186-0.001l0.009 0zM5 27.084c1.616 0.58 3.481 0.916 5.424 0.916 0.004 0 0.008 0 0.013 0h-0.001c0.048 0 0.104 0.001 0.161 0.001 9.027 0 16.344-7.317 16.344-16.344 0-0.055-0-0.11-0.001-0.165l0 0.008c0-0.256 0-0.502-0.022-0.746-0.001-0.014-0.001-0.031-0.001-0.049 0-0.335 0.165-0.632 0.418-0.813l0.003-0.002q0.312-0.222 0.6-0.466l-0.364 0.052c-0.038 0.005-0.082 0.008-0.126 0.008-0.552 0-1-0.448-1-1 0-0.363 0.193-0.68 0.482-0.856l0.004-0.003q0.222-0.134 0.428-0.286c-0.3 0.082-0.6 0.154-0.912 0.214-0.059 0.012-0.127 0.020-0.197 0.020-0.286 0-0.544-0.12-0.727-0.313l-0-0c-0.943-1.007-2.28-1.634-3.764-1.634-2.845 0-5.152 2.307-5.152 5.152 0 0.001 0 0.002 0 0.002v-0c-0 0.020-0 0.043-0 0.066 0 0.395 0.043 0.781 0.125 1.151l-0.007-0.035c0.017 0.069 0.027 0.148 0.027 0.23 0 0.242-0.086 0.463-0.228 0.636l0.001-0.002c-0.177 0.219-0.445 0.358-0.746 0.358-0.024 0-0.047-0.001-0.071-0.003l0.003 0c-4.85-0.253-9.167-2.342-12.31-5.577l-0.004-0.005c-0.098 0.376-0.155 0.808-0.155 1.253 0 1.778 0.902 3.345 2.272 4.27l0.018 0.012c0.27 0.182 0.446 0.487 0.446 0.832 0 0.552-0.448 1-1 1-0.008 0-0.015-0-0.023-0l0.001 0c-0.548-0.010-1.074-0.082-1.577-0.21l0.047 0.010c0.554 1.812 2.029 3.181 3.866 3.574l0.034 0.006c0.458 0.097 0.797 0.499 0.797 0.979 0 0.456-0.305 0.841-0.722 0.961l-0.007 0.002c-0.412 0.117-0.89 0.198-1.383 0.225l-0.017 0.001c0.926 1.304 2.415 2.156 4.105 2.2l0.007 0c0.546 0.009 0.984 0.453 0.984 1 0 0.319-0.15 0.603-0.382 0.787l-0.002 0.002c-1.596 1.249-3.522 2.154-5.625 2.568l-0.085 0.014z"></path>
3059
+ </svg>
3060
+ `;
3061
+
3062
+ const copy_link = `<!-- Generated by IcoMoon.io -->
3063
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
3064
+ <title>link</title>
3065
+ <path d="M19.247 23.019l-4.189 4.189c-2.831 2.831-7.435 2.831-10.265 0-1.371-1.372-2.125-3.193-2.125-5.132s0.755-3.761 2.125-5.133l4.189-4.191c0.521-0.521 0.521-1.364 0-1.885s-1.364-0.521-1.885 0l-4.189 4.191c-1.875 1.875-2.907 4.367-2.907 7.019s1.032 5.143 2.907 7.017 4.368 2.907 7.019 2.907 5.143-1.032 7.017-2.908l4.189-4.189c0.521-0.521 0.521-1.364 0-1.885s-1.364-0.52-1.885 0.001zM22.276 9.724c-0.521-0.521-1.364-0.521-1.885 0l-10.667 10.667c-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391l10.667-10.667c0.521-0.521 0.521-1.364 0-1.885zM29.093 2.908c-1.875-1.876-4.368-2.908-7.019-2.908s-5.143 1.032-7.017 2.908l-4.189 4.188c-0.521 0.521-0.521 1.364 0 1.885s1.364 0.521 1.885 0l4.189-4.189c2.831-2.831 7.435-2.831 10.265 0 1.371 1.372 2.125 3.193 2.125 5.132s-0.755 3.761-2.125 5.133l-4.189 4.191c-0.521 0.521-0.521 1.364 0 1.885 0.26 0.26 0.601 0.391 0.943 0.391s0.683-0.131 0.943-0.391l4.189-4.191c1.875-1.875 2.907-4.367 2.907-7.019s-1.032-5.143-2.907-7.016z"></path>
3066
+ </svg>
3067
+ `;
3068
+
3069
+ const email = `<!-- Generated by IcoMoon.io -->
3070
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
3071
+ <title>mail</title>
3072
+ <path d="M28 2.667h-24c-2.205 0-4 1.795-4 4v18.667c0 2.205 1.795 4 4 4h24c2.205 0 4-1.795 4-4v-18.667c0-2.205-1.795-4-4-4zM29.333 25.333c0 0.735-0.599 1.333-1.333 1.333h-24c-0.735 0-1.333-0.599-1.333-1.333v-12.685l10.54 4.865c0.888 0.409 1.84 0.613 2.793 0.613s1.907-0.204 2.793-0.615l10.54-4.864zM29.333 9.711l-11.657 5.38c-1.065 0.492-2.288 0.492-3.353 0l-11.656-5.38v-3.044c0-0.735 0.599-1.333 1.333-1.333h24c0.735 0 1.333 0.599 1.333 1.333z"></path>
3073
+ </svg>
3074
+ `;
3075
+
3076
+ const whatsapp = `<!-- Generated by IcoMoon.io -->
3077
+ <svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 32 32">
3078
+ <title>whatsapp</title>
3079
+ <path d="M16 32c-0.008 0-0.018 0-0.028 0-3.1 0-5.993-0.887-8.439-2.421l0.066 0.039-7.2 2.3 2.336-6.964c-1.713-2.492-2.736-5.575-2.736-8.897 0-0.020 0-0.040 0-0.060v0.003c0.009-8.833 7.167-15.991 15.999-16h0.001c8.837 0 16 7.163 16 16s-7.163 16-16 16v0zM7.906 27.424l0.4 0.264c2.169 1.449 4.837 2.312 7.707 2.312 7.732 0 14-6.268 14-14s-6.268-14-14-14c-0.004 0-0.009 0-0.013 0h0.001c-7.729 0.008-13.992 6.271-14 13.999v0.001c-0 0.010-0 0.021-0 0.032 0 3.072 1 5.909 2.693 8.206l-0.027-0.038 0.304 0.416-1.4 4.2zM20.716 24.958c-1.684-0.131-3.237-0.574-4.641-1.271l0.073 0.033c-3.098-1.456-5.634-3.668-7.438-6.405l-0.042-0.067c-1.102-1.357-1.819-3.067-1.962-4.938l-0.002-0.030c-0.001-0.036-0.001-0.078-0.001-0.12 0-1.575 0.66-2.995 1.719-4l0.002-0.002c0.547-0.52 1.289-0.839 2.105-0.839 0.033 0 0.066 0.001 0.099 0.002l-0.005-0c0.2 0 0.378 0 0.542 0.018 0.016-0.001 0.035-0.001 0.054-0.001 0.815 0 1.502 0.549 1.711 1.298l0.003 0.012 0.324 0.782c0.376 0.906 0.858 2.068 0.942 2.244 0.144 0.251 0.23 0.552 0.23 0.873 0 0.286-0.068 0.557-0.188 0.797l0.005-0.010c-0.149 0.307-0.332 0.57-0.55 0.802l0.002-0.002c-0.148 0.168-0.248 0.274-0.346 0.378s-0.172 0.18-0.26 0.284c0.575 0.92 1.237 1.713 1.992 2.406l0.008 0.008c0.829 0.758 1.802 1.373 2.872 1.8l0.064 0.022c0.369-0.266 0.672-0.6 0.896-0.985l0.008-0.015 0.174-0.232c0.328-0.484 0.875-0.798 1.495-0.798 0.249 0 0.487 0.051 0.703 0.142l-0.012-0.004c0.492 0.168 2.922 1.372 2.946 1.384l0.228 0.11c0.415 0.149 0.758 0.417 0.996 0.763l0.004 0.007c0.107 0.349 0.169 0.75 0.169 1.166 0 0.591-0.125 1.153-0.349 1.661l0.010-0.026c-0.702 1.368-1.983 2.353-3.511 2.637l-0.031 0.005c-0.309 0.071-0.663 0.112-1.028 0.112-0.004 0-0.007 0-0.011 0h0.001zM10.632 9.318c-0.028-0.002-0.062-0.004-0.095-0.004-0.245 0-0.472 0.076-0.659 0.206l0.004-0.002c-0.726 0.651-1.18 1.591-1.18 2.638 0 0.044 0.001 0.087 0.002 0.13l-0-0.006c0.122 1.404 0.662 2.662 1.495 3.671l-0.009-0.011 0.12 0.168c1.627 2.491 3.865 4.46 6.504 5.723l0.096 0.041c3.136 1.288 3.916 1.124 4.426 1.014 0.87-0.159 1.601-0.656 2.067-1.347l0.007-0.011c0.12-0.316 0.204-0.682 0.237-1.063l0.001-0.015-0.040-0.018-0.256-0.124c-0.8-0.4-2.46-1.2-2.734-1.292l-0.058 0.184c-0.346 0.501-0.684 0.934-1.045 1.347l0.015-0.017c-0.344 0.349-0.821 0.565-1.349 0.565-0.28 0-0.546-0.061-0.785-0.17l0.012 0.005c-1.403-0.547-2.609-1.301-3.646-2.239l0.010 0.009c-0.975-0.891-1.81-1.912-2.486-3.039l-0.034-0.061c-0.152-0.244-0.242-0.54-0.242-0.857 0-0.463 0.191-0.88 0.499-1.178l0-0c0.13-0.162 0.264-0.302 0.4-0.444l0.236-0.256c0.091-0.096 0.177-0.201 0.254-0.311l0.006-0.009c-0.158-0.36-0.622-1.472-0.988-2.352l-0.322-0.772-0.038-0.086c-0.188-0.010-0.302-0.016-0.426-0.016zM12.462 12.442v0.012z"></path>
3080
+ </svg>
3081
+ `;
3082
+
3083
+ var Socials;
3084
+ (function (Socials) {
3085
+ Socials["FACEBOOK"] = "facebook";
3086
+ Socials["TWITTER"] = "twitter";
3087
+ Socials["WHATSAPP"] = "whatsapp";
3088
+ Socials["EMAIL"] = "email";
3089
+ Socials["COPY_LINK"] = "copy_link";
3090
+ })(Socials || (Socials = {}));
3091
+
3092
+ const sallaSocialShareCss = "";
3093
+
3094
+ const SallaSocialShare = class {
3095
+ constructor(hostRef) {
3096
+ registerInstance(this, hostRef);
3097
+ this.opened = false;
3098
+ this.allPlatforms = [Socials.WHATSAPP, Socials.FACEBOOK, Socials.TWITTER, Socials.EMAIL, Socials.COPY_LINK];
3099
+ this.platformIcons = [{ icon: whatsapp, name: Socials.WHATSAPP }, { icon: facebook, name: Socials.FACEBOOK }, { icon: twitter, name: Socials.TWITTER }, { icon: email, name: Socials.EMAIL }, { icon: copy_link, name: Socials.COPY_LINK }];
3100
+ /**
3101
+ * page url that will be shared custom | current page url
3102
+ */
3103
+ this.url = "";
3104
+ /**
3105
+ * page url name that will be shared custom | current page url
3106
+ */
3107
+ this.urlName = "";
3108
+ /**
3109
+ * selected platforms to share | all platforms
3110
+ */
3111
+ this.platforms = this.allPlatforms;
3112
+ }
3113
+ componentWillLoad() {
3114
+ // ? this will not work if there are multiple share components on the same page, this will be applied to the first one only
3115
+ window.a2a_config = window.a2a_config || {};
3116
+ window.a2a_config.linkurl = this.url ? this.url : window.location.href;
3117
+ window.a2a_config.linkname = this.urlName ? this.urlName : document.title;
3118
+ salla.lang.onLoaded(() => {
3119
+ window.a2a_config.locale = salla.lang.locale;
3120
+ });
3121
+ }
3122
+ open() {
3123
+ this.opened = !this.opened;
3124
+ if (this.opened) {
3125
+ this.shareMenu.classList.add('opened');
3126
+ }
3127
+ else {
3128
+ this.shareMenu.classList.remove('opened');
3129
+ }
3130
+ new anime.timeline()
3131
+ .add({
3132
+ targets: this.shareMenu,
3133
+ translateY: [-50, 0],
3134
+ opacity: [0, 1],
3135
+ duration: 300,
3136
+ podding: '0',
3137
+ easing: 'easeInOutSine'
3138
+ })
3139
+ .add({
3140
+ targets: this.platformItem,
3141
+ translateZ: 0,
3142
+ translateY: [-30, 0],
3143
+ scaleY: [0, 1],
3144
+ opacity: [0, 1],
3145
+ duration: 1200,
3146
+ delay: anime.stagger(100)
3147
+ }, '-=200');
3148
+ }
3149
+ render() {
3150
+ return (h("div", { id: "s-social-share", class: "s-social-share-wrapper" }, h("slot", { name: 'widget' }, h("salla-button", { "aria-label": "Share", onClick: () => this.open(), class: "s-social-share-btn", shape: "icon", fill: "outline", color: "light" }, h("i", { class: this.opened ? "sicon-cancel" : "sicon-share-alt" }))), h("ul", { ref: el => this.shareMenu = el, class: "s-social-share-list a2a_kit share" }, this.platforms.map(platform => {
3151
+ return (h("li", { ref: el => this.platformItem = el }, h("a", { class: `a2a_button_${platform}`, "aria-label": `Share Via ${platform}` }, this.platformIcons.map((icon) => {
3152
+ if (icon.name === platform) {
3153
+ return h("span", { class: "s-social-share-icon", innerHTML: icon.icon });
3154
+ }
3155
+ }))));
3156
+ }))));
3157
+ }
3158
+ };
3159
+ SallaSocialShare.style = sallaSocialShareCss;
3160
+
1694
3161
  /**
1695
3162
  * SSR Window 4.0.2
1696
3163
  * Better handling for window object in SSR environment
@@ -8455,4 +9922,4 @@ const SallaVerify = class {
8455
9922
  };
8456
9923
  SallaVerify.style = sallaVerifyCss;
8457
9924
 
8458
- export { SallaBranches as salla_branches, SallaButton as salla_button, SallaInfiniteScroll as salla_infinite_scroll, SallaListTile as salla_list_tile, SallaLoading as salla_loading, SallaLocalizationModal as salla_localization_modal, SallaLoginModal as salla_login_modal, SallaLoyalty as salla_loyalty, SallaModal as salla_modal, SallaOfferModal as salla_offer_modal, SallaPlaceholder as salla_placeholder, SallaProductAvailability as salla_product_availability, SallaProductSizeGuide as salla_product_size_guide, SallaRatingModal as salla_rating_modal, SallaRatingStars as salla_rating_stars, SallaSearch as salla_search, SallaSwiper as salla_swiper, SallaTabContent as salla_tab_content, SallaTabHeader as salla_tab_header, SallaTabs as salla_tabs, SallaTelInput as salla_tel_input, SallaVerify as salla_verify };
9925
+ export { SallaButton as salla_button, SallaInfiniteScroll as salla_infinite_scroll, SallaListTile as salla_list_tile, SallaLoading as salla_loading, SallaLocalizationModal as salla_localization_modal, SallaLoginModal as salla_login_modal, SallaLoyalty as salla_loyalty, SallaModal as salla_modal, SallaOfferModal as salla_offer_modal, SallaPlaceholder as salla_placeholder, SallaProductAvailability as salla_product_availability, SallaProductSizeGuide as salla_product_size_guide, SallaRatingModal as salla_rating_modal, SallaRatingStars as salla_rating_stars, SallaScopees as salla_scopes, SallaSearch as salla_search, SallaSocialShare as salla_social_share, SallaSwiper as salla_swiper, SallaTabContent as salla_tab_content, SallaTabHeader as salla_tab_header, SallaTabs as salla_tabs, SallaTelInput as salla_tel_input, SallaVerify as salla_verify };