@usertour/helpers 0.0.39 → 0.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -37,12 +37,6 @@ var src_exports = {};
37
37
  __export(src_exports, {
38
38
  AbortController: () => AbortController,
39
39
  ArrayProto: () => ArrayProto,
40
- EmptyButton: () => EmptyButton,
41
- EmptyColumn: () => EmptyColumn,
42
- EmptyEmbed: () => EmptyEmbed,
43
- EmptyGroup: () => EmptyGroup,
44
- EmptyImage: () => EmptyImage,
45
- EmptyText: () => EmptyText,
46
40
  XMLHttpRequest: () => XMLHttpRequest,
47
41
  absoluteUrl: () => absoluteUrl,
48
42
  allConditionsHaveIds: () => allConditionsHaveIds,
@@ -55,19 +49,9 @@ __export(src_exports, {
55
49
  convertSettings: () => convertSettings,
56
50
  convertTimeConditionLegacyToV2: () => convertTimeConditionLegacyToV2,
57
51
  convertToCssVars: () => convertToCssVars,
58
- createNewColumn: () => createNewColumn,
59
- createNewGroup: () => createNewGroup,
60
- createStepCopy: () => createStepCopy,
61
- createValue1: () => createValue1,
62
- createValue2: () => createValue2,
63
- createValue3: () => createValue3,
64
- createValue4: () => createValue4,
65
- createValue5: () => createValue5,
66
- createValue6: () => createValue6,
67
52
  cuid: () => cuid,
68
53
  deepClone: () => deepClone,
69
54
  defaultContentConfig: () => defaultContentConfig,
70
- defaultInitialValue: () => defaultInitialValue,
71
55
  defaultStep: () => defaultStep,
72
56
  document: () => document,
73
57
  evalCode: () => evalCode,
@@ -76,19 +60,16 @@ __export(src_exports, {
76
60
  evaluateRulesConditions: () => evaluateRulesConditions,
77
61
  evaluateTimeCondition: () => evaluateTimeCondition,
78
62
  evaluateUrlCondition: () => evaluateUrlCondition,
79
- extractQuestionData: () => extractQuestionData,
80
63
  fetch: () => fetch,
81
64
  filterConditionsByType: () => filterConditionsByType,
82
65
  filterNullAttributes: () => filterNullAttributes,
83
66
  formatDate: () => formatDate,
84
67
  generateAutoStateColors: () => generateAutoStateColors,
85
- generateUniqueCopyName: () => generateUniqueCopyName,
86
68
  getAttributeType: () => getAttributeType,
87
69
  getAuthToken: () => getAuthToken,
88
70
  getCodeError: () => getCodeError,
89
71
  getContentError: () => getContentError,
90
72
  getCurrentTimeError: () => getCurrentTimeError,
91
- getDefaultDataForType: () => getDefaultDataForType,
92
73
  getElementError: () => getElementError,
93
74
  getErrorMessage: () => getErrorMessage,
94
75
  getNavitateError: () => getNavitateError,
@@ -100,16 +81,13 @@ __export(src_exports, {
100
81
  getUrlPatternError: () => getUrlPatternError,
101
82
  getUserAttrError: () => getUserAttrError,
102
83
  getWaitError: () => getWaitError,
103
- groupData: () => groupData,
104
84
  hasActionError: () => hasActionError,
105
85
  hasError: () => hasError,
106
- hasMissingRequiredData: () => hasMissingRequiredData,
107
86
  hexToHSLString: () => hexToHSLString,
108
87
  hexToRGBStr: () => hexToRGBStr,
109
88
  hexToRgb: () => hexToRgb,
110
89
  isArray: () => isArray,
111
90
  isBoolean: () => isBoolean,
112
- isClickableElement: () => isClickableElement,
113
91
  isConditionsActived: () => isConditionsActived,
114
92
  isDark: () => isDark,
115
93
  isDate: () => isDate,
@@ -121,15 +99,12 @@ __export(src_exports, {
121
99
  isFormData: () => isFormData,
122
100
  isFunction: () => isFunction,
123
101
  isMatchUrlPattern: () => isMatchUrlPattern,
124
- isMissingRequiredData: () => isMissingRequiredData,
125
102
  isNull: () => isNull,
126
103
  isNullish: () => isNullish,
127
104
  isNumber: () => isNumber,
128
105
  isObject: () => isObject,
129
106
  isPublishedAtLeastOneEnvironment: () => isPublishedAtLeastOneEnvironment,
130
107
  isPublishedInAllEnvironments: () => isPublishedInAllEnvironments,
131
- isQuestionElement: () => isQuestionElement,
132
- isRestrictedType: () => isRestrictedType,
133
108
  isString: () => isString,
134
109
  isTimeConditionDataLegacy: () => isTimeConditionDataLegacy,
135
110
  isTimeConditionDataV2: () => isTimeConditionDataV2,
@@ -144,14 +119,10 @@ __export(src_exports, {
144
119
  navigator: () => navigator,
145
120
  normalizeTimeConditionData: () => normalizeTimeConditionData,
146
121
  parseUrlParams: () => parseUrlParams,
147
- processQuestionElements: () => processQuestionElements,
148
122
  regenerateConditionIds: () => regenerateConditionIds,
149
- regenerateTarget: () => regenerateTarget,
150
- regenerateTrigger: () => regenerateTrigger,
151
123
  removeAuthToken: () => removeAuthToken,
152
124
  setAuthToken: () => setAuthToken,
153
125
  storage: () => storage,
154
- surveysValue: () => surveysValue,
155
126
  userAgent: () => userAgent,
156
127
  uuidV4: () => uuidV4,
157
128
  wait: () => wait,
@@ -1652,947 +1623,10 @@ var filterNullAttributes = (attributes) => {
1652
1623
  }
1653
1624
  return attrs;
1654
1625
  };
1655
-
1656
- // src/editor-helper.ts
1657
- var import_types7 = require("@usertour/types");
1658
- var EmptyGroup = {
1659
- element: { type: "group" },
1660
- children: []
1661
- };
1662
- var EmptyColumn = {
1663
- element: {
1664
- type: "column",
1665
- width: { type: "fill" },
1666
- justifyContent: "justify-center",
1667
- style: {}
1668
- },
1669
- children: []
1670
- };
1671
- var EmptyButton = {
1672
- element: {
1673
- type: "button",
1674
- data: {
1675
- action: "next",
1676
- text: "Next",
1677
- type: "default"
1678
- }
1679
- }
1680
- };
1681
- var EmptyImage = {
1682
- element: { type: "image", url: "" }
1683
- };
1684
- var EmptyEmbed = {
1685
- element: { type: "embed", url: "" }
1686
- };
1687
- var EmptyText = {
1688
- element: {
1689
- type: "text",
1690
- data: [{ type: "paragraph", children: [{ text: "Write text here" }] }]
1691
- }
1692
- };
1693
- var createNewGroup = (children) => {
1694
- return {
1695
- ...EmptyGroup,
1696
- id: uuidV4(),
1697
- children: [
1698
- {
1699
- ...EmptyColumn,
1700
- id: uuidV4(),
1701
- children: [...children]
1702
- }
1703
- ]
1704
- };
1705
- };
1706
- var createNewColumn = (children) => {
1707
- return {
1708
- ...EmptyColumn,
1709
- id: uuidV4(),
1710
- children: [...children]
1711
- };
1712
- };
1713
- var defaultInitialValue = [
1714
- {
1715
- ...EmptyGroup,
1716
- children: [
1717
- {
1718
- ...EmptyColumn,
1719
- children: [
1720
- {
1721
- ...EmptyText
1722
- }
1723
- ]
1724
- },
1725
- {
1726
- ...EmptyColumn,
1727
- children: [
1728
- {
1729
- ...EmptyEmbed
1730
- }
1731
- ]
1732
- }
1733
- ]
1734
- },
1735
- {
1736
- ...EmptyGroup,
1737
- children: [
1738
- {
1739
- ...EmptyColumn,
1740
- children: [
1741
- {
1742
- ...EmptyButton
1743
- }
1744
- ]
1745
- },
1746
- {
1747
- ...EmptyColumn,
1748
- children: [
1749
- {
1750
- ...EmptyImage
1751
- }
1752
- ]
1753
- }
1754
- ]
1755
- }
1756
- ];
1757
- var groupData = [
1758
- {
1759
- type: "group",
1760
- isFirst: true,
1761
- isLast: true,
1762
- children: [
1763
- {
1764
- type: "column",
1765
- width: { type: "fill", value: 50 },
1766
- justifyContent: "justify-center",
1767
- style: { marginRight: "30" },
1768
- children: [
1769
- {
1770
- type: "paragraph",
1771
- children: [{ text: "Write text here" }]
1772
- }
1773
- ]
1774
- },
1775
- {
1776
- type: "column",
1777
- width: { type: "fill", value: 50 },
1778
- justifyContent: "justify-center",
1779
- style: { marginRight: "30" },
1780
- children: [
1781
- {
1782
- type: "paragraph",
1783
- children: [{ text: "Write text here" }]
1784
- }
1785
- ]
1786
- }
1787
- ]
1788
- }
1789
- ];
1790
- var createValue1 = [
1791
- // {
1792
- // element: {
1793
- // type: "group",
1794
- // },
1795
- // children: [
1796
- // {
1797
- // element: {
1798
- // type: "column",
1799
- // width: {
1800
- // type: "fill",
1801
- // },
1802
- // justifyContent: "justify-start",
1803
- // style: {},
1804
- // },
1805
- // children: [
1806
- // {
1807
- // element: {
1808
- // type: "text",
1809
- // data: [
1810
- // {
1811
- // type: "h1",
1812
- // children: [
1813
- // {
1814
- // text: "This is Title",
1815
- // },
1816
- // ],
1817
- // },
1818
- // ],
1819
- // },
1820
- // children: null,
1821
- // },
1822
- // ],
1823
- // },
1824
- // ],
1825
- // },
1826
- {
1827
- element: {
1828
- type: "group"
1829
- },
1830
- children: [
1831
- {
1832
- element: {
1833
- type: "column",
1834
- justifyContent: "justify-start",
1835
- width: {
1836
- type: "fill"
1837
- },
1838
- style: {}
1839
- },
1840
- children: [
1841
- {
1842
- element: {
1843
- type: "text",
1844
- data: [
1845
- {
1846
- type: "paragraph",
1847
- children: [
1848
- {
1849
- text: "Write text here"
1850
- }
1851
- ]
1852
- },
1853
- {
1854
- type: "paragraph",
1855
- children: [
1856
- {
1857
- text: ""
1858
- }
1859
- ]
1860
- }
1861
- ]
1862
- }
1863
- }
1864
- ]
1865
- }
1866
- ]
1867
- }
1868
- ];
1869
- var createValue2 = [
1870
- {
1871
- element: {
1872
- type: "group"
1873
- },
1874
- children: [
1875
- {
1876
- element: {
1877
- type: "column",
1878
- justifyContent: "justify-center",
1879
- width: {
1880
- type: "fill"
1881
- },
1882
- style: {}
1883
- },
1884
- children: [
1885
- {
1886
- element: {
1887
- type: "text",
1888
- data: [
1889
- {
1890
- type: "paragraph",
1891
- children: [
1892
- {
1893
- text: "Write text here"
1894
- }
1895
- ],
1896
- align: "left"
1897
- },
1898
- {
1899
- type: "paragraph",
1900
- children: [
1901
- {
1902
- text: ""
1903
- }
1904
- ]
1905
- }
1906
- ]
1907
- }
1908
- }
1909
- ]
1910
- }
1911
- ]
1912
- },
1913
- {
1914
- element: {
1915
- type: "group"
1916
- },
1917
- children: [
1918
- {
1919
- element: {
1920
- type: "column",
1921
- width: {
1922
- type: "fill"
1923
- },
1924
- justifyContent: "justify-end",
1925
- style: {}
1926
- },
1927
- children: [
1928
- {
1929
- element: {
1930
- type: "button",
1931
- data: {
1932
- action: "goto",
1933
- text: "Prev",
1934
- type: "secondary"
1935
- }
1936
- },
1937
- children: null
1938
- },
1939
- {
1940
- element: {
1941
- type: "button",
1942
- data: {
1943
- action: "goto",
1944
- text: "Next",
1945
- type: "default"
1946
- },
1947
- margin: {
1948
- top: 0,
1949
- left: "10",
1950
- bottom: 0,
1951
- right: 0,
1952
- enabled: true
1953
- }
1954
- },
1955
- children: null
1956
- }
1957
- ]
1958
- }
1959
- ]
1960
- }
1961
- ];
1962
- var createValue3 = [
1963
- {
1964
- element: {
1965
- type: "group"
1966
- },
1967
- children: [
1968
- {
1969
- element: {
1970
- type: "column",
1971
- style: {},
1972
- width: {
1973
- type: "fill"
1974
- },
1975
- justifyContent: "justify-center"
1976
- },
1977
- children: [
1978
- {
1979
- element: {
1980
- url: "https://assets.usertour.io/5d9975de-f095-40ee-a6f9-8da3c3c38515/stick-figures-holding-word-welcome-vector-banner-text-welcome-welcome-together-people-big-colorful-letters-114865217.webp",
1981
- type: "image"
1982
- },
1983
- children: null
1984
- }
1985
- ]
1986
- }
1987
- ]
1988
- },
1989
- {
1990
- element: {
1991
- type: "group"
1992
- },
1993
- children: [
1994
- {
1995
- element: {
1996
- type: "column",
1997
- style: {},
1998
- width: {
1999
- type: "fill"
2000
- },
2001
- justifyContent: "justify-start"
2002
- },
2003
- children: [
2004
- {
2005
- element: {
2006
- data: [
2007
- {
2008
- type: "paragraph",
2009
- children: [
2010
- {
2011
- text: ""
2012
- }
2013
- ]
2014
- },
2015
- {
2016
- type: "h1",
2017
- align: "center",
2018
- children: [
2019
- {
2020
- bold: true,
2021
- text: "Welcome to Usertour!"
2022
- }
2023
- ]
2024
- },
2025
- {
2026
- type: "paragraph",
2027
- align: "center",
2028
- children: [
2029
- {
2030
- text: ""
2031
- }
2032
- ]
2033
- }
2034
- ],
2035
- type: "text"
2036
- },
2037
- children: null
2038
- }
2039
- ]
2040
- }
2041
- ]
2042
- },
2043
- {
2044
- element: {
2045
- type: "group"
2046
- },
2047
- children: [
2048
- {
2049
- element: {
2050
- type: "column",
2051
- style: {},
2052
- width: {
2053
- type: "fill"
2054
- },
2055
- justifyContent: "justify-center"
2056
- },
2057
- children: [
2058
- {
2059
- element: {
2060
- data: {
2061
- text: "Let's create a flow",
2062
- type: "default",
2063
- action: "goto",
2064
- actions: [
2065
- {
2066
- data: {
2067
- stepCvid: ""
2068
- },
2069
- type: "step-goto",
2070
- operators: "and"
2071
- }
2072
- ]
2073
- },
2074
- type: "button"
2075
- },
2076
- children: null
2077
- }
2078
- ]
2079
- }
2080
- ]
2081
- }
2082
- ];
2083
- var createValue4 = createValue3;
2084
- var createValue5 = [
2085
- {
2086
- element: {
2087
- type: "group"
2088
- },
2089
- children: [
2090
- {
2091
- element: {
2092
- type: "column",
2093
- justifyContent: "justify-center",
2094
- width: {
2095
- type: "fill"
2096
- },
2097
- style: {}
2098
- },
2099
- children: [
2100
- {
2101
- element: {
2102
- type: "text",
2103
- data: [
2104
- {
2105
- type: "paragraph",
2106
- children: [
2107
- {
2108
- text: "Welcome to Usertour!"
2109
- }
2110
- ],
2111
- align: "left"
2112
- },
2113
- {
2114
- type: "paragraph",
2115
- children: [
2116
- {
2117
- text: ""
2118
- }
2119
- ]
2120
- }
2121
- ]
2122
- }
2123
- }
2124
- ]
2125
- }
2126
- ]
2127
- },
2128
- {
2129
- element: {
2130
- type: "group"
2131
- },
2132
- children: [
2133
- {
2134
- element: {
2135
- type: "column",
2136
- width: {
2137
- type: "fill"
2138
- },
2139
- justifyContent: "justify-end",
2140
- style: {}
2141
- },
2142
- children: [
2143
- {
2144
- element: {
2145
- type: "button",
2146
- data: {
2147
- action: "goto",
2148
- text: "Prev",
2149
- type: "secondary"
2150
- }
2151
- },
2152
- children: null
2153
- },
2154
- {
2155
- element: {
2156
- type: "button",
2157
- data: {
2158
- action: "goto",
2159
- text: "Next",
2160
- type: "default"
2161
- },
2162
- margin: {
2163
- top: 0,
2164
- left: "10",
2165
- bottom: 0,
2166
- right: 0,
2167
- enabled: true
2168
- }
2169
- },
2170
- children: null
2171
- }
2172
- ]
2173
- }
2174
- ]
2175
- }
2176
- ];
2177
- var createValue6 = [
2178
- {
2179
- element: {
2180
- type: "group"
2181
- },
2182
- children: [
2183
- {
2184
- element: {
2185
- type: "column",
2186
- justifyContent: "justify-center",
2187
- width: {
2188
- type: "fill"
2189
- },
2190
- style: {}
2191
- },
2192
- children: [
2193
- {
2194
- element: {
2195
- type: "image",
2196
- url: "https://assets.usertour.io/5d9975de-f095-40ee-a6f9-8da3c3c38515/stick-figures-holding-word-welcome-vector-banner-text-welcome-welcome-together-people-big-colorful-letters-114865217.webp"
2197
- },
2198
- children: null
2199
- }
2200
- ]
2201
- }
2202
- ]
2203
- },
2204
- {
2205
- element: {
2206
- type: "group"
2207
- },
2208
- children: [
2209
- {
2210
- element: {
2211
- type: "column",
2212
- width: {
2213
- type: "fill"
2214
- },
2215
- justifyContent: "justify-start",
2216
- style: {}
2217
- },
2218
- children: [
2219
- {
2220
- element: {
2221
- type: "text",
2222
- data: [
2223
- {
2224
- type: "paragraph",
2225
- children: [
2226
- {
2227
- text: ""
2228
- }
2229
- ]
2230
- },
2231
- {
2232
- type: "paragraph",
2233
- children: [
2234
- {
2235
- text: "Title"
2236
- }
2237
- ]
2238
- }
2239
- ]
2240
- },
2241
- children: null
2242
- }
2243
- ]
2244
- }
2245
- ]
2246
- },
2247
- {
2248
- element: {
2249
- type: "group"
2250
- },
2251
- children: [
2252
- {
2253
- element: {
2254
- type: "column",
2255
- width: {
2256
- type: "fill"
2257
- },
2258
- justifyContent: "justify-start",
2259
- style: {}
2260
- },
2261
- children: [
2262
- {
2263
- element: {
2264
- type: "text",
2265
- data: [
2266
- {
2267
- type: "paragraph",
2268
- children: [
2269
- {
2270
- text: "Write text here"
2271
- }
2272
- ]
2273
- }
2274
- ]
2275
- },
2276
- children: null
2277
- }
2278
- ]
2279
- }
2280
- ]
2281
- },
2282
- {
2283
- element: {
2284
- type: "group"
2285
- },
2286
- children: [
2287
- {
2288
- element: {
2289
- type: "column",
2290
- justifyContent: "justify-end",
2291
- width: {
2292
- type: "fill"
2293
- },
2294
- style: {}
2295
- },
2296
- children: [
2297
- {
2298
- element: {
2299
- type: "button",
2300
- data: {
2301
- text: "Prev",
2302
- type: "secondary",
2303
- action: "next"
2304
- }
2305
- },
2306
- children: null
2307
- },
2308
- {
2309
- element: {
2310
- type: "button",
2311
- data: {
2312
- text: "Next",
2313
- type: "",
2314
- action: "next"
2315
- },
2316
- margin: {
2317
- top: "0",
2318
- left: "10",
2319
- bottom: 0,
2320
- right: 0,
2321
- enabled: true
2322
- }
2323
- },
2324
- children: null
2325
- }
2326
- ]
2327
- }
2328
- ]
2329
- }
2330
- ];
2331
- var surveysValue = [
2332
- {
2333
- element: {
2334
- type: "group"
2335
- },
2336
- children: [
2337
- {
2338
- element: {
2339
- type: "column",
2340
- style: {},
2341
- width: {
2342
- type: "fill"
2343
- },
2344
- justifyContent: "justify-start"
2345
- },
2346
- children: [
2347
- {
2348
- element: {
2349
- data: [
2350
- {
2351
- type: "paragraph",
2352
- children: [
2353
- {
2354
- text: ""
2355
- }
2356
- ]
2357
- },
2358
- {
2359
- type: "h1",
2360
- align: "center",
2361
- children: [
2362
- {
2363
- bold: true,
2364
- text: "How easy-to-use is our product?"
2365
- }
2366
- ]
2367
- },
2368
- {
2369
- type: "paragraph",
2370
- children: [
2371
- {
2372
- text: ""
2373
- }
2374
- ]
2375
- }
2376
- ],
2377
- type: "text"
2378
- }
2379
- }
2380
- ]
2381
- }
2382
- ]
2383
- },
2384
- {
2385
- element: {
2386
- type: "group"
2387
- },
2388
- children: [
2389
- {
2390
- element: {
2391
- type: "column",
2392
- style: {},
2393
- width: {
2394
- type: "fill"
2395
- },
2396
- justifyContent: "justify-center"
2397
- },
2398
- children: [
2399
- {
2400
- element: {
2401
- data: {
2402
- cvid: "oatboqldqf7qcxtl1kdrvsvk",
2403
- name: "sss",
2404
- actions: [
2405
- {
2406
- data: {},
2407
- type: "flow-dismis",
2408
- operators: "and"
2409
- }
2410
- ],
2411
- lowLabel: "",
2412
- highLabel: "",
2413
- bindToAttribute: true,
2414
- selectedAttribute: "nn5"
2415
- },
2416
- type: "nps"
2417
- },
2418
- children: null
2419
- }
2420
- ]
2421
- }
2422
- ]
2423
- }
2424
- ];
2425
- var isRestrictedType = (type) => {
2426
- const restrictedTypes = [
2427
- import_types7.ContentEditorElementType.NPS,
2428
- import_types7.ContentEditorElementType.STAR_RATING,
2429
- import_types7.ContentEditorElementType.SCALE,
2430
- import_types7.ContentEditorElementType.SINGLE_LINE_TEXT,
2431
- import_types7.ContentEditorElementType.MULTI_LINE_TEXT,
2432
- import_types7.ContentEditorElementType.MULTIPLE_CHOICE
2433
- ];
2434
- return restrictedTypes.includes(type);
2435
- };
2436
- var isMissingRequiredData = (element) => {
2437
- var _a, _b, _c, _d;
2438
- if (isRestrictedType(element.type)) {
2439
- return isEmptyString((_a = element.data) == null ? void 0 : _a.name);
2440
- }
2441
- if (element.type === import_types7.ContentEditorElementType.BUTTON) {
2442
- if (isEmptyString((_b = element.data) == null ? void 0 : _b.text)) {
2443
- return true;
2444
- }
2445
- if (!((_c = element == null ? void 0 : element.data) == null ? void 0 : _c.actions) || ((_d = element == null ? void 0 : element.data) == null ? void 0 : _d.actions.length) === 0) {
2446
- return true;
2447
- }
2448
- }
2449
- return false;
2450
- };
2451
- var hasMissingRequiredData = (contents) => {
2452
- return contents.some(
2453
- (group) => group.children.some(
2454
- (column) => column.children.some((item) => isMissingRequiredData(item.element))
2455
- )
2456
- );
2457
- };
2458
- var isQuestionElement = (element) => {
2459
- return element.type === import_types7.ContentEditorElementType.SINGLE_LINE_TEXT || element.type === import_types7.ContentEditorElementType.MULTI_LINE_TEXT || element.type === import_types7.ContentEditorElementType.NPS || element.type === import_types7.ContentEditorElementType.STAR_RATING || element.type === import_types7.ContentEditorElementType.SCALE || element.type === import_types7.ContentEditorElementType.MULTIPLE_CHOICE;
2460
- };
2461
- var isClickableElement = (element) => {
2462
- return element.type === import_types7.ContentEditorElementType.BUTTON || isQuestionElement(element);
2463
- };
2464
- var extractQuestionData = (data) => {
2465
- const result = [];
2466
- function isQuestionRootElement(item) {
2467
- return "element" in item && isQuestionElement(item.element);
2468
- }
2469
- function traverse(item) {
2470
- if (isQuestionRootElement(item)) {
2471
- result.push(item.element);
2472
- }
2473
- if ("children" in item && item.children) {
2474
- for (const child of item.children) {
2475
- traverse(child);
2476
- }
2477
- }
2478
- }
2479
- for (const item of data) {
2480
- traverse(item);
2481
- }
2482
- return result;
2483
- };
2484
- var getDefaultDataForType = (type) => {
2485
- switch (type) {
2486
- case "modal":
2487
- return createValue4;
2488
- case "hidden":
2489
- return createValue2;
2490
- default:
2491
- return createValue1;
2492
- }
2493
- };
2494
- var processQuestionElements = (contents) => {
2495
- if (!contents || !isArray(contents) || contents.length === 0) {
2496
- return [];
2497
- }
2498
- return contents.map((group) => ({
2499
- ...group,
2500
- children: group.children.map((column) => ({
2501
- ...column,
2502
- children: column.children.map((item) => {
2503
- var _a, _b;
2504
- const element = item.element;
2505
- if (isQuestionElement(element)) {
2506
- const questionElement = element;
2507
- const updatedElement = {
2508
- ...questionElement,
2509
- data: {
2510
- ...questionElement.data,
2511
- cvid: cuid(),
2512
- ...((_a = questionElement.data) == null ? void 0 : _a.actions) && isArray(questionElement.data.actions) ? { actions: regenerateConditionIds(questionElement.data.actions) } : {}
2513
- }
2514
- };
2515
- return {
2516
- ...item,
2517
- element: updatedElement
2518
- };
2519
- }
2520
- if (element.type === import_types7.ContentEditorElementType.BUTTON) {
2521
- const buttonElement = element;
2522
- if (((_b = buttonElement.data) == null ? void 0 : _b.actions) && isArray(buttonElement.data.actions)) {
2523
- return {
2524
- ...item,
2525
- element: {
2526
- ...buttonElement,
2527
- data: {
2528
- ...buttonElement.data,
2529
- actions: regenerateConditionIds(buttonElement.data.actions)
2530
- }
2531
- }
2532
- };
2533
- }
2534
- }
2535
- return item;
2536
- })
2537
- }))
2538
- }));
2539
- };
2540
- var regenerateTrigger = (trigger) => {
2541
- return trigger.map((t) => ({
2542
- ...t,
2543
- id: cuid(),
2544
- conditions: regenerateConditionIds(t.conditions),
2545
- actions: regenerateConditionIds(t.actions)
2546
- }));
2547
- };
2548
- var regenerateTarget = (target) => {
2549
- if (!target) {
2550
- return void 0;
2551
- }
2552
- if (target.actions && isArray(target.actions)) {
2553
- return {
2554
- ...target,
2555
- actions: regenerateConditionIds(target.actions)
2556
- };
2557
- }
2558
- return target;
2559
- };
2560
- var generateUniqueCopyName = (originalName, existingNames) => {
2561
- let name = `${originalName} (copy)`;
2562
- if (existingNames == null ? void 0 : existingNames.includes(name)) {
2563
- let number = 2;
2564
- while (existingNames.includes(`${originalName} (copy ${number})`)) {
2565
- number++;
2566
- }
2567
- name = `${originalName} (copy ${number})`;
2568
- }
2569
- return name;
2570
- };
2571
- var createStepCopy = (originalStep, sequence, existingStepNames) => {
2572
- const { id, cvid, updatedAt, createdAt, ...rest } = originalStep;
2573
- const name = generateUniqueCopyName(originalStep == null ? void 0 : originalStep.name, existingStepNames);
2574
- const trigger = (originalStep == null ? void 0 : originalStep.trigger) ? regenerateTrigger(originalStep == null ? void 0 : originalStep.trigger) : [];
2575
- const data = (originalStep == null ? void 0 : originalStep.data) ? processQuestionElements(originalStep == null ? void 0 : originalStep.data) : [];
2576
- const target = regenerateTarget(originalStep == null ? void 0 : originalStep.target);
2577
- return {
2578
- ...rest,
2579
- data,
2580
- trigger,
2581
- target,
2582
- name,
2583
- sequence
2584
- };
2585
- };
2586
1626
  // Annotate the CommonJS export names for ESM import in node:
2587
1627
  0 && (module.exports = {
2588
1628
  AbortController,
2589
1629
  ArrayProto,
2590
- EmptyButton,
2591
- EmptyColumn,
2592
- EmptyEmbed,
2593
- EmptyGroup,
2594
- EmptyImage,
2595
- EmptyText,
2596
1630
  XMLHttpRequest,
2597
1631
  absoluteUrl,
2598
1632
  allConditionsHaveIds,
@@ -2605,19 +1639,9 @@ var createStepCopy = (originalStep, sequence, existingStepNames) => {
2605
1639
  convertSettings,
2606
1640
  convertTimeConditionLegacyToV2,
2607
1641
  convertToCssVars,
2608
- createNewColumn,
2609
- createNewGroup,
2610
- createStepCopy,
2611
- createValue1,
2612
- createValue2,
2613
- createValue3,
2614
- createValue4,
2615
- createValue5,
2616
- createValue6,
2617
1642
  cuid,
2618
1643
  deepClone,
2619
1644
  defaultContentConfig,
2620
- defaultInitialValue,
2621
1645
  defaultStep,
2622
1646
  document,
2623
1647
  evalCode,
@@ -2626,19 +1650,16 @@ var createStepCopy = (originalStep, sequence, existingStepNames) => {
2626
1650
  evaluateRulesConditions,
2627
1651
  evaluateTimeCondition,
2628
1652
  evaluateUrlCondition,
2629
- extractQuestionData,
2630
1653
  fetch,
2631
1654
  filterConditionsByType,
2632
1655
  filterNullAttributes,
2633
1656
  formatDate,
2634
1657
  generateAutoStateColors,
2635
- generateUniqueCopyName,
2636
1658
  getAttributeType,
2637
1659
  getAuthToken,
2638
1660
  getCodeError,
2639
1661
  getContentError,
2640
1662
  getCurrentTimeError,
2641
- getDefaultDataForType,
2642
1663
  getElementError,
2643
1664
  getErrorMessage,
2644
1665
  getNavitateError,
@@ -2650,16 +1671,13 @@ var createStepCopy = (originalStep, sequence, existingStepNames) => {
2650
1671
  getUrlPatternError,
2651
1672
  getUserAttrError,
2652
1673
  getWaitError,
2653
- groupData,
2654
1674
  hasActionError,
2655
1675
  hasError,
2656
- hasMissingRequiredData,
2657
1676
  hexToHSLString,
2658
1677
  hexToRGBStr,
2659
1678
  hexToRgb,
2660
1679
  isArray,
2661
1680
  isBoolean,
2662
- isClickableElement,
2663
1681
  isConditionsActived,
2664
1682
  isDark,
2665
1683
  isDate,
@@ -2671,15 +1689,12 @@ var createStepCopy = (originalStep, sequence, existingStepNames) => {
2671
1689
  isFormData,
2672
1690
  isFunction,
2673
1691
  isMatchUrlPattern,
2674
- isMissingRequiredData,
2675
1692
  isNull,
2676
1693
  isNullish,
2677
1694
  isNumber,
2678
1695
  isObject,
2679
1696
  isPublishedAtLeastOneEnvironment,
2680
1697
  isPublishedInAllEnvironments,
2681
- isQuestionElement,
2682
- isRestrictedType,
2683
1698
  isString,
2684
1699
  isTimeConditionDataLegacy,
2685
1700
  isTimeConditionDataV2,
@@ -2694,14 +1709,10 @@ var createStepCopy = (originalStep, sequence, existingStepNames) => {
2694
1709
  navigator,
2695
1710
  normalizeTimeConditionData,
2696
1711
  parseUrlParams,
2697
- processQuestionElements,
2698
1712
  regenerateConditionIds,
2699
- regenerateTarget,
2700
- regenerateTrigger,
2701
1713
  removeAuthToken,
2702
1714
  setAuthToken,
2703
1715
  storage,
2704
- surveysValue,
2705
1716
  userAgent,
2706
1717
  uuidV4,
2707
1718
  wait,