@liveblocks/core 3.5.3 → 3.5.4

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.5.3";
9
+ var PKG_VERSION = "3.5.4";
10
10
  var PKG_FORMAT = "cjs";
11
11
 
12
12
  // src/dupe-detection.ts
@@ -3987,46 +3987,23 @@ var IncrementalJsonParser = class {
3987
3987
  };
3988
3988
 
3989
3989
  // src/types/ai.ts
3990
- function replaceOrAppend(content, newItem, keyFn, now2) {
3991
- const existingIndex = findLastIndex(
3992
- content,
3993
- (item) => item.type === newItem.type && keyFn(item) === keyFn(newItem)
3994
- );
3995
- if (existingIndex > -1) {
3996
- content[existingIndex] = newItem;
3997
- } else {
3998
- closePart(content[content.length - 1], now2);
3999
- content.push(newItem);
4000
- }
4001
- }
4002
- function closePart(prevPart, endedAt) {
4003
- if (_optionalChain([prevPart, 'optionalAccess', _55 => _55.type]) === "reasoning") {
4004
- prevPart.endedAt ??= endedAt;
4005
- }
4006
- }
4007
3990
  function patchContentWithDelta(content, delta) {
4008
- if (delta === null)
4009
- return;
4010
- const now2 = (/* @__PURE__ */ new Date()).toISOString();
4011
3991
  const lastPart = content[content.length - 1];
4012
3992
  switch (delta.type) {
4013
3993
  case "text-delta":
4014
- if (_optionalChain([lastPart, 'optionalAccess', _56 => _56.type]) === "text") {
3994
+ if (_optionalChain([lastPart, 'optionalAccess', _55 => _55.type]) === "text") {
4015
3995
  lastPart.text += delta.textDelta;
4016
3996
  } else {
4017
- closePart(lastPart, now2);
4018
3997
  content.push({ type: "text", text: delta.textDelta });
4019
3998
  }
4020
3999
  break;
4021
4000
  case "reasoning-delta":
4022
- if (_optionalChain([lastPart, 'optionalAccess', _57 => _57.type]) === "reasoning") {
4001
+ if (_optionalChain([lastPart, 'optionalAccess', _56 => _56.type]) === "reasoning") {
4023
4002
  lastPart.text += delta.textDelta;
4024
4003
  } else {
4025
- closePart(lastPart, now2);
4026
4004
  content.push({
4027
4005
  type: "reasoning",
4028
- text: _nullishCoalesce(delta.textDelta, () => ( "")),
4029
- startedAt: now2
4006
+ text: _nullishCoalesce(delta.textDelta, () => ( ""))
4030
4007
  });
4031
4008
  }
4032
4009
  break;
@@ -4039,17 +4016,23 @@ function patchContentWithDelta(content, delta) {
4039
4016
  break;
4040
4017
  }
4041
4018
  case "tool-delta": {
4042
- if (_optionalChain([lastPart, 'optionalAccess', _58 => _58.type]) === "tool-invocation" && lastPart.stage === "receiving") {
4043
- _optionalChain([lastPart, 'access', _59 => _59.__appendDelta, 'optionalCall', _60 => _60(delta.delta)]);
4019
+ if (_optionalChain([lastPart, 'optionalAccess', _57 => _57.type]) === "tool-invocation" && lastPart.stage === "receiving") {
4020
+ _optionalChain([lastPart, 'access', _58 => _58.__appendDelta, 'optionalCall', _59 => _59(delta.delta)]);
4044
4021
  }
4045
4022
  break;
4046
4023
  }
4047
- case "tool-invocation":
4048
- replaceOrAppend(content, delta, (x) => x.invocationId, now2);
4049
- break;
4050
- case "retrieval":
4051
- replaceOrAppend(content, delta, (x) => x.id, now2);
4024
+ case "tool-invocation": {
4025
+ const existingIndex = findLastIndex(
4026
+ content,
4027
+ (part) => part.type === "tool-invocation" && part.invocationId === delta.invocationId
4028
+ );
4029
+ if (existingIndex > -1) {
4030
+ content[existingIndex] = delta;
4031
+ } else {
4032
+ content.push(delta);
4033
+ }
4052
4034
  break;
4035
+ }
4053
4036
  default:
4054
4037
  return assertNever(delta, "Unhandled case");
4055
4038
  }
@@ -4061,20 +4044,16 @@ function createReceivingToolInvocation(invocationId, name, partialArgsText = "")
4061
4044
  stage: "receiving",
4062
4045
  invocationId,
4063
4046
  name,
4064
- // --- Alternative implementation for FRONTEND only ------------------------
4065
4047
  get partialArgsText() {
4066
4048
  return parser.source;
4067
4049
  },
4068
- // prettier-ignore
4069
4050
  get partialArgs() {
4070
4051
  return parser.json;
4071
4052
  },
4072
- // prettier-ignore
4053
+ // Internal method to append deltas
4073
4054
  __appendDelta(delta) {
4074
4055
  parser.append(delta);
4075
4056
  }
4076
- // prettier-ignore
4077
- // ------------------------------------------------------------------------
4078
4057
  };
4079
4058
  }
4080
4059
 
@@ -4159,7 +4138,7 @@ function createStore_forTools() {
4159
4138
  return DerivedSignal.from(() => {
4160
4139
  return (
4161
4140
  // A tool that's registered and scoped to a specific chat ID...
4162
- _nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess', _61 => _61.get, 'call', _62 => _62()]), () => ( // ...or a globally registered tool
4141
+ _nullishCoalesce(_optionalChain([(chatId !== void 0 ? toolsByChatId\u03A3.getOrCreate(chatId).getOrCreate(name) : void 0), 'optionalAccess', _60 => _60.get, 'call', _61 => _61()]), () => ( // ...or a globally registered tool
4163
4142
  toolsByChatId\u03A3.getOrCreate(kWILDCARD).getOrCreate(name).get()))
4164
4143
  );
4165
4144
  });
@@ -4189,8 +4168,8 @@ function createStore_forTools() {
4189
4168
  const globalTools\u03A3 = toolsByChatId\u03A3.get(kWILDCARD);
4190
4169
  const scopedTools\u03A3 = toolsByChatId\u03A3.get(chatId);
4191
4170
  return Array.from([
4192
- ..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _63 => _63.entries, 'call', _64 => _64()]), () => ( [])),
4193
- ..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _65 => _65.entries, 'call', _66 => _66()]), () => ( []))
4171
+ ..._nullishCoalesce(_optionalChain([globalTools\u03A3, 'optionalAccess', _62 => _62.entries, 'call', _63 => _63()]), () => ( [])),
4172
+ ..._nullishCoalesce(_optionalChain([scopedTools\u03A3, 'optionalAccess', _64 => _64.entries, 'call', _65 => _65()]), () => ( []))
4194
4173
  ]).flatMap(([name, tool\u03A3]) => {
4195
4174
  const tool = tool\u03A3.get();
4196
4175
  return tool && (_nullishCoalesce(tool.enabled, () => ( true))) ? [{ name, description: tool.description, parameters: tool.parameters }] : [];
@@ -4293,7 +4272,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
4293
4272
  } else {
4294
4273
  continue;
4295
4274
  }
4296
- const executeFn = _optionalChain([toolsStore, 'access', _67 => _67.getTool\u03A3, 'call', _68 => _68(toolInvocation.name, message.chatId), 'access', _69 => _69.get, 'call', _70 => _70(), 'optionalAccess', _71 => _71.execute]);
4275
+ const executeFn = _optionalChain([toolsStore, 'access', _66 => _66.getTool\u03A3, 'call', _67 => _67(toolInvocation.name, message.chatId), 'access', _68 => _68.get, 'call', _69 => _69(), 'optionalAccess', _70 => _70.execute]);
4297
4276
  if (executeFn) {
4298
4277
  (async () => {
4299
4278
  const result = await executeFn(toolInvocation.args, {
@@ -4392,8 +4371,8 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
4392
4371
  const spine = [];
4393
4372
  let lastVisitedMessage = null;
4394
4373
  for (const message2 of pool.walkUp(leaf.id)) {
4395
- const prev = _nullishCoalesce(_optionalChain([first, 'call', _72 => _72(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _73 => _73.id]), () => ( null));
4396
- const next = _nullishCoalesce(_optionalChain([first, 'call', _74 => _74(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _75 => _75.id]), () => ( null));
4374
+ const prev = _nullishCoalesce(_optionalChain([first, 'call', _71 => _71(pool.walkLeft(message2.id, isAlive)), 'optionalAccess', _72 => _72.id]), () => ( null));
4375
+ const next = _nullishCoalesce(_optionalChain([first, 'call', _73 => _73(pool.walkRight(message2.id, isAlive)), 'optionalAccess', _74 => _74.id]), () => ( null));
4397
4376
  if (!message2.deletedAt || prev || next) {
4398
4377
  const node = {
4399
4378
  ...message2,
@@ -4459,7 +4438,7 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
4459
4438
  const latest = pool.sorted.findRight(
4460
4439
  (m) => m.role === "assistant" && !m.deletedAt
4461
4440
  );
4462
- return _optionalChain([latest, 'optionalAccess', _76 => _76.copilotId]);
4441
+ return _optionalChain([latest, 'optionalAccess', _75 => _75.copilotId]);
4463
4442
  }
4464
4443
  return {
4465
4444
  // Readers
@@ -4476,33 +4455,6 @@ function createStore_forChatMessages(toolsStore, setToolResultFn) {
4476
4455
  failAllPending,
4477
4456
  markMine(messageId) {
4478
4457
  myMessages.add(messageId);
4479
- },
4480
- /**
4481
- * Iterates over all my auto-executing messages.
4482
- *
4483
- * These are messages that match all these conditions:
4484
- * - The message is an assistant message
4485
- * - The message is owned by this client ("mine")
4486
- * - The message is currently in "awaiting-tool" status
4487
- * - The message has at least one tool invocation in "executing" stage
4488
- * - The tool invocation has an execute() function defined
4489
- */
4490
- *getAutoExecutingMessageIds() {
4491
- for (const messageId of myMessages) {
4492
- const message = getMessageById(messageId);
4493
- if (_optionalChain([message, 'optionalAccess', _77 => _77.role]) === "assistant" && message.status === "awaiting-tool") {
4494
- const isAutoExecuting = message.contentSoFar.some((part) => {
4495
- if (part.type === "tool-invocation" && part.stage === "executing") {
4496
- const tool = toolsStore.getTool\u03A3(part.name, message.chatId).get();
4497
- return typeof _optionalChain([tool, 'optionalAccess', _78 => _78.execute]) === "function";
4498
- }
4499
- return false;
4500
- });
4501
- if (isAutoExecuting) {
4502
- yield message.id;
4503
- }
4504
- }
4505
- }
4506
4458
  }
4507
4459
  };
4508
4460
  }
@@ -4639,7 +4591,7 @@ function createAi(config) {
4639
4591
  flushPendingDeltas();
4640
4592
  switch (msg.event) {
4641
4593
  case "cmd-failed":
4642
- _optionalChain([pendingCmd, 'optionalAccess', _79 => _79.reject, 'call', _80 => _80(new Error(msg.error))]);
4594
+ _optionalChain([pendingCmd, 'optionalAccess', _76 => _76.reject, 'call', _77 => _77(new Error(msg.error))]);
4643
4595
  break;
4644
4596
  case "settle": {
4645
4597
  context.messagesStore.upsert(msg.message);
@@ -4716,7 +4668,7 @@ function createAi(config) {
4716
4668
  return assertNever(msg, "Unhandled case");
4717
4669
  }
4718
4670
  }
4719
- _optionalChain([pendingCmd, 'optionalAccess', _81 => _81.resolve, 'call', _82 => _82(msg)]);
4671
+ _optionalChain([pendingCmd, 'optionalAccess', _78 => _78.resolve, 'call', _79 => _79(msg)]);
4720
4672
  }
4721
4673
  managedSocket.events.onMessage.subscribe(handleServerMessage);
4722
4674
  managedSocket.events.statusDidChange.subscribe(onStatusDidChange);
@@ -4801,9 +4753,9 @@ function createAi(config) {
4801
4753
  invocationId,
4802
4754
  result,
4803
4755
  generationOptions: {
4804
- copilotId: _optionalChain([options, 'optionalAccess', _83 => _83.copilotId]),
4805
- stream: _optionalChain([options, 'optionalAccess', _84 => _84.stream]),
4806
- timeout: _optionalChain([options, 'optionalAccess', _85 => _85.timeout]),
4756
+ copilotId: _optionalChain([options, 'optionalAccess', _80 => _80.copilotId]),
4757
+ stream: _optionalChain([options, 'optionalAccess', _81 => _81.stream]),
4758
+ timeout: _optionalChain([options, 'optionalAccess', _82 => _82.timeout]),
4807
4759
  // Knowledge and tools aren't coming from the options, but retrieved
4808
4760
  // from the global context
4809
4761
  knowledge: knowledge.length > 0 ? knowledge : void 0,
@@ -4814,14 +4766,6 @@ function createAi(config) {
4814
4766
  messagesStore.markMine(resp.message.id);
4815
4767
  }
4816
4768
  }
4817
- function handleBeforeUnload() {
4818
- for (const messageId of context.messagesStore.getAutoExecutingMessageIds()) {
4819
- sendClientMsgWithResponse({ cmd: "abort-ai", messageId }).catch(() => {
4820
- });
4821
- }
4822
- }
4823
- const win = typeof window !== "undefined" ? window : void 0;
4824
- _optionalChain([win, 'optionalAccess', _86 => _86.addEventListener, 'call', _87 => _87("beforeunload", handleBeforeUnload, { once: true })]);
4825
4769
  return Object.defineProperty(
4826
4770
  {
4827
4771
  [kInternal]: {
@@ -4840,7 +4784,7 @@ function createAi(config) {
4840
4784
  clearChat: (chatId) => sendClientMsgWithResponse({ cmd: "clear-chat", chatId }),
4841
4785
  askUserMessageInChat: async (chatId, userMessage, targetMessageId, options) => {
4842
4786
  const globalKnowledge = context.knowledge.get();
4843
- const requestKnowledge = _optionalChain([options, 'optionalAccess', _88 => _88.knowledge]) || [];
4787
+ const requestKnowledge = _optionalChain([options, 'optionalAccess', _83 => _83.knowledge]) || [];
4844
4788
  const combinedKnowledge = [...globalKnowledge, ...requestKnowledge];
4845
4789
  const tools = context.toolsStore.getToolDescriptions(chatId);
4846
4790
  messagesStore.markMine(targetMessageId);
@@ -4850,9 +4794,9 @@ function createAi(config) {
4850
4794
  sourceMessage: userMessage,
4851
4795
  targetMessageId,
4852
4796
  generationOptions: {
4853
- copilotId: _optionalChain([options, 'optionalAccess', _89 => _89.copilotId]),
4854
- stream: _optionalChain([options, 'optionalAccess', _90 => _90.stream]),
4855
- timeout: _optionalChain([options, 'optionalAccess', _91 => _91.timeout]),
4797
+ copilotId: _optionalChain([options, 'optionalAccess', _84 => _84.copilotId]),
4798
+ stream: _optionalChain([options, 'optionalAccess', _85 => _85.stream]),
4799
+ timeout: _optionalChain([options, 'optionalAccess', _86 => _86.timeout]),
4856
4800
  // Combine global knowledge with request-specific knowledge
4857
4801
  knowledge: combinedKnowledge.length > 0 ? combinedKnowledge : void 0,
4858
4802
  tools: tools.length > 0 ? tools : void 0
@@ -4889,7 +4833,7 @@ function makeCreateSocketDelegateForAi(baseUrl, WebSocketPolyfill) {
4889
4833
  }
4890
4834
  const url2 = new URL(baseUrl);
4891
4835
  url2.protocol = url2.protocol === "http:" ? "ws" : "wss";
4892
- url2.pathname = "/ai/v6";
4836
+ url2.pathname = "/ai/v5";
4893
4837
  if (authValue.type === "secret") {
4894
4838
  url2.searchParams.set("tok", authValue.token.raw);
4895
4839
  } else if (authValue.type === "public") {
@@ -4953,7 +4897,7 @@ function createAuthManager(authOptions, onAuthenticate) {
4953
4897
  return void 0;
4954
4898
  }
4955
4899
  async function makeAuthRequest(options) {
4956
- const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _92 => _92.polyfills, 'optionalAccess', _93 => _93.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
4900
+ const fetcher = _nullishCoalesce(_optionalChain([authOptions, 'access', _87 => _87.polyfills, 'optionalAccess', _88 => _88.fetch]), () => ( (typeof window === "undefined" ? void 0 : window.fetch)));
4957
4901
  if (authentication.type === "private") {
4958
4902
  if (fetcher === void 0) {
4959
4903
  throw new StopRetrying(
@@ -4969,7 +4913,7 @@ function createAuthManager(authOptions, onAuthenticate) {
4969
4913
  "The same Liveblocks auth token was issued from the backend before. Caching Liveblocks tokens is not supported."
4970
4914
  );
4971
4915
  }
4972
- _optionalChain([onAuthenticate, 'optionalCall', _94 => _94(parsed.parsed)]);
4916
+ _optionalChain([onAuthenticate, 'optionalCall', _89 => _89(parsed.parsed)]);
4973
4917
  return parsed;
4974
4918
  }
4975
4919
  if (authentication.type === "custom") {
@@ -4977,7 +4921,7 @@ function createAuthManager(authOptions, onAuthenticate) {
4977
4921
  if (response && typeof response === "object") {
4978
4922
  if (typeof response.token === "string") {
4979
4923
  const parsed = parseAuthToken(response.token);
4980
- _optionalChain([onAuthenticate, 'optionalCall', _95 => _95(parsed.parsed)]);
4924
+ _optionalChain([onAuthenticate, 'optionalCall', _90 => _90(parsed.parsed)]);
4981
4925
  return parsed;
4982
4926
  } else if (typeof response.error === "string") {
4983
4927
  const reason = `Authentication failed: ${"reason" in response && typeof response.reason === "string" ? response.reason : "Forbidden"}`;
@@ -5135,7 +5079,7 @@ function sendToPanel(message, options) {
5135
5079
  ...message,
5136
5080
  source: "liveblocks-devtools-client"
5137
5081
  };
5138
- if (!(_optionalChain([options, 'optionalAccess', _96 => _96.force]) || _bridgeActive)) {
5082
+ if (!(_optionalChain([options, 'optionalAccess', _91 => _91.force]) || _bridgeActive)) {
5139
5083
  return;
5140
5084
  }
5141
5085
  window.postMessage(fullMsg, "*");
@@ -5143,7 +5087,7 @@ function sendToPanel(message, options) {
5143
5087
  var eventSource = makeEventSource();
5144
5088
  if (process.env.NODE_ENV !== "production" && typeof window !== "undefined") {
5145
5089
  window.addEventListener("message", (event) => {
5146
- if (event.source === window && _optionalChain([event, 'access', _97 => _97.data, 'optionalAccess', _98 => _98.source]) === "liveblocks-devtools-panel") {
5090
+ if (event.source === window && _optionalChain([event, 'access', _92 => _92.data, 'optionalAccess', _93 => _93.source]) === "liveblocks-devtools-panel") {
5147
5091
  eventSource.notify(event.data);
5148
5092
  } else {
5149
5093
  }
@@ -5285,7 +5229,7 @@ function fullSync(room) {
5285
5229
  msg: "room::sync::full",
5286
5230
  roomId: room.id,
5287
5231
  status: room.getStatus(),
5288
- storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _99 => _99.toTreeNode, 'call', _100 => _100("root"), 'access', _101 => _101.payload]), () => ( null)),
5232
+ storage: _nullishCoalesce(_optionalChain([root, 'optionalAccess', _94 => _94.toTreeNode, 'call', _95 => _95("root"), 'access', _96 => _96.payload]), () => ( null)),
5289
5233
  me,
5290
5234
  others
5291
5235
  });
@@ -5576,7 +5520,7 @@ function createManagedPool(roomId, options) {
5576
5520
  generateId: () => `${getCurrentConnectionId()}:${clock++}`,
5577
5521
  generateOpId: () => `${getCurrentConnectionId()}:${opClock++}`,
5578
5522
  dispatch(ops, reverse, storageUpdates) {
5579
- _optionalChain([onDispatch, 'optionalCall', _102 => _102(ops, reverse, storageUpdates)]);
5523
+ _optionalChain([onDispatch, 'optionalCall', _97 => _97(ops, reverse, storageUpdates)]);
5580
5524
  },
5581
5525
  assertStorageIsWritable: () => {
5582
5526
  if (!isStorageWritable()) {
@@ -5803,7 +5747,7 @@ var LiveRegister = class _LiveRegister extends AbstractCrdt {
5803
5747
  return [
5804
5748
  {
5805
5749
  type: 8 /* CREATE_REGISTER */,
5806
- opId: _optionalChain([pool, 'optionalAccess', _103 => _103.generateOpId, 'call', _104 => _104()]),
5750
+ opId: _optionalChain([pool, 'optionalAccess', _98 => _98.generateOpId, 'call', _99 => _99()]),
5807
5751
  id: this._id,
5808
5752
  parentId,
5809
5753
  parentKey,
@@ -5909,7 +5853,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
5909
5853
  const ops = [];
5910
5854
  const op = {
5911
5855
  id: this._id,
5912
- opId: _optionalChain([pool, 'optionalAccess', _105 => _105.generateOpId, 'call', _106 => _106()]),
5856
+ opId: _optionalChain([pool, 'optionalAccess', _100 => _100.generateOpId, 'call', _101 => _101()]),
5913
5857
  type: 2 /* CREATE_LIST */,
5914
5858
  parentId,
5915
5859
  parentKey
@@ -6180,7 +6124,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6180
6124
  #applyInsertUndoRedo(op) {
6181
6125
  const { id, parentKey: key } = op;
6182
6126
  const child = creationOpToLiveNode(op);
6183
- if (_optionalChain([this, 'access', _107 => _107._pool, 'optionalAccess', _108 => _108.getNode, 'call', _109 => _109(id)]) !== void 0) {
6127
+ if (_optionalChain([this, 'access', _102 => _102._pool, 'optionalAccess', _103 => _103.getNode, 'call', _104 => _104(id)]) !== void 0) {
6184
6128
  return { modified: false };
6185
6129
  }
6186
6130
  child._attach(id, nn(this._pool));
@@ -6188,8 +6132,8 @@ var LiveList = class _LiveList extends AbstractCrdt {
6188
6132
  const existingItemIndex = this._indexOfPosition(key);
6189
6133
  let newKey = key;
6190
6134
  if (existingItemIndex !== -1) {
6191
- const before2 = _optionalChain([this, 'access', _110 => _110.#items, 'access', _111 => _111[existingItemIndex], 'optionalAccess', _112 => _112._parentPos]);
6192
- const after2 = _optionalChain([this, 'access', _113 => _113.#items, 'access', _114 => _114[existingItemIndex + 1], 'optionalAccess', _115 => _115._parentPos]);
6135
+ const before2 = _optionalChain([this, 'access', _105 => _105.#items, 'access', _106 => _106[existingItemIndex], 'optionalAccess', _107 => _107._parentPos]);
6136
+ const after2 = _optionalChain([this, 'access', _108 => _108.#items, 'access', _109 => _109[existingItemIndex + 1], 'optionalAccess', _110 => _110._parentPos]);
6193
6137
  newKey = makePosition(before2, after2);
6194
6138
  child._setParentLink(this, newKey);
6195
6139
  }
@@ -6203,7 +6147,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6203
6147
  #applySetUndoRedo(op) {
6204
6148
  const { id, parentKey: key } = op;
6205
6149
  const child = creationOpToLiveNode(op);
6206
- if (_optionalChain([this, 'access', _116 => _116._pool, 'optionalAccess', _117 => _117.getNode, 'call', _118 => _118(id)]) !== void 0) {
6150
+ if (_optionalChain([this, 'access', _111 => _111._pool, 'optionalAccess', _112 => _112.getNode, 'call', _113 => _113(id)]) !== void 0) {
6207
6151
  return { modified: false };
6208
6152
  }
6209
6153
  this.#unacknowledgedSets.set(key, nn(op.opId));
@@ -6324,7 +6268,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6324
6268
  } else {
6325
6269
  this.#items[existingItemIndex]._setParentLink(
6326
6270
  this,
6327
- makePosition(newKey, _optionalChain([this, 'access', _119 => _119.#items, 'access', _120 => _120[existingItemIndex + 1], 'optionalAccess', _121 => _121._parentPos]))
6271
+ makePosition(newKey, _optionalChain([this, 'access', _114 => _114.#items, 'access', _115 => _115[existingItemIndex + 1], 'optionalAccess', _116 => _116._parentPos]))
6328
6272
  );
6329
6273
  const previousIndex = this.#items.indexOf(child);
6330
6274
  child._setParentLink(this, newKey);
@@ -6349,7 +6293,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6349
6293
  if (existingItemIndex !== -1) {
6350
6294
  this.#items[existingItemIndex]._setParentLink(
6351
6295
  this,
6352
- makePosition(newKey, _optionalChain([this, 'access', _122 => _122.#items, 'access', _123 => _123[existingItemIndex + 1], 'optionalAccess', _124 => _124._parentPos]))
6296
+ makePosition(newKey, _optionalChain([this, 'access', _117 => _117.#items, 'access', _118 => _118[existingItemIndex + 1], 'optionalAccess', _119 => _119._parentPos]))
6353
6297
  );
6354
6298
  }
6355
6299
  child._setParentLink(this, newKey);
@@ -6368,7 +6312,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6368
6312
  if (existingItemIndex !== -1) {
6369
6313
  this.#items[existingItemIndex]._setParentLink(
6370
6314
  this,
6371
- makePosition(newKey, _optionalChain([this, 'access', _125 => _125.#items, 'access', _126 => _126[existingItemIndex + 1], 'optionalAccess', _127 => _127._parentPos]))
6315
+ makePosition(newKey, _optionalChain([this, 'access', _120 => _120.#items, 'access', _121 => _121[existingItemIndex + 1], 'optionalAccess', _122 => _122._parentPos]))
6372
6316
  );
6373
6317
  }
6374
6318
  child._setParentLink(this, newKey);
@@ -6395,7 +6339,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6395
6339
  if (existingItemIndex !== -1) {
6396
6340
  this.#items[existingItemIndex]._setParentLink(
6397
6341
  this,
6398
- makePosition(newKey, _optionalChain([this, 'access', _128 => _128.#items, 'access', _129 => _129[existingItemIndex + 1], 'optionalAccess', _130 => _130._parentPos]))
6342
+ makePosition(newKey, _optionalChain([this, 'access', _123 => _123.#items, 'access', _124 => _124[existingItemIndex + 1], 'optionalAccess', _125 => _125._parentPos]))
6399
6343
  );
6400
6344
  }
6401
6345
  child._setParentLink(this, newKey);
@@ -6453,7 +6397,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6453
6397
  * @param element The element to add to the end of the LiveList.
6454
6398
  */
6455
6399
  push(element) {
6456
- _optionalChain([this, 'access', _131 => _131._pool, 'optionalAccess', _132 => _132.assertStorageIsWritable, 'call', _133 => _133()]);
6400
+ _optionalChain([this, 'access', _126 => _126._pool, 'optionalAccess', _127 => _127.assertStorageIsWritable, 'call', _128 => _128()]);
6457
6401
  return this.insert(element, this.length);
6458
6402
  }
6459
6403
  /**
@@ -6462,7 +6406,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6462
6406
  * @param index The index at which you want to insert the element.
6463
6407
  */
6464
6408
  insert(element, index) {
6465
- _optionalChain([this, 'access', _134 => _134._pool, 'optionalAccess', _135 => _135.assertStorageIsWritable, 'call', _136 => _136()]);
6409
+ _optionalChain([this, 'access', _129 => _129._pool, 'optionalAccess', _130 => _130.assertStorageIsWritable, 'call', _131 => _131()]);
6466
6410
  if (index < 0 || index > this.#items.length) {
6467
6411
  throw new Error(
6468
6412
  `Cannot insert list item at index "${index}". index should be between 0 and ${this.#items.length}`
@@ -6492,7 +6436,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6492
6436
  * @param targetIndex The index where the element should be after moving.
6493
6437
  */
6494
6438
  move(index, targetIndex) {
6495
- _optionalChain([this, 'access', _137 => _137._pool, 'optionalAccess', _138 => _138.assertStorageIsWritable, 'call', _139 => _139()]);
6439
+ _optionalChain([this, 'access', _132 => _132._pool, 'optionalAccess', _133 => _133.assertStorageIsWritable, 'call', _134 => _134()]);
6496
6440
  if (targetIndex < 0) {
6497
6441
  throw new Error("targetIndex cannot be less than 0");
6498
6442
  }
@@ -6550,7 +6494,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6550
6494
  * @param index The index of the element to delete
6551
6495
  */
6552
6496
  delete(index) {
6553
- _optionalChain([this, 'access', _140 => _140._pool, 'optionalAccess', _141 => _141.assertStorageIsWritable, 'call', _142 => _142()]);
6497
+ _optionalChain([this, 'access', _135 => _135._pool, 'optionalAccess', _136 => _136.assertStorageIsWritable, 'call', _137 => _137()]);
6554
6498
  if (index < 0 || index >= this.#items.length) {
6555
6499
  throw new Error(
6556
6500
  `Cannot delete list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -6583,7 +6527,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6583
6527
  }
6584
6528
  }
6585
6529
  clear() {
6586
- _optionalChain([this, 'access', _143 => _143._pool, 'optionalAccess', _144 => _144.assertStorageIsWritable, 'call', _145 => _145()]);
6530
+ _optionalChain([this, 'access', _138 => _138._pool, 'optionalAccess', _139 => _139.assertStorageIsWritable, 'call', _140 => _140()]);
6587
6531
  if (this._pool) {
6588
6532
  const ops = [];
6589
6533
  const reverseOps = [];
@@ -6617,7 +6561,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6617
6561
  }
6618
6562
  }
6619
6563
  set(index, item) {
6620
- _optionalChain([this, 'access', _146 => _146._pool, 'optionalAccess', _147 => _147.assertStorageIsWritable, 'call', _148 => _148()]);
6564
+ _optionalChain([this, 'access', _141 => _141._pool, 'optionalAccess', _142 => _142.assertStorageIsWritable, 'call', _143 => _143()]);
6621
6565
  if (index < 0 || index >= this.#items.length) {
6622
6566
  throw new Error(
6623
6567
  `Cannot set list item at index "${index}". index should be between 0 and ${this.#items.length - 1}`
@@ -6763,7 +6707,7 @@ var LiveList = class _LiveList extends AbstractCrdt {
6763
6707
  #shiftItemPosition(index, key) {
6764
6708
  const shiftedPosition = makePosition(
6765
6709
  key,
6766
- this.#items.length > index + 1 ? _optionalChain([this, 'access', _149 => _149.#items, 'access', _150 => _150[index + 1], 'optionalAccess', _151 => _151._parentPos]) : void 0
6710
+ this.#items.length > index + 1 ? _optionalChain([this, 'access', _144 => _144.#items, 'access', _145 => _145[index + 1], 'optionalAccess', _146 => _146._parentPos]) : void 0
6767
6711
  );
6768
6712
  this.#items[index]._setParentLink(this, shiftedPosition);
6769
6713
  }
@@ -6888,7 +6832,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
6888
6832
  const ops = [];
6889
6833
  const op = {
6890
6834
  id: this._id,
6891
- opId: _optionalChain([pool, 'optionalAccess', _152 => _152.generateOpId, 'call', _153 => _153()]),
6835
+ opId: _optionalChain([pool, 'optionalAccess', _147 => _147.generateOpId, 'call', _148 => _148()]),
6892
6836
  type: 7 /* CREATE_MAP */,
6893
6837
  parentId,
6894
6838
  parentKey
@@ -7023,7 +6967,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
7023
6967
  * @param value The value of the element to add. Should be serializable to JSON.
7024
6968
  */
7025
6969
  set(key, value) {
7026
- _optionalChain([this, 'access', _154 => _154._pool, 'optionalAccess', _155 => _155.assertStorageIsWritable, 'call', _156 => _156()]);
6970
+ _optionalChain([this, 'access', _149 => _149._pool, 'optionalAccess', _150 => _150.assertStorageIsWritable, 'call', _151 => _151()]);
7027
6971
  const oldValue = this.#map.get(key);
7028
6972
  if (oldValue) {
7029
6973
  oldValue._detach();
@@ -7069,7 +7013,7 @@ var LiveMap = class _LiveMap extends AbstractCrdt {
7069
7013
  * @returns true if an element existed and has been removed, or false if the element does not exist.
7070
7014
  */
7071
7015
  delete(key) {
7072
- _optionalChain([this, 'access', _157 => _157._pool, 'optionalAccess', _158 => _158.assertStorageIsWritable, 'call', _159 => _159()]);
7016
+ _optionalChain([this, 'access', _152 => _152._pool, 'optionalAccess', _153 => _153.assertStorageIsWritable, 'call', _154 => _154()]);
7073
7017
  const item = this.#map.get(key);
7074
7018
  if (item === void 0) {
7075
7019
  return false;
@@ -7259,7 +7203,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7259
7203
  if (this._id === void 0) {
7260
7204
  throw new Error("Cannot serialize item is not attached");
7261
7205
  }
7262
- const opId = _optionalChain([pool, 'optionalAccess', _160 => _160.generateOpId, 'call', _161 => _161()]);
7206
+ const opId = _optionalChain([pool, 'optionalAccess', _155 => _155.generateOpId, 'call', _156 => _156()]);
7263
7207
  const ops = [];
7264
7208
  const op = {
7265
7209
  type: 4 /* CREATE_OBJECT */,
@@ -7531,7 +7475,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7531
7475
  * @param value The value of the property to add
7532
7476
  */
7533
7477
  set(key, value) {
7534
- _optionalChain([this, 'access', _162 => _162._pool, 'optionalAccess', _163 => _163.assertStorageIsWritable, 'call', _164 => _164()]);
7478
+ _optionalChain([this, 'access', _157 => _157._pool, 'optionalAccess', _158 => _158.assertStorageIsWritable, 'call', _159 => _159()]);
7535
7479
  this.update({ [key]: value });
7536
7480
  }
7537
7481
  /**
@@ -7546,7 +7490,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7546
7490
  * @param key The key of the property to delete
7547
7491
  */
7548
7492
  delete(key) {
7549
- _optionalChain([this, 'access', _165 => _165._pool, 'optionalAccess', _166 => _166.assertStorageIsWritable, 'call', _167 => _167()]);
7493
+ _optionalChain([this, 'access', _160 => _160._pool, 'optionalAccess', _161 => _161.assertStorageIsWritable, 'call', _162 => _162()]);
7550
7494
  const keyAsString = key;
7551
7495
  const oldValue = this.#map.get(keyAsString);
7552
7496
  if (oldValue === void 0) {
@@ -7599,7 +7543,7 @@ var LiveObject = (_class2 = class _LiveObject extends AbstractCrdt {
7599
7543
  * @param patch The object used to overrides properties
7600
7544
  */
7601
7545
  update(patch) {
7602
- _optionalChain([this, 'access', _168 => _168._pool, 'optionalAccess', _169 => _169.assertStorageIsWritable, 'call', _170 => _170()]);
7546
+ _optionalChain([this, 'access', _163 => _163._pool, 'optionalAccess', _164 => _164.assertStorageIsWritable, 'call', _165 => _165()]);
7603
7547
  if (_LiveObject.detectLargeObjects) {
7604
7548
  const data = {};
7605
7549
  for (const [key, value] of this.#map) {
@@ -8347,15 +8291,15 @@ function installBackgroundTabSpy() {
8347
8291
  const doc = typeof document !== "undefined" ? document : void 0;
8348
8292
  const inBackgroundSince = { current: null };
8349
8293
  function onVisibilityChange() {
8350
- if (_optionalChain([doc, 'optionalAccess', _171 => _171.visibilityState]) === "hidden") {
8294
+ if (_optionalChain([doc, 'optionalAccess', _166 => _166.visibilityState]) === "hidden") {
8351
8295
  inBackgroundSince.current = _nullishCoalesce(inBackgroundSince.current, () => ( Date.now()));
8352
8296
  } else {
8353
8297
  inBackgroundSince.current = null;
8354
8298
  }
8355
8299
  }
8356
- _optionalChain([doc, 'optionalAccess', _172 => _172.addEventListener, 'call', _173 => _173("visibilitychange", onVisibilityChange)]);
8300
+ _optionalChain([doc, 'optionalAccess', _167 => _167.addEventListener, 'call', _168 => _168("visibilitychange", onVisibilityChange)]);
8357
8301
  const unsub = () => {
8358
- _optionalChain([doc, 'optionalAccess', _174 => _174.removeEventListener, 'call', _175 => _175("visibilitychange", onVisibilityChange)]);
8302
+ _optionalChain([doc, 'optionalAccess', _169 => _169.removeEventListener, 'call', _170 => _170("visibilitychange", onVisibilityChange)]);
8359
8303
  };
8360
8304
  return [inBackgroundSince, unsub];
8361
8305
  }
@@ -8535,7 +8479,7 @@ function createRoom(options, config) {
8535
8479
  }
8536
8480
  }
8537
8481
  function isStorageWritable() {
8538
- const scopes = _optionalChain([context, 'access', _176 => _176.dynamicSessionInfoSig, 'access', _177 => _177.get, 'call', _178 => _178(), 'optionalAccess', _179 => _179.scopes]);
8482
+ const scopes = _optionalChain([context, 'access', _171 => _171.dynamicSessionInfoSig, 'access', _172 => _172.get, 'call', _173 => _173(), 'optionalAccess', _174 => _174.scopes]);
8539
8483
  return scopes !== void 0 ? canWriteStorage(scopes) : true;
8540
8484
  }
8541
8485
  const eventHub = {
@@ -8661,7 +8605,7 @@ function createRoom(options, config) {
8661
8605
  }
8662
8606
  case "experimental-fallback-to-http": {
8663
8607
  warn("Message is too large for websockets, so sending over HTTP instead");
8664
- const nonce = _nullishCoalesce(_optionalChain([context, 'access', _180 => _180.dynamicSessionInfoSig, 'access', _181 => _181.get, 'call', _182 => _182(), 'optionalAccess', _183 => _183.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
8608
+ const nonce = _nullishCoalesce(_optionalChain([context, 'access', _175 => _175.dynamicSessionInfoSig, 'access', _176 => _176.get, 'call', _177 => _177(), 'optionalAccess', _178 => _178.nonce]), () => ( raise("Session is not authorized to send message over HTTP")));
8665
8609
  void httpClient.sendMessages({ roomId, nonce, messages }).then((resp) => {
8666
8610
  if (!resp.ok && resp.status === 403) {
8667
8611
  managedSocket.reconnect();
@@ -8712,7 +8656,7 @@ function createRoom(options, config) {
8712
8656
  } else {
8713
8657
  context.root = LiveObject._fromItems(message.items, context.pool);
8714
8658
  }
8715
- const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _184 => _184.get, 'call', _185 => _185(), 'optionalAccess', _186 => _186.canWrite]), () => ( true));
8659
+ const canWrite = _nullishCoalesce(_optionalChain([self, 'access', _179 => _179.get, 'call', _180 => _180(), 'optionalAccess', _181 => _181.canWrite]), () => ( true));
8716
8660
  const stackSizeBefore = context.undoStack.length;
8717
8661
  for (const key in context.initialStorage) {
8718
8662
  if (context.root.get(key) === void 0) {
@@ -8915,7 +8859,7 @@ function createRoom(options, config) {
8915
8859
  }
8916
8860
  context.myPresence.patch(patch);
8917
8861
  if (context.activeBatch) {
8918
- if (_optionalChain([options2, 'optionalAccess', _187 => _187.addToHistory])) {
8862
+ if (_optionalChain([options2, 'optionalAccess', _182 => _182.addToHistory])) {
8919
8863
  context.activeBatch.reverseOps.pushLeft({
8920
8864
  type: "presence",
8921
8865
  data: oldValues
@@ -8924,7 +8868,7 @@ function createRoom(options, config) {
8924
8868
  context.activeBatch.updates.presence = true;
8925
8869
  } else {
8926
8870
  flushNowOrSoon();
8927
- if (_optionalChain([options2, 'optionalAccess', _188 => _188.addToHistory])) {
8871
+ if (_optionalChain([options2, 'optionalAccess', _183 => _183.addToHistory])) {
8928
8872
  addToUndoStack([{ type: "presence", data: oldValues }]);
8929
8873
  }
8930
8874
  notify({ presence: true });
@@ -9121,7 +9065,7 @@ function createRoom(options, config) {
9121
9065
  if (process.env.NODE_ENV !== "production") {
9122
9066
  const traces = /* @__PURE__ */ new Set();
9123
9067
  for (const opId of message.opIds) {
9124
- const trace = _optionalChain([context, 'access', _189 => _189.opStackTraces, 'optionalAccess', _190 => _190.get, 'call', _191 => _191(opId)]);
9068
+ const trace = _optionalChain([context, 'access', _184 => _184.opStackTraces, 'optionalAccess', _185 => _185.get, 'call', _186 => _186(opId)]);
9125
9069
  if (trace) {
9126
9070
  traces.add(trace);
9127
9071
  }
@@ -9255,7 +9199,7 @@ ${Array.from(traces).join("\n\n")}`
9255
9199
  const unacknowledgedOps = new Map(context.unacknowledgedOps);
9256
9200
  createOrUpdateRootFromMessage(message);
9257
9201
  applyAndSendOps(unacknowledgedOps);
9258
- _optionalChain([_resolveStoragePromise, 'optionalCall', _192 => _192()]);
9202
+ _optionalChain([_resolveStoragePromise, 'optionalCall', _187 => _187()]);
9259
9203
  notifyStorageStatus();
9260
9204
  eventHub.storageDidLoad.notify();
9261
9205
  }
@@ -9476,8 +9420,8 @@ ${Array.from(traces).join("\n\n")}`
9476
9420
  async function getThreads(options2) {
9477
9421
  return httpClient.getThreads({
9478
9422
  roomId,
9479
- query: _optionalChain([options2, 'optionalAccess', _193 => _193.query]),
9480
- cursor: _optionalChain([options2, 'optionalAccess', _194 => _194.cursor])
9423
+ query: _optionalChain([options2, 'optionalAccess', _188 => _188.query]),
9424
+ cursor: _optionalChain([options2, 'optionalAccess', _189 => _189.cursor])
9481
9425
  });
9482
9426
  }
9483
9427
  async function getThread(threadId) {
@@ -9584,7 +9528,7 @@ ${Array.from(traces).join("\n\n")}`
9584
9528
  function getSubscriptionSettings(options2) {
9585
9529
  return httpClient.getSubscriptionSettings({
9586
9530
  roomId,
9587
- signal: _optionalChain([options2, 'optionalAccess', _195 => _195.signal])
9531
+ signal: _optionalChain([options2, 'optionalAccess', _190 => _190.signal])
9588
9532
  });
9589
9533
  }
9590
9534
  function updateSubscriptionSettings(settings) {
@@ -9606,7 +9550,7 @@ ${Array.from(traces).join("\n\n")}`
9606
9550
  {
9607
9551
  [kInternal]: {
9608
9552
  get presenceBuffer() {
9609
- return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _196 => _196.buffer, 'access', _197 => _197.presenceUpdates, 'optionalAccess', _198 => _198.data]), () => ( null)));
9553
+ return deepClone(_nullishCoalesce(_optionalChain([context, 'access', _191 => _191.buffer, 'access', _192 => _192.presenceUpdates, 'optionalAccess', _193 => _193.data]), () => ( null)));
9610
9554
  },
9611
9555
  // prettier-ignore
9612
9556
  get undoStack() {
@@ -9621,9 +9565,9 @@ ${Array.from(traces).join("\n\n")}`
9621
9565
  return context.yjsProvider;
9622
9566
  },
9623
9567
  setYjsProvider(newProvider) {
9624
- _optionalChain([context, 'access', _199 => _199.yjsProvider, 'optionalAccess', _200 => _200.off, 'call', _201 => _201("status", yjsStatusDidChange)]);
9568
+ _optionalChain([context, 'access', _194 => _194.yjsProvider, 'optionalAccess', _195 => _195.off, 'call', _196 => _196("status", yjsStatusDidChange)]);
9625
9569
  context.yjsProvider = newProvider;
9626
- _optionalChain([newProvider, 'optionalAccess', _202 => _202.on, 'call', _203 => _203("status", yjsStatusDidChange)]);
9570
+ _optionalChain([newProvider, 'optionalAccess', _197 => _197.on, 'call', _198 => _198("status", yjsStatusDidChange)]);
9627
9571
  context.yjsProviderDidChange.notify();
9628
9572
  },
9629
9573
  yjsProviderDidChange: context.yjsProviderDidChange.observable,
@@ -9669,7 +9613,7 @@ ${Array.from(traces).join("\n\n")}`
9669
9613
  source.dispose();
9670
9614
  }
9671
9615
  eventHub.roomWillDestroy.notify();
9672
- _optionalChain([context, 'access', _204 => _204.yjsProvider, 'optionalAccess', _205 => _205.off, 'call', _206 => _206("status", yjsStatusDidChange)]);
9616
+ _optionalChain([context, 'access', _199 => _199.yjsProvider, 'optionalAccess', _200 => _200.off, 'call', _201 => _201("status", yjsStatusDidChange)]);
9673
9617
  syncSourceForStorage.destroy();
9674
9618
  syncSourceForYjs.destroy();
9675
9619
  uninstallBgTabSpy();
@@ -9819,7 +9763,7 @@ function makeClassicSubscribeFn(roomId, events, errorEvents) {
9819
9763
  }
9820
9764
  if (isLiveNode(first)) {
9821
9765
  const node = first;
9822
- if (_optionalChain([options, 'optionalAccess', _207 => _207.isDeep])) {
9766
+ if (_optionalChain([options, 'optionalAccess', _202 => _202.isDeep])) {
9823
9767
  const storageCallback = second;
9824
9768
  return subscribeToLiveStructureDeeply(node, storageCallback);
9825
9769
  } else {
@@ -9898,8 +9842,8 @@ function createClient(options) {
9898
9842
  const userId = token.k === "sec-legacy" /* SECRET_LEGACY */ ? token.id : token.uid;
9899
9843
  currentUserId.set(() => userId);
9900
9844
  });
9901
- const fetchPolyfill = _optionalChain([clientOptions, 'access', _208 => _208.polyfills, 'optionalAccess', _209 => _209.fetch]) || /* istanbul ignore next */
9902
- _optionalChain([globalThis, 'access', _210 => _210.fetch, 'optionalAccess', _211 => _211.bind, 'call', _212 => _212(globalThis)]);
9845
+ const fetchPolyfill = _optionalChain([clientOptions, 'access', _203 => _203.polyfills, 'optionalAccess', _204 => _204.fetch]) || /* istanbul ignore next */
9846
+ _optionalChain([globalThis, 'access', _205 => _205.fetch, 'optionalAccess', _206 => _206.bind, 'call', _207 => _207(globalThis)]);
9903
9847
  const httpClient = createApiClient({
9904
9848
  baseUrl,
9905
9849
  fetchPolyfill,
@@ -9917,7 +9861,7 @@ function createClient(options) {
9917
9861
  delegates: {
9918
9862
  createSocket: makeCreateSocketDelegateForAi(
9919
9863
  baseUrl,
9920
- _optionalChain([clientOptions, 'access', _213 => _213.polyfills, 'optionalAccess', _214 => _214.WebSocket])
9864
+ _optionalChain([clientOptions, 'access', _208 => _208.polyfills, 'optionalAccess', _209 => _209.WebSocket])
9921
9865
  ),
9922
9866
  authenticate: async () => {
9923
9867
  const resp = await authManager.getAuthValue({
@@ -9985,7 +9929,7 @@ function createClient(options) {
9985
9929
  createSocket: makeCreateSocketDelegateForRoom(
9986
9930
  roomId,
9987
9931
  baseUrl,
9988
- _optionalChain([clientOptions, 'access', _215 => _215.polyfills, 'optionalAccess', _216 => _216.WebSocket])
9932
+ _optionalChain([clientOptions, 'access', _210 => _210.polyfills, 'optionalAccess', _211 => _211.WebSocket])
9989
9933
  ),
9990
9934
  authenticate: makeAuthDelegateForRoom(roomId, authManager)
9991
9935
  })),
@@ -10008,7 +9952,7 @@ function createClient(options) {
10008
9952
  const shouldConnect = _nullishCoalesce(options2.autoConnect, () => ( true));
10009
9953
  if (shouldConnect) {
10010
9954
  if (typeof atob === "undefined") {
10011
- if (_optionalChain([clientOptions, 'access', _217 => _217.polyfills, 'optionalAccess', _218 => _218.atob]) === void 0) {
9955
+ if (_optionalChain([clientOptions, 'access', _212 => _212.polyfills, 'optionalAccess', _213 => _213.atob]) === void 0) {
10012
9956
  throw new Error(
10013
9957
  "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"
10014
9958
  );
@@ -10020,7 +9964,7 @@ function createClient(options) {
10020
9964
  return leaseRoom(newRoomDetails);
10021
9965
  }
10022
9966
  function getRoom(roomId) {
10023
- const room = _optionalChain([roomsById, 'access', _219 => _219.get, 'call', _220 => _220(roomId), 'optionalAccess', _221 => _221.room]);
9967
+ const room = _optionalChain([roomsById, 'access', _214 => _214.get, 'call', _215 => _215(roomId), 'optionalAccess', _216 => _216.room]);
10024
9968
  return room ? room : null;
10025
9969
  }
10026
9970
  function logout() {
@@ -10040,7 +9984,7 @@ function createClient(options) {
10040
9984
  const batchedResolveUsers = new Batch(
10041
9985
  async (batchedUserIds) => {
10042
9986
  const userIds = batchedUserIds.flat();
10043
- const users = await _optionalChain([resolveUsers, 'optionalCall', _222 => _222({ userIds })]);
9987
+ const users = await _optionalChain([resolveUsers, 'optionalCall', _217 => _217({ userIds })]);
10044
9988
  warnIfNoResolveUsers();
10045
9989
  return _nullishCoalesce(users, () => ( userIds.map(() => void 0)));
10046
9990
  },
@@ -10058,7 +10002,7 @@ function createClient(options) {
10058
10002
  const batchedResolveRoomsInfo = new Batch(
10059
10003
  async (batchedRoomIds) => {
10060
10004
  const roomIds = batchedRoomIds.flat();
10061
- const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _223 => _223({ roomIds })]);
10005
+ const roomsInfo = await _optionalChain([resolveRoomsInfo, 'optionalCall', _218 => _218({ roomIds })]);
10062
10006
  warnIfNoResolveRoomsInfo();
10063
10007
  return _nullishCoalesce(roomsInfo, () => ( roomIds.map(() => void 0)));
10064
10008
  },
@@ -10111,7 +10055,7 @@ function createClient(options) {
10111
10055
  }
10112
10056
  };
10113
10057
  const win = typeof window !== "undefined" ? window : void 0;
10114
- _optionalChain([win, 'optionalAccess', _224 => _224.addEventListener, 'call', _225 => _225("beforeunload", maybePreventClose)]);
10058
+ _optionalChain([win, 'optionalAccess', _219 => _219.addEventListener, 'call', _220 => _220("beforeunload", maybePreventClose)]);
10115
10059
  }
10116
10060
  async function getNotificationSettings(options2) {
10117
10061
  const plainSettings = await httpClient.getNotificationSettings(options2);
@@ -10250,7 +10194,7 @@ var commentBodyElementsTypes = {
10250
10194
  mention: "inline"
10251
10195
  };
10252
10196
  function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
10253
- if (!body || !_optionalChain([body, 'optionalAccess', _226 => _226.content])) {
10197
+ if (!body || !_optionalChain([body, 'optionalAccess', _221 => _221.content])) {
10254
10198
  return;
10255
10199
  }
10256
10200
  const element = typeof elementOrVisitor === "string" ? elementOrVisitor : void 0;
@@ -10260,13 +10204,13 @@ function traverseCommentBody(body, elementOrVisitor, possiblyVisitor) {
10260
10204
  for (const block of body.content) {
10261
10205
  if (type === "all" || type === "block") {
10262
10206
  if (guard(block)) {
10263
- _optionalChain([visitor, 'optionalCall', _227 => _227(block)]);
10207
+ _optionalChain([visitor, 'optionalCall', _222 => _222(block)]);
10264
10208
  }
10265
10209
  }
10266
10210
  if (type === "all" || type === "inline") {
10267
10211
  for (const inline of block.children) {
10268
10212
  if (guard(inline)) {
10269
- _optionalChain([visitor, 'optionalCall', _228 => _228(inline)]);
10213
+ _optionalChain([visitor, 'optionalCall', _223 => _223(inline)]);
10270
10214
  }
10271
10215
  }
10272
10216
  }
@@ -10300,7 +10244,7 @@ async function resolveUsersInCommentBody(body, resolveUsers) {
10300
10244
  userIds
10301
10245
  });
10302
10246
  for (const [index, userId] of userIds.entries()) {
10303
- const user = _optionalChain([users, 'optionalAccess', _229 => _229[index]]);
10247
+ const user = _optionalChain([users, 'optionalAccess', _224 => _224[index]]);
10304
10248
  if (user) {
10305
10249
  resolvedUsers.set(userId, user);
10306
10250
  }
@@ -10419,7 +10363,7 @@ var stringifyCommentBodyPlainElements = {
10419
10363
  text: ({ element }) => element.text,
10420
10364
  link: ({ element }) => _nullishCoalesce(element.text, () => ( element.url)),
10421
10365
  mention: ({ element, user }) => {
10422
- return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _230 => _230.name]), () => ( element.id))}`;
10366
+ return `@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _225 => _225.name]), () => ( element.id))}`;
10423
10367
  }
10424
10368
  };
10425
10369
  var stringifyCommentBodyHtmlElements = {
@@ -10449,7 +10393,7 @@ var stringifyCommentBodyHtmlElements = {
10449
10393
  return html`<a href="${href}" target="_blank" rel="noopener noreferrer">${element.text ? html`${element.text}` : element.url}</a>`;
10450
10394
  },
10451
10395
  mention: ({ element, user }) => {
10452
- return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _231 => _231.name]) ? html`${_optionalChain([user, 'optionalAccess', _232 => _232.name])}` : element.id}</span>`;
10396
+ return html`<span data-mention>@${_optionalChain([user, 'optionalAccess', _226 => _226.name]) ? html`${_optionalChain([user, 'optionalAccess', _227 => _227.name])}` : element.id}</span>`;
10453
10397
  }
10454
10398
  };
10455
10399
  var stringifyCommentBodyMarkdownElements = {
@@ -10479,19 +10423,19 @@ var stringifyCommentBodyMarkdownElements = {
10479
10423
  return markdown`[${_nullishCoalesce(element.text, () => ( element.url))}](${href})`;
10480
10424
  },
10481
10425
  mention: ({ element, user }) => {
10482
- return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _233 => _233.name]), () => ( element.id))}`;
10426
+ return markdown`@${_nullishCoalesce(_optionalChain([user, 'optionalAccess', _228 => _228.name]), () => ( element.id))}`;
10483
10427
  }
10484
10428
  };
10485
10429
  async function stringifyCommentBody(body, options) {
10486
- const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _234 => _234.format]), () => ( "plain"));
10487
- const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _235 => _235.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
10430
+ const format = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _229 => _229.format]), () => ( "plain"));
10431
+ const separator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _230 => _230.separator]), () => ( (format === "markdown" ? "\n\n" : "\n")));
10488
10432
  const elements = {
10489
10433
  ...format === "html" ? stringifyCommentBodyHtmlElements : format === "markdown" ? stringifyCommentBodyMarkdownElements : stringifyCommentBodyPlainElements,
10490
- ..._optionalChain([options, 'optionalAccess', _236 => _236.elements])
10434
+ ..._optionalChain([options, 'optionalAccess', _231 => _231.elements])
10491
10435
  };
10492
10436
  const resolvedUsers = await resolveUsersInCommentBody(
10493
10437
  body,
10494
- _optionalChain([options, 'optionalAccess', _237 => _237.resolveUsers])
10438
+ _optionalChain([options, 'optionalAccess', _232 => _232.resolveUsers])
10495
10439
  );
10496
10440
  const blocks = body.content.flatMap((block, blockIndex) => {
10497
10441
  switch (block.type) {
@@ -10777,12 +10721,12 @@ function legacy_patchImmutableNode(state, path, update) {
10777
10721
  }
10778
10722
  const newState = Object.assign({}, state);
10779
10723
  for (const key in update.updates) {
10780
- if (_optionalChain([update, 'access', _238 => _238.updates, 'access', _239 => _239[key], 'optionalAccess', _240 => _240.type]) === "update") {
10724
+ if (_optionalChain([update, 'access', _233 => _233.updates, 'access', _234 => _234[key], 'optionalAccess', _235 => _235.type]) === "update") {
10781
10725
  const val = update.node.get(key);
10782
10726
  if (val !== void 0) {
10783
10727
  newState[key] = lsonToJson(val);
10784
10728
  }
10785
- } else if (_optionalChain([update, 'access', _241 => _241.updates, 'access', _242 => _242[key], 'optionalAccess', _243 => _243.type]) === "delete") {
10729
+ } else if (_optionalChain([update, 'access', _236 => _236.updates, 'access', _237 => _237[key], 'optionalAccess', _238 => _238.type]) === "delete") {
10786
10730
  delete newState[key];
10787
10731
  }
10788
10732
  }
@@ -10843,12 +10787,12 @@ function legacy_patchImmutableNode(state, path, update) {
10843
10787
  }
10844
10788
  const newState = Object.assign({}, state);
10845
10789
  for (const key in update.updates) {
10846
- if (_optionalChain([update, 'access', _244 => _244.updates, 'access', _245 => _245[key], 'optionalAccess', _246 => _246.type]) === "update") {
10790
+ if (_optionalChain([update, 'access', _239 => _239.updates, 'access', _240 => _240[key], 'optionalAccess', _241 => _241.type]) === "update") {
10847
10791
  const value = update.node.get(key);
10848
10792
  if (value !== void 0) {
10849
10793
  newState[key] = lsonToJson(value);
10850
10794
  }
10851
- } else if (_optionalChain([update, 'access', _247 => _247.updates, 'access', _248 => _248[key], 'optionalAccess', _249 => _249.type]) === "delete") {
10795
+ } else if (_optionalChain([update, 'access', _242 => _242.updates, 'access', _243 => _243[key], 'optionalAccess', _244 => _244.type]) === "delete") {
10852
10796
  delete newState[key];
10853
10797
  }
10854
10798
  }
@@ -10928,9 +10872,9 @@ function makePoller(callback, intervalMs, options) {
10928
10872
  const startTime = performance.now();
10929
10873
  const doc = typeof document !== "undefined" ? document : void 0;
10930
10874
  const win = typeof window !== "undefined" ? window : void 0;
10931
- const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _250 => _250.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
10875
+ const maxStaleTimeMs = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _245 => _245.maxStaleTimeMs]), () => ( Number.POSITIVE_INFINITY));
10932
10876
  const context = {
10933
- inForeground: _optionalChain([doc, 'optionalAccess', _251 => _251.visibilityState]) !== "hidden",
10877
+ inForeground: _optionalChain([doc, 'optionalAccess', _246 => _246.visibilityState]) !== "hidden",
10934
10878
  lastSuccessfulPollAt: startTime,
10935
10879
  count: 0,
10936
10880
  backoff: 0
@@ -11011,11 +10955,11 @@ function makePoller(callback, intervalMs, options) {
11011
10955
  pollNowIfStale();
11012
10956
  }
11013
10957
  function onVisibilityChange() {
11014
- setInForeground(_optionalChain([doc, 'optionalAccess', _252 => _252.visibilityState]) !== "hidden");
10958
+ setInForeground(_optionalChain([doc, 'optionalAccess', _247 => _247.visibilityState]) !== "hidden");
11015
10959
  }
11016
- _optionalChain([doc, 'optionalAccess', _253 => _253.addEventListener, 'call', _254 => _254("visibilitychange", onVisibilityChange)]);
11017
- _optionalChain([win, 'optionalAccess', _255 => _255.addEventListener, 'call', _256 => _256("online", onVisibilityChange)]);
11018
- _optionalChain([win, 'optionalAccess', _257 => _257.addEventListener, 'call', _258 => _258("focus", pollNowIfStale)]);
10960
+ _optionalChain([doc, 'optionalAccess', _248 => _248.addEventListener, 'call', _249 => _249("visibilitychange", onVisibilityChange)]);
10961
+ _optionalChain([win, 'optionalAccess', _250 => _250.addEventListener, 'call', _251 => _251("online", onVisibilityChange)]);
10962
+ _optionalChain([win, 'optionalAccess', _252 => _252.addEventListener, 'call', _253 => _253("focus", pollNowIfStale)]);
11019
10963
  fsm.start();
11020
10964
  return {
11021
10965
  inc,