@liveblocks/core 3.8.0 → 3.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 = "3.8.0";
9
+ var PKG_VERSION = "3.8.1";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -703,6 +703,7 @@ var AiChatDB = class {
703
703
  this.signal = new MutableSignal(this);
704
704
  }
705
705
  getEvenIfDeleted(chatId) {
706
+ this.signal.get();
706
707
  return this.#byId.get(chatId);
707
708
  }
708
709
  markDeleted(chatId) {
@@ -4255,6 +4256,23 @@ var KnowledgeStack = class {
4255
4256
  this.invalidate();
4256
4257
  }
4257
4258
  };
4259
+ function createStore_forKnowledge() {
4260
+ const knowledgeByChatId = new DefaultMap(
4261
+ (_chatId) => new KnowledgeStack()
4262
+ );
4263
+ function getKnowledgeStack(chatId) {
4264
+ return knowledgeByChatId.getOrCreate(_nullishCoalesce(chatId, () => ( kWILDCARD)));
4265
+ }
4266
+ function getKnowledgeForChat(chatId) {
4267
+ const globalKnowledge = knowledgeByChatId.getOrCreate(kWILDCARD).get();
4268
+ const scopedKnowledge = _nullishCoalesce(_optionalChain([knowledgeByChatId, 'access', _68 => _68.get, 'call', _69 => _69(chatId), 'optionalAccess', _70 => _70.get, 'call', _71 => _71()]), () => ( []));
4269
+ return [...globalKnowledge, ...scopedKnowledge];
4270
+ }
4271
+ return {
4272
+ getKnowledgeStack,
4273
+ getKnowledgeForChat
4274
+ };
4275
+ }
4258
4276
  function now() {
4259
4277
  return (/* @__PURE__ */ new Date()).toISOString();
4260
4278
  }
@@ -4272,7 +4290,7 @@ function createStore_forTools() {
4272
4290
  return DerivedSignal.from(() => {
4273
4291
  return (
4274
4292
  // A tool that's registered and scoped to a specific chat ID...
4275
- _nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess', _68 => _68.get, 'call', _69 => _69()]), () => ( // ...or a globally registered tool
4293
+ _nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess', _72 => _72.get, 'call', _73 => _73()]), () => ( // ...or a globally registered tool
4276
4294
  toolsByChatId\u03A3.getOrCreate(kWILDCARD).getOrCreate(name).get()))
4277
4295
  );
4278
4296
  });
@@ -4302,8 +4320,8 @@ function createStore_forTools() {
4302
4320
  const globalTools\u03A3 = toolsByChatId\u03A3.get(kWILDCARD);
4303
4321
  const scopedTools\u03A3 = toolsByChatId\u03A3.get(chatId);
4304
4322
  return Array.from([
4305
- ..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _70 => _70.entries, 'call', _71 => _71()]), () => ( [])),
4306
- ..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _72 => _72.entries, 'call', _73 => _73()]), () => ( []))
4323
+ ..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _74 => _74.entries, 'call', _75 => _75()]), () => ( [])),
4324
+ ..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _76 => _76.entries, 'call', _77 => _77()]), () => ( []))
4307
4325
  ]).flatMap(([name, tool\u03A3]) => {
4308
4326
  const tool = tool\u03A3.get();
4309
4327
  return tool && (_nullishCoalesce(tool.enabled, () => ( true))) ? [{ name, description: tool.description, parameters: tool.parameters }] : [];
@@ -4406,7 +4424,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
4406
4424
  } else {
4407
4425
  continue;
4408
4426
  }
4409
- const executeFn = _optionalChain([toolsStore, 'access', _74 => _74.getTool\u03A3, 'call', _75 => _75(toolInvocation.name, message.chatId), 'access', _76 => _76.get, 'call', _77 => _77(), 'optionalAccess', _78 => _78.execute]);
4427
+ const executeFn = _optionalChain([toolsStore, 'access', _78 => _78.getTool\u03A3, 'call', _79 => _79(toolInvocation.name, message.chatId), 'access', _80 => _80.get, 'call', _81 => _81(), 'optionalAccess', _82 => _82.execute]);
4410
4428
  if (executeFn) {
4411
4429
  (async () => {
4412
4430
  const result = await executeFn(toolInvocation.args, {
@@ -4505,8 +4523,8 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
4505
4523
  const spine = [];
4506
4524
  let lastVisitedMessage = null;
4507
4525
  for (const message2 of pool.walkUp(leaf.id)) {
4508
- const prev = _nullishCoalesce(_optionalChain([first, 'call', _79 => _79(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _80 => _80.id]), () => ( null));
4509
- const next = _nullishCoalesce(_optionalChain([first, 'call', _81 => _81(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _82 => _82.id]), () => ( null));
4526
+ const prev = _nullishCoalesce(_optionalChain([first, 'call', _83 => _83(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _84 => _84.id]), () => ( null));
4527
+ const next = _nullishCoalesce(_optionalChain([first, 'call', _85 => _85(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _86 => _86.id]), () => ( null));
4510
4528
  if (!message2.deletedAt || prev || next) {
4511
4529
  const node = {
4512
4530
  ...message2,
@@ -4572,7 +4590,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
4572
4590
  const latest = pool.sorted.findRight(
4573
4591
  (m) => m.role === "assistant" && !m.deletedAt
4574
4592
  );
4575
- return _optionalChain([latest, 'optionalAccess', _83 => _83.copilotId]);
4593
+ return _optionalChain([latest, 'optionalAccess', _87 => _87.copilotId]);
4576
4594
  }
4577
4595
  return {
4578
4596
  // Readers
@@ -4603,11 +4621,11 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
4603
4621
  *getAutoExecutingMessageIds() {
4604
4622
  for (const messageId of myMessages) {
4605
4623
  const message = getMessageById(messageId);
4606
- if (_optionalChain([message, 'optionalAccess', _84 => _84.role]) === "assistant" && message.status === "awaiting-tool") {
4624
+ if (_optionalChain([message, 'optionalAccess', _88 => _88.role]) === "assistant" && message.status === "awaiting-tool") {
4607
4625
  const isAutoExecuting = message.contentSoFar.some((part) => {
4608
4626
  if (part.type === "tool-invocation" && part.stage === "executing") {
4609
4627
  const tool = toolsStore.getTool\u03A3(part.name, message.chatId).get();
4610
- return typeof _optionalChain([tool, 'optionalAccess', _85 => _85.execute]) === "function";
4628
+ return typeof _optionalChain([tool, 'optionalAccess', _89 => _89.execute]) === "function";
4611
4629
  }
4612
4630
  return false;
4613
4631
  });
@@ -4658,6 +4676,7 @@ function createAi(config) {
4658
4676
  );
4659
4677
  const chatsStore = createStore_forUserAiChats();
4660
4678
  const toolsStore = createStore_forTools();
4679
+ const knowledgeStore = createStore_forKnowledge();
4661
4680
  const messagesStore = createStore_forChatMessages(toolsStore, setToolResult);
4662
4681
  const context = {
4663
4682
  staticSessionInfoSig: new Signal(null),
@@ -4666,7 +4685,7 @@ function createAi(config) {
4666
4685
  chatsStore,
4667
4686
  messagesStore,
4668
4687
  toolsStore,
4669
- knowledge: new KnowledgeStack()
4688
+ knowledgeStore
4670
4689
  };
4671
4690
  const DELTA_THROTTLE = 25;
4672
4691
  let pendingDeltas = [];
@@ -4752,7 +4771,7 @@ function createAi(config) {
4752
4771
  flushPendingDeltas();
4753
4772
  switch (msg.event) {
4754
4773
  case "cmd-failed":
4755
- _optionalChain([pendingCmd, 'optionalAccess', _86 => _86.reject, 'call', _87 => _87(new Error(msg.error))]);
4774
+ _optionalChain([pendingCmd, 'optionalAccess', _90 => _90.reject, 'call', _91 => _91(new Error(msg.error))]);
4756
4775
  break;
4757
4776
  case "settle": {
4758
4777
  context.messagesStore.upsert(msg.message);
@@ -4829,7 +4848,7 @@ function createAi(config) {
4829
4848
  return assertNever(msg, "Unhandled case");
4830
4849
  }
4831
4850
  }
4832
- _optionalChain([pendingCmd, 'optionalAccess', _88 => _88.resolve, 'call', _89 => _89(msg)]);
4851
+ _optionalChain([pendingCmd, 'optionalAccess', _92 => _92.resolve, 'call', _93 => _93(msg)]);
4833
4852
  }
4834
4853
  managedSocket.events.onMessage.subscribe(handleServerMessage);
4835
4854
  managedSocket.events.statusDidChange.subscribe(onStatusDidChange);
@@ -4895,17 +4914,8 @@ function createAi(config) {
4895
4914
  chatId
4896
4915
  });
4897
4916
  }
4898
- function registerKnowledgeLayer(uniqueLayerId) {
4899
- return context.knowledge.registerLayer(uniqueLayerId);
4900
- }
4901
- function deregisterKnowledgeLayer(layerKey) {
4902
- context.knowledge.deregisterLayer(layerKey);
4903
- }
4904
- function updateKnowledge(layerKey, data, key = nanoid()) {
4905
- context.knowledge.updateKnowledge(layerKey, key, data);
4906
- }
4907
4917
  async function setToolResult(chatId, messageId, invocationId, result, options) {
4908
- const knowledge = context.knowledge.get();
4918
+ const knowledge = context.knowledgeStore.getKnowledgeForChat(chatId);
4909
4919
  const tools = context.toolsStore.getToolDescriptions(chatId);
4910
4920
  const resp = await sendClientMsgWithResponse({
4911
4921
  cmd: "set-tool-result",
@@ -4914,9 +4924,9 @@ function createAi(config) {
4914
4924
  invocationId,
4915
4925
  result,
4916
4926
  generationOptions: {
4917
- copilotId: _optionalChain([options, 'optionalAccess', _90 => _90.copilotId]),
4918
- stream: _optionalChain([options, 'optionalAccess', _91 => _91.stream]),
4919
- timeout: _optionalChain([options, 'optionalAccess', _92 => _92.timeout]),
4927
+ copilotId: _optionalChain([options, 'optionalAccess', _94 => _94.copilotId]),
4928
+ stream: _optionalChain([options, 'optionalAccess', _95 => _95.stream]),
4929
+ timeout: _optionalChain([options, 'optionalAccess', _96 => _96.timeout]),
4920
4930
  // Knowledge and tools aren't coming from the options, but retrieved
4921
4931
  // from the global context
4922
4932
  knowledge: knowledge.length > 0 ? knowledge : void 0,
@@ -4934,7 +4944,7 @@ function createAi(config) {
4934
4944
  }
4935
4945
  }
4936
4946
  const win = typeof window !== "undefined" ? window : void 0;
4937
- _optionalChain([win, 'optionalAccess', _93 => _93.addEventListener, 'call', _94 => _94("beforeunload", handleBeforeUnload, { once: true })]);
4947
+ _optionalChain([win, 'optionalAccess', _97 => _97.addEventListener, 'call', _98 => _98("beforeunload", handleBeforeUnload, { once: true })]);
4938
4948
  return Object.defineProperty(
4939
4949
  {
4940
4950
  [kInternal]: {
@@ -4952,9 +4962,9 @@ function createAi(config) {
4952
4962
  deleteMessage: (chatId, messageId) => sendClientMsgWithResponse({ cmd: "delete-message", chatId, messageId }),
4953
4963
  clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
4954
4964
  askUserMessageInChat: async (chatId, userMessage, targetMessageId, options) => {
4955
- const globalKnowledge = context.knowledge.get();
4956
- const requestKnowledge = _optionalChain([options, 'optionalAccess', _95 => _95.knowledge]) || [];
4957
- const combinedKnowledge = [...globalKnowledge, ...requestKnowledge];
4965
+ const knowledge = context.knowledgeStore.getKnowledgeForChat(chatId);
4966
+ const requestKnowledge = _optionalChain([options, 'optionalAccess', _99 => _99.knowledge]) || [];
4967
+ const combinedKnowledge = [...knowledge, ...requestKnowledge];
4958
4968
  const tools = context.toolsStore.getToolDescriptions(chatId);
4959
4969
  messagesStore.markMine(targetMessageId);
4960
4970
  const resp = await sendClientMsgWithResponse({
@@ -4963,9 +4973,9 @@ function createAi(config) {
4963
4973
  sourceMessage: userMessage,
4964
4974
  targetMessageId,
4965
4975
  generationOptions: {
4966
- copilotId: _optionalChain([options, 'optionalAccess', _96 => _96.copilotId]),
4967
- stream: _optionalChain([options, 'optionalAccess', _97 => _97.stream]),
4968
- timeout: _optionalChain([options, 'optionalAccess', _98 => _98.timeout]),
4976
+ copilotId: _optionalChain([options, 'optionalAccess', _100 => _100.copilotId]),
4977
+ stream: _optionalChain([options, 'optionalAccess', _101 => _101.stream]),
4978
+ timeout: _optionalChain([options, 'optionalAccess', _102 => _102.timeout]),
4969
4979
  // Combine global knowledge with request-specific knowledge
4970
4980
  knowledge: combinedKnowledge.length > 0 ? combinedKnowledge : void 0,
4971
4981
  tools: tools.length > 0 ? tools : void 0
@@ -4983,9 +4993,18 @@ function createAi(config) {
4983
4993
  getChatById: context.chatsStore.getChatById,
4984
4994
  queryChats: context.chatsStore.findMany,
4985
4995
  getLastUsedCopilotId: context.messagesStore.getLastUsedCopilotId,
4986
- registerKnowledgeLayer,
4987
- deregisterKnowledgeLayer,
4988
- updateKnowledge,
4996
+ registerKnowledgeLayer: (uniqueLayerId, chatId) => {
4997
+ const stack = context.knowledgeStore.getKnowledgeStack(chatId);
4998
+ const layerKey = stack.registerLayer(uniqueLayerId);
4999
+ const deregister = () => stack.deregisterLayer(layerKey);
5000
+ return {
5001
+ layerKey,
5002
+ deregister
5003
+ };
5004
+ },
5005
+ updateKnowledge: (layerKey, data, key, chatId) => {
5006
+ context.knowledgeStore.getKnowledgeStack(chatId).updateKnowledge(layerKey, _nullishCoalesce(key, () => ( nanoid())), data);
5007
+ },
4989
5008
  registerTool: context.toolsStore.registerTool
4990
5009
  },
4991
5010
  kInternal,
@@ -5066,7 +5085,7 @@ function createAuthManager(authOptions, onAuthenticate) {
5066
5085
  return void 0;
5067
5086
  }
5068
5087
  async function makeAuthRequest(options) {
5069
- const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _99 => _99.polyfills, 'optionalAccess', _100 => _100.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
5088
+ const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _103 => _103.polyfills, 'optionalAccess', _104 => _104.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
5070
5089
  if (authentication.type === "private") {
5071
5090
  if (fetcher === void 0) {
5072
5091
  throw new StopRetrying(
@@ -5082,7 +5101,7 @@ function createAuthManager(authOptions, onAuthenticate) {
5082
5101
  "The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
5083
5102
  );
5084
5103
  }
5085
- _optionalChain([onAuthenticate, 'optionalCall', _101 => _101(parsed.parsed)]);
5104
+ _optionalChain([onAuthenticate, 'optionalCall', _105 => _105(parsed.parsed)]);
5086
5105
  return parsed;
5087
5106
  }
5088
5107
  if (authentication.type === "custom") {
@@ -5090,7 +5109,7 @@ function createAuthManager(authOptions, onAuthenticate) {
5090
5109
  if (response && typeof response === "object") {
5091
5110
  if (typeof response.token === "string") {
5092
5111
  const parsed = parseAuthToken(response.token);
5093
- _optionalChain([onAuthenticate, 'optionalCall', _102 => _102(parsed.parsed)]);
5112
+ _optionalChain([onAuthenticate, 'optionalCall', _106 => _106(parsed.parsed)]);
5094
5113
  return parsed;
5095
5114
  } else if (typeof response.error === "string") {
5096
5115
  const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
@@ -5249,7 +5268,7 @@ function sendToPanel(message, options) {
5249
5268
  ...message,
5250
5269
  source: "liveblocks-devtools-client"
5251
5270
  };
5252
- if (!(_optionalChain([options, 'optionalAccess', _103 => _103.force]) || _bridgeActive)) {
5271
+ if (!(_optionalChain([options, 'optionalAccess', _107 => _107.force]) || _bridgeActive)) {
5253
5272
  return;
5254
5273
  }
5255
5274
  window.postMessage(fullMsg, "*");
@@ -5257,7 +5276,7 @@ function sendToPanel(message, options) {
5257
5276
  var eventSource = makeEventSource();
5258
5277
  if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
5259
5278
  window.addEventListener("message", (event) => {
5260
- if (event.source === window && _optionalChain([event, 'access', _104 => _104.data, 'optionalAccess', _105 => _105.source]) === "liveblocks-devtools-panel") {
5279
+ if (event.source === window && _optionalChain([event, 'access', _108 => _108.data, 'optionalAccess', _109 => _109.source]) === "liveblocks-devtools-panel") {
5261
5280
  eventSource.notify(event.data);
5262
5281
  } else {
5263
5282
  }
@@ -5399,7 +5418,7 @@ function fullSync(room) {
5399
5418
  msg: "room::sync::full",
5400
5419
  roomId: room.id,
5401
5420
  status: room.getStatus(),
5402
- storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _106 => _106.toTreeNode, 'call', _107 => _107("root"), 'access', _108 => _108.payload]), () => ( null)),
5421
+ storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _110 => _110.toTreeNode, 'call', _111 => _111("root"), 'access', _112 => _112.payload]), () => ( null)),
5403
5422
  me,
5404
5423
  others
5405
5424
  });
@@ -5706,7 +5725,7 @@ function createManagedPool(roomId, options) {
5706
5725
  generateId: () => `${getCurrentConnectionId()}:${clock++}`,
5707
5726
  generateOpId: () => `${getCurrentConnectionId()}:${opClock++}`,
5708
5727
  dispatch(ops, reverse, storageUpdates) {
5709
- _optionalChain([onDispatch, 'optionalCall', _109 => _109(ops, reverse, storageUpdates)]);
5728
+ _optionalChain([onDispatch, 'optionalCall', _113 => _113(ops, reverse, storageUpdates)]);
5710
5729
  },
5711
5730
  assertStorageIsWritable: () => {
5712
5731
  if (!isStorageWritable()) {
@@ -5933,7 +5952,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
5933
5952
  return [
5934
5953
  {
5935
5954
  type: 8 /* CREATE_REGISTER */,
5936
- opId: _optionalChain([pool, 'optionalAccess', _110 => _110.generateOpId, 'call', _111 => _111()]),
5955
+ opId: _optionalChain([pool, 'optionalAccess', _114 => _114.generateOpId, 'call', _115 => _115()]),
5937
5956
  id: this._id,
5938
5957
  parentId,
5939
5958
  parentKey,
@@ -6039,7 +6058,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6039
6058
  const ops = [];
6040
6059
  const op = {
6041
6060
  id: this._id,
6042
- opId: _optionalChain([pool, 'optionalAccess', _112 => _112.generateOpId, 'call', _113 => _113()]),
6061
+ opId: _optionalChain([pool, 'optionalAccess', _116 => _116.generateOpId, 'call', _117 => _117()]),
6043
6062
  type: 2 /* CREATE_LIST */,
6044
6063
  parentId,
6045
6064
  parentKey
@@ -6310,7 +6329,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6310
6329
  #applyInsertUndoRedo(op) {
6311
6330
  const { id, parentKey: key } = op;
6312
6331
  const child = creationOpToLiveNode(op);
6313
- if (_optionalChain([this, 'access', _114 => _114._pool, 'optionalAccess', _115 => _115.getNode, 'call', _116 => _116(id)]) !== void 0) {
6332
+ if (_optionalChain([this, 'access', _118 => _118._pool, 'optionalAccess', _119 => _119.getNode, 'call', _120 => _120(id)]) !== void 0) {
6314
6333
  return { modified: false };
6315
6334
  }
6316
6335
  child._attach(id, nn(this._pool));
@@ -6318,8 +6337,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
6318
6337
  const existingItemIndex = this._indexOfPosition(key);
6319
6338
  let newKey = key;
6320
6339
  if (existingItemIndex !== -1) {
6321
- const before2 = _optionalChain([this, 'access', _117 => _117.#items, 'access', _118 => _118[existingItemIndex], 'optionalAccess', _119 => _119._parentPos]);
6322
- const after2 = _optionalChain([this, 'access', _120 => _120.#items, 'access', _121 => _121[existingItemIndex + 1], 'optionalAccess', _122 => _122._parentPos]);
6340
+ const before2 = _optionalChain([this, 'access', _121 => _121.#items, 'access', _122 => _122[existingItemIndex], 'optionalAccess', _123 => _123._parentPos]);
6341
+ const after2 = _optionalChain([this, 'access', _124 => _124.#items, 'access', _125 => _125[existingItemIndex + 1], 'optionalAccess', _126 => _126._parentPos]);
6323
6342
  newKey = makePosition(before2, after2);
6324
6343
  child._setParentLink(this, newKey);
6325
6344
  }
@@ -6333,7 +6352,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6333
6352
  #applySetUndoRedo(op) {
6334
6353
  const { id, parentKey: key } = op;
6335
6354
  const child = creationOpToLiveNode(op);
6336
- if (_optionalChain([this, 'access', _123 => _123._pool, 'optionalAccess', _124 => _124.getNode, 'call', _125 => _125(id)]) !== void 0) {
6355
+ if (_optionalChain([this, 'access', _127 => _127._pool, 'optionalAccess', _128 => _128.getNode, 'call', _129 => _129(id)]) !== void 0) {
6337
6356
  return { modified: false };
6338
6357
  }
6339
6358
  this.#unacknowledgedSets.set(key, nn(op.opId));
@@ -6454,7 +6473,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6454
6473
  } else {
6455
6474
  this.#items[existingItemIndex]._setParentLink(
6456
6475
  this,
6457
- makePosition(newKey, _optionalChain([this, 'access', _126 => _126.#items, 'access', _127 => _127[existingItemIndex + 1], 'optionalAccess', _128 => _128._parentPos]))
6476
+ makePosition(newKey, _optionalChain([this, 'access', _130 => _130.#items, 'access', _131 => _131[existingItemIndex + 1], 'optionalAccess', _132 => _132._parentPos]))
6458
6477
  );
6459
6478
  const previousIndex = this.#items.indexOf(child);
6460
6479
  child._setParentLink(this, newKey);
@@ -6479,7 +6498,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6479
6498
  if (existingItemIndex !== -1) {
6480
6499
  this.#items[existingItemIndex]._setParentLink(
6481
6500
  this,
6482
- makePosition(newKey, _optionalChain([this, 'access', _129 => _129.#items, 'access', _130 => _130[existingItemIndex + 1], 'optionalAccess', _131 => _131._parentPos]))
6501
+ makePosition(newKey, _optionalChain([this, 'access', _133 => _133.#items, 'access', _134 => _134[existingItemIndex + 1], 'optionalAccess', _135 => _135._parentPos]))
6483
6502
  );
6484
6503
  }
6485
6504
  child._setParentLink(this, newKey);
@@ -6498,7 +6517,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6498
6517
  if (existingItemIndex !== -1) {
6499
6518
  this.#items[existingItemIndex]._setParentLink(
6500
6519
  this,
6501
- makePosition(newKey, _optionalChain([this, 'access', _132 => _132.#items, 'access', _133 => _133[existingItemIndex + 1], 'optionalAccess', _134 => _134._parentPos]))
6520
+ makePosition(newKey, _optionalChain([this, 'access', _136 => _136.#items, 'access', _137 => _137[existingItemIndex + 1], 'optionalAccess', _138 => _138._parentPos]))
6502
6521
  );
6503
6522
  }
6504
6523
  child._setParentLink(this, newKey);
@@ -6526,7 +6545,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6526
6545
  if (existingItemIndex !== -1) {
6527
6546
  actualNewKey = makePosition(
6528
6547
  newKey,
6529
- _optionalChain([this, 'access', _135 => _135.#items, 'access', _136 => _136[existingItemIndex + 1], 'optionalAccess', _137 => _137._parentPos])
6548
+ _optionalChain([this, 'access', _139 => _139.#items, 'access', _140 => _140[existingItemIndex + 1], 'optionalAccess', _141 => _141._parentPos])
6530
6549
  );
6531
6550
  }
6532
6551
  child._setParentLink(this, actualNewKey);
@@ -6584,7 +6603,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6584
6603
  * @param element The element to add to the end of the LiveList.
6585
6604
  */
6586
6605
  push(element) {
6587
- _optionalChain([this, 'access', _138 => _138._pool, 'optionalAccess', _139 => _139.assertStorageIsWritable, 'call', _140 => _140()]);
6606
+ _optionalChain([this, 'access', _142 => _142._pool, 'optionalAccess', _143 => _143.assertStorageIsWritable, 'call', _144 => _144()]);
6588
6607
  return this.insert(element, this.length);
6589
6608
  }
6590
6609
  /**
@@ -6593,7 +6612,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6593
6612
  * @param index The index at which you want to insert the element.
6594
6613
  */
6595
6614
  insert(element, index) {
6596
- _optionalChain([this, 'access', _141 => _141._pool, 'optionalAccess', _142 => _142.assertStorageIsWritable, 'call', _143 => _143()]);
6615
+ _optionalChain([this, 'access', _145 => _145._pool, 'optionalAccess', _146 => _146.assertStorageIsWritable, 'call', _147 => _147()]);
6597
6616
  if (index < 0 || index > this.#items.length) {
6598
6617
  throw new Error(
6599
6618
  `Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
@@ -6623,7 +6642,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6623
6642
  * @param targetIndex The index where the element should be after moving.
6624
6643
  */
6625
6644
  move(index, targetIndex) {
6626
- _optionalChain([this, 'access', _144 => _144._pool, 'optionalAccess', _145 => _145.assertStorageIsWritable, 'call', _146 => _146()]);
6645
+ _optionalChain([this, 'access', _148 => _148._pool, 'optionalAccess', _149 => _149.assertStorageIsWritable, 'call', _150 => _150()]);
6627
6646
  if (targetIndex < 0) {
6628
6647
  throw new Error("targetIndex cannot be less than 0");
6629
6648
  }
@@ -6681,7 +6700,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6681
6700
  * @param index The index of the element to delete
6682
6701
  */
6683
6702
  delete(index) {
6684
- _optionalChain([this, 'access', _147 => _147._pool, 'optionalAccess', _148 => _148.assertStorageIsWritable, 'call', _149 => _149()]);
6703
+ _optionalChain([this, 'access', _151 => _151._pool, 'optionalAccess', _152 => _152.assertStorageIsWritable, 'call', _153 => _153()]);
6685
6704
  if (index < 0 || index >= this.#items.length) {
6686
6705
  throw new Error(
6687
6706
  `Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -6714,7 +6733,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6714
6733
  }
6715
6734
  }
6716
6735
  clear() {
6717
- _optionalChain([this, 'access', _150 => _150._pool, 'optionalAccess', _151 => _151.assertStorageIsWritable, 'call', _152 => _152()]);
6736
+ _optionalChain([this, 'access', _154 => _154._pool, 'optionalAccess', _155 => _155.assertStorageIsWritable, 'call', _156 => _156()]);
6718
6737
  if (this._pool) {
6719
6738
  const ops = [];
6720
6739
  const reverseOps = [];
@@ -6748,7 +6767,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6748
6767
  }
6749
6768
  }
6750
6769
  set(index, item) {
6751
- _optionalChain([this, 'access', _153 => _153._pool, 'optionalAccess', _154 => _154.assertStorageIsWritable, 'call', _155 => _155()]);
6770
+ _optionalChain([this, 'access', _157 => _157._pool, 'optionalAccess', _158 => _158.assertStorageIsWritable, 'call', _159 => _159()]);
6752
6771
  if (index < 0 || index >= this.#items.length) {
6753
6772
  throw new Error(
6754
6773
  `Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -6894,7 +6913,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6894
6913
  #shiftItemPosition(index, key) {
6895
6914
  const shiftedPosition = makePosition(
6896
6915
  key,
6897
- this.#items.length > index + 1 ? _optionalChain([this, 'access', _156 => _156.#items, 'access', _157 => _157[index + 1], 'optionalAccess', _158 => _158._parentPos]) : void 0
6916
+ this.#items.length > index + 1 ? _optionalChain([this, 'access', _160 => _160.#items, 'access', _161 => _161[index + 1], 'optionalAccess', _162 => _162._parentPos]) : void 0
6898
6917
  );
6899
6918
  this.#items[index]._setParentLink(this, shiftedPosition);
6900
6919
  }
@@ -7019,7 +7038,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
7019
7038
  const ops = [];
7020
7039
  const op = {
7021
7040
  id: this._id,
7022
- opId: _optionalChain([pool, 'optionalAccess', _159 => _159.generateOpId, 'call', _160 => _160()]),
7041
+ opId: _optionalChain([pool, 'optionalAccess', _163 => _163.generateOpId, 'call', _164 => _164()]),
7023
7042
  type: 7 /* CREATE_MAP */,
7024
7043
  parentId,
7025
7044
  parentKey
@@ -7159,7 +7178,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
7159
7178
  * @param value The value of the element to add. Should be serializable to JSON.
7160
7179
  */
7161
7180
  set(key, value) {
7162
- _optionalChain([this, 'access', _161 => _161._pool, 'optionalAccess', _162 => _162.assertStorageIsWritable, 'call', _163 => _163()]);
7181
+ _optionalChain([this, 'access', _165 => _165._pool, 'optionalAccess', _166 => _166.assertStorageIsWritable, 'call', _167 => _167()]);
7163
7182
  const oldValue = this.#map.get(key);
7164
7183
  if (oldValue) {
7165
7184
  oldValue._detach();
@@ -7205,7 +7224,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
7205
7224
  * @returns true if an element existed and has been removed, or false if the element does not exist.
7206
7225
  */
7207
7226
  delete(key) {
7208
- _optionalChain([this, 'access', _164 => _164._pool, 'optionalAccess', _165 => _165.assertStorageIsWritable, 'call', _166 => _166()]);
7227
+ _optionalChain([this, 'access', _168 => _168._pool, 'optionalAccess', _169 => _169.assertStorageIsWritable, 'call', _170 => _170()]);
7209
7228
  const item = this.#map.get(key);
7210
7229
  if (item === void 0) {
7211
7230
  return false;
@@ -7400,7 +7419,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7400
7419
  if (this._id === void 0) {
7401
7420
  throw new Error("Cannot serialize item is not attached");
7402
7421
  }
7403
- const opId = _optionalChain([pool, 'optionalAccess', _167 => _167.generateOpId, 'call', _168 => _168()]);
7422
+ const opId = _optionalChain([pool, 'optionalAccess', _171 => _171.generateOpId, 'call', _172 => _172()]);
7404
7423
  const ops = [];
7405
7424
  const op = {
7406
7425
  type: 4 /* CREATE_OBJECT */,
@@ -7674,7 +7693,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7674
7693
  * @param value The value of the property to add
7675
7694
  */
7676
7695
  set(key, value) {
7677
- _optionalChain([this, 'access', _169 => _169._pool, 'optionalAccess', _170 => _170.assertStorageIsWritable, 'call', _171 => _171()]);
7696
+ _optionalChain([this, 'access', _173 => _173._pool, 'optionalAccess', _174 => _174.assertStorageIsWritable, 'call', _175 => _175()]);
7678
7697
  this.update({ [key]: value });
7679
7698
  }
7680
7699
  /**
@@ -7689,7 +7708,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7689
7708
  * @param key The key of the property to delete
7690
7709
  */
7691
7710
  delete(key) {
7692
- _optionalChain([this, 'access', _172 => _172._pool, 'optionalAccess', _173 => _173.assertStorageIsWritable, 'call', _174 => _174()]);
7711
+ _optionalChain([this, 'access', _176 => _176._pool, 'optionalAccess', _177 => _177.assertStorageIsWritable, 'call', _178 => _178()]);
7693
7712
  const keyAsString = key;
7694
7713
  const oldValue = this.#map.get(keyAsString);
7695
7714
  if (oldValue === void 0) {
@@ -7744,7 +7763,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7744
7763
  * @param patch The object used to overrides properties
7745
7764
  */
7746
7765
  update(patch) {
7747
- _optionalChain([this, 'access', _175 => _175._pool, 'optionalAccess', _176 => _176.assertStorageIsWritable, 'call', _177 => _177()]);
7766
+ _optionalChain([this, 'access', _179 => _179._pool, 'optionalAccess', _180 => _180.assertStorageIsWritable, 'call', _181 => _181()]);
7748
7767
  if (_LiveObject.detectLargeObjects) {
7749
7768
  const data = {};
7750
7769
  for (const [key, value] of this.#map) {
@@ -8492,15 +8511,15 @@ function installBackgroundTabSpy() {
8492
8511
  const doc = typeof document !== "undefined" ? document : void 0;
8493
8512
  const inBackgroundSince = { current: null };
8494
8513
  function onVisibilityChange() {
8495
- if (_optionalChain([doc, 'optionalAccess', _178 => _178.visibilityState]) === "hidden") {
8514
+ if (_optionalChain([doc, 'optionalAccess', _182 => _182.visibilityState]) === "hidden") {
8496
8515
  inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
8497
8516
  } else {
8498
8517
  inBackgroundSince.current = null;
8499
8518
  }
8500
8519
  }
8501
- _optionalChain([doc, 'optionalAccess', _179 => _179.addEventListener, 'call', _180 => _180("visibilitychange", onVisibilityChange)]);
8520
+ _optionalChain([doc, 'optionalAccess', _183 => _183.addEventListener, 'call', _184 => _184("visibilitychange", onVisibilityChange)]);
8502
8521
  const unsub = () => {
8503
- _optionalChain([doc, 'optionalAccess', _181 => _181.removeEventListener, 'call', _182 => _182("visibilitychange", onVisibilityChange)]);
8522
+ _optionalChain([doc, 'optionalAccess', _185 => _185.removeEventListener, 'call', _186 => _186("visibilitychange", onVisibilityChange)]);
8504
8523
  };
8505
8524
  return [inBackgroundSince, unsub];
8506
8525
  }
@@ -8680,7 +8699,7 @@ function createRoom(options, config) {
8680
8699
  }
8681
8700
  }
8682
8701
  function isStorageWritable() {
8683
- const scopes = _optionalChain([context, 'access', _183 => _183.dynamicSessionInfoSig, 'access', _184 => _184.get, 'call', _185 => _185(), 'optionalAccess', _186 => _186.scopes]);
8702
+ const scopes = _optionalChain([context, 'access', _187 => _187.dynamicSessionInfoSig, 'access', _188 => _188.get, 'call', _189 => _189(), 'optionalAccess', _190 => _190.scopes]);
8684
8703
  return scopes !== void 0 ? canWriteStorage(scopes) : true;
8685
8704
  }
8686
8705
  const eventHub = {
@@ -8811,7 +8830,7 @@ function createRoom(options, config) {
8811
8830
  // be stuck in "synchronizing" forever).
8812
8831
  case "experimental-fallback-to-http": {
8813
8832
  warn("Message is too large for websockets, so sending over HTTP instead");
8814
- const nonce = _nullishCoalesce(_optionalChain([context, 'access', _187 => _187.dynamicSessionInfoSig, 'access', _188 => _188.get, 'call', _189 => _189(), 'optionalAccess', _190 => _190.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
8833
+ const nonce = _nullishCoalesce(_optionalChain([context, 'access', _191 => _191.dynamicSessionInfoSig, 'access', _192 => _192.get, 'call', _193 => _193(), 'optionalAccess', _194 => _194.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
8815
8834
  void httpClient.sendMessagesOverHTTP({ roomId, nonce, messages }).then((resp) => {
8816
8835
  if (!resp.ok && resp.status === 403) {
8817
8836
  managedSocket.reconnect();
@@ -8866,7 +8885,7 @@ function createRoom(options, config) {
8866
8885
  } else {
8867
8886
  context.root = LiveObject._fromItems(message.items, context.pool);
8868
8887
  }
8869
- const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _191 => _191.get, 'call', _192 => _192(), 'optionalAccess', _193 => _193.canWrite]), () => ( true));
8888
+ const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _195 => _195.get, 'call', _196 => _196(), 'optionalAccess', _197 => _197.canWrite]), () => ( true));
8870
8889
  const stackSizeBefore = context.undoStack.length;
8871
8890
  for (const key in context.initialStorage) {
8872
8891
  if (context.root.get(key) === void 0) {
@@ -9069,7 +9088,7 @@ function createRoom(options, config) {
9069
9088
  }
9070
9089
  context.myPresence.patch(patch);
9071
9090
  if (context.activeBatch) {
9072
- if (_optionalChain([options2, 'optionalAccess', _194 => _194.addToHistory])) {
9091
+ if (_optionalChain([options2, 'optionalAccess', _198 => _198.addToHistory])) {
9073
9092
  context.activeBatch.reverseOps.pushLeft({
9074
9093
  type: "presence",
9075
9094
  data: oldValues
@@ -9078,7 +9097,7 @@ function createRoom(options, config) {
9078
9097
  context.activeBatch.updates.presence = true;
9079
9098
  } else {
9080
9099
  flushNowOrSoon();
9081
- if (_optionalChain([options2, 'optionalAccess', _195 => _195.addToHistory])) {
9100
+ if (_optionalChain([options2, 'optionalAccess', _199 => _199.addToHistory])) {
9082
9101
  addToUndoStack([{ type: "presence", data: oldValues }]);
9083
9102
  }
9084
9103
  notify({ presence: true });
@@ -9275,7 +9294,7 @@ function createRoom(options, config) {
9275
9294
  if (process.env.NODE_ENV !== "production") {
9276
9295
  const traces = /* @__PURE__ */ new Set();
9277
9296
  for (const opId of message.opIds) {
9278
- const trace = _optionalChain([context, 'access', _196 => _196.opStackTraces, 'optionalAccess', _197 => _197.get, 'call', _198 => _198(opId)]);
9297
+ const trace = _optionalChain([context, 'access', _200 => _200.opStackTraces, 'optionalAccess', _201 => _201.get, 'call', _202 => _202(opId)]);
9279
9298
  if (trace) {
9280
9299
  traces.add(trace);
9281
9300
  }
@@ -9409,7 +9428,7 @@ ${Array.from(traces).join("\n\n")}`
9409
9428
  const unacknowledgedOps = new Map(context.unacknowledgedOps);
9410
9429
  createOrUpdateRootFromMessage(message);
9411
9430
  applyAndSendOps(unacknowledgedOps);
9412
- _optionalChain([_resolveStoragePromise, 'optionalCall', _199 => _199()]);
9431
+ _optionalChain([_resolveStoragePromise, 'optionalCall', _203 => _203()]);
9413
9432
  notifyStorageStatus();
9414
9433
  eventHub.storageDidLoad.notify();
9415
9434
  }
@@ -9630,8 +9649,8 @@ ${Array.from(traces).join("\n\n")}`
9630
9649
  async function getThreads(options2) {
9631
9650
  return httpClient.getThreads({
9632
9651
  roomId,
9633
- query: _optionalChain([options2, 'optionalAccess', _200 => _200.query]),
9634
- cursor: _optionalChain([options2, 'optionalAccess', _201 => _201.cursor])
9652
+ query: _optionalChain([options2, 'optionalAccess', _204 => _204.query]),
9653
+ cursor: _optionalChain([options2, 'optionalAccess', _205 => _205.cursor])
9635
9654
  });
9636
9655
  }
9637
9656
  async function getThread(threadId) {
@@ -9738,7 +9757,7 @@ ${Array.from(traces).join("\n\n")}`
9738
9757
  function getSubscriptionSettings(options2) {
9739
9758
  return httpClient.getSubscriptionSettings({
9740
9759
  roomId,
9741
- signal: _optionalChain([options2, 'optionalAccess', _202 => _202.signal])
9760
+ signal: _optionalChain([options2, 'optionalAccess', _206 => _206.signal])
9742
9761
  });
9743
9762
  }
9744
9763
  function updateSubscriptionSettings(settings) {
@@ -9760,7 +9779,7 @@ ${Array.from(traces).join("\n\n")}`
9760
9779
  {
9761
9780
  [kInternal]: {
9762
9781
  get presenceBuffer() {
9763
- return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _203 => _203.buffer, 'access', _204 => _204.presenceUpdates, 'optionalAccess', _205 => _205.data]), () => ( null)));
9782
+ return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _207 => _207.buffer, 'access', _208 => _208.presenceUpdates, 'optionalAccess', _209 => _209.data]), () => ( null)));
9764
9783
  },
9765
9784
  // prettier-ignore
9766
9785
  get undoStack() {
@@ -9775,9 +9794,9 @@ ${Array.from(traces).join("\n\n")}`
9775
9794
  return context.yjsProvider;
9776
9795
  },
9777
9796
  setYjsProvider(newProvider) {
9778
- _optionalChain([context, 'access', _206 => _206.yjsProvider, 'optionalAccess', _207 => _207.off, 'call', _208 => _208("status", yjsStatusDidChange)]);
9797
+ _optionalChain([context, 'access', _210 => _210.yjsProvider, 'optionalAccess', _211 => _211.off, 'call', _212 => _212("status", yjsStatusDidChange)]);
9779
9798
  context.yjsProvider = newProvider;
9780
- _optionalChain([newProvider, 'optionalAccess', _209 => _209.on, 'call', _210 => _210("status", yjsStatusDidChange)]);
9799
+ _optionalChain([newProvider, 'optionalAccess', _213 => _213.on, 'call', _214 => _214("status", yjsStatusDidChange)]);
9781
9800
  context.yjsProviderDidChange.notify();
9782
9801
  },
9783
9802
  yjsProviderDidChange: context.yjsProviderDidChange.observable,
@@ -9823,7 +9842,7 @@ ${Array.from(traces).join("\n\n")}`
9823
9842
  source.dispose();
9824
9843
  }
9825
9844
  eventHub.roomWillDestroy.notify();
9826
- _optionalChain([context, 'access', _211 => _211.yjsProvider, 'optionalAccess', _212 => _212.off, 'call', _213 => _213("status", yjsStatusDidChange)]);
9845
+ _optionalChain([context, 'access', _215 => _215.yjsProvider, 'optionalAccess', _216 => _216.off, 'call', _217 => _217("status", yjsStatusDidChange)]);
9827
9846
  syncSourceForStorage.destroy();
9828
9847
  syncSourceForYjs.destroy();
9829
9848
  uninstallBgTabSpy();
@@ -9973,7 +9992,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
9973
9992
  }
9974
9993
  if (isLiveNode(first)) {
9975
9994
  const node = first;
9976
- if (_optionalChain([options, 'optionalAccess', _214 => _214.isDeep])) {
9995
+ if (_optionalChain([options, 'optionalAccess', _218 => _218.isDeep])) {
9977
9996
  const storageCallback = second;
9978
9997
  return subscribeToLiveStructureDeeply(node, storageCallback);
9979
9998
  } else {
@@ -10053,8 +10072,8 @@ function createClient(options) {
10053
10072
  const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
10054
10073
  currentUserId.set(() => userId);
10055
10074
  });
10056
- const fetchPolyfill = _optionalChain([clientOptions, 'access', _215 => _215.polyfills, 'optionalAccess', _216 => _216.fetch]) || /* istanbul ignore next */
10057
- _optionalChain([globalThis, 'access', _217 => _217.fetch, 'optionalAccess', _218 => _218.bind, 'call', _219 => _219(globalThis)]);
10075
+ const fetchPolyfill = _optionalChain([clientOptions, 'access', _219 => _219.polyfills, 'optionalAccess', _220 => _220.fetch]) || /* istanbul ignore next */
10076
+ _optionalChain([globalThis, 'access', _221 => _221.fetch, 'optionalAccess', _222 => _222.bind, 'call', _223 => _223(globalThis)]);
10058
10077
  const httpClient = createApiClient({
10059
10078
  baseUrl,
10060
10079
  fetchPolyfill,
@@ -10072,7 +10091,7 @@ function createClient(options) {
10072
10091
  delegates: {
10073
10092
  createSocket: makeCreateSocketDelegateForAi(
10074
10093
  baseUrl,
10075
- _optionalChain([clientOptions, 'access', _220 => _220.polyfills, 'optionalAccess', _221 => _221.WebSocket])
10094
+ _optionalChain([clientOptions, 'access', _224 => _224.polyfills, 'optionalAccess', _225 => _225.WebSocket])
10076
10095
  ),
10077
10096
  authenticate: async () => {
10078
10097
  const resp = await authManager.getAuthValue({
@@ -10134,7 +10153,7 @@ function createClient(options) {
10134
10153
  createSocket: makeCreateSocketDelegateForRoom(
10135
10154
  roomId,
10136
10155
  baseUrl,
10137
- _optionalChain([clientOptions, 'access', _222 => _222.polyfills, 'optionalAccess', _223 => _223.WebSocket])
10156
+ _optionalChain([clientOptions, 'access', _226 => _226.polyfills, 'optionalAccess', _227 => _227.WebSocket])
10138
10157
  ),
10139
10158
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
10140
10159
  })),
@@ -10157,7 +10176,7 @@ function createClient(options) {
10157
10176
  const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
10158
10177
  if (shouldConnect) {
10159
10178
  if (typeof atob === "undefined") {
10160
- if (_optionalChain([clientOptions, 'access', _224 => _224.polyfills, 'optionalAccess', _225 => _225.atob]) === void 0) {
10179
+ if (_optionalChain([clientOptions, 'access', _228 => _228.polyfills, 'optionalAccess', _229 => _229.atob]) === void 0) {
10161
10180
  throw new Error(
10162
10181
  "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"
10163
10182
  );
@@ -10169,7 +10188,7 @@ function createClient(options) {
10169
10188
  return leaseRoom(newRoomDetails);
10170
10189
  }
10171
10190
  function getRoom(roomId) {
10172
- const room = _optionalChain([roomsById, 'access', _226 => _226.get, 'call', _227 => _227(roomId), 'optionalAccess', _228 => _228.room]);
10191
+ const room = _optionalChain([roomsById, 'access', _230 => _230.get, 'call', _231 => _231(roomId), 'optionalAccess', _232 => _232.room]);
10173
10192
  return room ? room : null;
10174
10193
  }
10175
10194
  function logout() {
@@ -10185,7 +10204,7 @@ function createClient(options) {
10185
10204
  const batchedResolveUsers = new Batch(
10186
10205
  async (batchedUserIds) => {
10187
10206
  const userIds = batchedUserIds.flat();
10188
- const users = await _optionalChain([resolveUsers, 'optionalCall', _229 => _229({ userIds })]);
10207
+ const users = await _optionalChain([resolveUsers, 'optionalCall', _233 => _233({ userIds })]);
10189
10208
  warnOnceIf(
10190
10209
  !resolveUsers,
10191
10210
  "Set the resolveUsers option in createClient to specify user info."
@@ -10202,7 +10221,7 @@ function createClient(options) {
10202
10221
  const batchedResolveRoomsInfo = new Batch(
10203
10222
  async (batchedRoomIds) => {
10204
10223
  const roomIds = batchedRoomIds.flat();
10205
- const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _230 => _230({ roomIds })]);
10224
+ const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _234 => _234({ roomIds })]);
10206
10225
  warnOnceIf(
10207
10226
  !resolveRoomsInfo,
10208
10227
  "Set the resolveRoomsInfo option in createClient to specify room info."
@@ -10219,7 +10238,7 @@ function createClient(options) {
10219
10238
  const batchedResolveGroupsInfo = new Batch(
10220
10239
  async (batchedGroupIds) => {
10221
10240
  const groupIds = batchedGroupIds.flat();
10222
- const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _231 => _231({ groupIds })]);
10241
+ const groupsInfo = await _optionalChain([resolveGroupsInfo, 'optionalCall', _235 => _235({ groupIds })]);
10223
10242
  warnOnceIf(
10224
10243
  !resolveGroupsInfo,
10225
10244
  "Set the resolveGroupsInfo option in createClient to specify group info."
@@ -10275,7 +10294,7 @@ function createClient(options) {
10275
10294
  }
10276
10295
  };
10277
10296
  const win = typeof window !== "undefined" ? window : void 0;
10278
- _optionalChain([win, 'optionalAccess', _232 => _232.addEventListener, 'call', _233 => _233("beforeunload", maybePreventClose)]);
10297
+ _optionalChain([win, 'optionalAccess', _236 => _236.addEventListener, 'call', _237 => _237("beforeunload", maybePreventClose)]);
10279
10298
  }
10280
10299
  async function getNotificationSettings(options2) {
10281
10300
  const plainSettings = await httpClient.getNotificationSettings(options2);
@@ -10402,7 +10421,7 @@ var commentBodyElementsTypes = {
10402
10421
  mention: "inline"
10403
10422
  };
10404
10423
  function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
10405
- if (!body || !_optionalChain([body, 'optionalAccess', _234 => _234.content])) {
10424
+ if (!body || !_optionalChain([body, 'optionalAccess', _238 => _238.content])) {
10406
10425
  return;
10407
10426
  }
10408
10427
  const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
@@ -10412,13 +10431,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
10412
10431
  for (const block of body.content) {
10413
10432
  if (type === "all" || type === "block") {
10414
10433
  if (guard(block)) {
10415
- _optionalChain([visitor, 'optionalCall', _235 => _235(block)]);
10434
+ _optionalChain([visitor, 'optionalCall', _239 => _239(block)]);
10416
10435
  }
10417
10436
  }
10418
10437
  if (type === "all" || type === "inline") {
10419
10438
  for (const inline of block.children) {
10420
10439
  if (guard(inline)) {
10421
- _optionalChain([visitor, 'optionalCall', _236 => _236(inline)]);
10440
+ _optionalChain([visitor, 'optionalCall', _240 => _240(inline)]);
10422
10441
  }
10423
10442
  }
10424
10443
  }
@@ -10588,7 +10607,7 @@ var stringifyCommentBodyPlainElements = {
10588
10607
  text: ({ element }) => element.text,
10589
10608
  link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
10590
10609
  mention: ({ element, user, group }) => {
10591
- return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _237 => _237.name]), () => ( _optionalChain([group, 'optionalAccess', _238 => _238.name]))), () => ( element.id))}`;
10610
+ return `@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _241 => _241.name]), () => ( _optionalChain([group, 'optionalAccess', _242 => _242.name]))), () => ( element.id))}`;
10592
10611
  }
10593
10612
  };
10594
10613
  var stringifyCommentBodyHtmlElements = {
@@ -10618,7 +10637,7 @@ var stringifyCommentBodyHtmlElements = {
10618
10637
  return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
10619
10638
  },
10620
10639
  mention: ({ element, user, group }) => {
10621
- return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _239 => _239.name]) ? html`${_optionalChain([user, 'optionalAccess', _240 => _240.name])}` : _optionalChain([group, 'optionalAccess', _241 => _241.name]) ? html`${_optionalChain([group, 'optionalAccess', _242 => _242.name])}` : element.id}</span>`;
10640
+ return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _243 => _243.name]) ? html`${_optionalChain([user, 'optionalAccess', _244 => _244.name])}` : _optionalChain([group, 'optionalAccess', _245 => _245.name]) ? html`${_optionalChain([group, 'optionalAccess', _246 => _246.name])}` : element.id}</span>`;
10622
10641
  }
10623
10642
  };
10624
10643
  var stringifyCommentBodyMarkdownElements = {
@@ -10648,20 +10667,20 @@ var stringifyCommentBodyMarkdownElements = {
10648
10667
  return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
10649
10668
  },
10650
10669
  mention: ({ element, user, group }) => {
10651
- return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _243 => _243.name]), () => ( _optionalChain([group, 'optionalAccess', _244 => _244.name]))), () => ( element.id))}`;
10670
+ return markdown`@${_nullishCoalesce(_nullishCoalesce(_optionalChain([user, 'optionalAccess', _247 => _247.name]), () => ( _optionalChain([group, 'optionalAccess', _248 => _248.name]))), () => ( element.id))}`;
10652
10671
  }
10653
10672
  };
10654
10673
  async function stringifyCommentBody(body, options) {
10655
- const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _245 => _245.format]), () => ( "plain"));
10656
- const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _246 => _246.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
10674
+ const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _249 => _249.format]), () => ( "plain"));
10675
+ const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _250 => _250.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
10657
10676
  const elements = {
10658
10677
  ...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
10659
- ..._optionalChain([options, 'optionalAccess', _247 => _247.elements])
10678
+ ..._optionalChain([options, 'optionalAccess', _251 => _251.elements])
10660
10679
  };
10661
10680
  const { users: resolvedUsers, groups: resolvedGroupsInfo } = await resolveMentionsInCommentBody(
10662
10681
  body,
10663
- _optionalChain([options, 'optionalAccess', _248 => _248.resolveUsers]),
10664
- _optionalChain([options, 'optionalAccess', _249 => _249.resolveGroupsInfo])
10682
+ _optionalChain([options, 'optionalAccess', _252 => _252.resolveUsers]),
10683
+ _optionalChain([options, 'optionalAccess', _253 => _253.resolveGroupsInfo])
10665
10684
  );
10666
10685
  const blocks = body.content.flatMap((block, blockIndex) => {
10667
10686
  switch (block.type) {
@@ -10948,12 +10967,12 @@ function legacy_patchImmutableNode(state, path, update) {
10948
10967
  }
10949
10968
  const newState = Object.assign({}, state);
10950
10969
  for (const key in update.updates) {
10951
- if (_optionalChain([update, 'access', _250 => _250.updates, 'access', _251 => _251[key], 'optionalAccess', _252 => _252.type]) === "update") {
10970
+ if (_optionalChain([update, 'access', _254 => _254.updates, 'access', _255 => _255[key], 'optionalAccess', _256 => _256.type]) === "update") {
10952
10971
  const val = update.node.get(key);
10953
10972
  if (val !== void 0) {
10954
10973
  newState[key] = lsonToJson(val);
10955
10974
  }
10956
- } else if (_optionalChain([update, 'access', _253 => _253.updates, 'access', _254 => _254[key], 'optionalAccess', _255 => _255.type]) === "delete") {
10975
+ } else if (_optionalChain([update, 'access', _257 => _257.updates, 'access', _258 => _258[key], 'optionalAccess', _259 => _259.type]) === "delete") {
10957
10976
  delete newState[key];
10958
10977
  }
10959
10978
  }
@@ -11014,12 +11033,12 @@ function legacy_patchImmutableNode(state, path, update) {
11014
11033
  }
11015
11034
  const newState = Object.assign({}, state);
11016
11035
  for (const key in update.updates) {
11017
- if (_optionalChain([update, 'access', _256 => _256.updates, 'access', _257 => _257[key], 'optionalAccess', _258 => _258.type]) === "update") {
11036
+ if (_optionalChain([update, 'access', _260 => _260.updates, 'access', _261 => _261[key], 'optionalAccess', _262 => _262.type]) === "update") {
11018
11037
  const value = update.node.get(key);
11019
11038
  if (value !== void 0) {
11020
11039
  newState[key] = lsonToJson(value);
11021
11040
  }
11022
- } else if (_optionalChain([update, 'access', _259 => _259.updates, 'access', _260 => _260[key], 'optionalAccess', _261 => _261.type]) === "delete") {
11041
+ } else if (_optionalChain([update, 'access', _263 => _263.updates, 'access', _264 => _264[key], 'optionalAccess', _265 => _265.type]) === "delete") {
11023
11042
  delete newState[key];
11024
11043
  }
11025
11044
  }
@@ -11099,9 +11118,9 @@ function makePoller(callback, intervalMs, options) {
11099
11118
  const startTime = performance.now();
11100
11119
  const doc = typeof document !== "undefined" ? document : void 0;
11101
11120
  const win = typeof window !== "undefined" ? window : void 0;
11102
- const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _262 => _262.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
11121
+ const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _266 => _266.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
11103
11122
  const context = {
11104
- inForeground: _optionalChain([doc, 'optionalAccess', _263 => _263.visibilityState]) !== "hidden",
11123
+ inForeground: _optionalChain([doc, 'optionalAccess', _267 => _267.visibilityState]) !== "hidden",
11105
11124
  lastSuccessfulPollAt: startTime,
11106
11125
  count: 0,
11107
11126
  backoff: 0
@@ -11182,11 +11201,11 @@ function makePoller(callback, intervalMs, options) {
11182
11201
  pollNowIfStale();
11183
11202
  }
11184
11203
  function onVisibilityChange() {
11185
- setInForeground(_optionalChain([doc, 'optionalAccess', _264 => _264.visibilityState]) !== "hidden");
11204
+ setInForeground(_optionalChain([doc, 'optionalAccess', _268 => _268.visibilityState]) !== "hidden");
11186
11205
  }
11187
- _optionalChain([doc, 'optionalAccess', _265 => _265.addEventListener, 'call', _266 => _266("visibilitychange", onVisibilityChange)]);
11188
- _optionalChain([win, 'optionalAccess', _267 => _267.addEventListener, 'call', _268 => _268("online", onVisibilityChange)]);
11189
- _optionalChain([win, 'optionalAccess', _269 => _269.addEventListener, 'call', _270 => _270("focus", pollNowIfStale)]);
11206
+ _optionalChain([doc, 'optionalAccess', _269 => _269.addEventListener, 'call', _270 => _270("visibilitychange", onVisibilityChange)]);
11207
+ _optionalChain([win, 'optionalAccess', _271 => _271.addEventListener, 'call', _272 => _272("online", onVisibilityChange)]);
11208
+ _optionalChain([win, 'optionalAccess', _273 => _273.addEventListener, 'call', _274 => _274("focus", pollNowIfStale)]);
11190
11209
  fsm.start();
11191
11210
  return {
11192
11211
  inc,