@liveblocks/core 2.25.0-aiprivatebeta5 → 2.25.0-aiprivatebeta7

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
@@ -6,7 +6,7 @@ var __export = (target, all) => {
6
6
 
7
7
  // src/version.ts
8
8
  var PKG_NAME = "@liveblocks/core";
9
- var PKG_VERSION = "2.25.0-aiprivatebeta5";
9
+ var PKG_VERSION = "2.25.0-aiprivatebeta7";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -3781,7 +3781,8 @@ function createStore_forChatMessages() {
3781
3781
  role,
3782
3782
  parentId,
3783
3783
  createdAt,
3784
- content
3784
+ content,
3785
+ _optimistic: true
3785
3786
  });
3786
3787
  } else {
3787
3788
  upsert({
@@ -3791,7 +3792,8 @@ function createStore_forChatMessages() {
3791
3792
  parentId,
3792
3793
  createdAt,
3793
3794
  status: "pending",
3794
- contentSoFar: []
3795
+ contentSoFar: [],
3796
+ _optimistic: true
3795
3797
  });
3796
3798
  }
3797
3799
  return id;
@@ -3846,7 +3848,7 @@ function createStore_forChatMessages() {
3846
3848
  function* iterPendingMessages() {
3847
3849
  for (const chatMsgs\u03A3 of messagePoolByChatId\u03A3.values()) {
3848
3850
  for (const m of chatMsgs\u03A3.get()) {
3849
- if (m.role === "assistant" && m.status === "pending") {
3851
+ if (m.role === "assistant" && m.status === "pending" && !m._optimistic) {
3850
3852
  yield m;
3851
3853
  }
3852
3854
  }
@@ -3854,7 +3856,16 @@ function createStore_forChatMessages() {
3854
3856
  }
3855
3857
  function failAllPending() {
3856
3858
  batch(() => {
3857
- pendingMessages\u03A3.mutate((lut) => lut.clear());
3859
+ pendingMessages\u03A3.mutate((lut) => {
3860
+ let deleted = false;
3861
+ for (const [k, v] of lut) {
3862
+ if (!v._optimistic) {
3863
+ lut.delete(k);
3864
+ deleted = true;
3865
+ }
3866
+ }
3867
+ return deleted;
3868
+ });
3858
3869
  upsertMany(
3859
3870
  Array.from(iterPendingMessages()).map(
3860
3871
  (message) => ({
@@ -3988,7 +3999,7 @@ function createStore_forUserAiChats() {
3988
3999
  SortedList.with((x, y) => y.createdAt < x.createdAt)
3989
4000
  );
3990
4001
  const chats\u03A3 = DerivedSignal.from(
3991
- () => Array.from(mutable\u03A3.get()).filter((c) => !c.ephemeral && !c.deletedAt)
4002
+ () => Array.from(mutable\u03A3.get()).filter((c) => !c.deletedAt)
3992
4003
  );
3993
4004
  function upsertMany(chats) {
3994
4005
  mutable\u03A3.mutate((list) => {
@@ -4030,7 +4041,7 @@ function createAi(config) {
4030
4041
  chatsStore,
4031
4042
  messagesStore,
4032
4043
  toolsStore,
4033
- contextByChatId: /* @__PURE__ */ new Map()
4044
+ knowledgeByChatId: /* @__PURE__ */ new Map()
4034
4045
  };
4035
4046
  let lastTokenKey;
4036
4047
  function onStatusDidChange(_newStatus) {
@@ -4132,7 +4143,7 @@ function createAi(config) {
4132
4143
  case "get-chats":
4133
4144
  context.chatsStore.upsertMany(msg.chats);
4134
4145
  break;
4135
- case "create-chat":
4146
+ case "get-or-create-chat":
4136
4147
  context.chatsStore.upsert(msg.chat);
4137
4148
  break;
4138
4149
  case "delete-chat":
@@ -4143,20 +4154,17 @@ function createAi(config) {
4143
4154
  context.chatsStore.upsert(msg.chat);
4144
4155
  context.messagesStore.upsertMany(msg.messages);
4145
4156
  break;
4146
- case "add-user-message":
4147
- context.messagesStore.upsert(msg.message);
4148
- break;
4149
4157
  case "delete-message":
4150
4158
  context.messagesStore.remove(msg.chatId, msg.messageId);
4151
4159
  break;
4152
4160
  case "clear-chat":
4153
4161
  context.messagesStore.removeByChatId(msg.chatId);
4154
4162
  break;
4155
- case "ask-ai":
4156
- if (msg.message) {
4157
- context.messagesStore.upsert(msg.message);
4158
- } else {
4163
+ case "ask-in-chat":
4164
+ if (msg.sourceMessage) {
4165
+ context.messagesStore.upsert(msg.sourceMessage);
4159
4166
  }
4167
+ context.messagesStore.upsert(msg.targetMessage);
4160
4168
  break;
4161
4169
  case "abort-ai":
4162
4170
  break;
@@ -4210,13 +4218,14 @@ function createAi(config) {
4210
4218
  cursor: options.cursor
4211
4219
  });
4212
4220
  }
4213
- function createChat(id, name, options) {
4221
+ function getOrCreateChat(id, title, options) {
4214
4222
  return sendClientMsgWithResponse({
4215
- cmd: "create-chat",
4223
+ cmd: "get-or-create-chat",
4216
4224
  id,
4217
- name,
4218
- ephemeral: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _65 => _65.ephemeral]), () => ( false)),
4219
- metadata: _nullishCoalesce(_optionalChain([options, 'optionalAccess', _66 => _66.metadata]), () => ( {}))
4225
+ options: {
4226
+ title,
4227
+ metadata: _optionalChain([options, 'optionalAccess', _65 => _65.metadata])
4228
+ }
4220
4229
  });
4221
4230
  }
4222
4231
  function getMessageTree(chatId) {
@@ -4225,19 +4234,19 @@ function createAi(config) {
4225
4234
  chatId
4226
4235
  });
4227
4236
  }
4228
- function registerChatContext(chatId, data) {
4229
- const chatContext = context.contextByChatId.get(chatId);
4230
- if (chatContext === void 0) {
4231
- context.contextByChatId.set(chatId, /* @__PURE__ */ new Set([data]));
4237
+ function registerKnowledgeSource(chatId, data) {
4238
+ const knowledge = context.knowledgeByChatId.get(chatId);
4239
+ if (knowledge === void 0) {
4240
+ context.knowledgeByChatId.set(chatId, /* @__PURE__ */ new Set([data]));
4232
4241
  } else {
4233
- chatContext.add(data);
4242
+ knowledge.add(data);
4234
4243
  }
4235
4244
  return () => {
4236
- const chatContext2 = context.contextByChatId.get(chatId);
4237
- if (chatContext2 !== void 0) {
4238
- chatContext2.delete(data);
4239
- if (chatContext2.size === 0) {
4240
- context.contextByChatId.delete(chatId);
4245
+ const knowledge2 = context.knowledgeByChatId.get(chatId);
4246
+ if (knowledge2 !== void 0) {
4247
+ knowledge2.delete(data);
4248
+ if (knowledge2.size === 0) {
4249
+ context.knowledgeByChatId.delete(chatId);
4241
4250
  }
4242
4251
  }
4243
4252
  };
@@ -4248,25 +4257,27 @@ function createAi(config) {
4248
4257
  "assistant",
4249
4258
  messageId
4250
4259
  );
4251
- const copilotId = _optionalChain([options, 'optionalAccess', _67 => _67.copilotId]);
4252
- const stream = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _68 => _68.stream]), () => ( false));
4253
- const timeout = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _69 => _69.timeout]), () => ( DEFAULT_AI_TIMEOUT));
4254
- const chatContext = context.contextByChatId.get(chatId);
4260
+ const copilotId = _optionalChain([options, 'optionalAccess', _66 => _66.copilotId]);
4261
+ const stream = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _67 => _67.stream]), () => ( false));
4262
+ const timeout = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _68 => _68.timeout]), () => ( DEFAULT_AI_TIMEOUT));
4263
+ const knowledge = context.knowledgeByChatId.get(chatId);
4255
4264
  return sendClientMsgWithResponse({
4256
- cmd: "ask-ai",
4265
+ cmd: "ask-in-chat",
4257
4266
  chatId,
4258
- sourceMessageId: messageId,
4267
+ sourceMessage: messageId,
4259
4268
  targetMessageId,
4260
- copilotId,
4261
4269
  clientId,
4262
- stream,
4263
- tools: context.toolsStore.getToolsForChat(chatId).map((tool) => ({
4264
- name: tool.name,
4265
- description: tool.definition.description,
4266
- parameters: tool.definition.parameters
4267
- })),
4268
- timeout,
4269
- context: chatContext ? Array.from(chatContext.values()) : void 0
4270
+ generationOptions: {
4271
+ copilotId,
4272
+ stream,
4273
+ knowledge: knowledge ? Array.from(knowledge) : void 0,
4274
+ tools: context.toolsStore.getToolsForChat(chatId).map((tool) => ({
4275
+ name: tool.name,
4276
+ description: tool.definition.description,
4277
+ parameters: tool.definition.parameters
4278
+ })),
4279
+ timeout
4280
+ }
4270
4281
  });
4271
4282
  }
4272
4283
  return Object.defineProperty(
@@ -4278,7 +4289,7 @@ function createAi(config) {
4278
4289
  reconnect: () => managedSocket.reconnect(),
4279
4290
  disconnect: () => managedSocket.disconnect(),
4280
4291
  getChats,
4281
- createChat,
4292
+ getOrCreateChat,
4282
4293
  deleteChat: (chatId) => {
4283
4294
  return sendClientMsgWithResponse({
4284
4295
  cmd: "delete-chat",
@@ -4288,23 +4299,6 @@ function createAi(config) {
4288
4299
  getMessageTree,
4289
4300
  deleteMessage: (chatId, messageId) => sendClientMsgWithResponse({ cmd: "delete-message", chatId, messageId }),
4290
4301
  clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
4291
- addUserMessage: (chatId, parentMessageId, message) => {
4292
- const content = [{ type: "text", text: message }];
4293
- const newMessageId = context.messagesStore.createOptimistically(
4294
- chatId,
4295
- "user",
4296
- parentMessageId,
4297
- content
4298
- );
4299
- return sendClientMsgWithResponse({
4300
- cmd: "add-user-message",
4301
- id: newMessageId,
4302
- chatId,
4303
- parentMessageId,
4304
- content
4305
- });
4306
- },
4307
- ask,
4308
4302
  regenerateMessage: (chatId, messageId, options) => {
4309
4303
  const parentUserMessageId = context.messagesStore.getLatestUserMessageAncestor(chatId, messageId);
4310
4304
  if (parentUserMessageId === null) {
@@ -4327,32 +4321,27 @@ function createAi(config) {
4327
4321
  "assistant",
4328
4322
  newMessageId
4329
4323
  );
4330
- await sendClientMsgWithResponse({
4331
- cmd: "add-user-message",
4332
- id: newMessageId,
4333
- chatId,
4334
- parentMessageId,
4335
- content
4336
- });
4337
- const copilotId = _optionalChain([options, 'optionalAccess', _70 => _70.copilotId]);
4338
- const stream = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _71 => _71.stream]), () => ( false));
4339
- const timeout = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _72 => _72.timeout]), () => ( DEFAULT_AI_TIMEOUT));
4340
- const chatContext = context.contextByChatId.get(chatId);
4324
+ const copilotId = _optionalChain([options, 'optionalAccess', _69 => _69.copilotId]);
4325
+ const stream = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _70 => _70.stream]), () => ( false));
4326
+ const timeout = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _71 => _71.timeout]), () => ( DEFAULT_AI_TIMEOUT));
4327
+ const knowledge = context.knowledgeByChatId.get(chatId);
4341
4328
  return sendClientMsgWithResponse({
4342
- cmd: "ask-ai",
4329
+ cmd: "ask-in-chat",
4343
4330
  chatId,
4344
- sourceMessageId: newMessageId,
4331
+ sourceMessage: { id: newMessageId, parentMessageId, content },
4345
4332
  targetMessageId,
4346
- copilotId,
4347
4333
  clientId,
4348
- stream,
4349
- tools: context.toolsStore.getToolsForChat(chatId).map((tool) => ({
4350
- name: tool.name,
4351
- description: tool.definition.description,
4352
- parameters: tool.definition.parameters
4353
- })),
4354
- timeout,
4355
- context: chatContext ? Array.from(chatContext.values()) : void 0
4334
+ generationOptions: {
4335
+ copilotId,
4336
+ stream,
4337
+ knowledge: knowledge ? Array.from(knowledge) : void 0,
4338
+ tools: context.toolsStore.getToolsForChat(chatId).map((tool) => ({
4339
+ name: tool.name,
4340
+ description: tool.definition.description,
4341
+ parameters: tool.definition.parameters
4342
+ })),
4343
+ timeout
4344
+ }
4356
4345
  });
4357
4346
  },
4358
4347
  abort: (messageId) => sendClientMsgWithResponse({ cmd: "abort-ai", messageId }),
@@ -4363,7 +4352,7 @@ function createAi(config) {
4363
4352
  getToolDefinition\u03A3: context.toolsStore.getToolCallByName\u03A3,
4364
4353
  getMessagesForChat\u03A3: context.messagesStore.getMessagesForChat\u03A3
4365
4354
  },
4366
- registerChatContext,
4355
+ registerKnowledgeSource,
4367
4356
  registerChatTool: context.toolsStore.addToolDefinition,
4368
4357
  unregisterChatTool: context.toolsStore.removeToolDefinition
4369
4358
  },
@@ -4445,7 +4434,7 @@ function createAuthManager(authOptions, onAuthenticate) {
4445
4434
  return void 0;
4446
4435
  }
4447
4436
  async function makeAuthRequest(options) {
4448
- const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _73 => _73.polyfills, 'optionalAccess', _74 => _74.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
4437
+ const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _72 => _72.polyfills, 'optionalAccess', _73 => _73.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
4449
4438
  if (authentication.type === "private") {
4450
4439
  if (fetcher === void 0) {
4451
4440
  throw new StopRetrying(
@@ -4461,7 +4450,7 @@ function createAuthManager(authOptions, onAuthenticate) {
4461
4450
  "The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
4462
4451
  );
4463
4452
  }
4464
- _optionalChain([onAuthenticate, 'optionalCall', _75 => _75(parsed.parsed)]);
4453
+ _optionalChain([onAuthenticate, 'optionalCall', _74 => _74(parsed.parsed)]);
4465
4454
  return parsed;
4466
4455
  }
4467
4456
  if (authentication.type === "custom") {
@@ -4469,7 +4458,7 @@ function createAuthManager(authOptions, onAuthenticate) {
4469
4458
  if (response && typeof response === "object") {
4470
4459
  if (typeof response.token === "string") {
4471
4460
  const parsed = parseAuthToken(response.token);
4472
- _optionalChain([onAuthenticate, 'optionalCall', _76 => _76(parsed.parsed)]);
4461
+ _optionalChain([onAuthenticate, 'optionalCall', _75 => _75(parsed.parsed)]);
4473
4462
  return parsed;
4474
4463
  } else if (typeof response.error === "string") {
4475
4464
  const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
@@ -4627,7 +4616,7 @@ function sendToPanel(message, options) {
4627
4616
  ...message,
4628
4617
  source: "liveblocks-devtools-client"
4629
4618
  };
4630
- if (!(_optionalChain([options, 'optionalAccess', _77 => _77.force]) || _bridgeActive)) {
4619
+ if (!(_optionalChain([options, 'optionalAccess', _76 => _76.force]) || _bridgeActive)) {
4631
4620
  return;
4632
4621
  }
4633
4622
  window.postMessage(fullMsg, "*");
@@ -4635,7 +4624,7 @@ function sendToPanel(message, options) {
4635
4624
  var eventSource = makeEventSource();
4636
4625
  if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
4637
4626
  window.addEventListener("message", (event) => {
4638
- if (event.source === window && _optionalChain([event, 'access', _78 => _78.data, 'optionalAccess', _79 => _79.source]) === "liveblocks-devtools-panel") {
4627
+ if (event.source === window && _optionalChain([event, 'access', _77 => _77.data, 'optionalAccess', _78 => _78.source]) === "liveblocks-devtools-panel") {
4639
4628
  eventSource.notify(event.data);
4640
4629
  } else {
4641
4630
  }
@@ -4777,7 +4766,7 @@ function fullSync(room) {
4777
4766
  msg: "room::sync::full",
4778
4767
  roomId: room.id,
4779
4768
  status: room.getStatus(),
4780
- storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _80 => _80.toTreeNode, 'call', _81 => _81("root"), 'access', _82 => _82.payload]), () => ( null)),
4769
+ storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _79 => _79.toTreeNode, 'call', _80 => _80("root"), 'access', _81 => _81.payload]), () => ( null)),
4781
4770
  me,
4782
4771
  others
4783
4772
  });
@@ -5068,7 +5057,7 @@ function createManagedPool(roomId, options) {
5068
5057
  generateId: () => `${getCurrentConnectionId()}:${clock++}`,
5069
5058
  generateOpId: () => `${getCurrentConnectionId()}:${opClock++}`,
5070
5059
  dispatch(ops, reverse, storageUpdates) {
5071
- _optionalChain([onDispatch, 'optionalCall', _83 => _83(ops, reverse, storageUpdates)]);
5060
+ _optionalChain([onDispatch, 'optionalCall', _82 => _82(ops, reverse, storageUpdates)]);
5072
5061
  },
5073
5062
  assertStorageIsWritable: () => {
5074
5063
  if (!isStorageWritable()) {
@@ -5295,7 +5284,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
5295
5284
  return [
5296
5285
  {
5297
5286
  type: 8 /* CREATE_REGISTER */,
5298
- opId: _optionalChain([pool, 'optionalAccess', _84 => _84.generateOpId, 'call', _85 => _85()]),
5287
+ opId: _optionalChain([pool, 'optionalAccess', _83 => _83.generateOpId, 'call', _84 => _84()]),
5299
5288
  id: this._id,
5300
5289
  parentId,
5301
5290
  parentKey,
@@ -5401,7 +5390,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5401
5390
  const ops = [];
5402
5391
  const op = {
5403
5392
  id: this._id,
5404
- opId: _optionalChain([pool, 'optionalAccess', _86 => _86.generateOpId, 'call', _87 => _87()]),
5393
+ opId: _optionalChain([pool, 'optionalAccess', _85 => _85.generateOpId, 'call', _86 => _86()]),
5405
5394
  type: 2 /* CREATE_LIST */,
5406
5395
  parentId,
5407
5396
  parentKey
@@ -5672,7 +5661,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5672
5661
  #applyInsertUndoRedo(op) {
5673
5662
  const { id, parentKey: key } = op;
5674
5663
  const child = creationOpToLiveNode(op);
5675
- if (_optionalChain([this, 'access', _88 => _88._pool, 'optionalAccess', _89 => _89.getNode, 'call', _90 => _90(id)]) !== void 0) {
5664
+ if (_optionalChain([this, 'access', _87 => _87._pool, 'optionalAccess', _88 => _88.getNode, 'call', _89 => _89(id)]) !== void 0) {
5676
5665
  return { modified: false };
5677
5666
  }
5678
5667
  child._attach(id, nn(this._pool));
@@ -5680,8 +5669,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
5680
5669
  const existingItemIndex = this._indexOfPosition(key);
5681
5670
  let newKey = key;
5682
5671
  if (existingItemIndex !== -1) {
5683
- const before2 = _optionalChain([this, 'access', _91 => _91.#items, 'access', _92 => _92[existingItemIndex], 'optionalAccess', _93 => _93._parentPos]);
5684
- const after2 = _optionalChain([this, 'access', _94 => _94.#items, 'access', _95 => _95[existingItemIndex + 1], 'optionalAccess', _96 => _96._parentPos]);
5672
+ const before2 = _optionalChain([this, 'access', _90 => _90.#items, 'access', _91 => _91[existingItemIndex], 'optionalAccess', _92 => _92._parentPos]);
5673
+ const after2 = _optionalChain([this, 'access', _93 => _93.#items, 'access', _94 => _94[existingItemIndex + 1], 'optionalAccess', _95 => _95._parentPos]);
5685
5674
  newKey = makePosition(before2, after2);
5686
5675
  child._setParentLink(this, newKey);
5687
5676
  }
@@ -5695,7 +5684,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5695
5684
  #applySetUndoRedo(op) {
5696
5685
  const { id, parentKey: key } = op;
5697
5686
  const child = creationOpToLiveNode(op);
5698
- if (_optionalChain([this, 'access', _97 => _97._pool, 'optionalAccess', _98 => _98.getNode, 'call', _99 => _99(id)]) !== void 0) {
5687
+ if (_optionalChain([this, 'access', _96 => _96._pool, 'optionalAccess', _97 => _97.getNode, 'call', _98 => _98(id)]) !== void 0) {
5699
5688
  return { modified: false };
5700
5689
  }
5701
5690
  this.#unacknowledgedSets.set(key, nn(op.opId));
@@ -5816,7 +5805,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5816
5805
  } else {
5817
5806
  this.#items[existingItemIndex]._setParentLink(
5818
5807
  this,
5819
- makePosition(newKey, _optionalChain([this, 'access', _100 => _100.#items, 'access', _101 => _101[existingItemIndex + 1], 'optionalAccess', _102 => _102._parentPos]))
5808
+ makePosition(newKey, _optionalChain([this, 'access', _99 => _99.#items, 'access', _100 => _100[existingItemIndex + 1], 'optionalAccess', _101 => _101._parentPos]))
5820
5809
  );
5821
5810
  const previousIndex = this.#items.indexOf(child);
5822
5811
  child._setParentLink(this, newKey);
@@ -5841,7 +5830,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5841
5830
  if (existingItemIndex !== -1) {
5842
5831
  this.#items[existingItemIndex]._setParentLink(
5843
5832
  this,
5844
- makePosition(newKey, _optionalChain([this, 'access', _103 => _103.#items, 'access', _104 => _104[existingItemIndex + 1], 'optionalAccess', _105 => _105._parentPos]))
5833
+ makePosition(newKey, _optionalChain([this, 'access', _102 => _102.#items, 'access', _103 => _103[existingItemIndex + 1], 'optionalAccess', _104 => _104._parentPos]))
5845
5834
  );
5846
5835
  }
5847
5836
  child._setParentLink(this, newKey);
@@ -5860,7 +5849,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5860
5849
  if (existingItemIndex !== -1) {
5861
5850
  this.#items[existingItemIndex]._setParentLink(
5862
5851
  this,
5863
- makePosition(newKey, _optionalChain([this, 'access', _106 => _106.#items, 'access', _107 => _107[existingItemIndex + 1], 'optionalAccess', _108 => _108._parentPos]))
5852
+ makePosition(newKey, _optionalChain([this, 'access', _105 => _105.#items, 'access', _106 => _106[existingItemIndex + 1], 'optionalAccess', _107 => _107._parentPos]))
5864
5853
  );
5865
5854
  }
5866
5855
  child._setParentLink(this, newKey);
@@ -5887,7 +5876,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5887
5876
  if (existingItemIndex !== -1) {
5888
5877
  this.#items[existingItemIndex]._setParentLink(
5889
5878
  this,
5890
- makePosition(newKey, _optionalChain([this, 'access', _109 => _109.#items, 'access', _110 => _110[existingItemIndex + 1], 'optionalAccess', _111 => _111._parentPos]))
5879
+ makePosition(newKey, _optionalChain([this, 'access', _108 => _108.#items, 'access', _109 => _109[existingItemIndex + 1], 'optionalAccess', _110 => _110._parentPos]))
5891
5880
  );
5892
5881
  }
5893
5882
  child._setParentLink(this, newKey);
@@ -5945,7 +5934,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5945
5934
  * @param element The element to add to the end of the LiveList.
5946
5935
  */
5947
5936
  push(element) {
5948
- _optionalChain([this, 'access', _112 => _112._pool, 'optionalAccess', _113 => _113.assertStorageIsWritable, 'call', _114 => _114()]);
5937
+ _optionalChain([this, 'access', _111 => _111._pool, 'optionalAccess', _112 => _112.assertStorageIsWritable, 'call', _113 => _113()]);
5949
5938
  return this.insert(element, this.length);
5950
5939
  }
5951
5940
  /**
@@ -5954,7 +5943,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5954
5943
  * @param index The index at which you want to insert the element.
5955
5944
  */
5956
5945
  insert(element, index) {
5957
- _optionalChain([this, 'access', _115 => _115._pool, 'optionalAccess', _116 => _116.assertStorageIsWritable, 'call', _117 => _117()]);
5946
+ _optionalChain([this, 'access', _114 => _114._pool, 'optionalAccess', _115 => _115.assertStorageIsWritable, 'call', _116 => _116()]);
5958
5947
  if (index < 0 || index > this.#items.length) {
5959
5948
  throw new Error(
5960
5949
  `Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
@@ -5984,7 +5973,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5984
5973
  * @param targetIndex The index where the element should be after moving.
5985
5974
  */
5986
5975
  move(index, targetIndex) {
5987
- _optionalChain([this, 'access', _118 => _118._pool, 'optionalAccess', _119 => _119.assertStorageIsWritable, 'call', _120 => _120()]);
5976
+ _optionalChain([this, 'access', _117 => _117._pool, 'optionalAccess', _118 => _118.assertStorageIsWritable, 'call', _119 => _119()]);
5988
5977
  if (targetIndex < 0) {
5989
5978
  throw new Error("targetIndex cannot be less than 0");
5990
5979
  }
@@ -6042,7 +6031,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6042
6031
  * @param index The index of the element to delete
6043
6032
  */
6044
6033
  delete(index) {
6045
- _optionalChain([this, 'access', _121 => _121._pool, 'optionalAccess', _122 => _122.assertStorageIsWritable, 'call', _123 => _123()]);
6034
+ _optionalChain([this, 'access', _120 => _120._pool, 'optionalAccess', _121 => _121.assertStorageIsWritable, 'call', _122 => _122()]);
6046
6035
  if (index < 0 || index >= this.#items.length) {
6047
6036
  throw new Error(
6048
6037
  `Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -6075,7 +6064,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6075
6064
  }
6076
6065
  }
6077
6066
  clear() {
6078
- _optionalChain([this, 'access', _124 => _124._pool, 'optionalAccess', _125 => _125.assertStorageIsWritable, 'call', _126 => _126()]);
6067
+ _optionalChain([this, 'access', _123 => _123._pool, 'optionalAccess', _124 => _124.assertStorageIsWritable, 'call', _125 => _125()]);
6079
6068
  if (this._pool) {
6080
6069
  const ops = [];
6081
6070
  const reverseOps = [];
@@ -6109,7 +6098,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6109
6098
  }
6110
6099
  }
6111
6100
  set(index, item) {
6112
- _optionalChain([this, 'access', _127 => _127._pool, 'optionalAccess', _128 => _128.assertStorageIsWritable, 'call', _129 => _129()]);
6101
+ _optionalChain([this, 'access', _126 => _126._pool, 'optionalAccess', _127 => _127.assertStorageIsWritable, 'call', _128 => _128()]);
6113
6102
  if (index < 0 || index >= this.#items.length) {
6114
6103
  throw new Error(
6115
6104
  `Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -6255,7 +6244,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6255
6244
  #shiftItemPosition(index, key) {
6256
6245
  const shiftedPosition = makePosition(
6257
6246
  key,
6258
- this.#items.length > index + 1 ? _optionalChain([this, 'access', _130 => _130.#items, 'access', _131 => _131[index + 1], 'optionalAccess', _132 => _132._parentPos]) : void 0
6247
+ this.#items.length > index + 1 ? _optionalChain([this, 'access', _129 => _129.#items, 'access', _130 => _130[index + 1], 'optionalAccess', _131 => _131._parentPos]) : void 0
6259
6248
  );
6260
6249
  this.#items[index]._setParentLink(this, shiftedPosition);
6261
6250
  }
@@ -6380,7 +6369,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
6380
6369
  const ops = [];
6381
6370
  const op = {
6382
6371
  id: this._id,
6383
- opId: _optionalChain([pool, 'optionalAccess', _133 => _133.generateOpId, 'call', _134 => _134()]),
6372
+ opId: _optionalChain([pool, 'optionalAccess', _132 => _132.generateOpId, 'call', _133 => _133()]),
6384
6373
  type: 7 /* CREATE_MAP */,
6385
6374
  parentId,
6386
6375
  parentKey
@@ -6515,7 +6504,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
6515
6504
  * @param value The value of the element to add. Should be serializable to JSON.
6516
6505
  */
6517
6506
  set(key, value) {
6518
- _optionalChain([this, 'access', _135 => _135._pool, 'optionalAccess', _136 => _136.assertStorageIsWritable, 'call', _137 => _137()]);
6507
+ _optionalChain([this, 'access', _134 => _134._pool, 'optionalAccess', _135 => _135.assertStorageIsWritable, 'call', _136 => _136()]);
6519
6508
  const oldValue = this.#map.get(key);
6520
6509
  if (oldValue) {
6521
6510
  oldValue._detach();
@@ -6561,7 +6550,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
6561
6550
  * @returns true if an element existed and has been removed, or false if the element does not exist.
6562
6551
  */
6563
6552
  delete(key) {
6564
- _optionalChain([this, 'access', _138 => _138._pool, 'optionalAccess', _139 => _139.assertStorageIsWritable, 'call', _140 => _140()]);
6553
+ _optionalChain([this, 'access', _137 => _137._pool, 'optionalAccess', _138 => _138.assertStorageIsWritable, 'call', _139 => _139()]);
6565
6554
  const item = this.#map.get(key);
6566
6555
  if (item === void 0) {
6567
6556
  return false;
@@ -6740,7 +6729,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
6740
6729
  if (this._id === void 0) {
6741
6730
  throw new Error("Cannot serialize item is not attached");
6742
6731
  }
6743
- const opId = _optionalChain([pool, 'optionalAccess', _141 => _141.generateOpId, 'call', _142 => _142()]);
6732
+ const opId = _optionalChain([pool, 'optionalAccess', _140 => _140.generateOpId, 'call', _141 => _141()]);
6744
6733
  const ops = [];
6745
6734
  const op = {
6746
6735
  type: 4 /* CREATE_OBJECT */,
@@ -7012,7 +7001,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
7012
7001
  * @param value The value of the property to add
7013
7002
  */
7014
7003
  set(key, value) {
7015
- _optionalChain([this, 'access', _143 => _143._pool, 'optionalAccess', _144 => _144.assertStorageIsWritable, 'call', _145 => _145()]);
7004
+ _optionalChain([this, 'access', _142 => _142._pool, 'optionalAccess', _143 => _143.assertStorageIsWritable, 'call', _144 => _144()]);
7016
7005
  this.update({ [key]: value });
7017
7006
  }
7018
7007
  /**
@@ -7027,7 +7016,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
7027
7016
  * @param key The key of the property to delete
7028
7017
  */
7029
7018
  delete(key) {
7030
- _optionalChain([this, 'access', _146 => _146._pool, 'optionalAccess', _147 => _147.assertStorageIsWritable, 'call', _148 => _148()]);
7019
+ _optionalChain([this, 'access', _145 => _145._pool, 'optionalAccess', _146 => _146.assertStorageIsWritable, 'call', _147 => _147()]);
7031
7020
  const keyAsString = key;
7032
7021
  const oldValue = this.#map.get(keyAsString);
7033
7022
  if (oldValue === void 0) {
@@ -7080,7 +7069,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
7080
7069
  * @param patch The object used to overrides properties
7081
7070
  */
7082
7071
  update(patch) {
7083
- _optionalChain([this, 'access', _149 => _149._pool, 'optionalAccess', _150 => _150.assertStorageIsWritable, 'call', _151 => _151()]);
7072
+ _optionalChain([this, 'access', _148 => _148._pool, 'optionalAccess', _149 => _149.assertStorageIsWritable, 'call', _150 => _150()]);
7084
7073
  if (this._pool === void 0 || this._id === void 0) {
7085
7074
  for (const key in patch) {
7086
7075
  const newValue = patch[key];
@@ -7803,15 +7792,15 @@ function installBackgroundTabSpy() {
7803
7792
  const doc = typeof document !== "undefined" ? document : void 0;
7804
7793
  const inBackgroundSince = { current: null };
7805
7794
  function onVisibilityChange() {
7806
- if (_optionalChain([doc, 'optionalAccess', _152 => _152.visibilityState]) === "hidden") {
7795
+ if (_optionalChain([doc, 'optionalAccess', _151 => _151.visibilityState]) === "hidden") {
7807
7796
  inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
7808
7797
  } else {
7809
7798
  inBackgroundSince.current = null;
7810
7799
  }
7811
7800
  }
7812
- _optionalChain([doc, 'optionalAccess', _153 => _153.addEventListener, 'call', _154 => _154("visibilitychange", onVisibilityChange)]);
7801
+ _optionalChain([doc, 'optionalAccess', _152 => _152.addEventListener, 'call', _153 => _153("visibilitychange", onVisibilityChange)]);
7813
7802
  const unsub = () => {
7814
- _optionalChain([doc, 'optionalAccess', _155 => _155.removeEventListener, 'call', _156 => _156("visibilitychange", onVisibilityChange)]);
7803
+ _optionalChain([doc, 'optionalAccess', _154 => _154.removeEventListener, 'call', _155 => _155("visibilitychange", onVisibilityChange)]);
7815
7804
  };
7816
7805
  return [inBackgroundSince, unsub];
7817
7806
  }
@@ -7991,7 +7980,7 @@ function createRoom(options, config) {
7991
7980
  }
7992
7981
  }
7993
7982
  function isStorageWritable() {
7994
- const scopes = _optionalChain([context, 'access', _157 => _157.dynamicSessionInfoSig, 'access', _158 => _158.get, 'call', _159 => _159(), 'optionalAccess', _160 => _160.scopes]);
7983
+ const scopes = _optionalChain([context, 'access', _156 => _156.dynamicSessionInfoSig, 'access', _157 => _157.get, 'call', _158 => _158(), 'optionalAccess', _159 => _159.scopes]);
7995
7984
  return scopes !== void 0 ? canWriteStorage(scopes) : true;
7996
7985
  }
7997
7986
  const eventHub = {
@@ -8108,7 +8097,7 @@ function createRoom(options, config) {
8108
8097
  }
8109
8098
  case "experimental-fallback-to-http": {
8110
8099
  warn("Message is too large for websockets, so sending over HTTP instead");
8111
- const nonce = _nullishCoalesce(_optionalChain([context, 'access', _161 => _161.dynamicSessionInfoSig, 'access', _162 => _162.get, 'call', _163 => _163(), 'optionalAccess', _164 => _164.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
8100
+ const nonce = _nullishCoalesce(_optionalChain([context, 'access', _160 => _160.dynamicSessionInfoSig, 'access', _161 => _161.get, 'call', _162 => _162(), 'optionalAccess', _163 => _163.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
8112
8101
  void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
8113
8102
  if (!resp.ok && resp.status === 403) {
8114
8103
  managedSocket.reconnect();
@@ -8159,7 +8148,7 @@ function createRoom(options, config) {
8159
8148
  } else {
8160
8149
  context.root = LiveObject._fromItems(message.items, context.pool);
8161
8150
  }
8162
- const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _165 => _165.get, 'call', _166 => _166(), 'optionalAccess', _167 => _167.canWrite]), () => ( true));
8151
+ const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _164 => _164.get, 'call', _165 => _165(), 'optionalAccess', _166 => _166.canWrite]), () => ( true));
8163
8152
  const stackSizeBefore = context.undoStack.length;
8164
8153
  for (const key in context.initialStorage) {
8165
8154
  if (context.root.get(key) === void 0) {
@@ -8362,7 +8351,7 @@ function createRoom(options, config) {
8362
8351
  }
8363
8352
  context.myPresence.patch(patch);
8364
8353
  if (context.activeBatch) {
8365
- if (_optionalChain([options2, 'optionalAccess', _168 => _168.addToHistory])) {
8354
+ if (_optionalChain([options2, 'optionalAccess', _167 => _167.addToHistory])) {
8366
8355
  context.activeBatch.reverseOps.pushLeft({
8367
8356
  type: "presence",
8368
8357
  data: oldValues
@@ -8371,7 +8360,7 @@ function createRoom(options, config) {
8371
8360
  context.activeBatch.updates.presence = true;
8372
8361
  } else {
8373
8362
  flushNowOrSoon();
8374
- if (_optionalChain([options2, 'optionalAccess', _169 => _169.addToHistory])) {
8363
+ if (_optionalChain([options2, 'optionalAccess', _168 => _168.addToHistory])) {
8375
8364
  addToUndoStack([{ type: "presence", data: oldValues }]);
8376
8365
  }
8377
8366
  notify({ presence: true });
@@ -8568,7 +8557,7 @@ function createRoom(options, config) {
8568
8557
  if (process.env.NODE_ENV !== "production") {
8569
8558
  const traces = /* @__PURE__ */ new Set();
8570
8559
  for (const opId of message.opIds) {
8571
- const trace = _optionalChain([context, 'access', _170 => _170.opStackTraces, 'optionalAccess', _171 => _171.get, 'call', _172 => _172(opId)]);
8560
+ const trace = _optionalChain([context, 'access', _169 => _169.opStackTraces, 'optionalAccess', _170 => _170.get, 'call', _171 => _171(opId)]);
8572
8561
  if (trace) {
8573
8562
  traces.add(trace);
8574
8563
  }
@@ -8702,7 +8691,7 @@ ${Array.from(traces).join("\n\n")}`
8702
8691
  const unacknowledgedOps = new Map(context.unacknowledgedOps);
8703
8692
  createOrUpdateRootFromMessage(message);
8704
8693
  applyAndSendOps(unacknowledgedOps);
8705
- _optionalChain([_resolveStoragePromise, 'optionalCall', _173 => _173()]);
8694
+ _optionalChain([_resolveStoragePromise, 'optionalCall', _172 => _172()]);
8706
8695
  notifyStorageStatus();
8707
8696
  eventHub.storageDidLoad.notify();
8708
8697
  }
@@ -8925,8 +8914,8 @@ ${Array.from(traces).join("\n\n")}`
8925
8914
  async function getThreads(options2) {
8926
8915
  return httpClient.getThreads({
8927
8916
  roomId,
8928
- query: _optionalChain([options2, 'optionalAccess', _174 => _174.query]),
8929
- cursor: _optionalChain([options2, 'optionalAccess', _175 => _175.cursor])
8917
+ query: _optionalChain([options2, 'optionalAccess', _173 => _173.query]),
8918
+ cursor: _optionalChain([options2, 'optionalAccess', _174 => _174.cursor])
8930
8919
  });
8931
8920
  }
8932
8921
  async function getThread(threadId) {
@@ -9033,7 +9022,7 @@ ${Array.from(traces).join("\n\n")}`
9033
9022
  function getSubscriptionSettings(options2) {
9034
9023
  return httpClient.getSubscriptionSettings({
9035
9024
  roomId,
9036
- signal: _optionalChain([options2, 'optionalAccess', _176 => _176.signal])
9025
+ signal: _optionalChain([options2, 'optionalAccess', _175 => _175.signal])
9037
9026
  });
9038
9027
  }
9039
9028
  function updateSubscriptionSettings(settings) {
@@ -9055,7 +9044,7 @@ ${Array.from(traces).join("\n\n")}`
9055
9044
  {
9056
9045
  [kInternal]: {
9057
9046
  get presenceBuffer() {
9058
- return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _177 => _177.buffer, 'access', _178 => _178.presenceUpdates, 'optionalAccess', _179 => _179.data]), () => ( null)));
9047
+ return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _176 => _176.buffer, 'access', _177 => _177.presenceUpdates, 'optionalAccess', _178 => _178.data]), () => ( null)));
9059
9048
  },
9060
9049
  // prettier-ignore
9061
9050
  get undoStack() {
@@ -9070,9 +9059,9 @@ ${Array.from(traces).join("\n\n")}`
9070
9059
  return context.yjsProvider;
9071
9060
  },
9072
9061
  setYjsProvider(newProvider) {
9073
- _optionalChain([context, 'access', _180 => _180.yjsProvider, 'optionalAccess', _181 => _181.off, 'call', _182 => _182("status", yjsStatusDidChange)]);
9062
+ _optionalChain([context, 'access', _179 => _179.yjsProvider, 'optionalAccess', _180 => _180.off, 'call', _181 => _181("status", yjsStatusDidChange)]);
9074
9063
  context.yjsProvider = newProvider;
9075
- _optionalChain([newProvider, 'optionalAccess', _183 => _183.on, 'call', _184 => _184("status", yjsStatusDidChange)]);
9064
+ _optionalChain([newProvider, 'optionalAccess', _182 => _182.on, 'call', _183 => _183("status", yjsStatusDidChange)]);
9076
9065
  context.yjsProviderDidChange.notify();
9077
9066
  },
9078
9067
  yjsProviderDidChange: context.yjsProviderDidChange.observable,
@@ -9118,7 +9107,7 @@ ${Array.from(traces).join("\n\n")}`
9118
9107
  source.dispose();
9119
9108
  }
9120
9109
  eventHub.roomWillDestroy.notify();
9121
- _optionalChain([context, 'access', _185 => _185.yjsProvider, 'optionalAccess', _186 => _186.off, 'call', _187 => _187("status", yjsStatusDidChange)]);
9110
+ _optionalChain([context, 'access', _184 => _184.yjsProvider, 'optionalAccess', _185 => _185.off, 'call', _186 => _186("status", yjsStatusDidChange)]);
9122
9111
  syncSourceForStorage.destroy();
9123
9112
  syncSourceForYjs.destroy();
9124
9113
  uninstallBgTabSpy();
@@ -9268,7 +9257,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
9268
9257
  }
9269
9258
  if (isLiveNode(first)) {
9270
9259
  const node = first;
9271
- if (_optionalChain([options, 'optionalAccess', _188 => _188.isDeep])) {
9260
+ if (_optionalChain([options, 'optionalAccess', _187 => _187.isDeep])) {
9272
9261
  const storageCallback = second;
9273
9262
  return subscribeToLiveStructureDeeply(node, storageCallback);
9274
9263
  } else {
@@ -9347,8 +9336,8 @@ function createClient(options) {
9347
9336
  const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
9348
9337
  currentUserId.set(() => userId);
9349
9338
  });
9350
- const fetchPolyfill = _optionalChain([clientOptions, 'access', _189 => _189.polyfills, 'optionalAccess', _190 => _190.fetch]) || /* istanbul ignore next */
9351
- _optionalChain([globalThis, 'access', _191 => _191.fetch, 'optionalAccess', _192 => _192.bind, 'call', _193 => _193(globalThis)]);
9339
+ const fetchPolyfill = _optionalChain([clientOptions, 'access', _188 => _188.polyfills, 'optionalAccess', _189 => _189.fetch]) || /* istanbul ignore next */
9340
+ _optionalChain([globalThis, 'access', _190 => _190.fetch, 'optionalAccess', _191 => _191.bind, 'call', _192 => _192(globalThis)]);
9352
9341
  const httpClient = createApiClient({
9353
9342
  baseUrl,
9354
9343
  fetchPolyfill,
@@ -9366,7 +9355,7 @@ function createClient(options) {
9366
9355
  delegates: {
9367
9356
  createSocket: makeCreateSocketDelegateForAi(
9368
9357
  baseUrl,
9369
- _optionalChain([clientOptions, 'access', _194 => _194.polyfills, 'optionalAccess', _195 => _195.WebSocket])
9358
+ _optionalChain([clientOptions, 'access', _193 => _193.polyfills, 'optionalAccess', _194 => _194.WebSocket])
9370
9359
  ),
9371
9360
  authenticate: makeAuthDelegateForRoom("default", authManager),
9372
9361
  canZombie: () => true
@@ -9416,7 +9405,7 @@ function createClient(options) {
9416
9405
  createSocket: makeCreateSocketDelegateForRoom(
9417
9406
  roomId,
9418
9407
  baseUrl,
9419
- _optionalChain([clientOptions, 'access', _196 => _196.polyfills, 'optionalAccess', _197 => _197.WebSocket])
9408
+ _optionalChain([clientOptions, 'access', _195 => _195.polyfills, 'optionalAccess', _196 => _196.WebSocket])
9420
9409
  ),
9421
9410
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
9422
9411
  })),
@@ -9439,7 +9428,7 @@ function createClient(options) {
9439
9428
  const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
9440
9429
  if (shouldConnect) {
9441
9430
  if (typeof atob === "undefined") {
9442
- if (_optionalChain([clientOptions, 'access', _198 => _198.polyfills, 'optionalAccess', _199 => _199.atob]) === void 0) {
9431
+ if (_optionalChain([clientOptions, 'access', _197 => _197.polyfills, 'optionalAccess', _198 => _198.atob]) === void 0) {
9443
9432
  throw new Error(
9444
9433
  "You need to polyfill atob to use the client in your environment. Please follow the instructions at https://liveblocks.io/docs/errors/liveblocks-client/atob-polyfill"
9445
9434
  );
@@ -9451,7 +9440,7 @@ function createClient(options) {
9451
9440
  return leaseRoom(newRoomDetails);
9452
9441
  }
9453
9442
  function getRoom(roomId) {
9454
- const room = _optionalChain([roomsById, 'access', _200 => _200.get, 'call', _201 => _201(roomId), 'optionalAccess', _202 => _202.room]);
9443
+ const room = _optionalChain([roomsById, 'access', _199 => _199.get, 'call', _200 => _200(roomId), 'optionalAccess', _201 => _201.room]);
9455
9444
  return room ? room : null;
9456
9445
  }
9457
9446
  function logout() {
@@ -9471,7 +9460,7 @@ function createClient(options) {
9471
9460
  const batchedResolveUsers = new Batch(
9472
9461
  async (batchedUserIds) => {
9473
9462
  const userIds = batchedUserIds.flat();
9474
- const users = await _optionalChain([resolveUsers, 'optionalCall', _203 => _203({ userIds })]);
9463
+ const users = await _optionalChain([resolveUsers, 'optionalCall', _202 => _202({ userIds })]);
9475
9464
  warnIfNoResolveUsers();
9476
9465
  return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
9477
9466
  },
@@ -9489,7 +9478,7 @@ function createClient(options) {
9489
9478
  const batchedResolveRoomsInfo = new Batch(
9490
9479
  async (batchedRoomIds) => {
9491
9480
  const roomIds = batchedRoomIds.flat();
9492
- const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _204 => _204({ roomIds })]);
9481
+ const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _203 => _203({ roomIds })]);
9493
9482
  warnIfNoResolveRoomsInfo();
9494
9483
  return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
9495
9484
  },
@@ -9542,7 +9531,7 @@ function createClient(options) {
9542
9531
  }
9543
9532
  };
9544
9533
  const win = typeof window !== "undefined" ? window : void 0;
9545
- _optionalChain([win, 'optionalAccess', _205 => _205.addEventListener, 'call', _206 => _206("beforeunload", maybePreventClose)]);
9534
+ _optionalChain([win, 'optionalAccess', _204 => _204.addEventListener, 'call', _205 => _205("beforeunload", maybePreventClose)]);
9546
9535
  }
9547
9536
  async function getNotificationSettings(options2) {
9548
9537
  const plainSettings = await httpClient.getNotificationSettings(options2);
@@ -9681,7 +9670,7 @@ var commentBodyElementsTypes = {
9681
9670
  mention: "inline"
9682
9671
  };
9683
9672
  function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
9684
- if (!body || !_optionalChain([body, 'optionalAccess', _207 => _207.content])) {
9673
+ if (!body || !_optionalChain([body, 'optionalAccess', _206 => _206.content])) {
9685
9674
  return;
9686
9675
  }
9687
9676
  const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
@@ -9691,13 +9680,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
9691
9680
  for (const block of body.content) {
9692
9681
  if (type === "all" || type === "block") {
9693
9682
  if (guard(block)) {
9694
- _optionalChain([visitor, 'optionalCall', _208 => _208(block)]);
9683
+ _optionalChain([visitor, 'optionalCall', _207 => _207(block)]);
9695
9684
  }
9696
9685
  }
9697
9686
  if (type === "all" || type === "inline") {
9698
9687
  for (const inline of block.children) {
9699
9688
  if (guard(inline)) {
9700
- _optionalChain([visitor, 'optionalCall', _209 => _209(inline)]);
9689
+ _optionalChain([visitor, 'optionalCall', _208 => _208(inline)]);
9701
9690
  }
9702
9691
  }
9703
9692
  }
@@ -9722,7 +9711,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
9722
9711
  userIds
9723
9712
  });
9724
9713
  for (const [index, userId] of userIds.entries()) {
9725
- const user = _optionalChain([users, 'optionalAccess', _210 => _210[index]]);
9714
+ const user = _optionalChain([users, 'optionalAccess', _209 => _209[index]]);
9726
9715
  if (user) {
9727
9716
  resolvedUsers.set(userId, user);
9728
9717
  }
@@ -9849,7 +9838,7 @@ var stringifyCommentBodyPlainElements = {
9849
9838
  text: ({ element }) => element.text,
9850
9839
  link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
9851
9840
  mention: ({ element, user }) => {
9852
- return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _211 => _211.name]), () => ( element.id))}`;
9841
+ return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _210 => _210.name]), () => ( element.id))}`;
9853
9842
  }
9854
9843
  };
9855
9844
  var stringifyCommentBodyHtmlElements = {
@@ -9879,7 +9868,7 @@ var stringifyCommentBodyHtmlElements = {
9879
9868
  return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
9880
9869
  },
9881
9870
  mention: ({ element, user }) => {
9882
- return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _212 => _212.name]) ? html`${_optionalChain([user, 'optionalAccess', _213 => _213.name])}` : element.id}</span>`;
9871
+ return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _211 => _211.name]) ? html`${_optionalChain([user, 'optionalAccess', _212 => _212.name])}` : element.id}</span>`;
9883
9872
  }
9884
9873
  };
9885
9874
  var stringifyCommentBodyMarkdownElements = {
@@ -9909,19 +9898,19 @@ var stringifyCommentBodyMarkdownElements = {
9909
9898
  return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
9910
9899
  },
9911
9900
  mention: ({ element, user }) => {
9912
- return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _214 => _214.name]), () => ( element.id))}`;
9901
+ return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _213 => _213.name]), () => ( element.id))}`;
9913
9902
  }
9914
9903
  };
9915
9904
  async function stringifyCommentBody(body, options) {
9916
- const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _215 => _215.format]), () => ( "plain"));
9917
- const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _216 => _216.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
9905
+ const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _214 => _214.format]), () => ( "plain"));
9906
+ const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _215 => _215.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
9918
9907
  const elements = {
9919
9908
  ...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
9920
- ..._optionalChain([options, 'optionalAccess', _217 => _217.elements])
9909
+ ..._optionalChain([options, 'optionalAccess', _216 => _216.elements])
9921
9910
  };
9922
9911
  const resolvedUsers = await resolveUsersInCommentBody(
9923
9912
  body,
9924
- _optionalChain([options, 'optionalAccess', _218 => _218.resolveUsers])
9913
+ _optionalChain([options, 'optionalAccess', _217 => _217.resolveUsers])
9925
9914
  );
9926
9915
  const blocks = body.content.flatMap((block, blockIndex) => {
9927
9916
  switch (block.type) {
@@ -10212,12 +10201,12 @@ function legacy_patchImmutableNode(state, path, update) {
10212
10201
  }
10213
10202
  const newState = Object.assign({}, state);
10214
10203
  for (const key in update.updates) {
10215
- if (_optionalChain([update, 'access', _219 => _219.updates, 'access', _220 => _220[key], 'optionalAccess', _221 => _221.type]) === "update") {
10204
+ if (_optionalChain([update, 'access', _218 => _218.updates, 'access', _219 => _219[key], 'optionalAccess', _220 => _220.type]) === "update") {
10216
10205
  const val = update.node.get(key);
10217
10206
  if (val !== void 0) {
10218
10207
  newState[key] = lsonToJson(val);
10219
10208
  }
10220
- } else if (_optionalChain([update, 'access', _222 => _222.updates, 'access', _223 => _223[key], 'optionalAccess', _224 => _224.type]) === "delete") {
10209
+ } else if (_optionalChain([update, 'access', _221 => _221.updates, 'access', _222 => _222[key], 'optionalAccess', _223 => _223.type]) === "delete") {
10221
10210
  delete newState[key];
10222
10211
  }
10223
10212
  }
@@ -10278,12 +10267,12 @@ function legacy_patchImmutableNode(state, path, update) {
10278
10267
  }
10279
10268
  const newState = Object.assign({}, state);
10280
10269
  for (const key in update.updates) {
10281
- if (_optionalChain([update, 'access', _225 => _225.updates, 'access', _226 => _226[key], 'optionalAccess', _227 => _227.type]) === "update") {
10270
+ if (_optionalChain([update, 'access', _224 => _224.updates, 'access', _225 => _225[key], 'optionalAccess', _226 => _226.type]) === "update") {
10282
10271
  const value = update.node.get(key);
10283
10272
  if (value !== void 0) {
10284
10273
  newState[key] = lsonToJson(value);
10285
10274
  }
10286
- } else if (_optionalChain([update, 'access', _228 => _228.updates, 'access', _229 => _229[key], 'optionalAccess', _230 => _230.type]) === "delete") {
10275
+ } else if (_optionalChain([update, 'access', _227 => _227.updates, 'access', _228 => _228[key], 'optionalAccess', _229 => _229.type]) === "delete") {
10287
10276
  delete newState[key];
10288
10277
  }
10289
10278
  }
@@ -10363,9 +10352,9 @@ function makePoller(callback, intervalMs, options) {
10363
10352
  const startTime = performance.now();
10364
10353
  const doc = typeof document !== "undefined" ? document : void 0;
10365
10354
  const win = typeof window !== "undefined" ? window : void 0;
10366
- const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _231 => _231.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
10355
+ const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _230 => _230.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
10367
10356
  const context = {
10368
- inForeground: _optionalChain([doc, 'optionalAccess', _232 => _232.visibilityState]) !== "hidden",
10357
+ inForeground: _optionalChain([doc, 'optionalAccess', _231 => _231.visibilityState]) !== "hidden",
10369
10358
  lastSuccessfulPollAt: startTime,
10370
10359
  count: 0,
10371
10360
  backoff: 0
@@ -10446,11 +10435,11 @@ function makePoller(callback, intervalMs, options) {
10446
10435
  pollNowIfStale();
10447
10436
  }
10448
10437
  function onVisibilityChange() {
10449
- setInForeground(_optionalChain([doc, 'optionalAccess', _233 => _233.visibilityState]) !== "hidden");
10438
+ setInForeground(_optionalChain([doc, 'optionalAccess', _232 => _232.visibilityState]) !== "hidden");
10450
10439
  }
10451
- _optionalChain([doc, 'optionalAccess', _234 => _234.addEventListener, 'call', _235 => _235("visibilitychange", onVisibilityChange)]);
10452
- _optionalChain([win, 'optionalAccess', _236 => _236.addEventListener, 'call', _237 => _237("online", onVisibilityChange)]);
10453
- _optionalChain([win, 'optionalAccess', _238 => _238.addEventListener, 'call', _239 => _239("focus", pollNowIfStale)]);
10440
+ _optionalChain([doc, 'optionalAccess', _233 => _233.addEventListener, 'call', _234 => _234("visibilitychange", onVisibilityChange)]);
10441
+ _optionalChain([win, 'optionalAccess', _235 => _235.addEventListener, 'call', _236 => _236("online", onVisibilityChange)]);
10442
+ _optionalChain([win, 'optionalAccess', _237 => _237.addEventListener, 'call', _238 => _238("focus", pollNowIfStale)]);
10454
10443
  fsm.start();
10455
10444
  return {
10456
10445
  inc,