bullmq 5.44.4 → 5.45.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"queue-events.js","sourceRoot":"","sources":["../../../src/classes/queue-events.ts"],"names":[],"mappings":";;;;AAMA,oCAKkB;AAClB,6CAAyC;AAwKzC;;;;;;GAMG;AACH,MAAa,WAAY,SAAQ,sBAAS;IAGxC,YACE,IAAY,EACZ,KAA8D;QAC5D,UAAU,EAAE,EAAE;KACf,EACD,UAAmC;YAHnC,EAAE,UAAU,EAAE,OAAO,GAAG,IAAI,OAE3B,EAFgC,IAAI,sBAArC,yBAAuC,CAAF;QAKrC,KAAK,CACH,IAAI,kCAEC,IAAI,KACP,UAAU,EAAE,IAAA,uBAAe,EAAC,UAAU,CAAC;gBACrC,CAAC,CAAe,UAAW,CAAC,SAAS,EAAE;gBACvC,CAAC,CAAC,UAAU,KAEhB,UAAU,EACV,IAAI,CACL,CAAC;QAnBI,YAAO,GAAG,KAAK,CAAC;QAqBtB,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,CACvB;YACE,eAAe,EAAE,KAAK;SACvB,EACD,IAAI,CAAC,IAAI,CACV,CAAC;QAEF,IAAI,OAAO,EAAE;YACX,IAAI,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;SACtD;IACH,CAAC;IAED,IAAI,CAGF,KAAQ,EAAE,GAAG,IAA8B;QAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;IACpC,CAAC;IAED,GAAG,CAGD,SAAY,EAAE,QAAgB;QAC9B,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,QAAoC,CAAC,CAAC;QAC3D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,EAAE,CAGA,KAA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,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;qBACtB;yBAAM;wBACL,IAAI,CAAC,IAAI,CAAC,KAAY,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;wBACtC,IAAI,QAAQ,CAAC,KAAK,EAAE;4BAClB,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,QAAQ,CAAC,KAAK,EAAS,EAAE,QAAQ,EAAE,EAAE,CAAC,CAAC;yBAC9D;qBACF;iBACF;aACF;SACF;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;SAClC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF;AAvJD,kCAuJC"}
@@ -1,24 +1,23 @@
1
1
  --[[
2
2
  Function to debounce a job.
3
- ]]
4
-
3
+ ]]
5
4
  local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
6
5
  local deduplicationId = deduplicationOpts and deduplicationOpts['id']
7
6
  if deduplicationId then
8
- local ttl = deduplicationOpts['ttl']
9
- local deduplicationKeyExists
10
- if ttl then
11
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
12
- else
13
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
14
- end
15
- if deduplicationKeyExists then
16
- local currentDebounceJobId = rcall('GET', deduplicationKey)
17
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
18
- "debounced", "jobId", currentDebounceJobId, "debounceId", deduplicationId)
19
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
20
- "deduplicated", "jobId", currentDebounceJobId, "deduplicationId", deduplicationId)
21
- return currentDebounceJobId
22
- end
7
+ local ttl = deduplicationOpts['ttl']
8
+ local deduplicationKeyExists
9
+ if ttl then
10
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
11
+ else
12
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
13
+ end
14
+ if deduplicationKeyExists then
15
+ local currentDebounceJobId = rcall('GET', deduplicationKey)
16
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
17
+ "debounceId", deduplicationId)
18
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
19
+ currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
20
+ return currentDebounceJobId
21
+ end
23
22
  end
24
23
  end
@@ -25,7 +25,8 @@
25
25
 
26
26
  Output:
27
27
  next delayed job id - OK
28
- ]] local rcall = redis.call
28
+ ]]
29
+ local rcall = redis.call
29
30
  local repeatKey = KEYS[1]
30
31
  local delayedKey = KEYS[2]
31
32
  local waitKey = KEYS[3]
@@ -51,34 +52,39 @@ local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
51
52
  if prevMillis ~= false then
52
53
  local currentDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
53
54
 
54
- if producerId == currentDelayedJobId and rcall("EXISTS", nextDelayedJobKey) ~= 1 then
55
- local schedulerAttributes = rcall("HMGET", schedulerKey, "name", "data")
56
-
57
- rcall("ZADD", repeatKey, nextMillis, jobSchedulerId)
58
- rcall("HINCRBY", schedulerKey, "ic", 1)
59
-
55
+ if producerId == currentDelayedJobId then
60
56
  local eventsKey = KEYS[9]
61
57
  local maxEvents = getOrSetMaxEvents(metaKey)
62
58
 
63
- rcall("INCR", KEYS[8])
59
+ if rcall("EXISTS", nextDelayedJobKey) ~= 1 then
60
+ local schedulerAttributes = rcall("HMGET", schedulerKey, "name", "data")
64
61
 
65
- -- TODO: remove this workaround in next breaking change,
66
- -- all job-schedulers must save job data
67
- local templateData = schedulerAttributes[2] or ARGV[3]
62
+ rcall("ZADD", repeatKey, nextMillis, jobSchedulerId)
63
+ rcall("HINCRBY", schedulerKey, "ic", 1)
68
64
 
69
- if templateData and templateData ~= '{}' then
70
- rcall("HSET", schedulerKey, "data", templateData)
71
- end
65
+ rcall("INCR", KEYS[8])
72
66
 
73
- addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[4], waitKey, pausedKey,
74
- KEYS[12], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
75
- schedulerAttributes[1], maxEvents, ARGV[5], templateData or '{}', jobSchedulerId)
67
+ -- TODO: remove this workaround in next breaking change,
68
+ -- all job-schedulers must save job data
69
+ local templateData = schedulerAttributes[2] or ARGV[3]
76
70
 
77
- -- TODO: remove this workaround in next breaking change
78
- if KEYS[11] ~= "" then
79
- rcall("HSET", KEYS[11], "nrjid", nextDelayedJobId)
80
- end
71
+ if templateData and templateData ~= '{}' then
72
+ rcall("HSET", schedulerKey, "data", templateData)
73
+ end
81
74
 
82
- return nextDelayedJobId .. "" -- convert to string
75
+ addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[4], waitKey, pausedKey,
76
+ KEYS[12], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
77
+ schedulerAttributes[1], maxEvents, ARGV[5], templateData or '{}', jobSchedulerId)
78
+
79
+ -- TODO: remove this workaround in next breaking change
80
+ if KEYS[11] ~= "" then
81
+ rcall("HSET", KEYS[11], "nrjid", nextDelayedJobId)
82
+ end
83
+
84
+ return nextDelayedJobId .. "" -- convert to string
85
+ else
86
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
87
+ "duplicated", "jobId", nextDelayedJobId)
88
+ end
83
89
  end
84
90
  end
@@ -114,25 +114,25 @@ local function addDelayedJob(jobId, delayedKey, eventsKey, timestamp,
114
114
  end
115
115
  --[[
116
116
  Function to debounce a job.
117
- ]]
117
+ ]]
118
118
  local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
119
119
  local deduplicationId = deduplicationOpts and deduplicationOpts['id']
120
120
  if deduplicationId then
121
- local ttl = deduplicationOpts['ttl']
122
- local deduplicationKeyExists
123
- if ttl then
124
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
125
- else
126
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
127
- end
128
- if deduplicationKeyExists then
129
- local currentDebounceJobId = rcall('GET', deduplicationKey)
130
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
131
- "debounced", "jobId", currentDebounceJobId, "debounceId", deduplicationId)
132
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
133
- "deduplicated", "jobId", currentDebounceJobId, "deduplicationId", deduplicationId)
134
- return currentDebounceJobId
135
- end
121
+ local ttl = deduplicationOpts['ttl']
122
+ local deduplicationKeyExists
123
+ if ttl then
124
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
125
+ else
126
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
127
+ end
128
+ if deduplicationKeyExists then
129
+ local currentDebounceJobId = rcall('GET', deduplicationKey)
130
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
131
+ "debounceId", deduplicationId)
132
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
133
+ currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
134
+ return currentDebounceJobId
135
+ end
136
136
  end
137
137
  end
138
138
  --[[
@@ -46,25 +46,25 @@ local parentData
46
46
  -- Includes
47
47
  --[[
48
48
  Function to debounce a job.
49
- ]]
49
+ ]]
50
50
  local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
51
51
  local deduplicationId = deduplicationOpts and deduplicationOpts['id']
52
52
  if deduplicationId then
53
- local ttl = deduplicationOpts['ttl']
54
- local deduplicationKeyExists
55
- if ttl then
56
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
57
- else
58
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
59
- end
60
- if deduplicationKeyExists then
61
- local currentDebounceJobId = rcall('GET', deduplicationKey)
62
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
63
- "debounced", "jobId", currentDebounceJobId, "debounceId", deduplicationId)
64
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
65
- "deduplicated", "jobId", currentDebounceJobId, "deduplicationId", deduplicationId)
66
- return currentDebounceJobId
67
- end
53
+ local ttl = deduplicationOpts['ttl']
54
+ local deduplicationKeyExists
55
+ if ttl then
56
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
57
+ else
58
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
59
+ end
60
+ if deduplicationKeyExists then
61
+ local currentDebounceJobId = rcall('GET', deduplicationKey)
62
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
63
+ "debounceId", deduplicationId)
64
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
65
+ currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
66
+ return currentDebounceJobId
67
+ end
68
68
  end
69
69
  end
70
70
  --[[
@@ -78,25 +78,25 @@ local function addJobWithPriority(markerKey, prioritizedKey, priority, jobId, pr
78
78
  end
79
79
  --[[
80
80
  Function to debounce a job.
81
- ]]
81
+ ]]
82
82
  local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
83
83
  local deduplicationId = deduplicationOpts and deduplicationOpts['id']
84
84
  if deduplicationId then
85
- local ttl = deduplicationOpts['ttl']
86
- local deduplicationKeyExists
87
- if ttl then
88
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
89
- else
90
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
91
- end
92
- if deduplicationKeyExists then
93
- local currentDebounceJobId = rcall('GET', deduplicationKey)
94
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
95
- "debounced", "jobId", currentDebounceJobId, "debounceId", deduplicationId)
96
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
97
- "deduplicated", "jobId", currentDebounceJobId, "deduplicationId", deduplicationId)
98
- return currentDebounceJobId
99
- end
85
+ local ttl = deduplicationOpts['ttl']
86
+ local deduplicationKeyExists
87
+ if ttl then
88
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
89
+ else
90
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
91
+ end
92
+ if deduplicationKeyExists then
93
+ local currentDebounceJobId = rcall('GET', deduplicationKey)
94
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
95
+ "debounceId", deduplicationId)
96
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
97
+ currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
98
+ return currentDebounceJobId
99
+ end
100
100
  end
101
101
  end
102
102
  --[[
@@ -72,25 +72,25 @@ local function addJobInTargetList(targetKey, markerKey, pushCmd, isPausedOrMaxed
72
72
  end
73
73
  --[[
74
74
  Function to debounce a job.
75
- ]]
75
+ ]]
76
76
  local function deduplicateJob(deduplicationOpts, jobId, deduplicationKey, eventsKey, maxEvents)
77
77
  local deduplicationId = deduplicationOpts and deduplicationOpts['id']
78
78
  if deduplicationId then
79
- local ttl = deduplicationOpts['ttl']
80
- local deduplicationKeyExists
81
- if ttl then
82
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
83
- else
84
- deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
85
- end
86
- if deduplicationKeyExists then
87
- local currentDebounceJobId = rcall('GET', deduplicationKey)
88
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
89
- "debounced", "jobId", currentDebounceJobId, "debounceId", deduplicationId)
90
- rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
91
- "deduplicated", "jobId", currentDebounceJobId, "deduplicationId", deduplicationId)
92
- return currentDebounceJobId
93
- end
79
+ local ttl = deduplicationOpts['ttl']
80
+ local deduplicationKeyExists
81
+ if ttl then
82
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'PX', ttl, 'NX')
83
+ else
84
+ deduplicationKeyExists = not rcall('SET', deduplicationKey, jobId, 'NX')
85
+ end
86
+ if deduplicationKeyExists then
87
+ local currentDebounceJobId = rcall('GET', deduplicationKey)
88
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "debounced", "jobId", currentDebounceJobId,
89
+ "debounceId", deduplicationId)
90
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event", "deduplicated", "jobId",
91
+ currentDebounceJobId, "deduplicationId", deduplicationId, "deduplicatedJobId", jobId)
92
+ return currentDebounceJobId
93
+ end
94
94
  end
95
95
  end
96
96
  --[[
@@ -25,7 +25,8 @@ const content = `--[[
25
25
  ARGV[7] producer id
26
26
  Output:
27
27
  next delayed job id - OK
28
- ]] local rcall = redis.call
28
+ ]]
29
+ local rcall = redis.call
29
30
  local repeatKey = KEYS[1]
30
31
  local delayedKey = KEYS[2]
31
32
  local waitKey = KEYS[3]
@@ -236,27 +237,32 @@ local nextDelayedJobKey = schedulerKey .. ":" .. nextMillis
236
237
  local prevMillis = rcall("ZSCORE", repeatKey, jobSchedulerId)
237
238
  if prevMillis ~= false then
238
239
  local currentDelayedJobId = "repeat:" .. jobSchedulerId .. ":" .. prevMillis
239
- if producerId == currentDelayedJobId and rcall("EXISTS", nextDelayedJobKey) ~= 1 then
240
- local schedulerAttributes = rcall("HMGET", schedulerKey, "name", "data")
241
- rcall("ZADD", repeatKey, nextMillis, jobSchedulerId)
242
- rcall("HINCRBY", schedulerKey, "ic", 1)
240
+ if producerId == currentDelayedJobId then
243
241
  local eventsKey = KEYS[9]
244
242
  local maxEvents = getOrSetMaxEvents(metaKey)
245
- rcall("INCR", KEYS[8])
246
- -- TODO: remove this workaround in next breaking change,
247
- -- all job-schedulers must save job data
248
- local templateData = schedulerAttributes[2] or ARGV[3]
249
- if templateData and templateData ~= '{}' then
250
- rcall("HSET", schedulerKey, "data", templateData)
251
- end
252
- addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[4], waitKey, pausedKey,
253
- KEYS[12], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
254
- schedulerAttributes[1], maxEvents, ARGV[5], templateData or '{}', jobSchedulerId)
255
- -- TODO: remove this workaround in next breaking change
256
- if KEYS[11] ~= "" then
257
- rcall("HSET", KEYS[11], "nrjid", nextDelayedJobId)
243
+ if rcall("EXISTS", nextDelayedJobKey) ~= 1 then
244
+ local schedulerAttributes = rcall("HMGET", schedulerKey, "name", "data")
245
+ rcall("ZADD", repeatKey, nextMillis, jobSchedulerId)
246
+ rcall("HINCRBY", schedulerKey, "ic", 1)
247
+ rcall("INCR", KEYS[8])
248
+ -- TODO: remove this workaround in next breaking change,
249
+ -- all job-schedulers must save job data
250
+ local templateData = schedulerAttributes[2] or ARGV[3]
251
+ if templateData and templateData ~= '{}' then
252
+ rcall("HSET", schedulerKey, "data", templateData)
253
+ end
254
+ addJobFromScheduler(nextDelayedJobKey, nextDelayedJobId, ARGV[4], waitKey, pausedKey,
255
+ KEYS[12], metaKey, prioritizedKey, KEYS[10], delayedKey, KEYS[7], eventsKey,
256
+ schedulerAttributes[1], maxEvents, ARGV[5], templateData or '{}', jobSchedulerId)
257
+ -- TODO: remove this workaround in next breaking change
258
+ if KEYS[11] ~= "" then
259
+ rcall("HSET", KEYS[11], "nrjid", nextDelayedJobId)
260
+ end
261
+ return nextDelayedJobId .. "" -- convert to string
262
+ else
263
+ rcall("XADD", eventsKey, "MAXLEN", "~", maxEvents, "*", "event",
264
+ "duplicated", "jobId", nextDelayedJobId)
258
265
  end
259
- return nextDelayedJobId .. "" -- convert to string
260
266
  end
261
267
  end
262
268
  `;
@@ -1 +1 @@
1
- {"version":3,"file":"updateJobScheduler-12.js","sourceRoot":"","sources":["../../../src/scripts/updateJobScheduler-12.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkQf,CAAC;AACW,QAAA,kBAAkB,GAAG;IAChC,IAAI,EAAE,oBAAoB;IAC1B,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}
1
+ {"version":3,"file":"updateJobScheduler-12.js","sourceRoot":"","sources":["../../../src/scripts/updateJobScheduler-12.ts"],"names":[],"mappings":";;;AAAA,MAAM,OAAO,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwQf,CAAC;AACW,QAAA,kBAAkB,GAAG;IAChC,IAAI,EAAE,oBAAoB;IAC1B,OAAO;IACP,IAAI,EAAE,EAAE;CACT,CAAC"}