@liveblocks/core 2.25.0-aiprivatebeta10 → 2.25.0-aiprivatebeta12

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-aiprivatebeta10";
9
+ var PKG_VERSION = "2.25.0-aiprivatebeta12";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -3780,46 +3780,61 @@ var KnowledgeStack = class {
3780
3780
  function now() {
3781
3781
  return (/* @__PURE__ */ new Date()).toISOString();
3782
3782
  }
3783
+ var kWILDCARD = Symbol("*");
3783
3784
  function createStore_forTools() {
3784
- const toolsByChatId\u03A3 = new DefaultMap((_chatId) => {
3785
- return new DefaultMap((_toolName) => {
3786
- return new Signal(void 0);
3785
+ const toolsByChatId\u03A3 = new DefaultMap(
3786
+ (_chatId) => {
3787
+ return new DefaultMap((_name) => {
3788
+ return new Signal(void 0);
3789
+ });
3790
+ }
3791
+ );
3792
+ const globalOrScopedTool\u03A3 = new DefaultMap((nameAndChat) => {
3793
+ const [name, chatId] = tryParseJson(nameAndChat);
3794
+ return DerivedSignal.from(() => {
3795
+ return (
3796
+ // A tool that's registered and scoped to a specific chat ID...
3797
+ _nullishCoalesce(_optionalChain([(chatId !== void 0 ? _optionalChain([toolsByChatId\u03A3, 'access', _57 => _57.get, 'call', _58 => _58(chatId), 'optionalAccess', _59 => _59.get, 'call', _60 => _60(name)]) : void 0), 'optionalAccess', _61 => _61.get, 'call', _62 => _62()]), () => ( // ...or a globally registered tool
3798
+ _optionalChain([toolsByChatId\u03A3, 'access', _63 => _63.getOrCreate, 'call', _64 => _64(kWILDCARD), 'access', _65 => _65.get, 'call', _66 => _66(name), 'optionalAccess', _67 => _67.get, 'call', _68 => _68()])))
3799
+ );
3787
3800
  });
3788
3801
  });
3789
- function getToolDefinition\u03A3(chatId, toolName) {
3790
- return toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(toolName);
3802
+ function getTool\u03A3(name, chatId) {
3803
+ const key = JSON.stringify(chatId !== void 0 ? [name, chatId] : [name]);
3804
+ return globalOrScopedTool\u03A3.getOrCreate(key);
3791
3805
  }
3792
- function addToolDefinition(chatId, name, definition) {
3793
- if (!definition.execute && !definition.render) {
3806
+ function registerTool(name, tool, chatId) {
3807
+ if (!tool.execute && !tool.render) {
3794
3808
  throw new Error(
3795
- "A tool definition must have an execute() function, a render property, or both."
3809
+ "A tool definition must have an execute() function, a render() function, or both."
3796
3810
  );
3797
3811
  }
3798
- toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name).set(definition);
3812
+ const key = _nullishCoalesce(chatId, () => ( kWILDCARD));
3813
+ toolsByChatId\u03A3.getOrCreate(key).getOrCreate(name).set(tool);
3814
+ return () => unregisterTool(key, name);
3799
3815
  }
3800
- function removeToolDefinition(chatId, toolName) {
3816
+ function unregisterTool(chatId, name) {
3801
3817
  const tools = toolsByChatId\u03A3.get(chatId);
3802
3818
  if (tools === void 0) return;
3803
- const tool = tools.get(toolName);
3819
+ const tool = tools.get(name);
3804
3820
  if (tool === void 0) return;
3805
3821
  tool.set(void 0);
3806
3822
  }
3807
- function getToolsForChat(chatId) {
3808
- const tools = toolsByChatId\u03A3.get(chatId);
3809
- if (tools === void 0) return [];
3810
- return Array.from(tools.entries()).map(([name, tool]) => {
3811
- if (tool.get() === void 0) return null;
3812
- return {
3813
- name,
3814
- definition: tool.get()
3815
- };
3816
- }).filter((tool) => tool !== null);
3823
+ function getToolDescriptions(chatId) {
3824
+ const globalTools\u03A3 = toolsByChatId\u03A3.get(kWILDCARD);
3825
+ const scopedTools\u03A3 = toolsByChatId\u03A3.get(chatId);
3826
+ return Array.from([
3827
+ ..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _69 => _69.entries, 'call', _70 => _70()]), () => ( [])),
3828
+ ..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _71 => _71.entries, 'call', _72 => _72()]), () => ( []))
3829
+ ]).flatMap(([name, tool\u03A3]) => {
3830
+ const tool = tool\u03A3.get();
3831
+ return tool ? [{ name, description: tool.description, parameters: tool.parameters }] : [];
3832
+ });
3817
3833
  }
3818
3834
  return {
3819
- getToolDefinition\u03A3,
3820
- getToolsForChat,
3821
- addToolDefinition,
3822
- removeToolDefinition
3835
+ getToolDescriptions,
3836
+ getTool\u03A3,
3837
+ registerTool
3823
3838
  };
3824
3839
  }
3825
3840
  function createStore_forChatMessages(toolsStore, setToolResult) {
@@ -3905,16 +3920,16 @@ function createStore_forChatMessages(toolsStore, setToolResult) {
3905
3920
  for (const toolCall of message.contentSoFar.filter(
3906
3921
  (part) => part.type === "tool-invocation" && part.status === "executing"
3907
3922
  )) {
3908
- if (seenToolCallIds.has(toolCall.toolCallId)) {
3923
+ if (seenToolCallIds.has(toolCall.invocationId)) {
3909
3924
  continue;
3910
3925
  }
3911
- seenToolCallIds.add(toolCall.toolCallId);
3912
- const toolDef = toolsStore.getToolDefinition\u03A3(message.chatId, toolCall.toolName).get();
3926
+ seenToolCallIds.add(toolCall.invocationId);
3927
+ const toolDef = toolsStore.getTool\u03A3(toolCall.name, message.chatId).get();
3913
3928
  const respondSync = (result) => {
3914
3929
  setToolResult(
3915
3930
  message.chatId,
3916
3931
  message.id,
3917
- toolCall.toolCallId,
3932
+ toolCall.invocationId,
3918
3933
  result
3919
3934
  // TODO Pass in AiGenerationOptions here, or make the backend use the same options
3920
3935
  ).catch((err) => {
@@ -3923,12 +3938,12 @@ function createStore_forChatMessages(toolsStore, setToolResult) {
3923
3938
  );
3924
3939
  });
3925
3940
  };
3926
- const executeFn = _optionalChain([toolDef, 'optionalAccess', _57 => _57.execute]);
3941
+ const executeFn = _optionalChain([toolDef, 'optionalAccess', _73 => _73.execute]);
3927
3942
  if (executeFn && autoExecutableMessages.has(message.id)) {
3928
3943
  (async () => {
3929
3944
  const result = await executeFn(toolCall.args, {
3930
- toolName: toolCall.toolName,
3931
- toolCallId: toolCall.toolCallId
3945
+ name: toolCall.name,
3946
+ invocationId: toolCall.invocationId
3932
3947
  });
3933
3948
  respondSync(result);
3934
3949
  })().catch((err) => {
@@ -4011,8 +4026,8 @@ function createStore_forChatMessages(toolsStore, setToolResult) {
4011
4026
  const spine = [];
4012
4027
  let lastVisitedMessage = null;
4013
4028
  for (const message2 of pool.walkUp(leaf.id)) {
4014
- const prev = _nullishCoalesce(_optionalChain([first, 'call', _58 => _58(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _59 => _59.id]), () => ( null));
4015
- const next = _nullishCoalesce(_optionalChain([first, 'call', _60 => _60(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _61 => _61.id]), () => ( null));
4029
+ const prev = _nullishCoalesce(_optionalChain([first, 'call', _74 => _74(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _75 => _75.id]), () => ( null));
4030
+ const next = _nullishCoalesce(_optionalChain([first, 'call', _76 => _76(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _77 => _77.id]), () => ( null));
4016
4031
  if (!message2.deletedAt || prev || next) {
4017
4032
  const node = {
4018
4033
  ...message2,
@@ -4091,16 +4106,16 @@ function createStore_forChatMessages(toolsStore, setToolResult) {
4091
4106
  };
4092
4107
  }
4093
4108
  function createStore_forUserAiChats() {
4094
- const mutable\u03A3 = new MutableSignal(
4109
+ const allChatsInclDeleted\u03A3 = new MutableSignal(
4095
4110
  SortedList.with((x, y) => y.createdAt < x.createdAt)
4096
4111
  );
4097
- const chats\u03A3 = DerivedSignal.from(
4098
- () => Array.from(mutable\u03A3.get()).filter((c) => !c.deletedAt)
4112
+ const nonDeletedChats\u03A3 = DerivedSignal.from(
4113
+ () => Array.from(allChatsInclDeleted\u03A3.get()).filter((c) => !c.deletedAt)
4099
4114
  );
4100
4115
  function upsertMany(chats) {
4101
- mutable\u03A3.mutate((list) => {
4116
+ allChatsInclDeleted\u03A3.mutate((list) => {
4102
4117
  for (const chat of chats) {
4103
- remove(chat.id);
4118
+ list.removeBy((c) => c.id === chat.id, 1);
4104
4119
  list.add(chat);
4105
4120
  }
4106
4121
  });
@@ -4108,19 +4123,26 @@ function createStore_forUserAiChats() {
4108
4123
  function upsert(chat) {
4109
4124
  upsertMany([chat]);
4110
4125
  }
4111
- function remove(chatId) {
4112
- mutable\u03A3.mutate((list) => list.removeBy((c) => c.id === chatId, 1));
4126
+ function markDeleted(chatId) {
4127
+ allChatsInclDeleted\u03A3.mutate((list) => {
4128
+ const chat = list.find((c) => c.id === chatId);
4129
+ if (!chat) return false;
4130
+ upsert({ ...chat, deletedAt: now() });
4131
+ return void 0;
4132
+ });
4113
4133
  }
4114
4134
  function getChatById(chatId) {
4115
- return Array.from(mutable\u03A3.get()).find((chat) => chat.id === chatId);
4135
+ return Array.from(allChatsInclDeleted\u03A3.get()).find(
4136
+ (chat) => chat.id === chatId
4137
+ );
4116
4138
  }
4117
4139
  return {
4118
- chats\u03A3,
4140
+ chats\u03A3: nonDeletedChats\u03A3,
4119
4141
  getChatById,
4120
4142
  // Mutations
4121
4143
  upsert,
4122
4144
  upsertMany,
4123
- remove
4145
+ markDeleted
4124
4146
  };
4125
4147
  }
4126
4148
  function createAi(config) {
@@ -4198,7 +4220,7 @@ function createAi(config) {
4198
4220
  if ("event" in msg) {
4199
4221
  switch (msg.event) {
4200
4222
  case "cmd-failed":
4201
- _optionalChain([pendingCmd, 'optionalAccess', _62 => _62.reject, 'call', _63 => _63(new Error(msg.error))]);
4223
+ _optionalChain([pendingCmd, 'optionalAccess', _78 => _78.reject, 'call', _79 => _79(new Error(msg.error))]);
4202
4224
  break;
4203
4225
  case "delta": {
4204
4226
  const { id, delta } = msg;
@@ -4209,7 +4231,11 @@ function createAi(config) {
4209
4231
  context.messagesStore.upsert(msg.message);
4210
4232
  break;
4211
4233
  }
4234
+ case "warning":
4235
+ warn(msg.message);
4236
+ break;
4212
4237
  case "error":
4238
+ error2(msg.error);
4213
4239
  break;
4214
4240
  case "rebooted":
4215
4241
  context.messagesStore.failAllPending();
@@ -4220,7 +4246,7 @@ function createAi(config) {
4220
4246
  context.messagesStore.remove(m.chatId, m.id);
4221
4247
  }
4222
4248
  for (const chatId of _nullishCoalesce(msg["-chats"], () => ( []))) {
4223
- context.chatsStore.remove(chatId);
4249
+ context.chatsStore.markDeleted(chatId);
4224
4250
  context.messagesStore.removeByChatId(chatId);
4225
4251
  }
4226
4252
  for (const chatId of _nullishCoalesce(msg.clear, () => ( []))) {
@@ -4246,7 +4272,7 @@ function createAi(config) {
4246
4272
  context.chatsStore.upsert(msg.chat);
4247
4273
  break;
4248
4274
  case "delete-chat":
4249
- context.chatsStore.remove(msg.chatId);
4275
+ context.chatsStore.markDeleted(msg.chatId);
4250
4276
  context.messagesStore.removeByChatId(msg.chatId);
4251
4277
  break;
4252
4278
  case "get-message-tree":
@@ -4276,7 +4302,7 @@ function createAi(config) {
4276
4302
  return assertNever(msg, "Unhandled case");
4277
4303
  }
4278
4304
  }
4279
- _optionalChain([pendingCmd, 'optionalAccess', _64 => _64.resolve, 'call', _65 => _65(msg)]);
4305
+ _optionalChain([pendingCmd, 'optionalAccess', _80 => _80.resolve, 'call', _81 => _81(msg)]);
4280
4306
  }
4281
4307
  managedSocket.events.onMessage.subscribe(handleServerMessage);
4282
4308
  managedSocket.events.statusDidChange.subscribe(onStatusDidChange);
@@ -4344,24 +4370,23 @@ function createAi(config) {
4344
4370
  function updateKnowledge(layerKey, data, key = nanoid()) {
4345
4371
  context.knowledge.updateKnowledge(layerKey, key, data);
4346
4372
  }
4347
- async function setToolResult(chatId, messageId, toolCallId, result, options) {
4373
+ async function setToolResult(chatId, messageId, invocationId, result, options) {
4348
4374
  const knowledge = context.knowledge.get();
4375
+ const tools = context.toolsStore.getToolDescriptions(chatId);
4349
4376
  const resp = await sendClientMsgWithResponse({
4350
4377
  cmd: "set-tool-result",
4351
4378
  chatId,
4352
4379
  messageId,
4353
- toolCallId,
4380
+ invocationId,
4354
4381
  result,
4355
4382
  generationOptions: {
4356
- copilotId: _optionalChain([options, 'optionalAccess', _66 => _66.copilotId]),
4357
- stream: _optionalChain([options, 'optionalAccess', _67 => _67.stream]),
4358
- timeout: _optionalChain([options, 'optionalAccess', _68 => _68.timeout]),
4383
+ copilotId: _optionalChain([options, 'optionalAccess', _82 => _82.copilotId]),
4384
+ stream: _optionalChain([options, 'optionalAccess', _83 => _83.stream]),
4385
+ timeout: _optionalChain([options, 'optionalAccess', _84 => _84.timeout]),
4386
+ // Knowledge and tools aren't coming from the options, but retrieved
4387
+ // from the global context
4359
4388
  knowledge: knowledge.length > 0 ? knowledge : void 0,
4360
- tools: context.toolsStore.getToolsForChat(chatId).map((tool) => ({
4361
- name: tool.name,
4362
- description: tool.definition.description,
4363
- parameters: tool.definition.parameters
4364
- }))
4389
+ tools: tools.length > 0 ? tools : void 0
4365
4390
  }
4366
4391
  });
4367
4392
  if (resp.ok) {
@@ -4387,21 +4412,20 @@ function createAi(config) {
4387
4412
  clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
4388
4413
  askUserMessageInChat: async (chatId, userMessage, targetMessageId, options) => {
4389
4414
  const knowledge = context.knowledge.get();
4415
+ const tools = context.toolsStore.getToolDescriptions(chatId);
4390
4416
  const resp = await sendClientMsgWithResponse({
4391
4417
  cmd: "ask-in-chat",
4392
4418
  chatId,
4393
4419
  sourceMessage: userMessage,
4394
4420
  targetMessageId,
4395
4421
  generationOptions: {
4396
- copilotId: _optionalChain([options, 'optionalAccess', _69 => _69.copilotId]),
4397
- stream: _optionalChain([options, 'optionalAccess', _70 => _70.stream]),
4398
- timeout: _optionalChain([options, 'optionalAccess', _71 => _71.timeout]),
4422
+ copilotId: _optionalChain([options, 'optionalAccess', _85 => _85.copilotId]),
4423
+ stream: _optionalChain([options, 'optionalAccess', _86 => _86.stream]),
4424
+ timeout: _optionalChain([options, 'optionalAccess', _87 => _87.timeout]),
4425
+ // Knowledge and tools aren't coming from the options, but retrieved
4426
+ // from the global context
4399
4427
  knowledge: knowledge.length > 0 ? knowledge : void 0,
4400
- tools: context.toolsStore.getToolsForChat(chatId).map((tool) => ({
4401
- name: tool.name,
4402
- description: tool.definition.description,
4403
- parameters: tool.definition.parameters
4404
- }))
4428
+ tools: tools.length > 0 ? tools : void 0
4405
4429
  }
4406
4430
  });
4407
4431
  messagesStore.allowAutoExecuteToolCall(resp.targetMessage.id);
@@ -4413,14 +4437,13 @@ function createAi(config) {
4413
4437
  signals: {
4414
4438
  chats\u03A3: context.chatsStore.chats\u03A3,
4415
4439
  getChatMessagesForBranch\u03A3: context.messagesStore.getChatMessagesForBranch\u03A3,
4416
- getToolDefinition\u03A3: context.toolsStore.getToolDefinition\u03A3
4440
+ getTool\u03A3: context.toolsStore.getTool\u03A3
4417
4441
  },
4418
4442
  getChatById: context.chatsStore.getChatById,
4419
4443
  registerKnowledgeLayer,
4420
4444
  deregisterKnowledgeLayer,
4421
4445
  updateKnowledge,
4422
- registerChatTool: context.toolsStore.addToolDefinition,
4423
- unregisterChatTool: context.toolsStore.removeToolDefinition
4446
+ registerTool: context.toolsStore.registerTool
4424
4447
  },
4425
4448
  kInternal,
4426
4449
  { enumerable: false }
@@ -4436,7 +4459,7 @@ function makeCreateSocketDelegateForAi(baseUrl, WebSocketPolyfill) {
4436
4459
  }
4437
4460
  const url2 = new URL(baseUrl);
4438
4461
  url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
4439
- url2.pathname = "/ai/v1";
4462
+ url2.pathname = "/ai/v2";
4440
4463
  if (authValue.type === "secret") {
4441
4464
  url2.searchParams.set("tok", authValue.token.raw);
4442
4465
  } else if (authValue.type === "public") {
@@ -4500,7 +4523,7 @@ function createAuthManager(authOptions, onAuthenticate) {
4500
4523
  return void 0;
4501
4524
  }
4502
4525
  async function makeAuthRequest(options) {
4503
- const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _72 => _72.polyfills, 'optionalAccess', _73 => _73.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
4526
+ const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _88 => _88.polyfills, 'optionalAccess', _89 => _89.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
4504
4527
  if (authentication.type === "private") {
4505
4528
  if (fetcher === void 0) {
4506
4529
  throw new StopRetrying(
@@ -4516,7 +4539,7 @@ function createAuthManager(authOptions, onAuthenticate) {
4516
4539
  "The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
4517
4540
  );
4518
4541
  }
4519
- _optionalChain([onAuthenticate, 'optionalCall', _74 => _74(parsed.parsed)]);
4542
+ _optionalChain([onAuthenticate, 'optionalCall', _90 => _90(parsed.parsed)]);
4520
4543
  return parsed;
4521
4544
  }
4522
4545
  if (authentication.type === "custom") {
@@ -4524,7 +4547,7 @@ function createAuthManager(authOptions, onAuthenticate) {
4524
4547
  if (response && typeof response === "object") {
4525
4548
  if (typeof response.token === "string") {
4526
4549
  const parsed = parseAuthToken(response.token);
4527
- _optionalChain([onAuthenticate, 'optionalCall', _75 => _75(parsed.parsed)]);
4550
+ _optionalChain([onAuthenticate, 'optionalCall', _91 => _91(parsed.parsed)]);
4528
4551
  return parsed;
4529
4552
  } else if (typeof response.error === "string") {
4530
4553
  const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
@@ -4682,7 +4705,7 @@ function sendToPanel(message, options) {
4682
4705
  ...message,
4683
4706
  source: "liveblocks-devtools-client"
4684
4707
  };
4685
- if (!(_optionalChain([options, 'optionalAccess', _76 => _76.force]) || _bridgeActive)) {
4708
+ if (!(_optionalChain([options, 'optionalAccess', _92 => _92.force]) || _bridgeActive)) {
4686
4709
  return;
4687
4710
  }
4688
4711
  window.postMessage(fullMsg, "*");
@@ -4690,7 +4713,7 @@ function sendToPanel(message, options) {
4690
4713
  var eventSource = makeEventSource();
4691
4714
  if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
4692
4715
  window.addEventListener("message", (event) => {
4693
- if (event.source === window && _optionalChain([event, 'access', _77 => _77.data, 'optionalAccess', _78 => _78.source]) === "liveblocks-devtools-panel") {
4716
+ if (event.source === window && _optionalChain([event, 'access', _93 => _93.data, 'optionalAccess', _94 => _94.source]) === "liveblocks-devtools-panel") {
4694
4717
  eventSource.notify(event.data);
4695
4718
  } else {
4696
4719
  }
@@ -4832,7 +4855,7 @@ function fullSync(room) {
4832
4855
  msg: "room::sync::full",
4833
4856
  roomId: room.id,
4834
4857
  status: room.getStatus(),
4835
- storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _79 => _79.toTreeNode, 'call', _80 => _80("root"), 'access', _81 => _81.payload]), () => ( null)),
4858
+ storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _95 => _95.toTreeNode, 'call', _96 => _96("root"), 'access', _97 => _97.payload]), () => ( null)),
4836
4859
  me,
4837
4860
  others
4838
4861
  });
@@ -5123,7 +5146,7 @@ function createManagedPool(roomId, options) {
5123
5146
  generateId: () => `${getCurrentConnectionId()}:${clock++}`,
5124
5147
  generateOpId: () => `${getCurrentConnectionId()}:${opClock++}`,
5125
5148
  dispatch(ops, reverse, storageUpdates) {
5126
- _optionalChain([onDispatch, 'optionalCall', _82 => _82(ops, reverse, storageUpdates)]);
5149
+ _optionalChain([onDispatch, 'optionalCall', _98 => _98(ops, reverse, storageUpdates)]);
5127
5150
  },
5128
5151
  assertStorageIsWritable: () => {
5129
5152
  if (!isStorageWritable()) {
@@ -5350,7 +5373,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
5350
5373
  return [
5351
5374
  {
5352
5375
  type: 8 /* CREATE_REGISTER */,
5353
- opId: _optionalChain([pool, 'optionalAccess', _83 => _83.generateOpId, 'call', _84 => _84()]),
5376
+ opId: _optionalChain([pool, 'optionalAccess', _99 => _99.generateOpId, 'call', _100 => _100()]),
5354
5377
  id: this._id,
5355
5378
  parentId,
5356
5379
  parentKey,
@@ -5456,7 +5479,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5456
5479
  const ops = [];
5457
5480
  const op = {
5458
5481
  id: this._id,
5459
- opId: _optionalChain([pool, 'optionalAccess', _85 => _85.generateOpId, 'call', _86 => _86()]),
5482
+ opId: _optionalChain([pool, 'optionalAccess', _101 => _101.generateOpId, 'call', _102 => _102()]),
5460
5483
  type: 2 /* CREATE_LIST */,
5461
5484
  parentId,
5462
5485
  parentKey
@@ -5727,7 +5750,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5727
5750
  #applyInsertUndoRedo(op) {
5728
5751
  const { id, parentKey: key } = op;
5729
5752
  const child = creationOpToLiveNode(op);
5730
- if (_optionalChain([this, 'access', _87 => _87._pool, 'optionalAccess', _88 => _88.getNode, 'call', _89 => _89(id)]) !== void 0) {
5753
+ if (_optionalChain([this, 'access', _103 => _103._pool, 'optionalAccess', _104 => _104.getNode, 'call', _105 => _105(id)]) !== void 0) {
5731
5754
  return { modified: false };
5732
5755
  }
5733
5756
  child._attach(id, nn(this._pool));
@@ -5735,8 +5758,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
5735
5758
  const existingItemIndex = this._indexOfPosition(key);
5736
5759
  let newKey = key;
5737
5760
  if (existingItemIndex !== -1) {
5738
- const before2 = _optionalChain([this, 'access', _90 => _90.#items, 'access', _91 => _91[existingItemIndex], 'optionalAccess', _92 => _92._parentPos]);
5739
- const after2 = _optionalChain([this, 'access', _93 => _93.#items, 'access', _94 => _94[existingItemIndex + 1], 'optionalAccess', _95 => _95._parentPos]);
5761
+ const before2 = _optionalChain([this, 'access', _106 => _106.#items, 'access', _107 => _107[existingItemIndex], 'optionalAccess', _108 => _108._parentPos]);
5762
+ const after2 = _optionalChain([this, 'access', _109 => _109.#items, 'access', _110 => _110[existingItemIndex + 1], 'optionalAccess', _111 => _111._parentPos]);
5740
5763
  newKey = makePosition(before2, after2);
5741
5764
  child._setParentLink(this, newKey);
5742
5765
  }
@@ -5750,7 +5773,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5750
5773
  #applySetUndoRedo(op) {
5751
5774
  const { id, parentKey: key } = op;
5752
5775
  const child = creationOpToLiveNode(op);
5753
- if (_optionalChain([this, 'access', _96 => _96._pool, 'optionalAccess', _97 => _97.getNode, 'call', _98 => _98(id)]) !== void 0) {
5776
+ if (_optionalChain([this, 'access', _112 => _112._pool, 'optionalAccess', _113 => _113.getNode, 'call', _114 => _114(id)]) !== void 0) {
5754
5777
  return { modified: false };
5755
5778
  }
5756
5779
  this.#unacknowledgedSets.set(key, nn(op.opId));
@@ -5871,7 +5894,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5871
5894
  } else {
5872
5895
  this.#items[existingItemIndex]._setParentLink(
5873
5896
  this,
5874
- makePosition(newKey, _optionalChain([this, 'access', _99 => _99.#items, 'access', _100 => _100[existingItemIndex + 1], 'optionalAccess', _101 => _101._parentPos]))
5897
+ makePosition(newKey, _optionalChain([this, 'access', _115 => _115.#items, 'access', _116 => _116[existingItemIndex + 1], 'optionalAccess', _117 => _117._parentPos]))
5875
5898
  );
5876
5899
  const previousIndex = this.#items.indexOf(child);
5877
5900
  child._setParentLink(this, newKey);
@@ -5896,7 +5919,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5896
5919
  if (existingItemIndex !== -1) {
5897
5920
  this.#items[existingItemIndex]._setParentLink(
5898
5921
  this,
5899
- makePosition(newKey, _optionalChain([this, 'access', _102 => _102.#items, 'access', _103 => _103[existingItemIndex + 1], 'optionalAccess', _104 => _104._parentPos]))
5922
+ makePosition(newKey, _optionalChain([this, 'access', _118 => _118.#items, 'access', _119 => _119[existingItemIndex + 1], 'optionalAccess', _120 => _120._parentPos]))
5900
5923
  );
5901
5924
  }
5902
5925
  child._setParentLink(this, newKey);
@@ -5915,7 +5938,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5915
5938
  if (existingItemIndex !== -1) {
5916
5939
  this.#items[existingItemIndex]._setParentLink(
5917
5940
  this,
5918
- makePosition(newKey, _optionalChain([this, 'access', _105 => _105.#items, 'access', _106 => _106[existingItemIndex + 1], 'optionalAccess', _107 => _107._parentPos]))
5941
+ makePosition(newKey, _optionalChain([this, 'access', _121 => _121.#items, 'access', _122 => _122[existingItemIndex + 1], 'optionalAccess', _123 => _123._parentPos]))
5919
5942
  );
5920
5943
  }
5921
5944
  child._setParentLink(this, newKey);
@@ -5942,7 +5965,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5942
5965
  if (existingItemIndex !== -1) {
5943
5966
  this.#items[existingItemIndex]._setParentLink(
5944
5967
  this,
5945
- makePosition(newKey, _optionalChain([this, 'access', _108 => _108.#items, 'access', _109 => _109[existingItemIndex + 1], 'optionalAccess', _110 => _110._parentPos]))
5968
+ makePosition(newKey, _optionalChain([this, 'access', _124 => _124.#items, 'access', _125 => _125[existingItemIndex + 1], 'optionalAccess', _126 => _126._parentPos]))
5946
5969
  );
5947
5970
  }
5948
5971
  child._setParentLink(this, newKey);
@@ -6000,7 +6023,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6000
6023
  * @param element The element to add to the end of the LiveList.
6001
6024
  */
6002
6025
  push(element) {
6003
- _optionalChain([this, 'access', _111 => _111._pool, 'optionalAccess', _112 => _112.assertStorageIsWritable, 'call', _113 => _113()]);
6026
+ _optionalChain([this, 'access', _127 => _127._pool, 'optionalAccess', _128 => _128.assertStorageIsWritable, 'call', _129 => _129()]);
6004
6027
  return this.insert(element, this.length);
6005
6028
  }
6006
6029
  /**
@@ -6009,7 +6032,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6009
6032
  * @param index The index at which you want to insert the element.
6010
6033
  */
6011
6034
  insert(element, index) {
6012
- _optionalChain([this, 'access', _114 => _114._pool, 'optionalAccess', _115 => _115.assertStorageIsWritable, 'call', _116 => _116()]);
6035
+ _optionalChain([this, 'access', _130 => _130._pool, 'optionalAccess', _131 => _131.assertStorageIsWritable, 'call', _132 => _132()]);
6013
6036
  if (index < 0 || index > this.#items.length) {
6014
6037
  throw new Error(
6015
6038
  `Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
@@ -6039,7 +6062,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6039
6062
  * @param targetIndex The index where the element should be after moving.
6040
6063
  */
6041
6064
  move(index, targetIndex) {
6042
- _optionalChain([this, 'access', _117 => _117._pool, 'optionalAccess', _118 => _118.assertStorageIsWritable, 'call', _119 => _119()]);
6065
+ _optionalChain([this, 'access', _133 => _133._pool, 'optionalAccess', _134 => _134.assertStorageIsWritable, 'call', _135 => _135()]);
6043
6066
  if (targetIndex < 0) {
6044
6067
  throw new Error("targetIndex cannot be less than 0");
6045
6068
  }
@@ -6097,7 +6120,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6097
6120
  * @param index The index of the element to delete
6098
6121
  */
6099
6122
  delete(index) {
6100
- _optionalChain([this, 'access', _120 => _120._pool, 'optionalAccess', _121 => _121.assertStorageIsWritable, 'call', _122 => _122()]);
6123
+ _optionalChain([this, 'access', _136 => _136._pool, 'optionalAccess', _137 => _137.assertStorageIsWritable, 'call', _138 => _138()]);
6101
6124
  if (index < 0 || index >= this.#items.length) {
6102
6125
  throw new Error(
6103
6126
  `Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -6130,7 +6153,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6130
6153
  }
6131
6154
  }
6132
6155
  clear() {
6133
- _optionalChain([this, 'access', _123 => _123._pool, 'optionalAccess', _124 => _124.assertStorageIsWritable, 'call', _125 => _125()]);
6156
+ _optionalChain([this, 'access', _139 => _139._pool, 'optionalAccess', _140 => _140.assertStorageIsWritable, 'call', _141 => _141()]);
6134
6157
  if (this._pool) {
6135
6158
  const ops = [];
6136
6159
  const reverseOps = [];
@@ -6164,7 +6187,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6164
6187
  }
6165
6188
  }
6166
6189
  set(index, item) {
6167
- _optionalChain([this, 'access', _126 => _126._pool, 'optionalAccess', _127 => _127.assertStorageIsWritable, 'call', _128 => _128()]);
6190
+ _optionalChain([this, 'access', _142 => _142._pool, 'optionalAccess', _143 => _143.assertStorageIsWritable, 'call', _144 => _144()]);
6168
6191
  if (index < 0 || index >= this.#items.length) {
6169
6192
  throw new Error(
6170
6193
  `Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -6310,7 +6333,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6310
6333
  #shiftItemPosition(index, key) {
6311
6334
  const shiftedPosition = makePosition(
6312
6335
  key,
6313
- this.#items.length > index + 1 ? _optionalChain([this, 'access', _129 => _129.#items, 'access', _130 => _130[index + 1], 'optionalAccess', _131 => _131._parentPos]) : void 0
6336
+ this.#items.length > index + 1 ? _optionalChain([this, 'access', _145 => _145.#items, 'access', _146 => _146[index + 1], 'optionalAccess', _147 => _147._parentPos]) : void 0
6314
6337
  );
6315
6338
  this.#items[index]._setParentLink(this, shiftedPosition);
6316
6339
  }
@@ -6435,7 +6458,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
6435
6458
  const ops = [];
6436
6459
  const op = {
6437
6460
  id: this._id,
6438
- opId: _optionalChain([pool, 'optionalAccess', _132 => _132.generateOpId, 'call', _133 => _133()]),
6461
+ opId: _optionalChain([pool, 'optionalAccess', _148 => _148.generateOpId, 'call', _149 => _149()]),
6439
6462
  type: 7 /* CREATE_MAP */,
6440
6463
  parentId,
6441
6464
  parentKey
@@ -6570,7 +6593,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
6570
6593
  * @param value The value of the element to add. Should be serializable to JSON.
6571
6594
  */
6572
6595
  set(key, value) {
6573
- _optionalChain([this, 'access', _134 => _134._pool, 'optionalAccess', _135 => _135.assertStorageIsWritable, 'call', _136 => _136()]);
6596
+ _optionalChain([this, 'access', _150 => _150._pool, 'optionalAccess', _151 => _151.assertStorageIsWritable, 'call', _152 => _152()]);
6574
6597
  const oldValue = this.#map.get(key);
6575
6598
  if (oldValue) {
6576
6599
  oldValue._detach();
@@ -6616,7 +6639,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
6616
6639
  * @returns true if an element existed and has been removed, or false if the element does not exist.
6617
6640
  */
6618
6641
  delete(key) {
6619
- _optionalChain([this, 'access', _137 => _137._pool, 'optionalAccess', _138 => _138.assertStorageIsWritable, 'call', _139 => _139()]);
6642
+ _optionalChain([this, 'access', _153 => _153._pool, 'optionalAccess', _154 => _154.assertStorageIsWritable, 'call', _155 => _155()]);
6620
6643
  const item = this.#map.get(key);
6621
6644
  if (item === void 0) {
6622
6645
  return false;
@@ -6795,7 +6818,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
6795
6818
  if (this._id === void 0) {
6796
6819
  throw new Error("Cannot serialize item is not attached");
6797
6820
  }
6798
- const opId = _optionalChain([pool, 'optionalAccess', _140 => _140.generateOpId, 'call', _141 => _141()]);
6821
+ const opId = _optionalChain([pool, 'optionalAccess', _156 => _156.generateOpId, 'call', _157 => _157()]);
6799
6822
  const ops = [];
6800
6823
  const op = {
6801
6824
  type: 4 /* CREATE_OBJECT */,
@@ -7067,7 +7090,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
7067
7090
  * @param value The value of the property to add
7068
7091
  */
7069
7092
  set(key, value) {
7070
- _optionalChain([this, 'access', _142 => _142._pool, 'optionalAccess', _143 => _143.assertStorageIsWritable, 'call', _144 => _144()]);
7093
+ _optionalChain([this, 'access', _158 => _158._pool, 'optionalAccess', _159 => _159.assertStorageIsWritable, 'call', _160 => _160()]);
7071
7094
  this.update({ [key]: value });
7072
7095
  }
7073
7096
  /**
@@ -7082,7 +7105,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
7082
7105
  * @param key The key of the property to delete
7083
7106
  */
7084
7107
  delete(key) {
7085
- _optionalChain([this, 'access', _145 => _145._pool, 'optionalAccess', _146 => _146.assertStorageIsWritable, 'call', _147 => _147()]);
7108
+ _optionalChain([this, 'access', _161 => _161._pool, 'optionalAccess', _162 => _162.assertStorageIsWritable, 'call', _163 => _163()]);
7086
7109
  const keyAsString = key;
7087
7110
  const oldValue = this.#map.get(keyAsString);
7088
7111
  if (oldValue === void 0) {
@@ -7135,7 +7158,7 @@ var LiveObject = class _LiveObject extends AbstractCrdt {
7135
7158
  * @param patch The object used to overrides properties
7136
7159
  */
7137
7160
  update(patch) {
7138
- _optionalChain([this, 'access', _148 => _148._pool, 'optionalAccess', _149 => _149.assertStorageIsWritable, 'call', _150 => _150()]);
7161
+ _optionalChain([this, 'access', _164 => _164._pool, 'optionalAccess', _165 => _165.assertStorageIsWritable, 'call', _166 => _166()]);
7139
7162
  if (this._pool === void 0 || this._id === void 0) {
7140
7163
  for (const key in patch) {
7141
7164
  const newValue = patch[key];
@@ -7858,15 +7881,15 @@ function installBackgroundTabSpy() {
7858
7881
  const doc = typeof document !== "undefined" ? document : void 0;
7859
7882
  const inBackgroundSince = { current: null };
7860
7883
  function onVisibilityChange() {
7861
- if (_optionalChain([doc, 'optionalAccess', _151 => _151.visibilityState]) === "hidden") {
7884
+ if (_optionalChain([doc, 'optionalAccess', _167 => _167.visibilityState]) === "hidden") {
7862
7885
  inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
7863
7886
  } else {
7864
7887
  inBackgroundSince.current = null;
7865
7888
  }
7866
7889
  }
7867
- _optionalChain([doc, 'optionalAccess', _152 => _152.addEventListener, 'call', _153 => _153("visibilitychange", onVisibilityChange)]);
7890
+ _optionalChain([doc, 'optionalAccess', _168 => _168.addEventListener, 'call', _169 => _169("visibilitychange", onVisibilityChange)]);
7868
7891
  const unsub = () => {
7869
- _optionalChain([doc, 'optionalAccess', _154 => _154.removeEventListener, 'call', _155 => _155("visibilitychange", onVisibilityChange)]);
7892
+ _optionalChain([doc, 'optionalAccess', _170 => _170.removeEventListener, 'call', _171 => _171("visibilitychange", onVisibilityChange)]);
7870
7893
  };
7871
7894
  return [inBackgroundSince, unsub];
7872
7895
  }
@@ -8046,7 +8069,7 @@ function createRoom(options, config) {
8046
8069
  }
8047
8070
  }
8048
8071
  function isStorageWritable() {
8049
- const scopes = _optionalChain([context, 'access', _156 => _156.dynamicSessionInfoSig, 'access', _157 => _157.get, 'call', _158 => _158(), 'optionalAccess', _159 => _159.scopes]);
8072
+ const scopes = _optionalChain([context, 'access', _172 => _172.dynamicSessionInfoSig, 'access', _173 => _173.get, 'call', _174 => _174(), 'optionalAccess', _175 => _175.scopes]);
8050
8073
  return scopes !== void 0 ? canWriteStorage(scopes) : true;
8051
8074
  }
8052
8075
  const eventHub = {
@@ -8163,7 +8186,7 @@ function createRoom(options, config) {
8163
8186
  }
8164
8187
  case "experimental-fallback-to-http": {
8165
8188
  warn("Message is too large for websockets, so sending over HTTP instead");
8166
- 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")));
8189
+ const nonce = _nullishCoalesce(_optionalChain([context, 'access', _176 => _176.dynamicSessionInfoSig, 'access', _177 => _177.get, 'call', _178 => _178(), 'optionalAccess', _179 => _179.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
8167
8190
  void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
8168
8191
  if (!resp.ok && resp.status === 403) {
8169
8192
  managedSocket.reconnect();
@@ -8214,7 +8237,7 @@ function createRoom(options, config) {
8214
8237
  } else {
8215
8238
  context.root = LiveObject._fromItems(message.items, context.pool);
8216
8239
  }
8217
- const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _164 => _164.get, 'call', _165 => _165(), 'optionalAccess', _166 => _166.canWrite]), () => ( true));
8240
+ const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _180 => _180.get, 'call', _181 => _181(), 'optionalAccess', _182 => _182.canWrite]), () => ( true));
8218
8241
  const stackSizeBefore = context.undoStack.length;
8219
8242
  for (const key in context.initialStorage) {
8220
8243
  if (context.root.get(key) === void 0) {
@@ -8417,7 +8440,7 @@ function createRoom(options, config) {
8417
8440
  }
8418
8441
  context.myPresence.patch(patch);
8419
8442
  if (context.activeBatch) {
8420
- if (_optionalChain([options2, 'optionalAccess', _167 => _167.addToHistory])) {
8443
+ if (_optionalChain([options2, 'optionalAccess', _183 => _183.addToHistory])) {
8421
8444
  context.activeBatch.reverseOps.pushLeft({
8422
8445
  type: "presence",
8423
8446
  data: oldValues
@@ -8426,7 +8449,7 @@ function createRoom(options, config) {
8426
8449
  context.activeBatch.updates.presence = true;
8427
8450
  } else {
8428
8451
  flushNowOrSoon();
8429
- if (_optionalChain([options2, 'optionalAccess', _168 => _168.addToHistory])) {
8452
+ if (_optionalChain([options2, 'optionalAccess', _184 => _184.addToHistory])) {
8430
8453
  addToUndoStack([{ type: "presence", data: oldValues }]);
8431
8454
  }
8432
8455
  notify({ presence: true });
@@ -8623,7 +8646,7 @@ function createRoom(options, config) {
8623
8646
  if (process.env.NODE_ENV !== "production") {
8624
8647
  const traces = /* @__PURE__ */ new Set();
8625
8648
  for (const opId of message.opIds) {
8626
- const trace = _optionalChain([context, 'access', _169 => _169.opStackTraces, 'optionalAccess', _170 => _170.get, 'call', _171 => _171(opId)]);
8649
+ const trace = _optionalChain([context, 'access', _185 => _185.opStackTraces, 'optionalAccess', _186 => _186.get, 'call', _187 => _187(opId)]);
8627
8650
  if (trace) {
8628
8651
  traces.add(trace);
8629
8652
  }
@@ -8757,7 +8780,7 @@ ${Array.from(traces).join("\n\n")}`
8757
8780
  const unacknowledgedOps = new Map(context.unacknowledgedOps);
8758
8781
  createOrUpdateRootFromMessage(message);
8759
8782
  applyAndSendOps(unacknowledgedOps);
8760
- _optionalChain([_resolveStoragePromise, 'optionalCall', _172 => _172()]);
8783
+ _optionalChain([_resolveStoragePromise, 'optionalCall', _188 => _188()]);
8761
8784
  notifyStorageStatus();
8762
8785
  eventHub.storageDidLoad.notify();
8763
8786
  }
@@ -8980,8 +9003,8 @@ ${Array.from(traces).join("\n\n")}`
8980
9003
  async function getThreads(options2) {
8981
9004
  return httpClient.getThreads({
8982
9005
  roomId,
8983
- query: _optionalChain([options2, 'optionalAccess', _173 => _173.query]),
8984
- cursor: _optionalChain([options2, 'optionalAccess', _174 => _174.cursor])
9006
+ query: _optionalChain([options2, 'optionalAccess', _189 => _189.query]),
9007
+ cursor: _optionalChain([options2, 'optionalAccess', _190 => _190.cursor])
8985
9008
  });
8986
9009
  }
8987
9010
  async function getThread(threadId) {
@@ -9088,7 +9111,7 @@ ${Array.from(traces).join("\n\n")}`
9088
9111
  function getSubscriptionSettings(options2) {
9089
9112
  return httpClient.getSubscriptionSettings({
9090
9113
  roomId,
9091
- signal: _optionalChain([options2, 'optionalAccess', _175 => _175.signal])
9114
+ signal: _optionalChain([options2, 'optionalAccess', _191 => _191.signal])
9092
9115
  });
9093
9116
  }
9094
9117
  function updateSubscriptionSettings(settings) {
@@ -9110,7 +9133,7 @@ ${Array.from(traces).join("\n\n")}`
9110
9133
  {
9111
9134
  [kInternal]: {
9112
9135
  get presenceBuffer() {
9113
- return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _176 => _176.buffer, 'access', _177 => _177.presenceUpdates, 'optionalAccess', _178 => _178.data]), () => ( null)));
9136
+ return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _192 => _192.buffer, 'access', _193 => _193.presenceUpdates, 'optionalAccess', _194 => _194.data]), () => ( null)));
9114
9137
  },
9115
9138
  // prettier-ignore
9116
9139
  get undoStack() {
@@ -9125,9 +9148,9 @@ ${Array.from(traces).join("\n\n")}`
9125
9148
  return context.yjsProvider;
9126
9149
  },
9127
9150
  setYjsProvider(newProvider) {
9128
- _optionalChain([context, 'access', _179 => _179.yjsProvider, 'optionalAccess', _180 => _180.off, 'call', _181 => _181("status", yjsStatusDidChange)]);
9151
+ _optionalChain([context, 'access', _195 => _195.yjsProvider, 'optionalAccess', _196 => _196.off, 'call', _197 => _197("status", yjsStatusDidChange)]);
9129
9152
  context.yjsProvider = newProvider;
9130
- _optionalChain([newProvider, 'optionalAccess', _182 => _182.on, 'call', _183 => _183("status", yjsStatusDidChange)]);
9153
+ _optionalChain([newProvider, 'optionalAccess', _198 => _198.on, 'call', _199 => _199("status", yjsStatusDidChange)]);
9131
9154
  context.yjsProviderDidChange.notify();
9132
9155
  },
9133
9156
  yjsProviderDidChange: context.yjsProviderDidChange.observable,
@@ -9173,7 +9196,7 @@ ${Array.from(traces).join("\n\n")}`
9173
9196
  source.dispose();
9174
9197
  }
9175
9198
  eventHub.roomWillDestroy.notify();
9176
- _optionalChain([context, 'access', _184 => _184.yjsProvider, 'optionalAccess', _185 => _185.off, 'call', _186 => _186("status", yjsStatusDidChange)]);
9199
+ _optionalChain([context, 'access', _200 => _200.yjsProvider, 'optionalAccess', _201 => _201.off, 'call', _202 => _202("status", yjsStatusDidChange)]);
9177
9200
  syncSourceForStorage.destroy();
9178
9201
  syncSourceForYjs.destroy();
9179
9202
  uninstallBgTabSpy();
@@ -9323,7 +9346,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
9323
9346
  }
9324
9347
  if (isLiveNode(first)) {
9325
9348
  const node = first;
9326
- if (_optionalChain([options, 'optionalAccess', _187 => _187.isDeep])) {
9349
+ if (_optionalChain([options, 'optionalAccess', _203 => _203.isDeep])) {
9327
9350
  const storageCallback = second;
9328
9351
  return subscribeToLiveStructureDeeply(node, storageCallback);
9329
9352
  } else {
@@ -9402,8 +9425,8 @@ function createClient(options) {
9402
9425
  const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
9403
9426
  currentUserId.set(() => userId);
9404
9427
  });
9405
- const fetchPolyfill = _optionalChain([clientOptions, 'access', _188 => _188.polyfills, 'optionalAccess', _189 => _189.fetch]) || /* istanbul ignore next */
9406
- _optionalChain([globalThis, 'access', _190 => _190.fetch, 'optionalAccess', _191 => _191.bind, 'call', _192 => _192(globalThis)]);
9428
+ const fetchPolyfill = _optionalChain([clientOptions, 'access', _204 => _204.polyfills, 'optionalAccess', _205 => _205.fetch]) || /* istanbul ignore next */
9429
+ _optionalChain([globalThis, 'access', _206 => _206.fetch, 'optionalAccess', _207 => _207.bind, 'call', _208 => _208(globalThis)]);
9407
9430
  const httpClient = createApiClient({
9408
9431
  baseUrl,
9409
9432
  fetchPolyfill,
@@ -9421,7 +9444,7 @@ function createClient(options) {
9421
9444
  delegates: {
9422
9445
  createSocket: makeCreateSocketDelegateForAi(
9423
9446
  baseUrl,
9424
- _optionalChain([clientOptions, 'access', _193 => _193.polyfills, 'optionalAccess', _194 => _194.WebSocket])
9447
+ _optionalChain([clientOptions, 'access', _209 => _209.polyfills, 'optionalAccess', _210 => _210.WebSocket])
9425
9448
  ),
9426
9449
  authenticate: makeAuthDelegateForRoom("default", authManager),
9427
9450
  canZombie: () => true
@@ -9471,7 +9494,7 @@ function createClient(options) {
9471
9494
  createSocket: makeCreateSocketDelegateForRoom(
9472
9495
  roomId,
9473
9496
  baseUrl,
9474
- _optionalChain([clientOptions, 'access', _195 => _195.polyfills, 'optionalAccess', _196 => _196.WebSocket])
9497
+ _optionalChain([clientOptions, 'access', _211 => _211.polyfills, 'optionalAccess', _212 => _212.WebSocket])
9475
9498
  ),
9476
9499
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
9477
9500
  })),
@@ -9494,7 +9517,7 @@ function createClient(options) {
9494
9517
  const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
9495
9518
  if (shouldConnect) {
9496
9519
  if (typeof atob === "undefined") {
9497
- if (_optionalChain([clientOptions, 'access', _197 => _197.polyfills, 'optionalAccess', _198 => _198.atob]) === void 0) {
9520
+ if (_optionalChain([clientOptions, 'access', _213 => _213.polyfills, 'optionalAccess', _214 => _214.atob]) === void 0) {
9498
9521
  throw new Error(
9499
9522
  "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"
9500
9523
  );
@@ -9506,7 +9529,7 @@ function createClient(options) {
9506
9529
  return leaseRoom(newRoomDetails);
9507
9530
  }
9508
9531
  function getRoom(roomId) {
9509
- const room = _optionalChain([roomsById, 'access', _199 => _199.get, 'call', _200 => _200(roomId), 'optionalAccess', _201 => _201.room]);
9532
+ const room = _optionalChain([roomsById, 'access', _215 => _215.get, 'call', _216 => _216(roomId), 'optionalAccess', _217 => _217.room]);
9510
9533
  return room ? room : null;
9511
9534
  }
9512
9535
  function logout() {
@@ -9526,7 +9549,7 @@ function createClient(options) {
9526
9549
  const batchedResolveUsers = new Batch(
9527
9550
  async (batchedUserIds) => {
9528
9551
  const userIds = batchedUserIds.flat();
9529
- const users = await _optionalChain([resolveUsers, 'optionalCall', _202 => _202({ userIds })]);
9552
+ const users = await _optionalChain([resolveUsers, 'optionalCall', _218 => _218({ userIds })]);
9530
9553
  warnIfNoResolveUsers();
9531
9554
  return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
9532
9555
  },
@@ -9544,7 +9567,7 @@ function createClient(options) {
9544
9567
  const batchedResolveRoomsInfo = new Batch(
9545
9568
  async (batchedRoomIds) => {
9546
9569
  const roomIds = batchedRoomIds.flat();
9547
- const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _203 => _203({ roomIds })]);
9570
+ const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _219 => _219({ roomIds })]);
9548
9571
  warnIfNoResolveRoomsInfo();
9549
9572
  return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
9550
9573
  },
@@ -9597,7 +9620,7 @@ function createClient(options) {
9597
9620
  }
9598
9621
  };
9599
9622
  const win = typeof window !== "undefined" ? window : void 0;
9600
- _optionalChain([win, 'optionalAccess', _204 => _204.addEventListener, 'call', _205 => _205("beforeunload", maybePreventClose)]);
9623
+ _optionalChain([win, 'optionalAccess', _220 => _220.addEventListener, 'call', _221 => _221("beforeunload", maybePreventClose)]);
9601
9624
  }
9602
9625
  async function getNotificationSettings(options2) {
9603
9626
  const plainSettings = await httpClient.getNotificationSettings(options2);
@@ -9736,7 +9759,7 @@ var commentBodyElementsTypes = {
9736
9759
  mention: "inline"
9737
9760
  };
9738
9761
  function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
9739
- if (!body || !_optionalChain([body, 'optionalAccess', _206 => _206.content])) {
9762
+ if (!body || !_optionalChain([body, 'optionalAccess', _222 => _222.content])) {
9740
9763
  return;
9741
9764
  }
9742
9765
  const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
@@ -9746,13 +9769,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
9746
9769
  for (const block of body.content) {
9747
9770
  if (type === "all" || type === "block") {
9748
9771
  if (guard(block)) {
9749
- _optionalChain([visitor, 'optionalCall', _207 => _207(block)]);
9772
+ _optionalChain([visitor, 'optionalCall', _223 => _223(block)]);
9750
9773
  }
9751
9774
  }
9752
9775
  if (type === "all" || type === "inline") {
9753
9776
  for (const inline of block.children) {
9754
9777
  if (guard(inline)) {
9755
- _optionalChain([visitor, 'optionalCall', _208 => _208(inline)]);
9778
+ _optionalChain([visitor, 'optionalCall', _224 => _224(inline)]);
9756
9779
  }
9757
9780
  }
9758
9781
  }
@@ -9777,7 +9800,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
9777
9800
  userIds
9778
9801
  });
9779
9802
  for (const [index, userId] of userIds.entries()) {
9780
- const user = _optionalChain([users, 'optionalAccess', _209 => _209[index]]);
9803
+ const user = _optionalChain([users, 'optionalAccess', _225 => _225[index]]);
9781
9804
  if (user) {
9782
9805
  resolvedUsers.set(userId, user);
9783
9806
  }
@@ -9904,7 +9927,7 @@ var stringifyCommentBodyPlainElements = {
9904
9927
  text: ({ element }) => element.text,
9905
9928
  link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
9906
9929
  mention: ({ element, user }) => {
9907
- return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _210 => _210.name]), () => ( element.id))}`;
9930
+ return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _226 => _226.name]), () => ( element.id))}`;
9908
9931
  }
9909
9932
  };
9910
9933
  var stringifyCommentBodyHtmlElements = {
@@ -9934,7 +9957,7 @@ var stringifyCommentBodyHtmlElements = {
9934
9957
  return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
9935
9958
  },
9936
9959
  mention: ({ element, user }) => {
9937
- return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _211 => _211.name]) ? html`${_optionalChain([user, 'optionalAccess', _212 => _212.name])}` : element.id}</span>`;
9960
+ return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _227 => _227.name]) ? html`${_optionalChain([user, 'optionalAccess', _228 => _228.name])}` : element.id}</span>`;
9938
9961
  }
9939
9962
  };
9940
9963
  var stringifyCommentBodyMarkdownElements = {
@@ -9964,19 +9987,19 @@ var stringifyCommentBodyMarkdownElements = {
9964
9987
  return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
9965
9988
  },
9966
9989
  mention: ({ element, user }) => {
9967
- return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _213 => _213.name]), () => ( element.id))}`;
9990
+ return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _229 => _229.name]), () => ( element.id))}`;
9968
9991
  }
9969
9992
  };
9970
9993
  async function stringifyCommentBody(body, options) {
9971
- const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _214 => _214.format]), () => ( "plain"));
9972
- const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _215 => _215.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
9994
+ const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _230 => _230.format]), () => ( "plain"));
9995
+ const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _231 => _231.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
9973
9996
  const elements = {
9974
9997
  ...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
9975
- ..._optionalChain([options, 'optionalAccess', _216 => _216.elements])
9998
+ ..._optionalChain([options, 'optionalAccess', _232 => _232.elements])
9976
9999
  };
9977
10000
  const resolvedUsers = await resolveUsersInCommentBody(
9978
10001
  body,
9979
- _optionalChain([options, 'optionalAccess', _217 => _217.resolveUsers])
10002
+ _optionalChain([options, 'optionalAccess', _233 => _233.resolveUsers])
9980
10003
  );
9981
10004
  const blocks = body.content.flatMap((block, blockIndex) => {
9982
10005
  switch (block.type) {
@@ -10267,12 +10290,12 @@ function legacy_patchImmutableNode(state, path, update) {
10267
10290
  }
10268
10291
  const newState = Object.assign({}, state);
10269
10292
  for (const key in update.updates) {
10270
- if (_optionalChain([update, 'access', _218 => _218.updates, 'access', _219 => _219[key], 'optionalAccess', _220 => _220.type]) === "update") {
10293
+ if (_optionalChain([update, 'access', _234 => _234.updates, 'access', _235 => _235[key], 'optionalAccess', _236 => _236.type]) === "update") {
10271
10294
  const val = update.node.get(key);
10272
10295
  if (val !== void 0) {
10273
10296
  newState[key] = lsonToJson(val);
10274
10297
  }
10275
- } else if (_optionalChain([update, 'access', _221 => _221.updates, 'access', _222 => _222[key], 'optionalAccess', _223 => _223.type]) === "delete") {
10298
+ } else if (_optionalChain([update, 'access', _237 => _237.updates, 'access', _238 => _238[key], 'optionalAccess', _239 => _239.type]) === "delete") {
10276
10299
  delete newState[key];
10277
10300
  }
10278
10301
  }
@@ -10333,12 +10356,12 @@ function legacy_patchImmutableNode(state, path, update) {
10333
10356
  }
10334
10357
  const newState = Object.assign({}, state);
10335
10358
  for (const key in update.updates) {
10336
- if (_optionalChain([update, 'access', _224 => _224.updates, 'access', _225 => _225[key], 'optionalAccess', _226 => _226.type]) === "update") {
10359
+ if (_optionalChain([update, 'access', _240 => _240.updates, 'access', _241 => _241[key], 'optionalAccess', _242 => _242.type]) === "update") {
10337
10360
  const value = update.node.get(key);
10338
10361
  if (value !== void 0) {
10339
10362
  newState[key] = lsonToJson(value);
10340
10363
  }
10341
- } else if (_optionalChain([update, 'access', _227 => _227.updates, 'access', _228 => _228[key], 'optionalAccess', _229 => _229.type]) === "delete") {
10364
+ } else if (_optionalChain([update, 'access', _243 => _243.updates, 'access', _244 => _244[key], 'optionalAccess', _245 => _245.type]) === "delete") {
10342
10365
  delete newState[key];
10343
10366
  }
10344
10367
  }
@@ -10418,9 +10441,9 @@ function makePoller(callback, intervalMs, options) {
10418
10441
  const startTime = performance.now();
10419
10442
  const doc = typeof document !== "undefined" ? document : void 0;
10420
10443
  const win = typeof window !== "undefined" ? window : void 0;
10421
- const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _230 => _230.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
10444
+ const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _246 => _246.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
10422
10445
  const context = {
10423
- inForeground: _optionalChain([doc, 'optionalAccess', _231 => _231.visibilityState]) !== "hidden",
10446
+ inForeground: _optionalChain([doc, 'optionalAccess', _247 => _247.visibilityState]) !== "hidden",
10424
10447
  lastSuccessfulPollAt: startTime,
10425
10448
  count: 0,
10426
10449
  backoff: 0
@@ -10501,11 +10524,11 @@ function makePoller(callback, intervalMs, options) {
10501
10524
  pollNowIfStale();
10502
10525
  }
10503
10526
  function onVisibilityChange() {
10504
- setInForeground(_optionalChain([doc, 'optionalAccess', _232 => _232.visibilityState]) !== "hidden");
10527
+ setInForeground(_optionalChain([doc, 'optionalAccess', _248 => _248.visibilityState]) !== "hidden");
10505
10528
  }
10506
- _optionalChain([doc, 'optionalAccess', _233 => _233.addEventListener, 'call', _234 => _234("visibilitychange", onVisibilityChange)]);
10507
- _optionalChain([win, 'optionalAccess', _235 => _235.addEventListener, 'call', _236 => _236("online", onVisibilityChange)]);
10508
- _optionalChain([win, 'optionalAccess', _237 => _237.addEventListener, 'call', _238 => _238("focus", pollNowIfStale)]);
10529
+ _optionalChain([doc, 'optionalAccess', _249 => _249.addEventListener, 'call', _250 => _250("visibilitychange", onVisibilityChange)]);
10530
+ _optionalChain([win, 'optionalAccess', _251 => _251.addEventListener, 'call', _252 => _252("online", onVisibilityChange)]);
10531
+ _optionalChain([win, 'optionalAccess', _253 => _253.addEventListener, 'call', _254 => _254("focus", pollNowIfStale)]);
10509
10532
  fsm.start();
10510
10533
  return {
10511
10534
  inc,