@activepieces/piece-date-helper 0.0.1 → 0.0.2
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/package.json +11 -10
- package/src/index.js +5 -1
- package/src/index.js.map +1 -1
- package/src/lib/actions/next-day-of-week.d.ts +8 -0
- package/src/lib/actions/next-day-of-week.js +95 -0
- package/src/lib/actions/next-day-of-week.js.map +1 -0
- package/src/lib/actions/next-day-of-year.d.ts +9 -0
- package/src/lib/actions/next-day-of-year.js +109 -0
- package/src/lib/actions/next-day-of-year.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@activepieces/piece-date-helper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@sinclair/typebox": "
|
|
6
|
-
"axios": "1.
|
|
7
|
-
"dayjs": "
|
|
8
|
-
"is-base64": "
|
|
9
|
-
"
|
|
5
|
+
"@sinclair/typebox": "0.26.8",
|
|
6
|
+
"axios": "^1.6.0",
|
|
7
|
+
"dayjs": "1.11.9",
|
|
8
|
+
"is-base64": "1.1.0",
|
|
9
|
+
"lodash": "4.17.21",
|
|
10
|
+
"nanoid": "3.3.6",
|
|
10
11
|
"semver": "7.5.4",
|
|
11
|
-
"@activepieces/pieces-framework": "0.
|
|
12
|
-
"@activepieces/shared": "0.
|
|
13
|
-
"tslib": "2.6.
|
|
12
|
+
"@activepieces/pieces-framework": "0.7.4",
|
|
13
|
+
"@activepieces/shared": "0.10.40",
|
|
14
|
+
"tslib": "2.6.2"
|
|
14
15
|
},
|
|
15
16
|
"main": "./src/index.js",
|
|
16
|
-
"
|
|
17
|
+
"type": "commonjs"
|
|
17
18
|
}
|
package/src/index.js
CHANGED
|
@@ -7,19 +7,23 @@ const format_date_1 = require("./lib/actions/format-date");
|
|
|
7
7
|
const extract_date_parts_1 = require("./lib/actions/extract-date-parts");
|
|
8
8
|
const date_difference_1 = require("./lib/actions/date-difference");
|
|
9
9
|
const add_subtract_date_1 = require("./lib/actions/add-subtract-date");
|
|
10
|
+
const next_day_of_week_1 = require("./lib/actions/next-day-of-week");
|
|
11
|
+
const next_day_of_year_1 = require("./lib/actions/next-day-of-year");
|
|
10
12
|
const description = `Effortlessly manipulate, format, and extract time units for all your date and time needs.`;
|
|
11
13
|
exports.utilityDate = (0, pieces_framework_1.createPiece)({
|
|
12
14
|
displayName: 'Date Helper',
|
|
13
15
|
auth: pieces_framework_1.PieceAuth.None(),
|
|
14
16
|
minimumSupportedRelease: '0.8.0',
|
|
15
17
|
logoUrl: 'https://cdn.activepieces.com/pieces/calendar_piece.svg',
|
|
16
|
-
authors: ['Salem-Alaa'],
|
|
18
|
+
authors: ['Salem-Alaa', 'joeworkman'],
|
|
17
19
|
actions: [
|
|
18
20
|
get_current_date_1.getCurrentDate,
|
|
19
21
|
format_date_1.formatDateAction,
|
|
20
22
|
extract_date_parts_1.extractDateParts,
|
|
21
23
|
date_difference_1.dateDifferenceAction,
|
|
22
24
|
add_subtract_date_1.addSubtractDateAction,
|
|
25
|
+
next_day_of_week_1.nextDayofWeek,
|
|
26
|
+
next_day_of_year_1.nextDayofYear,
|
|
23
27
|
],
|
|
24
28
|
triggers: [],
|
|
25
29
|
description: description,
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/date-helper/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAAwE;AACxE,qEAAgE;AAChE,2DAA6D;AAC7D,yEAAoE;AACpE,mEAAqE;AACrE,uEAAwE;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/pieces/date-helper/src/index.ts"],"names":[],"mappings":";;;AAAA,qEAAwE;AACxE,qEAAgE;AAChE,2DAA6D;AAC7D,yEAAoE;AACpE,mEAAqE;AACrE,uEAAwE;AACxE,qEAA+D;AAC/D,qEAA+D;AAE/D,MAAM,WAAW,GAAG,2FAA2F,CAAC;AAEnG,QAAA,WAAW,GAAG,IAAA,8BAAW,EAAC;IACrC,WAAW,EAAE,aAAa;IAC1B,IAAI,EAAE,4BAAS,CAAC,IAAI,EAAE;IACtB,uBAAuB,EAAE,OAAO;IAChC,OAAO,EAAE,wDAAwD;IACjE,OAAO,EAAE,CAAC,YAAY,EAAC,YAAY,CAAC;IACpC,OAAO,EAAE;QACP,iCAAc;QACd,8BAAgB;QAChB,qCAAgB;QAChB,sCAAoB;QACpB,yCAAqB;QACxB,gCAAa;QACb,gCAAa;KACX;IACD,QAAQ,EAAE,EAAE;IACZ,WAAW,EAAE,WAAW;CACzB,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { timeFormat } from '../common';
|
|
2
|
+
export declare const nextDayofWeek: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").PieceAuthProperty, {
|
|
3
|
+
weekday: import("@activepieces/pieces-framework").StaticDropdownProperty<number, true>;
|
|
4
|
+
time: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
5
|
+
currentTime: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
6
|
+
timeFormat: import("@activepieces/pieces-framework").StaticDropdownProperty<timeFormat, true>;
|
|
7
|
+
timeZone: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false> | import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nextDayofWeek = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
exports.nextDayofWeek = (0, pieces_framework_1.createAction)({
|
|
8
|
+
name: 'next_day_of_week',
|
|
9
|
+
displayName: 'Next Day of Week',
|
|
10
|
+
description: 'Get the date and time of the next day of the week',
|
|
11
|
+
props: {
|
|
12
|
+
weekday: pieces_framework_1.Property.StaticDropdown({
|
|
13
|
+
displayName: 'Weekday',
|
|
14
|
+
description: "The weekday that you would like to get the date and time of.",
|
|
15
|
+
options: {
|
|
16
|
+
options: [
|
|
17
|
+
{ label: 'Sunday', value: 0 },
|
|
18
|
+
{ label: 'Monday', value: 1 },
|
|
19
|
+
{ label: 'Tuesday', value: 2 },
|
|
20
|
+
{ label: 'Wednesday', value: 3 },
|
|
21
|
+
{ label: 'Thursday', value: 4 },
|
|
22
|
+
{ label: 'Friday', value: 5 },
|
|
23
|
+
{ label: 'Saturday', value: 6 },
|
|
24
|
+
],
|
|
25
|
+
},
|
|
26
|
+
required: true,
|
|
27
|
+
}),
|
|
28
|
+
time: pieces_framework_1.Property.ShortText({
|
|
29
|
+
displayName: '24h Time',
|
|
30
|
+
description: "The time that you would like to get the date and time of. This must be in 24h format.",
|
|
31
|
+
required: false,
|
|
32
|
+
defaultValue: "00:00",
|
|
33
|
+
validators: [pieces_framework_1.Validators.pattern(/^\d\d:\d\d$/)],
|
|
34
|
+
}),
|
|
35
|
+
currentTime: pieces_framework_1.Property.Checkbox({
|
|
36
|
+
displayName: 'Use Current Time',
|
|
37
|
+
description: 'If checked, the current time will be used instead of the time specified above.',
|
|
38
|
+
required: false,
|
|
39
|
+
defaultValue: false
|
|
40
|
+
}),
|
|
41
|
+
timeFormat: pieces_framework_1.Property.StaticDropdown({
|
|
42
|
+
displayName: 'To Time Format',
|
|
43
|
+
description: common_1.timeFormatDescription,
|
|
44
|
+
options: {
|
|
45
|
+
options: common_1.optionalTimeFormats,
|
|
46
|
+
},
|
|
47
|
+
required: true,
|
|
48
|
+
defaultValue: common_1.timeFormat.format00,
|
|
49
|
+
}),
|
|
50
|
+
timeZone: pieces_framework_1.Property.StaticDropdown({
|
|
51
|
+
displayName: 'Time Zone',
|
|
52
|
+
options: {
|
|
53
|
+
options: common_1.timeZoneOptions,
|
|
54
|
+
},
|
|
55
|
+
required: true,
|
|
56
|
+
defaultValue: 'UTC',
|
|
57
|
+
}),
|
|
58
|
+
},
|
|
59
|
+
run(context) {
|
|
60
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
const timeFormat = context.propsValue.timeFormat;
|
|
62
|
+
const timeZone = context.propsValue.timeZone;
|
|
63
|
+
const dayIndex = context.propsValue.weekday;
|
|
64
|
+
const currentTime = context.propsValue.currentTime;
|
|
65
|
+
let time = context.propsValue.time;
|
|
66
|
+
const nextOccurance = new Date();
|
|
67
|
+
if (currentTime === true) {
|
|
68
|
+
time = `${nextOccurance.getHours()}:${nextOccurance.getMinutes()}`;
|
|
69
|
+
}
|
|
70
|
+
const [hours, minutes] = time.split(':').map(Number);
|
|
71
|
+
// Validate inputs
|
|
72
|
+
if (dayIndex < 0 || dayIndex > 6 || hours < 0 || hours > 23 || minutes < 0 || minutes > 59) {
|
|
73
|
+
throw new Error(`Invalid input \ndayIndex: ${dayIndex} \nhours: ${hours} \nminutes: ${minutes}`);
|
|
74
|
+
}
|
|
75
|
+
if (typeof timeFormat !== 'string') {
|
|
76
|
+
throw new Error(`Output format is not a string \noutput format: ${JSON.stringify(timeFormat)}`);
|
|
77
|
+
}
|
|
78
|
+
// Set the time
|
|
79
|
+
nextOccurance.setHours(hours, minutes, 0, 0);
|
|
80
|
+
// Calculate the day difference
|
|
81
|
+
let dayDiff = dayIndex - nextOccurance.getDay();
|
|
82
|
+
console.log("dayDiff:", dayDiff, nextOccurance, new Date());
|
|
83
|
+
if (dayDiff < 0 || (dayDiff === 0 && nextOccurance.getTime() < new Date().getTime())) {
|
|
84
|
+
// If it's a past day in the week or today but past time, move to next week
|
|
85
|
+
dayDiff += 7;
|
|
86
|
+
}
|
|
87
|
+
// Set the date to the next occurrence of the given day
|
|
88
|
+
nextOccurance.setDate(nextOccurance.getDate() + dayDiff);
|
|
89
|
+
// Set the time for the timezone
|
|
90
|
+
nextOccurance.setMinutes(nextOccurance.getMinutes() + (0, common_1.timeDiff)('UTC', timeZone));
|
|
91
|
+
return { result: (0, common_1.createNewDate)(nextOccurance, timeFormat) };
|
|
92
|
+
});
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
//# sourceMappingURL=next-day-of-week.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-day-of-week.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/date-helper/src/lib/actions/next-day-of-week.ts"],"names":[],"mappings":";;;;AAAA,qEAAoF;AACpF,sCAA6H;AAEhH,QAAA,aAAa,GAAG,IAAA,+BAAY,EAAC;IACzC,IAAI,EAAU,kBAAkB;IAChC,WAAW,EAAG,kBAAkB;IAChC,WAAW,EAAG,mDAAmD;IACjE,KAAK,EAAS;QACP,OAAO,EAAE,2BAAQ,CAAC,cAAc,CAAC;YACtC,WAAW,EAAG,SAAS;YACvB,WAAW,EAAG,8DAA8D;YACnE,OAAO,EAAO;gBACV,OAAO,EAAE;oBACL,EAAE,KAAK,EAAE,QAAQ,EAAK,KAAK,EAAE,CAAC,EAAE;oBAChC,EAAE,KAAK,EAAE,QAAQ,EAAK,KAAK,EAAE,CAAC,EAAE;oBAChC,EAAE,KAAK,EAAE,SAAS,EAAI,KAAK,EAAE,CAAC,EAAE;oBAChC,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,CAAC,EAAE;oBAChC,EAAE,KAAK,EAAE,UAAU,EAAG,KAAK,EAAE,CAAC,EAAE;oBAChC,EAAE,KAAK,EAAE,QAAQ,EAAK,KAAK,EAAE,CAAC,EAAE;oBAChC,EAAE,KAAK,EAAE,UAAU,EAAG,KAAK,EAAE,CAAC,EAAE;iBACnC;aACJ;YACD,QAAQ,EAAO,IAAI;SACtB,CAAC;QACF,IAAI,EAAE,2BAAQ,CAAC,SAAS,CAAC;YACrB,WAAW,EAAI,UAAU;YACzB,WAAW,EAAI,uFAAuF;YACtG,QAAQ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,IAAA,sBAAa,EAAC,aAAa,EAAE,UAAU,CAAC,EAAE,CAAC;QACnE,CAAC;KAAA;CACD,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { timeFormat } from '../common';
|
|
2
|
+
export declare const nextDayofYear: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").PieceAuthProperty, {
|
|
3
|
+
month: import("@activepieces/pieces-framework").StaticDropdownProperty<number, true>;
|
|
4
|
+
day: import("@activepieces/pieces-framework").NumberProperty<true>;
|
|
5
|
+
time: import("@activepieces/pieces-framework").ShortTextProperty<false>;
|
|
6
|
+
currentTime: import("@activepieces/pieces-framework").CheckboxProperty<false>;
|
|
7
|
+
timeFormat: import("@activepieces/pieces-framework").StaticDropdownProperty<timeFormat, true>;
|
|
8
|
+
timeZone: import("@activepieces/pieces-framework").StaticDropdownProperty<string, false> | import("@activepieces/pieces-framework").StaticDropdownProperty<string, true>;
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.nextDayofYear = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const pieces_framework_1 = require("@activepieces/pieces-framework");
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
exports.nextDayofYear = (0, pieces_framework_1.createAction)({
|
|
8
|
+
name: 'next_day_of_year',
|
|
9
|
+
displayName: 'Next Day of Year',
|
|
10
|
+
description: 'Get the date and time of the next day of the year',
|
|
11
|
+
props: {
|
|
12
|
+
month: pieces_framework_1.Property.StaticDropdown({
|
|
13
|
+
displayName: 'Month',
|
|
14
|
+
description: "The month that you would like to get the date and time of.",
|
|
15
|
+
options: {
|
|
16
|
+
options: [
|
|
17
|
+
{ label: 'January', value: 1 },
|
|
18
|
+
{ label: 'February', value: 2 },
|
|
19
|
+
{ label: 'March', value: 3 },
|
|
20
|
+
{ label: 'April', value: 4 },
|
|
21
|
+
{ label: 'May', value: 5 },
|
|
22
|
+
{ label: 'June', value: 6 },
|
|
23
|
+
{ label: 'July', value: 7 },
|
|
24
|
+
{ label: 'August', value: 8 },
|
|
25
|
+
{ label: 'September', value: 9 },
|
|
26
|
+
{ label: 'October', value: 10 },
|
|
27
|
+
{ label: 'November', value: 11 },
|
|
28
|
+
{ label: 'December', value: 12 },
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
required: true,
|
|
32
|
+
}),
|
|
33
|
+
day: pieces_framework_1.Property.Number({
|
|
34
|
+
displayName: 'Day of Month',
|
|
35
|
+
description: "The day of the month that you would like to get the date and time of.",
|
|
36
|
+
required: true,
|
|
37
|
+
defaultValue: 1,
|
|
38
|
+
validators: [
|
|
39
|
+
pieces_framework_1.Validators.minValue(1),
|
|
40
|
+
pieces_framework_1.Validators.maxValue(31),
|
|
41
|
+
],
|
|
42
|
+
}),
|
|
43
|
+
time: pieces_framework_1.Property.ShortText({
|
|
44
|
+
displayName: '24h Time',
|
|
45
|
+
description: "The time that you would like to get the date and time of. This must be in 24h format.",
|
|
46
|
+
required: false,
|
|
47
|
+
defaultValue: "00:00",
|
|
48
|
+
validators: [pieces_framework_1.Validators.pattern(/^\d\d:\d\d$/)],
|
|
49
|
+
}),
|
|
50
|
+
currentTime: pieces_framework_1.Property.Checkbox({
|
|
51
|
+
displayName: 'Use Current Time',
|
|
52
|
+
description: 'If checked, the current time will be used instead of the time specified above.',
|
|
53
|
+
required: false,
|
|
54
|
+
defaultValue: false
|
|
55
|
+
}),
|
|
56
|
+
timeFormat: pieces_framework_1.Property.StaticDropdown({
|
|
57
|
+
displayName: 'To Time Format',
|
|
58
|
+
description: common_1.timeFormatDescription,
|
|
59
|
+
options: {
|
|
60
|
+
options: common_1.optionalTimeFormats,
|
|
61
|
+
},
|
|
62
|
+
required: true,
|
|
63
|
+
defaultValue: common_1.timeFormat.format00,
|
|
64
|
+
}),
|
|
65
|
+
timeZone: pieces_framework_1.Property.StaticDropdown({
|
|
66
|
+
displayName: 'Time Zone',
|
|
67
|
+
options: {
|
|
68
|
+
options: common_1.timeZoneOptions,
|
|
69
|
+
},
|
|
70
|
+
required: true,
|
|
71
|
+
defaultValue: 'UTC',
|
|
72
|
+
}),
|
|
73
|
+
},
|
|
74
|
+
run(context) {
|
|
75
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
const timeFormat = context.propsValue.timeFormat;
|
|
77
|
+
const timeZone = context.propsValue.timeZone;
|
|
78
|
+
const currentTime = context.propsValue.currentTime;
|
|
79
|
+
const month = context.propsValue.month;
|
|
80
|
+
const day = context.propsValue.day;
|
|
81
|
+
let time = context.propsValue.time;
|
|
82
|
+
const now = new Date();
|
|
83
|
+
if (currentTime === true) {
|
|
84
|
+
time = `${now.getHours()}:${now.getMinutes()}`;
|
|
85
|
+
}
|
|
86
|
+
const [hours, minutes] = time.split(':').map(Number);
|
|
87
|
+
// Validate inputs
|
|
88
|
+
if (month < 1 || month > 12 || day < 1 || day > 31) {
|
|
89
|
+
throw new Error(`Invalid input \nmonth: ${month} \nday: ${day}`);
|
|
90
|
+
}
|
|
91
|
+
if (typeof timeFormat !== 'string') {
|
|
92
|
+
throw new Error(`Output format is not a string \noutput format: ${JSON.stringify(timeFormat)}`);
|
|
93
|
+
}
|
|
94
|
+
const currentYear = now.getFullYear();
|
|
95
|
+
// Create a date object for the next occurrence
|
|
96
|
+
const nextOccurrence = new Date(currentYear, month - 1, day);
|
|
97
|
+
nextOccurrence.setHours(hours, minutes, 0, 0);
|
|
98
|
+
// Check if the next occurrence is already past in the current year
|
|
99
|
+
if (nextOccurrence.getTime() < now.getTime()) {
|
|
100
|
+
// Move to the next year
|
|
101
|
+
nextOccurrence.setFullYear(currentYear + 1);
|
|
102
|
+
}
|
|
103
|
+
// Set the time for the timezone
|
|
104
|
+
nextOccurrence.setMinutes(nextOccurrence.getMinutes() + (0, common_1.timeDiff)('UTC', timeZone));
|
|
105
|
+
return { result: (0, common_1.createNewDate)(nextOccurrence, timeFormat) };
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
//# sourceMappingURL=next-day-of-year.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"next-day-of-year.js","sourceRoot":"","sources":["../../../../../../../packages/pieces/date-helper/src/lib/actions/next-day-of-year.ts"],"names":[],"mappings":";;;;AAAA,qEAAoF;AACpF,sCAA6H;AAEhH,QAAA,aAAa,GAAG,IAAA,+BAAY,EAAC;IACzC,IAAI,EAAU,kBAAkB;IAChC,WAAW,EAAG,kBAAkB;IAChC,WAAW,EAAG,mDAAmD;IACjE,KAAK,EAAS;QACP,KAAK,EAAE,2BAAQ,CAAC,cAAc,CAAC;YACpC,WAAW,EAAG,OAAO;YACrB,WAAW,EAAG,4DAA4D;YACjE,OAAO,EAAO;gBACV,OAAO,EAAE;oBACL,EAAE,KAAK,EAAE,SAAS,EAAM,KAAK,EAAE,CAAC,EAAE;oBAClC,EAAE,KAAK,EAAE,UAAU,EAAK,KAAK,EAAE,CAAC,EAAE;oBAClC,EAAE,KAAK,EAAE,OAAO,EAAI,KAAK,EAAE,CAAC,EAAE;oBAC9B,EAAE,KAAK,EAAE,OAAO,EAAK,KAAK,EAAE,CAAC,EAAE;oBAC/B,EAAE,KAAK,EAAE,KAAK,EAAO,KAAK,EAAE,CAAC,EAAE;oBAC/B,EAAE,KAAK,EAAE,MAAM,EAAK,KAAK,EAAE,CAAC,EAAE;oBAC9B,EAAE,KAAK,EAAE,MAAM,EAAK,KAAK,EAAE,CAAC,EAAE;oBAC9B,EAAE,KAAK,EAAE,QAAQ,EAAG,KAAK,EAAE,CAAC,EAAE;oBAC9B,EAAE,KAAK,EAAE,WAAW,EAAG,KAAK,EAAE,CAAC,EAAE;oBACjC,EAAE,KAAK,EAAE,SAAS,EAAK,KAAK,EAAE,EAAE,EAAE;oBAClC,EAAE,KAAK,EAAE,UAAU,EAAI,KAAK,EAAE,EAAE,EAAE;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