@usertour/helpers 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-7IK5Q5N2.js +591 -0
- package/dist/chunk-DEG6MTU7.js +318 -0
- package/dist/chunk-Y6FPPOKF.js +28 -0
- package/dist/conditions.cjs +1001 -0
- package/dist/conditions.d.cts +23 -0
- package/dist/conditions.d.ts +23 -0
- package/dist/conditions.js +45 -0
- package/dist/finderx.cjs +346 -0
- package/dist/finderx.d.cts +47 -0
- package/dist/finderx.d.ts +47 -0
- package/dist/finderx.js +15 -0
- package/dist/index.cjs +913 -2
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +68 -17
- package/dist/listener.cjs +68 -0
- package/dist/listener.d.cts +7 -0
- package/dist/listener.d.ts +7 -0
- package/dist/listener.js +16 -0
- package/package.json +14 -9
package/dist/index.cjs
CHANGED
|
@@ -39,11 +39,17 @@ __export(src_exports, {
|
|
|
39
39
|
ArrayProto: () => ArrayProto,
|
|
40
40
|
JWTLicenseSigner: () => JWTLicenseSigner,
|
|
41
41
|
JWTLicenseValidator: () => JWTLicenseValidator,
|
|
42
|
+
PRIORITIES: () => PRIORITIES,
|
|
42
43
|
XMLHttpRequest: () => XMLHttpRequest,
|
|
43
44
|
absoluteUrl: () => absoluteUrl,
|
|
45
|
+
activedContentCondition: () => activedContentCondition,
|
|
46
|
+
activedContentRulesConditions: () => activedContentRulesConditions,
|
|
47
|
+
activedRulesConditions: () => activedRulesConditions,
|
|
44
48
|
assignableWindow: () => assignableWindow,
|
|
45
49
|
autoStartConditions: () => autoStartConditions,
|
|
46
50
|
buildConfig: () => buildConfig,
|
|
51
|
+
checklistIsDimissed: () => checklistIsDimissed,
|
|
52
|
+
checklistIsSeen: () => checklistIsSeen,
|
|
47
53
|
cn: () => cn,
|
|
48
54
|
conditionsIsSame: () => conditionsIsSame,
|
|
49
55
|
convertSettings: () => convertSettings,
|
|
@@ -52,9 +58,16 @@ __export(src_exports, {
|
|
|
52
58
|
deepClone: () => deepClone,
|
|
53
59
|
defaultContentConfig: () => defaultContentConfig,
|
|
54
60
|
defaultStep: () => defaultStep,
|
|
55
|
-
document: () =>
|
|
61
|
+
document: () => document2,
|
|
56
62
|
evalCode: () => evalCode,
|
|
57
63
|
fetch: () => fetch,
|
|
64
|
+
filterAutoStartContent: () => filterAutoStartContent,
|
|
65
|
+
findLatestEvent: () => findLatestEvent,
|
|
66
|
+
finder: () => finder,
|
|
67
|
+
finderV2: () => finderV2,
|
|
68
|
+
finderX: () => finderX,
|
|
69
|
+
flowIsDismissed: () => flowIsDismissed,
|
|
70
|
+
flowIsSeen: () => flowIsSeen,
|
|
58
71
|
formatDate: () => formatDate,
|
|
59
72
|
generateAutoStateColors: () => generateAutoStateColors,
|
|
60
73
|
getAuthToken: () => getAuthToken,
|
|
@@ -77,6 +90,8 @@ __export(src_exports, {
|
|
|
77
90
|
hexToHSLString: () => hexToHSLString,
|
|
78
91
|
hexToRGBStr: () => hexToRGBStr,
|
|
79
92
|
hexToRgb: () => hexToRgb,
|
|
93
|
+
isActive: () => isActive,
|
|
94
|
+
isActiveContent: () => isActiveContent,
|
|
80
95
|
isArray: () => isArray,
|
|
81
96
|
isBoolean: () => isBoolean,
|
|
82
97
|
isDark: () => isDark,
|
|
@@ -88,6 +103,7 @@ __export(src_exports, {
|
|
|
88
103
|
isFile: () => isFile,
|
|
89
104
|
isFormData: () => isFormData,
|
|
90
105
|
isFunction: () => isFunction,
|
|
106
|
+
isHasActivedContents: () => isHasActivedContents,
|
|
91
107
|
isMatchUrlPattern: () => isMatchUrlPattern,
|
|
92
108
|
isNull: () => isNull,
|
|
93
109
|
isNullish: () => isNullish,
|
|
@@ -95,21 +111,28 @@ __export(src_exports, {
|
|
|
95
111
|
isObject: () => isObject,
|
|
96
112
|
isPublishedAtLeastOneEnvironment: () => isPublishedAtLeastOneEnvironment,
|
|
97
113
|
isPublishedInAllEnvironments: () => isPublishedInAllEnvironments,
|
|
114
|
+
isSameContents: () => isSameContents,
|
|
98
115
|
isString: () => isString,
|
|
99
116
|
isUint8Array: () => isUint8Array,
|
|
100
117
|
isUndefined: () => isUndefined,
|
|
101
118
|
isUrl: () => isUrl,
|
|
119
|
+
isValidContent: () => isValidContent,
|
|
102
120
|
isValidSelector: () => isValidSelector,
|
|
121
|
+
isVisible: () => isVisible,
|
|
103
122
|
location: () => location,
|
|
104
123
|
mergeThemeDefaultSettings: () => mergeThemeDefaultSettings,
|
|
105
124
|
nativeForEach: () => nativeForEach,
|
|
106
125
|
nativeIndexOf: () => nativeIndexOf,
|
|
107
126
|
navigator: () => navigator,
|
|
127
|
+
parseUrlParams: () => parseUrlParams,
|
|
128
|
+
parserV2: () => parserV2,
|
|
129
|
+
parserX: () => parserX,
|
|
108
130
|
removeAuthToken: () => removeAuthToken,
|
|
109
131
|
setAuthToken: () => setAuthToken,
|
|
110
132
|
storage: () => storage,
|
|
111
133
|
userAgent: () => userAgent,
|
|
112
134
|
uuidV4: () => uuidV4,
|
|
135
|
+
wait: () => wait,
|
|
113
136
|
window: () => win
|
|
114
137
|
});
|
|
115
138
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -813,7 +836,7 @@ var ArrayProto = Array.prototype;
|
|
|
813
836
|
var nativeForEach = ArrayProto.forEach;
|
|
814
837
|
var nativeIndexOf = ArrayProto.indexOf;
|
|
815
838
|
var navigator = global == null ? void 0 : global.navigator;
|
|
816
|
-
var
|
|
839
|
+
var document2 = global == null ? void 0 : global.document;
|
|
817
840
|
var location = global == null ? void 0 : global.location;
|
|
818
841
|
var fetch = global == null ? void 0 : global.fetch;
|
|
819
842
|
var XMLHttpRequest = (global == null ? void 0 : global.XMLHttpRequest) && "withCredentials" in new global.XMLHttpRequest() ? global.XMLHttpRequest : void 0;
|
|
@@ -1373,17 +1396,888 @@ var JWTLicenseValidator = {
|
|
|
1373
1396
|
}
|
|
1374
1397
|
}
|
|
1375
1398
|
};
|
|
1399
|
+
|
|
1400
|
+
// src/conditions.ts
|
|
1401
|
+
var import_dom = require("@floating-ui/dom");
|
|
1402
|
+
|
|
1403
|
+
// src/finderx.ts
|
|
1404
|
+
var import_finder = require("@medv/finder");
|
|
1405
|
+
var finderAttrs = [
|
|
1406
|
+
"data-for",
|
|
1407
|
+
"data-id",
|
|
1408
|
+
"data-testid",
|
|
1409
|
+
"data-test-id",
|
|
1410
|
+
"for",
|
|
1411
|
+
"id",
|
|
1412
|
+
"name",
|
|
1413
|
+
"placeholder",
|
|
1414
|
+
"role"
|
|
1415
|
+
];
|
|
1416
|
+
var defaultConfig = {
|
|
1417
|
+
idName: () => false,
|
|
1418
|
+
className: () => false,
|
|
1419
|
+
tagName: () => false,
|
|
1420
|
+
attr: () => false,
|
|
1421
|
+
seedMinLength: 1,
|
|
1422
|
+
optimizedMinLength: 2,
|
|
1423
|
+
threshold: 1e3,
|
|
1424
|
+
maxNumberOfTries: 1e4
|
|
1425
|
+
};
|
|
1426
|
+
var finderConfigs = [
|
|
1427
|
+
{
|
|
1428
|
+
...defaultConfig,
|
|
1429
|
+
tagName: () => true
|
|
1430
|
+
},
|
|
1431
|
+
{
|
|
1432
|
+
...defaultConfig,
|
|
1433
|
+
idName: () => true
|
|
1434
|
+
},
|
|
1435
|
+
{
|
|
1436
|
+
...defaultConfig,
|
|
1437
|
+
tagName: () => true,
|
|
1438
|
+
attr: (name) => finderAttrs.includes(name)
|
|
1439
|
+
},
|
|
1440
|
+
{
|
|
1441
|
+
...defaultConfig,
|
|
1442
|
+
className: () => true,
|
|
1443
|
+
attr: (name) => finderAttrs.includes(name)
|
|
1444
|
+
},
|
|
1445
|
+
{
|
|
1446
|
+
...defaultConfig,
|
|
1447
|
+
tagName: () => true,
|
|
1448
|
+
idName: () => true,
|
|
1449
|
+
className: () => true,
|
|
1450
|
+
attr: () => false
|
|
1451
|
+
},
|
|
1452
|
+
{
|
|
1453
|
+
...defaultConfig,
|
|
1454
|
+
tagName: () => true,
|
|
1455
|
+
idName: () => true,
|
|
1456
|
+
className: () => true,
|
|
1457
|
+
attr: (name) => finderAttrs.includes(name)
|
|
1458
|
+
}
|
|
1459
|
+
];
|
|
1460
|
+
function getMaxDepth(node) {
|
|
1461
|
+
if (node.parentNode) {
|
|
1462
|
+
return getMaxDepth(node.parentNode);
|
|
1463
|
+
}
|
|
1464
|
+
return node.depth;
|
|
1465
|
+
}
|
|
1466
|
+
function queryNodeListBySelectors(selectors, rootDocument, removeRepeat = true) {
|
|
1467
|
+
const nodes = [];
|
|
1468
|
+
if (!selectors) {
|
|
1469
|
+
return nodes;
|
|
1470
|
+
}
|
|
1471
|
+
for (const s of selectors) {
|
|
1472
|
+
const els = rootDocument.querySelectorAll(s.replace(/\\\\/g, "\\"));
|
|
1473
|
+
if (els && els.length > 0) {
|
|
1474
|
+
nodes.push(...Array.from(els));
|
|
1475
|
+
}
|
|
1476
|
+
}
|
|
1477
|
+
return removeRepeat ? [...new Set(nodes)] : nodes;
|
|
1478
|
+
}
|
|
1479
|
+
function findMostRecurringNode(nodes) {
|
|
1480
|
+
const m = /* @__PURE__ */ new Map();
|
|
1481
|
+
let finalNode = nodes[0];
|
|
1482
|
+
let count = 0;
|
|
1483
|
+
for (const node of nodes) {
|
|
1484
|
+
const i = m.get(node) ? m.get(node) + 1 : 1;
|
|
1485
|
+
m.set(node, i);
|
|
1486
|
+
}
|
|
1487
|
+
m.forEach((value, key) => {
|
|
1488
|
+
if (value > count) {
|
|
1489
|
+
count = value;
|
|
1490
|
+
finalNode = key;
|
|
1491
|
+
}
|
|
1492
|
+
});
|
|
1493
|
+
return finalNode;
|
|
1494
|
+
}
|
|
1495
|
+
function compareParentNode(node, el, rootDocument, isCompareSibings = false) {
|
|
1496
|
+
let nodeParentNode = node.parentNode;
|
|
1497
|
+
let elParentElement = el.parentElement;
|
|
1498
|
+
const maxDepth = getMaxDepth(node);
|
|
1499
|
+
const xresult = {
|
|
1500
|
+
maxDepth,
|
|
1501
|
+
failedDepth: 0,
|
|
1502
|
+
success: true
|
|
1503
|
+
};
|
|
1504
|
+
while (nodeParentNode && elParentElement) {
|
|
1505
|
+
if (elParentElement === rootDocument) {
|
|
1506
|
+
break;
|
|
1507
|
+
}
|
|
1508
|
+
if (elParentElement === document.body || elParentElement === document.documentElement || elParentElement.parentElement === document.body) {
|
|
1509
|
+
break;
|
|
1510
|
+
}
|
|
1511
|
+
const parentNodes = queryNodeListBySelectors(nodeParentNode.selectors, rootDocument);
|
|
1512
|
+
const isMatchSibings = isCompareSibings ? compareSibingsNode(nodeParentNode, elParentElement, rootDocument) : true;
|
|
1513
|
+
if (!parentNodes || parentNodes.length === 0 || !parentNodes.includes(elParentElement) || !isMatchSibings) {
|
|
1514
|
+
xresult.failedDepth = nodeParentNode.depth;
|
|
1515
|
+
xresult.success = false;
|
|
1516
|
+
}
|
|
1517
|
+
nodeParentNode = nodeParentNode.parentNode;
|
|
1518
|
+
elParentElement = elParentElement.parentElement;
|
|
1519
|
+
}
|
|
1520
|
+
return xresult;
|
|
1521
|
+
}
|
|
1522
|
+
function compareSibingsNode(node, el, rootDocument) {
|
|
1523
|
+
let isMatchNext = true;
|
|
1524
|
+
let isMatchPrevious = true;
|
|
1525
|
+
const { previousElementSelectors, nextElementSelectors } = node;
|
|
1526
|
+
if (nextElementSelectors && nextElementSelectors.length > 0) {
|
|
1527
|
+
const nextElementSiblings = queryNodeListBySelectors(nextElementSelectors, rootDocument);
|
|
1528
|
+
isMatchNext = el.nextElementSibling && nextElementSiblings.includes(el.nextElementSibling);
|
|
1529
|
+
}
|
|
1530
|
+
if (previousElementSelectors && previousElementSelectors.length > 0) {
|
|
1531
|
+
const previousElementSiblings = queryNodeListBySelectors(
|
|
1532
|
+
previousElementSelectors,
|
|
1533
|
+
rootDocument
|
|
1534
|
+
);
|
|
1535
|
+
isMatchPrevious = el.previousElementSibling && previousElementSiblings.includes(el.previousElementSibling);
|
|
1536
|
+
}
|
|
1537
|
+
return isMatchNext && isMatchPrevious;
|
|
1538
|
+
}
|
|
1539
|
+
function queryElementSelectors(input) {
|
|
1540
|
+
const classes = Array.from(input.classList);
|
|
1541
|
+
const selectors = [];
|
|
1542
|
+
const configs = [...finderConfigs];
|
|
1543
|
+
for (const className of classes) {
|
|
1544
|
+
configs.push({
|
|
1545
|
+
...defaultConfig,
|
|
1546
|
+
className: (name) => {
|
|
1547
|
+
if (classes.filter((cn2) => cn2 !== className).includes(name)) {
|
|
1548
|
+
return false;
|
|
1549
|
+
}
|
|
1550
|
+
return true;
|
|
1551
|
+
}
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
try {
|
|
1555
|
+
for (const cfg of configs) {
|
|
1556
|
+
selectors.push(finder(input, cfg));
|
|
1557
|
+
}
|
|
1558
|
+
} catch (_) {
|
|
1559
|
+
return selectors;
|
|
1560
|
+
}
|
|
1561
|
+
return [...new Set(selectors)];
|
|
1562
|
+
}
|
|
1563
|
+
function parseSelectorsTree(input, parentNode, depth = 0) {
|
|
1564
|
+
const selectors = queryElementSelectors(input);
|
|
1565
|
+
if (selectors.length === 0) {
|
|
1566
|
+
return parentNode;
|
|
1567
|
+
}
|
|
1568
|
+
const currentNode = {
|
|
1569
|
+
previousElementSelectors: [],
|
|
1570
|
+
nextElementSelectors: [],
|
|
1571
|
+
selectors,
|
|
1572
|
+
depth
|
|
1573
|
+
};
|
|
1574
|
+
if (input.previousElementSibling) {
|
|
1575
|
+
currentNode.previousElementSelectors = queryElementSelectors(input.previousElementSibling);
|
|
1576
|
+
}
|
|
1577
|
+
if (input.nextElementSibling) {
|
|
1578
|
+
currentNode.nextElementSelectors = queryElementSelectors(input.nextElementSibling);
|
|
1579
|
+
}
|
|
1580
|
+
if (parentNode === null) {
|
|
1581
|
+
if (input.parentElement) {
|
|
1582
|
+
parseSelectorsTree(input.parentElement, currentNode, depth + 1);
|
|
1583
|
+
}
|
|
1584
|
+
return currentNode;
|
|
1585
|
+
}
|
|
1586
|
+
parentNode.parentNode = currentNode;
|
|
1587
|
+
if (input.parentElement) {
|
|
1588
|
+
parseSelectorsTree(input.parentElement, currentNode, depth + 1);
|
|
1589
|
+
}
|
|
1590
|
+
return parentNode;
|
|
1591
|
+
}
|
|
1592
|
+
function finderMostPrecisionElement(elements, node, rootDocument, precision) {
|
|
1593
|
+
const successEls = [];
|
|
1594
|
+
let failedData = {
|
|
1595
|
+
el: null,
|
|
1596
|
+
failedDepth: 0,
|
|
1597
|
+
maxDepth: 0
|
|
1598
|
+
};
|
|
1599
|
+
for (const el of elements) {
|
|
1600
|
+
const { success, failedDepth, maxDepth } = compareParentNode(node, el, rootDocument);
|
|
1601
|
+
if (success) {
|
|
1602
|
+
successEls.push(el);
|
|
1603
|
+
} else if (!failedData.el || failedDepth > failedData.failedDepth) {
|
|
1604
|
+
failedData = { el, failedDepth, maxDepth };
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
if (successEls.length === 1) {
|
|
1608
|
+
return successEls[0];
|
|
1609
|
+
}
|
|
1610
|
+
if (successEls.length > 1) {
|
|
1611
|
+
let tempEl = successEls[0];
|
|
1612
|
+
let tempFailedDepth = 0;
|
|
1613
|
+
for (const el of successEls) {
|
|
1614
|
+
const { success, failedDepth } = compareParentNode(node, el, rootDocument, true);
|
|
1615
|
+
if (success) {
|
|
1616
|
+
return el;
|
|
1617
|
+
}
|
|
1618
|
+
if (failedDepth > tempFailedDepth) {
|
|
1619
|
+
tempFailedDepth = failedDepth;
|
|
1620
|
+
tempEl = el;
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
return tempEl;
|
|
1624
|
+
}
|
|
1625
|
+
if (failedData.el) {
|
|
1626
|
+
const { failedDepth, maxDepth, el } = failedData;
|
|
1627
|
+
const rate = (failedDepth - 1) / maxDepth * 10;
|
|
1628
|
+
if (rate >= precision) {
|
|
1629
|
+
return el;
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
return null;
|
|
1633
|
+
}
|
|
1634
|
+
function finder(input, options) {
|
|
1635
|
+
return (0, import_finder.finder)(input, options);
|
|
1636
|
+
}
|
|
1637
|
+
function parserX(input) {
|
|
1638
|
+
return parseSelectorsTree(input, null);
|
|
1639
|
+
}
|
|
1640
|
+
function parserV2(element) {
|
|
1641
|
+
var _a;
|
|
1642
|
+
const content = (_a = element.innerText) != null ? _a : "";
|
|
1643
|
+
const selectors = parseSelectorsTree(element, null);
|
|
1644
|
+
const selectorsList = queryElementSelectors(element);
|
|
1645
|
+
return { content, selectors, selectorsList };
|
|
1646
|
+
}
|
|
1647
|
+
function finderV2(target, root) {
|
|
1648
|
+
const {
|
|
1649
|
+
selectors,
|
|
1650
|
+
content = "",
|
|
1651
|
+
sequence = 0,
|
|
1652
|
+
precision = "strict",
|
|
1653
|
+
isDynamicContent = false,
|
|
1654
|
+
customSelector = "",
|
|
1655
|
+
type = "auto"
|
|
1656
|
+
} = target;
|
|
1657
|
+
if (type === "auto") {
|
|
1658
|
+
const mapping = {
|
|
1659
|
+
looser: 1,
|
|
1660
|
+
loose: 3,
|
|
1661
|
+
loosest: 5,
|
|
1662
|
+
strict: 7,
|
|
1663
|
+
stricter: 8,
|
|
1664
|
+
strictest: 10
|
|
1665
|
+
};
|
|
1666
|
+
const el = finderX(selectors, root, mapping[precision]);
|
|
1667
|
+
if (el) {
|
|
1668
|
+
if (isDynamicContent && content && el.innerText !== content) {
|
|
1669
|
+
return null;
|
|
1670
|
+
}
|
|
1671
|
+
return el;
|
|
1672
|
+
}
|
|
1673
|
+
} else {
|
|
1674
|
+
const sequenceMapping = {
|
|
1675
|
+
"1st": 0,
|
|
1676
|
+
"2st": 1,
|
|
1677
|
+
"3st": 2,
|
|
1678
|
+
"4st": 3,
|
|
1679
|
+
"5st": 4
|
|
1680
|
+
};
|
|
1681
|
+
if (customSelector) {
|
|
1682
|
+
const selector = customSelector.replace(/\\\\/g, "\\");
|
|
1683
|
+
const els = root.querySelectorAll(selector);
|
|
1684
|
+
if (els.length > 0) {
|
|
1685
|
+
const el = els[sequenceMapping[sequence]] || els[0];
|
|
1686
|
+
if (content && el.innerText.trim() !== content) {
|
|
1687
|
+
return null;
|
|
1688
|
+
}
|
|
1689
|
+
return el;
|
|
1690
|
+
}
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
return null;
|
|
1694
|
+
}
|
|
1695
|
+
function finderX(node, root, precision = 10) {
|
|
1696
|
+
if (!node || node.selectors.length === 0) {
|
|
1697
|
+
return null;
|
|
1698
|
+
}
|
|
1699
|
+
const rootDocument = root || document;
|
|
1700
|
+
const elements = [];
|
|
1701
|
+
const nodeList = queryNodeListBySelectors(node.selectors, rootDocument, false);
|
|
1702
|
+
if (!nodeList || nodeList.length === 0) {
|
|
1703
|
+
return null;
|
|
1704
|
+
}
|
|
1705
|
+
if ([...new Set(nodeList)].length !== nodeList.length) {
|
|
1706
|
+
const el = findMostRecurringNode(nodeList);
|
|
1707
|
+
elements.push(el);
|
|
1708
|
+
} else {
|
|
1709
|
+
elements.push(...nodeList);
|
|
1710
|
+
}
|
|
1711
|
+
return finderMostPrecisionElement(elements, node, rootDocument, precision);
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
// src/conditions.ts
|
|
1715
|
+
var import_types4 = require("@usertour/types");
|
|
1716
|
+
var import_date_fns = require("date-fns");
|
|
1717
|
+
|
|
1718
|
+
// src/listener.ts
|
|
1719
|
+
function on(obj, ...args) {
|
|
1720
|
+
if (obj == null ? void 0 : obj.addEventListener) {
|
|
1721
|
+
obj.addEventListener(...args);
|
|
1722
|
+
}
|
|
1723
|
+
}
|
|
1724
|
+
function off(obj, ...args) {
|
|
1725
|
+
if (obj == null ? void 0 : obj.removeEventListener) {
|
|
1726
|
+
obj.removeEventListener(...args);
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
|
|
1730
|
+
// src/conditions.ts
|
|
1731
|
+
var rulesTypes = Object.values(import_types4.RulesType);
|
|
1732
|
+
var PRIORITIES = [
|
|
1733
|
+
import_types4.ContentPriority.HIGHEST,
|
|
1734
|
+
import_types4.ContentPriority.HIGH,
|
|
1735
|
+
import_types4.ContentPriority.MEDIUM,
|
|
1736
|
+
import_types4.ContentPriority.LOW,
|
|
1737
|
+
import_types4.ContentPriority.LOWEST
|
|
1738
|
+
];
|
|
1739
|
+
var isActiveRulesByCurrentPage = (rules) => {
|
|
1740
|
+
const { excludes, includes } = rules.data;
|
|
1741
|
+
if (location) {
|
|
1742
|
+
const href = location.href;
|
|
1743
|
+
return isMatchUrlPattern(href, includes, excludes);
|
|
1744
|
+
}
|
|
1745
|
+
return false;
|
|
1746
|
+
};
|
|
1747
|
+
var isActiveRulesByCurrentTime = (rules) => {
|
|
1748
|
+
const { endDate, endDateHour, endDateMinute, startDate, startDateHour, startDateMinute } = rules.data;
|
|
1749
|
+
const startTime = /* @__PURE__ */ new Date(`${startDate} ${startDateHour}:${startDateMinute}:00`);
|
|
1750
|
+
const endTime = /* @__PURE__ */ new Date(`${endDate} ${endDateHour}:${endDateMinute}:00`);
|
|
1751
|
+
const now = /* @__PURE__ */ new Date();
|
|
1752
|
+
if (!endDate) {
|
|
1753
|
+
return (0, import_date_fns.isAfter)(now, startTime);
|
|
1754
|
+
}
|
|
1755
|
+
return (0, import_date_fns.isAfter)(now, startTime) && (0, import_date_fns.isBefore)(now, endTime);
|
|
1756
|
+
};
|
|
1757
|
+
var isActivedContentRulesCondition = (rules, contentSession) => {
|
|
1758
|
+
const { contentId, logic } = rules.data;
|
|
1759
|
+
const { latestSession, seenSessions, completedSessions } = contentSession;
|
|
1760
|
+
if (!contentId || !logic || contentId !== contentSession.contentId) {
|
|
1761
|
+
return false;
|
|
1762
|
+
}
|
|
1763
|
+
if (logic === import_types4.ContentConditionLogic.ACTIVED || logic === import_types4.ContentConditionLogic.UNACTIVED) {
|
|
1764
|
+
if (!latestSession) {
|
|
1765
|
+
return logic === import_types4.ContentConditionLogic.UNACTIVED;
|
|
1766
|
+
}
|
|
1767
|
+
const isActived = !(flowIsDismissed(latestSession) || checklistIsDimissed(latestSession));
|
|
1768
|
+
return logic === import_types4.ContentConditionLogic.ACTIVED ? isActived : !isActived;
|
|
1769
|
+
}
|
|
1770
|
+
const isSeen = seenSessions > 0;
|
|
1771
|
+
const isCompleted = completedSessions > 0;
|
|
1772
|
+
if (logic === import_types4.ContentConditionLogic.SEEN || logic === import_types4.ContentConditionLogic.UNSEEN) {
|
|
1773
|
+
return logic === import_types4.ContentConditionLogic.SEEN ? isSeen : !isSeen;
|
|
1774
|
+
}
|
|
1775
|
+
if (logic === import_types4.ContentConditionLogic.COMPLETED || logic === import_types4.ContentConditionLogic.UNCOMPLETED) {
|
|
1776
|
+
return logic === import_types4.ContentConditionLogic.COMPLETED ? isCompleted : !isCompleted;
|
|
1777
|
+
}
|
|
1778
|
+
return false;
|
|
1779
|
+
};
|
|
1780
|
+
var isVisible = async (el) => {
|
|
1781
|
+
var _a, _b;
|
|
1782
|
+
if (!((_a = document2) == null ? void 0 : _a.body)) {
|
|
1783
|
+
return false;
|
|
1784
|
+
}
|
|
1785
|
+
const { middlewareData } = await (0, import_dom.computePosition)(el, document2.body, {
|
|
1786
|
+
strategy: "fixed",
|
|
1787
|
+
middleware: [(0, import_dom.hide)()]
|
|
1788
|
+
});
|
|
1789
|
+
if ((_b = middlewareData == null ? void 0 : middlewareData.hide) == null ? void 0 : _b.referenceHidden) {
|
|
1790
|
+
return false;
|
|
1791
|
+
}
|
|
1792
|
+
return true;
|
|
1793
|
+
};
|
|
1794
|
+
var cache = /* @__PURE__ */ new Map();
|
|
1795
|
+
var isClicked = (el) => {
|
|
1796
|
+
if (cache.has(el)) {
|
|
1797
|
+
return cache.get(el);
|
|
1798
|
+
}
|
|
1799
|
+
const onClick = () => {
|
|
1800
|
+
cache.set(el, true);
|
|
1801
|
+
off(el, "click", onClick);
|
|
1802
|
+
};
|
|
1803
|
+
on(el, "click", onClick);
|
|
1804
|
+
cache.set(el, false);
|
|
1805
|
+
return false;
|
|
1806
|
+
};
|
|
1807
|
+
var isActiveRulesByElement = async (rules) => {
|
|
1808
|
+
const { data } = rules;
|
|
1809
|
+
if (!document2) {
|
|
1810
|
+
return false;
|
|
1811
|
+
}
|
|
1812
|
+
const el = finderV2(data.elementData, document2);
|
|
1813
|
+
const isPresent = el ? await isVisible(el) : false;
|
|
1814
|
+
const isDisabled = el ? el.disabled : false;
|
|
1815
|
+
switch (data.logic) {
|
|
1816
|
+
case import_types4.ElementConditionLogic.PRESENT:
|
|
1817
|
+
return isPresent;
|
|
1818
|
+
case import_types4.ElementConditionLogic.UNPRESENT:
|
|
1819
|
+
return !isPresent;
|
|
1820
|
+
case import_types4.ElementConditionLogic.DISABLED:
|
|
1821
|
+
return el && isDisabled;
|
|
1822
|
+
case import_types4.ElementConditionLogic.UNDISABLED:
|
|
1823
|
+
return el && !isDisabled;
|
|
1824
|
+
case import_types4.ElementConditionLogic.CLICKED:
|
|
1825
|
+
return el && isClicked(el);
|
|
1826
|
+
case import_types4.ElementConditionLogic.UNCLICKED:
|
|
1827
|
+
return el && !isClicked(el);
|
|
1828
|
+
default:
|
|
1829
|
+
return false;
|
|
1830
|
+
}
|
|
1831
|
+
};
|
|
1832
|
+
var isActiveRulesByTextInput = async (rules) => {
|
|
1833
|
+
const {
|
|
1834
|
+
data: { elementData, logic, value }
|
|
1835
|
+
} = rules;
|
|
1836
|
+
if (!document2) {
|
|
1837
|
+
return false;
|
|
1838
|
+
}
|
|
1839
|
+
const el = finderV2(elementData, document2);
|
|
1840
|
+
if (!el) {
|
|
1841
|
+
return false;
|
|
1842
|
+
}
|
|
1843
|
+
const elValue = el.value;
|
|
1844
|
+
switch (logic) {
|
|
1845
|
+
case import_types4.StringConditionLogic.IS:
|
|
1846
|
+
return elValue === value;
|
|
1847
|
+
case import_types4.StringConditionLogic.NOT:
|
|
1848
|
+
return elValue !== value;
|
|
1849
|
+
case import_types4.StringConditionLogic.CONTAINS:
|
|
1850
|
+
return elValue.includes(value);
|
|
1851
|
+
case import_types4.StringConditionLogic.NOT_CONTAIN:
|
|
1852
|
+
return !elValue.includes(value);
|
|
1853
|
+
case import_types4.StringConditionLogic.STARTS_WITH:
|
|
1854
|
+
return elValue.startsWith(value);
|
|
1855
|
+
case import_types4.StringConditionLogic.ENDS_WITH:
|
|
1856
|
+
return elValue.endsWith(value);
|
|
1857
|
+
case import_types4.StringConditionLogic.MATCH:
|
|
1858
|
+
return elValue.search(value) !== -1;
|
|
1859
|
+
case import_types4.StringConditionLogic.UNMATCH:
|
|
1860
|
+
return elValue.search(value) === -1;
|
|
1861
|
+
case import_types4.StringConditionLogic.ANY:
|
|
1862
|
+
return true;
|
|
1863
|
+
case import_types4.StringConditionLogic.EMPTY:
|
|
1864
|
+
return !elValue;
|
|
1865
|
+
default:
|
|
1866
|
+
return false;
|
|
1867
|
+
}
|
|
1868
|
+
};
|
|
1869
|
+
var fillCache = /* @__PURE__ */ new Map();
|
|
1870
|
+
var isActiveRulesByTextFill = async (rules) => {
|
|
1871
|
+
const {
|
|
1872
|
+
data: { elementData }
|
|
1873
|
+
} = rules;
|
|
1874
|
+
if (!document2) {
|
|
1875
|
+
return false;
|
|
1876
|
+
}
|
|
1877
|
+
const el = finderV2(elementData, document2);
|
|
1878
|
+
if (!el) {
|
|
1879
|
+
return false;
|
|
1880
|
+
}
|
|
1881
|
+
const now = (/* @__PURE__ */ new Date()).getTime();
|
|
1882
|
+
const onKeyup = () => {
|
|
1883
|
+
const cacheData = fillCache.get(el);
|
|
1884
|
+
const data = { ...cacheData, timestamp: (/* @__PURE__ */ new Date()).getTime() };
|
|
1885
|
+
fillCache.set(el, data);
|
|
1886
|
+
};
|
|
1887
|
+
if (fillCache.has(el)) {
|
|
1888
|
+
const { timestamp, value, isActive: isActive2 } = fillCache.get(el);
|
|
1889
|
+
if (isActive2) {
|
|
1890
|
+
return true;
|
|
1891
|
+
}
|
|
1892
|
+
if (timestamp !== -1 && now - timestamp > 1e3 && value !== el.value) {
|
|
1893
|
+
off(document2, "click", onKeyup);
|
|
1894
|
+
fillCache.set(el, { timestamp, value, isActive: true });
|
|
1895
|
+
return true;
|
|
1896
|
+
}
|
|
1897
|
+
return false;
|
|
1898
|
+
}
|
|
1899
|
+
on(document2, "keyup", onKeyup);
|
|
1900
|
+
fillCache.set(el, { timestamp: -1, value: el.value, isActive: false });
|
|
1901
|
+
return false;
|
|
1902
|
+
};
|
|
1903
|
+
var isValidRulesType = (type) => {
|
|
1904
|
+
return rulesTypes.includes(type);
|
|
1905
|
+
};
|
|
1906
|
+
var isActiveRules = async (rules) => {
|
|
1907
|
+
if (!isValidRulesType(rules.type)) {
|
|
1908
|
+
return true;
|
|
1909
|
+
}
|
|
1910
|
+
switch (rules.type) {
|
|
1911
|
+
case import_types4.RulesType.CURRENT_PAGE:
|
|
1912
|
+
return isActiveRulesByCurrentPage(rules);
|
|
1913
|
+
case import_types4.RulesType.TIME:
|
|
1914
|
+
return isActiveRulesByCurrentTime(rules);
|
|
1915
|
+
case import_types4.RulesType.ELEMENT:
|
|
1916
|
+
return await isActiveRulesByElement(rules);
|
|
1917
|
+
case import_types4.RulesType.TEXT_INPUT:
|
|
1918
|
+
return await isActiveRulesByTextInput(rules);
|
|
1919
|
+
case import_types4.RulesType.TEXT_FILL:
|
|
1920
|
+
return await isActiveRulesByTextFill(rules);
|
|
1921
|
+
default:
|
|
1922
|
+
return rules.actived;
|
|
1923
|
+
}
|
|
1924
|
+
};
|
|
1925
|
+
var activedRulesConditions = async (conditions, rewrite) => {
|
|
1926
|
+
const rulesCondition = [...conditions];
|
|
1927
|
+
for (let j = 0; j < rulesCondition.length; j++) {
|
|
1928
|
+
const rules = rulesCondition[j];
|
|
1929
|
+
if (rules.type !== "group") {
|
|
1930
|
+
if (rewrite == null ? void 0 : rewrite[rules.type]) {
|
|
1931
|
+
rulesCondition[j].actived = true;
|
|
1932
|
+
} else {
|
|
1933
|
+
rulesCondition[j].actived = await isActiveRules(rules);
|
|
1934
|
+
}
|
|
1935
|
+
} else if (rules.conditions) {
|
|
1936
|
+
rulesCondition[j].conditions = await activedRulesConditions(rules.conditions);
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
return rulesCondition;
|
|
1940
|
+
};
|
|
1941
|
+
var activedContentRulesConditions = async (conditions, contents) => {
|
|
1942
|
+
const rulesCondition = [...conditions];
|
|
1943
|
+
for (let j = 0; j < rulesCondition.length; j++) {
|
|
1944
|
+
const rules = rulesCondition[j];
|
|
1945
|
+
if (rules.type !== "group") {
|
|
1946
|
+
if (rules.type === import_types4.RulesType.CONTENT) {
|
|
1947
|
+
const content = contents.find((c) => c.contentId === rules.data.contentId);
|
|
1948
|
+
if (content) {
|
|
1949
|
+
const contentSession = {
|
|
1950
|
+
contentId: content.contentId,
|
|
1951
|
+
latestSession: content.latestSession,
|
|
1952
|
+
totalSessions: content.totalSessions,
|
|
1953
|
+
dismissedSessions: content.dismissedSessions,
|
|
1954
|
+
completedSessions: content.completedSessions,
|
|
1955
|
+
seenSessions: content.seenSessions
|
|
1956
|
+
};
|
|
1957
|
+
rulesCondition[j].actived = isActivedContentRulesCondition(rules, contentSession);
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
} else if (rules.conditions) {
|
|
1961
|
+
rulesCondition[j].conditions = await activedContentRulesConditions(
|
|
1962
|
+
rules.conditions,
|
|
1963
|
+
contents
|
|
1964
|
+
);
|
|
1965
|
+
}
|
|
1966
|
+
}
|
|
1967
|
+
return rulesCondition;
|
|
1968
|
+
};
|
|
1969
|
+
var activedContentCondition = async (contents) => {
|
|
1970
|
+
const _contents = JSON.parse(JSON.stringify(contents));
|
|
1971
|
+
for (let index = 0; index < _contents.length; index++) {
|
|
1972
|
+
const content = _contents[index];
|
|
1973
|
+
const { enabledAutoStartRules, autoStartRules, hideRules, enabledHideRules } = content.config;
|
|
1974
|
+
if (enabledAutoStartRules && autoStartRules && autoStartRules.length > 0) {
|
|
1975
|
+
content.config.autoStartRules = await activedRulesConditions(autoStartRules);
|
|
1976
|
+
}
|
|
1977
|
+
if (enabledHideRules && hideRules && hideRules.length > 0) {
|
|
1978
|
+
content.config.hideRules = await activedRulesConditions(hideRules);
|
|
1979
|
+
}
|
|
1980
|
+
}
|
|
1981
|
+
return _contents;
|
|
1982
|
+
};
|
|
1983
|
+
var isActive = (autoStartRules) => {
|
|
1984
|
+
if (!autoStartRules || autoStartRules.length === 0) {
|
|
1985
|
+
return false;
|
|
1986
|
+
}
|
|
1987
|
+
const operator = autoStartRules[0].operators;
|
|
1988
|
+
const actives = autoStartRules.filter((rule) => {
|
|
1989
|
+
if (!rule.conditions) {
|
|
1990
|
+
return rule.actived;
|
|
1991
|
+
}
|
|
1992
|
+
return isActive(rule.conditions);
|
|
1993
|
+
});
|
|
1994
|
+
return operator === "and" ? actives.length === autoStartRules.length : actives.length > 0;
|
|
1995
|
+
};
|
|
1996
|
+
var isActiveContent = (content) => {
|
|
1997
|
+
const { enabledAutoStartRules, autoStartRules } = content.config;
|
|
1998
|
+
if (!enabledAutoStartRules || !isActive(autoStartRules)) {
|
|
1999
|
+
return false;
|
|
2000
|
+
}
|
|
2001
|
+
return true;
|
|
2002
|
+
};
|
|
2003
|
+
var priorityCompare = (a, b) => {
|
|
2004
|
+
var _a, _b, _c, _d;
|
|
2005
|
+
const a1 = (_b = (_a = a == null ? void 0 : a.config) == null ? void 0 : _a.autoStartRulesSetting) == null ? void 0 : _b.priority;
|
|
2006
|
+
const a2 = (_d = (_c = b == null ? void 0 : b.config) == null ? void 0 : _c.autoStartRulesSetting) == null ? void 0 : _d.priority;
|
|
2007
|
+
if (!a1 || !a2) {
|
|
2008
|
+
return 0;
|
|
2009
|
+
}
|
|
2010
|
+
const index1 = PRIORITIES.indexOf(a1);
|
|
2011
|
+
const index2 = PRIORITIES.indexOf(a2);
|
|
2012
|
+
if (index1 > index2) {
|
|
2013
|
+
return 1;
|
|
2014
|
+
}
|
|
2015
|
+
if (index1 < index2) {
|
|
2016
|
+
return -1;
|
|
2017
|
+
}
|
|
2018
|
+
return 0;
|
|
2019
|
+
};
|
|
2020
|
+
var filterAutoStartContent = (contents, type) => {
|
|
2021
|
+
return contents.filter((content) => {
|
|
2022
|
+
const isActive2 = isActiveContent(content);
|
|
2023
|
+
const isValid = isValidContent(content, contents);
|
|
2024
|
+
return content.type === type && isActive2 && isValid;
|
|
2025
|
+
}).sort(priorityCompare);
|
|
2026
|
+
};
|
|
2027
|
+
var isHasActivedContents = (source, dest) => {
|
|
2028
|
+
for (let index = 0; index < source.length; index++) {
|
|
2029
|
+
const content1 = source[index];
|
|
2030
|
+
const content2 = dest.find((c) => c.id === content1.id);
|
|
2031
|
+
if (!content2) {
|
|
2032
|
+
return true;
|
|
2033
|
+
}
|
|
2034
|
+
if (isActiveContent(content1) !== isActiveContent(content2)) {
|
|
2035
|
+
return true;
|
|
2036
|
+
}
|
|
2037
|
+
}
|
|
2038
|
+
return false;
|
|
2039
|
+
};
|
|
2040
|
+
var isSameContents = (source, dest) => {
|
|
2041
|
+
if (!source || !dest || source.length !== dest.length) {
|
|
2042
|
+
return false;
|
|
2043
|
+
}
|
|
2044
|
+
for (let index = 0; index < source.length; index++) {
|
|
2045
|
+
const content1 = source[index];
|
|
2046
|
+
const content2 = dest.find((c) => c.id === content1.id);
|
|
2047
|
+
if (!content2) {
|
|
2048
|
+
return false;
|
|
2049
|
+
}
|
|
2050
|
+
if (!conditionsIsSame(content1.config.autoStartRules, content2.config.autoStartRules)) {
|
|
2051
|
+
return false;
|
|
2052
|
+
}
|
|
2053
|
+
}
|
|
2054
|
+
return true;
|
|
2055
|
+
};
|
|
2056
|
+
var getLatestEvent = (currentContent, contents, eventCodeName) => {
|
|
2057
|
+
var _a;
|
|
2058
|
+
const bizEvents = [];
|
|
2059
|
+
const contentId = currentContent.id;
|
|
2060
|
+
const contentType = currentContent.type;
|
|
2061
|
+
for (let index = 0; index < contents.length; index++) {
|
|
2062
|
+
const content = contents[index];
|
|
2063
|
+
if (content.id === contentId || content.type !== contentType) {
|
|
2064
|
+
continue;
|
|
2065
|
+
}
|
|
2066
|
+
const sessionBizEvents = (_a = content.latestSession) == null ? void 0 : _a.bizEvent;
|
|
2067
|
+
if (sessionBizEvents && sessionBizEvents.length > 0) {
|
|
2068
|
+
bizEvents.push(...sessionBizEvents.filter((e) => {
|
|
2069
|
+
var _a2;
|
|
2070
|
+
return ((_a2 = e == null ? void 0 : e.event) == null ? void 0 : _a2.codeName) === eventCodeName;
|
|
2071
|
+
}));
|
|
2072
|
+
}
|
|
2073
|
+
}
|
|
2074
|
+
return findLatestEvent(bizEvents);
|
|
2075
|
+
};
|
|
2076
|
+
var findLatestEvent = (bizEvents) => {
|
|
2077
|
+
const initialValue = bizEvents[0];
|
|
2078
|
+
const lastEvent = bizEvents.reduce(
|
|
2079
|
+
(accumulator, currentValue) => {
|
|
2080
|
+
if ((0, import_date_fns.isAfter)(new Date(currentValue.createdAt), new Date(accumulator.createdAt))) {
|
|
2081
|
+
return currentValue;
|
|
2082
|
+
}
|
|
2083
|
+
return accumulator;
|
|
2084
|
+
},
|
|
2085
|
+
initialValue
|
|
2086
|
+
);
|
|
2087
|
+
return lastEvent;
|
|
2088
|
+
};
|
|
2089
|
+
var showEventMapping = {
|
|
2090
|
+
[import_types4.ContentDataType.FLOW]: import_types4.BizEvents.FLOW_STEP_SEEN,
|
|
2091
|
+
[import_types4.ContentDataType.LAUNCHER]: import_types4.BizEvents.LAUNCHER_SEEN,
|
|
2092
|
+
[import_types4.ContentDataType.CHECKLIST]: import_types4.BizEvents.CHECKLIST_SEEN
|
|
2093
|
+
};
|
|
2094
|
+
var isGreaterThenDuration = (dateLeft, dateRight, unit, duration) => {
|
|
2095
|
+
switch (unit) {
|
|
2096
|
+
case import_types4.FrequencyUnits.SECONDS: {
|
|
2097
|
+
if ((0, import_date_fns.differenceInSeconds)(dateLeft, dateRight) >= duration) {
|
|
2098
|
+
return true;
|
|
2099
|
+
}
|
|
2100
|
+
return false;
|
|
2101
|
+
}
|
|
2102
|
+
case import_types4.FrequencyUnits.MINUTES:
|
|
2103
|
+
if ((0, import_date_fns.differenceInMinutes)(dateLeft, dateRight) >= duration) {
|
|
2104
|
+
return true;
|
|
2105
|
+
}
|
|
2106
|
+
return false;
|
|
2107
|
+
case import_types4.FrequencyUnits.HOURS:
|
|
2108
|
+
if ((0, import_date_fns.differenceInHours)(dateLeft, dateRight) >= duration) {
|
|
2109
|
+
return true;
|
|
2110
|
+
}
|
|
2111
|
+
return false;
|
|
2112
|
+
case import_types4.FrequencyUnits.DAYES:
|
|
2113
|
+
if ((0, import_date_fns.differenceInDays)(dateLeft, dateRight) >= duration) {
|
|
2114
|
+
return true;
|
|
2115
|
+
}
|
|
2116
|
+
return false;
|
|
2117
|
+
default:
|
|
2118
|
+
return false;
|
|
2119
|
+
}
|
|
2120
|
+
};
|
|
2121
|
+
var checklistIsDimissed = (latestSession) => {
|
|
2122
|
+
var _a;
|
|
2123
|
+
return (_a = latestSession == null ? void 0 : latestSession.bizEvent) == null ? void 0 : _a.find(
|
|
2124
|
+
(event) => {
|
|
2125
|
+
var _a2;
|
|
2126
|
+
return ((_a2 = event == null ? void 0 : event.event) == null ? void 0 : _a2.codeName) === import_types4.BizEvents.CHECKLIST_DISMISSED;
|
|
2127
|
+
}
|
|
2128
|
+
);
|
|
2129
|
+
};
|
|
2130
|
+
var flowIsDismissed = (latestSession) => {
|
|
2131
|
+
var _a;
|
|
2132
|
+
return (_a = latestSession == null ? void 0 : latestSession.bizEvent) == null ? void 0 : _a.find((event) => {
|
|
2133
|
+
var _a2;
|
|
2134
|
+
return ((_a2 = event == null ? void 0 : event.event) == null ? void 0 : _a2.codeName) === import_types4.BizEvents.FLOW_ENDED;
|
|
2135
|
+
});
|
|
2136
|
+
};
|
|
2137
|
+
var flowIsSeen = (latestSession) => {
|
|
2138
|
+
var _a;
|
|
2139
|
+
return (_a = latestSession == null ? void 0 : latestSession.bizEvent) == null ? void 0 : _a.find(
|
|
2140
|
+
(event) => {
|
|
2141
|
+
var _a2;
|
|
2142
|
+
return ((_a2 = event == null ? void 0 : event.event) == null ? void 0 : _a2.codeName) === import_types4.BizEvents.FLOW_STEP_SEEN;
|
|
2143
|
+
}
|
|
2144
|
+
);
|
|
2145
|
+
};
|
|
2146
|
+
var checklistIsSeen = (latestSession) => {
|
|
2147
|
+
var _a;
|
|
2148
|
+
return (_a = latestSession == null ? void 0 : latestSession.bizEvent) == null ? void 0 : _a.find(
|
|
2149
|
+
(event) => {
|
|
2150
|
+
var _a2;
|
|
2151
|
+
return ((_a2 = event == null ? void 0 : event.event) == null ? void 0 : _a2.codeName) === import_types4.BizEvents.CHECKLIST_SEEN;
|
|
2152
|
+
}
|
|
2153
|
+
);
|
|
2154
|
+
};
|
|
2155
|
+
var isValidContent = (content, contents) => {
|
|
2156
|
+
var _a;
|
|
2157
|
+
const now = /* @__PURE__ */ new Date();
|
|
2158
|
+
if (content.type === import_types4.ContentDataType.FLOW) {
|
|
2159
|
+
if (!content.steps || content.steps.length === 0) {
|
|
2160
|
+
return false;
|
|
2161
|
+
}
|
|
2162
|
+
} else {
|
|
2163
|
+
if (!content.data) {
|
|
2164
|
+
return false;
|
|
2165
|
+
}
|
|
2166
|
+
}
|
|
2167
|
+
if (!content.config.autoStartRulesSetting) {
|
|
2168
|
+
return true;
|
|
2169
|
+
}
|
|
2170
|
+
const { frequency, startIfNotComplete } = content.config.autoStartRulesSetting;
|
|
2171
|
+
const completedSessions = content.completedSessions;
|
|
2172
|
+
const dismissedSessions = content.dismissedSessions;
|
|
2173
|
+
if (startIfNotComplete && completedSessions > 0) {
|
|
2174
|
+
return false;
|
|
2175
|
+
}
|
|
2176
|
+
if (!frequency) {
|
|
2177
|
+
return true;
|
|
2178
|
+
}
|
|
2179
|
+
const contentType = content.type;
|
|
2180
|
+
const lastEventName = showEventMapping[contentType];
|
|
2181
|
+
const lastEvent = getLatestEvent(content, contents, lastEventName);
|
|
2182
|
+
const contentEvents = (_a = content.latestSession) == null ? void 0 : _a.bizEvent;
|
|
2183
|
+
if (lastEvent && frequency && frequency.atLeast && !isGreaterThenDuration(
|
|
2184
|
+
now,
|
|
2185
|
+
new Date(lastEvent.createdAt),
|
|
2186
|
+
frequency.atLeast.unit,
|
|
2187
|
+
frequency.atLeast.duration
|
|
2188
|
+
)) {
|
|
2189
|
+
return false;
|
|
2190
|
+
}
|
|
2191
|
+
if (frequency.frequency === import_types4.Frequency.ONCE) {
|
|
2192
|
+
if (dismissedSessions > 0) {
|
|
2193
|
+
return false;
|
|
2194
|
+
}
|
|
2195
|
+
return true;
|
|
2196
|
+
}
|
|
2197
|
+
const showEventName = showEventMapping[contentType];
|
|
2198
|
+
const showEvents = contentEvents == null ? void 0 : contentEvents.filter(
|
|
2199
|
+
(e) => {
|
|
2200
|
+
var _a2, _b;
|
|
2201
|
+
return ((_a2 = e == null ? void 0 : e.event) == null ? void 0 : _a2.codeName) === showEventName && (contentType === import_types4.ContentDataType.FLOW ? ((_b = e == null ? void 0 : e.data) == null ? void 0 : _b.flow_step_number) === 0 : true);
|
|
2202
|
+
}
|
|
2203
|
+
);
|
|
2204
|
+
if (!showEvents || showEvents.length === 0) {
|
|
2205
|
+
return true;
|
|
2206
|
+
}
|
|
2207
|
+
const lastShowEvent = findLatestEvent(showEvents);
|
|
2208
|
+
const lastShowEventDate = new Date(lastShowEvent.createdAt);
|
|
2209
|
+
if (frequency.frequency === import_types4.Frequency.MULTIPLE) {
|
|
2210
|
+
if (frequency.every.times && dismissedSessions >= frequency.every.times) {
|
|
2211
|
+
return false;
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
if (frequency.frequency === import_types4.Frequency.MULTIPLE || frequency.frequency === import_types4.Frequency.UNLIMITED) {
|
|
2215
|
+
if (!isGreaterThenDuration(now, lastShowEventDate, frequency.every.unit, frequency.every.duration)) {
|
|
2216
|
+
return false;
|
|
2217
|
+
}
|
|
2218
|
+
}
|
|
2219
|
+
return true;
|
|
2220
|
+
};
|
|
2221
|
+
var parseUrlParams = (url, paramName) => {
|
|
2222
|
+
if (!url || !paramName) {
|
|
2223
|
+
return null;
|
|
2224
|
+
}
|
|
2225
|
+
try {
|
|
2226
|
+
const urlObj = new URL(url);
|
|
2227
|
+
const searchParams = new URLSearchParams(urlObj.search);
|
|
2228
|
+
if (searchParams.has(paramName)) {
|
|
2229
|
+
return searchParams.get(paramName);
|
|
2230
|
+
}
|
|
2231
|
+
if (urlObj.hash) {
|
|
2232
|
+
const hashSearch = urlObj.hash.split("?")[1];
|
|
2233
|
+
if (hashSearch) {
|
|
2234
|
+
const hashParams = new URLSearchParams(hashSearch);
|
|
2235
|
+
if (hashParams.has(paramName)) {
|
|
2236
|
+
return hashParams.get(paramName);
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
return null;
|
|
2241
|
+
} catch (error) {
|
|
2242
|
+
console.error("Error parsing URL:", error);
|
|
2243
|
+
return null;
|
|
2244
|
+
}
|
|
2245
|
+
};
|
|
2246
|
+
var wait = (seconds) => {
|
|
2247
|
+
if (typeof seconds !== "number" || Number.isNaN(seconds)) {
|
|
2248
|
+
return Promise.reject(new Error("Invalid wait time: must be a number"));
|
|
2249
|
+
}
|
|
2250
|
+
if (seconds < 0) {
|
|
2251
|
+
return Promise.reject(new Error("Invalid wait time: cannot be negative"));
|
|
2252
|
+
}
|
|
2253
|
+
if (seconds === 0) {
|
|
2254
|
+
return Promise.resolve();
|
|
2255
|
+
}
|
|
2256
|
+
return new Promise((resolve2, reject) => {
|
|
2257
|
+
try {
|
|
2258
|
+
setTimeout(resolve2, seconds * 1e3);
|
|
2259
|
+
} catch (error) {
|
|
2260
|
+
reject(error);
|
|
2261
|
+
}
|
|
2262
|
+
});
|
|
2263
|
+
};
|
|
1376
2264
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1377
2265
|
0 && (module.exports = {
|
|
1378
2266
|
AbortController,
|
|
1379
2267
|
ArrayProto,
|
|
1380
2268
|
JWTLicenseSigner,
|
|
1381
2269
|
JWTLicenseValidator,
|
|
2270
|
+
PRIORITIES,
|
|
1382
2271
|
XMLHttpRequest,
|
|
1383
2272
|
absoluteUrl,
|
|
2273
|
+
activedContentCondition,
|
|
2274
|
+
activedContentRulesConditions,
|
|
2275
|
+
activedRulesConditions,
|
|
1384
2276
|
assignableWindow,
|
|
1385
2277
|
autoStartConditions,
|
|
1386
2278
|
buildConfig,
|
|
2279
|
+
checklistIsDimissed,
|
|
2280
|
+
checklistIsSeen,
|
|
1387
2281
|
cn,
|
|
1388
2282
|
conditionsIsSame,
|
|
1389
2283
|
convertSettings,
|
|
@@ -1395,6 +2289,13 @@ var JWTLicenseValidator = {
|
|
|
1395
2289
|
document,
|
|
1396
2290
|
evalCode,
|
|
1397
2291
|
fetch,
|
|
2292
|
+
filterAutoStartContent,
|
|
2293
|
+
findLatestEvent,
|
|
2294
|
+
finder,
|
|
2295
|
+
finderV2,
|
|
2296
|
+
finderX,
|
|
2297
|
+
flowIsDismissed,
|
|
2298
|
+
flowIsSeen,
|
|
1398
2299
|
formatDate,
|
|
1399
2300
|
generateAutoStateColors,
|
|
1400
2301
|
getAuthToken,
|
|
@@ -1417,6 +2318,8 @@ var JWTLicenseValidator = {
|
|
|
1417
2318
|
hexToHSLString,
|
|
1418
2319
|
hexToRGBStr,
|
|
1419
2320
|
hexToRgb,
|
|
2321
|
+
isActive,
|
|
2322
|
+
isActiveContent,
|
|
1420
2323
|
isArray,
|
|
1421
2324
|
isBoolean,
|
|
1422
2325
|
isDark,
|
|
@@ -1428,6 +2331,7 @@ var JWTLicenseValidator = {
|
|
|
1428
2331
|
isFile,
|
|
1429
2332
|
isFormData,
|
|
1430
2333
|
isFunction,
|
|
2334
|
+
isHasActivedContents,
|
|
1431
2335
|
isMatchUrlPattern,
|
|
1432
2336
|
isNull,
|
|
1433
2337
|
isNullish,
|
|
@@ -1435,20 +2339,27 @@ var JWTLicenseValidator = {
|
|
|
1435
2339
|
isObject,
|
|
1436
2340
|
isPublishedAtLeastOneEnvironment,
|
|
1437
2341
|
isPublishedInAllEnvironments,
|
|
2342
|
+
isSameContents,
|
|
1438
2343
|
isString,
|
|
1439
2344
|
isUint8Array,
|
|
1440
2345
|
isUndefined,
|
|
1441
2346
|
isUrl,
|
|
2347
|
+
isValidContent,
|
|
1442
2348
|
isValidSelector,
|
|
2349
|
+
isVisible,
|
|
1443
2350
|
location,
|
|
1444
2351
|
mergeThemeDefaultSettings,
|
|
1445
2352
|
nativeForEach,
|
|
1446
2353
|
nativeIndexOf,
|
|
1447
2354
|
navigator,
|
|
2355
|
+
parseUrlParams,
|
|
2356
|
+
parserV2,
|
|
2357
|
+
parserX,
|
|
1448
2358
|
removeAuthToken,
|
|
1449
2359
|
setAuthToken,
|
|
1450
2360
|
storage,
|
|
1451
2361
|
userAgent,
|
|
1452
2362
|
uuidV4,
|
|
2363
|
+
wait,
|
|
1453
2364
|
window
|
|
1454
2365
|
});
|