@activepieces/piece-slack 0.7.12 → 0.7.14

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 CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@activepieces/piece-slack",
3
- "version": "0.7.12",
3
+ "version": "0.7.14",
4
4
  "dependencies": {
5
5
  "@anthropic-ai/sdk": "0.33.1",
6
6
  "@sinclair/typebox": "0.34.11",
7
7
  "@slack/web-api": "7.0.4",
8
- "axios": "1.7.8",
8
+ "axios": "1.8.2",
9
9
  "axios-retry": "4.4.1",
10
10
  "deepmerge-ts": "7.1.0",
11
11
  "mime-types": "2.1.35",
@@ -15,9 +15,9 @@
15
15
  "semver": "7.6.0",
16
16
  "slackify-markdown": "4.4.0",
17
17
  "zod": "3.23.8",
18
- "@activepieces/pieces-common": "0.4.1",
19
- "@activepieces/pieces-framework": "0.7.43",
20
- "@activepieces/shared": "0.10.149",
18
+ "@activepieces/pieces-common": "0.4.2",
19
+ "@activepieces/pieces-framework": "0.7.45",
20
+ "@activepieces/shared": "0.10.153",
21
21
  "tslib": "1.14.1"
22
22
  },
23
23
  "overrides": {
package/src/index.js CHANGED
@@ -27,6 +27,8 @@ const find_user_by_handle_1 = require("./lib/actions/find-user-by-handle");
27
27
  const set_user_status_1 = require("./lib/actions/set-user-status");
28
28
  const new_mention_1 = require("./lib/triggers/new-mention");
29
29
  const markdown_to_slack_format_1 = require("./lib/actions/markdown-to-slack-format");
30
+ const new_command_1 = require("./lib/triggers/new-command");
31
+ const get_file_1 = require("./lib/actions/get-file");
30
32
  exports.slackAuth = pieces_framework_1.PieceAuth.OAuth2({
31
33
  description: '',
32
34
  authUrl: 'https://slack.com/oauth/v2/authorize?user_scope=search:read,users.profile:write,reactions:read',
@@ -52,6 +54,7 @@ exports.slackAuth = pieces_framework_1.PieceAuth.OAuth2({
52
54
  'files:read',
53
55
  'users:read.email',
54
56
  'reactions:write',
57
+ 'usergroups:read'
55
58
  ],
56
59
  });
57
60
  exports.slack = (0, pieces_framework_1.createPiece)({
@@ -108,6 +111,7 @@ exports.slack = (0, pieces_framework_1.createPiece)({
108
111
  request_action_direct_message_1.requestActionDirectMessageAction,
109
112
  request_action_message_1.requestActionMessageAction,
110
113
  upload_file_1.uploadFile,
114
+ get_file_1.getFileAction,
111
115
  search_messages_1.searchMessages,
112
116
  find_user_by_email_1.findUserByEmailAction,
113
117
  find_user_by_handle_1.findUserByHandleAction,
@@ -145,6 +149,6 @@ exports.slack = (0, pieces_framework_1.createPiece)({
145
149
  },
146
150
  }),
147
151
  ],
148
- triggers: [new_message_1.newMessage, new_mention_1.newMention, new_reaction_added_1.newReactionAdded, new_channel_1.channelCreated],
152
+ triggers: [new_message_1.newMessage, new_mention_1.newMention, new_reaction_added_1.newReactionAdded, new_channel_1.channelCreated, new_command_1.newCommand],
149
153
  });
150
154
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/slack/src/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAwE;AACxE,qEAKwC;AACxC,iDAAqD;AACrD,sEAAiC;AACjC,+FAA+F;AAC/F,iFAAkF;AAClF,mGAAmG;AACnG,qFAA0F;AAC1F,yFAAwF;AACxF,2EAA2E;AAC3E,4DAAwD;AACxD,0EAAqE;AACrE,2DAAuD;AACvD,mEAA+D;AAC/D,iEAA6D;AAC7D,yEAAyE;AACzE,iEAAmE;AACnE,iEAAmE;AACnE,4DAA4D;AAC5D,mFAAkF;AAClF,2EAAsE;AACtE,2EAA2E;AAC3E,mEAAoE;AACpE,4DAAwD;AACxD,qFAA+E;AAElE,QAAA,SAAS,GAAG,4BAAS,CAAC,MAAM,CAAC;IACxC,WAAW,EAAE,EAAE;IACf,OAAO,EACL,gGAAgG;IAClG,QAAQ,EAAE,uCAAuC;IACjD,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE;QAC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AAI;oBACd,YAAY,EAAE,KAAK;iBACpB,CAAC;aACH;SACF,CAAC;KACH;IACD,QAAQ,EAAE,CAAC,wBAAU,EAAE,wBAAU,EAAE,qCAAgB,EAAE,4BAAc,CAAC;CACrE,CAAC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/pieces/community/slack/src/index.ts"],"names":[],"mappings":";;;;AAAA,+DAAwE;AACxE,qEAKwC;AACxC,iDAAqD;AACrD,sEAAiC;AACjC,+FAA+F;AAC/F,iFAAkF;AAClF,mGAAmG;AACnG,qFAA0F;AAC1F,yFAAwF;AACxF,2EAA2E;AAC3E,4DAAwD;AACxD,0EAAqE;AACrE,2DAAuD;AACvD,mEAA+D;AAC/D,iEAA6D;AAC7D,yEAAyE;AACzE,iEAAmE;AACnE,iEAAmE;AACnE,4DAA4D;AAC5D,mFAAkF;AAClF,2EAAsE;AACtE,2EAA2E;AAC3E,mEAAoE;AACpE,4DAAwD;AACxD,qFAA+E;AAC/E,4DAAwD;AACxD,qDAAuD;AAE1C,QAAA,SAAS,GAAG,4BAAS,CAAC,MAAM,CAAC;IACxC,WAAW,EAAE,EAAE;IACf,OAAO,EACL,gGAAgG;IAClG,QAAQ,EAAE,uCAAuC;IACjD,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE;QACL,eAAe;QACf,iBAAiB;QACjB,kBAAkB;QAClB,YAAY;QACZ,aAAa;QACb,cAAc;QACd,gBAAgB;QAChB,gBAAgB;QAChB,WAAW;QACX,YAAY;QACZ,cAAc;QACd,UAAU;QACV,SAAS;QACT,YAAY;QACZ,YAAY;QACZ,aAAa;QACb,YAAY;QACZ,kBAAkB;QAClB,iBAAiB;QACjB,iBAAiB;KAClB;CACF,CAAC,CAAC;AAEU,QAAA,KAAK,GAAG,IAAA,8BAAW,EAAC;IAC/B,WAAW,EAAE,OAAO;IACpB,WAAW,EAAE,kCAAkC;IAC/C,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EAAE,+CAA+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yB;QACzB,yDAA4B;QAC5B,4CAAsB;QACtB,oEAAkC;QAClC,2DAAgC;QAChC,gEAAgC;QAChC,mDAA0B;QAC1B,wBAAU;QACV,wBAAa;QACb,gCAAc;QACd,0CAAqB;QACrB,4CAAsB;QACtB,8BAAa;QACb,oCAAmB;QACnB,oCAAmB;QACnB,uCAAiB;QACjB,qCAAmB;QACnB,gDAAqB;QACrB,IAAA,yCAAyB,EAAC;YACxB,OAAO,EAAE,GAAG,EAAE;gBACZ,OAAO,uBAAuB,CAAC;YACjC,CAAC;YACD,IAAI,EAAE,iBAAS;YACf,WAAW,EAAE,CAAO,IAAI,EAAE,UAAU,EAAE,EAAE;;gBACtC,IAAI,UAAU,CAAC,YAAY,EAAE,CAAC;oBAC5B,OAAO;wBACL,aAAa,EAAE,UACb,MAAC,IAA4B,CAAC,IAAI,CAAC,aAAa,CAAC,0CAAE,YACrD,EAAE;qBACH,CAAC;gBACJ,CAAC;qBAAM,CAAC;oBACN,OAAO;wBACL,aAAa,EAAE,UACZ,IAA4B,CAAC,YAChC,EAAE;qBACH,CAAC;gBACJ,CAAC;YACH,CAAC,CAAA;YACD,UAAU,EAAE;gBACV,YAAY,EAAE,2BAAQ,CAAC,QAAQ,CAAC;oBAC9B,WAAW,EAAE,gBAAgB;oBAC7B,WAAW,EAAE,qCAAqC;oBAClD,QAAQ,EAAE,IAAI;oBACd,YAAY,EAAE,KAAK;iBACpB,CAAC;aACH;SACF,CAAC;KACH;IACD,QAAQ,EAAE,CAAC,wBAAU,EAAE,wBAAU,EAAE,qCAAgB,EAAE,4BAAc,EAAE,wBAAU,CAAC;CACjF,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare const getFileAction: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
2
+ fileId: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
+ }>;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getFileAction = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const index_1 = require("../../index");
6
+ const pieces_common_1 = require("@activepieces/pieces-common");
7
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
8
+ const web_api_1 = require("@slack/web-api");
9
+ exports.getFileAction = (0, pieces_framework_1.createAction)({
10
+ auth: index_1.slackAuth,
11
+ name: 'get-file',
12
+ displayName: 'Get File',
13
+ description: 'Return information about a given file ID.',
14
+ props: {
15
+ fileId: pieces_framework_1.Property.ShortText({
16
+ displayName: 'File ID',
17
+ required: true,
18
+ description: 'You can pass the file ID from the New Message Trigger payload.',
19
+ }),
20
+ },
21
+ run(context) {
22
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
23
+ var _a, _b;
24
+ const client = new web_api_1.WebClient(context.auth.access_token);
25
+ const fileData = yield client.files.info({ file: context.propsValue.fileId });
26
+ const fileDownloadUrl = (_a = fileData.file) === null || _a === void 0 ? void 0 : _a.url_private_download;
27
+ if (!fileDownloadUrl) {
28
+ throw new Error('Unable to find the download URL.');
29
+ }
30
+ const response = yield pieces_common_1.httpClient.sendRequest({
31
+ method: pieces_common_1.HttpMethod.GET,
32
+ url: fileDownloadUrl,
33
+ authentication: {
34
+ type: pieces_common_1.AuthenticationType.BEARER_TOKEN,
35
+ token: context.auth.access_token,
36
+ },
37
+ responseType: 'arraybuffer',
38
+ });
39
+ return Object.assign(Object.assign({}, fileData.file), { data: yield context.files.write({
40
+ fileName: ((_b = fileData.file) === null || _b === void 0 ? void 0 : _b.name) || `file`,
41
+ data: Buffer.from(response.body),
42
+ }) });
43
+ });
44
+ },
45
+ });
46
+ //# sourceMappingURL=get-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-file.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/slack/src/lib/actions/get-file.ts"],"names":[],"mappings":";;;;AAAA,uCAAwC;AACxC,+DAAyF;AACzF,qEAAwE;AACxE,4CAA2C;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iBAChC,CAAC,IACD;QACH,CAAC;KAAA;CACD,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { TriggerStrategy } from '@activepieces/pieces-framework';
2
+ export declare const newCommand: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
3
+ info: import("dist/packages/pieces/community/framework/src/lib/property/input/markdown-property").MarkDownProperty;
4
+ user: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
5
+ commands: import("@activepieces/pieces-framework").ArrayProperty<true>;
6
+ channels: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<string, false>;
7
+ ignoreBots: import("@activepieces/pieces-framework").CheckboxProperty<true>;
8
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
9
+ info: import("dist/packages/pieces/community/framework/src/lib/property/input/markdown-property").MarkDownProperty;
10
+ user: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
11
+ commands: import("@activepieces/pieces-framework").ArrayProperty<true>;
12
+ channels: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<string, false>;
13
+ ignoreBots: import("@activepieces/pieces-framework").CheckboxProperty<true>;
14
+ }> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").OAuth2Property<import("@activepieces/pieces-framework").OAuth2Props>, {
15
+ info: import("dist/packages/pieces/community/framework/src/lib/property/input/markdown-property").MarkDownProperty;
16
+ user: import("@activepieces/pieces-framework").DropdownProperty<string, false> | import("@activepieces/pieces-framework").DropdownProperty<string, true>;
17
+ commands: import("@activepieces/pieces-framework").ArrayProperty<true>;
18
+ channels: import("@activepieces/pieces-framework").MultiSelectDropdownProperty<string, false>;
19
+ ignoreBots: import("@activepieces/pieces-framework").CheckboxProperty<true>;
20
+ }>;
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.newCommand = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const pieces_framework_1 = require("@activepieces/pieces-framework");
6
+ const props_1 = require("../common/props");
7
+ const __1 = require("../../");
8
+ const web_api_1 = require("@slack/web-api");
9
+ const shared_1 = require("@activepieces/shared");
10
+ const utils_1 = require("../common/utils");
11
+ const sampleData = {
12
+ client_msg_id: '2767cf34-0651-44e0-b9c8-1b167ce9b7a9',
13
+ type: 'message',
14
+ text: '<@U07BN652T52> help argument1 argument2',
15
+ user: 'U037UG6FKPU',
16
+ ts: '1678231735.586539',
17
+ blocks: [
18
+ {
19
+ type: 'rich_text',
20
+ block_id: 'jCFSh',
21
+ elements: [
22
+ {
23
+ type: 'rich_text_section',
24
+ elements: [
25
+ {
26
+ type: 'user',
27
+ user_id: 'U07BN652T52',
28
+ },
29
+ {
30
+ type: 'text',
31
+ text: ' help argument1 argument2',
32
+ },
33
+ ],
34
+ },
35
+ ],
36
+ },
37
+ ],
38
+ team: 'T037MS4FGDC',
39
+ channel: 'C037RTX2ZDM',
40
+ event_ts: '1678231735.586539',
41
+ channel_type: 'channel',
42
+ parsed_command: {
43
+ command: 'help',
44
+ args: ['argument1', 'argument2'],
45
+ },
46
+ };
47
+ exports.newCommand = (0, pieces_framework_1.createTrigger)({
48
+ auth: __1.slackAuth,
49
+ name: 'new_command',
50
+ displayName: 'New Command',
51
+ description: 'Triggers when a specific command is sent to the bot (e.g., @bot command arg1 arg2)',
52
+ props: {
53
+ info: props_1.multiSelectChannelInfo,
54
+ user: props_1.userId,
55
+ commands: pieces_framework_1.Property.Array({
56
+ displayName: 'Commands',
57
+ description: 'List of valid commands that the bot should respond to (e.g., help, ocr, remind)',
58
+ required: true,
59
+ defaultValue: ['help'],
60
+ }),
61
+ channels: pieces_framework_1.Property.MultiSelectDropdown({
62
+ displayName: 'Channels',
63
+ description: 'If no channel is selected, the flow will be triggered for commands in all channels',
64
+ required: false,
65
+ refreshers: [],
66
+ options(_a) {
67
+ return tslib_1.__awaiter(this, arguments, void 0, function* ({ auth }) {
68
+ if (!auth) {
69
+ return {
70
+ disabled: true,
71
+ placeholder: 'connect slack account',
72
+ options: [],
73
+ };
74
+ }
75
+ const authentication = auth;
76
+ const accessToken = authentication['access_token'];
77
+ const channels = yield (0, props_1.getChannels)(accessToken);
78
+ return {
79
+ disabled: false,
80
+ placeholder: 'Select channel',
81
+ options: channels,
82
+ };
83
+ });
84
+ },
85
+ }),
86
+ ignoreBots: pieces_framework_1.Property.Checkbox({
87
+ displayName: 'Ignore Bot Messages ?',
88
+ required: true,
89
+ defaultValue: true,
90
+ }),
91
+ },
92
+ type: pieces_framework_1.TriggerStrategy.APP_WEBHOOK,
93
+ sampleData: sampleData,
94
+ onEnable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
95
+ var _a;
96
+ // Older OAuth2 has team_id, newer has team.id
97
+ const teamId = (_a = context.auth.data['team_id']) !== null && _a !== void 0 ? _a : context.auth.data['team']['id'];
98
+ context.app.createListeners({
99
+ events: ['message'],
100
+ identifierValue: teamId,
101
+ });
102
+ }),
103
+ onDisable: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
104
+ // Ignored
105
+ }),
106
+ test: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
107
+ const channels = context.propsValue.channels;
108
+ const commands = context.propsValue.commands;
109
+ const user = context.propsValue.user;
110
+ if (!channels || (Array.isArray(channels) && channels.length === 0)) {
111
+ return [
112
+ Object.assign(Object.assign({}, sampleData), { parsed_command: {
113
+ command: commands.length > 0 ? commands[0] : 'help',
114
+ args: ['argument1', 'argument2'],
115
+ } }),
116
+ ];
117
+ }
118
+ const client = new web_api_1.WebClient(context.auth.access_token);
119
+ const response = yield client.conversations.history({
120
+ channel: channels[0],
121
+ limit: 100,
122
+ });
123
+ if (!response.messages) {
124
+ return [];
125
+ }
126
+ // Filter and process messages with bot mention + command
127
+ const processedMessages = response.messages
128
+ .filter((message) => !(0, shared_1.isNil)(message.ts))
129
+ .filter((message) => {
130
+ // Ignore bot messages if configured to do so
131
+ if (context.propsValue.ignoreBots && message.bot_id) {
132
+ return false;
133
+ }
134
+ // Look for mentions of the bot user
135
+ return message.text && message.text.includes(`<@${user}>`);
136
+ })
137
+ .map((message) => {
138
+ // Parse the command
139
+ const parsedCommand = parseCommand(message.text || '', user, commands);
140
+ // Only include messages with valid commands
141
+ if (parsedCommand && commands.includes(parsedCommand.command)) {
142
+ return Object.assign(Object.assign({}, message), { channel: channels[0], event_ts: '1678231735.586539', channel_type: 'channel', parsed_command: parsedCommand });
143
+ }
144
+ return null;
145
+ })
146
+ .filter((message) => message !== null)
147
+ .sort((a, b) => parseFloat(b.ts) - parseFloat(a.ts));
148
+ return (0, utils_1.getFirstFiveOrAll)(processedMessages);
149
+ }),
150
+ run: (context) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
151
+ var _a, _b;
152
+ const payloadBody = context.payload.body;
153
+ const channels = (_a = context.propsValue.channels) !== null && _a !== void 0 ? _a : [];
154
+ const commands = (_b = context.propsValue.commands) !== null && _b !== void 0 ? _b : [];
155
+ const user = context.propsValue.user;
156
+ // Check if we should process this channel
157
+ if (!(channels.length === 0 || channels.includes(payloadBody.event.channel))) {
158
+ return [];
159
+ }
160
+ // Check for bot messages if configured to ignore them
161
+ if (context.propsValue.ignoreBots && payloadBody.event.bot_id) {
162
+ return [];
163
+ }
164
+ // Check for mention and parse command
165
+ if (user && payloadBody.event.text) {
166
+ const parsedCommand = parseCommand(payloadBody.event.text, user, commands);
167
+ if (parsedCommand && commands.includes(parsedCommand.command)) {
168
+ // Return event with parsed command
169
+ return [
170
+ Object.assign(Object.assign({}, payloadBody.event), { parsed_command: parsedCommand }),
171
+ ];
172
+ }
173
+ }
174
+ return [];
175
+ }),
176
+ });
177
+ /**
178
+ * Parse a message text to extract command and arguments
179
+ */
180
+ function parseCommand(text, botUserId, validCommands) {
181
+ if (!botUserId) {
182
+ return null;
183
+ }
184
+ // Check if the message mentions the bot
185
+ const mentionRegex = new RegExp(`<@${botUserId}>\\s+(.+)`, 's');
186
+ const mentionMatch = text.match(mentionRegex);
187
+ if (!mentionMatch) {
188
+ return null;
189
+ }
190
+ // Extract the text after the mention
191
+ const commandText = mentionMatch[1].trim();
192
+ // Split into command and arguments (first word is command, rest are args)
193
+ const parts = commandText.split(/\s+/);
194
+ const command = parts[0].toLowerCase();
195
+ const args = parts.slice(1);
196
+ // Check if it's a valid command
197
+ if (!validCommands.includes(command)) {
198
+ return null;
199
+ }
200
+ return {
201
+ command,
202
+ args,
203
+ };
204
+ }
205
+ //# sourceMappingURL=new-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"new-command.js","sourceRoot":"","sources":["../../../../../../../../packages/pieces/community/slack/src/lib/triggers/new-command.ts"],"names":[],"mappings":";;;;AAAA,qEAKwC;AACxC,2CAA8E;AAC9E,8BAAmC;AACnC,4CAA2C;AAC3C,iDAA6C;AAC7C,2CAAoD;AAEpD,MAAM,UAAU,GAAG;IACjB,aAAa,EAAE,sCAAsC;IACrD,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,yCAAyC;IAC/C,IAAI,EAAE,aAAa;IACnB,EAAE,EAAE,mBAAmB;IACvB,MAAM,EAAE;QACN;YACE,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,OAAO;YACjB,QAAQ,EAAE;gBACR;oBACE,IAAI,EAAE,mBAAmB;oBACzB,QAAQ,EAAE;wBACR;4BACE,IAAI,EAAE,MAAM;4BACZ,OAAO,EAAE,aAAa;yBACvB;wBACD;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,2BAA2B;yBAClC;qBACF;iBACF;aACF;SACF;KACF;IACD,IAAI,EAAE,aAAa;IACnB,OAAO,EAAE,aAAa;IACtB,QAAQ,EAAE,mBAAmB;IAC7B,YAAY,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