@yorkie-js/sdk 0.6.0
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/LICENSE +201 -0
- package/dist/counter.html +93 -0
- package/dist/devtool/object.css +147 -0
- package/dist/devtool/object.js +117 -0
- package/dist/devtool/text.css +452 -0
- package/dist/devtool/text.js +827 -0
- package/dist/drawing.html +181 -0
- package/dist/index.html +471 -0
- package/dist/multi.html +477 -0
- package/dist/prosemirror.css +543 -0
- package/dist/prosemirror.html +566 -0
- package/dist/quill-two-clients.css +97 -0
- package/dist/quill-two-clients.html +504 -0
- package/dist/quill.html +360 -0
- package/dist/style.css +196 -0
- package/dist/util.js +36 -0
- package/dist/whiteboard.css +119 -0
- package/dist/whiteboard.html +384 -0
- package/dist/yorkie-js-sdk.d.ts +6175 -0
- package/dist/yorkie-js-sdk.es.js +21106 -0
- package/dist/yorkie-js-sdk.es.js.map +1 -0
- package/dist/yorkie-js-sdk.js +21110 -0
- package/dist/yorkie-js-sdk.js.map +1 -0
- package/package.json +74 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yorkie-js-sdk.es.js","sources":["../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/code.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol-connect/code-string.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/connect-error.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/private/assert.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/private/enum.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/message.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/private/message-type.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/google/varint.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/proto-int64.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/scalar.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/private/scalars.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/binary-encoding.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/private/extensions.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/proto-base64.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/extension-accessor.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/private/reflect.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/is-message.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/private/field-wrapper.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/private/json-format.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/private/binary-format.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/private/util-common.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/private/proto-runtime.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/private/field-list.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/private/names.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/private/field.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/private/field-normalize.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/proto3.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/service-type.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/google/protobuf/timestamp_pb.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/google/protobuf/duration_pb.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/google/protobuf/any_pb.js","../../../node_modules/.pnpm/@bufbuild+protobuf@1.10.0/node_modules/@bufbuild/protobuf/dist/esm/google/protobuf/wrappers_pb.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/http-headers.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/any-client.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol/envelope.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol/async-iterable.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/promise-client.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol/signals.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/context-values.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol-grpc-web/trailer.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol-grpc/headers.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol-grpc-web/headers.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol-grpc-web/content-type.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol-grpc/gen/status_pb.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol-grpc/trailer-status.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol/create-method-url.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol/normalize.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/interceptor.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol/serialization.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol/run-call.js","../../../node_modules/.pnpm/@connectrpc+connect-web@1.4.0_@bufbuild+protobuf@1.10.0_@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0_/node_modules/@connectrpc/connect-web/dist/esm/assert-fetch-api.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol-grpc/validate-trailer.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol-grpc-web/request-header.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol-grpc/http-status.js","../../../node_modules/.pnpm/@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0/node_modules/@connectrpc/connect/dist/esm/protocol-grpc-web/validate-response.js","../../../node_modules/.pnpm/@connectrpc+connect-web@1.4.0_@bufbuild+protobuf@1.10.0_@connectrpc+connect@1.4.0_@bufbuild+protobuf@1.10.0_/node_modules/@connectrpc/connect-web/dist/esm/grpc-web-transport.js","../src/api/yorkie/v1/resources_pb.ts","../src/api/yorkie/v1/yorkie_pb.ts","../src/api/yorkie/v1/yorkie_connect.ts","../../../node_modules/.pnpm/@buf+googleapis_googleapis.bufbuild_es@1.4.0-20240729201550-8bc2c51e08c4.3_@bufbuild+protobuf@1.10.0/node_modules/@buf/googleapis_googleapis.bufbuild_es/google/rpc/error_details_pb.js","../src/util/error.ts","../src/util/object.ts","../src/document/presence/presence.ts","../src/document/time/actor_id.ts","../src/document/time/ticket.ts","../src/document/json/strings.ts","../src/document/crdt/element.ts","../src/document/crdt/element_rht.ts","../src/document/crdt/object.ts","../src/document/operation/operation.ts","../src/util/splay_tree.ts","../../../node_modules/.pnpm/long@5.2.0/node_modules/long/index.js","../src/document/crdt/primitive.ts","../src/document/crdt/rga_tree_list.ts","../src/document/crdt/array.ts","../src/document/operation/remove_operation.ts","../src/document/operation/set_operation.ts","../src/document/operation/add_operation.ts","../src/document/operation/move_operation.ts","../src/document/crdt/rht.ts","../src/document/crdt/text.ts","../src/document/operation/edit_operation.ts","../src/document/operation/style_operation.ts","../src/util/index_tree.ts","../src/util/comparator.ts","../src/util/llrb_tree.ts","../src/document/crdt/tree.ts","../src/document/operation/tree_edit_operation.ts","../src/document/time/version_vector.ts","../src/document/change/change_id.ts","../src/document/change/change.ts","../src/document/change/change_pack.ts","../src/document/change/checkpoint.ts","../src/document/crdt/rga_tree_split.ts","../src/util/number.ts","../src/document/crdt/counter.ts","../src/document/operation/increase_operation.ts","../src/document/operation/tree_style_operation.ts","../src/api/converter.ts","../src/util/logger.ts","../src/util/uuid.ts","../src/client/attachment.ts","../src/util/observable.ts","../src/document/change/context.ts","../src/document/crdt/root.ts","../src/document/json/object.ts","../src/document/json/array.ts","../src/document/json/text.ts","../src/document/json/counter.ts","../src/document/json/tree.ts","../src/document/json/element.ts","../src/document/history.ts","../src/devtools/protocol.ts","../src/devtools/types.ts","../src/devtools/index.ts","../src/document/document.ts","../src/client/auth_interceptor.ts","../src/client/metric_interceptor.ts","../src/util/validator.ts","../src/client/client.ts","../src/yorkie.ts"],"sourcesContent":["// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n/**\n * Connect represents categories of errors as codes, and each code maps to a\n * specific HTTP status code. The codes and their semantics were chosen to\n * match gRPC. Only the codes below are valid — there are no user-defined\n * codes.\n *\n * See the specification at https://connectrpc.com/docs/protocol#error-codes\n * for details.\n */\nexport var Code;\n(function (Code) {\n /**\n * Canceled, usually be the user\n */\n Code[Code[\"Canceled\"] = 1] = \"Canceled\";\n /**\n * Unknown error\n */\n Code[Code[\"Unknown\"] = 2] = \"Unknown\";\n /**\n * Argument invalid regardless of system state\n */\n Code[Code[\"InvalidArgument\"] = 3] = \"InvalidArgument\";\n /**\n * Operation expired, may or may not have completed.\n */\n Code[Code[\"DeadlineExceeded\"] = 4] = \"DeadlineExceeded\";\n /**\n * Entity not found.\n */\n Code[Code[\"NotFound\"] = 5] = \"NotFound\";\n /**\n * Entity already exists.\n */\n Code[Code[\"AlreadyExists\"] = 6] = \"AlreadyExists\";\n /**\n * Operation not authorized.\n */\n Code[Code[\"PermissionDenied\"] = 7] = \"PermissionDenied\";\n /**\n * Quota exhausted.\n */\n Code[Code[\"ResourceExhausted\"] = 8] = \"ResourceExhausted\";\n /**\n * Argument invalid in current system state.\n */\n Code[Code[\"FailedPrecondition\"] = 9] = \"FailedPrecondition\";\n /**\n * Operation aborted.\n */\n Code[Code[\"Aborted\"] = 10] = \"Aborted\";\n /**\n * Out of bounds, use instead of FailedPrecondition.\n */\n Code[Code[\"OutOfRange\"] = 11] = \"OutOfRange\";\n /**\n * Operation not implemented or disabled.\n */\n Code[Code[\"Unimplemented\"] = 12] = \"Unimplemented\";\n /**\n * Internal error, reserved for \"serious errors\".\n */\n Code[Code[\"Internal\"] = 13] = \"Internal\";\n /**\n * Unavailable, client should back off and retry.\n */\n Code[Code[\"Unavailable\"] = 14] = \"Unavailable\";\n /**\n * Unrecoverable data loss or corruption.\n */\n Code[Code[\"DataLoss\"] = 15] = \"DataLoss\";\n /**\n * Request isn't authenticated.\n */\n Code[Code[\"Unauthenticated\"] = 16] = \"Unauthenticated\";\n})(Code || (Code = {}));\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { Code } from \"../code.js\";\n/**\n * codeToString returns the string representation of a Code.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function codeToString(value) {\n const name = Code[value];\n if (typeof name != \"string\") {\n return value.toString();\n }\n return (name[0].toLowerCase() +\n name.substring(1).replace(/[A-Z]/g, (c) => \"_\" + c.toLowerCase()));\n}\nlet stringToCode;\n/**\n * codeFromString parses the string representation of a Code in snake_case.\n * For example, the string \"permission_denied\" parses into Code.PermissionDenied.\n *\n * If the given string cannot be parsed, the function returns undefined.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function codeFromString(value) {\n if (!stringToCode) {\n stringToCode = {};\n for (const value of Object.values(Code)) {\n if (typeof value == \"string\") {\n continue;\n }\n stringToCode[codeToString(value)] = value;\n }\n }\n return stringToCode[value];\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { Code } from \"./code.js\";\nimport { codeToString } from \"./protocol-connect/code-string.js\";\n/**\n * ConnectError captures four pieces of information: a Code, an error\n * message, an optional cause of the error, and an optional collection of\n * arbitrary Protobuf messages called \"details\".\n *\n * Because developer tools typically show just the error message, we prefix\n * it with the status code, so that the most important information is always\n * visible immediately.\n *\n * Error details are wrapped with google.protobuf.Any on the wire, so that\n * a server or middleware can attach arbitrary data to an error. Use the\n * method findDetails() to retrieve the details.\n */\nexport class ConnectError extends Error {\n /**\n * Create a new ConnectError.\n * If no code is provided, code \"unknown\" is used.\n * Outgoing details are only relevant for the server side - a service may\n * raise an error with details, and it is up to the protocol implementation\n * to encode and send the details along with error.\n */\n constructor(message, code = Code.Unknown, metadata, outgoingDetails, cause) {\n super(createMessage(message, code));\n this.name = \"ConnectError\";\n // see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-2.html#example\n Object.setPrototypeOf(this, new.target.prototype);\n this.rawMessage = message;\n this.code = code;\n this.metadata = new Headers(metadata !== null && metadata !== void 0 ? metadata : {});\n this.details = outgoingDetails !== null && outgoingDetails !== void 0 ? outgoingDetails : [];\n this.cause = cause;\n }\n /**\n * Convert any value - typically a caught error into a ConnectError,\n * following these rules:\n * - If the value is already a ConnectError, return it as is.\n * - If the value is an AbortError from the fetch API, return the message\n * of the AbortError with code Canceled.\n * - For other Errors, return the error message with code Unknown by default.\n * - For other values, return the values String representation as a message,\n * with the code Unknown by default.\n * The original value will be used for the \"cause\" property for the new\n * ConnectError.\n */\n static from(reason, code = Code.Unknown) {\n if (reason instanceof ConnectError) {\n return reason;\n }\n if (reason instanceof Error) {\n if (reason.name == \"AbortError\") {\n // Fetch requests can only be canceled with an AbortController.\n // We detect that condition by looking at the name of the raised\n // error object, and translate to the appropriate status code.\n return new ConnectError(reason.message, Code.Canceled);\n }\n return new ConnectError(reason.message, code, undefined, undefined, reason);\n }\n return new ConnectError(String(reason), code, undefined, undefined, reason);\n }\n static [Symbol.hasInstance](v) {\n if (!(v instanceof Error)) {\n return false;\n }\n if (Object.getPrototypeOf(v) === ConnectError.prototype) {\n return true;\n }\n return (v.name === \"ConnectError\" &&\n \"code\" in v &&\n typeof v.code === \"number\" &&\n \"metadata\" in v &&\n \"details\" in v &&\n Array.isArray(v.details) &&\n \"rawMessage\" in v &&\n typeof v.rawMessage == \"string\" &&\n \"cause\" in v);\n }\n findDetails(typeOrRegistry) {\n const registry = \"typeName\" in typeOrRegistry\n ? {\n findMessage: (typeName) => typeName === typeOrRegistry.typeName ? typeOrRegistry : undefined,\n }\n : typeOrRegistry;\n const details = [];\n for (const data of this.details) {\n if (\"getType\" in data) {\n if (registry.findMessage(data.getType().typeName)) {\n details.push(data);\n }\n continue;\n }\n const type = registry.findMessage(data.type);\n if (type) {\n try {\n details.push(type.fromBinary(data.value));\n }\n catch (_) {\n // We silently give up if we are unable to parse the detail, because\n // that appears to be the least worst behavior.\n // It is very unlikely that a user surrounds a catch body handling the\n // error with another try-catch statement, and we do not want to\n // recommend doing so.\n }\n }\n }\n return details;\n }\n}\n/**\n * Create an error message, prefixing the given code.\n */\nfunction createMessage(message, code) {\n return message.length\n ? `[${codeToString(code)}] ${message}`\n : `[${codeToString(code)}]`;\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n/**\n * Assert that condition is truthy or throw error (with message)\n */\nexport function assert(condition, msg) {\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions -- we want the implicit conversion to boolean\n if (!condition) {\n throw new Error(msg);\n }\n}\nconst FLOAT32_MAX = 3.4028234663852886e38, FLOAT32_MIN = -3.4028234663852886e38, UINT32_MAX = 0xffffffff, INT32_MAX = 0x7fffffff, INT32_MIN = -0x80000000;\n/**\n * Assert a valid signed protobuf 32-bit integer.\n */\nexport function assertInt32(arg) {\n if (typeof arg !== \"number\")\n throw new Error(\"invalid int 32: \" + typeof arg);\n if (!Number.isInteger(arg) || arg > INT32_MAX || arg < INT32_MIN)\n throw new Error(\"invalid int 32: \" + arg); // eslint-disable-line @typescript-eslint/restrict-plus-operands -- we want the implicit conversion to string\n}\n/**\n * Assert a valid unsigned protobuf 32-bit integer.\n */\nexport function assertUInt32(arg) {\n if (typeof arg !== \"number\")\n throw new Error(\"invalid uint 32: \" + typeof arg);\n if (!Number.isInteger(arg) || arg > UINT32_MAX || arg < 0)\n throw new Error(\"invalid uint 32: \" + arg); // eslint-disable-line @typescript-eslint/restrict-plus-operands -- we want the implicit conversion to string\n}\n/**\n * Assert a valid protobuf float value.\n */\nexport function assertFloat32(arg) {\n if (typeof arg !== \"number\")\n throw new Error(\"invalid float 32: \" + typeof arg);\n if (!Number.isFinite(arg))\n return;\n if (arg > FLOAT32_MAX || arg < FLOAT32_MIN)\n throw new Error(\"invalid float 32: \" + arg); // eslint-disable-line @typescript-eslint/restrict-plus-operands -- we want the implicit conversion to string\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { assert } from \"./assert.js\";\nconst enumTypeSymbol = Symbol(\"@bufbuild/protobuf/enum-type\");\n/**\n * Get reflection information from a generated enum.\n * If this function is called on something other than a generated\n * enum, it raises an error.\n */\nexport function getEnumType(enumObject) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-explicit-any\n const t = enumObject[enumTypeSymbol];\n assert(t, \"missing enum type on enum object\");\n return t; // eslint-disable-line @typescript-eslint/no-unsafe-return\n}\n/**\n * Sets reflection information on a generated enum.\n */\nexport function setEnumType(enumObject, typeName, values, opt) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any\n enumObject[enumTypeSymbol] = makeEnumType(typeName, values.map((v) => ({\n no: v.no,\n name: v.name,\n localName: enumObject[v.no],\n })), opt);\n}\n/**\n * Create a new EnumType with the given values.\n */\nexport function makeEnumType(typeName, values, \n// eslint-disable-next-line @typescript-eslint/no-unused-vars\n_opt) {\n const names = Object.create(null);\n const numbers = Object.create(null);\n const normalValues = [];\n for (const value of values) {\n // We do not surface options at this time\n // const value: EnumValueInfo = {...v, options: v.options ?? emptyReadonlyObject};\n const n = normalizeEnumValue(value);\n normalValues.push(n);\n names[value.name] = n;\n numbers[value.no] = n;\n }\n return {\n typeName,\n values: normalValues,\n // We do not surface options at this time\n // options: opt?.options ?? Object.create(null),\n findName(name) {\n return names[name];\n },\n findNumber(no) {\n return numbers[no];\n },\n };\n}\n/**\n * Create a new enum object with the given values.\n * Sets reflection information.\n */\nexport function makeEnum(typeName, values, opt) {\n const enumObject = {};\n for (const value of values) {\n const n = normalizeEnumValue(value);\n enumObject[n.localName] = n.no;\n enumObject[n.no] = n.localName;\n }\n setEnumType(enumObject, typeName, values, opt);\n return enumObject;\n}\nfunction normalizeEnumValue(value) {\n if (\"localName\" in value) {\n return value;\n }\n return Object.assign(Object.assign({}, value), { localName: value.name });\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n/**\n * Message is the base class of every message, generated, or created at\n * runtime.\n *\n * It is _not_ safe to extend this class. If you want to create a message at\n * run time, use proto3.makeMessageType().\n */\nexport class Message {\n /**\n * Compare with a message of the same type.\n * Note that this function disregards extensions and unknown fields.\n */\n equals(other) {\n return this.getType().runtime.util.equals(this.getType(), this, other);\n }\n /**\n * Create a deep copy.\n */\n clone() {\n return this.getType().runtime.util.clone(this);\n }\n /**\n * Parse from binary data, merging fields.\n *\n * Repeated fields are appended. Map entries are added, overwriting\n * existing keys.\n *\n * If a message field is already present, it will be merged with the\n * new data.\n */\n fromBinary(bytes, options) {\n const type = this.getType(), format = type.runtime.bin, opt = format.makeReadOptions(options);\n format.readMessage(this, opt.readerFactory(bytes), bytes.byteLength, opt);\n return this;\n }\n /**\n * Parse a message from a JSON value.\n */\n fromJson(jsonValue, options) {\n const type = this.getType(), format = type.runtime.json, opt = format.makeReadOptions(options);\n format.readMessage(type, jsonValue, opt, this);\n return this;\n }\n /**\n * Parse a message from a JSON string.\n */\n fromJsonString(jsonString, options) {\n let json;\n try {\n json = JSON.parse(jsonString);\n }\n catch (e) {\n throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${e instanceof Error ? e.message : String(e)}`);\n }\n return this.fromJson(json, options);\n }\n /**\n * Serialize the message to binary data.\n */\n toBinary(options) {\n const type = this.getType(), bin = type.runtime.bin, opt = bin.makeWriteOptions(options), writer = opt.writerFactory();\n bin.writeMessage(this, writer, opt);\n return writer.finish();\n }\n /**\n * Serialize the message to a JSON value, a JavaScript value that can be\n * passed to JSON.stringify().\n */\n toJson(options) {\n const type = this.getType(), json = type.runtime.json, opt = json.makeWriteOptions(options);\n return json.writeMessage(this, opt);\n }\n /**\n * Serialize the message to a JSON string.\n */\n toJsonString(options) {\n var _a;\n const value = this.toJson(options);\n return JSON.stringify(value, null, (_a = options === null || options === void 0 ? void 0 : options.prettySpaces) !== null && _a !== void 0 ? _a : 0);\n }\n /**\n * Override for serialization behavior. This will be invoked when calling\n * JSON.stringify on this message (i.e. JSON.stringify(msg)).\n *\n * Note that this will not serialize google.protobuf.Any with a packed\n * message because the protobuf JSON format specifies that it needs to be\n * unpacked, and this is only possible with a type registry to look up the\n * message type. As a result, attempting to serialize a message with this\n * type will throw an Error.\n *\n * This method is protected because you should not need to invoke it\n * directly -- instead use JSON.stringify or toJsonString for\n * stringified JSON. Alternatively, if actual JSON is desired, you should\n * use toJson.\n */\n toJSON() {\n return this.toJson({\n emitDefaultValues: true,\n });\n }\n /**\n * Retrieve the MessageType of this message - a singleton that represents\n * the protobuf message declaration and provides metadata for reflection-\n * based operations.\n */\n getType() {\n // Any class that extends Message _must_ provide a complete static\n // implementation of MessageType.\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-return\n return Object.getPrototypeOf(this).constructor;\n }\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { Message } from \"../message.js\";\n/**\n * Create a new message type using the given runtime.\n */\nexport function makeMessageType(runtime, typeName, fields, opt) {\n var _a;\n const localName = (_a = opt === null || opt === void 0 ? void 0 : opt.localName) !== null && _a !== void 0 ? _a : typeName.substring(typeName.lastIndexOf(\".\") + 1);\n const type = {\n [localName]: function (data) {\n runtime.util.initFields(this);\n runtime.util.initPartial(data, this);\n },\n }[localName];\n Object.setPrototypeOf(type.prototype, new Message());\n Object.assign(type, {\n runtime,\n typeName,\n fields: runtime.util.newFieldList(fields),\n fromBinary(bytes, options) {\n return new type().fromBinary(bytes, options);\n },\n fromJson(jsonValue, options) {\n return new type().fromJson(jsonValue, options);\n },\n fromJsonString(jsonString, options) {\n return new type().fromJsonString(jsonString, options);\n },\n equals(a, b) {\n return runtime.util.equals(type, a, b);\n },\n });\n return type;\n}\n","// Copyright 2008 Google Inc. All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are\n// met:\n//\n// * Redistributions of source code must retain the above copyright\n// notice, this list of conditions and the following disclaimer.\n// * Redistributions in binary form must reproduce the above\n// copyright notice, this list of conditions and the following disclaimer\n// in the documentation and/or other materials provided with the\n// distribution.\n// * Neither the name of Google Inc. nor the names of its\n// contributors may be used to endorse or promote products derived from\n// this software without specific prior written permission.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n// \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT\n// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT\n// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\n// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE\n// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n//\n// Code generated by the Protocol Buffer compiler is owned by the owner\n// of the input file used when generating it. This code is not\n// standalone and requires a support library to be linked with it. This\n// support library is itself covered by the above license.\n/* eslint-disable prefer-const,@typescript-eslint/restrict-plus-operands */\n/**\n * Read a 64 bit varint as two JS numbers.\n *\n * Returns tuple:\n * [0]: low bits\n * [1]: high bits\n *\n * Copyright 2008 Google Inc. All rights reserved.\n *\n * See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/buffer_decoder.js#L175\n */\nexport function varint64read() {\n let lowBits = 0;\n let highBits = 0;\n for (let shift = 0; shift < 28; shift += 7) {\n let b = this.buf[this.pos++];\n lowBits |= (b & 0x7f) << shift;\n if ((b & 0x80) == 0) {\n this.assertBounds();\n return [lowBits, highBits];\n }\n }\n let middleByte = this.buf[this.pos++];\n // last four bits of the first 32 bit number\n lowBits |= (middleByte & 0x0f) << 28;\n // 3 upper bits are part of the next 32 bit number\n highBits = (middleByte & 0x70) >> 4;\n if ((middleByte & 0x80) == 0) {\n this.assertBounds();\n return [lowBits, highBits];\n }\n for (let shift = 3; shift <= 31; shift += 7) {\n let b = this.buf[this.pos++];\n highBits |= (b & 0x7f) << shift;\n if ((b & 0x80) == 0) {\n this.assertBounds();\n return [lowBits, highBits];\n }\n }\n throw new Error(\"invalid varint\");\n}\n/**\n * Write a 64 bit varint, given as two JS numbers, to the given bytes array.\n *\n * Copyright 2008 Google Inc. All rights reserved.\n *\n * See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/writer.js#L344\n */\nexport function varint64write(lo, hi, bytes) {\n for (let i = 0; i < 28; i = i + 7) {\n const shift = lo >>> i;\n const hasNext = !(shift >>> 7 == 0 && hi == 0);\n const byte = (hasNext ? shift | 0x80 : shift) & 0xff;\n bytes.push(byte);\n if (!hasNext) {\n return;\n }\n }\n const splitBits = ((lo >>> 28) & 0x0f) | ((hi & 0x07) << 4);\n const hasMoreBits = !(hi >> 3 == 0);\n bytes.push((hasMoreBits ? splitBits | 0x80 : splitBits) & 0xff);\n if (!hasMoreBits) {\n return;\n }\n for (let i = 3; i < 31; i = i + 7) {\n const shift = hi >>> i;\n const hasNext = !(shift >>> 7 == 0);\n const byte = (hasNext ? shift | 0x80 : shift) & 0xff;\n bytes.push(byte);\n if (!hasNext) {\n return;\n }\n }\n bytes.push((hi >>> 31) & 0x01);\n}\n// constants for binary math\nconst TWO_PWR_32_DBL = 0x100000000;\n/**\n * Parse decimal string of 64 bit integer value as two JS numbers.\n *\n * Copyright 2008 Google Inc. All rights reserved.\n *\n * See https://github.com/protocolbuffers/protobuf-javascript/blob/a428c58273abad07c66071d9753bc4d1289de426/experimental/runtime/int64.js#L10\n */\nexport function int64FromString(dec) {\n // Check for minus sign.\n const minus = dec[0] === \"-\";\n if (minus) {\n dec = dec.slice(1);\n }\n // Work 6 decimal digits at a time, acting like we're converting base 1e6\n // digits to binary. This is safe to do with floating point math because\n // Number.isSafeInteger(ALL_32_BITS * 1e6) == true.\n const base = 1e6;\n let lowBits = 0;\n let highBits = 0;\n function add1e6digit(begin, end) {\n // Note: Number('') is 0.\n const digit1e6 = Number(dec.slice(begin, end));\n highBits *= base;\n lowBits = lowBits * base + digit1e6;\n // Carry bits from lowBits to\n if (lowBits >= TWO_PWR_32_DBL) {\n highBits = highBits + ((lowBits / TWO_PWR_32_DBL) | 0);\n lowBits = lowBits % TWO_PWR_32_DBL;\n }\n }\n add1e6digit(-24, -18);\n add1e6digit(-18, -12);\n add1e6digit(-12, -6);\n add1e6digit(-6);\n return minus ? negate(lowBits, highBits) : newBits(lowBits, highBits);\n}\n/**\n * Losslessly converts a 64-bit signed integer in 32:32 split representation\n * into a decimal string.\n *\n * Copyright 2008 Google Inc. All rights reserved.\n *\n * See https://github.com/protocolbuffers/protobuf-javascript/blob/a428c58273abad07c66071d9753bc4d1289de426/experimental/runtime/int64.js#L10\n */\nexport function int64ToString(lo, hi) {\n let bits = newBits(lo, hi);\n // If we're treating the input as a signed value and the high bit is set, do\n // a manual two's complement conversion before the decimal conversion.\n const negative = (bits.hi & 0x80000000);\n if (negative) {\n bits = negate(bits.lo, bits.hi);\n }\n const result = uInt64ToString(bits.lo, bits.hi);\n return negative ? \"-\" + result : result;\n}\n/**\n * Losslessly converts a 64-bit unsigned integer in 32:32 split representation\n * into a decimal string.\n *\n * Copyright 2008 Google Inc. All rights reserved.\n *\n * See https://github.com/protocolbuffers/protobuf-javascript/blob/a428c58273abad07c66071d9753bc4d1289de426/experimental/runtime/int64.js#L10\n */\nexport function uInt64ToString(lo, hi) {\n ({ lo, hi } = toUnsigned(lo, hi));\n // Skip the expensive conversion if the number is small enough to use the\n // built-in conversions.\n // Number.MAX_SAFE_INTEGER = 0x001FFFFF FFFFFFFF, thus any number with\n // highBits <= 0x1FFFFF can be safely expressed with a double and retain\n // integer precision.\n // Proven by: Number.isSafeInteger(0x1FFFFF * 2**32 + 0xFFFFFFFF) == true.\n if (hi <= 0x1FFFFF) {\n return String(TWO_PWR_32_DBL * hi + lo);\n }\n // What this code is doing is essentially converting the input number from\n // base-2 to base-1e7, which allows us to represent the 64-bit range with\n // only 3 (very large) digits. Those digits are then trivial to convert to\n // a base-10 string.\n // The magic numbers used here are -\n // 2^24 = 16777216 = (1,6777216) in base-1e7.\n // 2^48 = 281474976710656 = (2,8147497,6710656) in base-1e7.\n // Split 32:32 representation into 16:24:24 representation so our\n // intermediate digits don't overflow.\n const low = lo & 0xFFFFFF;\n const mid = ((lo >>> 24) | (hi << 8)) & 0xFFFFFF;\n const high = (hi >> 16) & 0xFFFF;\n // Assemble our three base-1e7 digits, ignoring carries. The maximum\n // value in a digit at this step is representable as a 48-bit integer, which\n // can be stored in a 64-bit floating point number.\n let digitA = low + (mid * 6777216) + (high * 6710656);\n let digitB = mid + (high * 8147497);\n let digitC = (high * 2);\n // Apply carries from A to B and from B to C.\n const base = 10000000;\n if (digitA >= base) {\n digitB += Math.floor(digitA / base);\n digitA %= base;\n }\n if (digitB >= base) {\n digitC += Math.floor(digitB / base);\n digitB %= base;\n }\n // If digitC is 0, then we should have returned in the trivial code path\n // at the top for non-safe integers. Given this, we can assume both digitB\n // and digitA need leading zeros.\n return digitC.toString() + decimalFrom1e7WithLeadingZeros(digitB) +\n decimalFrom1e7WithLeadingZeros(digitA);\n}\nfunction toUnsigned(lo, hi) {\n return { lo: lo >>> 0, hi: hi >>> 0 };\n}\nfunction newBits(lo, hi) {\n return { lo: lo | 0, hi: hi | 0 };\n}\n/**\n * Returns two's compliment negation of input.\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_Operators#Signed_32-bit_integers\n */\nfunction negate(lowBits, highBits) {\n highBits = ~highBits;\n if (lowBits) {\n lowBits = ~lowBits + 1;\n }\n else {\n // If lowBits is 0, then bitwise-not is 0xFFFFFFFF,\n // adding 1 to that, results in 0x100000000, which leaves\n // the low bits 0x0 and simply adds one to the high bits.\n highBits += 1;\n }\n return newBits(lowBits, highBits);\n}\n/**\n * Returns decimal representation of digit1e7 with leading zeros.\n */\nconst decimalFrom1e7WithLeadingZeros = (digit1e7) => {\n const partial = String(digit1e7);\n return \"0000000\".slice(partial.length) + partial;\n};\n/**\n * Write a 32 bit varint, signed or unsigned. Same as `varint64write(0, value, bytes)`\n *\n * Copyright 2008 Google Inc. All rights reserved.\n *\n * See https://github.com/protocolbuffers/protobuf/blob/1b18833f4f2a2f681f4e4a25cdf3b0a43115ec26/js/binary/encoder.js#L144\n */\nexport function varint32write(value, bytes) {\n if (value >= 0) {\n // write value as varint 32\n while (value > 0x7f) {\n bytes.push((value & 0x7f) | 0x80);\n value = value >>> 7;\n }\n bytes.push(value);\n }\n else {\n for (let i = 0; i < 9; i++) {\n bytes.push((value & 127) | 128);\n value = value >> 7;\n }\n bytes.push(1);\n }\n}\n/**\n * Read an unsigned 32 bit varint.\n *\n * See https://github.com/protocolbuffers/protobuf/blob/8a71927d74a4ce34efe2d8769fda198f52d20d12/js/experimental/runtime/kernel/buffer_decoder.js#L220\n */\nexport function varint32read() {\n let b = this.buf[this.pos++];\n let result = b & 0x7f;\n if ((b & 0x80) == 0) {\n this.assertBounds();\n return result;\n }\n b = this.buf[this.pos++];\n result |= (b & 0x7f) << 7;\n if ((b & 0x80) == 0) {\n this.assertBounds();\n return result;\n }\n b = this.buf[this.pos++];\n result |= (b & 0x7f) << 14;\n if ((b & 0x80) == 0) {\n this.assertBounds();\n return result;\n }\n b = this.buf[this.pos++];\n result |= (b & 0x7f) << 21;\n if ((b & 0x80) == 0) {\n this.assertBounds();\n return result;\n }\n // Extract only last 4 bits\n b = this.buf[this.pos++];\n result |= (b & 0x0f) << 28;\n for (let readBytes = 5; (b & 0x80) !== 0 && readBytes < 10; readBytes++)\n b = this.buf[this.pos++];\n if ((b & 0x80) != 0)\n throw new Error(\"invalid varint\");\n this.assertBounds();\n // Result can have 32 bits, convert it to unsigned\n return result >>> 0;\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { assert } from \"./private/assert.js\";\nimport { int64FromString, int64ToString, uInt64ToString, } from \"./google/varint.js\";\nfunction makeInt64Support() {\n const dv = new DataView(new ArrayBuffer(8));\n // note that Safari 14 implements BigInt, but not the DataView methods\n const ok = typeof BigInt === \"function\" &&\n typeof dv.getBigInt64 === \"function\" &&\n typeof dv.getBigUint64 === \"function\" &&\n typeof dv.setBigInt64 === \"function\" &&\n typeof dv.setBigUint64 === \"function\" &&\n (typeof process != \"object\" ||\n typeof process.env != \"object\" ||\n process.env.BUF_BIGINT_DISABLE !== \"1\");\n if (ok) {\n const MIN = BigInt(\"-9223372036854775808\"), MAX = BigInt(\"9223372036854775807\"), UMIN = BigInt(\"0\"), UMAX = BigInt(\"18446744073709551615\");\n return {\n zero: BigInt(0),\n supported: true,\n parse(value) {\n const bi = typeof value == \"bigint\" ? value : BigInt(value);\n if (bi > MAX || bi < MIN) {\n throw new Error(`int64 invalid: ${value}`);\n }\n return bi;\n },\n uParse(value) {\n const bi = typeof value == \"bigint\" ? value : BigInt(value);\n if (bi > UMAX || bi < UMIN) {\n throw new Error(`uint64 invalid: ${value}`);\n }\n return bi;\n },\n enc(value) {\n dv.setBigInt64(0, this.parse(value), true);\n return {\n lo: dv.getInt32(0, true),\n hi: dv.getInt32(4, true),\n };\n },\n uEnc(value) {\n dv.setBigInt64(0, this.uParse(value), true);\n return {\n lo: dv.getInt32(0, true),\n hi: dv.getInt32(4, true),\n };\n },\n dec(lo, hi) {\n dv.setInt32(0, lo, true);\n dv.setInt32(4, hi, true);\n return dv.getBigInt64(0, true);\n },\n uDec(lo, hi) {\n dv.setInt32(0, lo, true);\n dv.setInt32(4, hi, true);\n return dv.getBigUint64(0, true);\n },\n };\n }\n const assertInt64String = (value) => assert(/^-?[0-9]+$/.test(value), `int64 invalid: ${value}`);\n const assertUInt64String = (value) => assert(/^[0-9]+$/.test(value), `uint64 invalid: ${value}`);\n return {\n zero: \"0\",\n supported: false,\n parse(value) {\n if (typeof value != \"string\") {\n value = value.toString();\n }\n assertInt64String(value);\n return value;\n },\n uParse(value) {\n if (typeof value != \"string\") {\n value = value.toString();\n }\n assertUInt64String(value);\n return value;\n },\n enc(value) {\n if (typeof value != \"string\") {\n value = value.toString();\n }\n assertInt64String(value);\n return int64FromString(value);\n },\n uEnc(value) {\n if (typeof value != \"string\") {\n value = value.toString();\n }\n assertUInt64String(value);\n return int64FromString(value);\n },\n dec(lo, hi) {\n return int64ToString(lo, hi);\n },\n uDec(lo, hi) {\n return uInt64ToString(lo, hi);\n },\n };\n}\nexport const protoInt64 = makeInt64Support();\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n/**\n * Scalar value types. This is a subset of field types declared by protobuf\n * enum google.protobuf.FieldDescriptorProto.Type The types GROUP and MESSAGE\n * are omitted, but the numerical values are identical.\n */\nexport var ScalarType;\n(function (ScalarType) {\n // 0 is reserved for errors.\n // Order is weird for historical reasons.\n ScalarType[ScalarType[\"DOUBLE\"] = 1] = \"DOUBLE\";\n ScalarType[ScalarType[\"FLOAT\"] = 2] = \"FLOAT\";\n // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if\n // negative values are likely.\n ScalarType[ScalarType[\"INT64\"] = 3] = \"INT64\";\n ScalarType[ScalarType[\"UINT64\"] = 4] = \"UINT64\";\n // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if\n // negative values are likely.\n ScalarType[ScalarType[\"INT32\"] = 5] = \"INT32\";\n ScalarType[ScalarType[\"FIXED64\"] = 6] = \"FIXED64\";\n ScalarType[ScalarType[\"FIXED32\"] = 7] = \"FIXED32\";\n ScalarType[ScalarType[\"BOOL\"] = 8] = \"BOOL\";\n ScalarType[ScalarType[\"STRING\"] = 9] = \"STRING\";\n // Tag-delimited aggregate.\n // Group type is deprecated and not supported in proto3. However, Proto3\n // implementations should still be able to parse the group wire format and\n // treat group fields as unknown fields.\n // TYPE_GROUP = 10,\n // TYPE_MESSAGE = 11, // Length-delimited aggregate.\n // New in version 2.\n ScalarType[ScalarType[\"BYTES\"] = 12] = \"BYTES\";\n ScalarType[ScalarType[\"UINT32\"] = 13] = \"UINT32\";\n // TYPE_ENUM = 14,\n ScalarType[ScalarType[\"SFIXED32\"] = 15] = \"SFIXED32\";\n ScalarType[ScalarType[\"SFIXED64\"] = 16] = \"SFIXED64\";\n ScalarType[ScalarType[\"SINT32\"] = 17] = \"SINT32\";\n ScalarType[ScalarType[\"SINT64\"] = 18] = \"SINT64\";\n})(ScalarType || (ScalarType = {}));\n/**\n * JavaScript representation of fields with 64 bit integral types (int64, uint64,\n * sint64, fixed64, sfixed64).\n *\n * This is a subset of google.protobuf.FieldOptions.JSType, which defines JS_NORMAL,\n * JS_STRING, and JS_NUMBER. Protobuf-ES uses BigInt by default, but will use\n * String if `[jstype = JS_STRING]` is specified.\n *\n * ```protobuf\n * uint64 field_a = 1; // BigInt\n * uint64 field_b = 2 [jstype = JS_NORMAL]; // BigInt\n * uint64 field_b = 2 [jstype = JS_NUMBER]; // BigInt\n * uint64 field_b = 2 [jstype = JS_STRING]; // String\n * ```\n */\nexport var LongType;\n(function (LongType) {\n /**\n * Use JavaScript BigInt.\n */\n LongType[LongType[\"BIGINT\"] = 0] = \"BIGINT\";\n /**\n * Use JavaScript String.\n *\n * Field option `[jstype = JS_STRING]`.\n */\n LongType[LongType[\"STRING\"] = 1] = \"STRING\";\n})(LongType || (LongType = {}));\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { protoInt64 } from \"../proto-int64.js\";\nimport { LongType, ScalarType } from \"../scalar.js\";\n/**\n * Returns true if both scalar values are equal.\n */\nexport function scalarEquals(type, a, b) {\n if (a === b) {\n // This correctly matches equal values except BYTES and (possibly) 64-bit integers.\n return true;\n }\n // Special case BYTES - we need to compare each byte individually\n if (type == ScalarType.BYTES) {\n if (!(a instanceof Uint8Array) || !(b instanceof Uint8Array)) {\n return false;\n }\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n }\n // Special case 64-bit integers - we support number, string and bigint representation.\n // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check\n switch (type) {\n case ScalarType.UINT64:\n case ScalarType.FIXED64:\n case ScalarType.INT64:\n case ScalarType.SFIXED64:\n case ScalarType.SINT64:\n // Loose comparison will match between 0n, 0 and \"0\".\n return a == b;\n }\n // Anything that hasn't been caught by strict comparison or special cased\n // BYTES and 64-bit integers is not equal.\n return false;\n}\n/**\n * Returns the zero value for the given scalar type.\n */\nexport function scalarZeroValue(type, longType) {\n switch (type) {\n case ScalarType.BOOL:\n return false;\n case ScalarType.UINT64:\n case ScalarType.FIXED64:\n case ScalarType.INT64:\n case ScalarType.SFIXED64:\n case ScalarType.SINT64:\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison -- acceptable since it's covered by tests\n return (longType == 0 ? protoInt64.zero : \"0\");\n case ScalarType.DOUBLE:\n case ScalarType.FLOAT:\n return 0.0;\n case ScalarType.BYTES:\n return new Uint8Array(0);\n case ScalarType.STRING:\n return \"\";\n default:\n // Handles INT32, UINT32, SINT32, FIXED32, SFIXED32.\n // We do not use individual cases to save a few bytes code size.\n return 0;\n }\n}\n/**\n * Returns true for a zero-value. For example, an integer has the zero-value `0`,\n * a boolean is `false`, a string is `\"\"`, and bytes is an empty Uint8Array.\n *\n * In proto3, zero-values are not written to the wire, unless the field is\n * optional or repeated.\n */\nexport function isScalarZeroValue(type, value) {\n switch (type) {\n case ScalarType.BOOL:\n return value === false;\n case ScalarType.STRING:\n return value === \"\";\n case ScalarType.BYTES:\n return value instanceof Uint8Array && !value.byteLength;\n default:\n return value == 0; // Loose comparison matches 0n, 0 and \"0\"\n }\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { varint32read, varint32write, varint64read, varint64write, } from \"./google/varint.js\";\nimport { assertFloat32, assertInt32, assertUInt32 } from \"./private/assert.js\";\nimport { protoInt64 } from \"./proto-int64.js\";\n/* eslint-disable prefer-const,no-case-declarations,@typescript-eslint/restrict-plus-operands */\n/**\n * Protobuf binary format wire types.\n *\n * A wire type provides just enough information to find the length of the\n * following value.\n *\n * See https://developers.google.com/protocol-buffers/docs/encoding#structure\n */\nexport var WireType;\n(function (WireType) {\n /**\n * Used for int32, int64, uint32, uint64, sint32, sint64, bool, enum\n */\n WireType[WireType[\"Varint\"] = 0] = \"Varint\";\n /**\n * Used for fixed64, sfixed64, double.\n * Always 8 bytes with little-endian byte order.\n */\n WireType[WireType[\"Bit64\"] = 1] = \"Bit64\";\n /**\n * Used for string, bytes, embedded messages, packed repeated fields\n *\n * Only repeated numeric types (types which use the varint, 32-bit,\n * or 64-bit wire types) can be packed. In proto3, such fields are\n * packed by default.\n */\n WireType[WireType[\"LengthDelimited\"] = 2] = \"LengthDelimited\";\n /**\n * Start of a tag-delimited aggregate, such as a proto2 group, or a message\n * in editions with message_encoding = DELIMITED.\n */\n WireType[WireType[\"StartGroup\"] = 3] = \"StartGroup\";\n /**\n * End of a tag-delimited aggregate.\n */\n WireType[WireType[\"EndGroup\"] = 4] = \"EndGroup\";\n /**\n * Used for fixed32, sfixed32, float.\n * Always 4 bytes with little-endian byte order.\n */\n WireType[WireType[\"Bit32\"] = 5] = \"Bit32\";\n})(WireType || (WireType = {}));\nexport class BinaryWriter {\n constructor(textEncoder) {\n /**\n * Previous fork states.\n */\n this.stack = [];\n this.textEncoder = textEncoder !== null && textEncoder !== void 0 ? textEncoder : new TextEncoder();\n this.chunks = [];\n this.buf = [];\n }\n /**\n * Return all bytes written and reset this writer.\n */\n finish() {\n this.chunks.push(new Uint8Array(this.buf)); // flush the buffer\n let len = 0;\n for (let i = 0; i < this.chunks.length; i++)\n len += this.chunks[i].length;\n let bytes = new Uint8Array(len);\n let offset = 0;\n for (let i = 0; i < this.chunks.length; i++) {\n bytes.set(this.chunks[i], offset);\n offset += this.chunks[i].length;\n }\n this.chunks = [];\n return bytes;\n }\n /**\n * Start a new fork for length-delimited data like a message\n * or a packed repeated field.\n *\n * Must be joined later with `join()`.\n */\n fork() {\n this.stack.push({ chunks: this.chunks, buf: this.buf });\n this.chunks = [];\n this.buf = [];\n return this;\n }\n /**\n * Join the last fork. Write its length and bytes, then\n * return to the previous state.\n */\n join() {\n // get chunk of fork\n let chunk = this.finish();\n // restore previous state\n let prev = this.stack.pop();\n if (!prev)\n throw new Error(\"invalid state, fork stack empty\");\n this.chunks = prev.chunks;\n this.buf = prev.buf;\n // write length of chunk as varint\n this.uint32(chunk.byteLength);\n return this.raw(chunk);\n }\n /**\n * Writes a tag (field number and wire type).\n *\n * Equivalent to `uint32( (fieldNo << 3 | type) >>> 0 )`.\n *\n * Generated code should compute the tag ahead of time and call `uint32()`.\n */\n tag(fieldNo, type) {\n return this.uint32(((fieldNo << 3) | type) >>> 0);\n }\n /**\n * Write a chunk of raw bytes.\n */\n raw(chunk) {\n if (this.buf.length) {\n this.chunks.push(new Uint8Array(this.buf));\n this.buf = [];\n }\n this.chunks.push(chunk);\n return this;\n }\n /**\n * Write a `uint32` value, an unsigned 32 bit varint.\n */\n uint32(value) {\n assertUInt32(value);\n // write value as varint 32, inlined for speed\n while (value > 0x7f) {\n this.buf.push((value & 0x7f) | 0x80);\n value = value >>> 7;\n }\n this.buf.push(value);\n return this;\n }\n /**\n * Write a `int32` value, a signed 32 bit varint.\n */\n int32(value) {\n assertInt32(value);\n varint32write(value, this.buf);\n return this;\n }\n /**\n * Write a `bool` value, a variant.\n */\n bool(value) {\n this.buf.push(value ? 1 : 0);\n return this;\n }\n /**\n * Write a `bytes` value, length-delimited arbitrary data.\n */\n bytes(value) {\n this.uint32(value.byteLength); // write length of chunk as varint\n return this.raw(value);\n }\n /**\n * Write a `string` value, length-delimited data converted to UTF-8 text.\n */\n string(value) {\n let chunk = this.textEncoder.encode(value);\n this.uint32(chunk.byteLength); // write length of chunk as varint\n return this.raw(chunk);\n }\n /**\n * Write a `float` value, 32-bit floating point number.\n */\n float(value) {\n assertFloat32(value);\n let chunk = new Uint8Array(4);\n new DataView(chunk.buffer).setFloat32(0, value, true);\n return this.raw(chunk);\n }\n /**\n * Write a `double` value, a 64-bit floating point number.\n */\n double(value) {\n let chunk = new Uint8Array(8);\n new DataView(chunk.buffer).setFloat64(0, value, true);\n return this.raw(chunk);\n }\n /**\n * Write a `fixed32` value, an unsigned, fixed-length 32-bit integer.\n */\n fixed32(value) {\n assertUInt32(value);\n let chunk = new Uint8Array(4);\n new DataView(chunk.buffer).setUint32(0, value, true);\n return this.raw(chunk);\n }\n /**\n * Write a `sfixed32` value, a signed, fixed-length 32-bit integer.\n */\n sfixed32(value) {\n assertInt32(value);\n let chunk = new Uint8Array(4);\n new DataView(chunk.buffer).setInt32(0, value, true);\n return this.raw(chunk);\n }\n /**\n * Write a `sint32` value, a signed, zigzag-encoded 32-bit varint.\n */\n sint32(value) {\n assertInt32(value);\n // zigzag encode\n value = ((value << 1) ^ (value >> 31)) >>> 0;\n varint32write(value, this.buf);\n return this;\n }\n /**\n * Write a `fixed64` value, a signed, fixed-length 64-bit integer.\n */\n sfixed64(value) {\n let chunk = new Uint8Array(8), view = new DataView(chunk.buffer), tc = protoInt64.enc(value);\n view.setInt32(0, tc.lo, true);\n view.setInt32(4, tc.hi, true);\n return this.raw(chunk);\n }\n /**\n * Write a `fixed64` value, an unsigned, fixed-length 64 bit integer.\n */\n fixed64(value) {\n let chunk = new Uint8Array(8), view = new DataView(chunk.buffer), tc = protoInt64.uEnc(value);\n view.setInt32(0, tc.lo, true);\n view.setInt32(4, tc.hi, true);\n return this.raw(chunk);\n }\n /**\n * Write a `int64` value, a signed 64-bit varint.\n */\n int64(value) {\n let tc = protoInt64.enc(value);\n varint64write(tc.lo, tc.hi, this.buf);\n return this;\n }\n /**\n * Write a `sint64` value, a signed, zig-zag-encoded 64-bit varint.\n */\n sint64(value) {\n let tc = protoInt64.enc(value), \n // zigzag encode\n sign = tc.hi >> 31, lo = (tc.lo << 1) ^ sign, hi = ((tc.hi << 1) | (tc.lo >>> 31)) ^ sign;\n varint64write(lo, hi, this.buf);\n return this;\n }\n /**\n * Write a `uint64` value, an unsigned 64-bit varint.\n */\n uint64(value) {\n let tc = protoInt64.uEnc(value);\n varint64write(tc.lo, tc.hi, this.buf);\n return this;\n }\n}\nexport class BinaryReader {\n constructor(buf, textDecoder) {\n this.varint64 = varint64read; // dirty cast for `this`\n /**\n * Read a `uint32` field, an unsigned 32 bit varint.\n */\n this.uint32 = varint32read; // dirty cast for `this` and access to protected `buf`\n this.buf = buf;\n this.len = buf.length;\n this.pos = 0;\n this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);\n this.textDecoder = textDecoder !== null && textDecoder !== void 0 ? textDecoder : new TextDecoder();\n }\n /**\n * Reads a tag - field number and wire type.\n */\n tag() {\n let tag = this.uint32(), fieldNo = tag >>> 3, wireType = tag & 7;\n if (fieldNo <= 0 || wireType < 0 || wireType > 5)\n throw new Error(\"illegal tag: field no \" + fieldNo + \" wire type \" + wireType);\n return [fieldNo, wireType];\n }\n /**\n * Skip one element and return the skipped data.\n *\n * When skipping StartGroup, provide the tags field number to check for\n * matching field number in the EndGroup tag.\n */\n skip(wireType, fieldNo) {\n let start = this.pos;\n switch (wireType) {\n case WireType.Varint:\n while (this.buf[this.pos++] & 0x80) {\n // ignore\n }\n break;\n // eslint-disable-next-line\n // @ts-ignore TS7029: Fallthrough case in switch\n case WireType.Bit64:\n this.pos += 4;\n // eslint-disable-next-line\n // @ts-ignore TS7029: Fallthrough case in switch\n case WireType.Bit32:\n this.pos += 4;\n break;\n case WireType.LengthDelimited:\n let len = this.uint32();\n this.pos += len;\n break;\n case WireType.StartGroup:\n for (;;) {\n const [fn, wt] = this.tag();\n if (wt === WireType.EndGroup) {\n if (fieldNo !== undefined && fn !== fieldNo) {\n throw new Error(\"invalid end group tag\");\n }\n break;\n }\n this.skip(wt, fn);\n }\n break;\n default:\n throw new Error(\"cant skip wire type \" + wireType);\n }\n this.assertBounds();\n return this.buf.subarray(start, this.pos);\n }\n /**\n * Throws error if position in byte array is out of range.\n */\n assertBounds() {\n if (this.pos > this.len)\n throw new RangeError(\"premature EOF\");\n }\n /**\n * Read a `int32` field, a signed 32 bit varint.\n */\n int32() {\n return this.uint32() | 0;\n }\n /**\n * Read a `sint32` field, a signed, zigzag-encoded 32-bit varint.\n */\n sint32() {\n let zze = this.uint32();\n // decode zigzag\n return (zze >>> 1) ^ -(zze & 1);\n }\n /**\n * Read a `int64` field, a signed 64-bit varint.\n */\n int64() {\n return protoInt64.dec(...this.varint64());\n }\n /**\n * Read a `uint64` field, an unsigned 64-bit varint.\n */\n uint64() {\n return protoInt64.uDec(...this.varint64());\n }\n /**\n * Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.\n */\n sint64() {\n let [lo, hi] = this.varint64();\n // decode zig zag\n let s = -(lo & 1);\n lo = ((lo >>> 1) | ((hi & 1) << 31)) ^ s;\n hi = (hi >>> 1) ^ s;\n return protoInt64.dec(lo, hi);\n }\n /**\n * Read a `bool` field, a variant.\n */\n bool() {\n let [lo, hi] = this.varint64();\n return lo !== 0 || hi !== 0;\n }\n /**\n * Read a `fixed32` field, an unsigned, fixed-length 32-bit integer.\n */\n fixed32() {\n return this.view.getUint32((this.pos += 4) - 4, true);\n }\n /**\n * Read a `sfixed32` field, a signed, fixed-length 32-bit integer.\n */\n sfixed32() {\n return this.view.getInt32((this.pos += 4) - 4, true);\n }\n /**\n * Read a `fixed64` field, an unsigned, fixed-length 64 bit integer.\n */\n fixed64() {\n return protoInt64.uDec(this.sfixed32(), this.sfixed32());\n }\n /**\n * Read a `fixed64` field, a signed, fixed-length 64-bit integer.\n */\n sfixed64() {\n return protoInt64.dec(this.sfixed32(), this.sfixed32());\n }\n /**\n * Read a `float` field, 32-bit floating point number.\n */\n float() {\n return this.view.getFloat32((this.pos += 4) - 4, true);\n }\n /**\n * Read a `double` field, a 64-bit floating point number.\n */\n double() {\n return this.view.getFloat64((this.pos += 8) - 8, true);\n }\n /**\n * Read a `bytes` field, length-delimited arbitrary data.\n */\n bytes() {\n let len = this.uint32(), start = this.pos;\n this.pos += len;\n this.assertBounds();\n return this.buf.subarray(start, start + len);\n }\n /**\n * Read a `string` field, length-delimited data converted to UTF-8 text.\n */\n string() {\n return this.textDecoder.decode(this.bytes());\n }\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { scalarZeroValue } from \"./scalars.js\";\nimport { WireType } from \"../binary-encoding.js\";\n/**\n * Create a new extension using the given runtime.\n */\nexport function makeExtension(runtime, typeName, extendee, field) {\n let fi;\n return {\n typeName,\n extendee,\n get field() {\n if (!fi) {\n const i = (typeof field == \"function\" ? field() : field);\n i.name = typeName.split(\".\").pop();\n i.jsonName = `[${typeName}]`;\n fi = runtime.util.newFieldList([i]).list()[0];\n }\n return fi;\n },\n runtime,\n };\n}\n/**\n * Create a container that allows us to read extension fields into it with the\n * same logic as regular fields.\n */\nexport function createExtensionContainer(extension) {\n const localName = extension.field.localName;\n const container = Object.create(null);\n container[localName] = initExtensionField(extension);\n return [container, () => container[localName]];\n}\nfunction initExtensionField(ext) {\n const field = ext.field;\n if (field.repeated) {\n return [];\n }\n if (field.default !== undefined) {\n return field.default;\n }\n switch (field.kind) {\n case \"enum\":\n return field.T.values[0].no;\n case \"scalar\":\n return scalarZeroValue(field.T, field.L);\n case \"message\":\n // eslint-disable-next-line no-case-declarations\n const T = field.T, value = new T();\n return T.fieldWrapper ? T.fieldWrapper.unwrapField(value) : value;\n case \"map\":\n throw \"map fields are not allowed to be extensions\";\n }\n}\n/**\n * Helper to filter unknown fields, optimized based on field type.\n */\nexport function filterUnknownFields(unknownFields, field) {\n if (!field.repeated && (field.kind == \"enum\" || field.kind == \"scalar\")) {\n // singular scalar fields do not merge, we pick the last\n for (let i = unknownFields.length - 1; i >= 0; --i) {\n if (unknownFields[i].no == field.no) {\n return [unknownFields[i]];\n }\n }\n return [];\n }\n return unknownFields.filter((uf) => uf.no === field.no);\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-unnecessary-condition, prefer-const */\n// lookup table from base64 character to byte\nlet encTable = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\".split(\"\");\n// lookup table from base64 character *code* to byte because lookup by number is fast\nlet decTable = [];\nfor (let i = 0; i < encTable.length; i++)\n decTable[encTable[i].charCodeAt(0)] = i;\n// support base64url variants\ndecTable[\"-\".charCodeAt(0)] = encTable.indexOf(\"+\");\ndecTable[\"_\".charCodeAt(0)] = encTable.indexOf(\"/\");\nexport const protoBase64 = {\n /**\n * Decodes a base64 string to a byte array.\n *\n * - ignores white-space, including line breaks and tabs\n * - allows inner padding (can decode concatenated base64 strings)\n * - does not require padding\n * - understands base64url encoding:\n * \"-\" instead of \"+\",\n * \"_\" instead of \"/\",\n * no padding\n */\n dec(base64Str) {\n // estimate byte size, not accounting for inner padding and whitespace\n let es = (base64Str.length * 3) / 4;\n if (base64Str[base64Str.length - 2] == \"=\")\n es -= 2;\n else if (base64Str[base64Str.length - 1] == \"=\")\n es -= 1;\n let bytes = new Uint8Array(es), bytePos = 0, // position in byte array\n groupPos = 0, // position in base64 group\n b, // current byte\n p = 0; // previous byte\n for (let i = 0; i < base64Str.length; i++) {\n b = decTable[base64Str.charCodeAt(i)];\n if (b === undefined) {\n switch (base64Str[i]) {\n // @ts-ignore TS7029: Fallthrough case in switch\n case \"=\":\n groupPos = 0; // reset state when padding found\n // @ts-ignore TS7029: Fallthrough case in switch\n case \"\\n\":\n case \"\\r\":\n case \"\\t\":\n case \" \":\n continue; // skip white-space, and padding\n default:\n throw Error(\"invalid base64 string.\");\n }\n }\n switch (groupPos) {\n case 0:\n p = b;\n groupPos = 1;\n break;\n case 1:\n bytes[bytePos++] = (p << 2) | ((b & 48) >> 4);\n p = b;\n groupPos = 2;\n break;\n case 2:\n bytes[bytePos++] = ((p & 15) << 4) | ((b & 60) >> 2);\n p = b;\n groupPos = 3;\n break;\n case 3:\n bytes[bytePos++] = ((p & 3) << 6) | b;\n groupPos = 0;\n break;\n }\n }\n if (groupPos == 1)\n throw Error(\"invalid base64 string.\");\n return bytes.subarray(0, bytePos);\n },\n /**\n * Encode a byte array to a base64 string.\n */\n enc(bytes) {\n let base64 = \"\", groupPos = 0, // position in base64 group\n b, // current byte\n p = 0; // carry over from previous byte\n for (let i = 0; i < bytes.length; i++) {\n b = bytes[i];\n switch (groupPos) {\n case 0:\n base64 += encTable[b >> 2];\n p = (b & 3) << 4;\n groupPos = 1;\n break;\n case 1:\n base64 += encTable[p | (b >> 4)];\n p = (b & 15) << 2;\n groupPos = 2;\n break;\n case 2:\n base64 += encTable[p | (b >> 6)];\n base64 += encTable[b & 63];\n groupPos = 0;\n break;\n }\n }\n // add output padding\n if (groupPos) {\n base64 += encTable[p];\n base64 += \"=\";\n if (groupPos == 1)\n base64 += \"=\";\n }\n return base64;\n },\n};\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { assert } from \"./private/assert.js\";\nimport { createExtensionContainer, filterUnknownFields, } from \"./private/extensions.js\";\n/**\n * Retrieve an extension value from a message.\n *\n * The function never returns undefined. Use hasExtension() to check whether an\n * extension is set. If the extension is not set, this function returns the\n * default value (if one was specified in the protobuf source), or the zero value\n * (for example `0` for numeric types, `[]` for repeated extension fields, and\n * an empty message instance for message fields).\n *\n * Extensions are stored as unknown fields on a message. To mutate an extension\n * value, make sure to store the new value with setExtension() after mutating.\n *\n * If the extension does not extend the given message, an error is raised.\n */\nexport function getExtension(message, extension, options) {\n assertExtendee(extension, message);\n const opt = extension.runtime.bin.makeReadOptions(options);\n const ufs = filterUnknownFields(message.getType().runtime.bin.listUnknownFields(message), extension.field);\n const [container, get] = createExtensionContainer(extension);\n for (const uf of ufs) {\n extension.runtime.bin.readField(container, opt.readerFactory(uf.data), extension.field, uf.wireType, opt);\n }\n return get();\n}\n/**\n * Set an extension value on a message. If the message already has a value for\n * this extension, the value is replaced.\n *\n * If the extension does not extend the given message, an error is raised.\n */\nexport function setExtension(message, extension, value, options) {\n assertExtendee(extension, message);\n const readOpt = extension.runtime.bin.makeReadOptions(options);\n const writeOpt = extension.runtime.bin.makeWriteOptions(options);\n if (hasExtension(message, extension)) {\n const ufs = message\n .getType()\n .runtime.bin.listUnknownFields(message)\n .filter((uf) => uf.no != extension.field.no);\n message.getType().runtime.bin.discardUnknownFields(message);\n for (const uf of ufs) {\n message\n .getType()\n .runtime.bin.onUnknownField(message, uf.no, uf.wireType, uf.data);\n }\n }\n const writer = writeOpt.writerFactory();\n let f = extension.field;\n // Implicit presence does not apply to extensions, see https://github.com/protocolbuffers/protobuf/issues/8234\n // We patch the field info to use explicit presence:\n if (!f.opt && !f.repeated && (f.kind == \"enum\" || f.kind == \"scalar\")) {\n f = Object.assign(Object.assign({}, extension.field), { opt: true });\n }\n extension.runtime.bin.writeField(f, value, writer, writeOpt);\n const reader = readOpt.readerFactory(writer.finish());\n while (reader.pos < reader.len) {\n const [no, wireType] = reader.tag();\n const data = reader.skip(wireType, no);\n message.getType().runtime.bin.onUnknownField(message, no, wireType, data);\n }\n}\n/**\n * Remove an extension value from a message.\n *\n * If the extension does not extend the given message, an error is raised.\n */\nexport function clearExtension(message, extension) {\n assertExtendee(extension, message);\n if (hasExtension(message, extension)) {\n const bin = message.getType().runtime.bin;\n const ufs = bin\n .listUnknownFields(message)\n .filter((uf) => uf.no != extension.field.no);\n bin.discardUnknownFields(message);\n for (const uf of ufs) {\n bin.onUnknownField(message, uf.no, uf.wireType, uf.data);\n }\n }\n}\n/**\n * Check whether an extension is set on a message.\n */\nexport function hasExtension(message, extension) {\n const messageType = message.getType();\n return (extension.extendee.typeName === messageType.typeName &&\n !!messageType.runtime.bin\n .listUnknownFields(message)\n .find((uf) => uf.no == extension.field.no));\n}\nfunction assertExtendee(extension, message) {\n assert(extension.extendee.typeName == message.getType().typeName, `extension ${extension.typeName} can only be applied to message ${extension.extendee.typeName}`);\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { isScalarZeroValue, scalarZeroValue } from \"./scalars.js\";\n/**\n * Returns true if the field is set.\n */\nexport function isFieldSet(field, target) {\n const localName = field.localName;\n if (field.repeated) {\n return target[localName].length > 0;\n }\n if (field.oneof) {\n return target[field.oneof.localName].case === localName; // eslint-disable-line @typescript-eslint/no-unsafe-member-access\n }\n switch (field.kind) {\n case \"enum\":\n case \"scalar\":\n if (field.opt || field.req) {\n // explicit presence\n return target[localName] !== undefined;\n }\n // implicit presence\n if (field.kind == \"enum\") {\n return target[localName] !== field.T.values[0].no;\n }\n return !isScalarZeroValue(field.T, target[localName]);\n case \"message\":\n return target[localName] !== undefined;\n case \"map\":\n return Object.keys(target[localName]).length > 0; // eslint-disable-line @typescript-eslint/no-unsafe-argument\n }\n}\n/**\n * Resets the field, so that isFieldSet() will return false.\n */\nexport function clearField(field, target) {\n const localName = field.localName;\n const implicitPresence = !field.opt && !field.req;\n if (field.repeated) {\n target[localName] = [];\n }\n else if (field.oneof) {\n target[field.oneof.localName] = { case: undefined };\n }\n else {\n switch (field.kind) {\n case \"map\":\n target[localName] = {};\n break;\n case \"enum\":\n target[localName] = implicitPresence ? field.T.values[0].no : undefined;\n break;\n case \"scalar\":\n target[localName] = implicitPresence\n ? scalarZeroValue(field.T, field.L)\n : undefined;\n break;\n case \"message\":\n target[localName] = undefined;\n break;\n }\n }\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { Message } from \"./message.js\";\n/**\n * Check whether the given object is any subtype of Message or is a specific\n * Message by passing the type.\n *\n * Just like `instanceof`, `isMessage` narrows the type. The advantage of\n * `isMessage` is that it compares identity by the message type name, not by\n * class identity. This makes it robust against the dual package hazard and\n * similar situations, where the same message is duplicated.\n *\n * This function is _mostly_ equivalent to the `instanceof` operator. For\n * example, `isMessage(foo, MyMessage)` is the same as `foo instanceof MyMessage`,\n * and `isMessage(foo)` is the same as `foo instanceof Message`. In most cases,\n * `isMessage` should be preferred over `instanceof`.\n *\n * However, due to the fact that `isMessage` does not use class identity, there\n * are subtle differences between this function and `instanceof`. Notably,\n * calling `isMessage` on an explicit type of Message will return false.\n */\nexport function isMessage(arg, type) {\n if (arg === null || typeof arg != \"object\") {\n return false;\n }\n if (!Object.getOwnPropertyNames(Message.prototype).every((m) => m in arg && typeof arg[m] == \"function\")) {\n return false;\n }\n const actualType = arg.getType();\n if (actualType === null ||\n typeof actualType != \"function\" ||\n !(\"typeName\" in actualType) ||\n typeof actualType.typeName != \"string\") {\n return false;\n }\n return type === undefined ? true : actualType.typeName == type.typeName;\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { Message } from \"../message.js\";\nimport { ScalarType } from \"../scalar.js\";\nimport { isMessage } from \"../is-message.js\";\n/**\n * Wrap a primitive message field value in its corresponding wrapper\n * message. This function is idempotent.\n */\nexport function wrapField(type, value) {\n if (isMessage(value) || !type.fieldWrapper) {\n return value;\n }\n return type.fieldWrapper.wrapField(value);\n}\n/**\n * If the given field uses one of the well-known wrapper types, return\n * the primitive type it wraps.\n */\nexport function getUnwrappedFieldType(field) {\n if (field.fieldKind !== \"message\") {\n return undefined;\n }\n if (field.repeated) {\n return undefined;\n }\n if (field.oneof != undefined) {\n return undefined;\n }\n return wktWrapperToScalarType[field.message.typeName];\n}\nconst wktWrapperToScalarType = {\n \"google.protobuf.DoubleValue\": ScalarType.DOUBLE,\n \"google.protobuf.FloatValue\": ScalarType.FLOAT,\n \"google.protobuf.Int64Value\": ScalarType.INT64,\n \"google.protobuf.UInt64Value\": ScalarType.UINT64,\n \"google.protobuf.Int32Value\": ScalarType.INT32,\n \"google.protobuf.UInt32Value\": ScalarType.UINT32,\n \"google.protobuf.BoolValue\": ScalarType.BOOL,\n \"google.protobuf.StringValue\": ScalarType.STRING,\n \"google.protobuf.BytesValue\": ScalarType.BYTES,\n};\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { Message } from \"../message.js\";\nimport { assert, assertFloat32, assertInt32, assertUInt32 } from \"./assert.js\";\nimport { protoInt64 } from \"../proto-int64.js\";\nimport { protoBase64 } from \"../proto-base64.js\";\nimport { createExtensionContainer } from \"./extensions.js\";\nimport { getExtension, hasExtension, setExtension, } from \"../extension-accessor.js\";\nimport { clearField, isFieldSet } from \"./reflect.js\";\nimport { wrapField } from \"./field-wrapper.js\";\nimport { scalarZeroValue } from \"./scalars.js\";\nimport { isScalarZeroValue } from \"./scalars.js\";\nimport { LongType, ScalarType } from \"../scalar.js\";\nimport { isMessage } from \"../is-message.js\";\n/* eslint-disable no-case-declarations,@typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call */\n// Default options for parsing JSON.\nconst jsonReadDefaults = {\n ignoreUnknownFields: false,\n};\n// Default options for serializing to JSON.\nconst jsonWriteDefaults = {\n emitDefaultValues: false,\n enumAsInteger: false,\n useProtoFieldName: false,\n prettySpaces: 0,\n};\nfunction makeReadOptions(options) {\n return options ? Object.assign(Object.assign({}, jsonReadDefaults), options) : jsonReadDefaults;\n}\nfunction makeWriteOptions(options) {\n return options ? Object.assign(Object.assign({}, jsonWriteDefaults), options) : jsonWriteDefaults;\n}\nconst tokenNull = Symbol();\nconst tokenIgnoredUnknownEnum = Symbol();\nexport function makeJsonFormat() {\n return {\n makeReadOptions,\n makeWriteOptions,\n readMessage(type, json, options, message) {\n if (json == null || Array.isArray(json) || typeof json != \"object\") {\n throw new Error(`cannot decode message ${type.typeName} from JSON: ${debugJsonValue(json)}`);\n }\n message = message !== null && message !== void 0 ? message : new type();\n const oneofSeen = new Map();\n const registry = options.typeRegistry;\n for (const [jsonKey, jsonValue] of Object.entries(json)) {\n const field = type.fields.findJsonName(jsonKey);\n if (field) {\n if (field.oneof) {\n if (jsonValue === null && field.kind == \"scalar\") {\n // see conformance test Required.Proto3.JsonInput.OneofFieldNull{First,Second}\n continue;\n }\n const seen = oneofSeen.get(field.oneof);\n if (seen !== undefined) {\n throw new Error(`cannot decode message ${type.typeName} from JSON: multiple keys for oneof \"${field.oneof.name}\" present: \"${seen}\", \"${jsonKey}\"`);\n }\n oneofSeen.set(field.oneof, jsonKey);\n }\n readField(message, jsonValue, field, options, type);\n }\n else {\n let found = false;\n if ((registry === null || registry === void 0 ? void 0 : registry.findExtension) &&\n jsonKey.startsWith(\"[\") &&\n jsonKey.endsWith(\"]\")) {\n const ext = registry.findExtension(jsonKey.substring(1, jsonKey.length - 1));\n if (ext && ext.extendee.typeName == type.typeName) {\n found = true;\n const [container, get] = createExtensionContainer(ext);\n readField(container, jsonValue, ext.field, options, ext);\n // We pass on the options as BinaryReadOptions/BinaryWriteOptions,\n // so that users can bring their own binary reader and writer factories\n // if necessary.\n setExtension(message, ext, get(), options);\n }\n }\n if (!found && !options.ignoreUnknownFields) {\n throw new Error(`cannot decode message ${type.typeName} from JSON: key \"${jsonKey}\" is unknown`);\n }\n }\n }\n return message;\n },\n writeMessage(message, options) {\n const type = message.getType();\n const json = {};\n let field;\n try {\n for (field of type.fields.byNumber()) {\n if (!isFieldSet(field, message)) {\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (field.req) {\n throw `required field not set`;\n }\n if (!options.emitDefaultValues) {\n continue;\n }\n if (!canEmitFieldDefaultValue(field)) {\n continue;\n }\n }\n const value = field.oneof\n ? message[field.oneof.localName].value\n : message[field.localName];\n const jsonValue = writeField(field, value, options);\n if (jsonValue !== undefined) {\n json[options.useProtoFieldName ? field.name : field.jsonName] =\n jsonValue;\n }\n }\n const registry = options.typeRegistry;\n if (registry === null || registry === void 0 ? void 0 : registry.findExtensionFor) {\n for (const uf of type.runtime.bin.listUnknownFields(message)) {\n const ext = registry.findExtensionFor(type.typeName, uf.no);\n if (ext && hasExtension(message, ext)) {\n // We pass on the options as BinaryReadOptions, so that users can bring their own\n // binary reader factory if necessary.\n const value = getExtension(message, ext, options);\n const jsonValue = writeField(ext.field, value, options);\n if (jsonValue !== undefined) {\n json[ext.field.jsonName] = jsonValue;\n }\n }\n }\n }\n }\n catch (e) {\n const m = field\n ? `cannot encode field ${type.typeName}.${field.name} to JSON`\n : `cannot encode message ${type.typeName} to JSON`;\n const r = e instanceof Error ? e.message : String(e);\n throw new Error(m + (r.length > 0 ? `: ${r}` : \"\"));\n }\n return json;\n },\n readScalar(type, json, longType) {\n // The signature of our internal function has changed. For backwards-\n // compatibility, we support the old form that is part of the public API\n // through the interface JsonFormat.\n return readScalar(type, json, longType !== null && longType !== void 0 ? longType : LongType.BIGINT, true);\n },\n writeScalar(type, value, emitDefaultValues) {\n // The signature of our internal function has changed. For backwards-\n // compatibility, we support the old form that is part of the public API\n // through the interface JsonFormat.\n if (value === undefined) {\n return undefined;\n }\n if (emitDefaultValues || isScalarZeroValue(type, value)) {\n return writeScalar(type, value);\n }\n return undefined;\n },\n debug: debugJsonValue,\n };\n}\nfunction debugJsonValue(json) {\n if (json === null) {\n return \"null\";\n }\n switch (typeof json) {\n case \"object\":\n return Array.isArray(json) ? \"array\" : \"object\";\n case \"string\":\n return json.length > 100 ? \"string\" : `\"${json.split('\"').join('\\\\\"')}\"`;\n default:\n return String(json);\n }\n}\n// Read a JSON value for a field.\n// The \"parentType\" argument is only used to provide context in errors.\nfunction readField(target, jsonValue, field, options, parentType) {\n let localName = field.localName;\n if (field.repeated) {\n assert(field.kind != \"map\");\n if (jsonValue === null) {\n return;\n }\n if (!Array.isArray(jsonValue)) {\n throw new Error(`cannot decode field ${parentType.typeName}.${field.name} from JSON: ${debugJsonValue(jsonValue)}`);\n }\n const targetArray = target[localName];\n for (const jsonItem of jsonValue) {\n if (jsonItem === null) {\n throw new Error(`cannot decode field ${parentType.typeName}.${field.name} from JSON: ${debugJsonValue(jsonItem)}`);\n }\n switch (field.kind) {\n case \"message\":\n targetArray.push(field.T.fromJson(jsonItem, options));\n break;\n case \"enum\":\n const enumValue = readEnum(field.T, jsonItem, options.ignoreUnknownFields, true);\n if (enumValue !== tokenIgnoredUnknownEnum) {\n targetArray.push(enumValue);\n }\n break;\n case \"scalar\":\n try {\n targetArray.push(readScalar(field.T, jsonItem, field.L, true));\n }\n catch (e) {\n let m = `cannot decode field ${parentType.typeName}.${field.name} from JSON: ${debugJsonValue(jsonItem)}`;\n if (e instanceof Error && e.message.length > 0) {\n m += `: ${e.message}`;\n }\n throw new Error(m);\n }\n break;\n }\n }\n }\n else if (field.kind == \"map\") {\n if (jsonValue === null) {\n return;\n }\n if (typeof jsonValue != \"object\" || Array.isArray(jsonValue)) {\n throw new Error(`cannot decode field ${parentType.typeName}.${field.name} from JSON: ${debugJsonValue(jsonValue)}`);\n }\n const targetMap = target[localName];\n for (const [jsonMapKey, jsonMapValue] of Object.entries(jsonValue)) {\n if (jsonMapValue === null) {\n throw new Error(`cannot decode field ${parentType.typeName}.${field.name} from JSON: map value null`);\n }\n let key;\n try {\n key = readMapKey(field.K, jsonMapKey);\n }\n catch (e) {\n let m = `cannot decode map key for field ${parentType.typeName}.${field.name} from JSON: ${debugJsonValue(jsonValue)}`;\n if (e instanceof Error && e.message.length > 0) {\n m += `: ${e.message}`;\n }\n throw new Error(m);\n }\n switch (field.V.kind) {\n case \"message\":\n targetMap[key] = field.V.T.fromJson(jsonMapValue, options);\n break;\n case \"enum\":\n const enumValue = readEnum(field.V.T, jsonMapValue, options.ignoreUnknownFields, true);\n if (enumValue !== tokenIgnoredUnknownEnum) {\n targetMap[key] = enumValue;\n }\n break;\n case \"scalar\":\n try {\n targetMap[key] = readScalar(field.V.T, jsonMapValue, LongType.BIGINT, true);\n }\n catch (e) {\n let m = `cannot decode map value for field ${parentType.typeName}.${field.name} from JSON: ${debugJsonValue(jsonValue)}`;\n if (e instanceof Error && e.message.length > 0) {\n m += `: ${e.message}`;\n }\n throw new Error(m);\n }\n break;\n }\n }\n }\n else {\n if (field.oneof) {\n target = target[field.oneof.localName] = { case: localName };\n localName = \"value\";\n }\n switch (field.kind) {\n case \"message\":\n const messageType = field.T;\n if (jsonValue === null &&\n messageType.typeName != \"google.protobuf.Value\") {\n return;\n }\n let currentValue = target[localName];\n if (isMessage(currentValue)) {\n currentValue.fromJson(jsonValue, options);\n }\n else {\n target[localName] = currentValue = messageType.fromJson(jsonValue, options);\n if (messageType.fieldWrapper && !field.oneof) {\n target[localName] =\n messageType.fieldWrapper.unwrapField(currentValue);\n }\n }\n break;\n case \"enum\":\n const enumValue = readEnum(field.T, jsonValue, options.ignoreUnknownFields, false);\n switch (enumValue) {\n case tokenNull:\n clearField(field, target);\n break;\n case tokenIgnoredUnknownEnum:\n break;\n default:\n target[localName] = enumValue;\n break;\n }\n break;\n case \"scalar\":\n try {\n const scalarValue = readScalar(field.T, jsonValue, field.L, false);\n switch (scalarValue) {\n case tokenNull:\n clearField(field, target);\n break;\n default:\n target[localName] = scalarValue;\n break;\n }\n }\n catch (e) {\n let m = `cannot decode field ${parentType.typeName}.${field.name} from JSON: ${debugJsonValue(jsonValue)}`;\n if (e instanceof Error && e.message.length > 0) {\n m += `: ${e.message}`;\n }\n throw new Error(m);\n }\n break;\n }\n }\n}\nfunction readMapKey(type, json) {\n if (type === ScalarType.BOOL) {\n // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check\n switch (json) {\n case \"true\":\n json = true;\n break;\n case \"false\":\n json = false;\n break;\n }\n }\n return readScalar(type, json, LongType.BIGINT, true).toString();\n}\nfunction readScalar(type, json, longType, nullAsZeroValue) {\n if (json === null) {\n if (nullAsZeroValue) {\n return scalarZeroValue(type, longType);\n }\n return tokenNull;\n }\n // every valid case in the switch below returns, and every fall\n // through is regarded as a failure.\n switch (type) {\n // float, double: JSON value will be a number or one of the special string values \"NaN\", \"Infinity\", and \"-Infinity\".\n // Either numbers or strings are accepted. Exponent notation is also accepted.\n case ScalarType.DOUBLE:\n case ScalarType.FLOAT:\n if (json === \"NaN\")\n return Number.NaN;\n if (json === \"Infinity\")\n return Number.POSITIVE_INFINITY;\n if (json === \"-Infinity\")\n return Number.NEGATIVE_INFINITY;\n if (json === \"\") {\n // empty string is not a number\n break;\n }\n if (typeof json == \"string\" && json.trim().length !== json.length) {\n // extra whitespace\n break;\n }\n if (typeof json != \"string\" && typeof json != \"number\") {\n break;\n }\n const float = Number(json);\n if (Number.isNaN(float)) {\n // not a number\n break;\n }\n if (!Number.isFinite(float)) {\n // infinity and -infinity are handled by string representation above, so this is an error\n break;\n }\n if (type == ScalarType.FLOAT)\n assertFloat32(float);\n return float;\n // int32, fixed32, uint32: JSON value will be a decimal number. Either numbers or strings are accepted.\n case ScalarType.INT32:\n case ScalarType.FIXED32:\n case ScalarType.SFIXED32:\n case ScalarType.SINT32:\n case ScalarType.UINT32:\n let int32;\n if (typeof json == \"number\")\n int32 = json;\n else if (typeof json == \"string\" && json.length > 0) {\n if (json.trim().length === json.length)\n int32 = Number(json);\n }\n if (int32 === undefined)\n break;\n if (type == ScalarType.UINT32 || type == ScalarType.FIXED32)\n assertUInt32(int32);\n else\n assertInt32(int32);\n return int32;\n // int64, fixed64, uint64: JSON value will be a decimal string. Either numbers or strings are accepted.\n case ScalarType.INT64:\n case ScalarType.SFIXED64:\n case ScalarType.SINT64:\n if (typeof json != \"number\" && typeof json != \"string\")\n break;\n const long = protoInt64.parse(json);\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n return longType ? long.toString() : long;\n case ScalarType.FIXED64:\n case ScalarType.UINT64:\n if (typeof json != \"number\" && typeof json != \"string\")\n break;\n const uLong = protoInt64.uParse(json);\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n return longType ? uLong.toString() : uLong;\n // bool:\n case ScalarType.BOOL:\n if (typeof json !== \"boolean\")\n break;\n return json;\n // string:\n case ScalarType.STRING:\n if (typeof json !== \"string\") {\n break;\n }\n // A string must always contain UTF-8 encoded or 7-bit ASCII.\n // We validate with encodeURIComponent, which appears to be the fastest widely available option.\n try {\n encodeURIComponent(json);\n }\n catch (e) {\n throw new Error(\"invalid UTF8\");\n }\n return json;\n // bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings.\n // Either standard or URL-safe base64 encoding with/without paddings are accepted.\n case ScalarType.BYTES:\n if (json === \"\")\n return new Uint8Array(0);\n if (typeof json !== \"string\")\n break;\n return protoBase64.dec(json);\n }\n throw new Error();\n}\nfunction readEnum(type, json, ignoreUnknownFields, nullAsZeroValue) {\n if (json === null) {\n if (type.typeName == \"google.protobuf.NullValue\") {\n return 0; // google.protobuf.NullValue.NULL_VALUE = 0\n }\n return nullAsZeroValue ? type.values[0].no : tokenNull;\n }\n // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check\n switch (typeof json) {\n case \"number\":\n if (Number.isInteger(json)) {\n return json;\n }\n break;\n case \"string\":\n const value = type.findName(json);\n if (value !== undefined) {\n return value.no;\n }\n if (ignoreUnknownFields) {\n return tokenIgnoredUnknownEnum;\n }\n break;\n }\n throw new Error(`cannot decode enum ${type.typeName} from JSON: ${debugJsonValue(json)}`);\n}\n// Decide whether an unset field should be emitted with JSON write option `emitDefaultValues`\nfunction canEmitFieldDefaultValue(field) {\n if (field.repeated || field.kind == \"map\") {\n // maps are {}, repeated fields are []\n return true;\n }\n if (field.oneof) {\n // oneof fields are never emitted\n return false;\n }\n if (field.kind == \"message\") {\n // singular message field are allowed to emit JSON null, but we do not\n return false;\n }\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (field.opt || field.req) {\n // the field uses explicit presence, so we cannot emit a zero value\n return false;\n }\n return true;\n}\nfunction writeField(field, value, options) {\n if (field.kind == \"map\") {\n assert(typeof value == \"object\" && value != null);\n const jsonObj = {};\n const entries = Object.entries(value);\n switch (field.V.kind) {\n case \"scalar\":\n for (const [entryKey, entryValue] of entries) {\n jsonObj[entryKey.toString()] = writeScalar(field.V.T, entryValue); // JSON standard allows only (double quoted) string as property key\n }\n break;\n case \"message\":\n for (const [entryKey, entryValue] of entries) {\n // JSON standard allows only (double quoted) string as property key\n jsonObj[entryKey.toString()] = entryValue.toJson(options);\n }\n break;\n case \"enum\":\n const enumType = field.V.T;\n for (const [entryKey, entryValue] of entries) {\n // JSON standard allows only (double quoted) string as property key\n jsonObj[entryKey.toString()] = writeEnum(enumType, entryValue, options.enumAsInteger);\n }\n break;\n }\n return options.emitDefaultValues || entries.length > 0\n ? jsonObj\n : undefined;\n }\n if (field.repeated) {\n assert(Array.isArray(value));\n const jsonArr = [];\n switch (field.kind) {\n case \"scalar\":\n for (let i = 0; i < value.length; i++) {\n jsonArr.push(writeScalar(field.T, value[i]));\n }\n break;\n case \"enum\":\n for (let i = 0; i < value.length; i++) {\n jsonArr.push(writeEnum(field.T, value[i], options.enumAsInteger));\n }\n break;\n case \"message\":\n for (let i = 0; i < value.length; i++) {\n jsonArr.push(value[i].toJson(options));\n }\n break;\n }\n return options.emitDefaultValues || jsonArr.length > 0\n ? jsonArr\n : undefined;\n }\n switch (field.kind) {\n case \"scalar\":\n return writeScalar(field.T, value);\n case \"enum\":\n return writeEnum(field.T, value, options.enumAsInteger);\n case \"message\":\n return wrapField(field.T, value).toJson(options);\n }\n}\nfunction writeEnum(type, value, enumAsInteger) {\n var _a;\n assert(typeof value == \"number\");\n if (type.typeName == \"google.protobuf.NullValue\") {\n return null;\n }\n if (enumAsInteger) {\n return value;\n }\n const val = type.findNumber(value);\n return (_a = val === null || val === void 0 ? void 0 : val.name) !== null && _a !== void 0 ? _a : value; // if we don't know the enum value, just return the number\n}\nfunction writeScalar(type, value) {\n switch (type) {\n // int32, fixed32, uint32: JSON value will be a decimal number. Either numbers or strings are accepted.\n case ScalarType.INT32:\n case ScalarType.SFIXED32:\n case ScalarType.SINT32:\n case ScalarType.FIXED32:\n case ScalarType.UINT32:\n assert(typeof value == \"number\");\n return value;\n // float, double: JSON value will be a number or one of the special string values \"NaN\", \"Infinity\", and \"-Infinity\".\n // Either numbers or strings are accepted. Exponent notation is also accepted.\n case ScalarType.FLOAT:\n // assertFloat32(value);\n case ScalarType.DOUBLE: // eslint-disable-line no-fallthrough\n assert(typeof value == \"number\");\n if (Number.isNaN(value))\n return \"NaN\";\n if (value === Number.POSITIVE_INFINITY)\n return \"Infinity\";\n if (value === Number.NEGATIVE_INFINITY)\n return \"-Infinity\";\n return value;\n // string:\n case ScalarType.STRING:\n assert(typeof value == \"string\");\n return value;\n // bool:\n case ScalarType.BOOL:\n assert(typeof value == \"boolean\");\n return value;\n // JSON value will be a decimal string. Either numbers or strings are accepted.\n case ScalarType.UINT64:\n case ScalarType.FIXED64:\n case ScalarType.INT64:\n case ScalarType.SFIXED64:\n case ScalarType.SINT64:\n assert(typeof value == \"bigint\" ||\n typeof value == \"string\" ||\n typeof value == \"number\");\n return value.toString();\n // bytes: JSON value will be the data encoded as a string using standard base64 encoding with paddings.\n // Either standard or URL-safe base64 encoding with/without paddings are accepted.\n case ScalarType.BYTES:\n assert(value instanceof Uint8Array);\n return protoBase64.enc(value);\n }\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { BinaryReader, BinaryWriter, WireType } from \"../binary-encoding.js\";\nimport { Message } from \"../message.js\";\nimport { wrapField } from \"./field-wrapper.js\";\nimport { scalarZeroValue } from \"./scalars.js\";\nimport { assert } from \"./assert.js\";\nimport { isFieldSet } from \"./reflect.js\";\nimport { LongType, ScalarType } from \"../scalar.js\";\nimport { isMessage } from \"../is-message.js\";\n/* eslint-disable prefer-const,no-case-declarations,@typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return */\nconst unknownFieldsSymbol = Symbol(\"@bufbuild/protobuf/unknown-fields\");\n// Default options for parsing binary data.\nconst readDefaults = {\n readUnknownFields: true,\n readerFactory: (bytes) => new BinaryReader(bytes),\n};\n// Default options for serializing binary data.\nconst writeDefaults = {\n writeUnknownFields: true,\n writerFactory: () => new BinaryWriter(),\n};\nfunction makeReadOptions(options) {\n return options ? Object.assign(Object.assign({}, readDefaults), options) : readDefaults;\n}\nfunction makeWriteOptions(options) {\n return options ? Object.assign(Object.assign({}, writeDefaults), options) : writeDefaults;\n}\nexport function makeBinaryFormat() {\n return {\n makeReadOptions,\n makeWriteOptions,\n listUnknownFields(message) {\n var _a;\n return (_a = message[unknownFieldsSymbol]) !== null && _a !== void 0 ? _a : [];\n },\n discardUnknownFields(message) {\n delete message[unknownFieldsSymbol];\n },\n writeUnknownFields(message, writer) {\n const m = message;\n const c = m[unknownFieldsSymbol];\n if (c) {\n for (const f of c) {\n writer.tag(f.no, f.wireType).raw(f.data);\n }\n }\n },\n onUnknownField(message, no, wireType, data) {\n const m = message;\n if (!Array.isArray(m[unknownFieldsSymbol])) {\n m[unknownFieldsSymbol] = [];\n }\n m[unknownFieldsSymbol].push({ no, wireType, data });\n },\n readMessage(message, reader, lengthOrEndTagFieldNo, options, delimitedMessageEncoding) {\n const type = message.getType();\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n const end = delimitedMessageEncoding\n ? reader.len\n : reader.pos + lengthOrEndTagFieldNo;\n let fieldNo, wireType;\n while (reader.pos < end) {\n [fieldNo, wireType] = reader.tag();\n if (delimitedMessageEncoding === true &&\n wireType == WireType.EndGroup) {\n break;\n }\n const field = type.fields.find(fieldNo);\n if (!field) {\n const data = reader.skip(wireType, fieldNo);\n if (options.readUnknownFields) {\n this.onUnknownField(message, fieldNo, wireType, data);\n }\n continue;\n }\n readField(message, reader, field, wireType, options);\n }\n if (delimitedMessageEncoding && // eslint-disable-line @typescript-eslint/strict-boolean-expressions\n (wireType != WireType.EndGroup || fieldNo !== lengthOrEndTagFieldNo)) {\n throw new Error(`invalid end group tag`);\n }\n },\n readField,\n writeMessage(message, writer, options) {\n const type = message.getType();\n for (const field of type.fields.byNumber()) {\n if (!isFieldSet(field, message)) {\n if (field.req) {\n throw new Error(`cannot encode field ${type.typeName}.${field.name} to binary: required field not set`);\n }\n continue;\n }\n const value = field.oneof\n ? message[field.oneof.localName].value\n : message[field.localName];\n writeField(field, value, writer, options);\n }\n if (options.writeUnknownFields) {\n this.writeUnknownFields(message, writer);\n }\n return writer;\n },\n writeField(field, value, writer, options) {\n // The behavior of our internal function has changed, it does no longer\n // accept `undefined` values for singular scalar and map.\n // For backwards-compatibility, we support the old form that is part of\n // the public API through the interface BinaryFormat.\n if (value === undefined) {\n return undefined;\n }\n writeField(field, value, writer, options);\n },\n };\n}\nfunction readField(target, // eslint-disable-line @typescript-eslint/no-explicit-any -- `any` is the best choice for dynamic access\nreader, field, wireType, options) {\n let { repeated, localName } = field;\n if (field.oneof) {\n target = target[field.oneof.localName];\n if (target.case != localName) {\n delete target.value;\n }\n target.case = localName;\n localName = \"value\";\n }\n switch (field.kind) {\n case \"scalar\":\n case \"enum\":\n const scalarType = field.kind == \"enum\" ? ScalarType.INT32 : field.T;\n let read = readScalar;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-enum-comparison -- acceptable since it's covered by tests\n if (field.kind == \"scalar\" && field.L > 0) {\n read = readScalarLTString;\n }\n if (repeated) {\n let arr = target[localName]; // safe to assume presence of array, oneof cannot contain repeated values\n const isPacked = wireType == WireType.LengthDelimited &&\n scalarType != ScalarType.STRING &&\n scalarType != ScalarType.BYTES;\n if (isPacked) {\n let e = reader.uint32() + reader.pos;\n while (reader.pos < e) {\n arr.push(read(reader, scalarType));\n }\n }\n else {\n arr.push(read(reader, scalarType));\n }\n }\n else {\n target[localName] = read(reader, scalarType);\n }\n break;\n case \"message\":\n const messageType = field.T;\n if (repeated) {\n // safe to assume presence of array, oneof cannot contain repeated values\n target[localName].push(readMessageField(reader, new messageType(), options, field));\n }\n else {\n if (isMessage(target[localName])) {\n readMessageField(reader, target[localName], options, field);\n }\n else {\n target[localName] = readMessageField(reader, new messageType(), options, field);\n if (messageType.fieldWrapper && !field.oneof && !field.repeated) {\n target[localName] = messageType.fieldWrapper.unwrapField(target[localName]);\n }\n }\n }\n break;\n case \"map\":\n let [mapKey, mapVal] = readMapEntry(field, reader, options);\n // safe to assume presence of map object, oneof cannot contain repeated values\n target[localName][mapKey] = mapVal;\n break;\n }\n}\n// Read a message, avoiding MessageType.fromBinary() to re-use the\n// BinaryReadOptions and the IBinaryReader.\nfunction readMessageField(reader, message, options, field) {\n const format = message.getType().runtime.bin;\n const delimited = field === null || field === void 0 ? void 0 : field.delimited;\n format.readMessage(message, reader, delimited ? field.no : reader.uint32(), // eslint-disable-line @typescript-eslint/strict-boolean-expressions\n options, delimited);\n return message;\n}\n// Read a map field, expecting key field = 1, value field = 2\nfunction readMapEntry(field, reader, options) {\n const length = reader.uint32(), end = reader.pos + length;\n let key, val;\n while (reader.pos < end) {\n const [fieldNo] = reader.tag();\n switch (fieldNo) {\n case 1:\n key = readScalar(reader, field.K);\n break;\n case 2:\n switch (field.V.kind) {\n case \"scalar\":\n val = readScalar(reader, field.V.T);\n break;\n case \"enum\":\n val = reader.int32();\n break;\n case \"message\":\n val = readMessageField(reader, new field.V.T(), options, undefined);\n break;\n }\n break;\n }\n }\n if (key === undefined) {\n key = scalarZeroValue(field.K, LongType.BIGINT);\n }\n if (typeof key != \"string\" && typeof key != \"number\") {\n key = key.toString();\n }\n if (val === undefined) {\n switch (field.V.kind) {\n case \"scalar\":\n val = scalarZeroValue(field.V.T, LongType.BIGINT);\n break;\n case \"enum\":\n val = field.V.T.values[0].no;\n break;\n case \"message\":\n val = new field.V.T();\n break;\n }\n }\n return [key, val];\n}\n// Read a scalar value, but return 64 bit integral types (int64, uint64,\n// sint64, fixed64, sfixed64) as string instead of bigint.\nfunction readScalarLTString(reader, type) {\n const v = readScalar(reader, type);\n return typeof v == \"bigint\" ? v.toString() : v;\n}\n// Does not use scalarTypeInfo() for better performance.\nfunction readScalar(reader, type) {\n switch (type) {\n case ScalarType.STRING:\n return reader.string();\n case ScalarType.BOOL:\n return reader.bool();\n case ScalarType.DOUBLE:\n return reader.double();\n case ScalarType.FLOAT:\n return reader.float();\n case ScalarType.INT32:\n return reader.int32();\n case ScalarType.INT64:\n return reader.int64();\n case ScalarType.UINT64:\n return reader.uint64();\n case ScalarType.FIXED64:\n return reader.fixed64();\n case ScalarType.BYTES:\n return reader.bytes();\n case ScalarType.FIXED32:\n return reader.fixed32();\n case ScalarType.SFIXED32:\n return reader.sfixed32();\n case ScalarType.SFIXED64:\n return reader.sfixed64();\n case ScalarType.SINT64:\n return reader.sint64();\n case ScalarType.UINT32:\n return reader.uint32();\n case ScalarType.SINT32:\n return reader.sint32();\n }\n}\nfunction writeField(field, value, writer, options) {\n assert(value !== undefined);\n const repeated = field.repeated;\n switch (field.kind) {\n case \"scalar\":\n case \"enum\":\n let scalarType = field.kind == \"enum\" ? ScalarType.INT32 : field.T;\n if (repeated) {\n assert(Array.isArray(value));\n if (field.packed) {\n writePacked(writer, scalarType, field.no, value);\n }\n else {\n for (const item of value) {\n writeScalar(writer, scalarType, field.no, item);\n }\n }\n }\n else {\n writeScalar(writer, scalarType, field.no, value);\n }\n break;\n case \"message\":\n if (repeated) {\n assert(Array.isArray(value));\n for (const item of value) {\n writeMessageField(writer, options, field, item);\n }\n }\n else {\n writeMessageField(writer, options, field, value);\n }\n break;\n case \"map\":\n assert(typeof value == \"object\" && value != null);\n for (const [key, val] of Object.entries(value)) {\n writeMapEntry(writer, options, field, key, val);\n }\n break;\n }\n}\nexport function writeMapEntry(writer, options, field, key, value) {\n writer.tag(field.no, WireType.LengthDelimited);\n writer.fork();\n // javascript only allows number or string for object properties\n // we convert from our representation to the protobuf type\n let keyValue = key;\n // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- we deliberately handle just the special cases for map keys\n switch (field.K) {\n case ScalarType.INT32:\n case ScalarType.FIXED32:\n case ScalarType.UINT32:\n case ScalarType.SFIXED32:\n case ScalarType.SINT32:\n keyValue = Number.parseInt(key);\n break;\n case ScalarType.BOOL:\n assert(key == \"true\" || key == \"false\");\n keyValue = key == \"true\";\n break;\n }\n // write key, expecting key field number = 1\n writeScalar(writer, field.K, 1, keyValue);\n // write value, expecting value field number = 2\n switch (field.V.kind) {\n case \"scalar\":\n writeScalar(writer, field.V.T, 2, value);\n break;\n case \"enum\":\n writeScalar(writer, ScalarType.INT32, 2, value);\n break;\n case \"message\":\n assert(value !== undefined);\n writer.tag(2, WireType.LengthDelimited).bytes(value.toBinary(options));\n break;\n }\n writer.join();\n}\n// Value must not be undefined\nfunction writeMessageField(writer, options, field, value) {\n const message = wrapField(field.T, value);\n // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions\n if (field.delimited)\n writer\n .tag(field.no, WireType.StartGroup)\n .raw(message.toBinary(options))\n .tag(field.no, WireType.EndGroup);\n else\n writer\n .tag(field.no, WireType.LengthDelimited)\n .bytes(message.toBinary(options));\n}\nfunction writeScalar(writer, type, fieldNo, value) {\n assert(value !== undefined);\n let [wireType, method] = scalarTypeInfo(type);\n writer.tag(fieldNo, wireType)[method](value);\n}\nfunction writePacked(writer, type, fieldNo, value) {\n if (!value.length) {\n return;\n }\n writer.tag(fieldNo, WireType.LengthDelimited).fork();\n let [, method] = scalarTypeInfo(type);\n for (let i = 0; i < value.length; i++) {\n writer[method](value[i]);\n }\n writer.join();\n}\n/**\n * Get information for writing a scalar value.\n *\n * Returns tuple:\n * [0]: appropriate WireType\n * [1]: name of the appropriate method of IBinaryWriter\n * [2]: whether the given value is a default value for proto3 semantics\n *\n * If argument `value` is omitted, [2] is always false.\n */\n// TODO replace call-sites writeScalar() and writePacked(), then remove\nfunction scalarTypeInfo(type) {\n let wireType = WireType.Varint;\n // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- INT32, UINT32, SINT32 are covered by the defaults\n switch (type) {\n case ScalarType.BYTES:\n case ScalarType.STRING:\n wireType = WireType.LengthDelimited;\n break;\n case ScalarType.DOUBLE:\n case ScalarType.FIXED64:\n case ScalarType.SFIXED64:\n wireType = WireType.Bit64;\n break;\n case ScalarType.FIXED32:\n case ScalarType.SFIXED32:\n case ScalarType.FLOAT:\n wireType = WireType.Bit32;\n break;\n }\n const method = ScalarType[type].toLowerCase();\n return [wireType, method];\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { setEnumType } from \"./enum.js\";\nimport { Message } from \"../message.js\";\nimport { scalarEquals } from \"./scalars.js\";\nimport { ScalarType } from \"../scalar.js\";\nimport { isMessage } from \"../is-message.js\";\n/* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-argument,no-case-declarations */\nexport function makeUtilCommon() {\n return {\n setEnumType,\n initPartial(source, target) {\n if (source === undefined) {\n return;\n }\n const type = target.getType();\n for (const member of type.fields.byMember()) {\n const localName = member.localName, t = target, s = source;\n if (s[localName] == null) {\n // TODO if source is a Message instance, we should use isFieldSet() here to support future field presence\n continue;\n }\n switch (member.kind) {\n case \"oneof\":\n const sk = s[localName].case;\n if (sk === undefined) {\n continue;\n }\n const sourceField = member.findField(sk);\n let val = s[localName].value;\n if (sourceField &&\n sourceField.kind == \"message\" &&\n !isMessage(val, sourceField.T)) {\n val = new sourceField.T(val);\n }\n else if (sourceField &&\n sourceField.kind === \"scalar\" &&\n sourceField.T === ScalarType.BYTES) {\n val = toU8Arr(val);\n }\n t[localName] = { case: sk, value: val };\n break;\n case \"scalar\":\n case \"enum\":\n let copy = s[localName];\n if (member.T === ScalarType.BYTES) {\n copy = member.repeated\n ? copy.map(toU8Arr)\n : toU8Arr(copy);\n }\n t[localName] = copy;\n break;\n case \"map\":\n switch (member.V.kind) {\n case \"scalar\":\n case \"enum\":\n if (member.V.T === ScalarType.BYTES) {\n for (const [k, v] of Object.entries(s[localName])) {\n t[localName][k] = toU8Arr(v);\n }\n }\n else {\n Object.assign(t[localName], s[localName]);\n }\n break;\n case \"message\":\n const messageType = member.V.T;\n for (const k of Object.keys(s[localName])) {\n let val = s[localName][k];\n if (!messageType.fieldWrapper) {\n // We only take partial input for messages that are not a wrapper type.\n // For those messages, we recursively normalize the partial input.\n val = new messageType(val);\n }\n t[localName][k] = val;\n }\n break;\n }\n break;\n case \"message\":\n const mt = member.T;\n if (member.repeated) {\n t[localName] = s[localName].map((val) => isMessage(val, mt) ? val : new mt(val));\n }\n else {\n const val = s[localName];\n if (mt.fieldWrapper) {\n if (\n // We can't use BytesValue.typeName as that will create a circular import\n mt.typeName === \"google.protobuf.BytesValue\") {\n t[localName] = toU8Arr(val);\n }\n else {\n t[localName] = val;\n }\n }\n else {\n t[localName] = isMessage(val, mt) ? val : new mt(val);\n }\n }\n break;\n }\n }\n },\n // TODO use isFieldSet() here to support future field presence\n equals(type, a, b) {\n if (a === b) {\n return true;\n }\n if (!a || !b) {\n return false;\n }\n return type.fields.byMember().every((m) => {\n const va = a[m.localName];\n const vb = b[m.localName];\n if (m.repeated) {\n if (va.length !== vb.length) {\n return false;\n }\n // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- repeated fields are never \"map\"\n switch (m.kind) {\n case \"message\":\n return va.every((a, i) => m.T.equals(a, vb[i]));\n case \"scalar\":\n return va.every((a, i) => scalarEquals(m.T, a, vb[i]));\n case \"enum\":\n return va.every((a, i) => scalarEquals(ScalarType.INT32, a, vb[i]));\n }\n throw new Error(`repeated cannot contain ${m.kind}`);\n }\n switch (m.kind) {\n case \"message\":\n return m.T.equals(va, vb);\n case \"enum\":\n return scalarEquals(ScalarType.INT32, va, vb);\n case \"scalar\":\n return scalarEquals(m.T, va, vb);\n case \"oneof\":\n if (va.case !== vb.case) {\n return false;\n }\n const s = m.findField(va.case);\n if (s === undefined) {\n return true;\n }\n // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check -- oneof fields are never \"map\"\n switch (s.kind) {\n case \"message\":\n return s.T.equals(va.value, vb.value);\n case \"enum\":\n return scalarEquals(ScalarType.INT32, va.value, vb.value);\n case \"scalar\":\n return scalarEquals(s.T, va.value, vb.value);\n }\n throw new Error(`oneof cannot contain ${s.kind}`);\n case \"map\":\n const keys = Object.keys(va).concat(Object.keys(vb));\n switch (m.V.kind) {\n case \"message\":\n const messageType = m.V.T;\n return keys.every((k) => messageType.equals(va[k], vb[k]));\n case \"enum\":\n return keys.every((k) => scalarEquals(ScalarType.INT32, va[k], vb[k]));\n case \"scalar\":\n const scalarType = m.V.T;\n return keys.every((k) => scalarEquals(scalarType, va[k], vb[k]));\n }\n break;\n }\n });\n },\n // TODO use isFieldSet() here to support future field presence\n clone(message) {\n const type = message.getType(), target = new type(), any = target;\n for (const member of type.fields.byMember()) {\n const source = message[member.localName];\n let copy;\n if (member.repeated) {\n copy = source.map(cloneSingularField);\n }\n else if (member.kind == \"map\") {\n copy = any[member.localName];\n for (const [key, v] of Object.entries(source)) {\n copy[key] = cloneSingularField(v);\n }\n }\n else if (member.kind == \"oneof\") {\n const f = member.findField(source.case);\n copy = f\n ? { case: source.case, value: cloneSingularField(source.value) }\n : { case: undefined };\n }\n else {\n copy = cloneSingularField(source);\n }\n any[member.localName] = copy;\n }\n for (const uf of type.runtime.bin.listUnknownFields(message)) {\n type.runtime.bin.onUnknownField(any, uf.no, uf.wireType, uf.data);\n }\n return target;\n },\n };\n}\n// clone a single field value - i.e. the element type of repeated fields, the value type of maps\nfunction cloneSingularField(value) {\n if (value === undefined) {\n return value;\n }\n if (isMessage(value)) {\n return value.clone();\n }\n if (value instanceof Uint8Array) {\n const c = new Uint8Array(value.byteLength);\n c.set(value);\n return c;\n }\n return value;\n}\n// converts any ArrayLike<number> to Uint8Array if necessary.\nfunction toU8Arr(input) {\n return input instanceof Uint8Array ? input : new Uint8Array(input);\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { getEnumType, makeEnum, makeEnumType } from \"./enum.js\";\nimport { makeMessageType } from \"./message-type.js\";\nimport { makeExtension } from \"./extensions.js\";\nimport { makeJsonFormat } from \"./json-format.js\";\nimport { makeBinaryFormat } from \"./binary-format.js\";\nimport { makeUtilCommon } from \"./util-common.js\";\nexport function makeProtoRuntime(syntax, newFieldList, initFields) {\n return {\n syntax,\n json: makeJsonFormat(),\n bin: makeBinaryFormat(),\n util: Object.assign(Object.assign({}, makeUtilCommon()), { newFieldList,\n initFields }),\n makeMessageType(typeName, fields, opt) {\n return makeMessageType(this, typeName, fields, opt);\n },\n makeEnum,\n makeEnumType,\n getEnumType,\n makeExtension(typeName, extendee, field) {\n return makeExtension(this, typeName, extendee, field);\n },\n };\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nexport class InternalFieldList {\n constructor(fields, normalizer) {\n this._fields = fields;\n this._normalizer = normalizer;\n }\n findJsonName(jsonName) {\n if (!this.jsonNames) {\n const t = {};\n for (const f of this.list()) {\n t[f.jsonName] = t[f.name] = f;\n }\n this.jsonNames = t;\n }\n return this.jsonNames[jsonName];\n }\n find(fieldNo) {\n if (!this.numbers) {\n const t = {};\n for (const f of this.list()) {\n t[f.no] = f;\n }\n this.numbers = t;\n }\n return this.numbers[fieldNo];\n }\n list() {\n if (!this.all) {\n this.all = this._normalizer(this._fields);\n }\n return this.all;\n }\n byNumber() {\n if (!this.numbersAsc) {\n this.numbersAsc = this.list()\n .concat()\n .sort((a, b) => a.no - b.no);\n }\n return this.numbersAsc;\n }\n byMember() {\n if (!this.members) {\n this.members = [];\n const a = this.members;\n let o;\n for (const f of this.list()) {\n if (f.oneof) {\n if (f.oneof !== o) {\n o = f.oneof;\n a.push(o);\n }\n }\n else {\n a.push(f);\n }\n }\n }\n return this.members;\n }\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n/**\n * Returns the name of a protobuf element in generated code.\n *\n * Field names - including oneofs - are converted to lowerCamelCase. For\n * messages, enumerations and services, the package name is stripped from\n * the type name. For nested messages and enumerations, the names are joined\n * with an underscore. For methods, the first character is made lowercase.\n */\nexport function localName(desc) {\n switch (desc.kind) {\n case \"field\":\n return localFieldName(desc.name, desc.oneof !== undefined);\n case \"oneof\":\n return localOneofName(desc.name);\n case \"enum\":\n case \"message\":\n case \"service\":\n case \"extension\": {\n const pkg = desc.file.proto.package;\n const offset = pkg === undefined ? 0 : pkg.length + 1;\n const name = desc.typeName.substring(offset).replace(/\\./g, \"_\");\n // For services, we only care about safe identifiers, not safe object properties,\n // but we have shipped v1 with a bug that respected object properties, and we\n // do not want to introduce a breaking change, so we continue to escape for\n // safe object properties.\n // See https://github.com/bufbuild/protobuf-es/pull/391\n return safeObjectProperty(safeIdentifier(name));\n }\n case \"enum_value\": {\n let name = desc.name;\n const sharedPrefix = desc.parent.sharedPrefix;\n if (sharedPrefix !== undefined) {\n name = name.substring(sharedPrefix.length);\n }\n return safeObjectProperty(name);\n }\n case \"rpc\": {\n let name = desc.name;\n if (name.length == 0) {\n return name;\n }\n name = name[0].toLowerCase() + name.substring(1);\n return safeObjectProperty(name);\n }\n }\n}\n/**\n * Returns the name of a field in generated code.\n */\nexport function localFieldName(protoName, inOneof) {\n const name = protoCamelCase(protoName);\n if (inOneof) {\n // oneof member names are not properties, but values of the `case` property.\n return name;\n }\n return safeObjectProperty(safeMessageProperty(name));\n}\n/**\n * Returns the name of a oneof group in generated code.\n */\nexport function localOneofName(protoName) {\n return localFieldName(protoName, false);\n}\n/**\n * Returns the JSON name for a protobuf field, exactly like protoc does.\n */\nexport const fieldJsonName = protoCamelCase;\n/**\n * Finds a prefix shared by enum values, for example `MY_ENUM_` for\n * `enum MyEnum {MY_ENUM_A=0; MY_ENUM_B=1;}`.\n */\nexport function findEnumSharedPrefix(enumName, valueNames) {\n const prefix = camelToSnakeCase(enumName) + \"_\";\n for (const name of valueNames) {\n if (!name.toLowerCase().startsWith(prefix)) {\n return undefined;\n }\n const shortName = name.substring(prefix.length);\n if (shortName.length == 0) {\n return undefined;\n }\n if (/^\\d/.test(shortName)) {\n // identifiers must not start with numbers\n return undefined;\n }\n }\n return prefix;\n}\n/**\n * Converts lowerCamelCase or UpperCamelCase into lower_snake_case.\n * This is used to find shared prefixes in an enum.\n */\nfunction camelToSnakeCase(camel) {\n return (camel.substring(0, 1) + camel.substring(1).replace(/[A-Z]/g, (c) => \"_\" + c)).toLowerCase();\n}\n/**\n * Converts snake_case to protoCamelCase according to the convention\n * used by protoc to convert a field name to a JSON name.\n */\nfunction protoCamelCase(snakeCase) {\n let capNext = false;\n const b = [];\n for (let i = 0; i < snakeCase.length; i++) {\n let c = snakeCase.charAt(i);\n switch (c) {\n case \"_\":\n capNext = true;\n break;\n case \"0\":\n case \"1\":\n case \"2\":\n case \"3\":\n case \"4\":\n case \"5\":\n case \"6\":\n case \"7\":\n case \"8\":\n case \"9\":\n b.push(c);\n capNext = false;\n break;\n default:\n if (capNext) {\n capNext = false;\n c = c.toUpperCase();\n }\n b.push(c);\n break;\n }\n }\n return b.join(\"\");\n}\n/**\n * Names that cannot be used for identifiers, such as class names,\n * but _can_ be used for object properties.\n */\nconst reservedIdentifiers = new Set([\n // ECMAScript 2015 keywords\n \"break\",\n \"case\",\n \"catch\",\n \"class\",\n \"const\",\n \"continue\",\n \"debugger\",\n \"default\",\n \"delete\",\n \"do\",\n \"else\",\n \"export\",\n \"extends\",\n \"false\",\n \"finally\",\n \"for\",\n \"function\",\n \"if\",\n \"import\",\n \"in\",\n \"instanceof\",\n \"new\",\n \"null\",\n \"return\",\n \"super\",\n \"switch\",\n \"this\",\n \"throw\",\n \"true\",\n \"try\",\n \"typeof\",\n \"var\",\n \"void\",\n \"while\",\n \"with\",\n \"yield\",\n // ECMAScript 2015 future reserved keywords\n \"enum\",\n \"implements\",\n \"interface\",\n \"let\",\n \"package\",\n \"private\",\n \"protected\",\n \"public\",\n \"static\",\n // Class name cannot be 'Object' when targeting ES5 with module CommonJS\n \"Object\",\n // TypeScript keywords that cannot be used for types (as opposed to variables)\n \"bigint\",\n \"number\",\n \"boolean\",\n \"string\",\n \"object\",\n // Identifiers reserved for the runtime, so we can generate legible code\n \"globalThis\",\n \"Uint8Array\",\n \"Partial\",\n]);\n/**\n * Names that cannot be used for object properties because they are reserved\n * by built-in JavaScript properties.\n */\nconst reservedObjectProperties = new Set([\n // names reserved by JavaScript\n \"constructor\",\n \"toString\",\n \"toJSON\",\n \"valueOf\",\n]);\n/**\n * Names that cannot be used for object properties because they are reserved\n * by the runtime.\n */\nconst reservedMessageProperties = new Set([\n // names reserved by the runtime\n \"getType\",\n \"clone\",\n \"equals\",\n \"fromBinary\",\n \"fromJson\",\n \"fromJsonString\",\n \"toBinary\",\n \"toJson\",\n \"toJsonString\",\n // names reserved by the runtime for the future\n \"toObject\",\n]);\nconst fallback = (name) => `${name}$`;\n/**\n * Will wrap names that are Object prototype properties or names reserved\n * for `Message`s.\n */\nconst safeMessageProperty = (name) => {\n if (reservedMessageProperties.has(name)) {\n return fallback(name);\n }\n return name;\n};\n/**\n * Names that cannot be used for object properties because they are reserved\n * by built-in JavaScript properties.\n */\nexport const safeObjectProperty = (name) => {\n if (reservedObjectProperties.has(name)) {\n return fallback(name);\n }\n return name;\n};\n/**\n * Names that can be used for identifiers or class properties\n */\nexport const safeIdentifier = (name) => {\n if (reservedIdentifiers.has(name)) {\n return fallback(name);\n }\n return name;\n};\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { localOneofName } from \"./names.js\";\nimport { assert } from \"./assert.js\";\nexport class InternalOneofInfo {\n constructor(name) {\n this.kind = \"oneof\";\n this.repeated = false;\n this.packed = false;\n this.opt = false;\n this.req = false;\n this.default = undefined;\n this.fields = [];\n this.name = name;\n this.localName = localOneofName(name);\n }\n addField(field) {\n assert(field.oneof === this, `field ${field.name} not one of ${this.name}`);\n this.fields.push(field);\n }\n findField(localName) {\n if (!this._lookup) {\n this._lookup = Object.create(null);\n for (let i = 0; i < this.fields.length; i++) {\n this._lookup[this.fields[i].localName] = this.fields[i];\n }\n }\n return this._lookup[localName];\n }\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { InternalOneofInfo } from \"./field.js\";\nimport { fieldJsonName, localFieldName } from \"./names.js\";\nimport { LongType, ScalarType } from \"../scalar.js\";\n/**\n * Convert a collection of field info to an array of normalized FieldInfo.\n *\n * The argument `packedByDefault` specifies whether fields that do not specify\n * `packed` should be packed (proto3) or unpacked (proto2).\n */\nexport function normalizeFieldInfos(fieldInfos, packedByDefault) {\n var _a, _b, _c, _d, _e, _f;\n const r = [];\n let o;\n for (const field of typeof fieldInfos == \"function\"\n ? fieldInfos()\n : fieldInfos) {\n const f = field;\n f.localName = localFieldName(field.name, field.oneof !== undefined);\n f.jsonName = (_a = field.jsonName) !== null && _a !== void 0 ? _a : fieldJsonName(field.name);\n f.repeated = (_b = field.repeated) !== null && _b !== void 0 ? _b : false;\n if (field.kind == \"scalar\") {\n f.L = (_c = field.L) !== null && _c !== void 0 ? _c : LongType.BIGINT;\n }\n f.delimited = (_d = field.delimited) !== null && _d !== void 0 ? _d : false;\n f.req = (_e = field.req) !== null && _e !== void 0 ? _e : false;\n f.opt = (_f = field.opt) !== null && _f !== void 0 ? _f : false;\n if (field.packed === undefined) {\n if (packedByDefault) {\n f.packed =\n field.kind == \"enum\" ||\n (field.kind == \"scalar\" &&\n field.T != ScalarType.BYTES &&\n field.T != ScalarType.STRING);\n }\n else {\n f.packed = false;\n }\n }\n // We do not surface options at this time\n // f.options = field.options ?? emptyReadonlyObject;\n if (field.oneof !== undefined) {\n const ooname = typeof field.oneof == \"string\" ? field.oneof : field.oneof.name;\n if (!o || o.name != ooname) {\n o = new InternalOneofInfo(ooname);\n }\n f.oneof = o;\n o.addField(f);\n }\n r.push(f);\n }\n return r;\n}\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { makeProtoRuntime } from \"./private/proto-runtime.js\";\nimport { InternalFieldList } from \"./private/field-list.js\";\nimport { scalarZeroValue } from \"./private/scalars.js\";\nimport { normalizeFieldInfos } from \"./private/field-normalize.js\";\n/**\n * Provides functionality for messages defined with the proto3 syntax.\n */\nexport const proto3 = makeProtoRuntime(\"proto3\", (fields) => {\n return new InternalFieldList(fields, (source) => normalizeFieldInfos(source, true));\n}, \n// TODO merge with proto2 and initExtensionField, also see initPartial, equals, clone\n(target) => {\n for (const member of target.getType().fields.byMember()) {\n if (member.opt) {\n continue;\n }\n const name = member.localName, t = target;\n if (member.repeated) {\n t[name] = [];\n continue;\n }\n switch (member.kind) {\n case \"oneof\":\n t[name] = { case: undefined };\n break;\n case \"enum\":\n t[name] = 0;\n break;\n case \"map\":\n t[name] = {};\n break;\n case \"scalar\":\n t[name] = scalarZeroValue(member.T, member.L);\n break;\n case \"message\":\n // message fields are always optional in proto3\n break;\n }\n }\n});\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n/**\n * MethodKind represents the four method types that can be declared in\n * protobuf with the `stream` keyword:\n *\n * 1. Unary: rpc (Input) returns (Output)\n * 2. ServerStreaming: rpc (Input) returns (stream Output)\n * 3. ClientStreaming: rpc (stream Input) returns (Output)\n * 4. BiDiStreaming: rpc (stream Input) returns (stream Output)\n */\nexport var MethodKind;\n(function (MethodKind) {\n MethodKind[MethodKind[\"Unary\"] = 0] = \"Unary\";\n MethodKind[MethodKind[\"ServerStreaming\"] = 1] = \"ServerStreaming\";\n MethodKind[MethodKind[\"ClientStreaming\"] = 2] = \"ClientStreaming\";\n MethodKind[MethodKind[\"BiDiStreaming\"] = 3] = \"BiDiStreaming\";\n})(MethodKind || (MethodKind = {}));\n/**\n * Is this method side-effect-free (or safe in HTTP parlance), or just\n * idempotent, or neither? HTTP based RPC implementation may choose GET verb\n * for safe methods, and PUT verb for idempotent methods instead of the\n * default POST.\n *\n * This enum matches the protobuf enum google.protobuf.MethodOptions.IdempotencyLevel,\n * defined in the well-known type google/protobuf/descriptor.proto, but\n * drops UNKNOWN.\n */\nexport var MethodIdempotency;\n(function (MethodIdempotency) {\n /**\n * Idempotent, no side effects.\n */\n MethodIdempotency[MethodIdempotency[\"NoSideEffects\"] = 1] = \"NoSideEffects\";\n /**\n * Idempotent, but may have side effects.\n */\n MethodIdempotency[MethodIdempotency[\"Idempotent\"] = 2] = \"Idempotent\";\n})(MethodIdempotency || (MethodIdempotency = {}));\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { Message } from \"../../message.js\";\nimport { protoInt64 } from \"../../proto-int64.js\";\nimport { proto3 } from \"../../proto3.js\";\n/**\n * A Timestamp represents a point in time independent of any time zone or local\n * calendar, encoded as a count of seconds and fractions of seconds at\n * nanosecond resolution. The count is relative to an epoch at UTC midnight on\n * January 1, 1970, in the proleptic Gregorian calendar which extends the\n * Gregorian calendar backwards to year one.\n *\n * All minutes are 60 seconds long. Leap seconds are \"smeared\" so that no leap\n * second table is needed for interpretation, using a [24-hour linear\n * smear](https://developers.google.com/time/smear).\n *\n * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By\n * restricting to that range, we ensure that we can convert to and from [RFC\n * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings.\n *\n * # Examples\n *\n * Example 1: Compute Timestamp from POSIX `time()`.\n *\n * Timestamp timestamp;\n * timestamp.set_seconds(time(NULL));\n * timestamp.set_nanos(0);\n *\n * Example 2: Compute Timestamp from POSIX `gettimeofday()`.\n *\n * struct timeval tv;\n * gettimeofday(&tv, NULL);\n *\n * Timestamp timestamp;\n * timestamp.set_seconds(tv.tv_sec);\n * timestamp.set_nanos(tv.tv_usec * 1000);\n *\n * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`.\n *\n * FILETIME ft;\n * GetSystemTimeAsFileTime(&ft);\n * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime;\n *\n * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z\n * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z.\n * Timestamp timestamp;\n * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL));\n * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100));\n *\n * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`.\n *\n * long millis = System.currentTimeMillis();\n *\n * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000)\n * .setNanos((int) ((millis % 1000) * 1000000)).build();\n *\n * Example 5: Compute Timestamp from Java `Instant.now()`.\n *\n * Instant now = Instant.now();\n *\n * Timestamp timestamp =\n * Timestamp.newBuilder().setSeconds(now.getEpochSecond())\n * .setNanos(now.getNano()).build();\n *\n * Example 6: Compute Timestamp from current time in Python.\n *\n * timestamp = Timestamp()\n * timestamp.GetCurrentTime()\n *\n * # JSON Mapping\n *\n * In JSON format, the Timestamp type is encoded as a string in the\n * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the\n * format is \"{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z\"\n * where {year} is always expressed using four digits while {month}, {day},\n * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional\n * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution),\n * are optional. The \"Z\" suffix indicates the timezone (\"UTC\"); the timezone\n * is required. A proto3 JSON serializer should always use UTC (as indicated by\n * \"Z\") when printing the Timestamp type and a proto3 JSON parser should be\n * able to accept both UTC and other timezones (as indicated by an offset).\n *\n * For example, \"2017-01-15T01:30:15.01Z\" encodes 15.01 seconds past\n * 01:30 UTC on January 15, 2017.\n *\n * In JavaScript, one can convert a Date object to this format using the\n * standard\n * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)\n * method. In Python, a standard `datetime.datetime` object can be converted\n * to this format using\n * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with\n * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use\n * the Joda Time's [`ISODateTimeFormat.dateTime()`](\n * http://joda-time.sourceforge.net/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime()\n * ) to obtain a formatter capable of generating timestamps in this format.\n *\n *\n * @generated from message google.protobuf.Timestamp\n */\nexport class Timestamp extends Message {\n constructor(data) {\n super();\n /**\n * Represents seconds of UTC time since Unix epoch\n * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to\n * 9999-12-31T23:59:59Z inclusive.\n *\n * @generated from field: int64 seconds = 1;\n */\n this.seconds = protoInt64.zero;\n /**\n * Non-negative fractions of a second at nanosecond resolution. Negative\n * second values with fractions must still have non-negative nanos values\n * that count forward in time. Must be from 0 to 999,999,999\n * inclusive.\n *\n * @generated from field: int32 nanos = 2;\n */\n this.nanos = 0;\n proto3.util.initPartial(data, this);\n }\n fromJson(json, options) {\n if (typeof json !== \"string\") {\n throw new Error(`cannot decode google.protobuf.Timestamp from JSON: ${proto3.json.debug(json)}`);\n }\n const matches = json.match(/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})(?:Z|\\.([0-9]{3,9})Z|([+-][0-9][0-9]:[0-9][0-9]))$/);\n if (!matches) {\n throw new Error(`cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string`);\n }\n const ms = Date.parse(matches[1] + \"-\" + matches[2] + \"-\" + matches[3] + \"T\" + matches[4] + \":\" + matches[5] + \":\" + matches[6] + (matches[8] ? matches[8] : \"Z\"));\n if (Number.isNaN(ms)) {\n throw new Error(`cannot decode google.protobuf.Timestamp from JSON: invalid RFC 3339 string`);\n }\n if (ms < Date.parse(\"0001-01-01T00:00:00Z\") || ms > Date.parse(\"9999-12-31T23:59:59Z\")) {\n throw new Error(`cannot decode message google.protobuf.Timestamp from JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);\n }\n this.seconds = protoInt64.parse(ms / 1000);\n this.nanos = 0;\n if (matches[7]) {\n this.nanos = (parseInt(\"1\" + matches[7] + \"0\".repeat(9 - matches[7].length)) - 1000000000);\n }\n return this;\n }\n toJson(options) {\n const ms = Number(this.seconds) * 1000;\n if (ms < Date.parse(\"0001-01-01T00:00:00Z\") || ms > Date.parse(\"9999-12-31T23:59:59Z\")) {\n throw new Error(`cannot encode google.protobuf.Timestamp to JSON: must be from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59Z inclusive`);\n }\n if (this.nanos < 0) {\n throw new Error(`cannot encode google.protobuf.Timestamp to JSON: nanos must not be negative`);\n }\n let z = \"Z\";\n if (this.nanos > 0) {\n const nanosStr = (this.nanos + 1000000000).toString().substring(1);\n if (nanosStr.substring(3) === \"000000\") {\n z = \".\" + nanosStr.substring(0, 3) + \"Z\";\n }\n else if (nanosStr.substring(6) === \"000\") {\n z = \".\" + nanosStr.substring(0, 6) + \"Z\";\n }\n else {\n z = \".\" + nanosStr + \"Z\";\n }\n }\n return new Date(ms).toISOString().replace(\".000Z\", z);\n }\n toDate() {\n return new Date(Number(this.seconds) * 1000 + Math.ceil(this.nanos / 1000000));\n }\n static now() {\n return Timestamp.fromDate(new Date());\n }\n static fromDate(date) {\n const ms = date.getTime();\n return new Timestamp({\n seconds: protoInt64.parse(Math.floor(ms / 1000)),\n nanos: (ms % 1000) * 1000000,\n });\n }\n static fromBinary(bytes, options) {\n return new Timestamp().fromBinary(bytes, options);\n }\n static fromJson(jsonValue, options) {\n return new Timestamp().fromJson(jsonValue, options);\n }\n static fromJsonString(jsonString, options) {\n return new Timestamp().fromJsonString(jsonString, options);\n }\n static equals(a, b) {\n return proto3.util.equals(Timestamp, a, b);\n }\n}\nTimestamp.runtime = proto3;\nTimestamp.typeName = \"google.protobuf.Timestamp\";\nTimestamp.fields = proto3.util.newFieldList(() => [\n { no: 1, name: \"seconds\", kind: \"scalar\", T: 3 /* ScalarType.INT64 */ },\n { no: 2, name: \"nanos\", kind: \"scalar\", T: 5 /* ScalarType.INT32 */ },\n]);\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { Message } from \"../../message.js\";\nimport { protoInt64 } from \"../../proto-int64.js\";\nimport { proto3 } from \"../../proto3.js\";\n/**\n * A Duration represents a signed, fixed-length span of time represented\n * as a count of seconds and fractions of seconds at nanosecond\n * resolution. It is independent of any calendar and concepts like \"day\"\n * or \"month\". It is related to Timestamp in that the difference between\n * two Timestamp values is a Duration and it can be added or subtracted\n * from a Timestamp. Range is approximately +-10,000 years.\n *\n * # Examples\n *\n * Example 1: Compute Duration from two Timestamps in pseudo code.\n *\n * Timestamp start = ...;\n * Timestamp end = ...;\n * Duration duration = ...;\n *\n * duration.seconds = end.seconds - start.seconds;\n * duration.nanos = end.nanos - start.nanos;\n *\n * if (duration.seconds < 0 && duration.nanos > 0) {\n * duration.seconds += 1;\n * duration.nanos -= 1000000000;\n * } else if (duration.seconds > 0 && duration.nanos < 0) {\n * duration.seconds -= 1;\n * duration.nanos += 1000000000;\n * }\n *\n * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code.\n *\n * Timestamp start = ...;\n * Duration duration = ...;\n * Timestamp end = ...;\n *\n * end.seconds = start.seconds + duration.seconds;\n * end.nanos = start.nanos + duration.nanos;\n *\n * if (end.nanos < 0) {\n * end.seconds -= 1;\n * end.nanos += 1000000000;\n * } else if (end.nanos >= 1000000000) {\n * end.seconds += 1;\n * end.nanos -= 1000000000;\n * }\n *\n * Example 3: Compute Duration from datetime.timedelta in Python.\n *\n * td = datetime.timedelta(days=3, minutes=10)\n * duration = Duration()\n * duration.FromTimedelta(td)\n *\n * # JSON Mapping\n *\n * In JSON format, the Duration type is encoded as a string rather than an\n * object, where the string ends in the suffix \"s\" (indicating seconds) and\n * is preceded by the number of seconds, with nanoseconds expressed as\n * fractional seconds. For example, 3 seconds with 0 nanoseconds should be\n * encoded in JSON format as \"3s\", while 3 seconds and 1 nanosecond should\n * be expressed in JSON format as \"3.000000001s\", and 3 seconds and 1\n * microsecond should be expressed in JSON format as \"3.000001s\".\n *\n *\n * @generated from message google.protobuf.Duration\n */\nexport class Duration extends Message {\n constructor(data) {\n super();\n /**\n * Signed seconds of the span of time. Must be from -315,576,000,000\n * to +315,576,000,000 inclusive. Note: these bounds are computed from:\n * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years\n *\n * @generated from field: int64 seconds = 1;\n */\n this.seconds = protoInt64.zero;\n /**\n * Signed fractions of a second at nanosecond resolution of the span\n * of time. Durations less than one second are represented with a 0\n * `seconds` field and a positive or negative `nanos` field. For durations\n * of one second or more, a non-zero value for the `nanos` field must be\n * of the same sign as the `seconds` field. Must be from -999,999,999\n * to +999,999,999 inclusive.\n *\n * @generated from field: int32 nanos = 2;\n */\n this.nanos = 0;\n proto3.util.initPartial(data, this);\n }\n fromJson(json, options) {\n if (typeof json !== \"string\") {\n throw new Error(`cannot decode google.protobuf.Duration from JSON: ${proto3.json.debug(json)}`);\n }\n const match = json.match(/^(-?[0-9]+)(?:\\.([0-9]+))?s/);\n if (match === null) {\n throw new Error(`cannot decode google.protobuf.Duration from JSON: ${proto3.json.debug(json)}`);\n }\n const longSeconds = Number(match[1]);\n if (longSeconds > 315576000000 || longSeconds < -315576000000) {\n throw new Error(`cannot decode google.protobuf.Duration from JSON: ${proto3.json.debug(json)}`);\n }\n this.seconds = protoInt64.parse(longSeconds);\n if (typeof match[2] == \"string\") {\n const nanosStr = match[2] + \"0\".repeat(9 - match[2].length);\n this.nanos = parseInt(nanosStr);\n if (longSeconds < 0 || Object.is(longSeconds, -0)) {\n this.nanos = -this.nanos;\n }\n }\n return this;\n }\n toJson(options) {\n if (Number(this.seconds) > 315576000000 || Number(this.seconds) < -315576000000) {\n throw new Error(`cannot encode google.protobuf.Duration to JSON: value out of range`);\n }\n let text = this.seconds.toString();\n if (this.nanos !== 0) {\n let nanosStr = Math.abs(this.nanos).toString();\n nanosStr = \"0\".repeat(9 - nanosStr.length) + nanosStr;\n if (nanosStr.substring(3) === \"000000\") {\n nanosStr = nanosStr.substring(0, 3);\n }\n else if (nanosStr.substring(6) === \"000\") {\n nanosStr = nanosStr.substring(0, 6);\n }\n text += \".\" + nanosStr;\n if (this.nanos < 0 && Number(this.seconds) == 0) {\n text = \"-\" + text;\n }\n }\n return text + \"s\";\n }\n static fromBinary(bytes, options) {\n return new Duration().fromBinary(bytes, options);\n }\n static fromJson(jsonValue, options) {\n return new Duration().fromJson(jsonValue, options);\n }\n static fromJsonString(jsonString, options) {\n return new Duration().fromJsonString(jsonString, options);\n }\n static equals(a, b) {\n return proto3.util.equals(Duration, a, b);\n }\n}\nDuration.runtime = proto3;\nDuration.typeName = \"google.protobuf.Duration\";\nDuration.fields = proto3.util.newFieldList(() => [\n { no: 1, name: \"seconds\", kind: \"scalar\", T: 3 /* ScalarType.INT64 */ },\n { no: 2, name: \"nanos\", kind: \"scalar\", T: 5 /* ScalarType.INT32 */ },\n]);\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { Message } from \"../../message.js\";\nimport { proto3 } from \"../../proto3.js\";\n/**\n * `Any` contains an arbitrary serialized protocol buffer message along with a\n * URL that describes the type of the serialized message.\n *\n * Protobuf library provides support to pack/unpack Any values in the form\n * of utility functions or additional generated methods of the Any type.\n *\n * Example 1: Pack and unpack a message in C++.\n *\n * Foo foo = ...;\n * Any any;\n * any.PackFrom(foo);\n * ...\n * if (any.UnpackTo(&foo)) {\n * ...\n * }\n *\n * Example 2: Pack and unpack a message in Java.\n *\n * Foo foo = ...;\n * Any any = Any.pack(foo);\n * ...\n * if (any.is(Foo.class)) {\n * foo = any.unpack(Foo.class);\n * }\n * // or ...\n * if (any.isSameTypeAs(Foo.getDefaultInstance())) {\n * foo = any.unpack(Foo.getDefaultInstance());\n * }\n *\n * Example 3: Pack and unpack a message in Python.\n *\n * foo = Foo(...)\n * any = Any()\n * any.Pack(foo)\n * ...\n * if any.Is(Foo.DESCRIPTOR):\n * any.Unpack(foo)\n * ...\n *\n * Example 4: Pack and unpack a message in Go\n *\n * foo := &pb.Foo{...}\n * any, err := anypb.New(foo)\n * if err != nil {\n * ...\n * }\n * ...\n * foo := &pb.Foo{}\n * if err := any.UnmarshalTo(foo); err != nil {\n * ...\n * }\n *\n * The pack methods provided by protobuf library will by default use\n * 'type.googleapis.com/full.type.name' as the type URL and the unpack\n * methods only use the fully qualified type name after the last '/'\n * in the type URL, for example \"foo.bar.com/x/y.z\" will yield type\n * name \"y.z\".\n *\n * JSON\n * ====\n * The JSON representation of an `Any` value uses the regular\n * representation of the deserialized, embedded message, with an\n * additional field `@type` which contains the type URL. Example:\n *\n * package google.profile;\n * message Person {\n * string first_name = 1;\n * string last_name = 2;\n * }\n *\n * {\n * \"@type\": \"type.googleapis.com/google.profile.Person\",\n * \"firstName\": <string>,\n * \"lastName\": <string>\n * }\n *\n * If the embedded message type is well-known and has a custom JSON\n * representation, that representation will be embedded adding a field\n * `value` which holds the custom JSON in addition to the `@type`\n * field. Example (for message [google.protobuf.Duration][]):\n *\n * {\n * \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n * \"value\": \"1.212s\"\n * }\n *\n *\n * @generated from message google.protobuf.Any\n */\nexport class Any extends Message {\n constructor(data) {\n super();\n /**\n * A URL/resource name that uniquely identifies the type of the serialized\n * protocol buffer message. This string must contain at least\n * one \"/\" character. The last segment of the URL's path must represent\n * the fully qualified name of the type (as in\n * `path/google.protobuf.Duration`). The name should be in a canonical form\n * (e.g., leading \".\" is not accepted).\n *\n * In practice, teams usually precompile into the binary all types that they\n * expect it to use in the context of Any. However, for URLs which use the\n * scheme `http`, `https`, or no scheme, one can optionally set up a type\n * server that maps type URLs to message definitions as follows:\n *\n * * If no scheme is provided, `https` is assumed.\n * * An HTTP GET on the URL must yield a [google.protobuf.Type][]\n * value in binary format, or produce an error.\n * * Applications are allowed to cache lookup results based on the\n * URL, or have them precompiled into a binary to avoid any\n * lookup. Therefore, binary compatibility needs to be preserved\n * on changes to types. (Use versioned type names to manage\n * breaking changes.)\n *\n * Note: this functionality is not currently available in the official\n * protobuf release, and it is not used for type URLs beginning with\n * type.googleapis.com. As of May 2023, there are no widely used type server\n * implementations and no plans to implement one.\n *\n * Schemes other than `http`, `https` (or the empty scheme) might be\n * used with implementation specific semantics.\n *\n *\n * @generated from field: string type_url = 1;\n */\n this.typeUrl = \"\";\n /**\n * Must be a valid serialized protocol buffer of the above specified type.\n *\n * @generated from field: bytes value = 2;\n */\n this.value = new Uint8Array(0);\n proto3.util.initPartial(data, this);\n }\n toJson(options) {\n var _a;\n if (this.typeUrl === \"\") {\n return {};\n }\n const typeName = this.typeUrlToName(this.typeUrl);\n const messageType = (_a = options === null || options === void 0 ? void 0 : options.typeRegistry) === null || _a === void 0 ? void 0 : _a.findMessage(typeName);\n if (!messageType) {\n throw new Error(`cannot encode message google.protobuf.Any to JSON: \"${this.typeUrl}\" is not in the type registry`);\n }\n const message = messageType.fromBinary(this.value);\n let json = message.toJson(options);\n if (typeName.startsWith(\"google.protobuf.\") || (json === null || Array.isArray(json) || typeof json !== \"object\")) {\n json = { value: json };\n }\n json[\"@type\"] = this.typeUrl;\n return json;\n }\n fromJson(json, options) {\n var _a;\n if (json === null || Array.isArray(json) || typeof json != \"object\") {\n throw new Error(`cannot decode message google.protobuf.Any from JSON: expected object but got ${json === null ? \"null\" : Array.isArray(json) ? \"array\" : typeof json}`);\n }\n if (Object.keys(json).length == 0) {\n return this;\n }\n const typeUrl = json[\"@type\"];\n if (typeof typeUrl != \"string\" || typeUrl == \"\") {\n throw new Error(`cannot decode message google.protobuf.Any from JSON: \"@type\" is empty`);\n }\n const typeName = this.typeUrlToName(typeUrl), messageType = (_a = options === null || options === void 0 ? void 0 : options.typeRegistry) === null || _a === void 0 ? void 0 : _a.findMessage(typeName);\n if (!messageType) {\n throw new Error(`cannot decode message google.protobuf.Any from JSON: ${typeUrl} is not in the type registry`);\n }\n let message;\n if (typeName.startsWith(\"google.protobuf.\") && Object.prototype.hasOwnProperty.call(json, \"value\")) {\n message = messageType.fromJson(json[\"value\"], options);\n }\n else {\n const copy = Object.assign({}, json);\n delete copy[\"@type\"];\n message = messageType.fromJson(copy, options);\n }\n this.packFrom(message);\n return this;\n }\n packFrom(message) {\n this.value = message.toBinary();\n this.typeUrl = this.typeNameToUrl(message.getType().typeName);\n }\n unpackTo(target) {\n if (!this.is(target.getType())) {\n return false;\n }\n target.fromBinary(this.value);\n return true;\n }\n unpack(registry) {\n if (this.typeUrl === \"\") {\n return undefined;\n }\n const messageType = registry.findMessage(this.typeUrlToName(this.typeUrl));\n if (!messageType) {\n return undefined;\n }\n return messageType.fromBinary(this.value);\n }\n is(type) {\n if (this.typeUrl === '') {\n return false;\n }\n const name = this.typeUrlToName(this.typeUrl);\n let typeName = '';\n if (typeof type === 'string') {\n typeName = type;\n }\n else {\n typeName = type.typeName;\n }\n return name === typeName;\n }\n typeNameToUrl(name) {\n return `type.googleapis.com/${name}`;\n }\n typeUrlToName(url) {\n if (!url.length) {\n throw new Error(`invalid type url: ${url}`);\n }\n const slash = url.lastIndexOf(\"/\");\n const name = slash >= 0 ? url.substring(slash + 1) : url;\n if (!name.length) {\n throw new Error(`invalid type url: ${url}`);\n }\n return name;\n }\n static pack(message) {\n const any = new Any();\n any.packFrom(message);\n return any;\n }\n static fromBinary(bytes, options) {\n return new Any().fromBinary(bytes, options);\n }\n static fromJson(jsonValue, options) {\n return new Any().fromJson(jsonValue, options);\n }\n static fromJsonString(jsonString, options) {\n return new Any().fromJsonString(jsonString, options);\n }\n static equals(a, b) {\n return proto3.util.equals(Any, a, b);\n }\n}\nAny.runtime = proto3;\nAny.typeName = \"google.protobuf.Any\";\nAny.fields = proto3.util.newFieldList(() => [\n { no: 1, name: \"type_url\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"value\", kind: \"scalar\", T: 12 /* ScalarType.BYTES */ },\n]);\n","// Copyright 2021-2024 Buf Technologies, Inc.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { Message } from \"../../message.js\";\nimport { proto3 } from \"../../proto3.js\";\nimport { ScalarType } from \"../../scalar.js\";\nimport { protoInt64 } from \"../../proto-int64.js\";\n/**\n * Wrapper message for `double`.\n *\n * The JSON representation for `DoubleValue` is JSON number.\n *\n * @generated from message google.protobuf.DoubleValue\n */\nexport class DoubleValue extends Message {\n constructor(data) {\n super();\n /**\n * The double value.\n *\n * @generated from field: double value = 1;\n */\n this.value = 0;\n proto3.util.initPartial(data, this);\n }\n toJson(options) {\n return proto3.json.writeScalar(ScalarType.DOUBLE, this.value, true);\n }\n fromJson(json, options) {\n try {\n this.value = proto3.json.readScalar(ScalarType.DOUBLE, json);\n }\n catch (e) {\n let m = `cannot decode message google.protobuf.DoubleValue from JSON\"`;\n if (e instanceof Error && e.message.length > 0) {\n m += `: ${e.message}`;\n }\n throw new Error(m);\n }\n return this;\n }\n static fromBinary(bytes, options) {\n return new DoubleValue().fromBinary(bytes, options);\n }\n static fromJson(jsonValue, options) {\n return new DoubleValue().fromJson(jsonValue, options);\n }\n static fromJsonString(jsonString, options) {\n return new DoubleValue().fromJsonString(jsonString, options);\n }\n static equals(a, b) {\n return proto3.util.equals(DoubleValue, a, b);\n }\n}\nDoubleValue.runtime = proto3;\nDoubleValue.typeName = \"google.protobuf.DoubleValue\";\nDoubleValue.fields = proto3.util.newFieldList(() => [\n { no: 1, name: \"value\", kind: \"scalar\", T: 1 /* ScalarType.DOUBLE */ },\n]);\nDoubleValue.fieldWrapper = {\n wrapField(value) {\n return new DoubleValue({ value });\n },\n unwrapField(value) {\n return value.value;\n }\n};\n/**\n * Wrapper message for `float`.\n *\n * The JSON representation for `FloatValue` is JSON number.\n *\n * @generated from message google.protobuf.FloatValue\n */\nexport class FloatValue extends Message {\n constructor(data) {\n super();\n /**\n * The float value.\n *\n * @generated from field: float value = 1;\n */\n this.value = 0;\n proto3.util.initPartial(data, this);\n }\n toJson(options) {\n return proto3.json.writeScalar(ScalarType.FLOAT, this.value, true);\n }\n fromJson(json, options) {\n try {\n this.value = proto3.json.readScalar(ScalarType.FLOAT, json);\n }\n catch (e) {\n let m = `cannot decode message google.protobuf.FloatValue from JSON\"`;\n if (e instanceof Error && e.message.length > 0) {\n m += `: ${e.message}`;\n }\n throw new Error(m);\n }\n return this;\n }\n static fromBinary(bytes, options) {\n return new FloatValue().fromBinary(bytes, options);\n }\n static fromJson(jsonValue, options) {\n return new FloatValue().fromJson(jsonValue, options);\n }\n static fromJsonString(jsonString, options) {\n return new FloatValue().fromJsonString(jsonString, options);\n }\n static equals(a, b) {\n return proto3.util.equals(FloatValue, a, b);\n }\n}\nFloatValue.runtime = proto3;\nFloatValue.typeName = \"google.protobuf.FloatValue\";\nFloatValue.fields = proto3.util.newFieldList(() => [\n { no: 1, name: \"value\", kind: \"scalar\", T: 2 /* ScalarType.FLOAT */ },\n]);\nFloatValue.fieldWrapper = {\n wrapField(value) {\n return new FloatValue({ value });\n },\n unwrapField(value) {\n return value.value;\n }\n};\n/**\n * Wrapper message for `int64`.\n *\n * The JSON representation for `Int64Value` is JSON string.\n *\n * @generated from message google.protobuf.Int64Value\n */\nexport class Int64Value extends Message {\n constructor(data) {\n super();\n /**\n * The int64 value.\n *\n * @generated from field: int64 value = 1;\n */\n this.value = protoInt64.zero;\n proto3.util.initPartial(data, this);\n }\n toJson(options) {\n return proto3.json.writeScalar(ScalarType.INT64, this.value, true);\n }\n fromJson(json, options) {\n try {\n this.value = proto3.json.readScalar(ScalarType.INT64, json);\n }\n catch (e) {\n let m = `cannot decode message google.protobuf.Int64Value from JSON\"`;\n if (e instanceof Error && e.message.length > 0) {\n m += `: ${e.message}`;\n }\n throw new Error(m);\n }\n return this;\n }\n static fromBinary(bytes, options) {\n return new Int64Value().fromBinary(bytes, options);\n }\n static fromJson(jsonValue, options) {\n return new Int64Value().fromJson(jsonValue, options);\n }\n static fromJsonString(jsonString, options) {\n return new Int64Value().fromJsonString(jsonString, options);\n }\n static equals(a, b) {\n return proto3.util.equals(Int64Value, a, b);\n }\n}\nInt64Value.runtime = proto3;\nInt64Value.typeName = \"google.protobuf.Int64Value\";\nInt64Value.fields = proto3.util.newFieldList(() => [\n { no: 1, name: \"value\", kind: \"scalar\", T: 3 /* ScalarType.INT64 */ },\n]);\nInt64Value.fieldWrapper = {\n wrapField(value) {\n return new Int64Value({ value });\n },\n unwrapField(value) {\n return value.value;\n }\n};\n/**\n * Wrapper message for `uint64`.\n *\n * The JSON representation for `UInt64Value` is JSON string.\n *\n * @generated from message google.protobuf.UInt64Value\n */\nexport class UInt64Value extends Message {\n constructor(data) {\n super();\n /**\n * The uint64 value.\n *\n * @generated from field: uint64 value = 1;\n */\n this.value = protoInt64.zero;\n proto3.util.initPartial(data, this);\n }\n toJson(options) {\n return proto3.json.writeScalar(ScalarType.UINT64, this.value, true);\n }\n fromJson(json, options) {\n try {\n this.value = proto3.json.readScalar(ScalarType.UINT64, json);\n }\n catch (e) {\n let m = `cannot decode message google.protobuf.UInt64Value from JSON\"`;\n if (e instanceof Error && e.message.length > 0) {\n m += `: ${e.message}`;\n }\n throw new Error(m);\n }\n return this;\n }\n static fromBinary(bytes, options) {\n return new UInt64Value().fromBinary(bytes, options);\n }\n static fromJson(jsonValue, options) {\n return new UInt64Value().fromJson(jsonValue, options);\n }\n static fromJsonString(jsonString, options) {\n return new UInt64Value().fromJsonString(jsonString, options);\n }\n static equals(a, b) {\n return proto3.util.equals(UInt64Value, a, b);\n }\n}\nUInt64Value.runtime = proto3;\nUInt64Value.typeName = \"google.protobuf.UInt64Value\";\nUInt64Value.fields = proto3.util.newFieldList(() => [\n { no: 1, name: \"value\", kind: \"scalar\", T: 4 /* ScalarType.UINT64 */ },\n]);\nUInt64Value.fieldWrapper = {\n wrapField(value) {\n return new UInt64Value({ value });\n },\n unwrapField(value) {\n return value.value;\n }\n};\n/**\n * Wrapper message for `int32`.\n *\n * The JSON representation for `Int32Value` is JSON number.\n *\n * @generated from message google.protobuf.Int32Value\n */\nexport class Int32Value extends Message {\n constructor(data) {\n super();\n /**\n * The int32 value.\n *\n * @generated from field: int32 value = 1;\n */\n this.value = 0;\n proto3.util.initPartial(data, this);\n }\n toJson(options) {\n return proto3.json.writeScalar(ScalarType.INT32, this.value, true);\n }\n fromJson(json, options) {\n try {\n this.value = proto3.json.readScalar(ScalarType.INT32, json);\n }\n catch (e) {\n let m = `cannot decode message google.protobuf.Int32Value from JSON\"`;\n if (e instanceof Error && e.message.length > 0) {\n m += `: ${e.message}`;\n }\n throw new Error(m);\n }\n return this;\n }\n static fromBinary(bytes, options) {\n return new Int32Value().fromBinary(bytes, options);\n }\n static fromJson(jsonValue, options) {\n return new Int32Value().fromJson(jsonValue, options);\n }\n static fromJsonString(jsonString, options) {\n return new Int32Value().fromJsonString(jsonString, options);\n }\n static equals(a, b) {\n return proto3.util.equals(Int32Value, a, b);\n }\n}\nInt32Value.runtime = proto3;\nInt32Value.typeName = \"google.protobuf.Int32Value\";\nInt32Value.fields = proto3.util.newFieldList(() => [\n { no: 1, name: \"value\", kind: \"scalar\", T: 5 /* ScalarType.INT32 */ },\n]);\nInt32Value.fieldWrapper = {\n wrapField(value) {\n return new Int32Value({ value });\n },\n unwrapField(value) {\n return value.value;\n }\n};\n/**\n * Wrapper message for `uint32`.\n *\n * The JSON representation for `UInt32Value` is JSON number.\n *\n * @generated from message google.protobuf.UInt32Value\n */\nexport class UInt32Value extends Message {\n constructor(data) {\n super();\n /**\n * The uint32 value.\n *\n * @generated from field: uint32 value = 1;\n */\n this.value = 0;\n proto3.util.initPartial(data, this);\n }\n toJson(options) {\n return proto3.json.writeScalar(ScalarType.UINT32, this.value, true);\n }\n fromJson(json, options) {\n try {\n this.value = proto3.json.readScalar(ScalarType.UINT32, json);\n }\n catch (e) {\n let m = `cannot decode message google.protobuf.UInt32Value from JSON\"`;\n if (e instanceof Error && e.message.length > 0) {\n m += `: ${e.message}`;\n }\n throw new Error(m);\n }\n return this;\n }\n static fromBinary(bytes, options) {\n return new UInt32Value().fromBinary(bytes, options);\n }\n static fromJson(jsonValue, options) {\n return new UInt32Value().fromJson(jsonValue, options);\n }\n static fromJsonString(jsonString, options) {\n return new UInt32Value().fromJsonString(jsonString, options);\n }\n static equals(a, b) {\n return proto3.util.equals(UInt32Value, a, b);\n }\n}\nUInt32Value.runtime = proto3;\nUInt32Value.typeName = \"google.protobuf.UInt32Value\";\nUInt32Value.fields = proto3.util.newFieldList(() => [\n { no: 1, name: \"value\", kind: \"scalar\", T: 13 /* ScalarType.UINT32 */ },\n]);\nUInt32Value.fieldWrapper = {\n wrapField(value) {\n return new UInt32Value({ value });\n },\n unwrapField(value) {\n return value.value;\n }\n};\n/**\n * Wrapper message for `bool`.\n *\n * The JSON representation for `BoolValue` is JSON `true` and `false`.\n *\n * @generated from message google.protobuf.BoolValue\n */\nexport class BoolValue extends Message {\n constructor(data) {\n super();\n /**\n * The bool value.\n *\n * @generated from field: bool value = 1;\n */\n this.value = false;\n proto3.util.initPartial(data, this);\n }\n toJson(options) {\n return proto3.json.writeScalar(ScalarType.BOOL, this.value, true);\n }\n fromJson(json, options) {\n try {\n this.value = proto3.json.readScalar(ScalarType.BOOL, json);\n }\n catch (e) {\n let m = `cannot decode message google.protobuf.BoolValue from JSON\"`;\n if (e instanceof Error && e.message.length > 0) {\n m += `: ${e.message}`;\n }\n throw new Error(m);\n }\n return this;\n }\n static fromBinary(bytes, options) {\n return new BoolValue().fromBinary(bytes, options);\n }\n static fromJson(jsonValue, options) {\n return new BoolValue().fromJson(jsonValue, options);\n }\n static fromJsonString(jsonString, options) {\n return new BoolValue().fromJsonString(jsonString, options);\n }\n static equals(a, b) {\n return proto3.util.equals(BoolValue, a, b);\n }\n}\nBoolValue.runtime = proto3;\nBoolValue.typeName = \"google.protobuf.BoolValue\";\nBoolValue.fields = proto3.util.newFieldList(() => [\n { no: 1, name: \"value\", kind: \"scalar\", T: 8 /* ScalarType.BOOL */ },\n]);\nBoolValue.fieldWrapper = {\n wrapField(value) {\n return new BoolValue({ value });\n },\n unwrapField(value) {\n return value.value;\n }\n};\n/**\n * Wrapper message for `string`.\n *\n * The JSON representation for `StringValue` is JSON string.\n *\n * @generated from message google.protobuf.StringValue\n */\nexport class StringValue extends Message {\n constructor(data) {\n super();\n /**\n * The string value.\n *\n * @generated from field: string value = 1;\n */\n this.value = \"\";\n proto3.util.initPartial(data, this);\n }\n toJson(options) {\n return proto3.json.writeScalar(ScalarType.STRING, this.value, true);\n }\n fromJson(json, options) {\n try {\n this.value = proto3.json.readScalar(ScalarType.STRING, json);\n }\n catch (e) {\n let m = `cannot decode message google.protobuf.StringValue from JSON\"`;\n if (e instanceof Error && e.message.length > 0) {\n m += `: ${e.message}`;\n }\n throw new Error(m);\n }\n return this;\n }\n static fromBinary(bytes, options) {\n return new StringValue().fromBinary(bytes, options);\n }\n static fromJson(jsonValue, options) {\n return new StringValue().fromJson(jsonValue, options);\n }\n static fromJsonString(jsonString, options) {\n return new StringValue().fromJsonString(jsonString, options);\n }\n static equals(a, b) {\n return proto3.util.equals(StringValue, a, b);\n }\n}\nStringValue.runtime = proto3;\nStringValue.typeName = \"google.protobuf.StringValue\";\nStringValue.fields = proto3.util.newFieldList(() => [\n { no: 1, name: \"value\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n]);\nStringValue.fieldWrapper = {\n wrapField(value) {\n return new StringValue({ value });\n },\n unwrapField(value) {\n return value.value;\n }\n};\n/**\n * Wrapper message for `bytes`.\n *\n * The JSON representation for `BytesValue` is JSON string.\n *\n * @generated from message google.protobuf.BytesValue\n */\nexport class BytesValue extends Message {\n constructor(data) {\n super();\n /**\n * The bytes value.\n *\n * @generated from field: bytes value = 1;\n */\n this.value = new Uint8Array(0);\n proto3.util.initPartial(data, this);\n }\n toJson(options) {\n return proto3.json.writeScalar(ScalarType.BYTES, this.value, true);\n }\n fromJson(json, options) {\n try {\n this.value = proto3.json.readScalar(ScalarType.BYTES, json);\n }\n catch (e) {\n let m = `cannot decode message google.protobuf.BytesValue from JSON\"`;\n if (e instanceof Error && e.message.length > 0) {\n m += `: ${e.message}`;\n }\n throw new Error(m);\n }\n return this;\n }\n static fromBinary(bytes, options) {\n return new BytesValue().fromBinary(bytes, options);\n }\n static fromJson(jsonValue, options) {\n return new BytesValue().fromJson(jsonValue, options);\n }\n static fromJsonString(jsonString, options) {\n return new BytesValue().fromJsonString(jsonString, options);\n }\n static equals(a, b) {\n return proto3.util.equals(BytesValue, a, b);\n }\n}\nBytesValue.runtime = proto3;\nBytesValue.typeName = \"google.protobuf.BytesValue\";\nBytesValue.fields = proto3.util.newFieldList(() => [\n { no: 1, name: \"value\", kind: \"scalar\", T: 12 /* ScalarType.BYTES */ },\n]);\nBytesValue.fieldWrapper = {\n wrapField(value) {\n return new BytesValue({ value });\n },\n unwrapField(value) {\n return value.value;\n }\n};\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { protoBase64 } from \"@bufbuild/protobuf\";\nimport { ConnectError } from \"./connect-error.js\";\nimport { Code } from \"./code.js\";\n/**\n * Encode a single binary header value according to the Connect\n * and gRPC specifications.\n *\n * This function accepts raw binary data from a buffer, a string\n * with UTF-8 text, or a protobuf message. It encodes the input\n * with unpadded base64 and returns a string that can be used for\n * a header whose name ends with `-bin`.\n */\nexport function encodeBinaryHeader(value) {\n let bytes;\n if (typeof value == \"object\" && \"getType\" in value) {\n bytes = value.toBinary();\n }\n else if (typeof value == \"string\") {\n bytes = new TextEncoder().encode(value);\n }\n else {\n bytes = value instanceof Uint8Array ? value : new Uint8Array(value);\n }\n return protoBase64.enc(bytes).replace(/=+$/, \"\");\n}\nexport function decodeBinaryHeader(value, type, options) {\n try {\n const bytes = protoBase64.dec(value);\n if (type) {\n return type.fromBinary(bytes, options);\n }\n return bytes;\n }\n catch (e) {\n throw ConnectError.from(e, Code.DataLoss);\n }\n}\n/**\n * Merge two or more Headers objects by appending all fields from\n * all inputs to a new Headers object.\n */\nexport function appendHeaders(...headers) {\n const h = new Headers();\n for (const e of headers) {\n e.forEach((value, key) => {\n h.append(key, value);\n });\n }\n return h;\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n/**\n * Create any client for the given service.\n *\n * The given createMethod function is called for each method definition\n * of the service. The function it returns is added to the client object\n * as a method.\n */\nexport function makeAnyClient(service, createMethod) {\n const client = {};\n for (const [localName, methodInfo] of Object.entries(service.methods)) {\n const method = createMethod(Object.assign(Object.assign({}, methodInfo), { localName,\n service }));\n if (method != null) {\n client[localName] = method;\n }\n }\n return client;\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { ConnectError } from \"../connect-error.js\";\nimport { Code } from \"../code.js\";\nimport { compressedFlag } from \"./compression.js\";\n/**\n * Create a WHATWG ReadableStream of enveloped messages from a ReadableStream\n * of bytes.\n *\n * Ideally, this would simply be a TransformStream, but ReadableStream.pipeThrough\n * does not have the necessary availability at this time.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function createEnvelopeReadableStream(stream) {\n let reader;\n let buffer = new Uint8Array(0);\n function append(chunk) {\n const n = new Uint8Array(buffer.length + chunk.length);\n n.set(buffer);\n n.set(chunk, buffer.length);\n buffer = n;\n }\n return new ReadableStream({\n start() {\n reader = stream.getReader();\n },\n async pull(controller) {\n let header = undefined;\n for (;;) {\n if (header === undefined && buffer.byteLength >= 5) {\n let length = 0;\n for (let i = 1; i < 5; i++) {\n length = (length << 8) + buffer[i];\n }\n header = { flags: buffer[0], length };\n }\n if (header !== undefined && buffer.byteLength >= header.length + 5) {\n break;\n }\n const result = await reader.read();\n if (result.done) {\n break;\n }\n append(result.value);\n }\n if (header === undefined) {\n if (buffer.byteLength == 0) {\n controller.close();\n return;\n }\n controller.error(new ConnectError(\"premature end of stream\", Code.DataLoss));\n return;\n }\n const data = buffer.subarray(5, 5 + header.length);\n buffer = buffer.subarray(5 + header.length);\n controller.enqueue({\n flags: header.flags,\n data,\n });\n },\n });\n}\n/**\n * Compress an EnvelopedMessage.\n *\n * Raises Internal if an enveloped message is already compressed.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport async function envelopeCompress(envelope, compression, compressMinBytes) {\n let { flags, data } = envelope;\n if ((flags & compressedFlag) === compressedFlag) {\n throw new ConnectError(\"invalid envelope, already compressed\", Code.Internal);\n }\n if (compression && data.byteLength >= compressMinBytes) {\n data = await compression.compress(data);\n flags = flags | compressedFlag;\n }\n return { data, flags };\n}\n/**\n * Decompress an EnvelopedMessage.\n *\n * Raises InvalidArgument if an envelope is compressed, but compression is null.\n *\n * Relies on the provided Compression to raise ResourceExhausted if the\n * *decompressed* message size is larger than readMaxBytes. If the envelope is\n * not compressed, readMaxBytes is not honored.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport async function envelopeDecompress(envelope, compression, readMaxBytes) {\n let { flags, data } = envelope;\n if ((flags & compressedFlag) === compressedFlag) {\n if (!compression) {\n throw new ConnectError(\"received compressed envelope, but do not know how to decompress\", Code.InvalidArgument);\n }\n data = await compression.decompress(data, readMaxBytes);\n flags = flags ^ compressedFlag;\n }\n return { data, flags };\n}\n/**\n * Encode a single enveloped message.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function encodeEnvelope(flags, data) {\n const bytes = new Uint8Array(data.length + 5);\n bytes.set(data, 5);\n const v = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);\n v.setUint8(0, flags); // first byte is flags\n v.setUint32(1, data.length); // 4 bytes message length\n return bytes;\n}\n/**\n * Encode a set of enveloped messages.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function encodeEnvelopes(...envelopes) {\n const len = envelopes.reduce((previousValue, currentValue) => previousValue + currentValue.data.length + 5, 0);\n const bytes = new Uint8Array(len);\n const v = new DataView(bytes.buffer);\n let offset = 0;\n for (const e of envelopes) {\n v.setUint8(offset, e.flags); // first byte is flags\n v.setUint32(offset + 1, e.data.length); // 4 bytes message length\n bytes.set(e.data, offset + 5);\n offset += e.data.length + 5;\n }\n return bytes;\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nvar __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n};\nvar __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }\nvar __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n};\nvar __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n};\nimport { Code } from \"../code.js\";\nimport { ConnectError } from \"../connect-error.js\";\nimport { encodeEnvelope, envelopeCompress, envelopeDecompress, } from \"./envelope.js\";\nimport { assertReadMaxBytes } from \"./limit-io.js\";\nexport function pipeTo(source, ...rest) {\n const [transforms, sink, opt] = pickTransformsAndSink(rest);\n let iterable = source;\n let abortable;\n if ((opt === null || opt === void 0 ? void 0 : opt.propagateDownStreamError) === true) {\n iterable = abortable = makeIterableAbortable(iterable);\n }\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n iterable = pipe(iterable, ...transforms, { propagateDownStreamError: false });\n return sink(iterable).catch((reason) => {\n if (abortable) {\n return abortable.abort(reason).then(() => Promise.reject(reason));\n }\n return Promise.reject(reason);\n });\n}\n// pick transforms, the sink, and options from the pipeTo() rest parameter\nfunction pickTransformsAndSink(rest) {\n let opt;\n if (typeof rest[rest.length - 1] != \"function\") {\n opt = rest.pop();\n }\n const sink = rest.pop();\n return [rest, sink, opt];\n}\n/**\n * Creates an AsyncIterableSink that concatenates all elements from the input.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function sinkAll() {\n return async function (iterable) {\n var _a, e_1, _b, _c;\n const all = [];\n try {\n for (var _d = true, iterable_1 = __asyncValues(iterable), iterable_1_1; iterable_1_1 = await iterable_1.next(), _a = iterable_1_1.done, !_a; _d = true) {\n _c = iterable_1_1.value;\n _d = false;\n const chunk = _c;\n all.push(chunk);\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (!_d && !_a && (_b = iterable_1.return)) await _b.call(iterable_1);\n }\n finally { if (e_1) throw e_1.error; }\n }\n return all;\n };\n}\n/**\n * Creates an AsyncIterableSink that concatenates all chunks from the input into\n * a single Uint8Array.\n *\n * The iterable raises an error if the more than readMaxBytes are read.\n *\n * An optional length hint can be provided to optimize allocation and validation.\n * If more or less bytes are present in the source that the length hint indicates,\n * and error is raised.\n * If the length hint is larger than readMaxBytes, an error is raised.\n * If the length hint is not a positive integer, it is ignored.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function sinkAllBytes(readMaxBytes, lengthHint) {\n return async function (iterable) {\n return await readAllBytes(iterable, readMaxBytes, lengthHint);\n };\n}\nexport function pipe(source, ...rest) {\n var _a;\n return __asyncGenerator(this, arguments, function* pipe_1() {\n const [transforms, opt] = pickTransforms(rest);\n let abortable;\n const sourceIt = source[Symbol.asyncIterator]();\n const cachedSource = {\n [Symbol.asyncIterator]() {\n return sourceIt;\n },\n };\n let iterable = cachedSource;\n if ((opt === null || opt === void 0 ? void 0 : opt.propagateDownStreamError) === true) {\n iterable = abortable = makeIterableAbortable(iterable);\n }\n for (const t of transforms) {\n iterable = t(iterable);\n }\n const it = iterable[Symbol.asyncIterator]();\n try {\n for (;;) {\n const r = yield __await(it.next());\n if (r.done === true) {\n break;\n }\n if (!abortable) {\n yield yield __await(r.value);\n continue;\n }\n try {\n yield yield __await(r.value);\n }\n catch (e) {\n yield __await(abortable.abort(e)); // propagate downstream error to the source\n throw e;\n }\n }\n }\n finally {\n if ((opt === null || opt === void 0 ? void 0 : opt.propagateDownStreamError) === true) {\n // Call return on the source iterable to indicate\n // that we will no longer consume it and it should\n // cleanup any allocated resources.\n (_a = sourceIt.return) === null || _a === void 0 ? void 0 : _a.call(sourceIt).catch(() => {\n // return returns a promise, which we don't care about.\n //\n // Uncaught promises are thrown at sometime/somewhere by the event loop,\n // this is to ensure error is caught and ignored.\n });\n }\n }\n });\n}\nfunction pickTransforms(rest) {\n let opt;\n if (typeof rest[rest.length - 1] != \"function\") {\n opt = rest.pop();\n }\n return [rest, opt];\n}\n/**\n * Creates an AsyncIterableTransform that catches any error from the input, and\n * passes it to the given catchError function.\n *\n * The catchError function may return a final value.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function transformCatch(catchError) {\n return function (iterable) {\n return __asyncGenerator(this, arguments, function* () {\n // we deliberate avoid a for-await loop because we only want to catch upstream\n // errors, not downstream errors (yield).\n const it = iterable[Symbol.asyncIterator]();\n for (;;) {\n let r;\n try {\n r = yield __await(it.next());\n }\n catch (e) {\n const caught = yield __await(catchError(e));\n if (caught !== undefined) {\n yield yield __await(caught);\n }\n break;\n }\n if (r.done === true) {\n break;\n }\n yield yield __await(r.value);\n }\n });\n };\n}\n/**\n * Creates an AsyncIterableTransform that catches any error from the input, and\n * passes it to the given function. Unlike transformCatch(), the given function\n * is also called when no error is raised.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function transformCatchFinally(catchFinally) {\n return function (iterable) {\n return __asyncGenerator(this, arguments, function* () {\n // we deliberate avoid a for-await loop because we only want to catch upstream\n // errors, not downstream errors (yield).\n let err;\n const it = iterable[Symbol.asyncIterator]();\n for (;;) {\n let r;\n try {\n r = yield __await(it.next());\n }\n catch (e) {\n err = e;\n break;\n }\n if (r.done === true) {\n break;\n }\n yield yield __await(r.value);\n }\n const caught = yield __await(catchFinally(err));\n if (caught !== undefined) {\n yield yield __await(caught);\n }\n });\n };\n}\n/**\n * Creates an AsyncIterableTransform that appends a value.\n *\n * The element to append is provided by a function. If the function returns\n * undefined, no element is appended.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function transformAppend(provide) {\n return function (iterable) {\n return __asyncGenerator(this, arguments, function* () {\n var _a, e_2, _b, _c;\n try {\n for (var _d = true, iterable_2 = __asyncValues(iterable), iterable_2_1; iterable_2_1 = yield __await(iterable_2.next()), _a = iterable_2_1.done, !_a; _d = true) {\n _c = iterable_2_1.value;\n _d = false;\n const chunk = _c;\n yield yield __await(chunk);\n }\n }\n catch (e_2_1) { e_2 = { error: e_2_1 }; }\n finally {\n try {\n if (!_d && !_a && (_b = iterable_2.return)) yield __await(_b.call(iterable_2));\n }\n finally { if (e_2) throw e_2.error; }\n }\n const append = yield __await(provide());\n if (append !== undefined) {\n yield yield __await(append);\n }\n });\n };\n}\n/**\n * Creates an AsyncIterableTransform that prepends an element.\n *\n * The element to prepend is provided by a function. If the function returns\n * undefined, no element is appended.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function transformPrepend(provide) {\n return function (iterable) {\n return __asyncGenerator(this, arguments, function* () {\n var _a, e_3, _b, _c;\n const prepend = yield __await(provide());\n if (prepend !== undefined) {\n yield yield __await(prepend);\n }\n try {\n for (var _d = true, iterable_3 = __asyncValues(iterable), iterable_3_1; iterable_3_1 = yield __await(iterable_3.next()), _a = iterable_3_1.done, !_a; _d = true) {\n _c = iterable_3_1.value;\n _d = false;\n const chunk = _c;\n yield yield __await(chunk);\n }\n }\n catch (e_3_1) { e_3 = { error: e_3_1 }; }\n finally {\n try {\n if (!_d && !_a && (_b = iterable_3.return)) yield __await(_b.call(iterable_3));\n }\n finally { if (e_3) throw e_3.error; }\n }\n });\n };\n}\n/**\n * Creates an AsyncIterableTransform that reads all bytes from the input, and\n * concatenates them to a single Uint8Array.\n *\n * The iterable raises an error if the more than readMaxBytes are read.\n *\n * An optional length hint can be provided to optimize allocation and validation.\n * If more or less bytes are present in the source that the length hint indicates,\n * and error is raised.\n * If the length hint is larger than readMaxBytes, an error is raised.\n * If the length hint is not a positive integer, it is ignored.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function transformReadAllBytes(readMaxBytes, lengthHint) {\n return function (iterable) {\n return __asyncGenerator(this, arguments, function* () {\n yield yield __await(yield __await(readAllBytes(iterable, readMaxBytes, lengthHint)));\n });\n };\n}\nexport function transformSerializeEnvelope(serialization, endStreamFlag, endSerialization) {\n if (endStreamFlag === undefined || endSerialization === undefined) {\n return function (iterable) {\n return __asyncGenerator(this, arguments, function* () {\n var _a, e_4, _b, _c;\n try {\n for (var _d = true, iterable_4 = __asyncValues(iterable), iterable_4_1; iterable_4_1 = yield __await(iterable_4.next()), _a = iterable_4_1.done, !_a; _d = true) {\n _c = iterable_4_1.value;\n _d = false;\n const chunk = _c;\n const data = serialization.serialize(chunk);\n yield yield __await({ flags: 0, data });\n }\n }\n catch (e_4_1) { e_4 = { error: e_4_1 }; }\n finally {\n try {\n if (!_d && !_a && (_b = iterable_4.return)) yield __await(_b.call(iterable_4));\n }\n finally { if (e_4) throw e_4.error; }\n }\n });\n };\n }\n return function (iterable) {\n return __asyncGenerator(this, arguments, function* () {\n var _a, e_5, _b, _c;\n try {\n for (var _d = true, iterable_5 = __asyncValues(iterable), iterable_5_1; iterable_5_1 = yield __await(iterable_5.next()), _a = iterable_5_1.done, !_a; _d = true) {\n _c = iterable_5_1.value;\n _d = false;\n const chunk = _c;\n let data;\n let flags = 0;\n if (chunk.end) {\n flags = flags | endStreamFlag;\n data = endSerialization.serialize(chunk.value);\n }\n else {\n data = serialization.serialize(chunk.value);\n }\n yield yield __await({ flags, data });\n }\n }\n catch (e_5_1) { e_5 = { error: e_5_1 }; }\n finally {\n try {\n if (!_d && !_a && (_b = iterable_5.return)) yield __await(_b.call(iterable_5));\n }\n finally { if (e_5) throw e_5.error; }\n }\n });\n };\n}\nexport function transformParseEnvelope(serialization, endStreamFlag, endSerialization) {\n // code path always yields ParsedEnvelopedMessage<T, E>\n if (endSerialization && endStreamFlag !== undefined) {\n return function (iterable) {\n return __asyncGenerator(this, arguments, function* () {\n var _a, e_6, _b, _c;\n try {\n for (var _d = true, iterable_6 = __asyncValues(iterable), iterable_6_1; iterable_6_1 = yield __await(iterable_6.next()), _a = iterable_6_1.done, !_a; _d = true) {\n _c = iterable_6_1.value;\n _d = false;\n const { flags, data } = _c;\n if ((flags & endStreamFlag) === endStreamFlag) {\n yield yield __await({ value: endSerialization.parse(data), end: true });\n }\n else {\n yield yield __await({ value: serialization.parse(data), end: false });\n }\n }\n }\n catch (e_6_1) { e_6 = { error: e_6_1 }; }\n finally {\n try {\n if (!_d && !_a && (_b = iterable_6.return)) yield __await(_b.call(iterable_6));\n }\n finally { if (e_6) throw e_6.error; }\n }\n });\n };\n }\n // code path always yields T\n return function (iterable) {\n return __asyncGenerator(this, arguments, function* () {\n var _a, e_7, _b, _c;\n try {\n for (var _d = true, iterable_7 = __asyncValues(iterable), iterable_7_1; iterable_7_1 = yield __await(iterable_7.next()), _a = iterable_7_1.done, !_a; _d = true) {\n _c = iterable_7_1.value;\n _d = false;\n const { flags, data } = _c;\n if (endStreamFlag !== undefined &&\n (flags & endStreamFlag) === endStreamFlag) {\n if (endSerialization === null) {\n throw new ConnectError(\"unexpected end flag\", Code.InvalidArgument);\n }\n // skips end-of-stream envelope\n continue;\n }\n yield yield __await(serialization.parse(data));\n }\n }\n catch (e_7_1) { e_7 = { error: e_7_1 }; }\n finally {\n try {\n if (!_d && !_a && (_b = iterable_7.return)) yield __await(_b.call(iterable_7));\n }\n finally { if (e_7) throw e_7.error; }\n }\n });\n };\n}\n/**\n * Creates an AsyncIterableTransform that takes enveloped messages as a source,\n * and compresses them if they are larger than compressMinBytes.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function transformCompressEnvelope(compression, compressMinBytes) {\n return function (iterable) {\n return __asyncGenerator(this, arguments, function* () {\n var _a, e_8, _b, _c;\n try {\n for (var _d = true, iterable_8 = __asyncValues(iterable), iterable_8_1; iterable_8_1 = yield __await(iterable_8.next()), _a = iterable_8_1.done, !_a; _d = true) {\n _c = iterable_8_1.value;\n _d = false;\n const env = _c;\n yield yield __await(yield __await(envelopeCompress(env, compression, compressMinBytes)));\n }\n }\n catch (e_8_1) { e_8 = { error: e_8_1 }; }\n finally {\n try {\n if (!_d && !_a && (_b = iterable_8.return)) yield __await(_b.call(iterable_8));\n }\n finally { if (e_8) throw e_8.error; }\n }\n });\n };\n}\n/**\n * Creates an AsyncIterableTransform that takes enveloped messages as a source,\n * and decompresses them using the given compression.\n *\n * The iterable raises an error if the decompressed payload of an enveloped\n * message is larger than readMaxBytes, or if no compression is provided.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function transformDecompressEnvelope(compression, readMaxBytes) {\n return function (iterable) {\n return __asyncGenerator(this, arguments, function* () {\n var _a, e_9, _b, _c;\n try {\n for (var _d = true, iterable_9 = __asyncValues(iterable), iterable_9_1; iterable_9_1 = yield __await(iterable_9.next()), _a = iterable_9_1.done, !_a; _d = true) {\n _c = iterable_9_1.value;\n _d = false;\n const env = _c;\n yield yield __await(yield __await(envelopeDecompress(env, compression, readMaxBytes)));\n }\n }\n catch (e_9_1) { e_9 = { error: e_9_1 }; }\n finally {\n try {\n if (!_d && !_a && (_b = iterable_9.return)) yield __await(_b.call(iterable_9));\n }\n finally { if (e_9) throw e_9.error; }\n }\n });\n };\n}\n/**\n * Create an AsyncIterableTransform that takes enveloped messages as a source,\n * and joins them into a stream of raw bytes.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function transformJoinEnvelopes() {\n return function (iterable) {\n return __asyncGenerator(this, arguments, function* () {\n var _a, e_10, _b, _c;\n try {\n for (var _d = true, iterable_10 = __asyncValues(iterable), iterable_10_1; iterable_10_1 = yield __await(iterable_10.next()), _a = iterable_10_1.done, !_a; _d = true) {\n _c = iterable_10_1.value;\n _d = false;\n const { flags, data } = _c;\n yield yield __await(encodeEnvelope(flags, data));\n }\n }\n catch (e_10_1) { e_10 = { error: e_10_1 }; }\n finally {\n try {\n if (!_d && !_a && (_b = iterable_10.return)) yield __await(_b.call(iterable_10));\n }\n finally { if (e_10) throw e_10.error; }\n }\n });\n };\n}\n/**\n * Create an AsyncIterableTransform that takes raw bytes as a source, and splits\n * them into enveloped messages.\n *\n * The iterable raises an error\n * - if the payload of an enveloped message is larger than readMaxBytes,\n * - if the stream ended before an enveloped message fully arrived,\n * - or if the stream ended with extraneous data.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function transformSplitEnvelope(readMaxBytes) {\n // append chunk to buffer, returning updated buffer\n function append(buffer, chunk) {\n const n = new Uint8Array(buffer.byteLength + chunk.byteLength);\n n.set(buffer);\n n.set(chunk, buffer.length);\n return n;\n }\n // tuple 0: envelope, or undefined if incomplete\n // tuple 1: remainder of the buffer\n function shiftEnvelope(buffer, header) {\n if (buffer.byteLength < 5 + header.length) {\n return [undefined, buffer];\n }\n return [\n { flags: header.flags, data: buffer.subarray(5, 5 + header.length) },\n buffer.subarray(5 + header.length),\n ];\n }\n // undefined: header is incomplete\n function peekHeader(buffer) {\n if (buffer.byteLength < 5) {\n return undefined;\n }\n const view = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);\n const length = view.getUint32(1); // 4 bytes message length\n const flags = view.getUint8(0); // first byte is flags\n return { length, flags };\n }\n return function (iterable) {\n return __asyncGenerator(this, arguments, function* () {\n var _a, e_11, _b, _c;\n let buffer = new Uint8Array(0);\n try {\n for (var _d = true, iterable_11 = __asyncValues(iterable), iterable_11_1; iterable_11_1 = yield __await(iterable_11.next()), _a = iterable_11_1.done, !_a; _d = true) {\n _c = iterable_11_1.value;\n _d = false;\n const chunk = _c;\n buffer = append(buffer, chunk);\n for (;;) {\n const header = peekHeader(buffer);\n if (!header) {\n break;\n }\n assertReadMaxBytes(readMaxBytes, header.length, true);\n let env;\n [env, buffer] = shiftEnvelope(buffer, header);\n if (!env) {\n break;\n }\n yield yield __await(env);\n }\n }\n }\n catch (e_11_1) { e_11 = { error: e_11_1 }; }\n finally {\n try {\n if (!_d && !_a && (_b = iterable_11.return)) yield __await(_b.call(iterable_11));\n }\n finally { if (e_11) throw e_11.error; }\n }\n if (buffer.byteLength > 0) {\n const header = peekHeader(buffer);\n let message = \"protocol error: incomplete envelope\";\n if (header) {\n message = `protocol error: promised ${header.length} bytes in enveloped message, got ${buffer.byteLength - 5} bytes`;\n }\n throw new ConnectError(message, Code.InvalidArgument);\n }\n });\n };\n}\n/**\n * Reads all bytes from the source, and concatenates them to a single Uint8Array.\n *\n * Raises an error if:\n * - more than readMaxBytes are read\n * - lengthHint is a positive integer, but larger than readMaxBytes\n * - lengthHint is a positive integer, and the source contains more or less bytes\n * than promised\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport async function readAllBytes(iterable, readMaxBytes, lengthHint) {\n var _a, e_12, _b, _c, _d, e_13, _e, _f;\n const [ok, hint] = parseLengthHint(lengthHint);\n if (ok) {\n if (hint > readMaxBytes) {\n assertReadMaxBytes(readMaxBytes, hint, true);\n }\n const buffer = new Uint8Array(hint);\n let offset = 0;\n try {\n for (var _g = true, iterable_12 = __asyncValues(iterable), iterable_12_1; iterable_12_1 = await iterable_12.next(), _a = iterable_12_1.done, !_a; _g = true) {\n _c = iterable_12_1.value;\n _g = false;\n const chunk = _c;\n if (offset + chunk.byteLength > hint) {\n throw new ConnectError(`protocol error: promised ${hint} bytes, received ${offset + chunk.byteLength}`, Code.InvalidArgument);\n }\n buffer.set(chunk, offset);\n offset += chunk.byteLength;\n }\n }\n catch (e_12_1) { e_12 = { error: e_12_1 }; }\n finally {\n try {\n if (!_g && !_a && (_b = iterable_12.return)) await _b.call(iterable_12);\n }\n finally { if (e_12) throw e_12.error; }\n }\n if (offset < hint) {\n throw new ConnectError(`protocol error: promised ${hint} bytes, received ${offset}`, Code.InvalidArgument);\n }\n return buffer;\n }\n const chunks = [];\n let count = 0;\n try {\n for (var _h = true, iterable_13 = __asyncValues(iterable), iterable_13_1; iterable_13_1 = await iterable_13.next(), _d = iterable_13_1.done, !_d; _h = true) {\n _f = iterable_13_1.value;\n _h = false;\n const chunk = _f;\n count += chunk.byteLength;\n assertReadMaxBytes(readMaxBytes, count);\n chunks.push(chunk);\n }\n }\n catch (e_13_1) { e_13 = { error: e_13_1 }; }\n finally {\n try {\n if (!_h && !_d && (_e = iterable_13.return)) await _e.call(iterable_13);\n }\n finally { if (e_13) throw e_13.error; }\n }\n const all = new Uint8Array(count);\n let offset = 0;\n for (let chunk = chunks.shift(); chunk; chunk = chunks.shift()) {\n all.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return all;\n}\n// parse the lengthHint argument of readAllBytes()\nfunction parseLengthHint(lengthHint) {\n if (lengthHint === undefined || lengthHint === null) {\n return [false, 0];\n }\n const n = typeof lengthHint == \"string\" ? parseInt(lengthHint, 10) : lengthHint;\n if (!Number.isSafeInteger(n) || n < 0) {\n return [false, n];\n }\n return [true, n];\n}\n/**\n * Wait for the first element of an iterable without modifying the iterable.\n * This consumes the first element, but pushes it back on the stack.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport async function untilFirst(iterable) {\n const it = iterable[Symbol.asyncIterator]();\n let first = await it.next();\n return {\n [Symbol.asyncIterator]() {\n const w = {\n async next() {\n if (first !== null) {\n const n = first;\n first = null;\n return n;\n }\n return await it.next();\n },\n };\n if (it.throw !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- can't handle mutated object sensibly\n w.throw = (e) => it.throw(e);\n }\n if (it.return !== undefined) {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion,@typescript-eslint/no-explicit-any -- can't handle mutated object sensibly\n w.return = (value) => it.return(value);\n }\n return w;\n },\n };\n}\n/**\n * Wrap the given iterable and return an iterable with an abort() method.\n *\n * This function exists purely for convenience. Where one would typically have\n * to access the iterator directly, advance through all elements, and call\n * AsyncIterator.throw() to notify the upstream iterable, this function allows\n * to use convenient for-await loops and still notify the upstream iterable:\n *\n * ```ts\n * const abortable = makeIterableAbortable(iterable);\n * for await (const ele of abortable) {\n * await abortable.abort(\"ERR\");\n * }\n * ```\n * There are a couple of limitations of this function:\n * - the given async iterable must implement throw\n * - the async iterable cannot be re-use\n * - if source catches errors and yields values for them, they are ignored, and\n * the source may still dangle\n *\n * There are four possible ways an async function* can handle yield errors:\n * 1. don't catch errors at all - Abortable.abort() will resolve \"rethrown\"\n * 2. catch errors and rethrow - Abortable.abort() will resolve \"rethrown\"\n * 3. catch errors and return - Abortable.abort() will resolve \"completed\"\n * 4. catch errors and yield a value - Abortable.abort() will resolve \"caught\"\n *\n * Note that catching errors and yielding a value is problematic, and it should\n * be documented that this may leave the source in a dangling state.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function makeIterableAbortable(iterable) {\n const innerCandidate = iterable[Symbol.asyncIterator]();\n if (innerCandidate.throw === undefined) {\n throw new Error(\"AsyncIterable does not implement throw\");\n }\n const inner = innerCandidate;\n let aborted;\n let resultPromise;\n let it = {\n next() {\n resultPromise = inner.next().finally(() => {\n resultPromise = undefined;\n });\n return resultPromise;\n },\n throw(e) {\n return inner.throw(e);\n },\n };\n if (innerCandidate.return !== undefined) {\n it = Object.assign(Object.assign({}, it), { return(value) {\n return inner.return(value);\n } });\n }\n let used = false;\n return {\n abort(reason) {\n if (aborted) {\n return aborted.state;\n }\n const f = () => {\n return inner.throw(reason).then((r) => (r.done === true ? \"completed\" : \"caught\"), () => \"rethrown\");\n };\n if (resultPromise) {\n aborted = { reason, state: resultPromise.then(f, f) };\n return aborted.state;\n }\n aborted = { reason, state: f() };\n return aborted.state;\n },\n [Symbol.asyncIterator]() {\n if (used) {\n throw new Error(\"AsyncIterable cannot be re-used\");\n }\n used = true;\n return it;\n },\n };\n}\n/**\n * Create a new WritableIterable.\n */\nexport function createWritableIterable() {\n // We start with two queues to capture the read and write attempts.\n //\n // The writes and reads each check of their counterpart is\n // already available and either interact/add themselves to the queue.\n const readQueue = [];\n const writeQueue = [];\n let err = undefined;\n let nextResolve;\n let nextReject;\n let nextPromise = new Promise((resolve, reject) => {\n nextResolve = resolve;\n nextReject = reject;\n });\n let closed = false;\n // drain the readQueue in case of error/writer is closed by sending a\n // done result.\n function drain() {\n for (const next of readQueue.splice(0, readQueue.length)) {\n next({ done: true, value: undefined });\n }\n }\n return {\n close() {\n closed = true;\n drain();\n },\n async write(payload) {\n if (closed) {\n throw err !== null && err !== void 0 ? err : new Error(\"cannot write, WritableIterable already closed\");\n }\n const read = readQueue.shift();\n if (read === undefined) {\n // We didn't find a pending read so we add the payload to the write queue.\n writeQueue.push(payload);\n }\n else {\n // We found a pending read so we respond with the payload.\n read({ done: false, value: payload });\n if (readQueue.length > 0) {\n // If there are more in the read queue we can mark the write as complete.\n // as the error reporting is not guaranteed to be sequential and therefore cannot\n // to linked to a specific write.\n return;\n }\n }\n // We await the next call for as many times as there are items in the queue + 1\n //\n // If there are no items in the write queue that means write happened and we just have\n // to wait for one more call likewise if we are the nth write in the queue we\n // have to wait for n writes to complete and one more.\n const limit = writeQueue.length + 1;\n for (let i = 0; i < limit; i++) {\n await nextPromise;\n }\n },\n [Symbol.asyncIterator]() {\n return {\n next() {\n // Resolve the nextPromise to indicate\n // pending writes that a read attempt has been made\n // after their write.\n //\n // We also need to reset the promise for future writes.\n nextResolve();\n nextPromise = new Promise((resolve, reject) => {\n nextResolve = resolve;\n nextReject = reject;\n });\n const write = writeQueue.shift();\n if (write !== undefined) {\n // We found a pending write so response with the payload.\n return Promise.resolve({ done: false, value: write });\n }\n if (closed) {\n return Promise.resolve({ done: true, value: undefined });\n }\n // We return a promise immediately that is either resolved/rejected\n // as writes happen.\n let readResolve;\n const readPromise = new Promise((resolve) => (readResolve = resolve));\n readQueue.push(readResolve); // eslint-disable-line @typescript-eslint/no-non-null-assertion\n return readPromise;\n },\n throw(throwErr) {\n err = throwErr;\n closed = true;\n writeQueue.splice(0, writeQueue.length);\n nextPromise.catch(() => {\n // To make sure that the nextPromise is always resolved.\n });\n // This will reject all pending writes.\n nextReject(err);\n drain();\n return Promise.resolve({ done: true, value: undefined });\n },\n return() {\n closed = true;\n writeQueue.splice(0, writeQueue.length);\n // Resolve once for the write awaiting confirmation.\n nextResolve();\n // Reject all future writes.\n nextPromise = Promise.reject(new Error(\"cannot write, consumer called return\"));\n nextPromise.catch(() => {\n // To make sure that the nextPromise is always resolved.\n });\n drain();\n return Promise.resolve({ done: true, value: undefined });\n },\n };\n },\n };\n}\n/**\n * Create an asynchronous iterable from an array.\n *\n * @private Internal code, does not follow semantic versioning.\n */\n// eslint-disable-next-line @typescript-eslint/require-await\nexport function createAsyncIterable(items) {\n return __asyncGenerator(this, arguments, function* createAsyncIterable_1() {\n yield __await(yield* __asyncDelegator(__asyncValues(items)));\n });\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nvar __asyncValues = (this && this.__asyncValues) || function (o) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var m = o[Symbol.asyncIterator], i;\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\n};\nvar __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }\nvar __asyncDelegator = (this && this.__asyncDelegator) || function (o) {\n var i, p;\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }\n};\nvar __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n};\nimport { Message, MethodKind } from \"@bufbuild/protobuf\";\nimport { makeAnyClient } from \"./any-client.js\";\nimport { ConnectError } from \"./connect-error.js\";\nimport { Code } from \"./code.js\";\nimport { createAsyncIterable } from \"./protocol/async-iterable.js\";\n/**\n * Create a PromiseClient for the given service, invoking RPCs through the\n * given transport.\n */\nexport function createPromiseClient(service, transport) {\n return makeAnyClient(service, (method) => {\n switch (method.kind) {\n case MethodKind.Unary:\n return createUnaryFn(transport, service, method);\n case MethodKind.ServerStreaming:\n return createServerStreamingFn(transport, service, method);\n case MethodKind.ClientStreaming:\n return createClientStreamingFn(transport, service, method);\n case MethodKind.BiDiStreaming:\n return createBiDiStreamingFn(transport, service, method);\n default:\n return null;\n }\n });\n}\nexport function createUnaryFn(transport, service, method) {\n return async function (input, options) {\n var _a, _b;\n const response = await transport.unary(service, method, options === null || options === void 0 ? void 0 : options.signal, options === null || options === void 0 ? void 0 : options.timeoutMs, options === null || options === void 0 ? void 0 : options.headers, input, options === null || options === void 0 ? void 0 : options.contextValues);\n (_a = options === null || options === void 0 ? void 0 : options.onHeader) === null || _a === void 0 ? void 0 : _a.call(options, response.header);\n (_b = options === null || options === void 0 ? void 0 : options.onTrailer) === null || _b === void 0 ? void 0 : _b.call(options, response.trailer);\n return response.message;\n };\n}\nexport function createServerStreamingFn(transport, service, method) {\n return function (input, options) {\n return handleStreamResponse(transport.stream(service, method, options === null || options === void 0 ? void 0 : options.signal, options === null || options === void 0 ? void 0 : options.timeoutMs, options === null || options === void 0 ? void 0 : options.headers, createAsyncIterable([input]), options === null || options === void 0 ? void 0 : options.contextValues), options);\n };\n}\nexport function createClientStreamingFn(transport, service, method) {\n return async function (request, options) {\n var _a, e_1, _b, _c;\n var _d, _e;\n const response = await transport.stream(service, method, options === null || options === void 0 ? void 0 : options.signal, options === null || options === void 0 ? void 0 : options.timeoutMs, options === null || options === void 0 ? void 0 : options.headers, request, options === null || options === void 0 ? void 0 : options.contextValues);\n (_d = options === null || options === void 0 ? void 0 : options.onHeader) === null || _d === void 0 ? void 0 : _d.call(options, response.header);\n let singleMessage;\n try {\n for (var _f = true, _g = __asyncValues(response.message), _h; _h = await _g.next(), _a = _h.done, !_a; _f = true) {\n _c = _h.value;\n _f = false;\n const message = _c;\n singleMessage = message;\n }\n }\n catch (e_1_1) { e_1 = { error: e_1_1 }; }\n finally {\n try {\n if (!_f && !_a && (_b = _g.return)) await _b.call(_g);\n }\n finally { if (e_1) throw e_1.error; }\n }\n if (!singleMessage) {\n throw new ConnectError(\"protocol error: missing response message\", Code.Internal);\n }\n (_e = options === null || options === void 0 ? void 0 : options.onTrailer) === null || _e === void 0 ? void 0 : _e.call(options, response.trailer);\n return singleMessage;\n };\n}\nexport function createBiDiStreamingFn(transport, service, method) {\n return function (request, options) {\n return handleStreamResponse(transport.stream(service, method, options === null || options === void 0 ? void 0 : options.signal, options === null || options === void 0 ? void 0 : options.timeoutMs, options === null || options === void 0 ? void 0 : options.headers, request, options === null || options === void 0 ? void 0 : options.contextValues), options);\n };\n}\nfunction handleStreamResponse(stream, options) {\n const it = (function () {\n var _a, _b;\n return __asyncGenerator(this, arguments, function* () {\n const response = yield __await(stream);\n (_a = options === null || options === void 0 ? void 0 : options.onHeader) === null || _a === void 0 ? void 0 : _a.call(options, response.header);\n yield __await(yield* __asyncDelegator(__asyncValues(response.message)));\n (_b = options === null || options === void 0 ? void 0 : options.onTrailer) === null || _b === void 0 ? void 0 : _b.call(options, response.trailer);\n });\n })()[Symbol.asyncIterator]();\n // Create a new iterable to omit throw/return.\n return {\n [Symbol.asyncIterator]: () => ({\n next: () => it.next(),\n }),\n };\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { ConnectError } from \"../connect-error.js\";\nimport { Code } from \"../code.js\";\n/**\n * Create an AbortController that is automatically aborted if one of the given\n * signals is aborted.\n *\n * For convenience, the linked AbortSignals can be undefined.\n *\n * If the controller or any of the signals is aborted, all event listeners are\n * removed.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function createLinkedAbortController(...signals) {\n const controller = new AbortController();\n const sa = signals\n .filter((s) => s !== undefined)\n .concat(controller.signal);\n for (const signal of sa) {\n if (signal.aborted) {\n onAbort.apply(signal);\n break;\n }\n signal.addEventListener(\"abort\", onAbort);\n }\n function onAbort() {\n if (!controller.signal.aborted) {\n controller.abort(getAbortSignalReason(this));\n }\n for (const signal of sa) {\n signal.removeEventListener(\"abort\", onAbort);\n }\n }\n return controller;\n}\n/**\n * Create a deadline signal. The returned object contains an AbortSignal, but\n * also a cleanup function to stop the timer, which must be called once the\n * calling code is no longer interested in the signal.\n *\n * Ideally, we would simply use AbortSignal.timeout(), but it is not widely\n * available yet.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function createDeadlineSignal(timeoutMs) {\n const controller = new AbortController();\n const listener = () => {\n controller.abort(new ConnectError(\"the operation timed out\", Code.DeadlineExceeded));\n };\n let timeoutId;\n if (timeoutMs !== undefined) {\n if (timeoutMs <= 0)\n listener();\n else\n timeoutId = setTimeout(listener, timeoutMs);\n }\n return {\n signal: controller.signal,\n cleanup: () => clearTimeout(timeoutId),\n };\n}\n/**\n * Returns the reason why an AbortSignal was aborted. Returns undefined if the\n * signal has not been aborted.\n *\n * The property AbortSignal.reason is not widely available. This function\n * returns an AbortError if the signal is aborted, but reason is undefined.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function getAbortSignalReason(signal) {\n if (!signal.aborted) {\n return undefined;\n }\n if (signal.reason !== undefined) {\n return signal.reason;\n }\n // AbortSignal.reason is available in Node.js v16, v18, and later,\n // and in all browsers since early 2022.\n const e = new Error(\"This operation was aborted\");\n e.name = \"AbortError\";\n return e;\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n/**\n * createContextValues creates a new ContextValues.\n */\nexport function createContextValues() {\n return {\n get(key) {\n return key.id in this ? this[key.id] : key.defaultValue;\n },\n set(key, value) {\n this[key.id] = value;\n return this;\n },\n delete(key) {\n delete this[key.id];\n return this;\n },\n };\n}\n/**\n * createContextKey creates a new ContextKey.\n */\nexport function createContextKey(defaultValue, options) {\n return { id: Symbol(options === null || options === void 0 ? void 0 : options.description), defaultValue };\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n/**\n * trailerFlag indicates that the data in a EnvelopedMessage\n * is a set of trailers of the gRPC-web protocol.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport const trailerFlag = 0b10000000;\n/**\n * Parse a gRPC-web trailer, a set of header fields separated by CRLF.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function trailerParse(data) {\n const headers = new Headers();\n const lines = new TextDecoder().decode(data).split(\"\\r\\n\");\n for (const line of lines) {\n if (line === \"\") {\n continue;\n }\n const i = line.indexOf(\":\");\n if (i > 0) {\n const name = line.substring(0, i).trim();\n const value = line.substring(i + 1).trim();\n headers.append(name, value);\n }\n }\n return headers;\n}\n/**\n * Serialize a Headers object as a gRPC-web trailer.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function trailerSerialize(trailer) {\n const lines = [];\n trailer.forEach((value, key) => {\n lines.push(`${key}: ${value}\\r\\n`);\n });\n return new TextEncoder().encode(lines.join(\"\"));\n}\n/**\n * Create a Serialization object that serializes a gRPC-web trailer, a Headers\n * object that is serialized as a set of header fields, separated by CRLF.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function createTrailerSerialization() {\n return {\n serialize: trailerSerialize,\n parse: trailerParse,\n };\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n/**\n * @private Internal code, does not follow semantic versioning.\n */\nexport const headerContentType = \"Content-Type\";\nexport const headerEncoding = \"Grpc-Encoding\";\nexport const headerAcceptEncoding = \"Grpc-Accept-Encoding\";\nexport const headerTimeout = \"Grpc-Timeout\";\nexport const headerGrpcStatus = \"Grpc-Status\";\nexport const headerGrpcMessage = \"Grpc-Message\";\nexport const headerStatusDetailsBin = \"Grpc-Status-Details-Bin\";\nexport const headerMessageType = \"Grpc-Message-Type\";\nexport const headerUserAgent = \"User-Agent\";\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n/**\n * @private Internal code, does not follow semantic versioning.\n */\nexport { headerContentType, headerEncoding, headerAcceptEncoding, headerTimeout, headerGrpcStatus, headerGrpcMessage, headerStatusDetailsBin, headerUserAgent, } from \"../protocol-grpc/headers.js\";\n/**\n * gRPC-web does not use the standard header User-Agent.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport const headerXUserAgent = \"X-User-Agent\";\n/**\n * The canonical grpc/grpc-web JavaScript implementation sets\n * this request header with value \"1\".\n * Some servers may rely on the header to identify gRPC-web\n * requests. For example the proxy by improbable:\n * https://github.com/improbable-eng/grpc-web/blob/53aaf4cdc0fede7103c1b06f0cfc560c003a5c41/go/grpcweb/wrapper.go#L231\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport const headerXGrpcWeb = \"X-Grpc-Web\";\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n/**\n * Regular Expression that matches any valid gRPC-web Content-Type header value.\n * Note that this includes application/grpc-web-text with the additional base64\n * encoding.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport const contentTypeRegExp = /^application\\/grpc-web(-text)?(?:\\+(?:(json)(?:; ?charset=utf-?8)?|proto))?$/i;\nexport const contentTypeProto = \"application/grpc-web+proto\";\nexport const contentTypeJson = \"application/grpc-web+json\";\n/**\n * Parse a gRPC-web Content-Type header value.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function parseContentType(contentType) {\n const match = contentType === null || contentType === void 0 ? void 0 : contentType.match(contentTypeRegExp);\n if (!match) {\n return undefined;\n }\n const text = !!match[1];\n const binary = !match[2];\n return { text, binary };\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { Any, Message, proto3 } from \"@bufbuild/protobuf\";\n/**\n * The `Status` type defines a logical error model that is suitable for different\n * programming environments, including REST APIs and RPC APIs. It is used by\n * [gRPC](https://github.com/grpc). The error model is designed to be:\n *\n * - Simple to use and understand for most users\n * - Flexible enough to meet unexpected needs\n *\n * # Overview\n *\n * The `Status` message contains three pieces of data: error code, error message,\n * and error details. The error code should be an enum value of\n * [google.rpc.Code][google.rpc.Code], but it may accept additional error codes if needed. The\n * error message should be a developer-facing English message that helps\n * developers *understand* and *resolve* the error. If a localized user-facing\n * error message is needed, put the localized message in the error details or\n * localize it in the client. The optional error details may contain arbitrary\n * information about the error. There is a predefined set of error detail types\n * in the package `google.rpc` which can be used for common error conditions.\n *\n * # Language mapping\n *\n * The `Status` message is the logical representation of the error model, but it\n * is not necessarily the actual wire format. When the `Status` message is\n * exposed in different client libraries and different wire protocols, it can be\n * mapped differently. For example, it will likely be mapped to some exceptions\n * in Java, but more likely mapped to some error codes in C.\n *\n * # Other uses\n *\n * The error model and the `Status` message can be used in a variety of\n * environments, either with or without APIs, to provide a\n * consistent developer experience across different environments.\n *\n * Example uses of this error model include:\n *\n * - Partial errors. If a service needs to return partial errors to the client,\n * it may embed the `Status` in the normal response to indicate the partial\n * errors.\n *\n * - Workflow errors. A typical workflow has multiple steps. Each step may\n * have a `Status` message for error reporting purpose.\n *\n * - Batch operations. If a client uses batch request and batch response, the\n * `Status` message should be used directly inside batch response, one for\n * each error sub-response.\n *\n * - Asynchronous operations. If an API call embeds asynchronous operation\n * results in its response, the status of those operations should be\n * represented directly using the `Status` message.\n *\n * - Logging. If some API errors are stored in logs, the message `Status` could\n * be used directly after any stripping needed for security/privacy reasons.\n *\n * @generated from message google.rpc.Status\n */\nexport class Status extends Message {\n constructor(data) {\n super();\n /**\n * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code].\n *\n * @generated from field: int32 code = 1;\n */\n this.code = 0;\n /**\n * A developer-facing error message, which should be in English. Any\n * user-facing error message should be localized and sent in the\n * [google.rpc.Status.details][google.rpc.Status.details] field, or localized by the client.\n *\n * @generated from field: string message = 2;\n */\n this.message = \"\";\n /**\n * A list of messages that carry the error details. There will be a\n * common set of message types for APIs to use.\n *\n * @generated from field: repeated google.protobuf.Any details = 3;\n */\n this.details = [];\n proto3.util.initPartial(data, this);\n }\n static fromBinary(bytes, options) {\n return new Status().fromBinary(bytes, options);\n }\n static fromJson(jsonValue, options) {\n return new Status().fromJson(jsonValue, options);\n }\n static fromJsonString(jsonString, options) {\n return new Status().fromJsonString(jsonString, options);\n }\n static equals(a, b) {\n return proto3.util.equals(Status, a, b);\n }\n}\nStatus.runtime = proto3;\nStatus.typeName = \"google.rpc.Status\";\nStatus.fields = proto3.util.newFieldList(() => [\n { no: 1, name: \"code\", kind: \"scalar\", T: 5 /* ScalarType.INT32 */ },\n { no: 2, name: \"message\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 3, name: \"details\", kind: \"message\", T: Any, repeated: true },\n]);\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { Any } from \"@bufbuild/protobuf\";\nimport { Status } from \"./gen/status_pb.js\";\nimport { ConnectError } from \"../connect-error.js\";\nimport { decodeBinaryHeader, encodeBinaryHeader } from \"../http-headers.js\";\nimport { Code } from \"../code.js\";\nimport { headerGrpcMessage, headerGrpcStatus, headerStatusDetailsBin, } from \"./headers.js\";\n/**\n * The value of the Grpc-Status header or trailer in case of success.\n * Used by the gRPC and gRPC-web protocols.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport const grpcStatusOk = \"0\";\n/**\n * Sets the fields \"grpc-status\" and \"grpc-message\" in the given\n * Headers object.\n * If an error is given and contains error details, the function\n * will also set the field \"grpc-status-details-bin\" with an encoded\n * google.rpc.Status message including the error details.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function setTrailerStatus(target, error) {\n if (error) {\n target.set(headerGrpcStatus, error.code.toString(10));\n target.set(headerGrpcMessage, encodeURIComponent(error.rawMessage));\n if (error.details.length > 0) {\n const status = new Status({\n code: error.code,\n message: error.rawMessage,\n details: error.details.map((value) => \"getType\" in value\n ? Any.pack(value)\n : new Any({\n typeUrl: `type.googleapis.com/${value.type}`,\n value: value.value,\n })),\n });\n target.set(headerStatusDetailsBin, encodeBinaryHeader(status));\n }\n }\n else {\n target.set(headerGrpcStatus, grpcStatusOk.toString());\n }\n return target;\n}\n/**\n * Find an error status in the given Headers object, which can be either\n * a trailer, or a header (as allowed for so-called trailers-only responses).\n * The field \"grpc-status-details-bin\" is inspected, and if not present,\n * the fields \"grpc-status\" and \"grpc-message\" are used.\n * Returns an error only if the gRPC status code is > 0.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function findTrailerError(headerOrTrailer) {\n // TODO\n // let code: Code;\n // let message: string = \"\";\n var _a;\n // Prefer the protobuf-encoded data to the grpc-status header.\n const statusBytes = headerOrTrailer.get(headerStatusDetailsBin);\n if (statusBytes != null) {\n const status = decodeBinaryHeader(statusBytes, Status);\n if (status.code == 0) {\n return undefined;\n }\n const error = new ConnectError(status.message, status.code, headerOrTrailer);\n error.details = status.details.map((any) => ({\n type: any.typeUrl.substring(any.typeUrl.lastIndexOf(\"/\") + 1),\n value: any.value,\n }));\n return error;\n }\n const grpcStatus = headerOrTrailer.get(headerGrpcStatus);\n if (grpcStatus != null) {\n if (grpcStatus === grpcStatusOk) {\n return undefined;\n }\n const code = parseInt(grpcStatus, 10);\n if (code in Code) {\n return new ConnectError(decodeURIComponent((_a = headerOrTrailer.get(headerGrpcMessage)) !== null && _a !== void 0 ? _a : \"\"), code, headerOrTrailer);\n }\n return new ConnectError(`invalid grpc-status: ${grpcStatus}`, Code.Internal, headerOrTrailer);\n }\n return undefined;\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n/**\n * Create a URL for the given RPC. This simply adds the qualified\n * service name, a slash, and the method name to the path of the given\n * baseUrl.\n *\n * For example, the baseUri https://example.com and method \"Say\" from\n * the service example.ElizaService results in:\n * https://example.com/example.ElizaService/Say\n *\n * This format is used by the protocols Connect, gRPC and Twirp.\n *\n * Note that this function also accepts a protocol-relative baseUrl.\n * If given an empty string or \"/\" as a baseUrl, it returns just the\n * path.\n */\nexport function createMethodUrl(baseUrl, service, method) {\n const s = typeof service == \"string\" ? service : service.typeName;\n const m = typeof method == \"string\" ? method : method.name;\n return baseUrl.toString().replace(/\\/?$/, `/${s}/${m}`);\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { Message } from \"@bufbuild/protobuf\";\n/**\n * Takes a partial protobuf messages of the\n * specified message type as input, and returns full instances.\n */\nexport function normalize(type, message) {\n return message instanceof type\n ? message\n : new type(message);\n}\n/**\n * Takes an AsyncIterable of partial protobuf messages of the\n * specified message type as input, and yields full instances.\n */\nexport function normalizeIterable(messageType, input) {\n function transform(result) {\n if (result.done === true) {\n return result;\n }\n return {\n done: result.done,\n value: normalize(messageType, result.value),\n };\n }\n return {\n [Symbol.asyncIterator]() {\n const it = input[Symbol.asyncIterator]();\n const res = {\n next: () => it.next().then(transform),\n };\n if (it.throw !== undefined) {\n res.throw = (e) => it.throw(e).then(transform); // eslint-disable-line @typescript-eslint/no-non-null-assertion\n }\n if (it.return !== undefined) {\n res.return = (v) => it.return(v).then(transform); // eslint-disable-line @typescript-eslint/no-non-null-assertion\n }\n return res;\n },\n };\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n/**\n * applyInterceptors takes the given UnaryFn or ServerStreamingFn, and wraps\n * it with each of the given interceptors, returning a new UnaryFn or\n * ServerStreamingFn.\n */\nexport function applyInterceptors(next, interceptors) {\n var _a;\n return ((_a = interceptors === null || interceptors === void 0 ? void 0 : interceptors.concat().reverse().reduce(\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n (n, i) => i(n), next)) !== null && _a !== void 0 ? _a : next);\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { ConnectError } from \"../connect-error.js\";\nimport { Code } from \"../code.js\";\nimport { assertReadMaxBytes, assertWriteMaxBytes } from \"./limit-io.js\";\n/**\n * Sets default JSON serialization options for connect-es.\n *\n * With standard protobuf JSON serialization, unknown JSON fields are\n * rejected by default. In connect-es, unknown JSON fields are ignored\n * by default.\n */\nexport function getJsonOptions(options) {\n var _a;\n const o = Object.assign({}, options);\n (_a = o.ignoreUnknownFields) !== null && _a !== void 0 ? _a : (o.ignoreUnknownFields = true);\n return o;\n}\n/**\n * Create an object that provides convenient access to request and response\n * message serialization for a given method.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function createMethodSerializationLookup(method, binaryOptions, jsonOptions, limitOptions) {\n const inputBinary = limitSerialization(createBinarySerialization(method.I, binaryOptions), limitOptions);\n const inputJson = limitSerialization(createJsonSerialization(method.I, jsonOptions), limitOptions);\n const outputBinary = limitSerialization(createBinarySerialization(method.O, binaryOptions), limitOptions);\n const outputJson = limitSerialization(createJsonSerialization(method.O, jsonOptions), limitOptions);\n return {\n getI(useBinaryFormat) {\n return useBinaryFormat ? inputBinary : inputJson;\n },\n getO(useBinaryFormat) {\n return useBinaryFormat ? outputBinary : outputJson;\n },\n };\n}\n/**\n * Returns functions to normalize and serialize the input message\n * of an RPC, and to parse the output message of an RPC.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function createClientMethodSerializers(method, useBinaryFormat, jsonOptions, binaryOptions) {\n const input = useBinaryFormat\n ? createBinarySerialization(method.I, binaryOptions)\n : createJsonSerialization(method.I, jsonOptions);\n const output = useBinaryFormat\n ? createBinarySerialization(method.O, binaryOptions)\n : createJsonSerialization(method.O, jsonOptions);\n return { parse: output.parse, serialize: input.serialize };\n}\n/**\n * Apply I/O limits to a Serialization object, returning a new object.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function limitSerialization(serialization, limitOptions) {\n return {\n serialize(data) {\n const bytes = serialization.serialize(data);\n assertWriteMaxBytes(limitOptions.writeMaxBytes, bytes.byteLength);\n return bytes;\n },\n parse(data) {\n assertReadMaxBytes(limitOptions.readMaxBytes, data.byteLength, true);\n return serialization.parse(data);\n },\n };\n}\n/**\n * Creates a Serialization object for serializing the given protobuf message\n * with the protobuf binary format.\n */\nexport function createBinarySerialization(messageType, options) {\n return {\n parse(data) {\n try {\n return messageType.fromBinary(data, options);\n }\n catch (e) {\n const m = e instanceof Error ? e.message : String(e);\n throw new ConnectError(`parse binary: ${m}`, Code.InvalidArgument);\n }\n },\n serialize(data) {\n try {\n return data.toBinary(options);\n }\n catch (e) {\n const m = e instanceof Error ? e.message : String(e);\n throw new ConnectError(`serialize binary: ${m}`, Code.Internal);\n }\n },\n };\n}\n/**\n * Creates a Serialization object for serializing the given protobuf message\n * with the protobuf canonical JSON encoding.\n *\n * By default, unknown fields are ignored.\n */\nexport function createJsonSerialization(messageType, options) {\n var _a, _b;\n const textEncoder = (_a = options === null || options === void 0 ? void 0 : options.textEncoder) !== null && _a !== void 0 ? _a : new TextEncoder();\n const textDecoder = (_b = options === null || options === void 0 ? void 0 : options.textDecoder) !== null && _b !== void 0 ? _b : new TextDecoder();\n const o = getJsonOptions(options);\n return {\n parse(data) {\n try {\n const json = textDecoder.decode(data);\n return messageType.fromJsonString(json, o);\n }\n catch (e) {\n throw ConnectError.from(e, Code.InvalidArgument);\n }\n },\n serialize(data) {\n try {\n const json = data.toJsonString(o);\n return textEncoder.encode(json);\n }\n catch (e) {\n throw ConnectError.from(e, Code.Internal);\n }\n },\n };\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { applyInterceptors } from \"../interceptor.js\";\nimport { ConnectError } from \"../connect-error.js\";\nimport { createDeadlineSignal, createLinkedAbortController, getAbortSignalReason, } from \"./signals.js\";\nimport { normalize, normalizeIterable } from \"./normalize.js\";\n/**\n * Runs a unary method with the given interceptors. Note that this function\n * is only used when implementing a Transport.\n */\nexport function runUnaryCall(opt) {\n const next = applyInterceptors(opt.next, opt.interceptors);\n const [signal, abort, done] = setupSignal(opt);\n const req = Object.assign(Object.assign({}, opt.req), { message: normalize(opt.req.method.I, opt.req.message), signal });\n return next(req).then((res) => {\n done();\n return res;\n }, abort);\n}\n/**\n * Runs a server-streaming method with the given interceptors. Note that this\n * function is only used when implementing a Transport.\n */\nexport function runStreamingCall(opt) {\n const next = applyInterceptors(opt.next, opt.interceptors);\n const [signal, abort, done] = setupSignal(opt);\n const req = Object.assign(Object.assign({}, opt.req), { message: normalizeIterable(opt.req.method.I, opt.req.message), signal });\n let doneCalled = false;\n // Call return on the request iterable to indicate\n // that we will no longer consume it and it should\n // cleanup any allocated resources.\n signal.addEventListener(\"abort\", function () {\n var _a, _b;\n const it = opt.req.message[Symbol.asyncIterator]();\n // If the signal is aborted due to an error, we want to throw\n // the error to the request iterator.\n if (!doneCalled) {\n (_a = it.throw) === null || _a === void 0 ? void 0 : _a.call(it, this.reason).catch(() => {\n // throw returns a promise, which we don't care about.\n //\n // Uncaught promises are thrown at sometime/somewhere by the event loop,\n // this is to ensure error is caught and ignored.\n });\n }\n (_b = it.return) === null || _b === void 0 ? void 0 : _b.call(it).catch(() => {\n // return returns a promise, which we don't care about.\n //\n // Uncaught promises are thrown at sometime/somewhere by the event loop,\n // this is to ensure error is caught and ignored.\n });\n });\n return next(req).then((res) => {\n return Object.assign(Object.assign({}, res), { message: {\n [Symbol.asyncIterator]() {\n const it = res.message[Symbol.asyncIterator]();\n return {\n next() {\n return it.next().then((r) => {\n if (r.done == true) {\n doneCalled = true;\n done();\n }\n return r;\n }, abort);\n },\n // We deliberately omit throw/return.\n };\n },\n } });\n }, abort);\n}\n/**\n * Create an AbortSignal for Transport implementations. The signal is available\n * in UnaryRequest and StreamingRequest, and is triggered when the call is\n * aborted (via a timeout or explicit cancellation), errored (e.g. when reading\n * an error from the server from the wire), or finished successfully.\n *\n * Transport implementations can pass the signal to HTTP clients to ensure that\n * there are no unused connections leak.\n *\n * Returns a tuple:\n * [0]: The signal, which is also aborted if the optional deadline is reached.\n * [1]: Function to call if the Transport encountered an error.\n * [2]: Function to call if the Transport finished without an error.\n */\nfunction setupSignal(opt) {\n const { signal, cleanup } = createDeadlineSignal(opt.timeoutMs);\n const controller = createLinkedAbortController(opt.signal, signal);\n return [\n controller.signal,\n function abort(reason) {\n // We peek at the deadline signal because fetch() will throw an error on\n // abort that discards the signal reason.\n const e = ConnectError.from(signal.aborted ? getAbortSignalReason(signal) : reason);\n controller.abort(e);\n cleanup();\n return Promise.reject(e);\n },\n function done() {\n cleanup();\n controller.abort();\n },\n ];\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n/**\n * Asserts that the fetch API is available.\n */\nexport function assertFetchApi() {\n try {\n new Headers();\n }\n catch (_) {\n throw new Error(\"connect-web requires the fetch API. Are you running on an old version of Node.js? Node.js is not supported in Connect for Web - please stay tuned for Connect for Node.\");\n }\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { findTrailerError } from \"./trailer-status.js\";\n/**\n * Validates a trailer for the gRPC and the gRPC-web protocol.\n * Throws a ConnectError if the trailer contains an error status.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function validateTrailer(trailer, header) {\n const err = findTrailerError(trailer);\n if (err) {\n header.forEach((value, key) => {\n err.metadata.append(key, value);\n });\n throw err;\n }\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { headerAcceptEncoding, headerContentType, headerEncoding, headerTimeout, headerXGrpcWeb, headerUserAgent, headerXUserAgent, } from \"./headers.js\";\nimport { contentTypeJson, contentTypeProto } from \"./content-type.js\";\n/**\n * Creates headers for a gRPC-web request.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function requestHeader(useBinaryFormat, timeoutMs, userProvidedHeaders, setUserAgent) {\n const result = new Headers(userProvidedHeaders !== null && userProvidedHeaders !== void 0 ? userProvidedHeaders : {});\n // Note that we do not support the grpc-web-text format.\n // https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-WEB.md#protocol-differences-vs-grpc-over-http2\n result.set(headerContentType, useBinaryFormat ? contentTypeProto : contentTypeJson);\n result.set(headerXGrpcWeb, \"1\");\n // Note that we do not strictly comply with gRPC user agents.\n // We use \"connect-es/1.2.3\" where gRPC would use \"grpc-es/1.2.3\".\n // See https://github.com/grpc/grpc/blob/c462bb8d485fc1434ecfae438823ca8d14cf3154/doc/PROTOCOL-HTTP2.md#user-agents\n result.set(headerXUserAgent, \"connect-es/1.4.0\");\n if (setUserAgent) {\n result.set(headerUserAgent, \"connect-es/1.4.0\");\n }\n if (timeoutMs !== undefined) {\n result.set(headerTimeout, `${timeoutMs}m`);\n }\n return result;\n}\n/**\n * Creates headers for a gRPC-web request with compression.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function requestHeaderWithCompression(useBinaryFormat, timeoutMs, userProvidedHeaders, acceptCompression, sendCompression, setUserAgent) {\n const result = requestHeader(useBinaryFormat, timeoutMs, userProvidedHeaders, setUserAgent);\n if (sendCompression != null) {\n result.set(headerEncoding, sendCompression.name);\n }\n if (acceptCompression.length > 0) {\n result.set(headerAcceptEncoding, acceptCompression.map((c) => c.name).join(\",\"));\n }\n return result;\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { Code } from \"../code.js\";\n/**\n * Determine the gRPC-web error code for the given HTTP status code.\n * See https://github.com/grpc/grpc/blob/master/doc/http-grpc-status-mapping.md.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function codeFromHttpStatus(httpStatus) {\n switch (httpStatus) {\n case 400: // Bad Request\n return Code.Internal;\n case 401: // Unauthorized\n return Code.Unauthenticated;\n case 403: // Forbidden\n return Code.PermissionDenied;\n case 404: // Not Found\n return Code.Unimplemented;\n case 429: // Too Many Requests\n return Code.Unavailable;\n case 502: // Bad Gateway\n return Code.Unavailable;\n case 503: // Service Unavailable\n return Code.Unavailable;\n case 504: // Gateway Timeout\n return Code.Unavailable;\n default:\n // 200 is UNKNOWN because there should be a grpc-status in case of truly OK response.\n return Code.Unknown;\n }\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nimport { ConnectError } from \"../connect-error.js\";\nimport { Code } from \"../code.js\";\nimport { headerEncoding, headerGrpcMessage, headerGrpcStatus, } from \"./headers.js\";\nimport { codeFromHttpStatus } from \"../protocol-grpc/http-status.js\";\nimport { findTrailerError } from \"../protocol-grpc/trailer-status.js\";\n/**\n * Validates response status and header for the gRPC-web protocol.\n *\n * Throws a ConnectError if the header contains an error status,\n * or if the HTTP status indicates an error.\n *\n * Returns an object that indicates whether a gRPC status was found\n * in the response header. In this case, clients can not expect a\n * trailer.\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function validateResponse(status, headers) {\n var _a;\n // For compatibility with the `grpc-web` package, we treat all HTTP status\n // codes in the 200 range as valid, not just HTTP 200.\n if (status >= 200 && status < 300) {\n const err = findTrailerError(headers);\n if (err) {\n throw err;\n }\n return { foundStatus: headers.has(headerGrpcStatus) };\n }\n throw new ConnectError(decodeURIComponent((_a = headers.get(headerGrpcMessage)) !== null && _a !== void 0 ? _a : `HTTP ${status}`), codeFromHttpStatus(status), headers);\n}\n/**\n * Validates response status and header for the gRPC-web protocol.\n * This function is identical to validateResponse(), but also verifies\n * that a given encoding header is acceptable.\n *\n * Returns an object with the response compression, and a boolean\n * indicating whether a gRPC status was found in the response header\n * (in this case, clients can not expect a trailer).\n *\n * @private Internal code, does not follow semantic versioning.\n */\nexport function validateResponseWithCompression(acceptCompression, status, headers) {\n const { foundStatus } = validateResponse(status, headers);\n let compression;\n const encoding = headers.get(headerEncoding);\n if (encoding !== null && encoding.toLowerCase() !== \"identity\") {\n compression = acceptCompression.find((c) => c.name === encoding);\n if (!compression) {\n throw new ConnectError(`unsupported response encoding \"${encoding}\"`, Code.InvalidArgument, headers);\n }\n }\n return {\n foundStatus,\n compression,\n };\n}\n","// Copyright 2021-2024 The Connect Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\nvar __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }\nvar __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;\n function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }\n function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\n function fulfill(value) { resume(\"next\", value); }\n function reject(value) { resume(\"throw\", value); }\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\n};\nimport { Message, MethodKind } from \"@bufbuild/protobuf\";\nimport { createContextValues } from \"@connectrpc/connect\";\nimport { createClientMethodSerializers, createEnvelopeReadableStream, createMethodUrl, encodeEnvelope, runStreamingCall, runUnaryCall, } from \"@connectrpc/connect/protocol\";\nimport { requestHeader, trailerFlag, trailerParse, validateResponse, validateTrailer, } from \"@connectrpc/connect/protocol-grpc-web\";\nimport { assertFetchApi } from \"./assert-fetch-api.js\";\n/**\n * Create a Transport for the gRPC-web protocol. The protocol encodes\n * trailers in the response body and makes unary and server-streaming\n * methods available to web browsers. It uses the fetch API to make\n * HTTP requests.\n *\n * Note that this transport does not implement the grpc-web-text format,\n * which applies base64 encoding to the request and response bodies to\n * support reading streaming responses from an XMLHttpRequest.\n */\nexport function createGrpcWebTransport(options) {\n var _a;\n assertFetchApi();\n const useBinaryFormat = (_a = options.useBinaryFormat) !== null && _a !== void 0 ? _a : true;\n return {\n async unary(service, method, signal, timeoutMs, header, message, contextValues) {\n var _a;\n const { serialize, parse } = createClientMethodSerializers(method, useBinaryFormat, options.jsonOptions, options.binaryOptions);\n timeoutMs =\n timeoutMs === undefined\n ? options.defaultTimeoutMs\n : timeoutMs <= 0\n ? undefined\n : timeoutMs;\n return await runUnaryCall({\n interceptors: options.interceptors,\n signal,\n timeoutMs,\n req: {\n stream: false,\n service,\n method,\n url: createMethodUrl(options.baseUrl, service, method),\n init: {\n method: \"POST\",\n credentials: (_a = options.credentials) !== null && _a !== void 0 ? _a : \"same-origin\",\n redirect: \"error\",\n mode: \"cors\",\n },\n header: requestHeader(useBinaryFormat, timeoutMs, header, false),\n contextValues: contextValues !== null && contextValues !== void 0 ? contextValues : createContextValues(),\n message,\n },\n next: async (req) => {\n var _a;\n const fetch = (_a = options.fetch) !== null && _a !== void 0 ? _a : globalThis.fetch;\n const response = await fetch(req.url, Object.assign(Object.assign({}, req.init), { headers: req.header, signal: req.signal, body: encodeEnvelope(0, serialize(req.message)) }));\n validateResponse(response.status, response.headers);\n if (!response.body) {\n throw \"missing response body\";\n }\n const reader = createEnvelopeReadableStream(response.body).getReader();\n let trailer;\n let message;\n for (;;) {\n const r = await reader.read();\n if (r.done) {\n break;\n }\n const { flags, data } = r.value;\n if (flags === trailerFlag) {\n if (trailer !== undefined) {\n throw \"extra trailer\";\n }\n // Unary responses require exactly one response message, but in\n // case of an error, it is perfectly valid to have a response body\n // that only contains error trailers.\n trailer = trailerParse(data);\n continue;\n }\n if (message !== undefined) {\n throw \"extra message\";\n }\n message = parse(data);\n }\n if (trailer === undefined) {\n throw \"missing trailer\";\n }\n validateTrailer(trailer, response.headers);\n if (message === undefined) {\n throw \"missing message\";\n }\n return {\n stream: false,\n service,\n method,\n header: response.headers,\n message,\n trailer,\n };\n },\n });\n },\n async stream(service, method, signal, timeoutMs, header, input, contextValues) {\n var _a;\n const { serialize, parse } = createClientMethodSerializers(method, useBinaryFormat, options.jsonOptions, options.binaryOptions);\n function parseResponseBody(body, foundStatus, trailerTarget, header) {\n return __asyncGenerator(this, arguments, function* parseResponseBody_1() {\n const reader = createEnvelopeReadableStream(body).getReader();\n if (foundStatus) {\n // A grpc-status: 0 response header was present. This is a \"trailers-only\"\n // response (a response without a body and no trailers).\n //\n // The spec seems to disallow a trailers-only response for status 0 - we are\n // lenient and only verify that the body is empty.\n //\n // > [...] Trailers-Only is permitted for calls that produce an immediate error.\n // See https://github.com/grpc/grpc/blob/master/doc/PROTOCOL-HTTP2.md\n if (!(yield __await(reader.read())).done) {\n throw \"extra data for trailers-only\";\n }\n return yield __await(void 0);\n }\n let trailerReceived = false;\n for (;;) {\n const result = yield __await(reader.read());\n if (result.done) {\n break;\n }\n const { flags, data } = result.value;\n if ((flags & trailerFlag) === trailerFlag) {\n if (trailerReceived) {\n throw \"extra trailer\";\n }\n trailerReceived = true;\n const trailer = trailerParse(data);\n validateTrailer(trailer, header);\n trailer.forEach((value, key) => trailerTarget.set(key, value));\n continue;\n }\n if (trailerReceived) {\n throw \"extra message\";\n }\n yield yield __await(parse(data));\n continue;\n }\n if (!trailerReceived) {\n throw \"missing trailer\";\n }\n });\n }\n async function createRequestBody(input) {\n if (method.kind != MethodKind.ServerStreaming) {\n throw \"The fetch API does not support streaming request bodies\";\n }\n const r = await input[Symbol.asyncIterator]().next();\n if (r.done == true) {\n throw \"missing request message\";\n }\n return encodeEnvelope(0, serialize(r.value));\n }\n timeoutMs =\n timeoutMs === undefined\n ? options.defaultTimeoutMs\n : timeoutMs <= 0\n ? undefined\n : timeoutMs;\n return runStreamingCall({\n interceptors: options.interceptors,\n signal,\n timeoutMs,\n req: {\n stream: true,\n service,\n method,\n url: createMethodUrl(options.baseUrl, service, method),\n init: {\n method: \"POST\",\n credentials: (_a = options.credentials) !== null && _a !== void 0 ? _a : \"same-origin\",\n redirect: \"error\",\n mode: \"cors\",\n },\n header: requestHeader(useBinaryFormat, timeoutMs, header, false),\n contextValues: contextValues !== null && contextValues !== void 0 ? contextValues : createContextValues(),\n message: input,\n },\n next: async (req) => {\n var _a;\n const fetch = (_a = options.fetch) !== null && _a !== void 0 ? _a : globalThis.fetch;\n const fRes = await fetch(req.url, Object.assign(Object.assign({}, req.init), { headers: req.header, signal: req.signal, body: await createRequestBody(req.message) }));\n const { foundStatus } = validateResponse(fRes.status, fRes.headers);\n if (!fRes.body) {\n throw \"missing response body\";\n }\n const trailer = new Headers();\n const res = Object.assign(Object.assign({}, req), { header: fRes.headers, trailer, message: parseResponseBody(fRes.body, foundStatus, trailer, fRes.headers) });\n return res;\n },\n });\n },\n };\n}\n","//\n// Copyright 2022 The Yorkie Authors. All rights reserved.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// @generated by protoc-gen-es v1.10.0 with parameter \"target=ts,import_extension=none\"\n// @generated from file src/api/yorkie/v1/resources.proto (package yorkie.v1, syntax proto3)\n/* eslint-disable */\n// @ts-nocheck\n\nimport type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from \"@bufbuild/protobuf\";\nimport { Message, proto3, protoInt64, StringValue, Timestamp } from \"@bufbuild/protobuf\";\n\n/**\n * @generated from enum yorkie.v1.ValueType\n */\nexport enum ValueType {\n /**\n * @generated from enum value: VALUE_TYPE_NULL = 0;\n */\n NULL = 0,\n\n /**\n * @generated from enum value: VALUE_TYPE_BOOLEAN = 1;\n */\n BOOLEAN = 1,\n\n /**\n * @generated from enum value: VALUE_TYPE_INTEGER = 2;\n */\n INTEGER = 2,\n\n /**\n * @generated from enum value: VALUE_TYPE_LONG = 3;\n */\n LONG = 3,\n\n /**\n * @generated from enum value: VALUE_TYPE_DOUBLE = 4;\n */\n DOUBLE = 4,\n\n /**\n * @generated from enum value: VALUE_TYPE_STRING = 5;\n */\n STRING = 5,\n\n /**\n * @generated from enum value: VALUE_TYPE_BYTES = 6;\n */\n BYTES = 6,\n\n /**\n * @generated from enum value: VALUE_TYPE_DATE = 7;\n */\n DATE = 7,\n\n /**\n * @generated from enum value: VALUE_TYPE_JSON_OBJECT = 8;\n */\n JSON_OBJECT = 8,\n\n /**\n * @generated from enum value: VALUE_TYPE_JSON_ARRAY = 9;\n */\n JSON_ARRAY = 9,\n\n /**\n * @generated from enum value: VALUE_TYPE_TEXT = 10;\n */\n TEXT = 10,\n\n /**\n * @generated from enum value: VALUE_TYPE_INTEGER_CNT = 11;\n */\n INTEGER_CNT = 11,\n\n /**\n * @generated from enum value: VALUE_TYPE_LONG_CNT = 12;\n */\n LONG_CNT = 12,\n\n /**\n * @generated from enum value: VALUE_TYPE_TREE = 13;\n */\n TREE = 13,\n}\n// Retrieve enum metadata with: proto3.getEnumType(ValueType)\nproto3.util.setEnumType(ValueType, \"yorkie.v1.ValueType\", [\n { no: 0, name: \"VALUE_TYPE_NULL\" },\n { no: 1, name: \"VALUE_TYPE_BOOLEAN\" },\n { no: 2, name: \"VALUE_TYPE_INTEGER\" },\n { no: 3, name: \"VALUE_TYPE_LONG\" },\n { no: 4, name: \"VALUE_TYPE_DOUBLE\" },\n { no: 5, name: \"VALUE_TYPE_STRING\" },\n { no: 6, name: \"VALUE_TYPE_BYTES\" },\n { no: 7, name: \"VALUE_TYPE_DATE\" },\n { no: 8, name: \"VALUE_TYPE_JSON_OBJECT\" },\n { no: 9, name: \"VALUE_TYPE_JSON_ARRAY\" },\n { no: 10, name: \"VALUE_TYPE_TEXT\" },\n { no: 11, name: \"VALUE_TYPE_INTEGER_CNT\" },\n { no: 12, name: \"VALUE_TYPE_LONG_CNT\" },\n { no: 13, name: \"VALUE_TYPE_TREE\" },\n]);\n\n/**\n * @generated from enum yorkie.v1.DocEventType\n */\nexport enum DocEventType {\n /**\n * @generated from enum value: DOC_EVENT_TYPE_DOCUMENT_CHANGED = 0;\n */\n DOCUMENT_CHANGED = 0,\n\n /**\n * @generated from enum value: DOC_EVENT_TYPE_DOCUMENT_WATCHED = 1;\n */\n DOCUMENT_WATCHED = 1,\n\n /**\n * @generated from enum value: DOC_EVENT_TYPE_DOCUMENT_UNWATCHED = 2;\n */\n DOCUMENT_UNWATCHED = 2,\n\n /**\n * @generated from enum value: DOC_EVENT_TYPE_DOCUMENT_BROADCAST = 3;\n */\n DOCUMENT_BROADCAST = 3,\n}\n// Retrieve enum metadata with: proto3.getEnumType(DocEventType)\nproto3.util.setEnumType(DocEventType, \"yorkie.v1.DocEventType\", [\n { no: 0, name: \"DOC_EVENT_TYPE_DOCUMENT_CHANGED\" },\n { no: 1, name: \"DOC_EVENT_TYPE_DOCUMENT_WATCHED\" },\n { no: 2, name: \"DOC_EVENT_TYPE_DOCUMENT_UNWATCHED\" },\n { no: 3, name: \"DOC_EVENT_TYPE_DOCUMENT_BROADCAST\" },\n]);\n\n/**\n * ///////////////////////////////////////\n * Messages for Snapshot //\n * ///////////////////////////////////////\n *\n * @generated from message yorkie.v1.Snapshot\n */\nexport class Snapshot extends Message<Snapshot> {\n /**\n * @generated from field: yorkie.v1.JSONElement root = 1;\n */\n root?: JSONElement;\n\n /**\n * @generated from field: map<string, yorkie.v1.Presence> presences = 2;\n */\n presences: { [key: string]: Presence } = {};\n\n constructor(data?: PartialMessage<Snapshot>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.Snapshot\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"root\", kind: \"message\", T: JSONElement },\n { no: 2, name: \"presences\", kind: \"map\", K: 9 /* ScalarType.STRING */, V: {kind: \"message\", T: Presence} },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Snapshot {\n return new Snapshot().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Snapshot {\n return new Snapshot().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Snapshot {\n return new Snapshot().fromJsonString(jsonString, options);\n }\n\n static equals(a: Snapshot | PlainMessage<Snapshot> | undefined, b: Snapshot | PlainMessage<Snapshot> | undefined): boolean {\n return proto3.util.equals(Snapshot, a, b);\n }\n}\n\n/**\n * ChangePack is a message that contains all changes that occurred in a document.\n * It is used to synchronize changes between clients and servers.\n *\n * @generated from message yorkie.v1.ChangePack\n */\nexport class ChangePack extends Message<ChangePack> {\n /**\n * @generated from field: string document_key = 1;\n */\n documentKey = \"\";\n\n /**\n * @generated from field: yorkie.v1.Checkpoint checkpoint = 2;\n */\n checkpoint?: Checkpoint;\n\n /**\n * @generated from field: bytes snapshot = 3;\n */\n snapshot = new Uint8Array(0);\n\n /**\n * @generated from field: repeated yorkie.v1.Change changes = 4;\n */\n changes: Change[] = [];\n\n /**\n * @generated from field: yorkie.v1.TimeTicket min_synced_ticket = 5;\n */\n minSyncedTicket?: TimeTicket;\n\n /**\n * @generated from field: bool is_removed = 6;\n */\n isRemoved = false;\n\n /**\n * @generated from field: yorkie.v1.VersionVector version_vector = 7;\n */\n versionVector?: VersionVector;\n\n constructor(data?: PartialMessage<ChangePack>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.ChangePack\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"document_key\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"checkpoint\", kind: \"message\", T: Checkpoint },\n { no: 3, name: \"snapshot\", kind: \"scalar\", T: 12 /* ScalarType.BYTES */ },\n { no: 4, name: \"changes\", kind: \"message\", T: Change, repeated: true },\n { no: 5, name: \"min_synced_ticket\", kind: \"message\", T: TimeTicket },\n { no: 6, name: \"is_removed\", kind: \"scalar\", T: 8 /* ScalarType.BOOL */ },\n { no: 7, name: \"version_vector\", kind: \"message\", T: VersionVector },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ChangePack {\n return new ChangePack().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ChangePack {\n return new ChangePack().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ChangePack {\n return new ChangePack().fromJsonString(jsonString, options);\n }\n\n static equals(a: ChangePack | PlainMessage<ChangePack> | undefined, b: ChangePack | PlainMessage<ChangePack> | undefined): boolean {\n return proto3.util.equals(ChangePack, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.Change\n */\nexport class Change extends Message<Change> {\n /**\n * @generated from field: yorkie.v1.ChangeID id = 1;\n */\n id?: ChangeID;\n\n /**\n * @generated from field: string message = 2;\n */\n message = \"\";\n\n /**\n * @generated from field: repeated yorkie.v1.Operation operations = 3;\n */\n operations: Operation[] = [];\n\n /**\n * @generated from field: yorkie.v1.PresenceChange presence_change = 4;\n */\n presenceChange?: PresenceChange;\n\n constructor(data?: PartialMessage<Change>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.Change\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"id\", kind: \"message\", T: ChangeID },\n { no: 2, name: \"message\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 3, name: \"operations\", kind: \"message\", T: Operation, repeated: true },\n { no: 4, name: \"presence_change\", kind: \"message\", T: PresenceChange },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Change {\n return new Change().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Change {\n return new Change().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Change {\n return new Change().fromJsonString(jsonString, options);\n }\n\n static equals(a: Change | PlainMessage<Change> | undefined, b: Change | PlainMessage<Change> | undefined): boolean {\n return proto3.util.equals(Change, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.ChangeID\n */\nexport class ChangeID extends Message<ChangeID> {\n /**\n * @generated from field: uint32 client_seq = 1;\n */\n clientSeq = 0;\n\n /**\n * @generated from field: int64 server_seq = 2;\n */\n serverSeq = protoInt64.zero;\n\n /**\n * @generated from field: int64 lamport = 3;\n */\n lamport = protoInt64.zero;\n\n /**\n * @generated from field: bytes actor_id = 4;\n */\n actorId = new Uint8Array(0);\n\n /**\n * @generated from field: yorkie.v1.VersionVector version_vector = 5;\n */\n versionVector?: VersionVector;\n\n constructor(data?: PartialMessage<ChangeID>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.ChangeID\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"client_seq\", kind: \"scalar\", T: 13 /* ScalarType.UINT32 */ },\n { no: 2, name: \"server_seq\", kind: \"scalar\", T: 3 /* ScalarType.INT64 */ },\n { no: 3, name: \"lamport\", kind: \"scalar\", T: 3 /* ScalarType.INT64 */ },\n { no: 4, name: \"actor_id\", kind: \"scalar\", T: 12 /* ScalarType.BYTES */ },\n { no: 5, name: \"version_vector\", kind: \"message\", T: VersionVector },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ChangeID {\n return new ChangeID().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ChangeID {\n return new ChangeID().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ChangeID {\n return new ChangeID().fromJsonString(jsonString, options);\n }\n\n static equals(a: ChangeID | PlainMessage<ChangeID> | undefined, b: ChangeID | PlainMessage<ChangeID> | undefined): boolean {\n return proto3.util.equals(ChangeID, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.VersionVector\n */\nexport class VersionVector extends Message<VersionVector> {\n /**\n * @generated from field: map<string, int64> vector = 1;\n */\n vector: { [key: string]: bigint } = {};\n\n constructor(data?: PartialMessage<VersionVector>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.VersionVector\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"vector\", kind: \"map\", K: 9 /* ScalarType.STRING */, V: {kind: \"scalar\", T: 3 /* ScalarType.INT64 */} },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): VersionVector {\n return new VersionVector().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): VersionVector {\n return new VersionVector().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): VersionVector {\n return new VersionVector().fromJsonString(jsonString, options);\n }\n\n static equals(a: VersionVector | PlainMessage<VersionVector> | undefined, b: VersionVector | PlainMessage<VersionVector> | undefined): boolean {\n return proto3.util.equals(VersionVector, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.Operation\n */\nexport class Operation extends Message<Operation> {\n /**\n * @generated from oneof yorkie.v1.Operation.body\n */\n body: {\n /**\n * @generated from field: yorkie.v1.Operation.Set set = 1;\n */\n value: Operation_Set;\n case: \"set\";\n } | {\n /**\n * @generated from field: yorkie.v1.Operation.Add add = 2;\n */\n value: Operation_Add;\n case: \"add\";\n } | {\n /**\n * @generated from field: yorkie.v1.Operation.Move move = 3;\n */\n value: Operation_Move;\n case: \"move\";\n } | {\n /**\n * @generated from field: yorkie.v1.Operation.Remove remove = 4;\n */\n value: Operation_Remove;\n case: \"remove\";\n } | {\n /**\n * @generated from field: yorkie.v1.Operation.Edit edit = 5;\n */\n value: Operation_Edit;\n case: \"edit\";\n } | {\n /**\n * @generated from field: yorkie.v1.Operation.Select select = 6;\n */\n value: Operation_Select;\n case: \"select\";\n } | {\n /**\n * @generated from field: yorkie.v1.Operation.Style style = 7;\n */\n value: Operation_Style;\n case: \"style\";\n } | {\n /**\n * @generated from field: yorkie.v1.Operation.Increase increase = 8;\n */\n value: Operation_Increase;\n case: \"increase\";\n } | {\n /**\n * @generated from field: yorkie.v1.Operation.TreeEdit tree_edit = 9;\n */\n value: Operation_TreeEdit;\n case: \"treeEdit\";\n } | {\n /**\n * @generated from field: yorkie.v1.Operation.TreeStyle tree_style = 10;\n */\n value: Operation_TreeStyle;\n case: \"treeStyle\";\n } | {\n /**\n * @generated from field: yorkie.v1.Operation.ArraySet array_set = 11;\n */\n value: Operation_ArraySet;\n case: \"arraySet\";\n } | { case: undefined; value?: undefined } = { case: undefined };\n\n constructor(data?: PartialMessage<Operation>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.Operation\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"set\", kind: \"message\", T: Operation_Set, oneof: \"body\" },\n { no: 2, name: \"add\", kind: \"message\", T: Operation_Add, oneof: \"body\" },\n { no: 3, name: \"move\", kind: \"message\", T: Operation_Move, oneof: \"body\" },\n { no: 4, name: \"remove\", kind: \"message\", T: Operation_Remove, oneof: \"body\" },\n { no: 5, name: \"edit\", kind: \"message\", T: Operation_Edit, oneof: \"body\" },\n { no: 6, name: \"select\", kind: \"message\", T: Operation_Select, oneof: \"body\" },\n { no: 7, name: \"style\", kind: \"message\", T: Operation_Style, oneof: \"body\" },\n { no: 8, name: \"increase\", kind: \"message\", T: Operation_Increase, oneof: \"body\" },\n { no: 9, name: \"tree_edit\", kind: \"message\", T: Operation_TreeEdit, oneof: \"body\" },\n { no: 10, name: \"tree_style\", kind: \"message\", T: Operation_TreeStyle, oneof: \"body\" },\n { no: 11, name: \"array_set\", kind: \"message\", T: Operation_ArraySet, oneof: \"body\" },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Operation {\n return new Operation().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Operation {\n return new Operation().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Operation {\n return new Operation().fromJsonString(jsonString, options);\n }\n\n static equals(a: Operation | PlainMessage<Operation> | undefined, b: Operation | PlainMessage<Operation> | undefined): boolean {\n return proto3.util.equals(Operation, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.Operation.Set\n */\nexport class Operation_Set extends Message<Operation_Set> {\n /**\n * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1;\n */\n parentCreatedAt?: TimeTicket;\n\n /**\n * @generated from field: string key = 2;\n */\n key = \"\";\n\n /**\n * @generated from field: yorkie.v1.JSONElementSimple value = 3;\n */\n value?: JSONElementSimple;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket executed_at = 4;\n */\n executedAt?: TimeTicket;\n\n constructor(data?: PartialMessage<Operation_Set>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.Operation.Set\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"parent_created_at\", kind: \"message\", T: TimeTicket },\n { no: 2, name: \"key\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 3, name: \"value\", kind: \"message\", T: JSONElementSimple },\n { no: 4, name: \"executed_at\", kind: \"message\", T: TimeTicket },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Operation_Set {\n return new Operation_Set().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Operation_Set {\n return new Operation_Set().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Operation_Set {\n return new Operation_Set().fromJsonString(jsonString, options);\n }\n\n static equals(a: Operation_Set | PlainMessage<Operation_Set> | undefined, b: Operation_Set | PlainMessage<Operation_Set> | undefined): boolean {\n return proto3.util.equals(Operation_Set, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.Operation.Add\n */\nexport class Operation_Add extends Message<Operation_Add> {\n /**\n * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1;\n */\n parentCreatedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket prev_created_at = 2;\n */\n prevCreatedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.JSONElementSimple value = 3;\n */\n value?: JSONElementSimple;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket executed_at = 4;\n */\n executedAt?: TimeTicket;\n\n constructor(data?: PartialMessage<Operation_Add>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.Operation.Add\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"parent_created_at\", kind: \"message\", T: TimeTicket },\n { no: 2, name: \"prev_created_at\", kind: \"message\", T: TimeTicket },\n { no: 3, name: \"value\", kind: \"message\", T: JSONElementSimple },\n { no: 4, name: \"executed_at\", kind: \"message\", T: TimeTicket },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Operation_Add {\n return new Operation_Add().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Operation_Add {\n return new Operation_Add().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Operation_Add {\n return new Operation_Add().fromJsonString(jsonString, options);\n }\n\n static equals(a: Operation_Add | PlainMessage<Operation_Add> | undefined, b: Operation_Add | PlainMessage<Operation_Add> | undefined): boolean {\n return proto3.util.equals(Operation_Add, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.Operation.Move\n */\nexport class Operation_Move extends Message<Operation_Move> {\n /**\n * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1;\n */\n parentCreatedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket prev_created_at = 2;\n */\n prevCreatedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket created_at = 3;\n */\n createdAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket executed_at = 4;\n */\n executedAt?: TimeTicket;\n\n constructor(data?: PartialMessage<Operation_Move>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.Operation.Move\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"parent_created_at\", kind: \"message\", T: TimeTicket },\n { no: 2, name: \"prev_created_at\", kind: \"message\", T: TimeTicket },\n { no: 3, name: \"created_at\", kind: \"message\", T: TimeTicket },\n { no: 4, name: \"executed_at\", kind: \"message\", T: TimeTicket },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Operation_Move {\n return new Operation_Move().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Operation_Move {\n return new Operation_Move().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Operation_Move {\n return new Operation_Move().fromJsonString(jsonString, options);\n }\n\n static equals(a: Operation_Move | PlainMessage<Operation_Move> | undefined, b: Operation_Move | PlainMessage<Operation_Move> | undefined): boolean {\n return proto3.util.equals(Operation_Move, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.Operation.Remove\n */\nexport class Operation_Remove extends Message<Operation_Remove> {\n /**\n * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1;\n */\n parentCreatedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket created_at = 2;\n */\n createdAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket executed_at = 3;\n */\n executedAt?: TimeTicket;\n\n constructor(data?: PartialMessage<Operation_Remove>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.Operation.Remove\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"parent_created_at\", kind: \"message\", T: TimeTicket },\n { no: 2, name: \"created_at\", kind: \"message\", T: TimeTicket },\n { no: 3, name: \"executed_at\", kind: \"message\", T: TimeTicket },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Operation_Remove {\n return new Operation_Remove().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Operation_Remove {\n return new Operation_Remove().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Operation_Remove {\n return new Operation_Remove().fromJsonString(jsonString, options);\n }\n\n static equals(a: Operation_Remove | PlainMessage<Operation_Remove> | undefined, b: Operation_Remove | PlainMessage<Operation_Remove> | undefined): boolean {\n return proto3.util.equals(Operation_Remove, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.Operation.Edit\n */\nexport class Operation_Edit extends Message<Operation_Edit> {\n /**\n * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1;\n */\n parentCreatedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TextNodePos from = 2;\n */\n from?: TextNodePos;\n\n /**\n * @generated from field: yorkie.v1.TextNodePos to = 3;\n */\n to?: TextNodePos;\n\n /**\n * @generated from field: map<string, yorkie.v1.TimeTicket> created_at_map_by_actor = 4;\n */\n createdAtMapByActor: { [key: string]: TimeTicket } = {};\n\n /**\n * @generated from field: string content = 5;\n */\n content = \"\";\n\n /**\n * @generated from field: yorkie.v1.TimeTicket executed_at = 6;\n */\n executedAt?: TimeTicket;\n\n /**\n * @generated from field: map<string, string> attributes = 7;\n */\n attributes: { [key: string]: string } = {};\n\n constructor(data?: PartialMessage<Operation_Edit>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.Operation.Edit\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"parent_created_at\", kind: \"message\", T: TimeTicket },\n { no: 2, name: \"from\", kind: \"message\", T: TextNodePos },\n { no: 3, name: \"to\", kind: \"message\", T: TextNodePos },\n { no: 4, name: \"created_at_map_by_actor\", kind: \"map\", K: 9 /* ScalarType.STRING */, V: {kind: \"message\", T: TimeTicket} },\n { no: 5, name: \"content\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 6, name: \"executed_at\", kind: \"message\", T: TimeTicket },\n { no: 7, name: \"attributes\", kind: \"map\", K: 9 /* ScalarType.STRING */, V: {kind: \"scalar\", T: 9 /* ScalarType.STRING */} },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Operation_Edit {\n return new Operation_Edit().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Operation_Edit {\n return new Operation_Edit().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Operation_Edit {\n return new Operation_Edit().fromJsonString(jsonString, options);\n }\n\n static equals(a: Operation_Edit | PlainMessage<Operation_Edit> | undefined, b: Operation_Edit | PlainMessage<Operation_Edit> | undefined): boolean {\n return proto3.util.equals(Operation_Edit, a, b);\n }\n}\n\n/**\n * NOTE(hackerwins): Select Operation is not used in the current version.\n * In the previous version, it was used to represent selection of Text.\n * However, it has been replaced by Presence now. It is retained for backward\n * compatibility purposes.\n *\n * @generated from message yorkie.v1.Operation.Select\n */\nexport class Operation_Select extends Message<Operation_Select> {\n /**\n * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1;\n */\n parentCreatedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TextNodePos from = 2;\n */\n from?: TextNodePos;\n\n /**\n * @generated from field: yorkie.v1.TextNodePos to = 3;\n */\n to?: TextNodePos;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket executed_at = 4;\n */\n executedAt?: TimeTicket;\n\n constructor(data?: PartialMessage<Operation_Select>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.Operation.Select\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"parent_created_at\", kind: \"message\", T: TimeTicket },\n { no: 2, name: \"from\", kind: \"message\", T: TextNodePos },\n { no: 3, name: \"to\", kind: \"message\", T: TextNodePos },\n { no: 4, name: \"executed_at\", kind: \"message\", T: TimeTicket },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Operation_Select {\n return new Operation_Select().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Operation_Select {\n return new Operation_Select().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Operation_Select {\n return new Operation_Select().fromJsonString(jsonString, options);\n }\n\n static equals(a: Operation_Select | PlainMessage<Operation_Select> | undefined, b: Operation_Select | PlainMessage<Operation_Select> | undefined): boolean {\n return proto3.util.equals(Operation_Select, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.Operation.Style\n */\nexport class Operation_Style extends Message<Operation_Style> {\n /**\n * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1;\n */\n parentCreatedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TextNodePos from = 2;\n */\n from?: TextNodePos;\n\n /**\n * @generated from field: yorkie.v1.TextNodePos to = 3;\n */\n to?: TextNodePos;\n\n /**\n * @generated from field: map<string, string> attributes = 4;\n */\n attributes: { [key: string]: string } = {};\n\n /**\n * @generated from field: yorkie.v1.TimeTicket executed_at = 5;\n */\n executedAt?: TimeTicket;\n\n /**\n * @generated from field: map<string, yorkie.v1.TimeTicket> created_at_map_by_actor = 6;\n */\n createdAtMapByActor: { [key: string]: TimeTicket } = {};\n\n constructor(data?: PartialMessage<Operation_Style>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.Operation.Style\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"parent_created_at\", kind: \"message\", T: TimeTicket },\n { no: 2, name: \"from\", kind: \"message\", T: TextNodePos },\n { no: 3, name: \"to\", kind: \"message\", T: TextNodePos },\n { no: 4, name: \"attributes\", kind: \"map\", K: 9 /* ScalarType.STRING */, V: {kind: \"scalar\", T: 9 /* ScalarType.STRING */} },\n { no: 5, name: \"executed_at\", kind: \"message\", T: TimeTicket },\n { no: 6, name: \"created_at_map_by_actor\", kind: \"map\", K: 9 /* ScalarType.STRING */, V: {kind: \"message\", T: TimeTicket} },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Operation_Style {\n return new Operation_Style().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Operation_Style {\n return new Operation_Style().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Operation_Style {\n return new Operation_Style().fromJsonString(jsonString, options);\n }\n\n static equals(a: Operation_Style | PlainMessage<Operation_Style> | undefined, b: Operation_Style | PlainMessage<Operation_Style> | undefined): boolean {\n return proto3.util.equals(Operation_Style, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.Operation.Increase\n */\nexport class Operation_Increase extends Message<Operation_Increase> {\n /**\n * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1;\n */\n parentCreatedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.JSONElementSimple value = 2;\n */\n value?: JSONElementSimple;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket executed_at = 3;\n */\n executedAt?: TimeTicket;\n\n constructor(data?: PartialMessage<Operation_Increase>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.Operation.Increase\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"parent_created_at\", kind: \"message\", T: TimeTicket },\n { no: 2, name: \"value\", kind: \"message\", T: JSONElementSimple },\n { no: 3, name: \"executed_at\", kind: \"message\", T: TimeTicket },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Operation_Increase {\n return new Operation_Increase().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Operation_Increase {\n return new Operation_Increase().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Operation_Increase {\n return new Operation_Increase().fromJsonString(jsonString, options);\n }\n\n static equals(a: Operation_Increase | PlainMessage<Operation_Increase> | undefined, b: Operation_Increase | PlainMessage<Operation_Increase> | undefined): boolean {\n return proto3.util.equals(Operation_Increase, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.Operation.TreeEdit\n */\nexport class Operation_TreeEdit extends Message<Operation_TreeEdit> {\n /**\n * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1;\n */\n parentCreatedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TreePos from = 2;\n */\n from?: TreePos;\n\n /**\n * @generated from field: yorkie.v1.TreePos to = 3;\n */\n to?: TreePos;\n\n /**\n * @generated from field: map<string, yorkie.v1.TimeTicket> created_at_map_by_actor = 4;\n */\n createdAtMapByActor: { [key: string]: TimeTicket } = {};\n\n /**\n * @generated from field: repeated yorkie.v1.TreeNodes contents = 5;\n */\n contents: TreeNodes[] = [];\n\n /**\n * @generated from field: int32 split_level = 7;\n */\n splitLevel = 0;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket executed_at = 6;\n */\n executedAt?: TimeTicket;\n\n constructor(data?: PartialMessage<Operation_TreeEdit>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.Operation.TreeEdit\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"parent_created_at\", kind: \"message\", T: TimeTicket },\n { no: 2, name: \"from\", kind: \"message\", T: TreePos },\n { no: 3, name: \"to\", kind: \"message\", T: TreePos },\n { no: 4, name: \"created_at_map_by_actor\", kind: \"map\", K: 9 /* ScalarType.STRING */, V: {kind: \"message\", T: TimeTicket} },\n { no: 5, name: \"contents\", kind: \"message\", T: TreeNodes, repeated: true },\n { no: 7, name: \"split_level\", kind: \"scalar\", T: 5 /* ScalarType.INT32 */ },\n { no: 6, name: \"executed_at\", kind: \"message\", T: TimeTicket },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Operation_TreeEdit {\n return new Operation_TreeEdit().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Operation_TreeEdit {\n return new Operation_TreeEdit().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Operation_TreeEdit {\n return new Operation_TreeEdit().fromJsonString(jsonString, options);\n }\n\n static equals(a: Operation_TreeEdit | PlainMessage<Operation_TreeEdit> | undefined, b: Operation_TreeEdit | PlainMessage<Operation_TreeEdit> | undefined): boolean {\n return proto3.util.equals(Operation_TreeEdit, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.Operation.TreeStyle\n */\nexport class Operation_TreeStyle extends Message<Operation_TreeStyle> {\n /**\n * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1;\n */\n parentCreatedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TreePos from = 2;\n */\n from?: TreePos;\n\n /**\n * @generated from field: yorkie.v1.TreePos to = 3;\n */\n to?: TreePos;\n\n /**\n * @generated from field: map<string, string> attributes = 4;\n */\n attributes: { [key: string]: string } = {};\n\n /**\n * @generated from field: yorkie.v1.TimeTicket executed_at = 5;\n */\n executedAt?: TimeTicket;\n\n /**\n * @generated from field: repeated string attributes_to_remove = 6;\n */\n attributesToRemove: string[] = [];\n\n /**\n * @generated from field: map<string, yorkie.v1.TimeTicket> created_at_map_by_actor = 7;\n */\n createdAtMapByActor: { [key: string]: TimeTicket } = {};\n\n constructor(data?: PartialMessage<Operation_TreeStyle>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.Operation.TreeStyle\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"parent_created_at\", kind: \"message\", T: TimeTicket },\n { no: 2, name: \"from\", kind: \"message\", T: TreePos },\n { no: 3, name: \"to\", kind: \"message\", T: TreePos },\n { no: 4, name: \"attributes\", kind: \"map\", K: 9 /* ScalarType.STRING */, V: {kind: \"scalar\", T: 9 /* ScalarType.STRING */} },\n { no: 5, name: \"executed_at\", kind: \"message\", T: TimeTicket },\n { no: 6, name: \"attributes_to_remove\", kind: \"scalar\", T: 9 /* ScalarType.STRING */, repeated: true },\n { no: 7, name: \"created_at_map_by_actor\", kind: \"map\", K: 9 /* ScalarType.STRING */, V: {kind: \"message\", T: TimeTicket} },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Operation_TreeStyle {\n return new Operation_TreeStyle().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Operation_TreeStyle {\n return new Operation_TreeStyle().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Operation_TreeStyle {\n return new Operation_TreeStyle().fromJsonString(jsonString, options);\n }\n\n static equals(a: Operation_TreeStyle | PlainMessage<Operation_TreeStyle> | undefined, b: Operation_TreeStyle | PlainMessage<Operation_TreeStyle> | undefined): boolean {\n return proto3.util.equals(Operation_TreeStyle, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.Operation.ArraySet\n */\nexport class Operation_ArraySet extends Message<Operation_ArraySet> {\n /**\n * @generated from field: yorkie.v1.TimeTicket parent_created_at = 1;\n */\n parentCreatedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket created_at = 2;\n */\n createdAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.JSONElementSimple value = 3;\n */\n value?: JSONElementSimple;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket executed_at = 4;\n */\n executedAt?: TimeTicket;\n\n constructor(data?: PartialMessage<Operation_ArraySet>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.Operation.ArraySet\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"parent_created_at\", kind: \"message\", T: TimeTicket },\n { no: 2, name: \"created_at\", kind: \"message\", T: TimeTicket },\n { no: 3, name: \"value\", kind: \"message\", T: JSONElementSimple },\n { no: 4, name: \"executed_at\", kind: \"message\", T: TimeTicket },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Operation_ArraySet {\n return new Operation_ArraySet().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Operation_ArraySet {\n return new Operation_ArraySet().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Operation_ArraySet {\n return new Operation_ArraySet().fromJsonString(jsonString, options);\n }\n\n static equals(a: Operation_ArraySet | PlainMessage<Operation_ArraySet> | undefined, b: Operation_ArraySet | PlainMessage<Operation_ArraySet> | undefined): boolean {\n return proto3.util.equals(Operation_ArraySet, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.JSONElementSimple\n */\nexport class JSONElementSimple extends Message<JSONElementSimple> {\n /**\n * @generated from field: yorkie.v1.TimeTicket created_at = 1;\n */\n createdAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket moved_at = 2;\n */\n movedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket removed_at = 3;\n */\n removedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.ValueType type = 4;\n */\n type = ValueType.NULL;\n\n /**\n * @generated from field: bytes value = 5;\n */\n value = new Uint8Array(0);\n\n constructor(data?: PartialMessage<JSONElementSimple>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.JSONElementSimple\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"created_at\", kind: \"message\", T: TimeTicket },\n { no: 2, name: \"moved_at\", kind: \"message\", T: TimeTicket },\n { no: 3, name: \"removed_at\", kind: \"message\", T: TimeTicket },\n { no: 4, name: \"type\", kind: \"enum\", T: proto3.getEnumType(ValueType) },\n { no: 5, name: \"value\", kind: \"scalar\", T: 12 /* ScalarType.BYTES */ },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): JSONElementSimple {\n return new JSONElementSimple().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): JSONElementSimple {\n return new JSONElementSimple().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): JSONElementSimple {\n return new JSONElementSimple().fromJsonString(jsonString, options);\n }\n\n static equals(a: JSONElementSimple | PlainMessage<JSONElementSimple> | undefined, b: JSONElementSimple | PlainMessage<JSONElementSimple> | undefined): boolean {\n return proto3.util.equals(JSONElementSimple, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.JSONElement\n */\nexport class JSONElement extends Message<JSONElement> {\n /**\n * @generated from oneof yorkie.v1.JSONElement.body\n */\n body: {\n /**\n * @generated from field: yorkie.v1.JSONElement.JSONObject json_object = 1;\n */\n value: JSONElement_JSONObject;\n case: \"jsonObject\";\n } | {\n /**\n * @generated from field: yorkie.v1.JSONElement.JSONArray json_array = 2;\n */\n value: JSONElement_JSONArray;\n case: \"jsonArray\";\n } | {\n /**\n * @generated from field: yorkie.v1.JSONElement.Primitive primitive = 3;\n */\n value: JSONElement_Primitive;\n case: \"primitive\";\n } | {\n /**\n * @generated from field: yorkie.v1.JSONElement.Text text = 5;\n */\n value: JSONElement_Text;\n case: \"text\";\n } | {\n /**\n * @generated from field: yorkie.v1.JSONElement.Counter counter = 6;\n */\n value: JSONElement_Counter;\n case: \"counter\";\n } | {\n /**\n * @generated from field: yorkie.v1.JSONElement.Tree tree = 7;\n */\n value: JSONElement_Tree;\n case: \"tree\";\n } | { case: undefined; value?: undefined } = { case: undefined };\n\n constructor(data?: PartialMessage<JSONElement>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.JSONElement\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"json_object\", kind: \"message\", T: JSONElement_JSONObject, oneof: \"body\" },\n { no: 2, name: \"json_array\", kind: \"message\", T: JSONElement_JSONArray, oneof: \"body\" },\n { no: 3, name: \"primitive\", kind: \"message\", T: JSONElement_Primitive, oneof: \"body\" },\n { no: 5, name: \"text\", kind: \"message\", T: JSONElement_Text, oneof: \"body\" },\n { no: 6, name: \"counter\", kind: \"message\", T: JSONElement_Counter, oneof: \"body\" },\n { no: 7, name: \"tree\", kind: \"message\", T: JSONElement_Tree, oneof: \"body\" },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): JSONElement {\n return new JSONElement().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): JSONElement {\n return new JSONElement().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): JSONElement {\n return new JSONElement().fromJsonString(jsonString, options);\n }\n\n static equals(a: JSONElement | PlainMessage<JSONElement> | undefined, b: JSONElement | PlainMessage<JSONElement> | undefined): boolean {\n return proto3.util.equals(JSONElement, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.JSONElement.JSONObject\n */\nexport class JSONElement_JSONObject extends Message<JSONElement_JSONObject> {\n /**\n * @generated from field: repeated yorkie.v1.RHTNode nodes = 1;\n */\n nodes: RHTNode[] = [];\n\n /**\n * @generated from field: yorkie.v1.TimeTicket created_at = 2;\n */\n createdAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket moved_at = 3;\n */\n movedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket removed_at = 4;\n */\n removedAt?: TimeTicket;\n\n constructor(data?: PartialMessage<JSONElement_JSONObject>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.JSONElement.JSONObject\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"nodes\", kind: \"message\", T: RHTNode, repeated: true },\n { no: 2, name: \"created_at\", kind: \"message\", T: TimeTicket },\n { no: 3, name: \"moved_at\", kind: \"message\", T: TimeTicket },\n { no: 4, name: \"removed_at\", kind: \"message\", T: TimeTicket },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): JSONElement_JSONObject {\n return new JSONElement_JSONObject().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): JSONElement_JSONObject {\n return new JSONElement_JSONObject().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): JSONElement_JSONObject {\n return new JSONElement_JSONObject().fromJsonString(jsonString, options);\n }\n\n static equals(a: JSONElement_JSONObject | PlainMessage<JSONElement_JSONObject> | undefined, b: JSONElement_JSONObject | PlainMessage<JSONElement_JSONObject> | undefined): boolean {\n return proto3.util.equals(JSONElement_JSONObject, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.JSONElement.JSONArray\n */\nexport class JSONElement_JSONArray extends Message<JSONElement_JSONArray> {\n /**\n * @generated from field: repeated yorkie.v1.RGANode nodes = 1;\n */\n nodes: RGANode[] = [];\n\n /**\n * @generated from field: yorkie.v1.TimeTicket created_at = 2;\n */\n createdAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket moved_at = 3;\n */\n movedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket removed_at = 4;\n */\n removedAt?: TimeTicket;\n\n constructor(data?: PartialMessage<JSONElement_JSONArray>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.JSONElement.JSONArray\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"nodes\", kind: \"message\", T: RGANode, repeated: true },\n { no: 2, name: \"created_at\", kind: \"message\", T: TimeTicket },\n { no: 3, name: \"moved_at\", kind: \"message\", T: TimeTicket },\n { no: 4, name: \"removed_at\", kind: \"message\", T: TimeTicket },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): JSONElement_JSONArray {\n return new JSONElement_JSONArray().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): JSONElement_JSONArray {\n return new JSONElement_JSONArray().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): JSONElement_JSONArray {\n return new JSONElement_JSONArray().fromJsonString(jsonString, options);\n }\n\n static equals(a: JSONElement_JSONArray | PlainMessage<JSONElement_JSONArray> | undefined, b: JSONElement_JSONArray | PlainMessage<JSONElement_JSONArray> | undefined): boolean {\n return proto3.util.equals(JSONElement_JSONArray, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.JSONElement.Primitive\n */\nexport class JSONElement_Primitive extends Message<JSONElement_Primitive> {\n /**\n * @generated from field: yorkie.v1.ValueType type = 1;\n */\n type = ValueType.NULL;\n\n /**\n * @generated from field: bytes value = 2;\n */\n value = new Uint8Array(0);\n\n /**\n * @generated from field: yorkie.v1.TimeTicket created_at = 3;\n */\n createdAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket moved_at = 4;\n */\n movedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket removed_at = 5;\n */\n removedAt?: TimeTicket;\n\n constructor(data?: PartialMessage<JSONElement_Primitive>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.JSONElement.Primitive\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"type\", kind: \"enum\", T: proto3.getEnumType(ValueType) },\n { no: 2, name: \"value\", kind: \"scalar\", T: 12 /* ScalarType.BYTES */ },\n { no: 3, name: \"created_at\", kind: \"message\", T: TimeTicket },\n { no: 4, name: \"moved_at\", kind: \"message\", T: TimeTicket },\n { no: 5, name: \"removed_at\", kind: \"message\", T: TimeTicket },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): JSONElement_Primitive {\n return new JSONElement_Primitive().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): JSONElement_Primitive {\n return new JSONElement_Primitive().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): JSONElement_Primitive {\n return new JSONElement_Primitive().fromJsonString(jsonString, options);\n }\n\n static equals(a: JSONElement_Primitive | PlainMessage<JSONElement_Primitive> | undefined, b: JSONElement_Primitive | PlainMessage<JSONElement_Primitive> | undefined): boolean {\n return proto3.util.equals(JSONElement_Primitive, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.JSONElement.Text\n */\nexport class JSONElement_Text extends Message<JSONElement_Text> {\n /**\n * @generated from field: repeated yorkie.v1.TextNode nodes = 1;\n */\n nodes: TextNode[] = [];\n\n /**\n * @generated from field: yorkie.v1.TimeTicket created_at = 2;\n */\n createdAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket moved_at = 3;\n */\n movedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket removed_at = 4;\n */\n removedAt?: TimeTicket;\n\n constructor(data?: PartialMessage<JSONElement_Text>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.JSONElement.Text\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"nodes\", kind: \"message\", T: TextNode, repeated: true },\n { no: 2, name: \"created_at\", kind: \"message\", T: TimeTicket },\n { no: 3, name: \"moved_at\", kind: \"message\", T: TimeTicket },\n { no: 4, name: \"removed_at\", kind: \"message\", T: TimeTicket },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): JSONElement_Text {\n return new JSONElement_Text().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): JSONElement_Text {\n return new JSONElement_Text().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): JSONElement_Text {\n return new JSONElement_Text().fromJsonString(jsonString, options);\n }\n\n static equals(a: JSONElement_Text | PlainMessage<JSONElement_Text> | undefined, b: JSONElement_Text | PlainMessage<JSONElement_Text> | undefined): boolean {\n return proto3.util.equals(JSONElement_Text, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.JSONElement.Counter\n */\nexport class JSONElement_Counter extends Message<JSONElement_Counter> {\n /**\n * @generated from field: yorkie.v1.ValueType type = 1;\n */\n type = ValueType.NULL;\n\n /**\n * @generated from field: bytes value = 2;\n */\n value = new Uint8Array(0);\n\n /**\n * @generated from field: yorkie.v1.TimeTicket created_at = 3;\n */\n createdAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket moved_at = 4;\n */\n movedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket removed_at = 5;\n */\n removedAt?: TimeTicket;\n\n constructor(data?: PartialMessage<JSONElement_Counter>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.JSONElement.Counter\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"type\", kind: \"enum\", T: proto3.getEnumType(ValueType) },\n { no: 2, name: \"value\", kind: \"scalar\", T: 12 /* ScalarType.BYTES */ },\n { no: 3, name: \"created_at\", kind: \"message\", T: TimeTicket },\n { no: 4, name: \"moved_at\", kind: \"message\", T: TimeTicket },\n { no: 5, name: \"removed_at\", kind: \"message\", T: TimeTicket },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): JSONElement_Counter {\n return new JSONElement_Counter().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): JSONElement_Counter {\n return new JSONElement_Counter().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): JSONElement_Counter {\n return new JSONElement_Counter().fromJsonString(jsonString, options);\n }\n\n static equals(a: JSONElement_Counter | PlainMessage<JSONElement_Counter> | undefined, b: JSONElement_Counter | PlainMessage<JSONElement_Counter> | undefined): boolean {\n return proto3.util.equals(JSONElement_Counter, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.JSONElement.Tree\n */\nexport class JSONElement_Tree extends Message<JSONElement_Tree> {\n /**\n * @generated from field: repeated yorkie.v1.TreeNode nodes = 1;\n */\n nodes: TreeNode[] = [];\n\n /**\n * @generated from field: yorkie.v1.TimeTicket created_at = 2;\n */\n createdAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket moved_at = 3;\n */\n movedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TimeTicket removed_at = 4;\n */\n removedAt?: TimeTicket;\n\n constructor(data?: PartialMessage<JSONElement_Tree>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.JSONElement.Tree\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"nodes\", kind: \"message\", T: TreeNode, repeated: true },\n { no: 2, name: \"created_at\", kind: \"message\", T: TimeTicket },\n { no: 3, name: \"moved_at\", kind: \"message\", T: TimeTicket },\n { no: 4, name: \"removed_at\", kind: \"message\", T: TimeTicket },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): JSONElement_Tree {\n return new JSONElement_Tree().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): JSONElement_Tree {\n return new JSONElement_Tree().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): JSONElement_Tree {\n return new JSONElement_Tree().fromJsonString(jsonString, options);\n }\n\n static equals(a: JSONElement_Tree | PlainMessage<JSONElement_Tree> | undefined, b: JSONElement_Tree | PlainMessage<JSONElement_Tree> | undefined): boolean {\n return proto3.util.equals(JSONElement_Tree, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.RHTNode\n */\nexport class RHTNode extends Message<RHTNode> {\n /**\n * @generated from field: string key = 1;\n */\n key = \"\";\n\n /**\n * @generated from field: yorkie.v1.JSONElement element = 2;\n */\n element?: JSONElement;\n\n constructor(data?: PartialMessage<RHTNode>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.RHTNode\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"key\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"element\", kind: \"message\", T: JSONElement },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): RHTNode {\n return new RHTNode().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): RHTNode {\n return new RHTNode().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): RHTNode {\n return new RHTNode().fromJsonString(jsonString, options);\n }\n\n static equals(a: RHTNode | PlainMessage<RHTNode> | undefined, b: RHTNode | PlainMessage<RHTNode> | undefined): boolean {\n return proto3.util.equals(RHTNode, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.RGANode\n */\nexport class RGANode extends Message<RGANode> {\n /**\n * @generated from field: yorkie.v1.RGANode next = 1;\n */\n next?: RGANode;\n\n /**\n * @generated from field: yorkie.v1.JSONElement element = 2;\n */\n element?: JSONElement;\n\n constructor(data?: PartialMessage<RGANode>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.RGANode\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"next\", kind: \"message\", T: RGANode },\n { no: 2, name: \"element\", kind: \"message\", T: JSONElement },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): RGANode {\n return new RGANode().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): RGANode {\n return new RGANode().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): RGANode {\n return new RGANode().fromJsonString(jsonString, options);\n }\n\n static equals(a: RGANode | PlainMessage<RGANode> | undefined, b: RGANode | PlainMessage<RGANode> | undefined): boolean {\n return proto3.util.equals(RGANode, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.NodeAttr\n */\nexport class NodeAttr extends Message<NodeAttr> {\n /**\n * @generated from field: string value = 1;\n */\n value = \"\";\n\n /**\n * @generated from field: yorkie.v1.TimeTicket updated_at = 2;\n */\n updatedAt?: TimeTicket;\n\n /**\n * @generated from field: bool is_removed = 3;\n */\n isRemoved = false;\n\n constructor(data?: PartialMessage<NodeAttr>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.NodeAttr\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"value\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"updated_at\", kind: \"message\", T: TimeTicket },\n { no: 3, name: \"is_removed\", kind: \"scalar\", T: 8 /* ScalarType.BOOL */ },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): NodeAttr {\n return new NodeAttr().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): NodeAttr {\n return new NodeAttr().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): NodeAttr {\n return new NodeAttr().fromJsonString(jsonString, options);\n }\n\n static equals(a: NodeAttr | PlainMessage<NodeAttr> | undefined, b: NodeAttr | PlainMessage<NodeAttr> | undefined): boolean {\n return proto3.util.equals(NodeAttr, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.TextNode\n */\nexport class TextNode extends Message<TextNode> {\n /**\n * @generated from field: yorkie.v1.TextNodeID id = 1;\n */\n id?: TextNodeID;\n\n /**\n * @generated from field: string value = 2;\n */\n value = \"\";\n\n /**\n * @generated from field: yorkie.v1.TimeTicket removed_at = 3;\n */\n removedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TextNodeID ins_prev_id = 4;\n */\n insPrevId?: TextNodeID;\n\n /**\n * @generated from field: map<string, yorkie.v1.NodeAttr> attributes = 5;\n */\n attributes: { [key: string]: NodeAttr } = {};\n\n constructor(data?: PartialMessage<TextNode>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.TextNode\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"id\", kind: \"message\", T: TextNodeID },\n { no: 2, name: \"value\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 3, name: \"removed_at\", kind: \"message\", T: TimeTicket },\n { no: 4, name: \"ins_prev_id\", kind: \"message\", T: TextNodeID },\n { no: 5, name: \"attributes\", kind: \"map\", K: 9 /* ScalarType.STRING */, V: {kind: \"message\", T: NodeAttr} },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): TextNode {\n return new TextNode().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): TextNode {\n return new TextNode().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): TextNode {\n return new TextNode().fromJsonString(jsonString, options);\n }\n\n static equals(a: TextNode | PlainMessage<TextNode> | undefined, b: TextNode | PlainMessage<TextNode> | undefined): boolean {\n return proto3.util.equals(TextNode, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.TextNodeID\n */\nexport class TextNodeID extends Message<TextNodeID> {\n /**\n * @generated from field: yorkie.v1.TimeTicket created_at = 1;\n */\n createdAt?: TimeTicket;\n\n /**\n * @generated from field: int32 offset = 2;\n */\n offset = 0;\n\n constructor(data?: PartialMessage<TextNodeID>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.TextNodeID\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"created_at\", kind: \"message\", T: TimeTicket },\n { no: 2, name: \"offset\", kind: \"scalar\", T: 5 /* ScalarType.INT32 */ },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): TextNodeID {\n return new TextNodeID().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): TextNodeID {\n return new TextNodeID().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): TextNodeID {\n return new TextNodeID().fromJsonString(jsonString, options);\n }\n\n static equals(a: TextNodeID | PlainMessage<TextNodeID> | undefined, b: TextNodeID | PlainMessage<TextNodeID> | undefined): boolean {\n return proto3.util.equals(TextNodeID, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.TreeNode\n */\nexport class TreeNode extends Message<TreeNode> {\n /**\n * @generated from field: yorkie.v1.TreeNodeID id = 1;\n */\n id?: TreeNodeID;\n\n /**\n * @generated from field: string type = 2;\n */\n type = \"\";\n\n /**\n * @generated from field: string value = 3;\n */\n value = \"\";\n\n /**\n * @generated from field: yorkie.v1.TimeTicket removed_at = 4;\n */\n removedAt?: TimeTicket;\n\n /**\n * @generated from field: yorkie.v1.TreeNodeID ins_prev_id = 5;\n */\n insPrevId?: TreeNodeID;\n\n /**\n * @generated from field: yorkie.v1.TreeNodeID ins_next_id = 6;\n */\n insNextId?: TreeNodeID;\n\n /**\n * @generated from field: int32 depth = 7;\n */\n depth = 0;\n\n /**\n * @generated from field: map<string, yorkie.v1.NodeAttr> attributes = 8;\n */\n attributes: { [key: string]: NodeAttr } = {};\n\n constructor(data?: PartialMessage<TreeNode>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.TreeNode\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"id\", kind: \"message\", T: TreeNodeID },\n { no: 2, name: \"type\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 3, name: \"value\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 4, name: \"removed_at\", kind: \"message\", T: TimeTicket },\n { no: 5, name: \"ins_prev_id\", kind: \"message\", T: TreeNodeID },\n { no: 6, name: \"ins_next_id\", kind: \"message\", T: TreeNodeID },\n { no: 7, name: \"depth\", kind: \"scalar\", T: 5 /* ScalarType.INT32 */ },\n { no: 8, name: \"attributes\", kind: \"map\", K: 9 /* ScalarType.STRING */, V: {kind: \"message\", T: NodeAttr} },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): TreeNode {\n return new TreeNode().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): TreeNode {\n return new TreeNode().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): TreeNode {\n return new TreeNode().fromJsonString(jsonString, options);\n }\n\n static equals(a: TreeNode | PlainMessage<TreeNode> | undefined, b: TreeNode | PlainMessage<TreeNode> | undefined): boolean {\n return proto3.util.equals(TreeNode, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.TreeNodes\n */\nexport class TreeNodes extends Message<TreeNodes> {\n /**\n * @generated from field: repeated yorkie.v1.TreeNode content = 1;\n */\n content: TreeNode[] = [];\n\n constructor(data?: PartialMessage<TreeNodes>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.TreeNodes\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"content\", kind: \"message\", T: TreeNode, repeated: true },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): TreeNodes {\n return new TreeNodes().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): TreeNodes {\n return new TreeNodes().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): TreeNodes {\n return new TreeNodes().fromJsonString(jsonString, options);\n }\n\n static equals(a: TreeNodes | PlainMessage<TreeNodes> | undefined, b: TreeNodes | PlainMessage<TreeNodes> | undefined): boolean {\n return proto3.util.equals(TreeNodes, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.TreeNodeID\n */\nexport class TreeNodeID extends Message<TreeNodeID> {\n /**\n * @generated from field: yorkie.v1.TimeTicket created_at = 1;\n */\n createdAt?: TimeTicket;\n\n /**\n * @generated from field: int32 offset = 2;\n */\n offset = 0;\n\n constructor(data?: PartialMessage<TreeNodeID>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.TreeNodeID\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"created_at\", kind: \"message\", T: TimeTicket },\n { no: 2, name: \"offset\", kind: \"scalar\", T: 5 /* ScalarType.INT32 */ },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): TreeNodeID {\n return new TreeNodeID().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): TreeNodeID {\n return new TreeNodeID().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): TreeNodeID {\n return new TreeNodeID().fromJsonString(jsonString, options);\n }\n\n static equals(a: TreeNodeID | PlainMessage<TreeNodeID> | undefined, b: TreeNodeID | PlainMessage<TreeNodeID> | undefined): boolean {\n return proto3.util.equals(TreeNodeID, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.TreePos\n */\nexport class TreePos extends Message<TreePos> {\n /**\n * @generated from field: yorkie.v1.TreeNodeID parent_id = 1;\n */\n parentId?: TreeNodeID;\n\n /**\n * @generated from field: yorkie.v1.TreeNodeID left_sibling_id = 2;\n */\n leftSiblingId?: TreeNodeID;\n\n constructor(data?: PartialMessage<TreePos>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.TreePos\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"parent_id\", kind: \"message\", T: TreeNodeID },\n { no: 2, name: \"left_sibling_id\", kind: \"message\", T: TreeNodeID },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): TreePos {\n return new TreePos().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): TreePos {\n return new TreePos().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): TreePos {\n return new TreePos().fromJsonString(jsonString, options);\n }\n\n static equals(a: TreePos | PlainMessage<TreePos> | undefined, b: TreePos | PlainMessage<TreePos> | undefined): boolean {\n return proto3.util.equals(TreePos, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.User\n */\nexport class User extends Message<User> {\n /**\n * @generated from field: string id = 1;\n */\n id = \"\";\n\n /**\n * @generated from field: string username = 2;\n */\n username = \"\";\n\n /**\n * @generated from field: google.protobuf.Timestamp created_at = 3;\n */\n createdAt?: Timestamp;\n\n constructor(data?: PartialMessage<User>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.User\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"username\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 3, name: \"created_at\", kind: \"message\", T: Timestamp },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): User {\n return new User().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): User {\n return new User().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): User {\n return new User().fromJsonString(jsonString, options);\n }\n\n static equals(a: User | PlainMessage<User> | undefined, b: User | PlainMessage<User> | undefined): boolean {\n return proto3.util.equals(User, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.Project\n */\nexport class Project extends Message<Project> {\n /**\n * @generated from field: string id = 1;\n */\n id = \"\";\n\n /**\n * @generated from field: string name = 2;\n */\n name = \"\";\n\n /**\n * @generated from field: string public_key = 3;\n */\n publicKey = \"\";\n\n /**\n * @generated from field: string secret_key = 4;\n */\n secretKey = \"\";\n\n /**\n * @generated from field: string auth_webhook_url = 5;\n */\n authWebhookUrl = \"\";\n\n /**\n * @generated from field: repeated string auth_webhook_methods = 6;\n */\n authWebhookMethods: string[] = [];\n\n /**\n * @generated from field: string client_deactivate_threshold = 7;\n */\n clientDeactivateThreshold = \"\";\n\n /**\n * @generated from field: google.protobuf.Timestamp created_at = 8;\n */\n createdAt?: Timestamp;\n\n /**\n * @generated from field: google.protobuf.Timestamp updated_at = 9;\n */\n updatedAt?: Timestamp;\n\n constructor(data?: PartialMessage<Project>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.Project\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"name\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 3, name: \"public_key\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 4, name: \"secret_key\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 5, name: \"auth_webhook_url\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 6, name: \"auth_webhook_methods\", kind: \"scalar\", T: 9 /* ScalarType.STRING */, repeated: true },\n { no: 7, name: \"client_deactivate_threshold\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 8, name: \"created_at\", kind: \"message\", T: Timestamp },\n { no: 9, name: \"updated_at\", kind: \"message\", T: Timestamp },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Project {\n return new Project().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Project {\n return new Project().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Project {\n return new Project().fromJsonString(jsonString, options);\n }\n\n static equals(a: Project | PlainMessage<Project> | undefined, b: Project | PlainMessage<Project> | undefined): boolean {\n return proto3.util.equals(Project, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.UpdatableProjectFields\n */\nexport class UpdatableProjectFields extends Message<UpdatableProjectFields> {\n /**\n * @generated from field: google.protobuf.StringValue name = 1;\n */\n name?: string;\n\n /**\n * @generated from field: google.protobuf.StringValue auth_webhook_url = 2;\n */\n authWebhookUrl?: string;\n\n /**\n * @generated from field: yorkie.v1.UpdatableProjectFields.AuthWebhookMethods auth_webhook_methods = 3;\n */\n authWebhookMethods?: UpdatableProjectFields_AuthWebhookMethods;\n\n /**\n * @generated from field: google.protobuf.StringValue client_deactivate_threshold = 4;\n */\n clientDeactivateThreshold?: string;\n\n constructor(data?: PartialMessage<UpdatableProjectFields>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.UpdatableProjectFields\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"name\", kind: \"message\", T: StringValue },\n { no: 2, name: \"auth_webhook_url\", kind: \"message\", T: StringValue },\n { no: 3, name: \"auth_webhook_methods\", kind: \"message\", T: UpdatableProjectFields_AuthWebhookMethods },\n { no: 4, name: \"client_deactivate_threshold\", kind: \"message\", T: StringValue },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): UpdatableProjectFields {\n return new UpdatableProjectFields().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): UpdatableProjectFields {\n return new UpdatableProjectFields().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): UpdatableProjectFields {\n return new UpdatableProjectFields().fromJsonString(jsonString, options);\n }\n\n static equals(a: UpdatableProjectFields | PlainMessage<UpdatableProjectFields> | undefined, b: UpdatableProjectFields | PlainMessage<UpdatableProjectFields> | undefined): boolean {\n return proto3.util.equals(UpdatableProjectFields, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.UpdatableProjectFields.AuthWebhookMethods\n */\nexport class UpdatableProjectFields_AuthWebhookMethods extends Message<UpdatableProjectFields_AuthWebhookMethods> {\n /**\n * @generated from field: repeated string methods = 1;\n */\n methods: string[] = [];\n\n constructor(data?: PartialMessage<UpdatableProjectFields_AuthWebhookMethods>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.UpdatableProjectFields.AuthWebhookMethods\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"methods\", kind: \"scalar\", T: 9 /* ScalarType.STRING */, repeated: true },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): UpdatableProjectFields_AuthWebhookMethods {\n return new UpdatableProjectFields_AuthWebhookMethods().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): UpdatableProjectFields_AuthWebhookMethods {\n return new UpdatableProjectFields_AuthWebhookMethods().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): UpdatableProjectFields_AuthWebhookMethods {\n return new UpdatableProjectFields_AuthWebhookMethods().fromJsonString(jsonString, options);\n }\n\n static equals(a: UpdatableProjectFields_AuthWebhookMethods | PlainMessage<UpdatableProjectFields_AuthWebhookMethods> | undefined, b: UpdatableProjectFields_AuthWebhookMethods | PlainMessage<UpdatableProjectFields_AuthWebhookMethods> | undefined): boolean {\n return proto3.util.equals(UpdatableProjectFields_AuthWebhookMethods, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.DocumentSummary\n */\nexport class DocumentSummary extends Message<DocumentSummary> {\n /**\n * @generated from field: string id = 1;\n */\n id = \"\";\n\n /**\n * @generated from field: string key = 2;\n */\n key = \"\";\n\n /**\n * @generated from field: string snapshot = 3;\n */\n snapshot = \"\";\n\n /**\n * @generated from field: google.protobuf.Timestamp created_at = 4;\n */\n createdAt?: Timestamp;\n\n /**\n * @generated from field: google.protobuf.Timestamp accessed_at = 5;\n */\n accessedAt?: Timestamp;\n\n /**\n * @generated from field: google.protobuf.Timestamp updated_at = 6;\n */\n updatedAt?: Timestamp;\n\n constructor(data?: PartialMessage<DocumentSummary>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.DocumentSummary\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"key\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 3, name: \"snapshot\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 4, name: \"created_at\", kind: \"message\", T: Timestamp },\n { no: 5, name: \"accessed_at\", kind: \"message\", T: Timestamp },\n { no: 6, name: \"updated_at\", kind: \"message\", T: Timestamp },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): DocumentSummary {\n return new DocumentSummary().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): DocumentSummary {\n return new DocumentSummary().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): DocumentSummary {\n return new DocumentSummary().fromJsonString(jsonString, options);\n }\n\n static equals(a: DocumentSummary | PlainMessage<DocumentSummary> | undefined, b: DocumentSummary | PlainMessage<DocumentSummary> | undefined): boolean {\n return proto3.util.equals(DocumentSummary, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.PresenceChange\n */\nexport class PresenceChange extends Message<PresenceChange> {\n /**\n * @generated from field: yorkie.v1.PresenceChange.ChangeType type = 1;\n */\n type = PresenceChange_ChangeType.UNSPECIFIED;\n\n /**\n * @generated from field: yorkie.v1.Presence presence = 2;\n */\n presence?: Presence;\n\n constructor(data?: PartialMessage<PresenceChange>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.PresenceChange\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"type\", kind: \"enum\", T: proto3.getEnumType(PresenceChange_ChangeType) },\n { no: 2, name: \"presence\", kind: \"message\", T: Presence },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): PresenceChange {\n return new PresenceChange().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): PresenceChange {\n return new PresenceChange().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): PresenceChange {\n return new PresenceChange().fromJsonString(jsonString, options);\n }\n\n static equals(a: PresenceChange | PlainMessage<PresenceChange> | undefined, b: PresenceChange | PlainMessage<PresenceChange> | undefined): boolean {\n return proto3.util.equals(PresenceChange, a, b);\n }\n}\n\n/**\n * @generated from enum yorkie.v1.PresenceChange.ChangeType\n */\nexport enum PresenceChange_ChangeType {\n /**\n * @generated from enum value: CHANGE_TYPE_UNSPECIFIED = 0;\n */\n UNSPECIFIED = 0,\n\n /**\n * @generated from enum value: CHANGE_TYPE_PUT = 1;\n */\n PUT = 1,\n\n /**\n * @generated from enum value: CHANGE_TYPE_DELETE = 2;\n */\n DELETE = 2,\n\n /**\n * @generated from enum value: CHANGE_TYPE_CLEAR = 3;\n */\n CLEAR = 3,\n}\n// Retrieve enum metadata with: proto3.getEnumType(PresenceChange_ChangeType)\nproto3.util.setEnumType(PresenceChange_ChangeType, \"yorkie.v1.PresenceChange.ChangeType\", [\n { no: 0, name: \"CHANGE_TYPE_UNSPECIFIED\" },\n { no: 1, name: \"CHANGE_TYPE_PUT\" },\n { no: 2, name: \"CHANGE_TYPE_DELETE\" },\n { no: 3, name: \"CHANGE_TYPE_CLEAR\" },\n]);\n\n/**\n * @generated from message yorkie.v1.Presence\n */\nexport class Presence extends Message<Presence> {\n /**\n * @generated from field: map<string, string> data = 1;\n */\n data: { [key: string]: string } = {};\n\n constructor(data?: PartialMessage<Presence>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.Presence\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"data\", kind: \"map\", K: 9 /* ScalarType.STRING */, V: {kind: \"scalar\", T: 9 /* ScalarType.STRING */} },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Presence {\n return new Presence().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Presence {\n return new Presence().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Presence {\n return new Presence().fromJsonString(jsonString, options);\n }\n\n static equals(a: Presence | PlainMessage<Presence> | undefined, b: Presence | PlainMessage<Presence> | undefined): boolean {\n return proto3.util.equals(Presence, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.Checkpoint\n */\nexport class Checkpoint extends Message<Checkpoint> {\n /**\n * @generated from field: int64 server_seq = 1;\n */\n serverSeq = protoInt64.zero;\n\n /**\n * @generated from field: uint32 client_seq = 2;\n */\n clientSeq = 0;\n\n constructor(data?: PartialMessage<Checkpoint>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.Checkpoint\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"server_seq\", kind: \"scalar\", T: 3 /* ScalarType.INT64 */ },\n { no: 2, name: \"client_seq\", kind: \"scalar\", T: 13 /* ScalarType.UINT32 */ },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Checkpoint {\n return new Checkpoint().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Checkpoint {\n return new Checkpoint().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Checkpoint {\n return new Checkpoint().fromJsonString(jsonString, options);\n }\n\n static equals(a: Checkpoint | PlainMessage<Checkpoint> | undefined, b: Checkpoint | PlainMessage<Checkpoint> | undefined): boolean {\n return proto3.util.equals(Checkpoint, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.TextNodePos\n */\nexport class TextNodePos extends Message<TextNodePos> {\n /**\n * @generated from field: yorkie.v1.TimeTicket created_at = 1;\n */\n createdAt?: TimeTicket;\n\n /**\n * @generated from field: int32 offset = 2;\n */\n offset = 0;\n\n /**\n * @generated from field: int32 relative_offset = 3;\n */\n relativeOffset = 0;\n\n constructor(data?: PartialMessage<TextNodePos>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.TextNodePos\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"created_at\", kind: \"message\", T: TimeTicket },\n { no: 2, name: \"offset\", kind: \"scalar\", T: 5 /* ScalarType.INT32 */ },\n { no: 3, name: \"relative_offset\", kind: \"scalar\", T: 5 /* ScalarType.INT32 */ },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): TextNodePos {\n return new TextNodePos().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): TextNodePos {\n return new TextNodePos().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): TextNodePos {\n return new TextNodePos().fromJsonString(jsonString, options);\n }\n\n static equals(a: TextNodePos | PlainMessage<TextNodePos> | undefined, b: TextNodePos | PlainMessage<TextNodePos> | undefined): boolean {\n return proto3.util.equals(TextNodePos, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.TimeTicket\n */\nexport class TimeTicket extends Message<TimeTicket> {\n /**\n * @generated from field: int64 lamport = 1;\n */\n lamport = protoInt64.zero;\n\n /**\n * @generated from field: uint32 delimiter = 2;\n */\n delimiter = 0;\n\n /**\n * @generated from field: bytes actor_id = 3;\n */\n actorId = new Uint8Array(0);\n\n constructor(data?: PartialMessage<TimeTicket>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.TimeTicket\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"lamport\", kind: \"scalar\", T: 3 /* ScalarType.INT64 */ },\n { no: 2, name: \"delimiter\", kind: \"scalar\", T: 13 /* ScalarType.UINT32 */ },\n { no: 3, name: \"actor_id\", kind: \"scalar\", T: 12 /* ScalarType.BYTES */ },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): TimeTicket {\n return new TimeTicket().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): TimeTicket {\n return new TimeTicket().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): TimeTicket {\n return new TimeTicket().fromJsonString(jsonString, options);\n }\n\n static equals(a: TimeTicket | PlainMessage<TimeTicket> | undefined, b: TimeTicket | PlainMessage<TimeTicket> | undefined): boolean {\n return proto3.util.equals(TimeTicket, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.DocEventBody\n */\nexport class DocEventBody extends Message<DocEventBody> {\n /**\n * @generated from field: string topic = 1;\n */\n topic = \"\";\n\n /**\n * @generated from field: bytes payload = 2;\n */\n payload = new Uint8Array(0);\n\n constructor(data?: PartialMessage<DocEventBody>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.DocEventBody\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"topic\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"payload\", kind: \"scalar\", T: 12 /* ScalarType.BYTES */ },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): DocEventBody {\n return new DocEventBody().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): DocEventBody {\n return new DocEventBody().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): DocEventBody {\n return new DocEventBody().fromJsonString(jsonString, options);\n }\n\n static equals(a: DocEventBody | PlainMessage<DocEventBody> | undefined, b: DocEventBody | PlainMessage<DocEventBody> | undefined): boolean {\n return proto3.util.equals(DocEventBody, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.DocEvent\n */\nexport class DocEvent extends Message<DocEvent> {\n /**\n * @generated from field: yorkie.v1.DocEventType type = 1;\n */\n type = DocEventType.DOCUMENT_CHANGED;\n\n /**\n * @generated from field: string publisher = 2;\n */\n publisher = \"\";\n\n /**\n * @generated from field: yorkie.v1.DocEventBody body = 3;\n */\n body?: DocEventBody;\n\n constructor(data?: PartialMessage<DocEvent>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.DocEvent\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"type\", kind: \"enum\", T: proto3.getEnumType(DocEventType) },\n { no: 2, name: \"publisher\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 3, name: \"body\", kind: \"message\", T: DocEventBody },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): DocEvent {\n return new DocEvent().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): DocEvent {\n return new DocEvent().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): DocEvent {\n return new DocEvent().fromJsonString(jsonString, options);\n }\n\n static equals(a: DocEvent | PlainMessage<DocEvent> | undefined, b: DocEvent | PlainMessage<DocEvent> | undefined): boolean {\n return proto3.util.equals(DocEvent, a, b);\n }\n}\n\n","//\n// Copyright 2020 The Yorkie Authors. All rights reserved.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// @generated by protoc-gen-es v1.10.0 with parameter \"target=ts,import_extension=none\"\n// @generated from file src/api/yorkie/v1/yorkie.proto (package yorkie.v1, syntax proto3)\n/* eslint-disable */\n// @ts-nocheck\n\nimport type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from \"@bufbuild/protobuf\";\nimport { Message, proto3 } from \"@bufbuild/protobuf\";\nimport { ChangePack, DocEvent } from \"./resources_pb\";\n\n/**\n * @generated from message yorkie.v1.ActivateClientRequest\n */\nexport class ActivateClientRequest extends Message<ActivateClientRequest> {\n /**\n * @generated from field: string client_key = 1;\n */\n clientKey = \"\";\n\n /**\n * @generated from field: map<string, string> metadata = 2;\n */\n metadata: { [key: string]: string } = {};\n\n constructor(data?: PartialMessage<ActivateClientRequest>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.ActivateClientRequest\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"client_key\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"metadata\", kind: \"map\", K: 9 /* ScalarType.STRING */, V: {kind: \"scalar\", T: 9 /* ScalarType.STRING */} },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ActivateClientRequest {\n return new ActivateClientRequest().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ActivateClientRequest {\n return new ActivateClientRequest().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ActivateClientRequest {\n return new ActivateClientRequest().fromJsonString(jsonString, options);\n }\n\n static equals(a: ActivateClientRequest | PlainMessage<ActivateClientRequest> | undefined, b: ActivateClientRequest | PlainMessage<ActivateClientRequest> | undefined): boolean {\n return proto3.util.equals(ActivateClientRequest, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.ActivateClientResponse\n */\nexport class ActivateClientResponse extends Message<ActivateClientResponse> {\n /**\n * @generated from field: string client_id = 1;\n */\n clientId = \"\";\n\n constructor(data?: PartialMessage<ActivateClientResponse>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.ActivateClientResponse\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"client_id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): ActivateClientResponse {\n return new ActivateClientResponse().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): ActivateClientResponse {\n return new ActivateClientResponse().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): ActivateClientResponse {\n return new ActivateClientResponse().fromJsonString(jsonString, options);\n }\n\n static equals(a: ActivateClientResponse | PlainMessage<ActivateClientResponse> | undefined, b: ActivateClientResponse | PlainMessage<ActivateClientResponse> | undefined): boolean {\n return proto3.util.equals(ActivateClientResponse, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.DeactivateClientRequest\n */\nexport class DeactivateClientRequest extends Message<DeactivateClientRequest> {\n /**\n * @generated from field: string client_id = 1;\n */\n clientId = \"\";\n\n constructor(data?: PartialMessage<DeactivateClientRequest>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.DeactivateClientRequest\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"client_id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): DeactivateClientRequest {\n return new DeactivateClientRequest().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): DeactivateClientRequest {\n return new DeactivateClientRequest().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): DeactivateClientRequest {\n return new DeactivateClientRequest().fromJsonString(jsonString, options);\n }\n\n static equals(a: DeactivateClientRequest | PlainMessage<DeactivateClientRequest> | undefined, b: DeactivateClientRequest | PlainMessage<DeactivateClientRequest> | undefined): boolean {\n return proto3.util.equals(DeactivateClientRequest, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.DeactivateClientResponse\n */\nexport class DeactivateClientResponse extends Message<DeactivateClientResponse> {\n constructor(data?: PartialMessage<DeactivateClientResponse>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.DeactivateClientResponse\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): DeactivateClientResponse {\n return new DeactivateClientResponse().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): DeactivateClientResponse {\n return new DeactivateClientResponse().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): DeactivateClientResponse {\n return new DeactivateClientResponse().fromJsonString(jsonString, options);\n }\n\n static equals(a: DeactivateClientResponse | PlainMessage<DeactivateClientResponse> | undefined, b: DeactivateClientResponse | PlainMessage<DeactivateClientResponse> | undefined): boolean {\n return proto3.util.equals(DeactivateClientResponse, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.AttachDocumentRequest\n */\nexport class AttachDocumentRequest extends Message<AttachDocumentRequest> {\n /**\n * @generated from field: string client_id = 1;\n */\n clientId = \"\";\n\n /**\n * @generated from field: yorkie.v1.ChangePack change_pack = 2;\n */\n changePack?: ChangePack;\n\n constructor(data?: PartialMessage<AttachDocumentRequest>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.AttachDocumentRequest\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"client_id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"change_pack\", kind: \"message\", T: ChangePack },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): AttachDocumentRequest {\n return new AttachDocumentRequest().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): AttachDocumentRequest {\n return new AttachDocumentRequest().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): AttachDocumentRequest {\n return new AttachDocumentRequest().fromJsonString(jsonString, options);\n }\n\n static equals(a: AttachDocumentRequest | PlainMessage<AttachDocumentRequest> | undefined, b: AttachDocumentRequest | PlainMessage<AttachDocumentRequest> | undefined): boolean {\n return proto3.util.equals(AttachDocumentRequest, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.AttachDocumentResponse\n */\nexport class AttachDocumentResponse extends Message<AttachDocumentResponse> {\n /**\n * @generated from field: string document_id = 1;\n */\n documentId = \"\";\n\n /**\n * @generated from field: yorkie.v1.ChangePack change_pack = 2;\n */\n changePack?: ChangePack;\n\n constructor(data?: PartialMessage<AttachDocumentResponse>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.AttachDocumentResponse\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"document_id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"change_pack\", kind: \"message\", T: ChangePack },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): AttachDocumentResponse {\n return new AttachDocumentResponse().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): AttachDocumentResponse {\n return new AttachDocumentResponse().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): AttachDocumentResponse {\n return new AttachDocumentResponse().fromJsonString(jsonString, options);\n }\n\n static equals(a: AttachDocumentResponse | PlainMessage<AttachDocumentResponse> | undefined, b: AttachDocumentResponse | PlainMessage<AttachDocumentResponse> | undefined): boolean {\n return proto3.util.equals(AttachDocumentResponse, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.DetachDocumentRequest\n */\nexport class DetachDocumentRequest extends Message<DetachDocumentRequest> {\n /**\n * @generated from field: string client_id = 1;\n */\n clientId = \"\";\n\n /**\n * @generated from field: string document_id = 2;\n */\n documentId = \"\";\n\n /**\n * @generated from field: yorkie.v1.ChangePack change_pack = 3;\n */\n changePack?: ChangePack;\n\n /**\n * @generated from field: bool remove_if_not_attached = 4;\n */\n removeIfNotAttached = false;\n\n constructor(data?: PartialMessage<DetachDocumentRequest>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.DetachDocumentRequest\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"client_id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"document_id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 3, name: \"change_pack\", kind: \"message\", T: ChangePack },\n { no: 4, name: \"remove_if_not_attached\", kind: \"scalar\", T: 8 /* ScalarType.BOOL */ },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): DetachDocumentRequest {\n return new DetachDocumentRequest().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): DetachDocumentRequest {\n return new DetachDocumentRequest().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): DetachDocumentRequest {\n return new DetachDocumentRequest().fromJsonString(jsonString, options);\n }\n\n static equals(a: DetachDocumentRequest | PlainMessage<DetachDocumentRequest> | undefined, b: DetachDocumentRequest | PlainMessage<DetachDocumentRequest> | undefined): boolean {\n return proto3.util.equals(DetachDocumentRequest, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.DetachDocumentResponse\n */\nexport class DetachDocumentResponse extends Message<DetachDocumentResponse> {\n /**\n * @generated from field: yorkie.v1.ChangePack change_pack = 2;\n */\n changePack?: ChangePack;\n\n constructor(data?: PartialMessage<DetachDocumentResponse>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.DetachDocumentResponse\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 2, name: \"change_pack\", kind: \"message\", T: ChangePack },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): DetachDocumentResponse {\n return new DetachDocumentResponse().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): DetachDocumentResponse {\n return new DetachDocumentResponse().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): DetachDocumentResponse {\n return new DetachDocumentResponse().fromJsonString(jsonString, options);\n }\n\n static equals(a: DetachDocumentResponse | PlainMessage<DetachDocumentResponse> | undefined, b: DetachDocumentResponse | PlainMessage<DetachDocumentResponse> | undefined): boolean {\n return proto3.util.equals(DetachDocumentResponse, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.WatchDocumentRequest\n */\nexport class WatchDocumentRequest extends Message<WatchDocumentRequest> {\n /**\n * @generated from field: string client_id = 1;\n */\n clientId = \"\";\n\n /**\n * @generated from field: string document_id = 2;\n */\n documentId = \"\";\n\n constructor(data?: PartialMessage<WatchDocumentRequest>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.WatchDocumentRequest\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"client_id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"document_id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): WatchDocumentRequest {\n return new WatchDocumentRequest().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): WatchDocumentRequest {\n return new WatchDocumentRequest().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): WatchDocumentRequest {\n return new WatchDocumentRequest().fromJsonString(jsonString, options);\n }\n\n static equals(a: WatchDocumentRequest | PlainMessage<WatchDocumentRequest> | undefined, b: WatchDocumentRequest | PlainMessage<WatchDocumentRequest> | undefined): boolean {\n return proto3.util.equals(WatchDocumentRequest, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.WatchDocumentResponse\n */\nexport class WatchDocumentResponse extends Message<WatchDocumentResponse> {\n /**\n * @generated from oneof yorkie.v1.WatchDocumentResponse.body\n */\n body: {\n /**\n * @generated from field: yorkie.v1.WatchDocumentResponse.Initialization initialization = 1;\n */\n value: WatchDocumentResponse_Initialization;\n case: \"initialization\";\n } | {\n /**\n * @generated from field: yorkie.v1.DocEvent event = 2;\n */\n value: DocEvent;\n case: \"event\";\n } | { case: undefined; value?: undefined } = { case: undefined };\n\n constructor(data?: PartialMessage<WatchDocumentResponse>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.WatchDocumentResponse\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"initialization\", kind: \"message\", T: WatchDocumentResponse_Initialization, oneof: \"body\" },\n { no: 2, name: \"event\", kind: \"message\", T: DocEvent, oneof: \"body\" },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): WatchDocumentResponse {\n return new WatchDocumentResponse().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): WatchDocumentResponse {\n return new WatchDocumentResponse().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): WatchDocumentResponse {\n return new WatchDocumentResponse().fromJsonString(jsonString, options);\n }\n\n static equals(a: WatchDocumentResponse | PlainMessage<WatchDocumentResponse> | undefined, b: WatchDocumentResponse | PlainMessage<WatchDocumentResponse> | undefined): boolean {\n return proto3.util.equals(WatchDocumentResponse, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.WatchDocumentResponse.Initialization\n */\nexport class WatchDocumentResponse_Initialization extends Message<WatchDocumentResponse_Initialization> {\n /**\n * @generated from field: repeated string client_ids = 1;\n */\n clientIds: string[] = [];\n\n constructor(data?: PartialMessage<WatchDocumentResponse_Initialization>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.WatchDocumentResponse.Initialization\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"client_ids\", kind: \"scalar\", T: 9 /* ScalarType.STRING */, repeated: true },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): WatchDocumentResponse_Initialization {\n return new WatchDocumentResponse_Initialization().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): WatchDocumentResponse_Initialization {\n return new WatchDocumentResponse_Initialization().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): WatchDocumentResponse_Initialization {\n return new WatchDocumentResponse_Initialization().fromJsonString(jsonString, options);\n }\n\n static equals(a: WatchDocumentResponse_Initialization | PlainMessage<WatchDocumentResponse_Initialization> | undefined, b: WatchDocumentResponse_Initialization | PlainMessage<WatchDocumentResponse_Initialization> | undefined): boolean {\n return proto3.util.equals(WatchDocumentResponse_Initialization, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.RemoveDocumentRequest\n */\nexport class RemoveDocumentRequest extends Message<RemoveDocumentRequest> {\n /**\n * @generated from field: string client_id = 1;\n */\n clientId = \"\";\n\n /**\n * @generated from field: string document_id = 2;\n */\n documentId = \"\";\n\n /**\n * @generated from field: yorkie.v1.ChangePack change_pack = 3;\n */\n changePack?: ChangePack;\n\n constructor(data?: PartialMessage<RemoveDocumentRequest>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.RemoveDocumentRequest\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"client_id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"document_id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 3, name: \"change_pack\", kind: \"message\", T: ChangePack },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): RemoveDocumentRequest {\n return new RemoveDocumentRequest().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): RemoveDocumentRequest {\n return new RemoveDocumentRequest().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): RemoveDocumentRequest {\n return new RemoveDocumentRequest().fromJsonString(jsonString, options);\n }\n\n static equals(a: RemoveDocumentRequest | PlainMessage<RemoveDocumentRequest> | undefined, b: RemoveDocumentRequest | PlainMessage<RemoveDocumentRequest> | undefined): boolean {\n return proto3.util.equals(RemoveDocumentRequest, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.RemoveDocumentResponse\n */\nexport class RemoveDocumentResponse extends Message<RemoveDocumentResponse> {\n /**\n * @generated from field: yorkie.v1.ChangePack change_pack = 1;\n */\n changePack?: ChangePack;\n\n constructor(data?: PartialMessage<RemoveDocumentResponse>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.RemoveDocumentResponse\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"change_pack\", kind: \"message\", T: ChangePack },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): RemoveDocumentResponse {\n return new RemoveDocumentResponse().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): RemoveDocumentResponse {\n return new RemoveDocumentResponse().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): RemoveDocumentResponse {\n return new RemoveDocumentResponse().fromJsonString(jsonString, options);\n }\n\n static equals(a: RemoveDocumentResponse | PlainMessage<RemoveDocumentResponse> | undefined, b: RemoveDocumentResponse | PlainMessage<RemoveDocumentResponse> | undefined): boolean {\n return proto3.util.equals(RemoveDocumentResponse, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.PushPullChangesRequest\n */\nexport class PushPullChangesRequest extends Message<PushPullChangesRequest> {\n /**\n * @generated from field: string client_id = 1;\n */\n clientId = \"\";\n\n /**\n * @generated from field: string document_id = 2;\n */\n documentId = \"\";\n\n /**\n * @generated from field: yorkie.v1.ChangePack change_pack = 3;\n */\n changePack?: ChangePack;\n\n /**\n * @generated from field: bool push_only = 4;\n */\n pushOnly = false;\n\n constructor(data?: PartialMessage<PushPullChangesRequest>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.PushPullChangesRequest\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"client_id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"document_id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 3, name: \"change_pack\", kind: \"message\", T: ChangePack },\n { no: 4, name: \"push_only\", kind: \"scalar\", T: 8 /* ScalarType.BOOL */ },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): PushPullChangesRequest {\n return new PushPullChangesRequest().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): PushPullChangesRequest {\n return new PushPullChangesRequest().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): PushPullChangesRequest {\n return new PushPullChangesRequest().fromJsonString(jsonString, options);\n }\n\n static equals(a: PushPullChangesRequest | PlainMessage<PushPullChangesRequest> | undefined, b: PushPullChangesRequest | PlainMessage<PushPullChangesRequest> | undefined): boolean {\n return proto3.util.equals(PushPullChangesRequest, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.PushPullChangesResponse\n */\nexport class PushPullChangesResponse extends Message<PushPullChangesResponse> {\n /**\n * @generated from field: yorkie.v1.ChangePack change_pack = 1;\n */\n changePack?: ChangePack;\n\n constructor(data?: PartialMessage<PushPullChangesResponse>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.PushPullChangesResponse\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"change_pack\", kind: \"message\", T: ChangePack },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): PushPullChangesResponse {\n return new PushPullChangesResponse().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): PushPullChangesResponse {\n return new PushPullChangesResponse().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): PushPullChangesResponse {\n return new PushPullChangesResponse().fromJsonString(jsonString, options);\n }\n\n static equals(a: PushPullChangesResponse | PlainMessage<PushPullChangesResponse> | undefined, b: PushPullChangesResponse | PlainMessage<PushPullChangesResponse> | undefined): boolean {\n return proto3.util.equals(PushPullChangesResponse, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.BroadcastRequest\n */\nexport class BroadcastRequest extends Message<BroadcastRequest> {\n /**\n * @generated from field: string client_id = 1;\n */\n clientId = \"\";\n\n /**\n * @generated from field: string document_id = 2;\n */\n documentId = \"\";\n\n /**\n * @generated from field: string topic = 3;\n */\n topic = \"\";\n\n /**\n * @generated from field: bytes payload = 4;\n */\n payload = new Uint8Array(0);\n\n constructor(data?: PartialMessage<BroadcastRequest>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.BroadcastRequest\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n { no: 1, name: \"client_id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"document_id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 3, name: \"topic\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 4, name: \"payload\", kind: \"scalar\", T: 12 /* ScalarType.BYTES */ },\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BroadcastRequest {\n return new BroadcastRequest().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BroadcastRequest {\n return new BroadcastRequest().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BroadcastRequest {\n return new BroadcastRequest().fromJsonString(jsonString, options);\n }\n\n static equals(a: BroadcastRequest | PlainMessage<BroadcastRequest> | undefined, b: BroadcastRequest | PlainMessage<BroadcastRequest> | undefined): boolean {\n return proto3.util.equals(BroadcastRequest, a, b);\n }\n}\n\n/**\n * @generated from message yorkie.v1.BroadcastResponse\n */\nexport class BroadcastResponse extends Message<BroadcastResponse> {\n constructor(data?: PartialMessage<BroadcastResponse>) {\n super();\n proto3.util.initPartial(data, this);\n }\n\n static readonly runtime: typeof proto3 = proto3;\n static readonly typeName = \"yorkie.v1.BroadcastResponse\";\n static readonly fields: FieldList = proto3.util.newFieldList(() => [\n ]);\n\n static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): BroadcastResponse {\n return new BroadcastResponse().fromBinary(bytes, options);\n }\n\n static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): BroadcastResponse {\n return new BroadcastResponse().fromJson(jsonValue, options);\n }\n\n static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): BroadcastResponse {\n return new BroadcastResponse().fromJsonString(jsonString, options);\n }\n\n static equals(a: BroadcastResponse | PlainMessage<BroadcastResponse> | undefined, b: BroadcastResponse | PlainMessage<BroadcastResponse> | undefined): boolean {\n return proto3.util.equals(BroadcastResponse, a, b);\n }\n}\n\n","//\n// Copyright 2020 The Yorkie Authors. All rights reserved.\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// @generated by protoc-gen-connect-es v1.4.0 with parameter \"target=ts,import_extension=none\"\n// @generated from file src/api/yorkie/v1/yorkie.proto (package yorkie.v1, syntax proto3)\n/* eslint-disable */\n// @ts-nocheck\n\nimport { ActivateClientRequest, ActivateClientResponse, AttachDocumentRequest, AttachDocumentResponse, BroadcastRequest, BroadcastResponse, DeactivateClientRequest, DeactivateClientResponse, DetachDocumentRequest, DetachDocumentResponse, PushPullChangesRequest, PushPullChangesResponse, RemoveDocumentRequest, RemoveDocumentResponse, WatchDocumentRequest, WatchDocumentResponse } from \"./yorkie_pb\";\nimport { MethodKind } from \"@bufbuild/protobuf\";\n\n/**\n * Yorkie is a service that provides an API for SDKs.\n *\n * @generated from service yorkie.v1.YorkieService\n */\nexport const YorkieService = {\n typeName: \"yorkie.v1.YorkieService\",\n methods: {\n /**\n * @generated from rpc yorkie.v1.YorkieService.ActivateClient\n */\n activateClient: {\n name: \"ActivateClient\",\n I: ActivateClientRequest,\n O: ActivateClientResponse,\n kind: MethodKind.Unary,\n },\n /**\n * @generated from rpc yorkie.v1.YorkieService.DeactivateClient\n */\n deactivateClient: {\n name: \"DeactivateClient\",\n I: DeactivateClientRequest,\n O: DeactivateClientResponse,\n kind: MethodKind.Unary,\n },\n /**\n * @generated from rpc yorkie.v1.YorkieService.AttachDocument\n */\n attachDocument: {\n name: \"AttachDocument\",\n I: AttachDocumentRequest,\n O: AttachDocumentResponse,\n kind: MethodKind.Unary,\n },\n /**\n * @generated from rpc yorkie.v1.YorkieService.DetachDocument\n */\n detachDocument: {\n name: \"DetachDocument\",\n I: DetachDocumentRequest,\n O: DetachDocumentResponse,\n kind: MethodKind.Unary,\n },\n /**\n * @generated from rpc yorkie.v1.YorkieService.RemoveDocument\n */\n removeDocument: {\n name: \"RemoveDocument\",\n I: RemoveDocumentRequest,\n O: RemoveDocumentResponse,\n kind: MethodKind.Unary,\n },\n /**\n * @generated from rpc yorkie.v1.YorkieService.PushPullChanges\n */\n pushPullChanges: {\n name: \"PushPullChanges\",\n I: PushPullChangesRequest,\n O: PushPullChangesResponse,\n kind: MethodKind.Unary,\n },\n /**\n * @generated from rpc yorkie.v1.YorkieService.WatchDocument\n */\n watchDocument: {\n name: \"WatchDocument\",\n I: WatchDocumentRequest,\n O: WatchDocumentResponse,\n kind: MethodKind.ServerStreaming,\n },\n /**\n * @generated from rpc yorkie.v1.YorkieService.Broadcast\n */\n broadcast: {\n name: \"Broadcast\",\n I: BroadcastRequest,\n O: BroadcastResponse,\n kind: MethodKind.Unary,\n },\n }\n} as const;\n\n","// Copyright 2024 Google LLC\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// @generated by protoc-gen-es v1.4.0\n// @generated from file google/rpc/error_details.proto (package google.rpc, syntax proto3)\n/* eslint-disable */\n// @ts-nocheck\n\nimport { Duration, proto3 } from \"@bufbuild/protobuf\";\n\n/**\n * Describes the cause of the error with structured details.\n *\n * Example of an error when contacting the \"pubsub.googleapis.com\" API when it\n * is not enabled:\n *\n * { \"reason\": \"API_DISABLED\"\n * \"domain\": \"googleapis.com\"\n * \"metadata\": {\n * \"resource\": \"projects/123\",\n * \"service\": \"pubsub.googleapis.com\"\n * }\n * }\n *\n * This response indicates that the pubsub.googleapis.com API is not enabled.\n *\n * Example of an error that is returned when attempting to create a Spanner\n * instance in a region that is out of stock:\n *\n * { \"reason\": \"STOCKOUT\"\n * \"domain\": \"spanner.googleapis.com\",\n * \"metadata\": {\n * \"availableRegions\": \"us-central1,us-east2\"\n * }\n * }\n *\n * @generated from message google.rpc.ErrorInfo\n */\nexport const ErrorInfo = proto3.makeMessageType(\n \"google.rpc.ErrorInfo\",\n () => [\n { no: 1, name: \"reason\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"domain\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 3, name: \"metadata\", kind: \"map\", K: 9 /* ScalarType.STRING */, V: {kind: \"scalar\", T: 9 /* ScalarType.STRING */} },\n ],\n);\n\n/**\n * Describes when the clients can retry a failed request. Clients could ignore\n * the recommendation here or retry when this information is missing from error\n * responses.\n *\n * It's always recommended that clients should use exponential backoff when\n * retrying.\n *\n * Clients should wait until `retry_delay` amount of time has passed since\n * receiving the error response before retrying. If retrying requests also\n * fail, clients should use an exponential backoff scheme to gradually increase\n * the delay between retries based on `retry_delay`, until either a maximum\n * number of retries have been reached or a maximum retry delay cap has been\n * reached.\n *\n * @generated from message google.rpc.RetryInfo\n */\nexport const RetryInfo = proto3.makeMessageType(\n \"google.rpc.RetryInfo\",\n () => [\n { no: 1, name: \"retry_delay\", kind: \"message\", T: Duration },\n ],\n);\n\n/**\n * Describes additional debugging info.\n *\n * @generated from message google.rpc.DebugInfo\n */\nexport const DebugInfo = proto3.makeMessageType(\n \"google.rpc.DebugInfo\",\n () => [\n { no: 1, name: \"stack_entries\", kind: \"scalar\", T: 9 /* ScalarType.STRING */, repeated: true },\n { no: 2, name: \"detail\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n ],\n);\n\n/**\n * Describes how a quota check failed.\n *\n * For example if a daily limit was exceeded for the calling project,\n * a service could respond with a QuotaFailure detail containing the project\n * id and the description of the quota limit that was exceeded. If the\n * calling project hasn't enabled the service in the developer console, then\n * a service could respond with the project id and set `service_disabled`\n * to true.\n *\n * Also see RetryInfo and Help types for other details about handling a\n * quota failure.\n *\n * @generated from message google.rpc.QuotaFailure\n */\nexport const QuotaFailure = proto3.makeMessageType(\n \"google.rpc.QuotaFailure\",\n () => [\n { no: 1, name: \"violations\", kind: \"message\", T: QuotaFailure_Violation, repeated: true },\n ],\n);\n\n/**\n * A message type used to describe a single quota violation. For example, a\n * daily quota or a custom quota that was exceeded.\n *\n * @generated from message google.rpc.QuotaFailure.Violation\n */\nexport const QuotaFailure_Violation = proto3.makeMessageType(\n \"google.rpc.QuotaFailure.Violation\",\n () => [\n { no: 1, name: \"subject\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"description\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n ],\n {localName: \"QuotaFailure_Violation\"},\n);\n\n/**\n * Describes what preconditions have failed.\n *\n * For example, if an RPC failed because it required the Terms of Service to be\n * acknowledged, it could list the terms of service violation in the\n * PreconditionFailure message.\n *\n * @generated from message google.rpc.PreconditionFailure\n */\nexport const PreconditionFailure = proto3.makeMessageType(\n \"google.rpc.PreconditionFailure\",\n () => [\n { no: 1, name: \"violations\", kind: \"message\", T: PreconditionFailure_Violation, repeated: true },\n ],\n);\n\n/**\n * A message type used to describe a single precondition failure.\n *\n * @generated from message google.rpc.PreconditionFailure.Violation\n */\nexport const PreconditionFailure_Violation = proto3.makeMessageType(\n \"google.rpc.PreconditionFailure.Violation\",\n () => [\n { no: 1, name: \"type\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"subject\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 3, name: \"description\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n ],\n {localName: \"PreconditionFailure_Violation\"},\n);\n\n/**\n * Describes violations in a client request. This error type focuses on the\n * syntactic aspects of the request.\n *\n * @generated from message google.rpc.BadRequest\n */\nexport const BadRequest = proto3.makeMessageType(\n \"google.rpc.BadRequest\",\n () => [\n { no: 1, name: \"field_violations\", kind: \"message\", T: BadRequest_FieldViolation, repeated: true },\n ],\n);\n\n/**\n * A message type used to describe a single bad request field.\n *\n * @generated from message google.rpc.BadRequest.FieldViolation\n */\nexport const BadRequest_FieldViolation = proto3.makeMessageType(\n \"google.rpc.BadRequest.FieldViolation\",\n () => [\n { no: 1, name: \"field\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"description\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n ],\n {localName: \"BadRequest_FieldViolation\"},\n);\n\n/**\n * Contains metadata about the request that clients can attach when filing a bug\n * or providing other forms of feedback.\n *\n * @generated from message google.rpc.RequestInfo\n */\nexport const RequestInfo = proto3.makeMessageType(\n \"google.rpc.RequestInfo\",\n () => [\n { no: 1, name: \"request_id\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"serving_data\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n ],\n);\n\n/**\n * Describes the resource that is being accessed.\n *\n * @generated from message google.rpc.ResourceInfo\n */\nexport const ResourceInfo = proto3.makeMessageType(\n \"google.rpc.ResourceInfo\",\n () => [\n { no: 1, name: \"resource_type\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"resource_name\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 3, name: \"owner\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 4, name: \"description\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n ],\n);\n\n/**\n * Provides links to documentation or for performing an out of band action.\n *\n * For example, if a quota check failed with an error indicating the calling\n * project hasn't enabled the accessed service, this can contain a URL pointing\n * directly to the right place in the developer console to flip the bit.\n *\n * @generated from message google.rpc.Help\n */\nexport const Help = proto3.makeMessageType(\n \"google.rpc.Help\",\n () => [\n { no: 1, name: \"links\", kind: \"message\", T: Help_Link, repeated: true },\n ],\n);\n\n/**\n * Describes a URL link.\n *\n * @generated from message google.rpc.Help.Link\n */\nexport const Help_Link = proto3.makeMessageType(\n \"google.rpc.Help.Link\",\n () => [\n { no: 1, name: \"description\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"url\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n ],\n {localName: \"Help_Link\"},\n);\n\n/**\n * Provides a localized error message that is safe to return to the user\n * which can be attached to an RPC error.\n *\n * @generated from message google.rpc.LocalizedMessage\n */\nexport const LocalizedMessage = proto3.makeMessageType(\n \"google.rpc.LocalizedMessage\",\n () => [\n { no: 1, name: \"locale\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n { no: 2, name: \"message\", kind: \"scalar\", T: 9 /* ScalarType.STRING */ },\n ],\n);\n\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport enum Code {\n // Ok is returned when the operation completed successfully.\n Ok = 'ok',\n\n // ErrClientNotActivated is returned when the client is not active.\n ErrClientNotActivated = 'ErrClientNotActivated',\n\n // ErrClientNotFound is returned when the client is not found.\n ErrClientNotFound = 'ErrClientNotFound',\n\n // ErrUnimplemented is returned when the operation is not implemented.\n ErrUnimplemented = 'ErrUnimplemented',\n\n // ErrInvalidType is returned when the type is invalid.\n ErrInvalidType = 'ErrInvalidType',\n\n // ErrDummy is used to verify errors for testing purposes.\n ErrDummy = 'ErrDummy',\n\n // ErrDocumentNotAttached is returned when the document is not attached.\n ErrDocumentNotAttached = 'ErrDocumentNotAttached',\n\n // ErrDocumentNotDetached is returned when the document is not detached.\n ErrDocumentNotDetached = 'ErrDocumentNotDetached',\n\n // ErrDocumentRemoved is returned when the document is removed.\n ErrDocumentRemoved = 'ErrDocumentRemoved',\n\n // InvalidObjectKey is returned when the object key is invalid.\n ErrInvalidObjectKey = 'ErrInvalidObjectKey',\n\n // ErrInvalidArgument is returned when the argument is invalid.\n ErrInvalidArgument = 'ErrInvalidArgument',\n\n // ErrNotInitialized is returned when required initialization has not been completed.\n ErrNotInitialized = 'ErrNotInitialized',\n\n // ErrNotReady is returned when execution of following actions is not ready.\n ErrNotReady = 'ErrNotReady',\n\n // ErrRefused is returned when the execution is rejected.\n ErrRefused = 'ErrRefused',\n\n // ErrContextNotProvided is returned when a required React context is missing\n ErrContextNotProvided = 'ErrContextNotProvided',\n\n // ErrPermissionDenied is returned when the authorization webhook denies the request.\n ErrPermissionDenied = 'ErrPermissionDenied',\n\n // ErrUnauthenticated is returned when the request does not have valid authentication credentials.\n ErrUnauthenticated = 'ErrUnauthenticated',\n}\n\n/**\n * `YorkieError` is an error returned by a Yorkie operation.\n */\nexport class YorkieError extends Error {\n name = 'YorkieError';\n stack?: string;\n\n constructor(\n readonly code: Code,\n readonly message: string,\n ) {\n super(message);\n this.toString = (): string => `[code=${this.code}]: ${this.message}`;\n }\n}\n","/*\n * Copyright 2023 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Indexable } from '@yorkie-js-sdk/src/document/document';\n\n/**\n * `deepcopy` returns a deep copy of the given object.\n */\nexport function deepcopy<T>(object: T): T {\n if (object instanceof Map) {\n const pairs = Array.from(object);\n return new Map(JSON.parse(JSON.stringify(pairs))) as unknown as T;\n }\n\n return JSON.parse(JSON.stringify(object));\n}\n\n/**\n `isEmpty` returns whether parameter object is empty or not \n */\nexport const isEmpty = (object: object) => {\n if (!object) {\n return true;\n }\n\n return Object.entries(object).length === 0;\n};\n\n/**\n * `stringifyObjectValues` makes values of attributes to JSON parsable string.\n */\nexport const stringifyObjectValues = <A extends Indexable>(\n attributes: A,\n): Record<string, string> => {\n const attrs: Record<string, string> = {};\n for (const [key, value] of Object.entries(attributes)) {\n attrs[key] = JSON.stringify(value);\n }\n return attrs;\n};\n\n/**\n `parseObjectValues` returns the JSON parsable string values to the origin states.\n */\nexport const parseObjectValues = <A extends Indexable>(\n attrs: Record<string, string>,\n): A => {\n const attributes: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(attrs)) {\n attributes[key] = JSON.parse(value);\n }\n return attributes as A;\n};\n","/*\n * Copyright 2023 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { deepcopy } from '@yorkie-js-sdk/src/util/object';\nimport { Indexable } from '@yorkie-js-sdk/src/document/document';\nimport { ChangeContext } from '@yorkie-js-sdk/src/document/change/context';\n\n/**\n * `PresenceChangeType` represents the type of presence change.\n */\nexport enum PresenceChangeType {\n Put = 'put',\n Clear = 'clear',\n}\n\n/**\n * `PresenceChange` represents the change of presence.\n */\nexport type PresenceChange<P extends Indexable> =\n | { type: PresenceChangeType.Put; presence: P }\n | { type: PresenceChangeType.Clear };\n\n/**\n * `Presence` represents a proxy for the Presence to be manipulated from the outside.\n */\nexport class Presence<P extends Indexable> {\n private context: ChangeContext;\n private presence: P;\n\n constructor(changeContext: ChangeContext, presence: P) {\n this.context = changeContext;\n this.presence = presence;\n }\n\n /**\n * `set` updates the presence based on the partial presence.\n */\n public set(presence: Partial<P>, option?: { addToHistory: boolean }) {\n for (const key of Object.keys(presence)) {\n this.presence[key as keyof P] = presence[key]!;\n }\n\n this.context.setPresenceChange({\n type: PresenceChangeType.Put,\n presence: deepcopy(this.presence),\n });\n\n this.context.setReversePresence(presence, option);\n }\n\n /**\n * `get` returns the presence value of the given key.\n */\n public get<K extends keyof P>(key: K): P[K] {\n return this.presence[key];\n }\n\n /**\n * `clear` clears the presence.\n * @internal\n */\n public clear() {\n this.presence = {} as P;\n\n this.context.setPresenceChange({\n type: PresenceChangeType.Clear,\n });\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * `ActorID` is used to identify who is making changes to the document.\n * It is a hexadecimal string and should be generated by a unique value.\n *\n * @public\n */\nexport type ActorID = string;\n\n/**\n * `InitialActorID` is the initial value of ActorID.\n */\nexport const InitialActorID = '000000000000000000000000';\n\n/**\n * `MaxActorID` is the maximum value of ActorID.\n */\nexport const MaxActorID = 'FFFFFFFFFFFFFFFFFFFFFFFF';\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Comparator } from '@yorkie-js-sdk/src/util/comparator';\nimport {\n ActorID,\n InitialActorID,\n MaxActorID,\n} from '@yorkie-js-sdk/src/document/time/actor_id';\n\nexport const TicketComparator: Comparator<TimeTicket> = (\n p1: TimeTicket,\n p2: TimeTicket,\n) => {\n return p1.compare(p2);\n};\n\n/**\n * `TimeTicketStruct` is a structure represents the meta data of the ticket.\n * It is used to serialize and deserialize the ticket.\n */\nexport type TimeTicketStruct = {\n lamport: string;\n delimiter: number;\n actorID: ActorID;\n};\n\n/**\n * `TimeTicket` is a timestamp of the logical clock. Ticket is immutable.\n * It is created by `ChangeID`.\n *\n * @public\n */\nexport class TimeTicket {\n private lamport: bigint;\n private delimiter: number;\n private actorID: ActorID;\n\n constructor(lamport: bigint, delimiter: number, actorID: string) {\n this.lamport = lamport;\n this.delimiter = delimiter;\n this.actorID = actorID;\n }\n\n /**\n * `of` creates an instance of Ticket.\n */\n public static of(\n lamport: bigint,\n delimiter: number,\n actorID: string,\n ): TimeTicket {\n return new TimeTicket(lamport, delimiter, actorID);\n }\n\n /**\n * `fromStruct` creates an instance of Ticket from the struct.\n */\n public static fromStruct(struct: TimeTicketStruct): TimeTicket {\n return TimeTicket.of(\n BigInt(struct.lamport),\n struct.delimiter,\n struct.actorID,\n );\n }\n\n /**\n * `toIDString` returns the lamport string for this Ticket.\n */\n public toIDString(): string {\n return `${this.lamport.toString()}:${this.actorID}:${this.delimiter}`;\n }\n\n /**\n * `toStruct` returns the structure of this Ticket.\n */\n public toStruct(): TimeTicketStruct {\n return {\n lamport: this.getLamportAsString(),\n delimiter: this.getDelimiter(),\n actorID: this.getActorID(),\n };\n }\n\n /**\n * `toTestString` returns a string containing the meta data of the ticket\n * for debugging purpose.\n */\n public toTestString(): string {\n return `${this.lamport.toString()}:${this.actorID.slice(-2)}:${\n this.delimiter\n }`;\n }\n\n /**\n * `setActor` creates a new instance of Ticket with the given actorID.\n */\n public setActor(actorID: ActorID): TimeTicket {\n return new TimeTicket(this.lamport, this.delimiter, actorID);\n }\n\n /**\n * `getLamportAsString` returns the lamport string.\n */\n public getLamportAsString(): string {\n return this.lamport.toString();\n }\n\n /**\n * `getLamport` returns the lamport.\n */\n public getLamport(): bigint {\n return this.lamport;\n }\n\n /**\n * `getDelimiter` returns delimiter.\n */\n public getDelimiter(): number {\n return this.delimiter;\n }\n\n /**\n * `getActorID` returns actorID.\n */\n public getActorID(): string {\n return this.actorID;\n }\n\n /**\n * `after` returns whether the given ticket was created later.\n */\n public after(other: TimeTicket): boolean {\n return this.compare(other) > 0;\n }\n\n /**\n * `equals` returns whether the given ticket was created.\n */\n public equals(other: TimeTicket): boolean {\n return this.compare(other) === 0;\n }\n\n /**\n * `compare` returns an integer comparing two Ticket.\n * The result will be 0 if id==other, -1 if `id < other`, and +1 if `id > other`.\n * If the receiver or argument is nil, it would panic at runtime.\n */\n public compare(other: TimeTicket): number {\n if (this.lamport > other.lamport) {\n return 1;\n } else if (other.lamport > this.lamport) {\n return -1;\n }\n\n const compare = this.actorID.localeCompare(other.actorID);\n if (compare !== 0) {\n return compare;\n }\n\n if (this.delimiter > other.delimiter) {\n return 1;\n } else if (other.delimiter > this.delimiter) {\n return -1;\n }\n\n return 0;\n }\n}\n\nexport const InitialDelimiter = 0;\nexport const MaxDelemiter = 4294967295; // UInt32 MAX_VALUE\nexport const MaxLamport = 9223372036854775807n; // Int64 MAX_VALUE\n\nexport const InitialTimeTicket = new TimeTicket(\n 0n,\n InitialDelimiter,\n InitialActorID,\n);\n\nexport const MaxTimeTicket = new TimeTicket(\n MaxLamport,\n MaxDelemiter,\n MaxActorID,\n);\n","/**\n * `EscapeString` escapes the given string.\n */\nexport function escapeString(str: string): string {\n return str.replace(/[\"'\\\\\\n\\r\\f\\b\\t\\u2028\\u2029]/g, function (character) {\n switch (character) {\n case '\"':\n case '\\\\':\n return '\\\\' + character;\n case '\\n':\n return '\\\\n';\n case '\\r':\n return '\\\\r';\n case '\\f':\n return '\\\\f';\n case '\\b':\n return '\\\\b';\n case '\\t':\n return '\\\\t';\n case '\\u2028':\n return '\\\\u2028';\n case '\\u2029':\n return '\\\\u2029';\n default:\n return character;\n }\n });\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport type * as Devtools from '@yorkie-js-sdk/src/devtools/types';\n\n/**\n * `CRDTElement` represents an element that has `TimeTicket`s.\n *\n * @internal\n */\nexport abstract class CRDTElement {\n private createdAt: TimeTicket;\n private movedAt?: TimeTicket;\n private removedAt?: TimeTicket;\n\n constructor(createdAt: TimeTicket) {\n this.createdAt = createdAt;\n }\n\n /**\n * `getCreatedAt` returns the creation time of this element.\n */\n public getCreatedAt(): TimeTicket {\n return this.createdAt;\n }\n\n /**\n * `getID` returns the creation time of this element.\n */\n public getID(): TimeTicket {\n return this.createdAt;\n }\n\n /**\n * `getMovedAt` returns the move time of this element.\n */\n public getMovedAt(): TimeTicket | undefined {\n return this.movedAt;\n }\n\n /**\n * `getRemovedAt` returns the removal time of this element.\n */\n public getRemovedAt(): TimeTicket | undefined {\n return this.removedAt;\n }\n\n /**\n * `getPositionedAt` returns the time of this element when it was positioned\n * in the document by undo/redo or move operation.\n */\n public getPositionedAt(): TimeTicket {\n if (!this.movedAt) {\n return this.createdAt;\n }\n\n return this.movedAt;\n }\n\n /**\n * `setMovedAt` sets the move time of this element.\n */\n public setMovedAt(movedAt?: TimeTicket): boolean {\n if (!this.movedAt || (movedAt && movedAt.after(this.movedAt))) {\n this.movedAt = movedAt;\n return true;\n }\n\n return false;\n }\n\n /**\n * `setRemovedAt` sets the remove time of this element.\n */\n public setRemovedAt(removedAt?: TimeTicket): void {\n this.removedAt = removedAt;\n }\n\n /**\n * `remove` removes this element.\n */\n public remove(removedAt?: TimeTicket): boolean {\n if (\n removedAt &&\n removedAt.after(this.getPositionedAt()) &&\n (!this.removedAt || removedAt.after(this.removedAt))\n ) {\n // NOTE(chacha912): If it's a CRDTContainer, removedAt is marked only on\n // the top-level element, without marking all descendant elements. This\n // enhances the speed of deletion.\n this.removedAt = removedAt;\n return true;\n }\n\n return false;\n }\n\n /**\n * `isRemoved` check if this element was removed.\n */\n public isRemoved(): boolean {\n return !!this.removedAt;\n }\n\n abstract toJSON(): string;\n abstract toSortedJSON(): string;\n abstract toJSForTest(): Devtools.JSONElement;\n abstract deepcopy(): CRDTElement;\n}\n\n/**\n *\n * `CRDTContainer` represents CRDTArray or CRDtObject.\n */\nexport abstract class CRDTContainer extends CRDTElement {\n constructor(createdAt: TimeTicket) {\n super(createdAt);\n }\n\n /**\n * `subPathOf` returns the sub path of the given element.\n */\n abstract subPathOf(createdAt: TimeTicket): string | undefined;\n\n abstract purge(element: CRDTElement): void;\n\n abstract delete(createdAt: TimeTicket, executedAt: TimeTicket): CRDTElement;\n\n abstract getDescendants(\n callback: (elem: CRDTElement, parent: CRDTContainer) => boolean,\n ): void;\n\n /**\n * `get` returns the element of the given key or index. This method is called\n * by users. So it should return undefined if the element is removed.\n */\n abstract get(keyOrIndex: string | number): CRDTElement | undefined;\n\n /**\n * `getByID` returns the element of the given creation time. This method is\n * called by internal. So it should return the element even if the element is\n * removed.\n */\n abstract getByID(createdAt: TimeTicket): CRDTElement | undefined;\n}\n","/*\n * Copyright 2023 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { CRDTElement } from '@yorkie-js-sdk/src/document/crdt/element';\nimport { YorkieError, Code } from '@yorkie-js-sdk/src/util/error';\n\n/**\n * `ElementRHTNode` is a node of ElementRHT.\n */\nexport class ElementRHTNode {\n private strKey: string;\n private value: CRDTElement;\n\n constructor(strKey: string, value: CRDTElement) {\n this.strKey = strKey;\n this.value = value;\n }\n\n /**\n * `of` creates a instance of ElementRHTNode.\n */\n public static of(strKey: string, value: CRDTElement): ElementRHTNode {\n return new ElementRHTNode(strKey, value);\n }\n\n /**\n * `isRemoved` checks whether this value was removed.\n */\n public isRemoved(): boolean {\n return this.value.isRemoved();\n }\n\n /**\n * `getStrKey` returns the key of this node.\n */\n public getStrKey(): string {\n return this.strKey;\n }\n\n /**\n * `getValue` return the value(element) of this node\n */\n public getValue(): CRDTElement {\n return this.value;\n }\n\n /**\n * `remove` removes a value base on removing time.\n */\n public remove(removedAt: TimeTicket): boolean {\n return this.value.remove(removedAt);\n }\n}\n\n/**\n * ElementRHT is a hashtable with logical clock(Replicated hashtable)\n *\n */\nexport class ElementRHT {\n private nodeMapByKey: Map<string, ElementRHTNode>;\n private nodeMapByCreatedAt: Map<string, ElementRHTNode>;\n\n constructor() {\n this.nodeMapByKey = new Map();\n this.nodeMapByCreatedAt = new Map();\n }\n\n /**\n * `create` creates an instance of ElementRHT.\n */\n public static create(): ElementRHT {\n return new ElementRHT();\n }\n\n /**\n * `set` sets the value of the given key.\n */\n public set(\n key: string,\n value: CRDTElement,\n executedAt: TimeTicket,\n ): CRDTElement | undefined {\n let removed;\n const node = this.nodeMapByKey.get(key);\n if (node != null && !node.isRemoved() && node.remove(executedAt)) {\n removed = node.getValue();\n }\n\n const newNode = ElementRHTNode.of(key, value);\n this.nodeMapByCreatedAt.set(value.getCreatedAt().toIDString(), newNode);\n if (node == null || executedAt.after(node.getValue().getPositionedAt())) {\n this.nodeMapByKey.set(key, newNode);\n value.setMovedAt(executedAt);\n }\n return removed;\n }\n\n /**\n * `delete` deletes the Element of the given key.\n */\n public delete(createdAt: TimeTicket, executedAt: TimeTicket): CRDTElement {\n if (!this.nodeMapByCreatedAt.has(createdAt.toIDString())) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to find ${createdAt.toIDString()}`,\n );\n }\n\n const node = this.nodeMapByCreatedAt.get(createdAt.toIDString())!;\n node.remove(executedAt);\n return node.getValue();\n }\n\n /**\n * `subPathOf` returns the sub path of the given element.\n */\n public subPathOf(createdAt: TimeTicket): string | undefined {\n const node = this.nodeMapByCreatedAt.get(createdAt.toIDString());\n if (!node) {\n return;\n }\n\n return node.getStrKey();\n }\n\n /**\n * `purge` physically purge child element.\n */\n public purge(element: CRDTElement): void {\n const node = this.nodeMapByCreatedAt.get(\n element.getCreatedAt().toIDString(),\n );\n if (!node) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to find ${element.getCreatedAt().toIDString()}`,\n );\n }\n\n const nodeByKey = this.nodeMapByKey.get(node.getStrKey());\n if (node === nodeByKey) {\n this.nodeMapByKey.delete(nodeByKey.getStrKey());\n }\n\n this.nodeMapByCreatedAt.delete(node.getValue().getCreatedAt().toIDString());\n }\n\n /**\n * `deleteByKey` deletes the Element of the given key and removed time.\n */\n public deleteByKey(\n key: string,\n removedAt: TimeTicket,\n ): CRDTElement | undefined {\n const node = this.nodeMapByKey.get(key);\n if (node == null) {\n return;\n }\n\n if (!node.remove(removedAt)) {\n return;\n }\n\n return node.getValue();\n }\n\n /**\n * `has` returns whether the element exists of the given key or not.\n */\n public has(key: string): boolean {\n const node = this.nodeMapByKey.get(key);\n if (node == null) {\n return false;\n }\n return !node.isRemoved();\n }\n\n /**\n * `getByID` returns the node of the given createdAt.\n */\n public getByID(createdAt: TimeTicket): ElementRHTNode | undefined {\n return this.nodeMapByCreatedAt.get(createdAt.toIDString());\n }\n\n /**\n * `get` returns the node of the given key.\n */\n public get(key: string): ElementRHTNode | undefined {\n const node = this.nodeMapByKey.get(key);\n if (!node || node.isRemoved()) {\n return;\n }\n\n return node;\n }\n\n // eslint-disable-next-line jsdoc/require-jsdoc\n public *[Symbol.iterator](): IterableIterator<ElementRHTNode> {\n for (const [, node] of this.nodeMapByKey) {\n yield node;\n }\n }\n}\n","/*\n * Copyright 2023 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { escapeString } from '@yorkie-js-sdk/src/document/json/strings';\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport {\n CRDTContainer,\n CRDTElement,\n} from '@yorkie-js-sdk/src/document/crdt/element';\nimport { ElementRHT } from '@yorkie-js-sdk/src/document/crdt/element_rht';\nimport type * as Devtools from '@yorkie-js-sdk/src/devtools/types';\n\n/**\n * `CRDTObject` represents an object data type, but unlike regular JSON,\n * it has `TimeTicket`s which are created by logical clock.\n *\n */\nexport class CRDTObject extends CRDTContainer {\n private memberNodes: ElementRHT;\n\n constructor(createdAt: TimeTicket, memberNodes: ElementRHT) {\n super(createdAt);\n this.memberNodes = memberNodes;\n }\n\n /**\n * `create` creates a new instance of CRDTObject.\n */\n public static create(\n createdAt: TimeTicket,\n value?: { [key: string]: CRDTElement },\n ): CRDTObject {\n if (!value) {\n return new CRDTObject(createdAt, ElementRHT.create());\n }\n\n const memberNodes = ElementRHT.create();\n for (const [k, v] of Object.entries(value)) {\n memberNodes.set(k, v.deepcopy(), v.getCreatedAt());\n }\n return new CRDTObject(createdAt, memberNodes);\n }\n\n /**\n * `subPathOf` returns the sub path of the given element.\n */\n public subPathOf(createdAt: TimeTicket): string | undefined {\n return this.memberNodes.subPathOf(createdAt);\n }\n\n /**\n * `purge` physically purges the given element.\n */\n public purge(value: CRDTElement): void {\n this.memberNodes.purge(value);\n }\n\n /**\n * `set` sets the given element of the given key.\n */\n public set(\n key: string,\n value: CRDTElement,\n executedAt: TimeTicket,\n ): CRDTElement | undefined {\n return this.memberNodes.set(key, value, executedAt);\n }\n\n /**\n * `delete` deletes the element of the given key.\n */\n public delete(createdAt: TimeTicket, executedAt: TimeTicket): CRDTElement {\n return this.memberNodes.delete(createdAt, executedAt);\n }\n\n /**\n * `deleteByKey` deletes the element of the given key and execution time.\n */\n public deleteByKey(\n key: string,\n executedAt: TimeTicket,\n ): CRDTElement | undefined {\n return this.memberNodes.deleteByKey(key, executedAt);\n }\n\n /**\n * `get` returns the value of the given key.\n */\n public get(key: string): CRDTElement | undefined {\n const node = this.memberNodes.get(key);\n return node?.getValue();\n }\n\n /**\n * `getByID` returns the element of the given createAt.\n */\n public getByID(createdAt: TimeTicket): CRDTElement | undefined {\n const node = this.memberNodes.getByID(createdAt);\n return node?.getValue();\n }\n\n /**\n * `has` returns whether the element exists of the given key or not.\n */\n public has(key: string): boolean {\n return this.memberNodes.has(key);\n }\n\n /**\n * `toJSON` returns the JSON encoding of this object.\n */\n public toJSON(): string {\n const json = [];\n for (const [key, value] of this) {\n json.push(`\"${escapeString(key)}\":${value.toJSON()}`);\n }\n return `{${json.join(',')}}`;\n }\n\n /**\n * `toJS` returns the JavaScript object of this object.\n */\n public toJS(): any {\n return JSON.parse(this.toJSON());\n }\n\n /**\n * `toJSForTest` returns value with meta data for testing.\n */\n public toJSForTest(): Devtools.JSONElement {\n const values: Devtools.ContainerValue = {};\n for (const [key, elem] of this) {\n const { createdAt, value, type } = elem.toJSForTest();\n values[key] = {\n key,\n createdAt,\n value,\n type,\n };\n }\n return {\n createdAt: this.getCreatedAt().toTestString(),\n value: values,\n type: 'YORKIE_OBJECT',\n };\n }\n\n /**\n * `getKeys` returns array of keys in this object.\n */\n public getKeys(): Array<string> {\n const keys = Array<string>();\n for (const [key] of this) {\n keys.push(key);\n }\n\n return keys;\n }\n\n /**\n * `toSortedJSON` returns the sorted JSON encoding of this object.\n */\n public toSortedJSON(): string {\n const keys = Array<string>();\n for (const [key] of this) {\n keys.push(key);\n }\n\n const json = [];\n for (const key of keys.sort()) {\n const node = this.memberNodes.get(key)?.getValue();\n json.push(`\"${escapeString(key)}\":${node!.toSortedJSON()}`);\n }\n\n return `{${json.join(',')}}`;\n }\n\n /**\n * `getRHT` RHTNodes returns the RHTPQMap nodes.\n */\n public getRHT(): ElementRHT {\n return this.memberNodes;\n }\n\n /**\n * `deepcopy` copies itself deeply.\n */\n public deepcopy(): CRDTObject {\n const clone = CRDTObject.create(this.getCreatedAt());\n for (const node of this.memberNodes) {\n clone.memberNodes.set(\n node.getStrKey(),\n node.getValue().deepcopy(),\n this.getPositionedAt(),\n );\n }\n clone.remove(this.getRemovedAt());\n return clone;\n }\n\n /**\n * `getDescendants` returns the descendants of this object by traversing.\n */\n public getDescendants(\n callback: (elem: CRDTElement, parent: CRDTContainer) => boolean,\n ): void {\n for (const node of this.memberNodes) {\n const element = node.getValue();\n if (callback(element, this)) {\n return;\n }\n\n if (element instanceof CRDTContainer) {\n element.getDescendants(callback);\n }\n }\n }\n\n /**\n * eslint-disable-next-line jsdoc/require-jsdoc\n * @internal\n */\n public *[Symbol.iterator](): IterableIterator<[string, CRDTElement]> {\n const keySet = new Set<string>();\n for (const node of this.memberNodes) {\n if (!keySet.has(node.getStrKey())) {\n keySet.add(node.getStrKey());\n if (!node.isRemoved()) {\n yield [node.getStrKey(), node.getValue()];\n }\n }\n }\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ActorID } from '@yorkie-js-sdk/src/document/time/actor_id';\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { VersionVector } from '@yorkie-js-sdk/src/document/time/version_vector';\nimport { TreeNode } from '@yorkie-js-sdk/src/document/crdt/tree';\nimport { CRDTRoot } from '@yorkie-js-sdk/src/document/crdt/root';\nimport { Indexable } from '@yorkie-js-sdk/src/document/document';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\n\n/**\n * `OpSource` represents the source of the operation. It is used to handle\n * corner cases in the operations created by undo/redo allow the removed\n * elements when executing them.\n */\nexport enum OpSource {\n Local = 'local',\n Remote = 'remote',\n UndoRedo = 'undoredo',\n}\n\n/**\n * `OperationInfo` represents the information of an operation.\n * It is used to inform to the user what kind of operation was executed.\n */\nexport type OperationInfo =\n | TextOperationInfo\n | CounterOperationInfo\n | ArrayOperationInfo\n | ObjectOperationInfo\n | TreeOperationInfo;\n\n/**\n * `TextOperationInfo` represents the OperationInfo for the yorkie.Text.\n */\nexport type TextOperationInfo = EditOpInfo | StyleOpInfo;\n\n/**\n * `CounterOperationInfo` represents the OperationInfo for the yorkie.Counter.\n */\nexport type CounterOperationInfo = IncreaseOpInfo;\n\n/**\n * `ArrayOperationInfo` represents the OperationInfo for the JSONArray.\n */\nexport type ArrayOperationInfo = AddOpInfo | RemoveOpInfo | MoveOpInfo;\n\n/**\n * `ObjectOperationInfo` represents the OperationInfo for the JSONObject.\n */\nexport type ObjectOperationInfo = SetOpInfo | RemoveOpInfo;\n\n/**\n * `TreeOperationInfo` represents the OperationInfo for the yorkie.Tree.\n */\nexport type TreeOperationInfo = TreeEditOpInfo | TreeStyleOpInfo;\n\n/**\n * `AddOpInfo` represents the information of the add operation.\n */\nexport type AddOpInfo = {\n type: 'add';\n path: string;\n index: number;\n};\n\n/**\n * `MoveOpInfo` represents the information of the move operation.\n */\nexport type MoveOpInfo = {\n type: 'move';\n path: string;\n previousIndex: number;\n index: number;\n};\n\n/**\n * `SetOpInfo` represents the information of the set operation.\n */\nexport type SetOpInfo = {\n type: 'set';\n path: string;\n key: string;\n};\n\n/**\n * `RemoveOpInfo` represents the information of the remove operation.\n */\nexport type RemoveOpInfo = {\n type: 'remove';\n path: string;\n key?: string;\n index?: number;\n};\n\n/**\n * `IncreaseOpInfo` represents the information of the increase operation.\n */\nexport type IncreaseOpInfo = {\n type: 'increase';\n path: string;\n value: number;\n};\n\n/**\n * `EditOpInfo` represents the information of the edit operation.\n */\nexport type EditOpInfo = {\n type: 'edit';\n path: string;\n from: number;\n to: number;\n value: {\n attributes: Indexable;\n content: string;\n };\n};\n\n/**\n * `StyleOpInfo` represents the information of the style operation.\n */\nexport type StyleOpInfo = {\n type: 'style';\n path: string;\n from: number;\n to: number;\n value: {\n attributes: Indexable;\n };\n};\n\n/**\n * `TreeEditOpInfo` represents the information of the tree edit operation.\n */\nexport type TreeEditOpInfo = {\n type: 'tree-edit';\n path: string;\n from: number;\n to: number;\n value?: Array<TreeNode>;\n splitLevel?: number;\n fromPath: Array<number>;\n toPath: Array<number>;\n};\n\n/**\n * `TreeStyleOpInfo` represents the information of the tree style operation.\n */\nexport type TreeStyleOpInfo = {\n type: 'tree-style';\n path: string;\n from: number;\n to: number;\n fromPath: Array<number>;\n toPath: Array<number>;\n value: {\n attributes?: Indexable;\n attributesToRemove?: Array<string>;\n };\n};\n\n/**\n * `ExecutionResult` represents the result of operation execution.\n */\nexport type ExecutionResult = {\n opInfos: Array<OperationInfo>;\n // TODO(chacha912): After implementing all of the reverseOperation,\n // we change the type to non-optional.\n reverseOp?: Operation;\n};\n\n/**\n * `Operation` represents an operation to be executed on a document.\n */\nexport abstract class Operation {\n private parentCreatedAt: TimeTicket;\n // NOTE(Hyemmie): `executedAt` variable is undefined if this operation is not executed yet.\n private executedAt?: TimeTicket;\n\n constructor(parentCreatedAt: TimeTicket, executedAt?: TimeTicket) {\n this.parentCreatedAt = parentCreatedAt;\n this.executedAt = executedAt;\n }\n\n /**\n * `getParentCreatedAt` returns the creation time of the target element to\n * execute the operation.\n */\n public getParentCreatedAt(): TimeTicket {\n return this.parentCreatedAt;\n }\n\n /**\n * `getExecutedAt` returns execution time of this operation.\n */\n public getExecutedAt(): TimeTicket {\n // NOTE(chacha912): When an operation is in the undo/redo stack,\n // it doesn't have an executedAt yet. The executedAt is set when\n // the operation is executed through undo or redo.\n if (!this.executedAt) {\n throw new YorkieError(Code.ErrNotReady, 'executedAt is not set yet');\n }\n return this.executedAt;\n }\n\n /**\n * `setActor` sets the given actor to this operation.\n */\n public setActor(actorID: ActorID): void {\n if (this.executedAt) {\n this.executedAt = this.executedAt.setActor(actorID);\n }\n }\n\n /**\n * `setExecutedAt` sets the executedAt.\n */\n public setExecutedAt(executedAt: TimeTicket): void {\n this.executedAt = executedAt;\n }\n\n /**\n * `getEffectedCreatedAt` returns the creation time of the effected element.\n */\n public abstract getEffectedCreatedAt(): TimeTicket;\n\n /**\n * `toTestString` returns a string containing the meta data for debugging purpose.\n */\n public abstract toTestString(): string;\n\n /**\n * `execute` executes this operation on the given `CRDTRoot`.\n */\n public abstract execute(\n root: CRDTRoot,\n source: OpSource,\n versionVector?: VersionVector,\n ): ExecutionResult | undefined;\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Code, YorkieError } from './error';\n\n/**\n * `SplayNode` is a node of SplayTree.\n */\nexport abstract class SplayNode<V> {\n protected value: V;\n\n private left?: SplayNode<V>;\n private right?: SplayNode<V>;\n private parent?: SplayNode<V>;\n private weight!: number;\n\n constructor(value: V) {\n this.value = value;\n this.initWeight();\n }\n\n abstract getLength(): number;\n\n /**\n * `getNodeString` returns a string of weight and value of this node.\n */\n public getNodeString(): string {\n return `${this.weight}${this.value}`;\n }\n\n /**\n * `getValue` returns value of this node.\n */\n public getValue(): V {\n return this.value;\n }\n\n /**\n * `getLeftWeight` returns left weight of this node.\n */\n public getLeftWeight(): number {\n return !this.hasLeft() ? 0 : this.left!.getWeight();\n }\n\n /**\n * `getRightWeight` returns right weight of this node.\n */\n public getRightWeight(): number {\n return !this.hasRight() ? 0 : this.right!.getWeight();\n }\n\n /**\n * `getWeight` returns weight of this node.\n */\n public getWeight(): number {\n return this.weight;\n }\n\n /**\n * `getLeft` returns a left node.\n */\n public getLeft(): SplayNode<V> | undefined {\n return this.left;\n }\n\n /**\n * `getRight` returns a right node.\n */\n public getRight(): SplayNode<V> | undefined {\n return this.right;\n }\n\n /**\n * `getParent` returns parent of this node.\n */\n public getParent(): SplayNode<V> | undefined {\n return this.parent;\n }\n\n /**\n * `hasLeft` check if the left node exists\n */\n public hasLeft(): boolean {\n return !!this.left;\n }\n\n /**\n * `hasRight` check if the right node exists\n */\n public hasRight(): boolean {\n return !!this.right;\n }\n\n /**\n * `hasParent` check if the parent node exists\n */\n public hasParent(): boolean {\n return !!this.parent;\n }\n\n /**\n * `setLeft` sets a left node.\n */\n public setLeft(left?: SplayNode<V>): void {\n this.left = left;\n }\n\n /**\n * `setRight` sets a right node.\n */\n public setRight(right?: SplayNode<V>): void {\n this.right = right;\n }\n\n /**\n * `setParent` sets a parent node.\n */\n public setParent(parent?: SplayNode<V>): void {\n this.parent = parent;\n }\n\n /**\n * `unlink` unlink parent, right and left node.\n */\n public unlink(): void {\n this.parent = undefined;\n this.right = undefined;\n this.left = undefined;\n }\n\n /**\n * `hasLinks` checks if parent, right and left node exists.\n */\n public hasLinks(): boolean {\n return this.hasParent() || this.hasLeft() || this.hasRight();\n }\n\n /**\n * `increaseWeight` increases weight.\n */\n public increaseWeight(weight: number): void {\n this.weight! += weight;\n }\n\n /**\n * `initWeight` sets initial weight of this node.\n */\n public initWeight(): void {\n this.weight = this.getLength();\n }\n}\n\n/**\n * SplayTree is weighted binary search tree which is based on Splay tree.\n * original paper on Splay Trees:\n * @see https://www.cs.cmu.edu/~sleator/papers/self-adjusting.pdf\n */\nexport class SplayTree<V> {\n private root?: SplayNode<V>;\n\n constructor(root?: SplayNode<V>) {\n this.root = root;\n }\n\n /**\n * `length` returns the size of this tree.\n */\n public get length(): number {\n return this.root ? this.root.getWeight() : 0;\n }\n\n /**\n * `find` returns the Node and offset of the given index.\n */\n public find(pos: number): [SplayNode<V> | undefined, number] {\n if (!this.root || pos < 0) {\n return [undefined, 0];\n }\n\n let node = this.root;\n for (;;) {\n if (node.hasLeft() && pos <= node.getLeftWeight()) {\n node = node.getLeft()!;\n } else if (\n node.hasRight() &&\n node.getLeftWeight() + node.getLength() < pos\n ) {\n pos -= node.getLeftWeight() + node.getLength();\n node = node.getRight()!;\n } else {\n pos -= node.getLeftWeight();\n break;\n }\n }\n if (pos > node.getLength()) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `out of index range: pos: ${pos} > node.length: ${node.getLength()}`,\n );\n }\n this.splayNode(node);\n return [node, pos];\n }\n\n /**\n * Find the index of the given node in BST.\n *\n * @param node - the given node\n * @returns the index of given node\n */\n public indexOf(node: SplayNode<V>): number {\n if (!node || (node !== this.root && !node.hasLinks())) {\n return -1;\n }\n\n this.splayNode(node);\n return this.root!.getLeftWeight();\n }\n\n /**\n * `getRoot` returns root of this tree.\n */\n public getRoot(): SplayNode<V> {\n return this.root!;\n }\n\n /**\n * `insert` inserts the node at the last.\n */\n public insert(newNode: SplayNode<V>): SplayNode<V> {\n return this.insertAfter(this.root, newNode);\n }\n\n /**\n * `insertAfter` inserts the node after the given previous node.\n */\n public insertAfter(\n target: SplayNode<V> | undefined,\n newNode: SplayNode<V>,\n ): SplayNode<V> {\n // TODO(Eithea): Consider moving the code below to insert()\n if (!target) {\n this.root = newNode;\n return newNode;\n }\n\n this.splayNode(target);\n this.root = newNode;\n newNode.setRight(target.getRight());\n if (target.hasRight()) {\n target.getRight()!.setParent(newNode);\n }\n newNode.setLeft(target);\n target.setParent(newNode);\n target.setRight();\n this.updateWeight(target);\n this.updateWeight(newNode);\n\n return newNode;\n }\n\n /**\n * `updateWeight` recalculates the weight of this node with the value and children.\n */\n public updateWeight(node: SplayNode<V>): void {\n node.initWeight();\n\n if (node.hasLeft()) {\n node.increaseWeight(node.getLeftWeight());\n }\n if (node.hasRight()) {\n node.increaseWeight(node.getRightWeight());\n }\n }\n\n private updateTreeWeight(node: SplayNode<V>): void {\n while (node) {\n this.updateWeight(node);\n node = node.getParent()!;\n }\n }\n\n /**\n * `splayNode` moves the given node to the root.\n */\n public splayNode(node: SplayNode<V> | undefined): void {\n if (!node) {\n return;\n }\n\n for (;;) {\n if (this.isLeftChild(node.getParent()) && this.isRightChild(node)) {\n // zig-zag\n this.rotateLeft(node);\n this.rotateRight(node);\n } else if (\n this.isRightChild(node.getParent()) &&\n this.isLeftChild(node)\n ) {\n // zig-zag\n this.rotateRight(node);\n this.rotateLeft(node);\n } else if (this.isLeftChild(node.getParent()) && this.isLeftChild(node)) {\n // zig-zig\n this.rotateRight(node.getParent()!);\n this.rotateRight(node);\n } else if (\n this.isRightChild(node.getParent()) &&\n this.isRightChild(node)\n ) {\n // zig-zig\n this.rotateLeft(node.getParent()!);\n this.rotateLeft(node);\n } else {\n // zig\n if (this.isLeftChild(node)) {\n this.rotateRight(node);\n } else if (this.isRightChild(node)) {\n this.rotateLeft(node);\n }\n this.updateWeight(node);\n return;\n }\n }\n }\n\n /**\n * `delete` deletes target node of this tree.\n */\n public delete(node: SplayNode<V>): void {\n this.splayNode(node);\n\n const leftTree = new SplayTree(node.getLeft());\n if (leftTree.root) {\n leftTree.root.setParent();\n }\n\n const rightTree = new SplayTree(node.getRight());\n if (rightTree.root) {\n rightTree.root.setParent();\n }\n\n if (leftTree.root) {\n const rightmostNode = leftTree.getRightmost();\n leftTree.splayNode(rightmostNode);\n leftTree.root.setRight(rightTree.root);\n if (rightTree.root) {\n rightTree.root.setParent(leftTree.root);\n }\n this.root = leftTree.root;\n } else {\n this.root = rightTree.root;\n }\n\n node.unlink();\n if (this.root) {\n this.updateWeight(this.root);\n }\n }\n\n /**\n * `deleteRange` separates the range between given 2 boundaries from this Tree.\n * This function separates the range to delete as a subtree\n * by splaying outer boundary nodes.\n * leftBoundary must exist because of 0-indexed initial dummy node of tree,\n * but rightBoundary can be nil means range to delete includes the end of tree.\n * Refer to the design document in https://github.com/yorkie-team/yorkie/tree/main/design\n */\n public deleteRange(\n leftBoundary: SplayNode<V>,\n rightBoundary: SplayNode<V> | undefined,\n ): void {\n if (!rightBoundary) {\n this.splayNode(leftBoundary);\n this.cutOffRight(leftBoundary);\n return;\n }\n this.splayNode(leftBoundary);\n this.splayNode(rightBoundary);\n if (rightBoundary.getLeft() != leftBoundary) {\n this.rotateRight(leftBoundary);\n }\n this.cutOffRight(leftBoundary);\n }\n\n private cutOffRight(root: SplayNode<V>): void {\n const nodesToFreeWeight: Array<SplayNode<V>> = [];\n this.traversePostorder(root.getRight(), nodesToFreeWeight);\n for (const node of nodesToFreeWeight) {\n node.initWeight();\n }\n this.updateTreeWeight(root);\n }\n\n /**\n * `toTestString` returns a string containing the meta data of the Node\n * for debugging purpose.\n */\n public toTestString(): string {\n const metaString: Array<SplayNode<V>> = [];\n this.traverseInorder(this.root!, metaString);\n return metaString\n .map((n) => `[${n.getWeight()},${n.getLength()}]${n.getValue() || ''}`)\n .join('');\n }\n\n /**\n * `checkWeight` returns false when there is an incorrect weight node.\n * for debugging purpose.\n */\n public checkWeight(): boolean {\n const nodes: Array<SplayNode<V>> = [];\n this.traverseInorder(this.root!, nodes);\n for (const node of nodes) {\n if (\n node.getWeight() !=\n node.getLength() + node.getLeftWeight() + node.getRightWeight()\n ) {\n return false;\n }\n }\n return true;\n }\n\n private getRightmost(): SplayNode<V> {\n let node = this.root!;\n while (node.hasRight()) {\n node = node.getRight()!;\n }\n return node;\n }\n\n private traverseInorder(\n node: SplayNode<V> | undefined,\n stack: Array<SplayNode<V>>,\n ): void {\n if (!node) {\n return;\n }\n\n this.traverseInorder(node.getLeft(), stack);\n stack.push(node);\n this.traverseInorder(node.getRight(), stack);\n }\n\n private traversePostorder(\n node: SplayNode<V> | undefined,\n stack: Array<SplayNode<V>>,\n ): void {\n if (!node) {\n return;\n }\n\n this.traversePostorder(node.getLeft(), stack);\n this.traversePostorder(node.getRight(), stack);\n stack.push(node);\n }\n\n private rotateLeft(pivot: SplayNode<V>): void {\n const root = pivot.getParent()!;\n if (root.hasParent()) {\n if (root === root.getParent()!.getLeft()) {\n root.getParent()!.setLeft(pivot);\n } else {\n root.getParent()!.setRight(pivot);\n }\n } else {\n this.root = pivot;\n }\n pivot.setParent(root.getParent());\n\n root.setRight(pivot.getLeft());\n if (root.hasRight()) {\n root.getRight()!.setParent(root);\n }\n\n pivot.setLeft(root);\n pivot.getLeft()!.setParent(pivot);\n\n this.updateWeight(root);\n this.updateWeight(pivot);\n }\n\n private rotateRight(pivot: SplayNode<V>): void {\n const root = pivot.getParent()!;\n if (root.hasParent()) {\n if (root === root.getParent()!.getLeft()) {\n root.getParent()!.setLeft(pivot);\n } else {\n root.getParent()!.setRight(pivot);\n }\n } else {\n this.root = pivot;\n }\n pivot.setParent(root.getParent());\n\n root.setLeft(pivot.getRight());\n if (root.hasLeft()) {\n root.getLeft()!.setParent(root);\n }\n\n pivot.setRight(root);\n pivot.getRight()!.setParent(pivot);\n\n this.updateWeight(root);\n this.updateWeight(pivot);\n }\n\n private isLeftChild(node?: SplayNode<V>): boolean {\n if (node && node.hasParent()) {\n return node.getParent()!.getLeft() === node;\n }\n return false;\n }\n\n private isRightChild(node?: SplayNode<V>): boolean {\n if (node && node.hasParent()) {\n return node.getParent()!.getRight() === node;\n }\n return false;\n }\n}\n","/**\n * @license\n * Copyright 2009 The Closure Library Authors\n * Copyright 2020 Daniel Wirtz / The long.js Authors.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n *\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// WebAssembly optimizations to do native i64 multiplication and divide\nvar wasm = null;\ntry {\n wasm = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([\n 0, 97, 115, 109, 1, 0, 0, 0, 1, 13, 2, 96, 0, 1, 127, 96, 4, 127, 127, 127, 127, 1, 127, 3, 7, 6, 0, 1, 1, 1, 1, 1, 6, 6, 1, 127, 1, 65, 0, 11, 7, 50, 6, 3, 109, 117, 108, 0, 1, 5, 100, 105, 118, 95, 115, 0, 2, 5, 100, 105, 118, 95, 117, 0, 3, 5, 114, 101, 109, 95, 115, 0, 4, 5, 114, 101, 109, 95, 117, 0, 5, 8, 103, 101, 116, 95, 104, 105, 103, 104, 0, 0, 10, 191, 1, 6, 4, 0, 35, 0, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 126, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 127, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 128, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 129, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11, 36, 1, 1, 126, 32, 0, 173, 32, 1, 173, 66, 32, 134, 132, 32, 2, 173, 32, 3, 173, 66, 32, 134, 132, 130, 34, 4, 66, 32, 135, 167, 36, 0, 32, 4, 167, 11\n ])), {}).exports;\n} catch (e) {\n // no wasm support :(\n}\n\n/**\n * Constructs a 64 bit two's-complement integer, given its low and high 32 bit values as *signed* integers.\n * See the from* functions below for more convenient ways of constructing Longs.\n * @exports Long\n * @class A Long class for representing a 64 bit two's-complement integer value.\n * @param {number} low The low (signed) 32 bits of the long\n * @param {number} high The high (signed) 32 bits of the long\n * @param {boolean=} unsigned Whether unsigned or not, defaults to signed\n * @constructor\n */\nfunction Long(low, high, unsigned) {\n\n /**\n * The low 32 bits as a signed value.\n * @type {number}\n */\n this.low = low | 0;\n\n /**\n * The high 32 bits as a signed value.\n * @type {number}\n */\n this.high = high | 0;\n\n /**\n * Whether unsigned or not.\n * @type {boolean}\n */\n this.unsigned = !!unsigned;\n}\n\n// The internal representation of a long is the two given signed, 32-bit values.\n// We use 32-bit pieces because these are the size of integers on which\n// Javascript performs bit-operations. For operations like addition and\n// multiplication, we split each number into 16 bit pieces, which can easily be\n// multiplied within Javascript's floating-point representation without overflow\n// or change in sign.\n//\n// In the algorithms below, we frequently reduce the negative case to the\n// positive case by negating the input(s) and then post-processing the result.\n// Note that we must ALWAYS check specially whether those values are MIN_VALUE\n// (-2^63) because -MIN_VALUE == MIN_VALUE (since 2^63 cannot be represented as\n// a positive number, it overflows back into a negative). Not handling this\n// case would often result in infinite recursion.\n//\n// Common constant values ZERO, ONE, NEG_ONE, etc. are defined below the from*\n// methods on which they depend.\n\n/**\n * An indicator used to reliably determine if an object is a Long or not.\n * @type {boolean}\n * @const\n * @private\n */\nLong.prototype.__isLong__;\n\nObject.defineProperty(Long.prototype, \"__isLong__\", { value: true });\n\n/**\n * @function\n * @param {*} obj Object\n * @returns {boolean}\n * @inner\n */\nfunction isLong(obj) {\n return (obj && obj[\"__isLong__\"]) === true;\n}\n\n/**\n * @function\n * @param {*} value number\n * @returns {number}\n * @inner\n */\nfunction ctz32(value) {\n var c = Math.clz32(value & -value);\n return value ? 31 - c : c;\n}\n\n/**\n * Tests if the specified object is a Long.\n * @function\n * @param {*} obj Object\n * @returns {boolean}\n */\nLong.isLong = isLong;\n\n/**\n * A cache of the Long representations of small integer values.\n * @type {!Object}\n * @inner\n */\nvar INT_CACHE = {};\n\n/**\n * A cache of the Long representations of small unsigned integer values.\n * @type {!Object}\n * @inner\n */\nvar UINT_CACHE = {};\n\n/**\n * @param {number} value\n * @param {boolean=} unsigned\n * @returns {!Long}\n * @inner\n */\nfunction fromInt(value, unsigned) {\n var obj, cachedObj, cache;\n if (unsigned) {\n value >>>= 0;\n if (cache = (0 <= value && value < 256)) {\n cachedObj = UINT_CACHE[value];\n if (cachedObj)\n return cachedObj;\n }\n obj = fromBits(value, 0, true);\n if (cache)\n UINT_CACHE[value] = obj;\n return obj;\n } else {\n value |= 0;\n if (cache = (-128 <= value && value < 128)) {\n cachedObj = INT_CACHE[value];\n if (cachedObj)\n return cachedObj;\n }\n obj = fromBits(value, value < 0 ? -1 : 0, false);\n if (cache)\n INT_CACHE[value] = obj;\n return obj;\n }\n}\n\n/**\n * Returns a Long representing the given 32 bit integer value.\n * @function\n * @param {number} value The 32 bit integer in question\n * @param {boolean=} unsigned Whether unsigned or not, defaults to signed\n * @returns {!Long} The corresponding Long value\n */\nLong.fromInt = fromInt;\n\n/**\n * @param {number} value\n * @param {boolean=} unsigned\n * @returns {!Long}\n * @inner\n */\nfunction fromNumber(value, unsigned) {\n if (isNaN(value))\n return unsigned ? UZERO : ZERO;\n if (unsigned) {\n if (value < 0)\n return UZERO;\n if (value >= TWO_PWR_64_DBL)\n return MAX_UNSIGNED_VALUE;\n } else {\n if (value <= -TWO_PWR_63_DBL)\n return MIN_VALUE;\n if (value + 1 >= TWO_PWR_63_DBL)\n return MAX_VALUE;\n }\n if (value < 0)\n return fromNumber(-value, unsigned).neg();\n return fromBits((value % TWO_PWR_32_DBL) | 0, (value / TWO_PWR_32_DBL) | 0, unsigned);\n}\n\n/**\n * Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned.\n * @function\n * @param {number} value The number in question\n * @param {boolean=} unsigned Whether unsigned or not, defaults to signed\n * @returns {!Long} The corresponding Long value\n */\nLong.fromNumber = fromNumber;\n\n/**\n * @param {number} lowBits\n * @param {number} highBits\n * @param {boolean=} unsigned\n * @returns {!Long}\n * @inner\n */\nfunction fromBits(lowBits, highBits, unsigned) {\n return new Long(lowBits, highBits, unsigned);\n}\n\n/**\n * Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is\n * assumed to use 32 bits.\n * @function\n * @param {number} lowBits The low 32 bits\n * @param {number} highBits The high 32 bits\n * @param {boolean=} unsigned Whether unsigned or not, defaults to signed\n * @returns {!Long} The corresponding Long value\n */\nLong.fromBits = fromBits;\n\n/**\n * @function\n * @param {number} base\n * @param {number} exponent\n * @returns {number}\n * @inner\n */\nvar pow_dbl = Math.pow; // Used 4 times (4*8 to 15+4)\n\n/**\n * @param {string} str\n * @param {(boolean|number)=} unsigned\n * @param {number=} radix\n * @returns {!Long}\n * @inner\n */\nfunction fromString(str, unsigned, radix) {\n if (str.length === 0)\n throw Error('empty string');\n if (typeof unsigned === 'number') {\n // For goog.math.long compatibility\n radix = unsigned;\n unsigned = false;\n } else {\n unsigned = !!unsigned;\n }\n if (str === \"NaN\" || str === \"Infinity\" || str === \"+Infinity\" || str === \"-Infinity\")\n return unsigned ? UZERO : ZERO;\n radix = radix || 10;\n if (radix < 2 || 36 < radix)\n throw RangeError('radix');\n\n var p;\n if ((p = str.indexOf('-')) > 0)\n throw Error('interior hyphen');\n else if (p === 0) {\n return fromString(str.substring(1), unsigned, radix).neg();\n }\n\n // Do several (8) digits each time through the loop, so as to\n // minimize the calls to the very expensive emulated div.\n var radixToPower = fromNumber(pow_dbl(radix, 8));\n\n var result = ZERO;\n for (var i = 0; i < str.length; i += 8) {\n var size = Math.min(8, str.length - i),\n value = parseInt(str.substring(i, i + size), radix);\n if (size < 8) {\n var power = fromNumber(pow_dbl(radix, size));\n result = result.mul(power).add(fromNumber(value));\n } else {\n result = result.mul(radixToPower);\n result = result.add(fromNumber(value));\n }\n }\n result.unsigned = unsigned;\n return result;\n}\n\n/**\n * Returns a Long representation of the given string, written using the specified radix.\n * @function\n * @param {string} str The textual representation of the Long\n * @param {(boolean|number)=} unsigned Whether unsigned or not, defaults to signed\n * @param {number=} radix The radix in which the text is written (2-36), defaults to 10\n * @returns {!Long} The corresponding Long value\n */\nLong.fromString = fromString;\n\n/**\n * @function\n * @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val\n * @param {boolean=} unsigned\n * @returns {!Long}\n * @inner\n */\nfunction fromValue(val, unsigned) {\n if (typeof val === 'number')\n return fromNumber(val, unsigned);\n if (typeof val === 'string')\n return fromString(val, unsigned);\n // Throws for non-objects, converts non-instanceof Long:\n return fromBits(val.low, val.high, typeof unsigned === 'boolean' ? unsigned : val.unsigned);\n}\n\n/**\n * Converts the specified value to a Long using the appropriate from* function for its type.\n * @function\n * @param {!Long|number|string|!{low: number, high: number, unsigned: boolean}} val Value\n * @param {boolean=} unsigned Whether unsigned or not, defaults to signed\n * @returns {!Long}\n */\nLong.fromValue = fromValue;\n\n// NOTE: the compiler should inline these constant values below and then remove these variables, so there should be\n// no runtime penalty for these.\n\n/**\n * @type {number}\n * @const\n * @inner\n */\nvar TWO_PWR_16_DBL = 1 << 16;\n\n/**\n * @type {number}\n * @const\n * @inner\n */\nvar TWO_PWR_24_DBL = 1 << 24;\n\n/**\n * @type {number}\n * @const\n * @inner\n */\nvar TWO_PWR_32_DBL = TWO_PWR_16_DBL * TWO_PWR_16_DBL;\n\n/**\n * @type {number}\n * @const\n * @inner\n */\nvar TWO_PWR_64_DBL = TWO_PWR_32_DBL * TWO_PWR_32_DBL;\n\n/**\n * @type {number}\n * @const\n * @inner\n */\nvar TWO_PWR_63_DBL = TWO_PWR_64_DBL / 2;\n\n/**\n * @type {!Long}\n * @const\n * @inner\n */\nvar TWO_PWR_24 = fromInt(TWO_PWR_24_DBL);\n\n/**\n * @type {!Long}\n * @inner\n */\nvar ZERO = fromInt(0);\n\n/**\n * Signed zero.\n * @type {!Long}\n */\nLong.ZERO = ZERO;\n\n/**\n * @type {!Long}\n * @inner\n */\nvar UZERO = fromInt(0, true);\n\n/**\n * Unsigned zero.\n * @type {!Long}\n */\nLong.UZERO = UZERO;\n\n/**\n * @type {!Long}\n * @inner\n */\nvar ONE = fromInt(1);\n\n/**\n * Signed one.\n * @type {!Long}\n */\nLong.ONE = ONE;\n\n/**\n * @type {!Long}\n * @inner\n */\nvar UONE = fromInt(1, true);\n\n/**\n * Unsigned one.\n * @type {!Long}\n */\nLong.UONE = UONE;\n\n/**\n * @type {!Long}\n * @inner\n */\nvar NEG_ONE = fromInt(-1);\n\n/**\n * Signed negative one.\n * @type {!Long}\n */\nLong.NEG_ONE = NEG_ONE;\n\n/**\n * @type {!Long}\n * @inner\n */\nvar MAX_VALUE = fromBits(0xFFFFFFFF | 0, 0x7FFFFFFF | 0, false);\n\n/**\n * Maximum signed value.\n * @type {!Long}\n */\nLong.MAX_VALUE = MAX_VALUE;\n\n/**\n * @type {!Long}\n * @inner\n */\nvar MAX_UNSIGNED_VALUE = fromBits(0xFFFFFFFF | 0, 0xFFFFFFFF | 0, true);\n\n/**\n * Maximum unsigned value.\n * @type {!Long}\n */\nLong.MAX_UNSIGNED_VALUE = MAX_UNSIGNED_VALUE;\n\n/**\n * @type {!Long}\n * @inner\n */\nvar MIN_VALUE = fromBits(0, 0x80000000 | 0, false);\n\n/**\n * Minimum signed value.\n * @type {!Long}\n */\nLong.MIN_VALUE = MIN_VALUE;\n\n/**\n * @alias Long.prototype\n * @inner\n */\nvar LongPrototype = Long.prototype;\n\n/**\n * Converts the Long to a 32 bit integer, assuming it is a 32 bit integer.\n * @this {!Long}\n * @returns {number}\n */\nLongPrototype.toInt = function toInt() {\n return this.unsigned ? this.low >>> 0 : this.low;\n};\n\n/**\n * Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa).\n * @this {!Long}\n * @returns {number}\n */\nLongPrototype.toNumber = function toNumber() {\n if (this.unsigned)\n return ((this.high >>> 0) * TWO_PWR_32_DBL) + (this.low >>> 0);\n return this.high * TWO_PWR_32_DBL + (this.low >>> 0);\n};\n\n/**\n * Converts the Long to a string written in the specified radix.\n * @this {!Long}\n * @param {number=} radix Radix (2-36), defaults to 10\n * @returns {string}\n * @override\n * @throws {RangeError} If `radix` is out of range\n */\nLongPrototype.toString = function toString(radix) {\n radix = radix || 10;\n if (radix < 2 || 36 < radix)\n throw RangeError('radix');\n if (this.isZero())\n return '0';\n if (this.isNegative()) { // Unsigned Longs are never negative\n if (this.eq(MIN_VALUE)) {\n // We need to change the Long value before it can be negated, so we remove\n // the bottom-most digit in this base and then recurse to do the rest.\n var radixLong = fromNumber(radix),\n div = this.div(radixLong),\n rem1 = div.mul(radixLong).sub(this);\n return div.toString(radix) + rem1.toInt().toString(radix);\n } else\n return '-' + this.neg().toString(radix);\n }\n\n // Do several (6) digits each time through the loop, so as to\n // minimize the calls to the very expensive emulated div.\n var radixToPower = fromNumber(pow_dbl(radix, 6), this.unsigned),\n rem = this;\n var result = '';\n while (true) {\n var remDiv = rem.div(radixToPower),\n intval = rem.sub(remDiv.mul(radixToPower)).toInt() >>> 0,\n digits = intval.toString(radix);\n rem = remDiv;\n if (rem.isZero())\n return digits + result;\n else {\n while (digits.length < 6)\n digits = '0' + digits;\n result = '' + digits + result;\n }\n }\n};\n\n/**\n * Gets the high 32 bits as a signed integer.\n * @this {!Long}\n * @returns {number} Signed high bits\n */\nLongPrototype.getHighBits = function getHighBits() {\n return this.high;\n};\n\n/**\n * Gets the high 32 bits as an unsigned integer.\n * @this {!Long}\n * @returns {number} Unsigned high bits\n */\nLongPrototype.getHighBitsUnsigned = function getHighBitsUnsigned() {\n return this.high >>> 0;\n};\n\n/**\n * Gets the low 32 bits as a signed integer.\n * @this {!Long}\n * @returns {number} Signed low bits\n */\nLongPrototype.getLowBits = function getLowBits() {\n return this.low;\n};\n\n/**\n * Gets the low 32 bits as an unsigned integer.\n * @this {!Long}\n * @returns {number} Unsigned low bits\n */\nLongPrototype.getLowBitsUnsigned = function getLowBitsUnsigned() {\n return this.low >>> 0;\n};\n\n/**\n * Gets the number of bits needed to represent the absolute value of this Long.\n * @this {!Long}\n * @returns {number}\n */\nLongPrototype.getNumBitsAbs = function getNumBitsAbs() {\n if (this.isNegative()) // Unsigned Longs are never negative\n return this.eq(MIN_VALUE) ? 64 : this.neg().getNumBitsAbs();\n var val = this.high != 0 ? this.high : this.low;\n for (var bit = 31; bit > 0; bit--)\n if ((val & (1 << bit)) != 0)\n break;\n return this.high != 0 ? bit + 33 : bit + 1;\n};\n\n/**\n * Tests if this Long's value equals zero.\n * @this {!Long}\n * @returns {boolean}\n */\nLongPrototype.isZero = function isZero() {\n return this.high === 0 && this.low === 0;\n};\n\n/**\n * Tests if this Long's value equals zero. This is an alias of {@link Long#isZero}.\n * @returns {boolean}\n */\nLongPrototype.eqz = LongPrototype.isZero;\n\n/**\n * Tests if this Long's value is negative.\n * @this {!Long}\n * @returns {boolean}\n */\nLongPrototype.isNegative = function isNegative() {\n return !this.unsigned && this.high < 0;\n};\n\n/**\n * Tests if this Long's value is positive or zero.\n * @this {!Long}\n * @returns {boolean}\n */\nLongPrototype.isPositive = function isPositive() {\n return this.unsigned || this.high >= 0;\n};\n\n/**\n * Tests if this Long's value is odd.\n * @this {!Long}\n * @returns {boolean}\n */\nLongPrototype.isOdd = function isOdd() {\n return (this.low & 1) === 1;\n};\n\n/**\n * Tests if this Long's value is even.\n * @this {!Long}\n * @returns {boolean}\n */\nLongPrototype.isEven = function isEven() {\n return (this.low & 1) === 0;\n};\n\n/**\n * Tests if this Long's value equals the specified's.\n * @this {!Long}\n * @param {!Long|number|string} other Other value\n * @returns {boolean}\n */\nLongPrototype.equals = function equals(other) {\n if (!isLong(other))\n other = fromValue(other);\n if (this.unsigned !== other.unsigned && (this.high >>> 31) === 1 && (other.high >>> 31) === 1)\n return false;\n return this.high === other.high && this.low === other.low;\n};\n\n/**\n * Tests if this Long's value equals the specified's. This is an alias of {@link Long#equals}.\n * @function\n * @param {!Long|number|string} other Other value\n * @returns {boolean}\n */\nLongPrototype.eq = LongPrototype.equals;\n\n/**\n * Tests if this Long's value differs from the specified's.\n * @this {!Long}\n * @param {!Long|number|string} other Other value\n * @returns {boolean}\n */\nLongPrototype.notEquals = function notEquals(other) {\n return !this.eq(/* validates */ other);\n};\n\n/**\n * Tests if this Long's value differs from the specified's. This is an alias of {@link Long#notEquals}.\n * @function\n * @param {!Long|number|string} other Other value\n * @returns {boolean}\n */\nLongPrototype.neq = LongPrototype.notEquals;\n\n/**\n * Tests if this Long's value differs from the specified's. This is an alias of {@link Long#notEquals}.\n * @function\n * @param {!Long|number|string} other Other value\n * @returns {boolean}\n */\nLongPrototype.ne = LongPrototype.notEquals;\n\n/**\n * Tests if this Long's value is less than the specified's.\n * @this {!Long}\n * @param {!Long|number|string} other Other value\n * @returns {boolean}\n */\nLongPrototype.lessThan = function lessThan(other) {\n return this.comp(/* validates */ other) < 0;\n};\n\n/**\n * Tests if this Long's value is less than the specified's. This is an alias of {@link Long#lessThan}.\n * @function\n * @param {!Long|number|string} other Other value\n * @returns {boolean}\n */\nLongPrototype.lt = LongPrototype.lessThan;\n\n/**\n * Tests if this Long's value is less than or equal the specified's.\n * @this {!Long}\n * @param {!Long|number|string} other Other value\n * @returns {boolean}\n */\nLongPrototype.lessThanOrEqual = function lessThanOrEqual(other) {\n return this.comp(/* validates */ other) <= 0;\n};\n\n/**\n * Tests if this Long's value is less than or equal the specified's. This is an alias of {@link Long#lessThanOrEqual}.\n * @function\n * @param {!Long|number|string} other Other value\n * @returns {boolean}\n */\nLongPrototype.lte = LongPrototype.lessThanOrEqual;\n\n/**\n * Tests if this Long's value is less than or equal the specified's. This is an alias of {@link Long#lessThanOrEqual}.\n * @function\n * @param {!Long|number|string} other Other value\n * @returns {boolean}\n */\nLongPrototype.le = LongPrototype.lessThanOrEqual;\n\n/**\n * Tests if this Long's value is greater than the specified's.\n * @this {!Long}\n * @param {!Long|number|string} other Other value\n * @returns {boolean}\n */\nLongPrototype.greaterThan = function greaterThan(other) {\n return this.comp(/* validates */ other) > 0;\n};\n\n/**\n * Tests if this Long's value is greater than the specified's. This is an alias of {@link Long#greaterThan}.\n * @function\n * @param {!Long|number|string} other Other value\n * @returns {boolean}\n */\nLongPrototype.gt = LongPrototype.greaterThan;\n\n/**\n * Tests if this Long's value is greater than or equal the specified's.\n * @this {!Long}\n * @param {!Long|number|string} other Other value\n * @returns {boolean}\n */\nLongPrototype.greaterThanOrEqual = function greaterThanOrEqual(other) {\n return this.comp(/* validates */ other) >= 0;\n};\n\n/**\n * Tests if this Long's value is greater than or equal the specified's. This is an alias of {@link Long#greaterThanOrEqual}.\n * @function\n * @param {!Long|number|string} other Other value\n * @returns {boolean}\n */\nLongPrototype.gte = LongPrototype.greaterThanOrEqual;\n\n/**\n * Tests if this Long's value is greater than or equal the specified's. This is an alias of {@link Long#greaterThanOrEqual}.\n * @function\n * @param {!Long|number|string} other Other value\n * @returns {boolean}\n */\nLongPrototype.ge = LongPrototype.greaterThanOrEqual;\n\n/**\n * Compares this Long's value with the specified's.\n * @this {!Long}\n * @param {!Long|number|string} other Other value\n * @returns {number} 0 if they are the same, 1 if the this is greater and -1\n * if the given one is greater\n */\nLongPrototype.compare = function compare(other) {\n if (!isLong(other))\n other = fromValue(other);\n if (this.eq(other))\n return 0;\n var thisNeg = this.isNegative(),\n otherNeg = other.isNegative();\n if (thisNeg && !otherNeg)\n return -1;\n if (!thisNeg && otherNeg)\n return 1;\n // At this point the sign bits are the same\n if (!this.unsigned)\n return this.sub(other).isNegative() ? -1 : 1;\n // Both are positive if at least one is unsigned\n return (other.high >>> 0) > (this.high >>> 0) || (other.high === this.high && (other.low >>> 0) > (this.low >>> 0)) ? -1 : 1;\n};\n\n/**\n * Compares this Long's value with the specified's. This is an alias of {@link Long#compare}.\n * @function\n * @param {!Long|number|string} other Other value\n * @returns {number} 0 if they are the same, 1 if the this is greater and -1\n * if the given one is greater\n */\nLongPrototype.comp = LongPrototype.compare;\n\n/**\n * Negates this Long's value.\n * @this {!Long}\n * @returns {!Long} Negated Long\n */\nLongPrototype.negate = function negate() {\n if (!this.unsigned && this.eq(MIN_VALUE))\n return MIN_VALUE;\n return this.not().add(ONE);\n};\n\n/**\n * Negates this Long's value. This is an alias of {@link Long#negate}.\n * @function\n * @returns {!Long} Negated Long\n */\nLongPrototype.neg = LongPrototype.negate;\n\n/**\n * Returns the sum of this and the specified Long.\n * @this {!Long}\n * @param {!Long|number|string} addend Addend\n * @returns {!Long} Sum\n */\nLongPrototype.add = function add(addend) {\n if (!isLong(addend))\n addend = fromValue(addend);\n\n // Divide each number into 4 chunks of 16 bits, and then sum the chunks.\n\n var a48 = this.high >>> 16;\n var a32 = this.high & 0xFFFF;\n var a16 = this.low >>> 16;\n var a00 = this.low & 0xFFFF;\n\n var b48 = addend.high >>> 16;\n var b32 = addend.high & 0xFFFF;\n var b16 = addend.low >>> 16;\n var b00 = addend.low & 0xFFFF;\n\n var c48 = 0, c32 = 0, c16 = 0, c00 = 0;\n c00 += a00 + b00;\n c16 += c00 >>> 16;\n c00 &= 0xFFFF;\n c16 += a16 + b16;\n c32 += c16 >>> 16;\n c16 &= 0xFFFF;\n c32 += a32 + b32;\n c48 += c32 >>> 16;\n c32 &= 0xFFFF;\n c48 += a48 + b48;\n c48 &= 0xFFFF;\n return fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);\n};\n\n/**\n * Returns the difference of this and the specified Long.\n * @this {!Long}\n * @param {!Long|number|string} subtrahend Subtrahend\n * @returns {!Long} Difference\n */\nLongPrototype.subtract = function subtract(subtrahend) {\n if (!isLong(subtrahend))\n subtrahend = fromValue(subtrahend);\n return this.add(subtrahend.neg());\n};\n\n/**\n * Returns the difference of this and the specified Long. This is an alias of {@link Long#subtract}.\n * @function\n * @param {!Long|number|string} subtrahend Subtrahend\n * @returns {!Long} Difference\n */\nLongPrototype.sub = LongPrototype.subtract;\n\n/**\n * Returns the product of this and the specified Long.\n * @this {!Long}\n * @param {!Long|number|string} multiplier Multiplier\n * @returns {!Long} Product\n */\nLongPrototype.multiply = function multiply(multiplier) {\n if (this.isZero())\n return this;\n if (!isLong(multiplier))\n multiplier = fromValue(multiplier);\n\n // use wasm support if present\n if (wasm) {\n var low = wasm[\"mul\"](this.low,\n this.high,\n multiplier.low,\n multiplier.high);\n return fromBits(low, wasm[\"get_high\"](), this.unsigned);\n }\n\n if (multiplier.isZero())\n return this.unsigned ? UZERO : ZERO;\n if (this.eq(MIN_VALUE))\n return multiplier.isOdd() ? MIN_VALUE : ZERO;\n if (multiplier.eq(MIN_VALUE))\n return this.isOdd() ? MIN_VALUE : ZERO;\n\n if (this.isNegative()) {\n if (multiplier.isNegative())\n return this.neg().mul(multiplier.neg());\n else\n return this.neg().mul(multiplier).neg();\n } else if (multiplier.isNegative())\n return this.mul(multiplier.neg()).neg();\n\n // If both longs are small, use float multiplication\n if (this.lt(TWO_PWR_24) && multiplier.lt(TWO_PWR_24))\n return fromNumber(this.toNumber() * multiplier.toNumber(), this.unsigned);\n\n // Divide each long into 4 chunks of 16 bits, and then add up 4x4 products.\n // We can skip products that would overflow.\n\n var a48 = this.high >>> 16;\n var a32 = this.high & 0xFFFF;\n var a16 = this.low >>> 16;\n var a00 = this.low & 0xFFFF;\n\n var b48 = multiplier.high >>> 16;\n var b32 = multiplier.high & 0xFFFF;\n var b16 = multiplier.low >>> 16;\n var b00 = multiplier.low & 0xFFFF;\n\n var c48 = 0, c32 = 0, c16 = 0, c00 = 0;\n c00 += a00 * b00;\n c16 += c00 >>> 16;\n c00 &= 0xFFFF;\n c16 += a16 * b00;\n c32 += c16 >>> 16;\n c16 &= 0xFFFF;\n c16 += a00 * b16;\n c32 += c16 >>> 16;\n c16 &= 0xFFFF;\n c32 += a32 * b00;\n c48 += c32 >>> 16;\n c32 &= 0xFFFF;\n c32 += a16 * b16;\n c48 += c32 >>> 16;\n c32 &= 0xFFFF;\n c32 += a00 * b32;\n c48 += c32 >>> 16;\n c32 &= 0xFFFF;\n c48 += a48 * b00 + a32 * b16 + a16 * b32 + a00 * b48;\n c48 &= 0xFFFF;\n return fromBits((c16 << 16) | c00, (c48 << 16) | c32, this.unsigned);\n};\n\n/**\n * Returns the product of this and the specified Long. This is an alias of {@link Long#multiply}.\n * @function\n * @param {!Long|number|string} multiplier Multiplier\n * @returns {!Long} Product\n */\nLongPrototype.mul = LongPrototype.multiply;\n\n/**\n * Returns this Long divided by the specified. The result is signed if this Long is signed or\n * unsigned if this Long is unsigned.\n * @this {!Long}\n * @param {!Long|number|string} divisor Divisor\n * @returns {!Long} Quotient\n */\nLongPrototype.divide = function divide(divisor) {\n if (!isLong(divisor))\n divisor = fromValue(divisor);\n if (divisor.isZero())\n throw Error('division by zero');\n\n // use wasm support if present\n if (wasm) {\n // guard against signed division overflow: the largest\n // negative number / -1 would be 1 larger than the largest\n // positive number, due to two's complement.\n if (!this.unsigned &&\n this.high === -0x80000000 &&\n divisor.low === -1 && divisor.high === -1) {\n // be consistent with non-wasm code path\n return this;\n }\n var low = (this.unsigned ? wasm[\"div_u\"] : wasm[\"div_s\"])(\n this.low,\n this.high,\n divisor.low,\n divisor.high\n );\n return fromBits(low, wasm[\"get_high\"](), this.unsigned);\n }\n\n if (this.isZero())\n return this.unsigned ? UZERO : ZERO;\n var approx, rem, res;\n if (!this.unsigned) {\n // This section is only relevant for signed longs and is derived from the\n // closure library as a whole.\n if (this.eq(MIN_VALUE)) {\n if (divisor.eq(ONE) || divisor.eq(NEG_ONE))\n return MIN_VALUE; // recall that -MIN_VALUE == MIN_VALUE\n else if (divisor.eq(MIN_VALUE))\n return ONE;\n else {\n // At this point, we have |other| >= 2, so |this/other| < |MIN_VALUE|.\n var halfThis = this.shr(1);\n approx = halfThis.div(divisor).shl(1);\n if (approx.eq(ZERO)) {\n return divisor.isNegative() ? ONE : NEG_ONE;\n } else {\n rem = this.sub(divisor.mul(approx));\n res = approx.add(rem.div(divisor));\n return res;\n }\n }\n } else if (divisor.eq(MIN_VALUE))\n return this.unsigned ? UZERO : ZERO;\n if (this.isNegative()) {\n if (divisor.isNegative())\n return this.neg().div(divisor.neg());\n return this.neg().div(divisor).neg();\n } else if (divisor.isNegative())\n return this.div(divisor.neg()).neg();\n res = ZERO;\n } else {\n // The algorithm below has not been made for unsigned longs. It's therefore\n // required to take special care of the MSB prior to running it.\n if (!divisor.unsigned)\n divisor = divisor.toUnsigned();\n if (divisor.gt(this))\n return UZERO;\n if (divisor.gt(this.shru(1))) // 15 >>> 1 = 7 ; with divisor = 8 ; true\n return UONE;\n res = UZERO;\n }\n\n // Repeat the following until the remainder is less than other: find a\n // floating-point that approximates remainder / other *from below*, add this\n // into the result, and subtract it from the remainder. It is critical that\n // the approximate value is less than or equal to the real value so that the\n // remainder never becomes negative.\n rem = this;\n while (rem.gte(divisor)) {\n // Approximate the result of division. This may be a little greater or\n // smaller than the actual value.\n approx = Math.max(1, Math.floor(rem.toNumber() / divisor.toNumber()));\n\n // We will tweak the approximate result by changing it in the 48-th digit or\n // the smallest non-fractional digit, whichever is larger.\n var log2 = Math.ceil(Math.log(approx) / Math.LN2),\n delta = (log2 <= 48) ? 1 : pow_dbl(2, log2 - 48),\n\n // Decrease the approximation until it is smaller than the remainder. Note\n // that if it is too large, the product overflows and is negative.\n approxRes = fromNumber(approx),\n approxRem = approxRes.mul(divisor);\n while (approxRem.isNegative() || approxRem.gt(rem)) {\n approx -= delta;\n approxRes = fromNumber(approx, this.unsigned);\n approxRem = approxRes.mul(divisor);\n }\n\n // We know the answer can't be zero... and actually, zero would cause\n // infinite recursion since we would make no progress.\n if (approxRes.isZero())\n approxRes = ONE;\n\n res = res.add(approxRes);\n rem = rem.sub(approxRem);\n }\n return res;\n};\n\n/**\n * Returns this Long divided by the specified. This is an alias of {@link Long#divide}.\n * @function\n * @param {!Long|number|string} divisor Divisor\n * @returns {!Long} Quotient\n */\nLongPrototype.div = LongPrototype.divide;\n\n/**\n * Returns this Long modulo the specified.\n * @this {!Long}\n * @param {!Long|number|string} divisor Divisor\n * @returns {!Long} Remainder\n */\nLongPrototype.modulo = function modulo(divisor) {\n if (!isLong(divisor))\n divisor = fromValue(divisor);\n\n // use wasm support if present\n if (wasm) {\n var low = (this.unsigned ? wasm[\"rem_u\"] : wasm[\"rem_s\"])(\n this.low,\n this.high,\n divisor.low,\n divisor.high\n );\n return fromBits(low, wasm[\"get_high\"](), this.unsigned);\n }\n\n return this.sub(this.div(divisor).mul(divisor));\n};\n\n/**\n * Returns this Long modulo the specified. This is an alias of {@link Long#modulo}.\n * @function\n * @param {!Long|number|string} divisor Divisor\n * @returns {!Long} Remainder\n */\nLongPrototype.mod = LongPrototype.modulo;\n\n/**\n * Returns this Long modulo the specified. This is an alias of {@link Long#modulo}.\n * @function\n * @param {!Long|number|string} divisor Divisor\n * @returns {!Long} Remainder\n */\nLongPrototype.rem = LongPrototype.modulo;\n\n/**\n * Returns the bitwise NOT of this Long.\n * @this {!Long}\n * @returns {!Long}\n */\nLongPrototype.not = function not() {\n return fromBits(~this.low, ~this.high, this.unsigned);\n};\n\n/**\n * Returns count leading zeros of this Long.\n * @this {!Long}\n * @returns {!number}\n */\nLongPrototype.countLeadingZeros = function countLeadingZeros() {\n return this.high ? Math.clz32(this.high) : Math.clz32(this.low) + 32;\n};\n\n/**\n * Returns count leading zeros. This is an alias of {@link Long#countLeadingZeros}.\n * @function\n * @param {!Long}\n * @returns {!number}\n */\nLongPrototype.clz = LongPrototype.countLeadingZeros;\n\n/**\n * Returns count trailing zeros of this Long.\n * @this {!Long}\n * @returns {!number}\n */\nLongPrototype.countTrailingZeros = function countTrailingZeros() {\n return this.low ? ctz32(this.low) : ctz32(this.high) + 32;\n};\n\n/**\n * Returns count trailing zeros. This is an alias of {@link Long#countTrailingZeros}.\n * @function\n * @param {!Long}\n * @returns {!number}\n */\nLongPrototype.ctz = LongPrototype.countTrailingZeros;\n\n/**\n * Returns the bitwise AND of this Long and the specified.\n * @this {!Long}\n * @param {!Long|number|string} other Other Long\n * @returns {!Long}\n */\nLongPrototype.and = function and(other) {\n if (!isLong(other))\n other = fromValue(other);\n return fromBits(this.low & other.low, this.high & other.high, this.unsigned);\n};\n\n/**\n * Returns the bitwise OR of this Long and the specified.\n * @this {!Long}\n * @param {!Long|number|string} other Other Long\n * @returns {!Long}\n */\nLongPrototype.or = function or(other) {\n if (!isLong(other))\n other = fromValue(other);\n return fromBits(this.low | other.low, this.high | other.high, this.unsigned);\n};\n\n/**\n * Returns the bitwise XOR of this Long and the given one.\n * @this {!Long}\n * @param {!Long|number|string} other Other Long\n * @returns {!Long}\n */\nLongPrototype.xor = function xor(other) {\n if (!isLong(other))\n other = fromValue(other);\n return fromBits(this.low ^ other.low, this.high ^ other.high, this.unsigned);\n};\n\n/**\n * Returns this Long with bits shifted to the left by the given amount.\n * @this {!Long}\n * @param {number|!Long} numBits Number of bits\n * @returns {!Long} Shifted Long\n */\nLongPrototype.shiftLeft = function shiftLeft(numBits) {\n if (isLong(numBits))\n numBits = numBits.toInt();\n if ((numBits &= 63) === 0)\n return this;\n else if (numBits < 32)\n return fromBits(this.low << numBits, (this.high << numBits) | (this.low >>> (32 - numBits)), this.unsigned);\n else\n return fromBits(0, this.low << (numBits - 32), this.unsigned);\n};\n\n/**\n * Returns this Long with bits shifted to the left by the given amount. This is an alias of {@link Long#shiftLeft}.\n * @function\n * @param {number|!Long} numBits Number of bits\n * @returns {!Long} Shifted Long\n */\nLongPrototype.shl = LongPrototype.shiftLeft;\n\n/**\n * Returns this Long with bits arithmetically shifted to the right by the given amount.\n * @this {!Long}\n * @param {number|!Long} numBits Number of bits\n * @returns {!Long} Shifted Long\n */\nLongPrototype.shiftRight = function shiftRight(numBits) {\n if (isLong(numBits))\n numBits = numBits.toInt();\n if ((numBits &= 63) === 0)\n return this;\n else if (numBits < 32)\n return fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >> numBits, this.unsigned);\n else\n return fromBits(this.high >> (numBits - 32), this.high >= 0 ? 0 : -1, this.unsigned);\n};\n\n/**\n * Returns this Long with bits arithmetically shifted to the right by the given amount. This is an alias of {@link Long#shiftRight}.\n * @function\n * @param {number|!Long} numBits Number of bits\n * @returns {!Long} Shifted Long\n */\nLongPrototype.shr = LongPrototype.shiftRight;\n\n/**\n * Returns this Long with bits logically shifted to the right by the given amount.\n * @this {!Long}\n * @param {number|!Long} numBits Number of bits\n * @returns {!Long} Shifted Long\n */\nLongPrototype.shiftRightUnsigned = function shiftRightUnsigned(numBits) {\n if (isLong(numBits)) numBits = numBits.toInt();\n if ((numBits &= 63) === 0) return this;\n if (numBits < 32) return fromBits((this.low >>> numBits) | (this.high << (32 - numBits)), this.high >>> numBits, this.unsigned);\n if (numBits === 32) return fromBits(this.high, 0, this.unsigned);\n return fromBits(this.high >>> (numBits - 32), 0, this.unsigned);\n};\n\n/**\n * Returns this Long with bits logically shifted to the right by the given amount. This is an alias of {@link Long#shiftRightUnsigned}.\n * @function\n * @param {number|!Long} numBits Number of bits\n * @returns {!Long} Shifted Long\n */\nLongPrototype.shru = LongPrototype.shiftRightUnsigned;\n\n/**\n * Returns this Long with bits logically shifted to the right by the given amount. This is an alias of {@link Long#shiftRightUnsigned}.\n * @function\n * @param {number|!Long} numBits Number of bits\n * @returns {!Long} Shifted Long\n */\nLongPrototype.shr_u = LongPrototype.shiftRightUnsigned;\n\n/**\n * Returns this Long with bits rotated to the left by the given amount.\n * @this {!Long}\n * @param {number|!Long} numBits Number of bits\n * @returns {!Long} Rotated Long\n */\nLongPrototype.rotateLeft = function rotateLeft(numBits) {\n var b;\n if (isLong(numBits)) numBits = numBits.toInt();\n if ((numBits &= 63) === 0) return this;\n if (numBits === 32) return fromBits(this.high, this.low, this.unsigned);\n if (numBits < 32) {\n b = (32 - numBits);\n return fromBits(((this.low << numBits) | (this.high >>> b)), ((this.high << numBits) | (this.low >>> b)), this.unsigned);\n }\n numBits -= 32;\n b = (32 - numBits);\n return fromBits(((this.high << numBits) | (this.low >>> b)), ((this.low << numBits) | (this.high >>> b)), this.unsigned);\n}\n/**\n * Returns this Long with bits rotated to the left by the given amount. This is an alias of {@link Long#rotateLeft}.\n * @function\n * @param {number|!Long} numBits Number of bits\n * @returns {!Long} Rotated Long\n */\nLongPrototype.rotl = LongPrototype.rotateLeft;\n\n/**\n * Returns this Long with bits rotated to the right by the given amount.\n * @this {!Long}\n * @param {number|!Long} numBits Number of bits\n * @returns {!Long} Rotated Long\n */\nLongPrototype.rotateRight = function rotateRight(numBits) {\n var b;\n if (isLong(numBits)) numBits = numBits.toInt();\n if ((numBits &= 63) === 0) return this;\n if (numBits === 32) return fromBits(this.high, this.low, this.unsigned);\n if (numBits < 32) {\n b = (32 - numBits);\n return fromBits(((this.high << b) | (this.low >>> numBits)), ((this.low << b) | (this.high >>> numBits)), this.unsigned);\n }\n numBits -= 32;\n b = (32 - numBits);\n return fromBits(((this.low << b) | (this.high >>> numBits)), ((this.high << b) | (this.low >>> numBits)), this.unsigned);\n}\n/**\n * Returns this Long with bits rotated to the right by the given amount. This is an alias of {@link Long#rotateRight}.\n * @function\n * @param {number|!Long} numBits Number of bits\n * @returns {!Long} Rotated Long\n */\nLongPrototype.rotr = LongPrototype.rotateRight;\n\n/**\n * Converts this Long to signed.\n * @this {!Long}\n * @returns {!Long} Signed long\n */\nLongPrototype.toSigned = function toSigned() {\n if (!this.unsigned)\n return this;\n return fromBits(this.low, this.high, false);\n};\n\n/**\n * Converts this Long to unsigned.\n * @this {!Long}\n * @returns {!Long} Unsigned long\n */\nLongPrototype.toUnsigned = function toUnsigned() {\n if (this.unsigned)\n return this;\n return fromBits(this.low, this.high, true);\n};\n\n/**\n * Converts this Long to its byte representation.\n * @param {boolean=} le Whether little or big endian, defaults to big endian\n * @this {!Long}\n * @returns {!Array.<number>} Byte representation\n */\nLongPrototype.toBytes = function toBytes(le) {\n return le ? this.toBytesLE() : this.toBytesBE();\n};\n\n/**\n * Converts this Long to its little endian byte representation.\n * @this {!Long}\n * @returns {!Array.<number>} Little endian byte representation\n */\nLongPrototype.toBytesLE = function toBytesLE() {\n var hi = this.high,\n lo = this.low;\n return [\n lo & 0xff,\n lo >>> 8 & 0xff,\n lo >>> 16 & 0xff,\n lo >>> 24,\n hi & 0xff,\n hi >>> 8 & 0xff,\n hi >>> 16 & 0xff,\n hi >>> 24\n ];\n};\n\n/**\n * Converts this Long to its big endian byte representation.\n * @this {!Long}\n * @returns {!Array.<number>} Big endian byte representation\n */\nLongPrototype.toBytesBE = function toBytesBE() {\n var hi = this.high,\n lo = this.low;\n return [\n hi >>> 24,\n hi >>> 16 & 0xff,\n hi >>> 8 & 0xff,\n hi & 0xff,\n lo >>> 24,\n lo >>> 16 & 0xff,\n lo >>> 8 & 0xff,\n lo & 0xff\n ];\n};\n\n/**\n * Creates a Long from its byte representation.\n * @param {!Array.<number>} bytes Byte representation\n * @param {boolean=} unsigned Whether unsigned or not, defaults to signed\n * @param {boolean=} le Whether little or big endian, defaults to big endian\n * @returns {Long} The corresponding Long value\n */\nLong.fromBytes = function fromBytes(bytes, unsigned, le) {\n return le ? Long.fromBytesLE(bytes, unsigned) : Long.fromBytesBE(bytes, unsigned);\n};\n\n/**\n * Creates a Long from its little endian byte representation.\n * @param {!Array.<number>} bytes Little endian byte representation\n * @param {boolean=} unsigned Whether unsigned or not, defaults to signed\n * @returns {Long} The corresponding Long value\n */\nLong.fromBytesLE = function fromBytesLE(bytes, unsigned) {\n return new Long(\n bytes[0] |\n bytes[1] << 8 |\n bytes[2] << 16 |\n bytes[3] << 24,\n bytes[4] |\n bytes[5] << 8 |\n bytes[6] << 16 |\n bytes[7] << 24,\n unsigned\n );\n};\n\n/**\n * Creates a Long from its big endian byte representation.\n * @param {!Array.<number>} bytes Big endian byte representation\n * @param {boolean=} unsigned Whether unsigned or not, defaults to signed\n * @returns {Long} The corresponding Long value\n */\nLong.fromBytesBE = function fromBytesBE(bytes, unsigned) {\n return new Long(\n bytes[4] << 24 |\n bytes[5] << 16 |\n bytes[6] << 8 |\n bytes[7],\n bytes[0] << 24 |\n bytes[1] << 16 |\n bytes[2] << 8 |\n bytes[3],\n unsigned\n );\n};\n\nexport default Long;\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Long from 'long';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { CRDTElement } from '@yorkie-js-sdk/src/document/crdt/element';\nimport { escapeString } from '@yorkie-js-sdk/src/document/json/strings';\nimport type * as Devtools from '@yorkie-js-sdk/src/devtools/types';\n\nexport enum PrimitiveType {\n Null,\n Boolean,\n Integer,\n Long,\n Double,\n String,\n Bytes,\n Date,\n}\n\n/**\n * `PrimitiveValue` represents a value of primitive type. Only values of type\n * included in `PrimitiveValue` can be set to the document.\n */\nexport type PrimitiveValue =\n // eslint-disable-next-line @typescript-eslint/ban-types\n null | boolean | number | Long | string | Uint8Array | Date;\n\n/**\n * `Primitive` represents primitive data type including logical clock.\n * It has a type and a value.\n */\nexport class Primitive extends CRDTElement {\n private valueType: PrimitiveType;\n private value: PrimitiveValue;\n\n constructor(value: PrimitiveValue, createdAt: TimeTicket) {\n super(createdAt);\n this.valueType = Primitive.getPrimitiveType(value)!;\n this.value = value === undefined ? null : value;\n }\n\n /**\n * `of` creates a new instance of Primitive.\n */\n public static of(value: PrimitiveValue, createdAt: TimeTicket): Primitive {\n return new Primitive(value, createdAt);\n }\n\n /**\n * `valueFromBytes` parses the given bytes into value.\n */\n public static valueFromBytes(\n primitiveType: PrimitiveType,\n bytes: Uint8Array,\n ): PrimitiveValue {\n switch (primitiveType) {\n case PrimitiveType.Null:\n return null;\n case PrimitiveType.Boolean:\n return bytes[0] ? true : false;\n case PrimitiveType.Integer:\n return bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24);\n case PrimitiveType.Double: {\n const view = new DataView(bytes.buffer);\n bytes.forEach(function (b, i) {\n view.setUint8(i, b);\n });\n return view.getFloat64(0, true);\n }\n case PrimitiveType.String:\n return new TextDecoder('utf-8').decode(bytes);\n case PrimitiveType.Long:\n return Long.fromBytesLE(Array.from(bytes));\n case PrimitiveType.Bytes:\n return bytes;\n case PrimitiveType.Date:\n return new Date(Long.fromBytesLE(Array.from(bytes), true).toNumber());\n default:\n throw new YorkieError(\n Code.ErrUnimplemented,\n `unimplemented type: ${primitiveType}`,\n );\n }\n }\n\n /**\n * `toJSON` returns the JSON encoding of the value.\n */\n public toJSON(): string {\n if (this.valueType === PrimitiveType.String) {\n return `\"${escapeString(this.value as string)}\"`;\n }\n\n // TODO(hackerwins): We need to consider the case where the value is\n // a byte array and a date.\n return `${this.value}`;\n }\n\n /**\n * `toSortedJSON` returns the sorted JSON encoding of the value.\n */\n public toSortedJSON(): string {\n return this.toJSON();\n }\n\n /**\n * `toJSForTest` returns value with meta data for testing.\n */\n public toJSForTest(): Devtools.JSONElement {\n return {\n createdAt: this.getCreatedAt().toTestString(),\n value: this.value,\n type: 'YORKIE_PRIMITIVE',\n };\n }\n\n /**\n * `deepcopy` copies itself deeply.\n */\n public deepcopy(): Primitive {\n const primitive = Primitive.of(this.value, this.getCreatedAt());\n primitive.setMovedAt(this.getMovedAt());\n primitive.setRemovedAt(this.getRemovedAt());\n return primitive;\n }\n\n /**\n * `getType` returns the type of the value.\n */\n public getType(): PrimitiveType {\n return this.valueType!;\n }\n\n /**\n * `getPrimitiveType` returns the primitive type of the value.\n */\n public static getPrimitiveType(value: unknown): PrimitiveType | undefined {\n switch (typeof value) {\n case 'undefined':\n return PrimitiveType.Null;\n case 'boolean':\n return PrimitiveType.Boolean;\n case 'number':\n if (this.isInteger(value)) {\n return PrimitiveType.Integer;\n } else {\n return PrimitiveType.Double;\n }\n case 'string':\n return PrimitiveType.String;\n case 'object':\n if (value === null) {\n return PrimitiveType.Null;\n } else if (value instanceof Long) {\n return PrimitiveType.Long;\n } else if (value instanceof Uint8Array) {\n return PrimitiveType.Bytes;\n } else if (value instanceof Date) {\n return PrimitiveType.Date;\n }\n }\n\n return;\n }\n\n /**\n * `isSupport` check if the given value is supported type.\n */\n public static isSupport(value: unknown): boolean {\n const primitiveType = Primitive.getPrimitiveType(value);\n if (primitiveType === undefined) {\n return false;\n }\n return true;\n }\n\n /**\n * `isInteger` checks if the given number is integer.\n */\n public static isInteger(num: number): boolean {\n return num % 1 === 0;\n }\n\n /**\n * `isNumericType` checks numeric type by JSONPrimitive\n */\n public isNumericType(): boolean {\n const t = this.valueType;\n return (\n t === PrimitiveType.Integer ||\n t === PrimitiveType.Long ||\n t === PrimitiveType.Double\n );\n }\n\n /**\n * `getValue` returns the value of Primitive.\n */\n public getValue(): PrimitiveValue {\n return this.value;\n }\n\n /**\n * `toBytes` creates an array representing the value.\n */\n public toBytes(): Uint8Array {\n switch (this.valueType) {\n case PrimitiveType.Null: {\n return new Uint8Array();\n }\n case PrimitiveType.Boolean: {\n const boolVal = this.value as boolean;\n return boolVal ? new Uint8Array([1]) : new Uint8Array([0]);\n }\n case PrimitiveType.Integer: {\n const intVal = this.value as number;\n return new Uint8Array([\n intVal & 0xff,\n (intVal >> 8) & 0xff,\n (intVal >> 16) & 0xff,\n (intVal >> 24) & 0xff,\n ]);\n }\n case PrimitiveType.Double: {\n const doubleVal = this.value as number;\n const uint8Array = new Uint8Array(8);\n const view = new DataView(uint8Array.buffer);\n view.setFloat64(0, doubleVal, true);\n return uint8Array;\n }\n case PrimitiveType.String: {\n return new TextEncoder().encode(this.value as string);\n }\n case PrimitiveType.Long: {\n const longVal = this.value as Long;\n const longToBytes = longVal.toBytesLE();\n return Uint8Array.from(longToBytes);\n }\n case PrimitiveType.Bytes: {\n const bytesVal = this.value as Uint8Array;\n return bytesVal;\n }\n case PrimitiveType.Date: {\n const dateVal = this.value as Date;\n const dateToBytes = Long.fromNumber(\n dateVal.getTime(),\n true,\n ).toBytesLE();\n return Uint8Array.from(dateToBytes);\n }\n default:\n throw new YorkieError(\n Code.ErrUnimplemented,\n `unimplemented type: ${this.valueType}`,\n );\n }\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { SplayNode, SplayTree } from '@yorkie-js-sdk/src/util/splay_tree';\nimport {\n InitialTimeTicket,\n TimeTicket,\n} from '@yorkie-js-sdk/src/document/time/ticket';\nimport { CRDTElement } from '@yorkie-js-sdk/src/document/crdt/element';\nimport { Primitive } from '@yorkie-js-sdk/src/document/crdt/primitive';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\n\n/**\n * `RGATreeListNode` is a node of RGATreeList.\n */\nclass RGATreeListNode extends SplayNode<CRDTElement> {\n private prev?: RGATreeListNode;\n private next?: RGATreeListNode;\n\n constructor(value: CRDTElement) {\n super(value);\n this.value = value;\n }\n\n /**\n * `createAfter` creates a new node after the given node.\n */\n public static createAfter(\n prev: RGATreeListNode,\n value: CRDTElement,\n ): RGATreeListNode {\n const newNode = new RGATreeListNode(value);\n const prevNext = prev.next;\n prev.next = newNode;\n newNode.prev = prev;\n newNode.next = prevNext;\n if (prevNext) {\n prevNext.prev = newNode;\n }\n\n return newNode;\n }\n\n /**\n * `remove` removes value based on removing time.\n */\n public remove(removedAt: TimeTicket): boolean {\n return this.value.remove(removedAt);\n }\n\n /**\n * `getCreatedAt` returns creation time of this value\n */\n public getCreatedAt(): TimeTicket {\n return this.value.getCreatedAt();\n }\n\n /**\n * `getPositionedAt` returns the time of this element when it was positioned\n * in the array.\n */\n public getPositionedAt(): TimeTicket {\n return this.value.getPositionedAt();\n }\n\n /**\n * `release` releases prev and next node.\n */\n public release(): void {\n if (this.prev) {\n this.prev.next = this.next;\n }\n if (this.next) {\n this.next.prev = this.prev;\n }\n this.prev = undefined;\n this.next = undefined;\n }\n\n /**\n * `getLength` returns the length of this node.\n */\n public getLength(): number {\n return this.value.isRemoved() ? 0 : 1;\n }\n\n /**\n * `getPrev` returns a previous node.\n */\n public getPrev(): RGATreeListNode | undefined {\n return this.prev;\n }\n\n /**\n * `getNext` returns a next node.\n */\n public getNext(): RGATreeListNode | undefined {\n return this.next;\n }\n\n /**\n * `getValue` returns a element value.\n */\n public getValue(): CRDTElement {\n return this.value;\n }\n\n /**\n * `isRemoved` checks if the value was removed.\n */\n public isRemoved(): boolean {\n return this.value.isRemoved();\n }\n}\n\n/**\n * `RGATreeList` is a replicated growable array.\n *\n * @internal\n */\nexport class RGATreeList {\n private dummyHead: RGATreeListNode;\n private last: RGATreeListNode;\n private nodeMapByIndex: SplayTree<CRDTElement>;\n private nodeMapByCreatedAt: Map<string, RGATreeListNode>;\n\n constructor() {\n const dummyValue = Primitive.of(0, InitialTimeTicket);\n dummyValue.setRemovedAt(InitialTimeTicket);\n this.dummyHead = new RGATreeListNode(dummyValue);\n this.last = this.dummyHead;\n this.nodeMapByIndex = new SplayTree();\n this.nodeMapByCreatedAt = new Map();\n\n this.nodeMapByIndex.insert(this.dummyHead);\n this.nodeMapByCreatedAt.set(\n this.dummyHead.getCreatedAt().toIDString(),\n this.dummyHead,\n );\n }\n\n /**\n * `create` creates instance of RGATreeList.\n */\n public static create(): RGATreeList {\n return new RGATreeList();\n }\n\n /**\n * `length` returns size of RGATreeList.\n */\n public get length(): number {\n return this.nodeMapByIndex.length;\n }\n\n /**\n * `findNextBeforeExecutedAt` returns the node by the given createdAt and\n * executedAt. It passes through nodes created after executedAt from the\n * given node and returns the next node.\n * @param createdAt - created time\n * @param executedAt - executed time\n * @returns next node\n */\n private findNextBeforeExecutedAt(\n createdAt: TimeTicket,\n executedAt: TimeTicket,\n ): RGATreeListNode {\n let node = this.nodeMapByCreatedAt.get(createdAt.toIDString());\n if (!node) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `cant find the given node: ${createdAt.toIDString()}`,\n );\n }\n\n while (\n node!.getNext() &&\n node!.getNext()!.getPositionedAt().after(executedAt)\n ) {\n node = node!.getNext();\n }\n\n return node!;\n }\n\n private release(node: RGATreeListNode): void {\n if (this.last === node) {\n this.last = node.getPrev()!;\n }\n\n node.release();\n this.nodeMapByIndex.delete(node);\n this.nodeMapByCreatedAt.delete(node.getValue().getCreatedAt().toIDString());\n }\n\n /**\n * `insertAfter` adds a new node with the value after the given node.\n */\n public insertAfter(\n prevCreatedAt: TimeTicket,\n value: CRDTElement,\n executedAt: TimeTicket = value.getCreatedAt(),\n ): void {\n const prevNode = this.findNextBeforeExecutedAt(prevCreatedAt, executedAt);\n const newNode = RGATreeListNode.createAfter(prevNode, value);\n if (prevNode === this.last) {\n this.last = newNode;\n }\n\n this.nodeMapByIndex.insertAfter(prevNode, newNode);\n this.nodeMapByCreatedAt.set(newNode.getCreatedAt().toIDString(), newNode);\n }\n\n /**\n * `moveAfter` moves the given `createdAt` element\n * after the `prevCreatedAt` element.\n */\n public moveAfter(\n prevCreatedAt: TimeTicket,\n createdAt: TimeTicket,\n executedAt: TimeTicket,\n ): void {\n const prevNode = this.nodeMapByCreatedAt.get(prevCreatedAt.toIDString());\n if (!prevNode) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `cant find the given node: ${prevCreatedAt.toIDString()}`,\n );\n }\n\n const node = this.nodeMapByCreatedAt.get(createdAt.toIDString());\n if (!node) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `cant find the given node: ${createdAt.toIDString()}`,\n );\n }\n\n if (\n prevNode !== node &&\n (!node!.getValue().getMovedAt() ||\n executedAt.after(node!.getValue().getMovedAt()!))\n ) {\n this.release(node!);\n this.insertAfter(prevNode!.getCreatedAt(), node!.getValue(), executedAt);\n node!.getValue().setMovedAt(executedAt);\n }\n }\n\n /**\n * `insert` adds the given element after the last node.\n */\n public insert(value: CRDTElement): void {\n this.insertAfter(this.last.getCreatedAt(), value);\n }\n\n /**\n * `getByID` returns the element of the given creation time.\n */\n public getByID(createdAt: TimeTicket): RGATreeListNode | undefined {\n return this.nodeMapByCreatedAt.get(createdAt.toIDString());\n }\n\n /**\n * `subPathOf` returns the sub path of the given element.\n */\n public subPathOf(createdAt: TimeTicket): string | undefined {\n const node = this.nodeMapByCreatedAt.get(createdAt.toIDString());\n if (!node) {\n return;\n }\n return String(this.nodeMapByIndex.indexOf(node));\n }\n\n /**\n * `purge` physically purges element.\n */\n public purge(element: CRDTElement): void {\n const node = this.nodeMapByCreatedAt.get(\n element.getCreatedAt().toIDString(),\n );\n if (!node) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to find the given createdAt: ${element\n .getCreatedAt()\n .toIDString()}`,\n );\n }\n this.release(node!);\n }\n\n /**\n * `getByIndex` returns node of the given index.\n */\n public getByIndex(idx: number): RGATreeListNode | undefined {\n if (idx >= this.length) {\n return;\n }\n\n const [node, offset] = this.nodeMapByIndex.find(idx);\n let rgaNode = node as RGATreeListNode | undefined;\n\n if ((idx === 0 && node === this.dummyHead) || offset > 0) {\n do {\n if (rgaNode) {\n rgaNode = rgaNode.getNext();\n }\n } while (rgaNode && rgaNode.isRemoved());\n }\n\n return rgaNode;\n }\n\n /**\n * `getPrevCreatedAt` returns a creation time of the previous node.\n */\n public getPrevCreatedAt(createdAt: TimeTicket): TimeTicket {\n let node = this.nodeMapByCreatedAt.get(createdAt.toIDString());\n do {\n node = node!.getPrev()!;\n } while (this.dummyHead !== node && node.isRemoved());\n return node.getValue().getCreatedAt();\n }\n\n /**\n * `delete` deletes the node of the given creation time.\n */\n public delete(createdAt: TimeTicket, editedAt: TimeTicket): CRDTElement {\n const node = this.nodeMapByCreatedAt.get(createdAt.toIDString());\n const alreadyRemoved = node!.isRemoved();\n if (node!.remove(editedAt) && !alreadyRemoved) {\n this.nodeMapByIndex.splayNode(node);\n }\n return node!.getValue();\n }\n\n /**\n * `deleteByIndex` deletes the node of the given index.\n */\n public deleteByIndex(\n index: number,\n editedAt: TimeTicket,\n ): CRDTElement | undefined {\n const node = this.getByIndex(index);\n if (!node) {\n return;\n }\n\n if (node.remove(editedAt)) {\n this.nodeMapByIndex.splayNode(node);\n }\n return node.getValue();\n }\n\n /**\n * `getHead` returns the value of head elements.\n */\n public getHead(): CRDTElement {\n return this.dummyHead.getValue();\n }\n\n /**\n * `getLast` returns the value of last elements.\n */\n public getLast(): CRDTElement {\n return this.last.getValue();\n }\n\n /**\n * `getLastCreatedAt` returns the creation time of last element.\n */\n public getLastCreatedAt(): TimeTicket {\n return this.last.getCreatedAt();\n }\n\n /**\n * `toTestString` returns a String containing the meta data of the node id\n * for debugging purpose.\n */\n public toTestString(): string {\n const json = [];\n\n for (const node of this) {\n const elem = `${node.getCreatedAt().toIDString()}:${node\n .getValue()\n .toJSON()}`;\n if (node.isRemoved()) {\n json.push(`{${elem}}`);\n } else {\n json.push(`[${elem}]`);\n }\n }\n\n return json.join('');\n }\n\n // eslint-disable-next-line jsdoc/require-jsdoc\n public *[Symbol.iterator](): IterableIterator<RGATreeListNode> {\n let node = this.dummyHead.getNext();\n while (node) {\n yield node;\n node = node.getNext();\n }\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport {\n CRDTContainer,\n CRDTElement,\n} from '@yorkie-js-sdk/src/document/crdt/element';\nimport { RGATreeList } from '@yorkie-js-sdk/src/document/crdt/rga_tree_list';\nimport * as Devtools from '@yorkie-js-sdk/src/devtools/types';\n\n/**\n * `CRDTArray` represents an array data type containing `CRDTElement`s.\n *\n * @internal\n */\nexport class CRDTArray extends CRDTContainer {\n private elements: RGATreeList;\n\n constructor(createdAt: TimeTicket, elements: RGATreeList) {\n super(createdAt);\n this.elements = elements;\n }\n\n /**\n * `create` creates a new instance of Array.\n */\n public static create(\n createdAt: TimeTicket,\n value?: Array<CRDTElement>,\n ): CRDTArray {\n if (!value) {\n return new CRDTArray(createdAt, RGATreeList.create());\n }\n\n const elements = RGATreeList.create();\n for (const v of value) {\n elements.insertAfter(elements.getLastCreatedAt(), v.deepcopy());\n }\n return new CRDTArray(createdAt, elements);\n }\n\n /**\n * `subPathOf` returns the sub path of the given element.\n */\n public subPathOf(createdAt: TimeTicket): string | undefined {\n return this.elements.subPathOf(createdAt);\n }\n\n /**\n * `purge` physically purge the given element.\n */\n public purge(element: CRDTElement): void {\n this.elements.purge(element);\n }\n\n /**\n * `insertAfter` adds a new node after the the given node.\n */\n public insertAfter(prevCreatedAt: TimeTicket, value: CRDTElement): void {\n this.elements.insertAfter(prevCreatedAt, value);\n }\n\n /**\n * `moveAfter` moves the given `createdAt` element after the `prevCreatedAt`.\n */\n public moveAfter(\n prevCreatedAt: TimeTicket,\n createdAt: TimeTicket,\n executedAt: TimeTicket,\n ): void {\n this.elements.moveAfter(prevCreatedAt, createdAt, executedAt);\n }\n\n /**\n * `get` returns the element of the given index.\n */\n public get(index: number): CRDTElement | undefined {\n const node = this.elements.getByIndex(index);\n return node?.getValue();\n }\n\n /**\n * `getByID` returns the element of the given createAt.\n */\n public getByID(createdAt: TimeTicket): CRDTElement | undefined {\n const node = this.elements.getByID(createdAt);\n return node?.getValue();\n }\n\n /**\n * `getHead` returns dummy head element.\n */\n public getHead(): CRDTElement {\n return this.elements.getHead();\n }\n\n /**\n * `getLast` returns last element.\n */\n public getLast(): CRDTElement {\n return this.elements.getLast();\n }\n\n /**\n * `getPrevCreatedAt` returns the creation time of the previous node.\n */\n public getPrevCreatedAt(createdAt: TimeTicket): TimeTicket {\n return this.elements.getPrevCreatedAt(createdAt);\n }\n\n /**\n * `delete` deletes the element of the given creation time.\n */\n public delete(createdAt: TimeTicket, editedAt: TimeTicket): CRDTElement {\n return this.elements.delete(createdAt, editedAt);\n }\n\n /**\n * `deleteByIndex` deletes the element of given index and editedAt.\n */\n public deleteByIndex(\n index: number,\n editedAt: TimeTicket,\n ): CRDTElement | undefined {\n return this.elements.deleteByIndex(index, editedAt);\n }\n\n /**\n * `getLastCreatedAt` get last created element.\n */\n public getLastCreatedAt(): TimeTicket {\n return this.elements.getLastCreatedAt();\n }\n\n /**\n * `length` returns length of this elements.\n */\n public get length(): number {\n return this.elements.length;\n }\n\n /**\n * eslint-disable-next-line jsdoc/require-jsdoc\n * @internal\n */\n public *[Symbol.iterator](): IterableIterator<CRDTElement> {\n for (const node of this.elements) {\n if (!node.isRemoved()) {\n yield node.getValue();\n }\n }\n }\n\n /**\n * `toTestString` returns a String containing the meta data of this value\n * for debugging purpose.\n */\n public toTestString(): string {\n return this.elements.toTestString();\n }\n\n /**\n * `getDescendants` traverse the descendants of this array.\n */\n public getDescendants(\n callback: (elem: CRDTElement, parent: CRDTContainer) => boolean,\n ): void {\n for (const node of this.elements) {\n const element = node.getValue();\n if (callback(element, this)) {\n return;\n }\n\n if (element instanceof CRDTContainer) {\n element.getDescendants(callback);\n }\n }\n }\n\n /**\n * `toJSON` returns the JSON encoding of this array.\n */\n public toJSON(): string {\n const json = [];\n for (const value of this) {\n json.push(value.toJSON());\n }\n return `[${json.join(',')}]`;\n }\n\n /**\n * `toJS` return the javascript object of this array.\n */\n public toJS(): any {\n return JSON.parse(this.toJSON());\n }\n\n /**\n * `toJSForTest` returns value with meta data for testing.\n */\n public toJSForTest(): Devtools.JSONElement {\n const values: Devtools.ContainerValue = {};\n for (let i = 0; i < this.length; i++) {\n const { createdAt, value, type } = this.get(i)!.toJSForTest();\n values[i] = {\n key: String(i),\n createdAt,\n value,\n type,\n };\n }\n return {\n createdAt: this.getCreatedAt().toTestString(),\n value: values,\n type: 'YORKIE_ARRAY',\n };\n }\n\n /**\n * `toSortedJSON` returns the sorted JSON encoding of this array.\n */\n public toSortedJSON(): string {\n return this.toJSON();\n }\n\n /**\n * `getElements` returns an array of elements contained in this RGATreeList.\n */\n public getElements(): RGATreeList {\n return this.elements;\n }\n\n /**\n * `deepcopy` copies itself deeply.\n */\n public deepcopy(): CRDTArray {\n const clone = CRDTArray.create(this.getCreatedAt());\n for (const node of this.elements) {\n clone.elements.insertAfter(\n clone.getLastCreatedAt(),\n node.getValue().deepcopy(),\n );\n }\n clone.remove(this.getRemovedAt());\n return clone;\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { CRDTRoot } from '@yorkie-js-sdk/src/document/crdt/root';\nimport {\n OpSource,\n Operation,\n OperationInfo,\n ExecutionResult,\n} from '@yorkie-js-sdk/src/document/operation/operation';\nimport {\n CRDTContainer,\n CRDTElement,\n} from '@yorkie-js-sdk/src/document/crdt/element';\nimport { CRDTObject } from '@yorkie-js-sdk/src/document/crdt/object';\nimport { CRDTArray } from '@yorkie-js-sdk/src/document/crdt/array';\nimport { SetOperation } from '@yorkie-js-sdk/src/document/operation/set_operation';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\n\n/**\n * `RemoveOperation` is an operation that removes an element from `CRDTContainer`.\n */\nexport class RemoveOperation extends Operation {\n private createdAt: TimeTicket;\n\n constructor(\n parentCreatedAt: TimeTicket,\n createdAt: TimeTicket,\n executedAt?: TimeTicket,\n ) {\n super(parentCreatedAt, executedAt);\n this.createdAt = createdAt;\n }\n\n /**\n * `create` creates a new instance of RemoveOperation.\n */\n public static create(\n parentCreatedAt: TimeTicket,\n createdAt: TimeTicket,\n executedAt?: TimeTicket,\n ): RemoveOperation {\n return new RemoveOperation(parentCreatedAt, createdAt, executedAt);\n }\n\n /**\n * `execute` executes this operation on the given `CRDTRoot`.\n */\n public execute(\n root: CRDTRoot,\n source: OpSource,\n ): ExecutionResult | undefined {\n const container = root.findByCreatedAt(\n this.getParentCreatedAt(),\n ) as CRDTContainer;\n if (!container) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to find ${this.getParentCreatedAt()}`,\n );\n }\n if (!(container instanceof CRDTContainer)) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `only object and array can execute remove: ${container}`,\n );\n }\n\n // NOTE(chacha912): Handle cases where operation cannot be executed during undo and redo.\n if (source === OpSource.UndoRedo) {\n let parent: CRDTElement | undefined = container.getByID(this.createdAt);\n while (parent) {\n if (parent.getRemovedAt()) {\n return;\n }\n parent = root.findElementPairByCreatedAt(parent.getCreatedAt())?.parent;\n }\n }\n const key = container.subPathOf(this.createdAt);\n const reverseOp = this.toReverseOperation(container);\n\n const elem = container.delete(this.createdAt, this.getExecutedAt());\n root.registerRemovedElement(elem);\n\n const opInfos: Array<OperationInfo> =\n container instanceof CRDTArray\n ? [\n {\n type: 'remove',\n path: root.createPath(this.getParentCreatedAt()),\n index: Number(key),\n },\n ]\n : [\n {\n type: 'remove',\n path: root.createPath(this.getParentCreatedAt()),\n key,\n },\n ];\n\n return { opInfos, reverseOp };\n }\n\n /**\n * `toReverseOperation` returns the reverse operation of this operation.\n */\n private toReverseOperation(\n parentObject: CRDTContainer,\n ): Operation | undefined {\n // TODO(Hyemmie): consider CRDTArray\n if (parentObject instanceof CRDTObject) {\n const key = parentObject.subPathOf(this.createdAt);\n if (key !== undefined) {\n const value = parentObject.get(key);\n if (value !== undefined) {\n return SetOperation.create(\n key,\n value.deepcopy(),\n this.getParentCreatedAt(),\n );\n }\n }\n }\n }\n\n /**\n * `getEffectedCreatedAt` returns the creation time of the effected element.\n */\n public getEffectedCreatedAt(): TimeTicket {\n return this.getParentCreatedAt();\n }\n\n /**\n * `toTestString` returns a string containing the meta data.\n */\n public toTestString(): string {\n return `${this.getParentCreatedAt().toTestString()}.REMOVE.${this.createdAt.toTestString()}`;\n }\n\n /**\n * `getCreatedAt` returns the creation time of the target element.\n */\n public getCreatedAt(): TimeTicket {\n return this.createdAt;\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { CRDTElement } from '@yorkie-js-sdk/src/document/crdt/element';\nimport { CRDTRoot } from '@yorkie-js-sdk/src/document/crdt/root';\nimport { CRDTObject } from '@yorkie-js-sdk/src/document/crdt/object';\nimport {\n OpSource,\n Operation,\n ExecutionResult,\n} from '@yorkie-js-sdk/src/document/operation/operation';\nimport { RemoveOperation } from '@yorkie-js-sdk/src/document/operation/remove_operation';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\n\n/**\n * `SetOperation` represents an operation that stores the value corresponding to the\n * given key in the Object.\n */\nexport class SetOperation extends Operation {\n private key: string;\n private value: CRDTElement;\n\n constructor(\n key: string,\n value: CRDTElement,\n parentCreatedAt: TimeTicket,\n executedAt?: TimeTicket,\n ) {\n super(parentCreatedAt, executedAt);\n this.key = key;\n this.value = value;\n }\n\n /**\n * `create` creates a new instance of SetOperation.\n */\n public static create(\n key: string,\n value: CRDTElement,\n parentCreatedAt: TimeTicket,\n executedAt?: TimeTicket,\n ): SetOperation {\n return new SetOperation(key, value, parentCreatedAt, executedAt);\n }\n\n /**\n * `execute` executes this operation on the given `CRDTRoot`.\n */\n public execute(\n root: CRDTRoot,\n source: OpSource,\n ): ExecutionResult | undefined {\n const obj = root.findByCreatedAt(this.getParentCreatedAt()) as CRDTObject;\n if (!obj) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to find ${this.getParentCreatedAt()}`,\n );\n }\n if (!(obj instanceof CRDTObject)) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to execute, only object can execute set`,\n );\n }\n\n // NOTE(chacha912): Handle cases where operation cannot be executed during undo and redo.\n if (source === OpSource.UndoRedo) {\n let parent: CRDTElement | undefined = obj;\n while (parent) {\n if (parent.getRemovedAt()) {\n return;\n }\n parent = root.findElementPairByCreatedAt(parent.getCreatedAt())?.parent;\n }\n }\n const previousValue = obj.get(this.key);\n const reverseOp = this.toReverseOperation(previousValue);\n\n const value = this.value.deepcopy();\n const removed = obj.set(this.key, value, this.getExecutedAt());\n // NOTE(chacha912): When resetting elements with the pre-existing createdAt\n // during undo/redo, it's essential to handle previously tombstoned elements.\n // In non-GC languages, there may be a need to execute both deregister and purge.\n if (\n source === OpSource.UndoRedo &&\n root.findByCreatedAt(value.getCreatedAt())\n ) {\n root.deregisterElement(value);\n }\n root.registerElement(value, obj);\n if (removed) {\n root.registerRemovedElement(removed);\n }\n\n return {\n opInfos: [\n {\n type: 'set',\n path: root.createPath(this.getParentCreatedAt()),\n key: this.key,\n },\n ],\n reverseOp,\n };\n }\n\n /**\n * `toReverseOperation` returns the reverse operation of this operation.\n */\n private toReverseOperation(value: CRDTElement | undefined): Operation {\n let reverseOp: SetOperation | RemoveOperation = RemoveOperation.create(\n this.getParentCreatedAt(),\n this.value.getCreatedAt(),\n );\n\n if (value !== undefined && !value.isRemoved()) {\n reverseOp = SetOperation.create(\n this.key,\n value.deepcopy(),\n this.getParentCreatedAt(),\n );\n }\n return reverseOp;\n }\n\n /**\n * `getEffectedCreatedAt` returns the creation time of the effected element.\n */\n public getEffectedCreatedAt(): TimeTicket {\n return this.value.getCreatedAt();\n }\n\n /**\n * `toTestString` returns a string containing the meta data.\n */\n public toTestString(): string {\n return `${this.getParentCreatedAt().toTestString()}.SET.${\n this.key\n }=${this.value.toSortedJSON()}`;\n }\n\n /**\n * `getKey` returns the key of this operation.\n */\n public getKey(): string {\n return this.key;\n }\n\n /**\n * `getValue` returns the value of this operation.\n */\n public getValue(): CRDTElement {\n return this.value;\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { CRDTElement } from '@yorkie-js-sdk/src/document/crdt/element';\nimport { CRDTRoot } from '@yorkie-js-sdk/src/document/crdt/root';\nimport { CRDTArray } from '@yorkie-js-sdk/src/document/crdt/array';\nimport {\n Operation,\n ExecutionResult,\n} from '@yorkie-js-sdk/src/document/operation/operation';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\n\n/**\n * `AddOperation` is an operation representing adding an element to an Array.\n */\nexport class AddOperation extends Operation {\n private prevCreatedAt: TimeTicket;\n private value: CRDTElement;\n\n constructor(\n parentCreatedAt: TimeTicket,\n prevCreatedAt: TimeTicket,\n value: CRDTElement,\n executedAt: TimeTicket,\n ) {\n super(parentCreatedAt, executedAt);\n this.prevCreatedAt = prevCreatedAt;\n this.value = value;\n }\n\n /**\n * `create` creates a new instance of AddOperation.\n */\n public static create(\n parentCreatedAt: TimeTicket,\n prevCreatedAt: TimeTicket,\n value: CRDTElement,\n executedAt: TimeTicket,\n ): AddOperation {\n return new AddOperation(parentCreatedAt, prevCreatedAt, value, executedAt);\n }\n\n /**\n * `execute` executes this operation on the given `CRDTRoot`.\n */\n public execute(root: CRDTRoot): ExecutionResult {\n const parentObject = root.findByCreatedAt(this.getParentCreatedAt());\n if (!parentObject) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to find ${this.getParentCreatedAt()}`,\n );\n }\n if (!(parentObject instanceof CRDTArray)) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to execute, only array can execute add`,\n );\n }\n const array = parentObject as CRDTArray;\n const value = this.value.deepcopy();\n array.insertAfter(this.prevCreatedAt, value);\n root.registerElement(value, array);\n\n return {\n opInfos: [\n {\n type: 'add',\n path: root.createPath(this.getParentCreatedAt()),\n index: Number(array.subPathOf(this.getEffectedCreatedAt())),\n },\n ],\n };\n }\n\n /**\n * `getEffectedCreatedAt` returns the creation time of the effected element.\n */\n public getEffectedCreatedAt(): TimeTicket {\n return this.value.getCreatedAt();\n }\n\n /**\n * `toTestString` returns a string containing the meta data.\n */\n public toTestString(): string {\n return `${this.getParentCreatedAt().toTestString()}.ADD.${this.value.toJSON()}`;\n }\n\n /**\n * `getPrevCreatedAt` returns the creation time of previous element.\n */\n public getPrevCreatedAt(): TimeTicket {\n return this.prevCreatedAt;\n }\n\n /**\n * `getValue` returns the value of this operation.\n */\n public getValue(): CRDTElement {\n return this.value;\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { CRDTRoot } from '@yorkie-js-sdk/src/document/crdt/root';\nimport { CRDTArray } from '@yorkie-js-sdk/src/document/crdt/array';\nimport {\n Operation,\n ExecutionResult,\n} from '@yorkie-js-sdk/src/document/operation/operation';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\n\n/**\n * `MoveOperation` is an operation representing moving an element to an Array.\n */\nexport class MoveOperation extends Operation {\n private prevCreatedAt: TimeTicket;\n private createdAt: TimeTicket;\n\n constructor(\n parentCreatedAt: TimeTicket,\n prevCreatedAt: TimeTicket,\n createdAt: TimeTicket,\n executedAt: TimeTicket,\n ) {\n super(parentCreatedAt, executedAt);\n this.prevCreatedAt = prevCreatedAt;\n this.createdAt = createdAt;\n }\n\n /**\n * `create` creates a new instance of MoveOperation.\n */\n public static create(\n parentCreatedAt: TimeTicket,\n prevCreatedAt: TimeTicket,\n createdAt: TimeTicket,\n executedAt: TimeTicket,\n ): MoveOperation {\n return new MoveOperation(\n parentCreatedAt,\n prevCreatedAt,\n createdAt,\n executedAt,\n );\n }\n\n /**\n * `execute` executes this operation on the given `CRDTRoot`.\n */\n public execute(root: CRDTRoot): ExecutionResult {\n const parentObject = root.findByCreatedAt(this.getParentCreatedAt());\n if (!parentObject) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to find ${this.getParentCreatedAt()}`,\n );\n }\n if (!(parentObject instanceof CRDTArray)) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to execute, only array can execute move`,\n );\n }\n const array = parentObject as CRDTArray;\n const previousIndex = Number(array.subPathOf(this.createdAt));\n array.moveAfter(this.prevCreatedAt, this.createdAt, this.getExecutedAt());\n const index = Number(array.subPathOf(this.createdAt));\n return {\n opInfos: [\n {\n type: 'move',\n path: root.createPath(this.getParentCreatedAt()),\n index,\n previousIndex,\n },\n ],\n };\n }\n\n /**\n * `getEffectedCreatedAt` returns the creation time of the effected element.\n */\n public getEffectedCreatedAt(): TimeTicket {\n return this.createdAt;\n }\n\n /**\n * `toTestString` returns a string containing the meta data.\n */\n public toTestString(): string {\n return `${this.getParentCreatedAt().toTestString()}.MOVE`;\n }\n\n /**\n * `getPrevCreatedAt` returns the creation time of previous element.\n */\n public getPrevCreatedAt(): TimeTicket {\n return this.prevCreatedAt;\n }\n\n /**\n * `getCreatedAt` returns the creation time of the target element.\n */\n public getCreatedAt(): TimeTicket {\n return this.createdAt;\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { escapeString } from '@yorkie-js-sdk/src/document/json/strings';\nimport { GCChild } from '@yorkie-js-sdk/src/document/crdt/gc';\n\n/**\n * `RHTNode` is a node of RHT(Replicated Hashtable).\n */\nexport class RHTNode implements GCChild {\n private key: string;\n private value: string;\n private updatedAt: TimeTicket;\n private _isRemoved: boolean;\n\n constructor(\n key: string,\n value: string,\n updatedAt: TimeTicket,\n isRemoved: boolean,\n ) {\n this.key = key;\n this.value = value;\n this.updatedAt = updatedAt;\n this._isRemoved = isRemoved;\n }\n\n /**\n * `of` creates a new instance of RHTNode.\n */\n public static of(\n key: string,\n value: string,\n createdAt: TimeTicket,\n isRemoved: boolean,\n ): RHTNode {\n return new RHTNode(key, value, createdAt, isRemoved);\n }\n\n /**\n * `getKey` returns a key of node.\n */\n public getKey(): string {\n return this.key;\n }\n\n /**\n * `getValue` returns a value of node.\n */\n public getValue(): string {\n return this.value;\n }\n\n /**\n * `getUpdatedAt` returns updated time of node.\n */\n public getUpdatedAt(): TimeTicket {\n return this.updatedAt;\n }\n\n /**\n * `isRemoved` returns whether the node has been removed or not.\n */\n public isRemoved(): boolean {\n return this._isRemoved;\n }\n\n /**\n * `toIDString` returns the IDString of this node.\n */\n public toIDString(): string {\n return `${this.updatedAt.toIDString()}:${this.key}`;\n }\n\n /**\n * `getRemovedAt` returns the time when this node was removed.\n */\n public getRemovedAt(): TimeTicket | undefined {\n if (this._isRemoved) {\n return this.updatedAt;\n }\n\n return undefined;\n }\n}\n\n/**\n * RHT is replicated hash table by creation time.\n * For more details about RHT: @see http://csl.skku.edu/papers/jpdc11.pdf\n */\nexport class RHT {\n private nodeMapByKey: Map<string, RHTNode>;\n private numberOfRemovedElement: number;\n\n constructor() {\n this.nodeMapByKey = new Map();\n this.numberOfRemovedElement = 0;\n }\n\n /**\n * `create` creates a new instance of RHT.\n */\n public static create(): RHT {\n return new RHT();\n }\n\n /**\n * `getNodeMapByKey` returns the hashtable of RHT.\n */\n public getNodeMapByKey(): Map<string, RHTNode> {\n return this.nodeMapByKey;\n }\n\n /**\n * `set` sets the value of the given key.\n */\n public set(\n key: string,\n value: string,\n executedAt: TimeTicket,\n ): [RHTNode | undefined, RHTNode | undefined] {\n const prev = this.nodeMapByKey.get(key);\n\n if (prev && prev.isRemoved() && executedAt.after(prev.getUpdatedAt())) {\n this.numberOfRemovedElement -= 1;\n }\n\n if (prev === undefined || executedAt.after(prev.getUpdatedAt())) {\n const node = RHTNode.of(key, value, executedAt, false);\n this.nodeMapByKey.set(key, node);\n\n if (prev !== undefined && prev.isRemoved()) {\n return [prev, node];\n }\n return [undefined, node];\n }\n\n if (prev.isRemoved()) {\n return [prev, undefined];\n }\n\n return [undefined, undefined];\n }\n\n /**\n * SetInternal sets the value of the given key internally.\n */\n public setInternal(\n key: string,\n value: string,\n executedAt: TimeTicket,\n removed: boolean,\n ) {\n const node = RHTNode.of(key, value, executedAt, removed);\n this.nodeMapByKey.set(key, node);\n\n if (removed) {\n this.numberOfRemovedElement++;\n }\n }\n\n /**\n * `remove` removes the Element of the given key.\n */\n public remove(key: string, executedAt: TimeTicket): Array<RHTNode> {\n const prev = this.nodeMapByKey.get(key);\n\n const gcNodes: Array<RHTNode> = [];\n if (prev === undefined || executedAt.after(prev.getUpdatedAt())) {\n if (prev === undefined) {\n this.numberOfRemovedElement += 1;\n const node = RHTNode.of(key, '', executedAt, true);\n this.nodeMapByKey.set(key, node);\n\n gcNodes.push(node);\n return gcNodes;\n }\n\n const alreadyRemoved = prev.isRemoved();\n if (!alreadyRemoved) {\n this.numberOfRemovedElement += 1;\n }\n\n if (alreadyRemoved) {\n gcNodes.push(prev);\n }\n\n const node = RHTNode.of(key, prev.getValue(), executedAt, true);\n this.nodeMapByKey.set(key, node);\n gcNodes.push(node);\n\n return gcNodes;\n }\n\n return gcNodes;\n }\n\n /**\n * `has` returns whether the element exists of the given key or not.\n */\n public has(key: string): boolean {\n if (this.nodeMapByKey.has(key)) {\n const node = this.nodeMapByKey.get(key);\n return node !== undefined && !node.isRemoved();\n }\n return false;\n }\n\n /**\n * `get` returns the value of the given key.\n */\n public get(key: string): string | undefined {\n if (!this.nodeMapByKey.has(key)) {\n return;\n }\n\n return this.nodeMapByKey.get(key)!.getValue();\n }\n\n /**\n * `deepcopy` copies itself deeply.\n */\n public deepcopy(): RHT {\n const rht = new RHT();\n for (const [, node] of this.nodeMapByKey) {\n rht.setInternal(\n node.getKey(),\n node.getValue(),\n node.getUpdatedAt(),\n node.isRemoved(),\n );\n }\n return rht;\n }\n\n /**\n * `toJSON` returns the JSON encoding of this hashtable.\n */\n public toJSON(): string {\n if (!this.size()) {\n return '{}';\n }\n\n const items = [];\n for (const [key, node] of this.nodeMapByKey) {\n if (!node.isRemoved()) {\n items.push(`\"${escapeString(key)}\":\"${escapeString(node.getValue())}\"`);\n }\n }\n return `{${items.join(',')}}`;\n }\n\n /**\n * `size` returns the size of RHT\n */\n public size(): number {\n return this.nodeMapByKey.size - this.numberOfRemovedElement;\n }\n\n /**\n * `toObject` returns the object of this hashtable.\n */\n public toObject(): Record<string, string> {\n const obj: Record<string, string> = {};\n for (const [key, node] of this.nodeMapByKey) {\n if (!node.isRemoved()) {\n obj[key] = node.getValue();\n }\n }\n\n return obj;\n }\n\n // eslint-disable-next-line jsdoc/require-jsdoc\n public *[Symbol.iterator](): IterableIterator<RHTNode> {\n for (const [, node] of this.nodeMapByKey) {\n yield node as RHTNode;\n }\n }\n\n /**\n * `purge` purges the given child node.\n */\n public purge(child: RHTNode) {\n const node = this.nodeMapByKey.get(child.getKey());\n if (node == undefined || node.toIDString() != child.toIDString()) {\n // TODO(hackerwins): Should we return an error when the child is not found?\n return;\n }\n\n this.nodeMapByKey.delete(child.getKey());\n this.numberOfRemovedElement--;\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n MaxLamport,\n InitialTimeTicket,\n TimeTicket,\n} from '@yorkie-js-sdk/src/document/time/ticket';\nimport { VersionVector } from '@yorkie-js-sdk/src/document/time/version_vector';\nimport { Indexable } from '@yorkie-js-sdk/src/document/document';\nimport { RHT, RHTNode } from '@yorkie-js-sdk/src/document/crdt/rht';\nimport { CRDTElement } from '@yorkie-js-sdk/src/document/crdt/element';\nimport {\n RGATreeSplit,\n RGATreeSplitNode,\n RGATreeSplitNodeID,\n RGATreeSplitPosRange,\n ValueChange,\n} from '@yorkie-js-sdk/src/document/crdt/rga_tree_split';\nimport { escapeString } from '@yorkie-js-sdk/src/document/json/strings';\nimport { parseObjectValues } from '@yorkie-js-sdk/src/util/object';\nimport type * as Devtools from '@yorkie-js-sdk/src/devtools/types';\nimport { GCChild, GCPair } from '@yorkie-js-sdk/src/document/crdt/gc';\nimport { SplayTree } from '@yorkie-js-sdk/src/util/splay_tree';\nimport { LLRBTree } from '@yorkie-js-sdk/src/util/llrb_tree';\n\n/**\n * `TextChangeType` is the type of TextChange.\n *\n */\nenum TextChangeType {\n Content = 'content',\n Style = 'style',\n}\n\n/**\n * `TextValueType` is a value of Text\n * which has a attributes that expresses the text style.\n */\nexport interface TextValueType<A> {\n attributes?: A;\n content?: string;\n}\n\n/**\n * `TextChange` represents the changes to the text\n * when executing the edit, setstyle methods.\n */\ninterface TextChange<A = Indexable> extends ValueChange<TextValueType<A>> {\n type: TextChangeType;\n}\n\n/**\n * `CRDTTextValue` is a value of Text\n * which has a attributes that expresses the text style.\n * Attributes are represented by RHT.\n *\n */\nexport class CRDTTextValue {\n private attributes: RHT;\n private content: string;\n\n constructor(content: string) {\n this.attributes = RHT.create();\n this.content = content;\n }\n\n /**\n * `create` creates a instance of CRDTTextValue.\n */\n public static create(content: string): CRDTTextValue {\n return new CRDTTextValue(content);\n }\n\n /**\n * `length` returns the length of value.\n */\n public get length(): number {\n return this.content.length;\n }\n\n /**\n * `substring` returns a sub-string value of the given range.\n */\n public substring(indexStart: number, indexEnd: number): CRDTTextValue {\n const value = new CRDTTextValue(\n this.content.substring(indexStart, indexEnd),\n );\n value.attributes = this.attributes.deepcopy();\n return value;\n }\n\n /**\n * `setAttr` sets attribute of the given key, updated time and value.\n */\n public setAttr(\n key: string,\n content: string,\n updatedAt: TimeTicket,\n ): [RHTNode | undefined, RHTNode | undefined] {\n return this.attributes.set(key, content, updatedAt);\n }\n\n /**\n * `getAttr` returns the attributes of this value.\n */\n public getAttrs(): RHT {\n return this.attributes;\n }\n\n /**\n * `toString` returns the string representation of this value.\n */\n public toString(): string {\n return this.content;\n }\n\n /**\n * `toJSON` returns the JSON encoding of this value.\n */\n public toJSON(): string {\n const content = escapeString(this.content);\n const attrsObj = this.attributes.toObject();\n const attrs = [];\n for (const [key, v] of Object.entries(attrsObj)) {\n const value = JSON.parse(v);\n const item =\n typeof value === 'string'\n ? `\"${escapeString(key)}\":\"${escapeString(value)}\"`\n : `\"${escapeString(key)}\":${String(value)}`;\n attrs.push(item);\n }\n attrs.sort();\n if (attrs.length === 0) {\n return `{\"val\":\"${content}\"}`;\n }\n return `{\"attrs\":{${attrs.join(',')}},\"val\":\"${content}\"}`;\n }\n\n /**\n * `getAttributes` returns the attributes of this value.\n */\n public getAttributes(): Record<string, string> {\n return this.attributes.toObject();\n }\n\n /**\n * `getContent` returns the internal content.\n */\n public getContent(): string {\n return this.content;\n }\n\n /**\n * `purge` purges the given child node.\n */\n public purge(node: GCChild): void {\n if (this.attributes && node instanceof RHTNode) {\n this.attributes.purge(node);\n }\n }\n\n /**\n * `getGCPairs` returns the pairs of GC.\n */\n public getGCPairs(): Array<GCPair> {\n const pairs = [];\n\n for (const node of this.attributes) {\n if (node.getRemovedAt()) {\n pairs.push({ parent: this, child: node });\n }\n }\n\n return pairs;\n }\n}\n\n/**\n * `CRDTText` is a custom CRDT data type to represent the contents of text editors.\n *\n */\nexport class CRDTText<A extends Indexable = Indexable> extends CRDTElement {\n private rgaTreeSplit: RGATreeSplit<CRDTTextValue>;\n\n constructor(\n rgaTreeSplit: RGATreeSplit<CRDTTextValue>,\n createdAt: TimeTicket,\n ) {\n super(createdAt);\n this.rgaTreeSplit = rgaTreeSplit;\n }\n\n /**\n * `create` a instance of Text.\n */\n public static create<A extends Indexable>(\n rgaTreeSplit: RGATreeSplit<CRDTTextValue>,\n createdAt: TimeTicket,\n ): CRDTText<A> {\n return new CRDTText<A>(rgaTreeSplit, createdAt);\n }\n\n /**\n * `edit` edits the given range with the given value and attributes.\n *\n * @internal\n */\n public edit(\n range: RGATreeSplitPosRange,\n content: string,\n editedAt: TimeTicket,\n attributes?: Record<string, string>,\n maxCreatedAtMapByActor?: Map<string, TimeTicket>,\n versionVector?: VersionVector,\n ): [\n Map<string, TimeTicket>,\n Array<TextChange<A>>,\n Array<GCPair>,\n RGATreeSplitPosRange,\n ] {\n const crdtTextValue = content ? CRDTTextValue.create(content) : undefined;\n if (crdtTextValue && attributes) {\n for (const [k, v] of Object.entries(attributes)) {\n crdtTextValue.setAttr(k, v, editedAt);\n }\n }\n\n const [caretPos, maxCreatedAtMap, pairs, valueChanges] =\n this.rgaTreeSplit.edit(\n range,\n editedAt,\n crdtTextValue,\n maxCreatedAtMapByActor,\n versionVector,\n );\n\n const changes: Array<TextChange<A>> = valueChanges.map((change) => ({\n ...change,\n value: change.value\n ? {\n attributes: parseObjectValues<A>(change.value.getAttributes()),\n content: change.value.getContent(),\n }\n : {\n attributes: undefined,\n content: '',\n },\n type: TextChangeType.Content,\n }));\n\n return [maxCreatedAtMap, changes, pairs, [caretPos, caretPos]];\n }\n\n /**\n * `setStyle` applies the style of the given range.\n * 01. split nodes with from and to\n * 02. style nodes between from and to\n *\n * @param range - range of RGATreeSplitNode\n * @param attributes - style attributes\n * @param editedAt - edited time\n * @param maxCreatedAtMapByActor - maxCreatedAtMapByActor\n * @internal\n */\n public setStyle(\n range: RGATreeSplitPosRange,\n attributes: Record<string, string>,\n editedAt: TimeTicket,\n maxCreatedAtMapByActor?: Map<string, TimeTicket>,\n versionVector?: VersionVector,\n ): [Map<string, TimeTicket>, Array<GCPair>, Array<TextChange<A>>] {\n // 01. split nodes with from and to\n const [, toRight] = this.rgaTreeSplit.findNodeWithSplit(range[1], editedAt);\n const [, fromRight] = this.rgaTreeSplit.findNodeWithSplit(\n range[0],\n editedAt,\n );\n\n // 02. style nodes between from and to\n const changes: Array<TextChange<A>> = [];\n const nodes = this.rgaTreeSplit.findBetween(fromRight, toRight);\n const createdAtMapByActor = new Map<string, TimeTicket>();\n const toBeStyleds: Array<RGATreeSplitNode<CRDTTextValue>> = [];\n\n for (const node of nodes) {\n const actorID = node.getCreatedAt().getActorID();\n let maxCreatedAt: TimeTicket | undefined;\n let clientLamportAtChange = 0n;\n if (versionVector === undefined && maxCreatedAtMapByActor === undefined) {\n // Local edit - use version vector comparison\n clientLamportAtChange = MaxLamport;\n } else if (versionVector!.size() > 0) {\n clientLamportAtChange = versionVector!.get(actorID)\n ? versionVector!.get(actorID)!\n : 0n;\n } else {\n maxCreatedAt = maxCreatedAtMapByActor!.has(actorID)\n ? maxCreatedAtMapByActor!.get(actorID)\n : InitialTimeTicket;\n }\n\n if (node.canStyle(editedAt, maxCreatedAt, clientLamportAtChange)) {\n const maxCreatedAt = createdAtMapByActor.get(actorID);\n const createdAt = node.getCreatedAt();\n if (!maxCreatedAt || createdAt.after(maxCreatedAt)) {\n createdAtMapByActor.set(actorID, createdAt);\n }\n toBeStyleds.push(node);\n }\n }\n\n const pairs: Array<GCPair> = [];\n for (const node of toBeStyleds) {\n if (node.isRemoved()) {\n continue;\n }\n\n const [fromIdx, toIdx] = this.rgaTreeSplit.findIndexesFromRange(\n node.createPosRange(),\n );\n changes.push({\n type: TextChangeType.Style,\n actor: editedAt.getActorID(),\n from: fromIdx,\n to: toIdx,\n value: {\n attributes: parseObjectValues(attributes) as A,\n },\n });\n\n for (const [key, value] of Object.entries(attributes)) {\n const [prev] = node.getValue().setAttr(key, value, editedAt);\n if (prev !== undefined) {\n pairs.push({ parent: node.getValue(), child: prev });\n }\n }\n }\n\n return [createdAtMapByActor, pairs, changes];\n }\n\n /**\n * `indexRangeToPosRange` returns the position range of the given index range.\n */\n public indexRangeToPosRange(\n fromIdx: number,\n toIdx: number,\n ): RGATreeSplitPosRange {\n const fromPos = this.rgaTreeSplit.indexToPos(fromIdx);\n if (fromIdx === toIdx) {\n return [fromPos, fromPos];\n }\n\n return [fromPos, this.rgaTreeSplit.indexToPos(toIdx)];\n }\n\n /**\n * `length` returns size of RGATreeList.\n */\n public get length(): number {\n return this.rgaTreeSplit.length;\n }\n\n /**\n * `getTreeByIndex` returns the tree by index for debugging.\n */\n public getTreeByIndex(): SplayTree<CRDTTextValue> {\n return this.rgaTreeSplit.getTreeByIndex();\n }\n\n /**\n * `getTreeByID` returns the tree by ID for debugging.\n */\n public getTreeByID(): LLRBTree<\n RGATreeSplitNodeID,\n RGATreeSplitNode<CRDTTextValue>\n > {\n return this.rgaTreeSplit.getTreeByID();\n }\n\n /**\n * `toJSON` returns the JSON encoding of this text.\n */\n public toJSON(): string {\n const json = [];\n\n for (const node of this.rgaTreeSplit) {\n if (!node.isRemoved()) {\n json.push(node.getValue().toJSON());\n }\n }\n\n return `[${json.join(',')}]`;\n }\n\n /**\n * `toSortedJSON` returns the sorted JSON encoding of this text.\n */\n public toSortedJSON(): string {\n return this.toJSON();\n }\n\n /**\n * `toJSForTest` returns value with meta data for testing.\n */\n public toJSForTest(): Devtools.JSONElement {\n return {\n createdAt: this.getCreatedAt().toTestString(),\n value: JSON.parse(this.toJSON()),\n type: 'YORKIE_TEXT',\n };\n }\n\n /**\n * `toString` returns the string representation of this text.\n */\n public toString(): string {\n return this.rgaTreeSplit.toString();\n }\n\n /**\n * `values` returns the content-attributes pair array of this text.\n */\n public values(): Array<TextValueType<A>> {\n const values = [];\n\n for (const node of this.rgaTreeSplit) {\n if (!node.isRemoved()) {\n const value = node.getValue();\n values.push({\n attributes: parseObjectValues<A>(value.getAttributes()),\n content: value.getContent(),\n });\n }\n }\n\n return values;\n }\n\n /**\n * `getRGATreeSplit` returns rgaTreeSplit.\n *\n * @internal\n */\n public getRGATreeSplit(): RGATreeSplit<CRDTTextValue> {\n return this.rgaTreeSplit;\n }\n\n /**\n * `toTestString` returns a String containing the meta data of this value\n * for debugging purpose.\n */\n public toTestString(): string {\n return this.rgaTreeSplit.toTestString();\n }\n\n /**\n * `deepcopy` copies itself deeply.\n */\n public deepcopy(): CRDTText<A> {\n const text = new CRDTText<A>(\n this.rgaTreeSplit.deepcopy(),\n this.getCreatedAt(),\n );\n text.remove(this.getRemovedAt());\n return text;\n }\n\n /**\n * `findIndexesFromRange` returns pair of integer offsets of the given range.\n */\n public findIndexesFromRange(range: RGATreeSplitPosRange): [number, number] {\n return this.rgaTreeSplit.findIndexesFromRange(range);\n }\n\n /**\n * `getGCPairs` returns the pairs of GC.\n */\n public getGCPairs(): Array<GCPair> {\n const pairs = [];\n for (const node of this.rgaTreeSplit) {\n if (node.getRemovedAt()) {\n pairs.push({ parent: this.rgaTreeSplit, child: node });\n }\n\n for (const p of node.getValue().getGCPairs()) {\n pairs.push(p);\n }\n }\n\n return pairs;\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { VersionVector } from '@yorkie-js-sdk/src/document/time/version_vector';\nimport { CRDTRoot } from '@yorkie-js-sdk/src/document/crdt/root';\nimport { RGATreeSplitPos } from '@yorkie-js-sdk/src/document/crdt/rga_tree_split';\nimport { CRDTText } from '@yorkie-js-sdk/src/document/crdt/text';\nimport {\n Operation,\n OperationInfo,\n ExecutionResult,\n OpSource,\n} from '@yorkie-js-sdk/src/document/operation/operation';\nimport { Indexable } from '../document';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\n\n/**\n * `EditOperation` is an operation representing editing Text. Most of the same as\n * Edit, but with additional style properties, attributes.\n */\nexport class EditOperation extends Operation {\n private fromPos: RGATreeSplitPos;\n private toPos: RGATreeSplitPos;\n private maxCreatedAtMapByActor: Map<string, TimeTicket>;\n private content: string;\n private attributes: Map<string, string>;\n\n constructor(\n parentCreatedAt: TimeTicket,\n fromPos: RGATreeSplitPos,\n toPos: RGATreeSplitPos,\n maxCreatedAtMapByActor: Map<string, TimeTicket>,\n content: string,\n attributes: Map<string, string>,\n executedAt: TimeTicket,\n ) {\n super(parentCreatedAt, executedAt);\n this.fromPos = fromPos;\n this.toPos = toPos;\n this.maxCreatedAtMapByActor = maxCreatedAtMapByActor;\n this.content = content;\n this.attributes = attributes;\n }\n\n /**\n * `create` creates a new instance of EditOperation.\n */\n public static create(\n parentCreatedAt: TimeTicket,\n fromPos: RGATreeSplitPos,\n toPos: RGATreeSplitPos,\n maxCreatedAtMapByActor: Map<string, TimeTicket>,\n content: string,\n attributes: Map<string, string>,\n executedAt: TimeTicket,\n ): EditOperation {\n return new EditOperation(\n parentCreatedAt,\n fromPos,\n toPos,\n maxCreatedAtMapByActor,\n content,\n attributes,\n executedAt,\n );\n }\n\n /**\n * `execute` executes this operation on the given `CRDTRoot`.\n */\n public execute<A extends Indexable>(\n root: CRDTRoot,\n _: OpSource,\n versionVector?: VersionVector,\n ): ExecutionResult {\n const parentObject = root.findByCreatedAt(this.getParentCreatedAt());\n if (!parentObject) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to find ${this.getParentCreatedAt()}`,\n );\n }\n if (!(parentObject instanceof CRDTText)) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to execute, only Text can execute edit`,\n );\n }\n\n const text = parentObject as CRDTText<A>;\n const [, changes, pairs] = text.edit(\n [this.fromPos, this.toPos],\n this.content,\n this.getExecutedAt(),\n Object.fromEntries(this.attributes),\n this.maxCreatedAtMapByActor,\n versionVector,\n );\n\n for (const pair of pairs) {\n root.registerGCPair(pair);\n }\n\n return {\n opInfos: changes.map(({ from, to, value }) => {\n return {\n type: 'edit',\n from,\n to,\n value,\n path: root.createPath(this.getParentCreatedAt()),\n } as OperationInfo;\n }),\n };\n }\n\n /**\n * `getEffectedCreatedAt` returns the creation time of the effected element.\n */\n public getEffectedCreatedAt(): TimeTicket {\n return this.getParentCreatedAt();\n }\n\n /**\n * `toTestString` returns a string containing the meta data.\n */\n public toTestString(): string {\n const parent = this.getParentCreatedAt().toTestString();\n const fromPos = this.fromPos.toTestString();\n const toPos = this.toPos.toTestString();\n const content = this.content;\n return `${parent}.EDIT(${fromPos},${toPos},${content})`;\n }\n\n /**\n * `getFromPos` returns the start point of the editing range.\n */\n public getFromPos(): RGATreeSplitPos {\n return this.fromPos;\n }\n\n /**\n * `getToPos` returns the end point of the editing range.\n */\n public getToPos(): RGATreeSplitPos {\n return this.toPos;\n }\n\n /**\n * `getContent` returns the content of Edit.\n */\n public getContent(): string {\n return this.content;\n }\n\n /**\n * `getAttributes` returns the attributes of this Edit.\n */\n public getAttributes(): Map<string, string> {\n return this.attributes || new Map();\n }\n\n /**\n * `getMaxCreatedAtMapByActor` returns the map that stores the latest creation time\n * by actor for the nodes included in the editing range.\n */\n public getMaxCreatedAtMapByActor(): Map<string, TimeTicket> {\n return this.maxCreatedAtMapByActor;\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { VersionVector } from '@yorkie-js-sdk/src/document/time/version_vector';\nimport { CRDTRoot } from '@yorkie-js-sdk/src/document/crdt/root';\nimport { RGATreeSplitPos } from '@yorkie-js-sdk/src/document/crdt/rga_tree_split';\nimport { CRDTText } from '@yorkie-js-sdk/src/document/crdt/text';\nimport {\n Operation,\n OperationInfo,\n ExecutionResult,\n OpSource,\n} from '@yorkie-js-sdk/src/document/operation/operation';\nimport { Indexable } from '../document';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\n\n/**\n * `StyleOperation` is an operation applies the style of the given range to Text.\n */\nexport class StyleOperation extends Operation {\n private fromPos: RGATreeSplitPos;\n private toPos: RGATreeSplitPos;\n private maxCreatedAtMapByActor: Map<string, TimeTicket>;\n private attributes: Map<string, string>;\n\n constructor(\n parentCreatedAt: TimeTicket,\n fromPos: RGATreeSplitPos,\n toPos: RGATreeSplitPos,\n maxCreatedAtMapByActor: Map<string, TimeTicket>,\n attributes: Map<string, string>,\n executedAt: TimeTicket,\n ) {\n super(parentCreatedAt, executedAt);\n this.fromPos = fromPos;\n this.toPos = toPos;\n this.maxCreatedAtMapByActor = maxCreatedAtMapByActor;\n this.attributes = attributes;\n }\n\n /**\n * `create` creates a new instance of StyleOperation.\n */\n public static create(\n parentCreatedAt: TimeTicket,\n fromPos: RGATreeSplitPos,\n toPos: RGATreeSplitPos,\n maxCreatedAtMapByActor: Map<string, TimeTicket>,\n attributes: Map<string, string>,\n executedAt: TimeTicket,\n ): StyleOperation {\n return new StyleOperation(\n parentCreatedAt,\n fromPos,\n toPos,\n maxCreatedAtMapByActor,\n attributes,\n executedAt,\n );\n }\n\n /**\n * `execute` executes this operation on the given `CRDTRoot`.\n */\n public execute<A extends Indexable>(\n root: CRDTRoot,\n _: OpSource,\n versionVector?: VersionVector,\n ): ExecutionResult {\n const parentObject = root.findByCreatedAt(this.getParentCreatedAt());\n if (!parentObject) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to find ${this.getParentCreatedAt()}`,\n );\n }\n if (!(parentObject instanceof CRDTText)) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to execute, only Text can execute edit`,\n );\n }\n const text = parentObject as CRDTText<A>;\n const [, pairs, changes] = text.setStyle(\n [this.fromPos, this.toPos],\n this.attributes ? Object.fromEntries(this.attributes) : {},\n this.getExecutedAt(),\n this.maxCreatedAtMapByActor,\n versionVector,\n );\n\n for (const pair of pairs) {\n root.registerGCPair(pair);\n }\n\n return {\n opInfos: changes.map(({ from, to, value }) => {\n return {\n type: 'style',\n from,\n to,\n value,\n path: root.createPath(this.getParentCreatedAt()),\n } as OperationInfo;\n }),\n };\n }\n\n /**\n * `getEffectedCreatedAt` returns the creation time of the effected element.\n */\n public getEffectedCreatedAt(): TimeTicket {\n return this.getParentCreatedAt();\n }\n\n /**\n * `toTestString` returns a string containing the meta data.\n */\n public toTestString(): string {\n const parent = this.getParentCreatedAt().toTestString();\n const fromPos = this.fromPos.toTestString();\n const toPos = this.toPos.toTestString();\n const attributes = this.attributes;\n return `${parent}.STYL(${fromPos},${toPos},${JSON.stringify(attributes)})`;\n }\n\n /**\n * `getFromPos` returns the start point of the editing range.\n */\n public getFromPos(): RGATreeSplitPos {\n return this.fromPos;\n }\n\n /**\n * `getToPos` returns the end point of the editing range.\n */\n public getToPos(): RGATreeSplitPos {\n return this.toPos;\n }\n\n /**\n * `getAttributes` returns the attributes of this operation.\n */\n public getAttributes(): Map<string, string> {\n return this.attributes;\n }\n\n /**\n * `getMaxCreatedAtMapByActor` returns the map that stores the latest creation time\n * by actor for the nodes included in the editing range.\n */\n public getMaxCreatedAtMapByActor(): Map<string, TimeTicket> {\n return this.maxCreatedAtMapByActor;\n }\n}\n","/*\n * Copyright 2023 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TimeTicket } from '../yorkie';\nimport { Code, YorkieError } from './error';\n\n/**\n * About `index`, `path`, `size` and `TreePos` in crdt.IndexTree.\n *\n * `index` of crdt.IndexTree represents a absolute position of a node in the tree.\n * `size` is used to calculate the relative index of nodes in the tree.\n * `index` in yorkie.IndexTree inspired by ProseMirror's index.\n *\n * For example, empty paragraph's size is 0 and index 0 is the position of the:\n * 0\n * <p> </p>, p.size = 0\n *\n * If a paragraph has <i>, its size becomes 2 and there are 3 indexes:\n * 0 1 2\n * <p> <i> </i> </p> p.size = 2, i.size = 0\n *\n * If the paragraph has <i> and <b>, its size becomes 4:\n * 0 1 2 3 4\n * <p> <i> </i> <b> </b> </p> p.size = 4, i.size = 0, b.size = 0\n * 0 1 2 3 4 5 6\n * <p> <i> </i> <b> </b> <s> </s> </p> p.size = 6, i.size = 0, b.size = 0, s.size = 0\n *\n * If a paragraph has text, its size becomes length of the characters:\n * 0 1 2 3\n * <p> A B C </p> p.size = 3, text.size = 3\n *\n * So the size of a node is the sum of the size and type of its children:\n * `size = children(element type).length * 2 + children.reduce((child, acc) => child.size + acc, 0)`\n *\n * `TreePos` is also used to represent the position in the tree. It contains node and offset.\n * `TreePos` can be converted to `index` and vice versa.\n *\n * For example, if a paragraph has <i>, there are 3 indexes:\n * 0 1 2\n * <p> <i> </i> </p> p.size = 2, i.size = 0\n *\n * In this case, index of TreePos(p, 0) is 0, index of TreePos(p, 1) is 2.\n * Index 1 can be converted to TreePos(i, 0).\n *\n * `path` of crdt.IndexTree represents a position like `index` in crdt.IndexTree.\n * It contains offsets of each node from the root node as elements except the last.\n * The last element of the path represents the position in the parent node.\n *\n * Let's say we have a tree like this:\n * 0 1 2\n * <p> <i> a b </i> <b> c d </b> </p>\n *\n * The path of the position between 'c' and 'd' is [1, 1]. The first element of the\n * path is the offset of the <b> in <p> and the second element represents the position\n * between 'c' and 'd' in <b>.\n */\n\n/**\n * `ElementPaddingSize` is the size of an element node as a child of another element node.\n * Because an element node could be considered as a pair of open and close tags.\n */\nexport const ElementPaddingSize = 2;\n\n/**\n * `DefaultRootType` is the default type of the root node.\n * It is used when the type of the root node is not specified.\n */\nexport const DefaultRootType = 'root';\n\n/**\n * `DefaultTextType` is the default type of the text node.\n * It is used when the type of the text node is not specified.\n */\nexport const DefaultTextType = 'text';\n\n/**\n * `NoteType` is the type of a node in the tree.\n */\nexport type TreeNodeType = string;\n\n/**\n * `addSizeOfLeftSiblings` returns the size of left siblings of the given offset.\n */\nexport function addSizeOfLeftSiblings<T extends IndexTreeNode<T>>(\n parent: T,\n offset: number,\n): number {\n let acc = 0;\n const siblings = parent.children;\n\n for (let i = 0; i < offset; i++) {\n const leftSibling = siblings[i];\n\n if (!leftSibling || leftSibling.isRemoved) {\n continue;\n }\n\n acc += leftSibling.paddedSize;\n }\n\n return acc;\n}\n\n/**\n * `IndexTreeNode` is the node of IndexTree. It is used to represent the\n * document of text-based editors.\n */\nexport abstract class IndexTreeNode<T extends IndexTreeNode<T>> {\n type: TreeNodeType;\n parent?: T;\n _children: Array<T>;\n size: number;\n\n constructor(type: TreeNodeType, children: Array<T> = []) {\n this.type = type;\n this.size = 0;\n this._children = children;\n\n if (this.isText && this._children.length > 0) {\n throw new YorkieError(Code.ErrRefused, 'Text node cannot have children');\n }\n }\n\n /**\n * `updateAncestorsSize` updates the size of the ancestors. It is used when\n * the size of the node is changed.\n */\n updateAncestorsSize(): void {\n let parent: T | undefined = this.parent;\n const sign = this.isRemoved ? -1 : 1;\n\n while (parent) {\n parent.size += this.paddedSize * sign;\n if (parent.isRemoved) {\n break;\n }\n\n parent = parent.parent;\n }\n }\n\n /**\n * `updateDescendantsSize` updates the size of the descendants. It is used when\n * the tree is newly created and the size of the descendants is not calculated.\n */\n updateDescendantsSize(): number {\n let size = 0;\n for (const child of this._children) {\n const childSize = child.updateDescendantsSize();\n if (child.isRemoved) {\n continue;\n }\n\n size += childSize;\n }\n\n this.size += size;\n\n return this.paddedSize;\n }\n\n /**\n * `isText` returns true if the node is a text node.\n */\n get isText(): boolean {\n // TODO(hackerwins): We need to get the type of text node from user.\n // Consider the use schema to get the type of text node.\n return this.type === DefaultTextType;\n }\n\n /**\n * `paddedSize` returns the size of the node including padding size.\n */\n get paddedSize(): number {\n return this.size + (this.isText ? 0 : ElementPaddingSize);\n }\n\n /**\n * `isAncenstorOf` returns true if the node is an ancestor of the given node.\n */\n isAncestorOf(node: T): boolean {\n return ancestorOf(this as any, node);\n }\n\n /**\n * `nextSibling` returns the next sibling of the node.\n */\n get nextSibling(): T | undefined {\n const offset = this.parent!.findOffset(this as any);\n const sibling = this.parent!.children[offset + 1];\n if (sibling) {\n return sibling;\n }\n\n return undefined;\n }\n\n /**\n * `prevSibling` returns the previous sibling of the node.\n */\n get prevSibling(): T | undefined {\n const offset = this.parent!.findOffset(this as any);\n const sibling = this.parent!.children[offset - 1];\n if (sibling) {\n return sibling;\n }\n\n return undefined;\n }\n\n /**\n * `isRemoved` returns true if the node is removed.\n */\n abstract get isRemoved(): boolean;\n\n /**\n * `cloneText` clones the text node with the given id and value.\n */\n abstract cloneText(offset: number): T;\n\n /**\n * `cloneElement` clones the element node with the given issueTimeTicket\n * function and value.\n */\n abstract cloneElement(issueTimeTicket: () => TimeTicket): T;\n\n /**\n * `value` returns the value of the node.\n */\n abstract get value();\n\n /**\n * `value` sets the value of the node.\n */\n abstract set value(v: string);\n\n /**\n * `splitText` splits the given node at the given offset.\n */\n splitText(offset: number, absOffset: number): T | undefined {\n if (offset === 0 || offset === this.size) {\n return;\n }\n\n const leftValue = this.value.slice(0, offset);\n const rightValue = this.value.slice(offset);\n\n if (!rightValue.length) {\n return;\n }\n\n this.value = leftValue;\n\n const rightNode = this.cloneText(offset + absOffset);\n rightNode.value = rightValue;\n\n this.parent!.insertAfterInternal(rightNode, this as any);\n\n return rightNode;\n }\n\n /**\n * `children` returns the children of the node.\n */\n get children(): Array<T> {\n // Tombstone nodes remain awhile in the tree during editing.\n // They will be removed after the editing is done.\n // So, we need to filter out the tombstone nodes to get the real children.\n return this._children.filter((child) => !child.isRemoved);\n }\n\n /**\n * `allChildren` returns all the children of the node including tombstone nodes.\n * It returns the shallow copy of the children.\n */\n get allChildren(): Array<T> {\n return [...this._children];\n }\n\n /**\n * `hasTextChild` returns true if the node's children consist of only text children.\n */\n hasTextChild(): boolean {\n return (\n this.children.length > 0 && this.children.every((child) => child.isText)\n );\n }\n\n /**\n * `append` appends the given nodes to the children.\n */\n append(...newNode: Array<T>): void {\n if (this.isText) {\n throw new YorkieError(Code.ErrRefused, 'Text node cannot have children');\n }\n\n this._children.push(...newNode);\n for (const node of newNode) {\n node.parent = this as any;\n node.updateAncestorsSize();\n }\n }\n\n /**\n * `prepend` prepends the given nodes to the children. It is only used\n * for creating a new node from snapshot.\n */\n prepend(...newNode: Array<T>): void {\n if (this.isText) {\n throw new YorkieError(Code.ErrRefused, 'Text node cannot have children');\n }\n\n this._children.unshift(...newNode);\n for (const node of newNode) {\n node.parent = this as any;\n }\n }\n\n /**\n * `insertBefore` inserts the given node before the given child.\n */\n insertBefore(newNode: T, referenceNode: T): void {\n if (this.isText) {\n throw new YorkieError(Code.ErrRefused, 'Text node cannot have children');\n }\n\n const offset = this._children.indexOf(referenceNode);\n if (offset === -1) {\n throw new YorkieError(Code.ErrInvalidArgument, 'child not found');\n }\n\n this.insertAtInternal(newNode, offset);\n newNode.updateAncestorsSize();\n }\n\n /**\n * `insertAfter` inserts the given node after the given child.\n */\n insertAfter(newNode: T, referenceNode: T): void {\n if (this.isText) {\n throw new YorkieError(Code.ErrRefused, 'Text node cannot have children');\n }\n\n const offset = this._children.indexOf(referenceNode);\n if (offset === -1) {\n throw new YorkieError(Code.ErrInvalidArgument, 'child not found');\n }\n\n this.insertAtInternal(newNode, offset + 1);\n newNode.updateAncestorsSize();\n }\n\n /**\n * `insertAt` inserts the given node at the given offset.\n */\n insertAt(newNode: T, offset: number): void {\n if (this.isText) {\n throw new YorkieError(Code.ErrRefused, 'Text node cannot have children');\n }\n\n this.insertAtInternal(newNode, offset);\n newNode.updateAncestorsSize();\n }\n\n /**\n * `removeChild` removes the given child.\n */\n removeChild(child: T) {\n if (this.isText) {\n throw new YorkieError(Code.ErrRefused, 'Text node cannot have children');\n }\n\n const offset = this._children.indexOf(child);\n if (offset === -1) {\n throw new YorkieError(Code.ErrInvalidArgument, 'child not found');\n }\n\n this._children.splice(offset, 1);\n child.parent = undefined;\n }\n\n /**\n * `splitElement` splits the given element at the given offset.\n */\n splitElement(\n offset: number,\n issueTimeTicket: () => TimeTicket,\n ): T | undefined {\n /**\n * TODO(hackerwins): Define ID of split node for concurrent editing.\n * Text has fixed content and its split nodes could have limited offset\n * range. But element node could have arbitrary children and its split\n * nodes could have arbitrary offset range. So, id could be duplicated\n * and its order could be broken when concurrent editing happens.\n * Currently, we use the similar ID of split element with the split text.\n */\n const clone = this.cloneElement(issueTimeTicket);\n this.parent!.insertAfterInternal(clone, this as any);\n clone.updateAncestorsSize();\n\n const leftChildren = this.children.slice(0, offset);\n const rightChildren = this.children.slice(offset);\n this._children = leftChildren;\n clone._children = rightChildren;\n this.size = this._children.reduce(\n (acc, child) => acc + child.paddedSize,\n 0,\n );\n clone.size = clone._children.reduce(\n (acc, child) => acc + child.paddedSize,\n 0,\n );\n for (const child of clone._children) {\n child.parent = clone;\n }\n\n return clone;\n }\n\n /**\n * `insertAfterInternal` inserts the given node after the given child.\n * This method does not update the size of the ancestors.\n */\n insertAfterInternal(newNode: T, referenceNode: T): void {\n if (this.isText) {\n throw new YorkieError(Code.ErrRefused, 'Text node cannot have children');\n }\n\n const offset = this._children.indexOf(referenceNode);\n if (offset === -1) {\n throw new YorkieError(Code.ErrInvalidArgument, 'child not found');\n }\n\n this.insertAtInternal(newNode, offset + 1);\n }\n\n /**\n * `insertAtInternal` inserts the given node at the given index.\n * This method does not update the size of the ancestors.\n */\n insertAtInternal(newNode: T, offset: number): void {\n if (this.isText) {\n throw new YorkieError(Code.ErrRefused, 'Text node cannot have children');\n }\n\n this._children.splice(offset, 0, newNode);\n newNode.parent = this as any;\n }\n\n /**\n * findOffset returns the offset of the given node in the children.\n * It excludes the removed nodes.\n */\n findOffset(node: T): number {\n if (this.isText) {\n throw new YorkieError(Code.ErrRefused, 'Text node cannot have children');\n }\n\n if (node.isRemoved) {\n const index = this._children.indexOf(node);\n\n // If nodes are removed, the offset of the removed node is the number of\n // nodes before the node excluding the removed nodes.\n const refined = this.allChildren\n .splice(0, index)\n .filter((node) => !node.isRemoved).length;\n\n return refined;\n }\n\n return this.children.indexOf(node);\n }\n\n /**\n * `findBranchOffset` returns offset of the given descendant node in this node.\n * If the given node is not a descendant of this node, it returns -1.\n */\n findBranchOffset(node: T): number {\n if (this.isText) {\n throw new YorkieError(Code.ErrRefused, 'Text node cannot have children');\n }\n\n let current: T | undefined = node;\n while (current) {\n const offset = this._children.indexOf(current);\n if (offset !== -1) {\n return offset;\n }\n\n current = current.parent;\n }\n\n return -1;\n }\n}\n\n/**\n * `TreePos` is the position of a node in the tree.\n *\n * `offset` is the position of node's token. For example, if the node is an\n * element node, the offset is the index of the child node. If the node is a\n * text node, the offset is the index of the character.\n */\nexport type TreePos<T extends IndexTreeNode<T>> = {\n node: T;\n offset: number;\n};\n\n/**\n * `ancestorOf` returns true if the given node is an ancestor of the other node.\n */\nfunction ancestorOf<T extends IndexTreeNode<T>>(ancestor: T, node: T): boolean {\n if (ancestor === node) {\n return false;\n }\n\n while (node.parent) {\n if (node.parent === ancestor) {\n return true;\n }\n node = node.parent;\n }\n return false;\n}\n\n/**\n * `TokenType` represents the type of token in XML representation.\n */\nexport enum TokenType {\n /**\n * `Start` represents that the start token type.\n */\n Start = 'Start',\n\n /**\n * `End` represents that the end token type.\n */\n End = 'End',\n\n /**\n * `Text` represents that the text token type.\n */\n Text = 'Text',\n}\n\n/**\n * `TreeToken` represents the token of the tree in XML representation.\n */\nexport type TreeToken<T> = [T, TokenType];\n\n/**\n * `tokensBetween` iterates the tokens between the given range.\n *\n * For example, if the tree is <p><i>abc</i></p>, the tokens are\n * [p, Start], [i, Start], [abc, Text], [i, End], [p, End].\n *\n * If the given range is collapsed, the callback is not called.\n * It traverses the tree based on the concept of token.\n * NOTE(sejongk): Nodes should not be removed in callback, because it leads wrong behaviors.\n */\nfunction tokensBetween<T extends IndexTreeNode<T>>(\n root: T,\n from: number,\n to: number,\n callback: (token: TreeToken<T>, ended: boolean) => void,\n) {\n if (from > to) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `from is greater than to: ${from} > ${to}`,\n );\n }\n\n if (from > root.size) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `from is out of range: ${from} > ${root.size}`,\n );\n }\n\n if (to > root.size) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `to is out of range: ${to} > ${root.size}`,\n );\n }\n\n if (from === to) {\n return;\n }\n\n let pos = 0;\n for (const child of root.children) {\n // If the child is an element node, the size of the child.\n if (from - child.paddedSize < pos && pos < to) {\n // If the child is an element node, the range of the child\n // is from - 1 to to - 1. Because the range of the element node is from\n // the open tag to the close tag.\n const fromChild = child.isText ? from - pos : from - pos - 1;\n const toChild = child.isText ? to - pos : to - pos - 1;\n\n // If the range spans outside the child,\n // the callback is called with the child.\n const startContained = !child.isText && fromChild < 0;\n const endContained = !child.isText && toChild > child.size;\n if (child.isText || startContained) {\n callback(\n [child, child.isText ? TokenType.Text : TokenType.Start],\n endContained,\n );\n }\n tokensBetween(\n child,\n Math.max(0, fromChild),\n Math.min(toChild, child.size),\n callback,\n );\n if (endContained) {\n callback([child, TokenType.End], endContained);\n }\n }\n pos += child.paddedSize;\n }\n}\n\n/**\n * `traverse` traverses the tree with postorder traversal.\n */\nexport function traverse<T extends IndexTreeNode<T>>(\n node: T,\n callback: (node: T, depth: number) => void,\n depth = 0,\n) {\n for (const child of node.children) {\n traverse(child, callback, depth + 1);\n }\n callback(node, depth);\n}\n\n/**\n * `traverseAll` traverses the whole tree (include tombstones) with postorder traversal.\n */\nexport function traverseAll<T extends IndexTreeNode<T>>(\n node: T,\n callback: (node: T, depth: number) => void,\n depth = 0,\n) {\n for (const child of node._children) {\n traverseAll(child, callback, depth + 1);\n }\n callback(node, depth);\n}\n\n/**\n * `findTreePos` finds the position of the given index in the given node.\n */\nfunction findTreePos<T extends IndexTreeNode<T>>(\n node: T,\n index: number,\n preferText = true,\n): TreePos<T> {\n if (index > node.size) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `index is out of range: ${index} > ${node.size}`,\n );\n }\n\n if (node.isText) {\n return { node, offset: index };\n }\n\n // offset is the index of the child node.\n // pos is the window of the index in the given node.\n let offset = 0;\n let pos = 0;\n for (const child of node.children) {\n // The pos is in bothsides of the text node, we should traverse\n // inside of the text node if preferText is true.\n if (preferText && child.isText && child.size >= index - pos) {\n return findTreePos(child, index - pos, preferText);\n }\n\n // The position is in leftside of the element node.\n if (index === pos) {\n return { node, offset };\n }\n\n // The position is in rightside of the element node and preferText is false.\n if (!preferText && child.paddedSize === index - pos) {\n return { node, offset: offset + 1 };\n }\n\n // The position is in middle the element node.\n if (child.paddedSize > index - pos) {\n // If we traverse inside of the element node, we should skip the open.\n const skipOpenSize = 1;\n return findTreePos(child, index - pos - skipOpenSize, preferText);\n }\n\n pos += child.paddedSize;\n offset += 1;\n }\n\n // The position is in rightmost of the given node.\n return { node, offset };\n}\n\n/**\n * `getAncestors` returns the ancestors of the given node.\n */\nexport function getAncestors<T extends IndexTreeNode<T>>(node: T): Array<T> {\n const ancestors: Array<T> = [];\n let parent = node.parent;\n while (parent) {\n ancestors.unshift(parent);\n parent = parent.parent;\n }\n return ancestors;\n}\n\n/**\n * `findCommonAncestor` finds the lowest common ancestor of the given nodes.\n */\nexport function findCommonAncestor<T extends IndexTreeNode<T>>(\n nodeA: T,\n nodeB: T,\n): T | undefined {\n if (nodeA === nodeB) {\n return nodeA;\n }\n\n const ancestorsOfA = getAncestors(nodeA);\n const ancestorsOfB = getAncestors(nodeB);\n\n let commonAncestor: T | undefined;\n for (let i = 0; i < ancestorsOfA.length; i++) {\n const ancestorOfA = ancestorsOfA[i];\n const ancestorOfB = ancestorsOfB[i];\n\n if (ancestorOfA !== ancestorOfB) {\n break;\n }\n\n commonAncestor = ancestorOfA;\n }\n\n return commonAncestor;\n}\n\n/**\n * `findLeftmost` finds the leftmost node of the given tree.\n */\nexport function findLeftmost<T extends IndexTreeNode<T>>(node: T): T {\n if (node.isText || node.children.length === 0) {\n return node;\n }\n\n return findLeftmost(node.children[0]);\n}\n\n/**\n * `findTextPos` returns the tree position of the given path element.\n */\nfunction findTextPos<T extends IndexTreeNode<T>>(node: T, pathElement: number) {\n if (node.size < pathElement) {\n throw new YorkieError(Code.ErrInvalidArgument, 'unacceptable path');\n }\n\n for (let i = 0; i < node.children.length; i++) {\n const child = node.children[i];\n\n if (child.size < pathElement) {\n pathElement -= child.size;\n } else {\n node = child;\n\n break;\n }\n }\n\n return { node, offset: pathElement };\n}\n\n/**\n * `IndexTree` is a tree structure for linear indexing.\n */\nexport class IndexTree<T extends IndexTreeNode<T>> {\n private root: T;\n\n constructor(root: T) {\n this.root = root;\n }\n\n /**\n * `tokensBetween` returns the tokens between the given range.\n */\n tokensBetween(\n from: number,\n to: number,\n callback: (token: TreeToken<T>, ended: boolean) => void,\n ): void {\n tokensBetween<T>(this.root, from, to, callback);\n }\n\n /**\n * `traverse` traverses the tree with postorder traversal.\n */\n traverse(callback: (node: T) => void): void {\n traverse(this.root, callback, 0);\n }\n\n /**\n * `traverseAll` traverses the whole tree (include tombstones) with postorder traversal.\n */\n traverseAll(callback: (node: T) => void): void {\n traverseAll(this.root, callback, 0);\n }\n\n /**\n * findTreePos finds the position of the given index in the tree.\n */\n public findTreePos(index: number, preferText = true): TreePos<T> {\n return findTreePos(this.root, index, preferText);\n }\n\n /**\n * `treePosToPath` returns path from given treePos\n */\n public treePosToPath(treePos: TreePos<T>) {\n const path = [];\n let node = treePos.node;\n\n if (node.isText) {\n const offset = node.parent!.findOffset(node);\n if (offset === -1) {\n throw new YorkieError(Code.ErrInvalidArgument, 'invalid treePos');\n }\n\n const sizeOfLeftSiblings = addSizeOfLeftSiblings(\n node.parent! as T,\n offset,\n );\n path.push(sizeOfLeftSiblings + treePos.offset);\n node = node.parent!;\n } else if (node.hasTextChild()) {\n // TODO(hackerwins): The function does not consider the situation\n // where Element and Text nodes are mixed in the Element's Children.\n const sizeOfLeftSiblings = addSizeOfLeftSiblings(\n node! as T,\n treePos.offset,\n );\n path.push(sizeOfLeftSiblings);\n } else {\n path.push(treePos.offset);\n }\n\n while (node.parent) {\n const offset = node.parent.findOffset(node);\n if (offset === -1) {\n throw new YorkieError(Code.ErrInvalidArgument, 'invalid treePos');\n }\n\n path.push(offset);\n node = node.parent;\n }\n\n return path.reverse();\n }\n\n /**\n * `pathToIndex` returns index from given path\n */\n public pathToIndex(path: Array<number>): number {\n const treePos = this.pathToTreePos(path);\n\n return this.indexOf(treePos);\n }\n\n /**\n * `pathToTreePos` returns treePos from given path\n */\n public pathToTreePos(path: Array<number>): TreePos<T> {\n if (!path.length) {\n throw new YorkieError(Code.ErrInvalidArgument, 'unacceptable path');\n }\n\n let node = this.root;\n for (let i = 0; i < path.length - 1; i++) {\n const pathElement = path[i];\n node = node.children[pathElement];\n\n if (!node) {\n throw new YorkieError(Code.ErrInvalidArgument, 'unacceptable path');\n }\n }\n\n if (node.hasTextChild()) {\n return findTextPos(node, path[path.length - 1]);\n }\n\n if (node.children.length < path[path.length - 1]) {\n throw new YorkieError(Code.ErrInvalidArgument, 'unacceptable path');\n }\n\n return {\n node,\n offset: path[path.length - 1],\n };\n }\n\n /**\n * `getRoot` returns the root node of the tree.\n */\n public getRoot(): T {\n return this.root;\n }\n\n /**\n * `getSize` returns the size of the tree.\n */\n public get size(): number {\n return this.root.size;\n }\n\n /**\n * `findPostorderRight` finds right node of the given tree position with\n * postorder traversal.\n */\n public findPostorderRight(treePos: TreePos<T>): T | undefined {\n const { node, offset } = treePos;\n\n if (node.isText) {\n if (node.size === offset) {\n const nextSibling = node.nextSibling;\n if (nextSibling) {\n return nextSibling;\n }\n\n return node.parent;\n }\n\n return node;\n }\n\n if (node.children.length === offset) {\n return node;\n }\n\n return findLeftmost(node.children[offset]);\n }\n\n /**\n * `indexOf` returns the index of the given tree position.\n */\n public indexOf(pos: TreePos<T>): number {\n let { node } = pos;\n const { offset } = pos;\n\n let size = 0;\n let depth = 1;\n if (node.isText) {\n size += offset;\n\n const parent = node.parent! as T;\n const offsetOfNode = parent.findOffset(node);\n if (offsetOfNode === -1) {\n throw new YorkieError(Code.ErrInvalidArgument, 'invalid pos');\n }\n\n size += addSizeOfLeftSiblings(parent, offsetOfNode);\n\n node = node.parent!;\n } else {\n size += addSizeOfLeftSiblings(node, offset);\n }\n\n while (node?.parent) {\n const parent = node.parent;\n const offsetOfNode = parent.findOffset(node);\n if (offsetOfNode === -1) {\n throw new YorkieError(Code.ErrInvalidArgument, 'invalid pos');\n }\n\n size += addSizeOfLeftSiblings(parent, offsetOfNode);\n depth++;\n node = node.parent;\n }\n\n return size + depth - 1;\n }\n\n /**\n * `indexToPath` returns the path of the given index.\n */\n public indexToPath(index: number): Array<number> {\n const treePos = this.findTreePos(index);\n return this.treePosToPath(treePos);\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type Comparator<K> = (keyA: K, keyB: K) => number;\n\n// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types\nexport const DefaultComparator = (a: any, b: any): number => {\n if (a === b) {\n return 0;\n } else if (a < b) {\n return -1;\n } else {\n return 1;\n }\n};\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n Comparator,\n DefaultComparator,\n} from '@yorkie-js-sdk/src/util/comparator';\n\ninterface Entry<K, V> {\n key: K;\n value: V;\n}\n\n/**\n * `LLRBNode` is node of LLRBTree.\n */\nclass LLRBNode<K, V> {\n public key: K;\n public value: V;\n public parent?: LLRBNode<K, V>;\n public left?: LLRBNode<K, V>;\n public right?: LLRBNode<K, V>;\n public isRed: boolean;\n\n constructor(key: K, value: V, isRed: boolean) {\n this.key = key;\n this.value = value;\n this.isRed = isRed;\n }\n}\n\n/**\n * `SortedMapIterator` is a interator for traversing LLRBTree.\n */\nexport class SortedMapIterator<K, V> {\n public stack: Array<Entry<K, V>>;\n\n constructor(root: LLRBNode<K, V>) {\n this.stack = [];\n this.traverseInorder(root);\n }\n\n // TODO: Replace with iterative approach, if we encounter performance problem.\n private traverseInorder(node: LLRBNode<K, V>): void {\n if (!node) {\n return;\n }\n\n this.traverseInorder(node.left!);\n this.stack.push({\n key: node.key,\n value: node.value,\n });\n this.traverseInorder(node.right!);\n }\n}\n\n/**\n * LLRBTree is an implementation of Left-learning Red-Black Tree.\n *\n * Original paper on Left-leaning Red-Black Trees:\n * @see http://www.cs.princeton.edu/~rs/talks/LLRB/LLRB.pdf\n *\n * Invariant 1: No red node has a red child\n * Invariant 2: Every leaf path has the same number of black nodes\n * Invariant 3: Only the left child can be red (left leaning)\n */\nexport class LLRBTree<K, V> {\n private root?: LLRBNode<K, V>;\n private comparator: Comparator<K>;\n private counter: number;\n\n constructor(comparator?: Comparator<K>) {\n this.comparator =\n typeof comparator !== 'undefined' ? comparator : DefaultComparator;\n this.counter = 0;\n }\n\n /**\n * `put` puts the value of the given key.\n */\n public put(key: K, value: V): V {\n this.root = this.putInternal(key, value, this.root);\n this.root.isRed = false;\n return value;\n }\n\n /**\n * `get` gets a value of the given key.\n */\n public get(key: K): V | undefined {\n const node = this.getInternal(key, this.root);\n return node ? node.value : undefined;\n }\n\n /**\n * `remove` removes a element of key.\n */\n public remove(key: K): void {\n if (!this.isRed(this.root!.left!) && !this.isRed(this.root!.right!)) {\n this.root!.isRed = true;\n }\n\n this.root = this.removeInternal(this.root!, key);\n if (this.root) {\n this.root.isRed = false;\n }\n }\n\n /**\n * `getIterator` returns a new instance of SortedMapIterator.\n */\n public getIterator(): SortedMapIterator<K, V> {\n return new SortedMapIterator(this.root!);\n }\n\n /**\n * `values` returns value array of LLRBTree.\n */\n public values(): Array<V> {\n const values = [];\n for (const entry of this.getIterator().stack) {\n values.push(entry.value);\n }\n return values;\n }\n\n /**\n * `floorEntry` returns the entry for the greatest key less than or equal to the\n * given key. If there is no such key, returns `undefined`.\n */\n public floorEntry(key: K): Entry<K, V> | undefined {\n let node = this.root;\n while (node) {\n const compare = this.comparator(key, node.key);\n if (compare > 0) {\n if (node.right) {\n node.right.parent = node;\n node = node.right;\n } else {\n return node;\n }\n } else if (compare < 0) {\n if (node.left) {\n node.left.parent = node;\n node = node.left;\n } else {\n let parent = node.parent;\n let childNode = node;\n while (parent && childNode === parent.left) {\n childNode = parent;\n parent = parent.parent;\n }\n return parent!;\n }\n } else {\n return node;\n }\n }\n return;\n }\n\n /**\n * `lastEntry` returns last entry of LLRBTree.\n */\n public lastEntry(): Entry<K, V> | undefined {\n if (!this.root) {\n return this.root;\n }\n\n let node = this.root;\n while (node.right) {\n node = node.right;\n }\n return node;\n }\n\n /**\n * `size` is a size of LLRBTree.\n */\n public size(): number {\n return this.counter;\n }\n\n /**\n * `isEmpty` checks if size is empty.\n */\n public isEmpty(): boolean {\n return this.counter === 0;\n }\n\n private getInternal(\n key: K,\n node?: LLRBNode<K, V>,\n ): LLRBNode<K, V> | undefined {\n while (node) {\n const compare = this.comparator(key, node.key);\n if (compare === 0) {\n return node;\n } else if (compare < 0) {\n node = node.left!;\n } else if (compare > 0) {\n node = node.right!;\n }\n }\n\n return;\n }\n\n private putInternal(key: K, value: V, node?: LLRBNode<K, V>): LLRBNode<K, V> {\n if (!node) {\n this.counter += 1;\n return new LLRBNode(key, value, true);\n }\n\n const compare = this.comparator(key, node.key);\n if (compare < 0) {\n node.left = this.putInternal(key, value, node.left);\n } else if (compare > 0) {\n node.right = this.putInternal(key, value, node.right);\n } else {\n node.value = value;\n }\n\n if (this.isRed(node.right!) && !this.isRed(node.left!)) {\n node = this.rotateLeft(node);\n }\n\n if (this.isRed(node.left!) && this.isRed(node.left!.left!)) {\n node = this.rotateRight(node);\n }\n\n if (this.isRed(node.left!) && this.isRed(node.right!)) {\n this.flipColors(node);\n }\n\n return node;\n }\n\n private removeInternal(\n node: LLRBNode<K, V>,\n key: K,\n ): LLRBNode<K, V> | undefined {\n if (this.comparator(key, node.key) < 0) {\n if (!this.isRed(node.left!) && !this.isRed(node.left!.left!)) {\n node = this.moveRedLeft(node);\n }\n node.left = this.removeInternal(node.left!, key);\n } else {\n if (this.isRed(node.left!)) {\n node = this.rotateRight(node);\n }\n\n if (this.comparator(key, node.key) === 0 && !node.right) {\n this.counter -= 1;\n return;\n }\n\n if (!this.isRed(node.right!) && !this.isRed(node.right!.left!)) {\n node = this.moveRedRight(node);\n }\n\n if (this.comparator(key, node.key) === 0) {\n this.counter -= 1;\n const smallest = this.min(node.right!);\n node.value = smallest.value;\n node.key = smallest.key;\n node.right = this.removeMin(node.right!);\n } else {\n node.right = this.removeInternal(node.right!, key);\n }\n }\n\n return this.fixUp(node);\n }\n\n private min(node: LLRBNode<K, V>): LLRBNode<K, V> {\n if (!node.left) {\n return node;\n } else {\n return this.min(node.left);\n }\n }\n\n private removeMin(node: LLRBNode<K, V>): LLRBNode<K, V> | undefined {\n if (!node.left) {\n return;\n }\n\n if (!this.isRed(node.left) && !this.isRed(node.left!.left!)) {\n node = this.moveRedLeft(node);\n }\n\n node.left = this.removeMin(node.left!);\n return this.fixUp(node);\n }\n\n private fixUp(node: LLRBNode<K, V>): LLRBNode<K, V> {\n if (this.isRed(node.right!)) {\n node = this.rotateLeft(node);\n }\n\n if (this.isRed(node.left!) && this.isRed(node.left!.left!)) {\n node = this.rotateRight(node);\n }\n\n if (this.isRed(node.left!) && this.isRed(node.right!)) {\n this.flipColors(node);\n }\n\n return node;\n }\n\n private moveRedLeft(node: LLRBNode<K, V>): LLRBNode<K, V> {\n this.flipColors(node);\n if (this.isRed(node.right!.left!)) {\n node.right = this.rotateRight(node.right!);\n node = this.rotateLeft(node);\n this.flipColors(node);\n }\n return node;\n }\n\n private moveRedRight(node: LLRBNode<K, V>): LLRBNode<K, V> {\n this.flipColors(node);\n if (this.isRed(node.left!.left!)) {\n node = this.rotateRight(node);\n this.flipColors(node);\n }\n return node;\n }\n\n private isRed(node: LLRBNode<K, V>): boolean {\n return node && node.isRed;\n }\n\n private rotateLeft(node: LLRBNode<K, V>): LLRBNode<K, V> {\n const x = node.right!;\n node.right = x.left;\n x.left = node;\n x.isRed = x.left.isRed;\n x.left.isRed = true;\n return x;\n }\n\n private rotateRight(node: LLRBNode<K, V>): LLRBNode<K, V> {\n const x = node.left!;\n node.left = x.right;\n x.right = node;\n x.isRed = x.right.isRed;\n x.right.isRed = true;\n return x;\n }\n\n private flipColors(node: LLRBNode<K, V>): void {\n node.isRed = !node.isRed!;\n node.left!.isRed = !node.left!.isRed;\n node.right!.isRed = !node.right!.isRed;\n }\n}\n","/*\n * Copyright 2023 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n TimeTicket,\n InitialTimeTicket,\n TimeTicketStruct,\n MaxLamport,\n} from '@yorkie-js-sdk/src/document/time/ticket';\nimport { VersionVector } from '@yorkie-js-sdk/src/document/time/version_vector';\nimport { CRDTElement } from '@yorkie-js-sdk/src/document/crdt/element';\n\nimport {\n IndexTree,\n TreePos,\n IndexTreeNode,\n traverseAll,\n TokenType,\n} from '@yorkie-js-sdk/src/util/index_tree';\nimport { RHT, RHTNode } from './rht';\nimport { ActorID } from './../time/actor_id';\nimport { LLRBTree } from '@yorkie-js-sdk/src/util/llrb_tree';\nimport { Comparator } from '@yorkie-js-sdk/src/util/comparator';\nimport { parseObjectValues } from '@yorkie-js-sdk/src/util/object';\nimport type {\n DefaultTextType,\n TreeNodeType,\n TreeToken,\n} from '@yorkie-js-sdk/src/util/index_tree';\nimport { Indexable } from '@yorkie-js-sdk/src/document/document';\nimport type * as Devtools from '@yorkie-js-sdk/src/devtools/types';\nimport { escapeString } from '@yorkie-js-sdk/src/document/json/strings';\nimport { GCChild, GCPair, GCParent } from '@yorkie-js-sdk/src/document/crdt/gc';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\n\n/**\n * `TreeNode` represents a node in the tree.\n */\nexport type TreeNode = TextNode | ElementNode;\n\n/**\n * `ElementNode` represents an element node. It has an attributes and children.\n */\nexport type ElementNode<A extends Indexable = Indexable> = {\n type: TreeNodeType;\n attributes?: A;\n children: Array<TreeNode>;\n};\n\n/**\n * `TextNode` represents a text node. It has a string value.\n */\nexport type TextNode = {\n type: typeof DefaultTextType;\n value: string;\n};\n\n/**\n * `TreeNodeForTest` represents the JSON representation of a node in the tree.\n * It is used for testing.\n */\nexport type TreeNodeForTest = TreeNode & {\n children?: Array<TreeNodeForTest>;\n size: number;\n isRemoved: boolean;\n};\n\n/**\n * `TreeChangeType` represents the type of change in the tree.\n */\nexport enum TreeChangeType {\n Content = 'content',\n Style = 'style',\n RemoveStyle = 'removeStyle',\n}\n\n/**\n * `TreeChange` represents the change in the tree.\n */\nexport type TreeChange =\n | {\n actor: ActorID;\n type: TreeChangeType.Content;\n from: number;\n to: number;\n fromPath: Array<number>;\n toPath: Array<number>;\n value?: Array<TreeNode>;\n splitLevel?: number;\n }\n | {\n actor: ActorID;\n type: TreeChangeType.Style;\n from: number;\n to: number;\n fromPath: Array<number>;\n toPath: Array<number>;\n value: { [key: string]: string };\n splitLevel?: number;\n }\n | {\n actor: ActorID;\n type: TreeChangeType.RemoveStyle;\n from: number;\n to: number;\n fromPath: Array<number>;\n toPath: Array<number>;\n value?: Array<string>;\n splitLevel?: number;\n };\n\n/**\n * `CRDTTreePos` represent a position in the tree. It is used to identify a\n * position in the tree. It is composed of the parent ID and the left sibling\n * ID. If there's no left sibling in parent's children, then left sibling is\n * parent.\n */\nexport class CRDTTreePos {\n private parentID: CRDTTreeNodeID;\n private leftSiblingID: CRDTTreeNodeID;\n\n constructor(parentID: CRDTTreeNodeID, leftSiblingID: CRDTTreeNodeID) {\n this.parentID = parentID;\n this.leftSiblingID = leftSiblingID;\n }\n\n /**\n * `of` creates a new instance of CRDTTreePos.\n */\n public static of(parentID: CRDTTreeNodeID, leftSiblingID: CRDTTreeNodeID) {\n return new CRDTTreePos(parentID, leftSiblingID);\n }\n\n /**\n * `fromTreePos` creates a new instance of CRDTTreePos from the given TreePos.\n */\n public static fromTreePos(pos: TreePos<CRDTTreeNode>): CRDTTreePos {\n const { offset } = pos;\n let { node } = pos;\n let leftNode;\n\n if (node.isText) {\n if (node.parent!.children[0] === node && offset === 0) {\n leftNode = node.parent!;\n } else {\n leftNode = node;\n }\n\n node = node.parent!;\n } else {\n if (offset === 0) {\n leftNode = node;\n } else {\n leftNode = node.children[offset - 1];\n }\n }\n\n return CRDTTreePos.of(\n node.id,\n CRDTTreeNodeID.of(leftNode.getCreatedAt(), leftNode.getOffset() + offset),\n );\n }\n\n /**\n * `getParentID` returns the parent ID.\n */\n public getParentID() {\n return this.parentID;\n }\n\n /**\n * `fromStruct` creates a new instance of CRDTTreeNodeID from the given struct.\n */\n public static fromStruct(struct: CRDTTreePosStruct): CRDTTreePos {\n return CRDTTreePos.of(\n CRDTTreeNodeID.of(\n TimeTicket.fromStruct(struct.parentID.createdAt),\n struct.parentID.offset,\n ),\n CRDTTreeNodeID.of(\n TimeTicket.fromStruct(struct.leftSiblingID.createdAt),\n struct.leftSiblingID.offset,\n ),\n );\n }\n\n /**\n * `toStruct` returns the structure of this position.\n */\n public toStruct(): CRDTTreePosStruct {\n return {\n parentID: {\n createdAt: this.getParentID().getCreatedAt().toStruct(),\n offset: this.getParentID().getOffset(),\n },\n leftSiblingID: {\n createdAt: this.getLeftSiblingID().getCreatedAt().toStruct(),\n offset: this.getLeftSiblingID().getOffset(),\n },\n };\n }\n\n /**\n * `toTreeNodePair` converts the pos to parent and left sibling nodes.\n * If the position points to the middle of a node, then the left sibling node\n * is the node that contains the position. Otherwise, the left sibling node is\n * the node that is located at the left of the position.\n */\n public toTreeNodePair(tree: CRDTTree): TreeNodePair {\n const parentID = this.getParentID();\n const leftSiblingID = this.getLeftSiblingID();\n const parentNode = tree.findFloorNode(parentID);\n let leftNode = tree.findFloorNode(leftSiblingID);\n if (!parentNode || !leftNode) {\n throw new YorkieError(\n Code.ErrRefused,\n `cannot find node of CRDTTreePos(${parentID.toTestString()}, ${leftSiblingID.toTestString()})`,\n );\n }\n\n /**\n * NOTE(hackerwins): If the left node and the parent node are the same,\n * it means that the position is the left-most of the parent node.\n * We need to skip finding the left of the position.\n */\n if (\n !leftSiblingID.equals(parentID) &&\n leftSiblingID.getOffset() > 0 &&\n leftSiblingID.getOffset() === leftNode.id.getOffset() &&\n leftNode.insPrevID\n ) {\n leftNode = tree.findFloorNode(leftNode.insPrevID)!;\n }\n\n return [parentNode, leftNode];\n }\n\n /**\n * `getLeftSiblingID` returns the left sibling ID.\n */\n public getLeftSiblingID() {\n return this.leftSiblingID;\n }\n\n /**\n * `equals` returns whether the given pos equals to this or not.\n */\n public equals(other: CRDTTreePos): boolean {\n return (\n this.getParentID()\n .getCreatedAt()\n .equals(other.getParentID().getCreatedAt()) &&\n this.getParentID().getOffset() === other.getParentID().getOffset() &&\n this.getLeftSiblingID()\n .getCreatedAt()\n .equals(other.getLeftSiblingID().getCreatedAt()) &&\n this.getLeftSiblingID().getOffset() ===\n other.getLeftSiblingID().getOffset()\n );\n }\n}\n\n/**\n * `CRDTTreeNodeID` represent an ID of a node in the tree. It is used to\n * identify a node in the tree. It is composed of the creation time of the node\n * and the offset from the beginning of the node if the node is split.\n *\n * Some of replicas may have nodes that are not split yet. In this case, we can\n * use `map.floorEntry()` to find the adjacent node.\n */\nexport class CRDTTreeNodeID {\n /**\n * `createdAt` is the creation time of the node.\n */\n private createdAt: TimeTicket;\n\n /**\n * `offset` is the distance from the beginning of the node if the node is\n * split.\n */\n private offset: number;\n\n constructor(createdAt: TimeTicket, offset: number) {\n this.createdAt = createdAt;\n this.offset = offset;\n }\n\n /**\n * `of` creates a new instance of CRDTTreeNodeID.\n */\n public static of(createdAt: TimeTicket, offset: number): CRDTTreeNodeID {\n return new CRDTTreeNodeID(createdAt, offset);\n }\n\n /**\n * `fromStruct` creates a new instance of CRDTTreeNodeID from the given struct.\n */\n public static fromStruct(struct: CRDTTreeNodeIDStruct): CRDTTreeNodeID {\n return CRDTTreeNodeID.of(\n TimeTicket.fromStruct(struct.createdAt),\n struct.offset,\n );\n }\n\n /**\n * `createComparator` creates a comparator for CRDTTreeNodeID.\n */\n public static createComparator(): Comparator<CRDTTreeNodeID> {\n return (idA: CRDTTreeNodeID, idB: CRDTTreeNodeID) => {\n const compare = idA.getCreatedAt().compare(idB.getCreatedAt());\n if (compare !== 0) {\n return compare;\n }\n if (idA.getOffset() > idB.getOffset()) {\n return 1;\n } else if (idA.getOffset() < idB.getOffset()) {\n return -1;\n }\n return 0;\n };\n }\n\n /**\n * `getCreatedAt` returns the creation time of the node.\n */\n public getCreatedAt(): TimeTicket {\n return this.createdAt;\n }\n\n /**\n * `equals` returns whether given ID equals to this ID or not.\n */\n public equals(other: CRDTTreeNodeID): boolean {\n return (\n this.createdAt.compare(other.createdAt) === 0 &&\n this.offset === other.offset\n );\n }\n\n /**\n * `getOffset` returns returns the offset of the node.\n */\n public getOffset(): number {\n return this.offset;\n }\n\n /**\n * `setOffset` sets the offset of the node.\n */\n public setOffset(offset: number): void {\n this.offset = offset;\n }\n\n /**\n * `toStruct` returns the structure of this position.\n */\n public toStruct(): CRDTTreeNodeIDStruct {\n return {\n createdAt: this.createdAt.toStruct(),\n offset: this.offset,\n };\n }\n\n /**\n * `toIDString` returns a string that can be used as an ID for this position.\n */\n public toIDString(): string {\n return `${this.createdAt.toIDString()}:${this.offset}`;\n }\n\n /**\n * `toTestString` returns a string containing the meta data of the ticket\n * for debugging purpose.\n */\n public toTestString(): string {\n return `${this.createdAt.toTestString()}/${this.offset}`;\n }\n}\n\n/**\n * `CRDTTreePosStruct` represents the structure of CRDTTreePos.\n */\nexport type CRDTTreePosStruct = {\n parentID: CRDTTreeNodeIDStruct;\n leftSiblingID: CRDTTreeNodeIDStruct;\n};\n\n/**\n * `CRDTTreeNodeIDStruct` represents the structure of CRDTTreeNodeID.\n * It is used to serialize and deserialize the CRDTTreeNodeID.\n */\nexport type CRDTTreeNodeIDStruct = {\n createdAt: TimeTicketStruct;\n offset: number;\n};\n\n/**\n * `TreePosRange` represents a pair of CRDTTreePos.\n */\nexport type TreePosRange = [CRDTTreePos, CRDTTreePos];\n\n/**\n * `TreeNodePair` represents a pair of CRDTTreeNode. It represents the position\n * of the node in the tree with the left and parent nodes.\n */\ntype TreeNodePair = [CRDTTreeNode, CRDTTreeNode];\n\n/**\n * `TreePosStructRange` represents the structure of TreeRange.\n * It is used to serialize and deserialize the TreeRange.\n */\nexport type TreePosStructRange = [CRDTTreePosStruct, CRDTTreePosStruct];\n\n/**\n * `CRDTTreeNode` is a node of CRDTTree. It includes the logical clock and\n * links to other nodes to resolve conflicts.\n */\nexport class CRDTTreeNode\n extends IndexTreeNode<CRDTTreeNode>\n implements GCParent, GCChild\n{\n id: CRDTTreeNodeID;\n removedAt?: TimeTicket;\n attrs?: RHT;\n\n /**\n * `insPrevID` is the previous node id of this node after the node is split.\n */\n insPrevID?: CRDTTreeNodeID;\n\n /**\n * `insNextID` is the previous node id of this node after the node is split.\n */\n insNextID?: CRDTTreeNodeID;\n\n _value = '';\n\n constructor(\n id: CRDTTreeNodeID,\n type: string,\n opts?: string | Array<CRDTTreeNode>,\n attributes?: RHT,\n removedAt?: TimeTicket,\n ) {\n super(type);\n this.id = id;\n this.removedAt = removedAt;\n attributes && (this.attrs = attributes);\n\n if (typeof opts === 'string') {\n this.value = opts;\n } else if (Array.isArray(opts)) {\n this._children = opts;\n }\n }\n\n /**\n * `toIDString` returns the IDString of this node.\n */\n toIDString(): string {\n return this.id.toIDString();\n }\n\n /**\n * `getRemovedAt` returns the time when this node was removed.\n */\n getRemovedAt(): TimeTicket | undefined {\n return this.removedAt;\n }\n\n /**\n * `create` creates a new instance of CRDTTreeNode.\n */\n static create(\n id: CRDTTreeNodeID,\n type: string,\n opts?: string | Array<CRDTTreeNode>,\n attributes?: RHT,\n ) {\n return new CRDTTreeNode(id, type, opts, attributes);\n }\n\n /**\n * `deepcopy` copies itself deeply.\n */\n deepcopy(): CRDTTreeNode {\n const clone = new CRDTTreeNode(this.id, this.type);\n clone.removedAt = this.removedAt;\n clone._value = this._value;\n clone.size = this.size;\n clone.attrs = this.attrs?.deepcopy();\n clone._children = this._children.map((child) => {\n const childClone = child.deepcopy();\n childClone.parent = clone;\n return childClone;\n });\n clone.insPrevID = this.insPrevID;\n clone.insNextID = this.insNextID;\n return clone;\n }\n\n /**\n * `value` returns the value of the node.\n */\n get value() {\n if (!this.isText) {\n throw new YorkieError(\n Code.ErrInvalidType,\n `cannot get value of element node: ${this.type}`,\n );\n }\n\n return this._value;\n }\n\n /**\n * `value` sets the value of the node.\n */\n set value(v: string) {\n if (!this.isText) {\n throw new YorkieError(\n Code.ErrInvalidType,\n `cannot set value of element node: ${this.type}`,\n );\n }\n\n this._value = v;\n this.size = v.length;\n }\n\n /**\n * `isRemoved` returns whether the node is removed or not.\n */\n get isRemoved(): boolean {\n return !!this.removedAt;\n }\n\n /**\n * `remove` marks the node as removed.\n */\n remove(removedAt: TimeTicket): void {\n const alived = !this.removedAt;\n\n if (!this.removedAt || this.removedAt.compare(removedAt) > 0) {\n this.removedAt = removedAt;\n }\n\n if (alived) {\n this.updateAncestorsSize();\n }\n }\n\n /**\n * `cloneText` clones this text node with the given offset.\n */\n cloneText(offset: number): CRDTTreeNode {\n return new CRDTTreeNode(\n CRDTTreeNodeID.of(this.id.getCreatedAt(), offset),\n this.type,\n undefined,\n undefined,\n this.removedAt,\n );\n }\n\n /**\n * `cloneElement` clones this element node with the given issueTimeTicket function.\n */\n cloneElement(issueTimeTicket: () => TimeTicket): CRDTTreeNode {\n return new CRDTTreeNode(\n CRDTTreeNodeID.of(issueTimeTicket(), 0),\n this.type,\n undefined,\n undefined,\n this.removedAt,\n );\n }\n\n /**\n * `split` splits the given offset of this node.\n */\n public split(\n tree: CRDTTree,\n offset: number,\n issueTimeTicket?: () => TimeTicket,\n ): CRDTTreeNode | undefined {\n const split = this.isText\n ? this.splitText(offset, this.id.getOffset())\n : this.splitElement(offset, issueTimeTicket!);\n\n if (split) {\n split.insPrevID = this.id;\n if (this.insNextID) {\n const insNext = tree.findFloorNode(this.insNextID)!;\n insNext.insPrevID = split.id;\n split.insNextID = this.insNextID;\n }\n this.insNextID = split.id;\n tree.registerNode(split);\n }\n return split;\n }\n\n /**\n * `getCreatedAt` returns the creation time of this element.\n */\n public getCreatedAt(): TimeTicket {\n return this.id.getCreatedAt();\n }\n\n /**\n * `getOffset` returns the offset of a pos.\n */\n public getOffset(): number {\n return this.id.getOffset();\n }\n\n /**\n * `canDelete` checks if node is able to delete.\n */\n public canDelete(\n editedAt: TimeTicket,\n maxCreatedAt: TimeTicket | undefined,\n clientLamportAtChange: bigint,\n ): boolean {\n const nodeExisted = maxCreatedAt\n ? !this.getCreatedAt().after(maxCreatedAt)\n : this.getCreatedAt().getLamport() <= clientLamportAtChange;\n\n return nodeExisted && (!this.removedAt || editedAt.after(this.removedAt));\n }\n\n /**\n * `canStyle` checks if node is able to style.\n */\n public canStyle(\n editedAt: TimeTicket,\n maxCreatedAt: TimeTicket | undefined,\n clientLamportAtChange: bigint,\n ): boolean {\n if (this.isText) {\n return false;\n }\n const nodeExisted = maxCreatedAt\n ? !this.getCreatedAt().after(maxCreatedAt)\n : this.getCreatedAt().getLamport() <= clientLamportAtChange;\n\n return nodeExisted && (!this.removedAt || editedAt.after(this.removedAt));\n }\n\n /**\n * `setAttrs` sets the attributes of the node.\n */\n public setAttrs(\n attrs: { [key: string]: string },\n editedAt: TimeTicket,\n ): Array<[RHTNode | undefined, RHTNode | undefined]> {\n if (!this.attrs) {\n this.attrs = new RHT();\n }\n\n const pairs: Array<[RHTNode | undefined, RHTNode | undefined]> = [];\n for (const [key, value] of Object.entries(attrs)) {\n pairs.push(this.attrs.set(key, value, editedAt));\n }\n\n return pairs;\n }\n\n /**\n * `purge` purges the given child node.\n */\n public purge(node: RHTNode): void {\n if (this.attrs) {\n this.attrs.purge(node);\n }\n }\n\n /**\n * `getGCPairs` returns the pairs of GC.\n */\n public getGCPairs(): Array<GCPair> {\n const pairs: Array<GCPair> = [];\n if (!this.attrs) {\n return pairs;\n }\n\n for (const node of this.attrs) {\n if (node.getRemovedAt()) {\n pairs.push({ parent: this, child: node });\n }\n }\n\n return pairs;\n }\n}\n\n/**\n * `toTreeNode` converts the given CRDTTreeNode to TreeNode.\n */\nfunction toTreeNode(node: CRDTTreeNode): TreeNode {\n if (node.isText) {\n const currentNode = node;\n return {\n type: currentNode.type,\n value: currentNode.value,\n } as TextNode;\n }\n\n const treeNode: TreeNode = {\n type: node.type,\n children: node.children.map(toTreeNode),\n };\n\n if (node.attrs) {\n treeNode.attributes = parseObjectValues(node.attrs?.toObject());\n }\n\n return treeNode;\n}\n\n/**\n * `toXML` converts the given CRDTNode to XML string.\n */\nexport function toXML(node: CRDTTreeNode): string {\n if (node.isText) {\n const currentNode = node;\n return currentNode.value;\n }\n\n let attrs = '';\n if (node.attrs && node.attrs.size()) {\n attrs =\n ' ' +\n Array.from(node.attrs)\n .filter((n) => !n.isRemoved())\n .sort((a, b) => a.getKey().localeCompare(b.getKey()))\n .map((n) => {\n const obj = JSON.parse(n.getValue());\n if (typeof obj === 'string') {\n return `${n.getKey()}=\"${obj}\"`;\n }\n return `${n.getKey()}=\"${escapeString(n.getValue())}\"`;\n })\n .join(' ');\n }\n\n return `<${node.type}${attrs}>${node.children\n .map((child) => toXML(child))\n .join('')}</${node.type}>`;\n}\n\n/**\n * `toTestTreeNode` converts the given CRDTNode JSON for debugging.\n */\nfunction toTestTreeNode(node: CRDTTreeNode): TreeNodeForTest {\n if (node.isText) {\n const currentNode = node;\n return {\n type: currentNode.type,\n value: currentNode.value,\n size: currentNode.size,\n isRemoved: currentNode.isRemoved,\n } as TreeNodeForTest;\n }\n\n return {\n type: node.type,\n children: node.children.map(toTestTreeNode),\n size: node.size,\n isRemoved: node.isRemoved,\n };\n}\n\n/**\n * `CRDTTree` is a CRDT implementation of a tree.\n */\nexport class CRDTTree extends CRDTElement implements GCParent {\n private indexTree: IndexTree<CRDTTreeNode>;\n private nodeMapByID: LLRBTree<CRDTTreeNodeID, CRDTTreeNode>;\n\n constructor(root: CRDTTreeNode, createdAt: TimeTicket) {\n super(createdAt);\n this.indexTree = new IndexTree<CRDTTreeNode>(root);\n this.nodeMapByID = new LLRBTree(CRDTTreeNodeID.createComparator());\n\n this.indexTree.traverseAll((node) => {\n this.nodeMapByID.put(node.id, node);\n });\n }\n\n /**\n * `create` creates a new instance of `CRDTTree`.\n */\n public static create(root: CRDTTreeNode, ticket: TimeTicket): CRDTTree {\n return new CRDTTree(root, ticket);\n }\n\n /**\n * `findFloorNode` finds node of given id.\n */\n public findFloorNode(id: CRDTTreeNodeID): CRDTTreeNode | undefined {\n const entry = this.nodeMapByID.floorEntry(id);\n if (!entry || !entry.key.getCreatedAt().equals(id.getCreatedAt())) {\n return;\n }\n\n return entry.value;\n }\n\n /**\n * `registerNode` registers the given node to the tree.\n */\n public registerNode(node: CRDTTreeNode): void {\n this.nodeMapByID.put(node.id, node);\n }\n\n /**\n * `findNodesAndSplitText` finds `TreePos` of the given `CRDTTreeNodeID` and\n * splits nodes if the position is in the middle of a text node.\n *\n * The ids of the given `pos` are the ids of the node in the CRDT perspective.\n * This is different from `TreePos` which is a position of the tree in the\n * physical perspective.\n *\n * If `editedAt` is given, then it is used to find the appropriate left node\n * for concurrent insertion.\n */\n public findNodesAndSplitText(\n pos: CRDTTreePos,\n editedAt?: TimeTicket,\n ): TreeNodePair {\n // 01. Find the parent and left sibling node of the given position.\n const [parent, leftSibling] = pos.toTreeNodePair(this);\n let leftNode = leftSibling;\n\n // 02. Determine whether the position is left-most and the exact parent\n // in the current tree.\n const isLeftMost = parent === leftNode;\n const realParent =\n leftNode.parent && !isLeftMost ? leftNode.parent : parent;\n\n // 03. Split text node if the left node is a text node.\n if (leftNode.isText) {\n leftNode.split(\n this,\n pos.getLeftSiblingID().getOffset() - leftNode.id.getOffset(),\n );\n }\n\n // 04. Find the appropriate left node. If some nodes are inserted at the\n // same position concurrently, then we need to find the appropriate left\n // node. This is similar to RGA.\n if (editedAt) {\n const allChildren = realParent.allChildren;\n const index = isLeftMost ? 0 : allChildren.indexOf(leftNode) + 1;\n\n for (let i = index; i < allChildren.length; i++) {\n const next = allChildren[i];\n if (!next.id.getCreatedAt().after(editedAt)) {\n break;\n }\n\n leftNode = next;\n }\n }\n\n return [realParent, leftNode];\n }\n\n /**\n * `style` applies the given attributes of the given range.\n */\n public style(\n range: [CRDTTreePos, CRDTTreePos],\n attributes: { [key: string]: string } | undefined,\n editedAt: TimeTicket,\n maxCreatedAtMapByActor?: Map<string, TimeTicket>,\n versionVector?: VersionVector,\n ): [Map<string, TimeTicket>, Array<GCPair>, Array<TreeChange>] {\n const [fromParent, fromLeft] = this.findNodesAndSplitText(\n range[0],\n editedAt,\n );\n const [toParent, toLeft] = this.findNodesAndSplitText(range[1], editedAt);\n\n const changes: Array<TreeChange> = [];\n const attrs: { [key: string]: any } = attributes\n ? parseObjectValues(attributes)\n : {};\n const createdAtMapByActor = new Map<string, TimeTicket>();\n const pairs: Array<GCPair> = [];\n this.traverseInPosRange(\n fromParent,\n fromLeft,\n toParent,\n toLeft,\n ([node]) => {\n const actorID = node.getCreatedAt().getActorID();\n let maxCreatedAt: TimeTicket | undefined;\n let clientLamportAtChange = 0n;\n if (\n versionVector === undefined &&\n maxCreatedAtMapByActor === undefined\n ) {\n // Local edit - use version vector comparison\n clientLamportAtChange = MaxLamport;\n } else if (versionVector!.size() > 0) {\n clientLamportAtChange = versionVector!.get(actorID)\n ? versionVector!.get(actorID)!\n : 0n;\n } else {\n maxCreatedAt = maxCreatedAtMapByActor!.has(actorID)\n ? maxCreatedAtMapByActor!.get(actorID)\n : InitialTimeTicket;\n }\n\n if (\n node.canStyle(editedAt, maxCreatedAt, clientLamportAtChange) &&\n attributes\n ) {\n const maxCreatedAt = createdAtMapByActor!.get(actorID);\n const createdAt = node.getCreatedAt();\n if (!maxCreatedAt || createdAt.after(maxCreatedAt)) {\n createdAtMapByActor.set(actorID, createdAt);\n }\n\n const updatedAttrPairs = node.setAttrs(attributes, editedAt);\n const affectedAttrs = updatedAttrPairs.reduce(\n (acc: { [key: string]: string }, [, curr]) => {\n if (!curr) {\n return acc;\n }\n\n acc[curr.getKey()] = attrs[curr.getKey()];\n return acc;\n },\n {},\n );\n\n const parentOfNode = node.parent!;\n const previousNode = node.prevSibling || node.parent!;\n\n if (Object.keys(affectedAttrs).length > 0) {\n changes.push({\n type: TreeChangeType.Style,\n from: this.toIndex(parentOfNode, previousNode),\n to: this.toIndex(node, node),\n fromPath: this.toPath(parentOfNode, previousNode),\n toPath: this.toPath(node, node),\n actor: editedAt.getActorID(),\n value: affectedAttrs,\n });\n }\n\n for (const [prev] of updatedAttrPairs) {\n if (prev) {\n pairs.push({ parent: node, child: prev });\n }\n }\n }\n },\n );\n\n return [createdAtMapByActor, pairs, changes];\n }\n\n /**\n * `removeStyle` removes the given attributes of the given range.\n */\n public removeStyle(\n range: [CRDTTreePos, CRDTTreePos],\n attributesToRemove: Array<string>,\n editedAt: TimeTicket,\n maxCreatedAtMapByActor?: Map<string, TimeTicket>,\n versionVector?: VersionVector,\n ): [Map<string, TimeTicket>, Array<GCPair>, Array<TreeChange>] {\n const [fromParent, fromLeft] = this.findNodesAndSplitText(\n range[0],\n editedAt,\n );\n const [toParent, toLeft] = this.findNodesAndSplitText(range[1], editedAt);\n\n const changes: Array<TreeChange> = [];\n const createdAtMapByActor = new Map<string, TimeTicket>();\n const pairs: Array<GCPair> = [];\n this.traverseInPosRange(\n fromParent,\n fromLeft,\n toParent,\n toLeft,\n ([node]) => {\n const actorID = node.getCreatedAt().getActorID();\n let maxCreatedAt: TimeTicket | undefined;\n let clientLamportAtChange = 0n;\n if (\n versionVector === undefined &&\n maxCreatedAtMapByActor === undefined\n ) {\n // Local edit - use version vector comparison\n clientLamportAtChange = MaxLamport;\n } else if (versionVector!.size() > 0) {\n clientLamportAtChange = versionVector!.get(actorID)\n ? versionVector!.get(actorID)!\n : 0n;\n } else {\n maxCreatedAt = maxCreatedAtMapByActor!.has(actorID)\n ? maxCreatedAtMapByActor!.get(actorID)\n : InitialTimeTicket;\n }\n\n if (\n node.canStyle(editedAt, maxCreatedAt, clientLamportAtChange) &&\n attributesToRemove\n ) {\n const maxCreatedAt = createdAtMapByActor!.get(actorID);\n const createdAt = node.getCreatedAt();\n if (!maxCreatedAt || createdAt.after(maxCreatedAt)) {\n createdAtMapByActor.set(actorID, createdAt);\n }\n\n if (!node.attrs) {\n node.attrs = new RHT();\n }\n\n for (const value of attributesToRemove) {\n const nodesTobeRemoved = node.attrs.remove(value, editedAt);\n for (const rhtNode of nodesTobeRemoved) {\n pairs.push({ parent: node, child: rhtNode });\n }\n }\n\n const parentOfNode = node.parent!;\n const previousNode = node.prevSibling || node.parent!;\n\n changes.push({\n actor: editedAt.getActorID()!,\n type: TreeChangeType.RemoveStyle,\n from: this.toIndex(parentOfNode, previousNode),\n to: this.toIndex(node, node),\n fromPath: this.toPath(parentOfNode, previousNode),\n toPath: this.toPath(node, node),\n value: attributesToRemove,\n });\n }\n },\n );\n\n return [createdAtMapByActor, pairs, changes];\n }\n\n /**\n * `edit` edits the tree with the given range and content.\n * If the content is undefined, the range will be removed.\n */\n public edit(\n range: [CRDTTreePos, CRDTTreePos],\n contents: Array<CRDTTreeNode> | undefined,\n splitLevel: number,\n editedAt: TimeTicket,\n issueTimeTicket: (() => TimeTicket) | undefined,\n maxCreatedAtMapByActor?: Map<string, TimeTicket>,\n versionVector?: VersionVector,\n ): [Array<TreeChange>, Array<GCPair>, Map<string, TimeTicket>] {\n // 01. find nodes from the given range and split nodes.\n const [fromParent, fromLeft] = this.findNodesAndSplitText(\n range[0],\n editedAt,\n );\n const [toParent, toLeft] = this.findNodesAndSplitText(range[1], editedAt);\n\n const fromIdx = this.toIndex(fromParent, fromLeft);\n const fromPath = this.toPath(fromParent, fromLeft);\n\n const nodesToBeRemoved: Array<CRDTTreeNode> = [];\n const tokensToBeRemoved: Array<TreeToken<CRDTTreeNode>> = [];\n const toBeMovedToFromParents: Array<CRDTTreeNode> = [];\n const maxCreatedAtMap = new Map<string, TimeTicket>();\n this.traverseInPosRange(\n fromParent,\n fromLeft,\n toParent,\n toLeft,\n ([node, tokenType], ended) => {\n // NOTE(hackerwins): If the node overlaps as a start tag with the\n // range then we need to move the remaining children to fromParent.\n if (tokenType === TokenType.Start && !ended) {\n // TODO(hackerwins): Define more clearly merge-able rules\n // between two parents. For now, we only merge two parents are\n // both element nodes having text children.\n // e.g. <p>a|b</p><p>c|d</p> -> <p>a|d</p>\n // if (!fromParent.hasTextChild() || !toParent.hasTextChild()) {\n // return;\n // }\n\n for (const child of node.children) {\n toBeMovedToFromParents.push(child);\n }\n }\n\n const actorID = node.getCreatedAt().getActorID();\n let maxCreatedAt: TimeTicket | undefined;\n let clientLamportAtChange = 0n;\n if (\n versionVector === undefined &&\n maxCreatedAtMapByActor === undefined\n ) {\n // Local edit - use version vector comparison\n clientLamportAtChange = MaxLamport;\n } else if (versionVector!.size() > 0) {\n clientLamportAtChange = versionVector!.get(actorID)\n ? versionVector!.get(actorID)!\n : 0n;\n } else {\n maxCreatedAt = maxCreatedAtMapByActor!.has(actorID)\n ? maxCreatedAtMapByActor!.get(actorID)\n : InitialTimeTicket;\n }\n\n // NOTE(sejongk): If the node is removable or its parent is going to\n // be removed, then this node should be removed.\n if (\n node.canDelete(editedAt, maxCreatedAt, clientLamportAtChange) ||\n nodesToBeRemoved.includes(node.parent!)\n ) {\n const maxCreatedAt = maxCreatedAtMap.get(actorID);\n const createdAt = node.getCreatedAt();\n\n if (!maxCreatedAt || createdAt.after(maxCreatedAt)) {\n maxCreatedAtMap.set(actorID, createdAt);\n }\n\n // NOTE(hackerwins): If the node overlaps as an end token with the\n // range then we need to keep the node.\n if (tokenType === TokenType.Text || tokenType === TokenType.Start) {\n nodesToBeRemoved.push(node);\n }\n tokensToBeRemoved.push([node, tokenType]);\n }\n },\n );\n\n // NOTE(hackerwins): If concurrent deletion happens, we need to separate the\n // range(from, to) into multiple ranges.\n const changes: Array<TreeChange> = this.makeDeletionChanges(\n tokensToBeRemoved,\n editedAt,\n );\n\n // 02. Delete: delete the nodes that are marked as removed.\n const pairs: Array<GCPair> = [];\n for (const node of nodesToBeRemoved) {\n node.remove(editedAt);\n if (node.isRemoved) {\n pairs.push({ parent: this, child: node });\n }\n }\n\n // 03. Merge: move the nodes that are marked as moved.\n for (const node of toBeMovedToFromParents) {\n if (!node.removedAt) {\n fromParent.append(node);\n }\n }\n\n // 04. Split: split the element nodes for the given split level.\n if (splitLevel > 0) {\n let splitCount = 0;\n let parent = fromParent;\n let left = fromLeft;\n while (splitCount < splitLevel) {\n parent.split(this, parent.findOffset(left) + 1, issueTimeTicket);\n left = parent;\n parent = parent.parent!;\n splitCount++;\n }\n changes.push({\n type: TreeChangeType.Content,\n from: fromIdx,\n to: fromIdx,\n fromPath,\n toPath: fromPath,\n actor: editedAt.getActorID(),\n });\n }\n\n // 05. Insert: insert the given nodes at the given position.\n if (contents?.length) {\n const aliveContents: Array<CRDTTreeNode> = [];\n let leftInChildren = fromLeft; // tree\n for (const content of contents) {\n // 05-1. Insert the content nodes to the tree.\n if (leftInChildren === fromParent) {\n // 05-1-1. when there's no leftSibling, then insert content into very front of parent's children.\n fromParent.insertAt(content, 0);\n } else {\n // 05-1-2. insert after leftSibling\n fromParent.insertAfter(content, leftInChildren);\n }\n\n leftInChildren = content;\n traverseAll(content, (node) => {\n // If insertion happens during concurrent editing and parent node has been removed,\n // make new nodes as tombstone immediately.\n if (fromParent.isRemoved) {\n node.remove(editedAt);\n\n pairs.push({ parent: this, child: node });\n }\n\n this.nodeMapByID.put(node.id, node);\n });\n\n if (!content.isRemoved) {\n aliveContents.push(content);\n }\n }\n if (aliveContents.length) {\n const value = aliveContents.map((content) => toTreeNode(content));\n if (changes.length && changes[changes.length - 1].from === fromIdx) {\n changes[changes.length - 1].value = value;\n } else {\n changes.push({\n type: TreeChangeType.Content,\n from: fromIdx,\n to: fromIdx,\n fromPath,\n toPath: fromPath,\n actor: editedAt.getActorID(),\n value,\n });\n }\n }\n }\n\n return [changes, pairs, maxCreatedAtMap];\n }\n\n /**\n * `editT` edits the given range with the given value.\n * This method uses indexes instead of a pair of TreePos for testing.\n */\n public editT(\n range: [number, number],\n contents: Array<CRDTTreeNode> | undefined,\n splitLevel: number,\n editedAt: TimeTicket,\n issueTimeTicket: () => TimeTicket,\n ): void {\n const fromPos = this.findPos(range[0]);\n const toPos = this.findPos(range[1]);\n this.edit(\n [fromPos, toPos],\n contents,\n splitLevel,\n editedAt,\n issueTimeTicket,\n );\n }\n\n /**\n * `move` move the given source range to the given target range.\n */\n public move(\n target: [number, number],\n source: [number, number],\n ticket: TimeTicket,\n ): void {\n // TODO(hackerwins, easylogic): Implement this with keeping references of the nodes.\n throw new YorkieError(\n Code.ErrUnimplemented,\n `not implemented: ${target}, ${source}, ${ticket}`,\n );\n }\n\n /**\n * `purge` physically purges the given node.\n */\n public purge(node: CRDTTreeNode): void {\n node.parent?.removeChild(node);\n this.nodeMapByID.remove(node.id);\n\n const insPrevID = node.insPrevID;\n const insNextID = node.insNextID;\n\n if (insPrevID) {\n const insPrev = this.findFloorNode(insPrevID)!;\n insPrev.insNextID = insNextID;\n }\n\n if (insNextID) {\n const insNext = this.findFloorNode(insNextID)!;\n insNext.insPrevID = insPrevID;\n }\n\n node.insPrevID = undefined;\n node.insNextID = undefined;\n }\n\n /**\n * `getGCPairs` returns the pairs of GC.\n */\n public getGCPairs(): Array<GCPair> {\n const pairs: Array<GCPair> = [];\n this.indexTree.traverse((node) => {\n if (node.getRemovedAt()) {\n pairs.push({ parent: this, child: node });\n }\n\n for (const p of node.getGCPairs()) {\n pairs.push(p);\n }\n });\n\n return pairs;\n }\n\n /**\n * `findPos` finds the position of the given index in the tree.\n */\n public findPos(index: number, preferText = true): CRDTTreePos {\n const treePos = this.indexTree.findTreePos(index, preferText);\n return CRDTTreePos.fromTreePos(treePos);\n }\n\n /**\n * `pathToPosRange` converts the given path of the node to the range of the position.\n */\n public pathToPosRange(path: Array<number>): [CRDTTreePos, CRDTTreePos] {\n const fromIdx = this.pathToIndex(path);\n return [this.findPos(fromIdx), this.findPos(fromIdx + 1)];\n }\n\n /**\n * `pathToPos` finds the position of the given index in the tree by path.\n */\n public pathToPos(path: Array<number>): CRDTTreePos {\n const index = this.indexTree.pathToIndex(path);\n return this.findPos(index);\n }\n\n /**\n * `getRoot` returns the root node of the tree.\n */\n public getRoot(): CRDTTreeNode {\n return this.indexTree.getRoot();\n }\n\n /**\n * `getSize` returns the size of the tree.\n */\n public getSize(): number {\n return this.indexTree.size;\n }\n\n /**\n * `getNodeSize` returns the size of the LLRBTree.\n */\n public getNodeSize(): number {\n return this.nodeMapByID.size();\n }\n\n /**\n * `getIndexTree` returns the index tree.\n */\n public getIndexTree(): IndexTree<CRDTTreeNode> {\n return this.indexTree;\n }\n\n /**\n * toXML returns the XML encoding of this tree.\n */\n public toXML(): string {\n return toXML(this.indexTree.getRoot());\n }\n\n /**\n * `toJSON` returns the JSON encoding of this tree.\n */\n public toJSON(): string {\n return JSON.stringify(this.getRootTreeNode());\n }\n\n /**\n * `toJSForTest` returns value with meta data for testing.\n *\n * @internal\n */\n public toJSForTest(): Devtools.JSONElement {\n return {\n createdAt: this.getCreatedAt().toTestString(),\n value: JSON.parse(this.toJSON()),\n type: 'YORKIE_TREE',\n };\n }\n\n /**\n * `toJSInfoForTest` returns detailed TreeNode information for use in Devtools.\n *\n * @internal\n */\n public toJSInfoForTest(): Devtools.TreeNodeInfo {\n const rootNode = this.indexTree.getRoot();\n\n const toTreeNodeInfo = (\n node: CRDTTreeNode,\n parentNode: CRDTTreeNode | undefined = undefined,\n leftChildNode: CRDTTreeNode | undefined = undefined,\n depth = 0,\n ): Devtools.TreeNodeInfo => {\n let index, path, pos;\n\n const treePos = node.isText\n ? { node, offset: 0 }\n : parentNode && leftChildNode\n ? this.toTreePos(parentNode, leftChildNode)\n : null;\n\n if (treePos) {\n index = this.indexTree.indexOf(treePos);\n path = this.indexTree.treePosToPath(treePos);\n pos = CRDTTreePos.fromTreePos(treePos).toStruct();\n }\n\n const nodeInfo: Devtools.TreeNodeInfo = {\n type: node.type,\n parent: parentNode?.id.toTestString(),\n size: node.size,\n id: node.id.toTestString(),\n removedAt: node.removedAt?.toTestString(),\n insPrev: node.insPrevID?.toTestString(),\n insNext: node.insNextID?.toTestString(),\n value: node.isText ? node.value : undefined,\n isRemoved: node.isRemoved,\n children: [] as Array<Devtools.TreeNodeInfo>,\n depth,\n attributes: node.attrs\n ? parseObjectValues(node.attrs?.toObject())\n : undefined,\n index,\n path,\n pos,\n };\n\n for (let i = 0; i < node.allChildren.length; i++) {\n const leftChildNode = i === 0 ? node : node.allChildren[i - 1];\n nodeInfo.children.push(\n toTreeNodeInfo(node.allChildren[i], node, leftChildNode, depth + 1),\n );\n }\n\n return nodeInfo;\n };\n\n return toTreeNodeInfo(rootNode);\n }\n\n /**\n * `getRootTreeNode` returns the converted value of this tree to TreeNode.\n */\n public getRootTreeNode(): TreeNode {\n return toTreeNode(this.indexTree.getRoot());\n }\n\n /**\n * `toTestTreeNode` returns the JSON of this tree for debugging.\n */\n public toTestTreeNode(): TreeNodeForTest {\n return toTestTreeNode(this.indexTree.getRoot());\n }\n\n /**\n * `toSortedJSON` returns the sorted JSON encoding of this tree.\n */\n public toSortedJSON(): string {\n return this.toJSON();\n }\n\n /**\n * `deepcopy` copies itself deeply.\n */\n public deepcopy(): CRDTTree {\n const root = this.getRoot();\n return new CRDTTree(root.deepcopy(), this.getCreatedAt());\n }\n\n /**\n * `toPath` converts the given CRDTTreeNodeID to the path of the tree.\n */\n public toPath(\n parentNode: CRDTTreeNode,\n leftNode: CRDTTreeNode,\n ): Array<number> {\n const treePos = this.toTreePos(parentNode, leftNode);\n if (!treePos) {\n return [];\n }\n\n return this.indexTree.treePosToPath(treePos);\n }\n\n /**\n * `toIndex` converts the given CRDTTreeNodeID to the index of the tree.\n */\n public toIndex(parentNode: CRDTTreeNode, leftNode: CRDTTreeNode): number {\n const treePos = this.toTreePos(parentNode, leftNode);\n if (!treePos) {\n return -1;\n }\n\n return this.indexTree.indexOf(treePos);\n }\n\n /**\n * `indexToPath` converts the given tree index to path.\n */\n public indexToPath(index: number): Array<number> {\n return this.indexTree.indexToPath(index);\n }\n\n /**\n * `pathToIndex` converts the given path to index.\n */\n public pathToIndex(path: Array<number>): number {\n return this.indexTree.pathToIndex(path);\n }\n\n /**\n * `indexRangeToPosRange` returns the position range from the given index range.\n */\n public indexRangeToPosRange(range: [number, number]): TreePosRange {\n const fromPos = this.findPos(range[0]);\n if (range[0] === range[1]) {\n return [fromPos, fromPos];\n }\n return [fromPos, this.findPos(range[1])];\n }\n\n /**\n * `indexRangeToPosStructRange` converts the integer index range into the Tree position range structure.\n */\n public indexRangeToPosStructRange(\n range: [number, number],\n ): TreePosStructRange {\n const [fromIdx, toIdx] = range;\n const fromPos = this.findPos(fromIdx);\n if (fromIdx === toIdx) {\n return [fromPos.toStruct(), fromPos.toStruct()];\n }\n\n return [fromPos.toStruct(), this.findPos(toIdx).toStruct()];\n }\n\n /**\n * `posRangeToPathRange` converts the given position range to the path range.\n */\n public posRangeToPathRange(\n range: TreePosRange,\n ): [Array<number>, Array<number>] {\n const [fromParent, fromLeft] = this.findNodesAndSplitText(range[0]);\n const [toParent, toLeft] = this.findNodesAndSplitText(range[1]);\n return [this.toPath(fromParent, fromLeft), this.toPath(toParent, toLeft)];\n }\n\n /**\n * `posRangeToIndexRange` converts the given position range to the path range.\n */\n public posRangeToIndexRange(range: TreePosRange): [number, number] {\n const [fromParent, fromLeft] = this.findNodesAndSplitText(range[0]);\n const [toParent, toLeft] = this.findNodesAndSplitText(range[1]);\n return [this.toIndex(fromParent, fromLeft), this.toIndex(toParent, toLeft)];\n }\n\n /**\n * `traverseInPosRange` traverses the tree in the given position range.\n */\n private traverseInPosRange(\n fromParent: CRDTTreeNode,\n fromLeft: CRDTTreeNode,\n toParent: CRDTTreeNode,\n toLeft: CRDTTreeNode,\n callback: (token: TreeToken<CRDTTreeNode>, ended: boolean) => void,\n ): void {\n const fromIdx = this.toIndex(fromParent, fromLeft);\n const toIdx = this.toIndex(toParent, toLeft);\n return this.indexTree.tokensBetween(fromIdx, toIdx, callback);\n }\n\n /**\n * `toTreePos` converts the given nodes to the position of the IndexTree.\n */\n private toTreePos(\n parentNode: CRDTTreeNode,\n leftNode: CRDTTreeNode,\n ): TreePos<CRDTTreeNode> | undefined {\n if (!parentNode || !leftNode) {\n return;\n }\n\n if (parentNode.isRemoved) {\n let childNode: CRDTTreeNode;\n while (parentNode.isRemoved) {\n childNode = parentNode;\n parentNode = childNode.parent!;\n }\n\n const offset = parentNode.findOffset(childNode!);\n return {\n node: parentNode,\n offset,\n };\n }\n\n if (parentNode === leftNode) {\n return {\n node: parentNode,\n offset: 0,\n };\n }\n\n let offset = parentNode.findOffset(leftNode);\n if (!leftNode.isRemoved) {\n if (leftNode.isText) {\n return {\n node: leftNode,\n offset: leftNode.paddedSize,\n };\n }\n\n offset++;\n }\n\n return {\n node: parentNode,\n offset,\n };\n }\n\n /**\n * `makeDeletionChanges` converts nodes to be deleted to deletion changes.\n */\n private makeDeletionChanges(\n candidates: Array<TreeToken<CRDTTreeNode>>,\n editedAt: TimeTicket,\n ): Array<TreeChange> {\n const changes: Array<TreeChange> = [];\n const ranges: Array<Array<TreeToken<CRDTTreeNode>>> = [];\n\n // Generate ranges by accumulating consecutive nodes.\n let start = null;\n let end = null;\n for (let i = 0; i < candidates.length; i++) {\n const cur = candidates[i];\n const next = candidates[i + 1];\n if (!start) {\n start = cur;\n }\n end = cur;\n\n const rightToken = this.findRightToken(cur);\n if (\n !rightToken ||\n !next ||\n rightToken[0] !== next[0] ||\n rightToken[1] !== next[1]\n ) {\n ranges.push([start, end]);\n start = null;\n end = null;\n }\n }\n\n // Convert each range to a deletion change.\n for (const range of ranges) {\n const [start, end] = range;\n const [fromLeft, fromLeftTokenType] = this.findLeftToken(start);\n const [toLeft, toLeftTokenType] = end;\n const fromParent =\n fromLeftTokenType === TokenType.Start ? fromLeft : fromLeft.parent!;\n const toParent =\n toLeftTokenType === TokenType.Start ? toLeft : toLeft.parent!;\n\n const fromIdx = this.toIndex(fromParent, fromLeft);\n const toIdx = this.toIndex(toParent, toLeft);\n if (fromIdx < toIdx) {\n // When the range is overlapped with the previous one, compact them.\n if (changes.length > 0 && fromIdx === changes[changes.length - 1].to) {\n changes[changes.length - 1].to = toIdx;\n changes[changes.length - 1].toPath = this.toPath(toParent, toLeft);\n } else {\n changes.push({\n type: TreeChangeType.Content,\n from: fromIdx,\n to: toIdx,\n fromPath: this.toPath(fromParent, fromLeft),\n toPath: this.toPath(toParent, toLeft),\n actor: editedAt.getActorID(),\n });\n }\n }\n }\n return changes.reverse();\n }\n\n /**\n * `findRightToken` returns the token to the right of the given token in the tree.\n */\n private findRightToken([\n node,\n tokenType,\n ]: TreeToken<CRDTTreeNode>): TreeToken<CRDTTreeNode> {\n if (tokenType === TokenType.Start) {\n const children = node.allChildren;\n if (children.length > 0) {\n return [\n children[0],\n children[0].isText ? TokenType.Text : TokenType.Start,\n ];\n }\n return [node, TokenType.End];\n }\n\n const parent = node.parent!;\n const siblings = parent.allChildren;\n const offset = siblings.indexOf(node);\n if (parent && offset === siblings.length - 1) {\n return [parent, TokenType.End];\n }\n\n const next = siblings[offset + 1];\n return [next, next.isText ? TokenType.Text : TokenType.Start];\n }\n\n /**\n * `findLeftToken` returns the token to the left of the given token in the tree.\n */\n private findLeftToken([\n node,\n tokenType,\n ]: TreeToken<CRDTTreeNode>): TreeToken<CRDTTreeNode> {\n if (tokenType === TokenType.End) {\n const children = node.allChildren;\n if (children.length > 0) {\n const lastChild = children[children.length - 1];\n return [lastChild, lastChild.isText ? TokenType.Text : TokenType.End];\n }\n\n return [node, TokenType.Start];\n }\n\n const parent = node.parent!;\n const siblings = parent.allChildren;\n const offset = siblings.indexOf(node);\n if (parent && offset === 0) {\n return [parent, TokenType.Start];\n }\n\n const prev = siblings[offset - 1];\n return [prev, prev.isText ? TokenType.Text : TokenType.End];\n }\n}\n","/*\n * Copyright 2023 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { VersionVector } from '@yorkie-js-sdk/src/document/time/version_vector';\nimport { CRDTRoot } from '@yorkie-js-sdk/src/document/crdt/root';\nimport {\n CRDTTree,\n CRDTTreeNode,\n CRDTTreePos,\n toXML,\n} from '@yorkie-js-sdk/src/document/crdt/tree';\nimport {\n Operation,\n OperationInfo,\n ExecutionResult,\n OpSource,\n} from '@yorkie-js-sdk/src/document/operation/operation';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\n\n/**\n * `TreeEditOperation` is an operation representing Tree editing.\n */\nexport class TreeEditOperation extends Operation {\n private fromPos: CRDTTreePos;\n private toPos: CRDTTreePos;\n private contents: Array<CRDTTreeNode> | undefined;\n private splitLevel: number;\n private maxCreatedAtMapByActor: Map<string, TimeTicket>;\n\n constructor(\n parentCreatedAt: TimeTicket,\n fromPos: CRDTTreePos,\n toPos: CRDTTreePos,\n contents: Array<CRDTTreeNode> | undefined,\n splitLevel: number,\n maxCreatedAtMapByActor: Map<string, TimeTicket>,\n executedAt: TimeTicket,\n ) {\n super(parentCreatedAt, executedAt);\n this.fromPos = fromPos;\n this.toPos = toPos;\n this.contents = contents;\n this.splitLevel = splitLevel;\n this.maxCreatedAtMapByActor = maxCreatedAtMapByActor;\n }\n\n /**\n * `create` creates a new instance of EditOperation.\n */\n public static create(\n parentCreatedAt: TimeTicket,\n fromPos: CRDTTreePos,\n toPos: CRDTTreePos,\n contents: Array<CRDTTreeNode> | undefined,\n splitLevel: number,\n maxCreatedAtMapByActor: Map<string, TimeTicket>,\n executedAt: TimeTicket,\n ): TreeEditOperation {\n return new TreeEditOperation(\n parentCreatedAt,\n fromPos,\n toPos,\n contents,\n splitLevel,\n maxCreatedAtMapByActor,\n executedAt,\n );\n }\n\n /**\n * `execute` executes this operation on the given `CRDTRoot`.\n */\n public execute(\n root: CRDTRoot,\n _: OpSource,\n versionVector?: VersionVector,\n ): ExecutionResult {\n const parentObject = root.findByCreatedAt(this.getParentCreatedAt());\n if (!parentObject) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to find ${this.getParentCreatedAt()}`,\n );\n }\n if (!(parentObject instanceof CRDTTree)) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to execute, only Tree can execute edit`,\n );\n }\n const editedAt = this.getExecutedAt();\n const tree = parentObject as CRDTTree;\n const [changes, pairs] = tree.edit(\n [this.fromPos, this.toPos],\n this.contents?.map((content) => content.deepcopy()),\n this.splitLevel,\n editedAt,\n /**\n * TODO(sejongk): When splitting element nodes, a new nodeID is assigned with a different timeTicket.\n * In the same change context, the timeTickets share the same lamport and actorID but have different delimiters,\n * incremented by one for each.\n * Therefore, it is possible to simulate later timeTickets using `editedAt` and the length of `contents`.\n * This logic might be unclear; consider refactoring for multi-level concurrent editing in the Tree implementation.\n */\n (() => {\n let delimiter = editedAt.getDelimiter();\n if (this.contents !== undefined) {\n delimiter += this.contents.length;\n }\n const issueTimeTicket = () =>\n TimeTicket.of(\n editedAt.getLamport(),\n ++delimiter,\n editedAt.getActorID(),\n );\n return issueTimeTicket;\n })(),\n this.maxCreatedAtMapByActor,\n versionVector,\n );\n\n for (const pair of pairs) {\n root.registerGCPair(pair);\n }\n\n return {\n opInfos: changes.map(\n ({ from, to, value, splitLevel, fromPath, toPath }) => {\n return {\n type: 'tree-edit',\n path: root.createPath(this.getParentCreatedAt()),\n from,\n to,\n value,\n splitLevel,\n fromPath,\n toPath,\n } as OperationInfo;\n },\n ),\n };\n }\n\n /**\n * `getEffectedCreatedAt` returns the creation time of the effected element.\n */\n public getEffectedCreatedAt(): TimeTicket {\n return this.getParentCreatedAt();\n }\n\n /**\n * `toTestString` returns a string containing the meta data.\n */\n public toTestString(): string {\n const parent = this.getParentCreatedAt().toTestString();\n const fromPos = `${this.fromPos\n .getLeftSiblingID()\n .getCreatedAt()\n .toTestString()}/${this.fromPos.getLeftSiblingID().getOffset()}`;\n const toPos = `${this.toPos\n .getLeftSiblingID()\n .getCreatedAt()\n .toTestString()}/${this.toPos.getLeftSiblingID().getOffset()}`;\n const contents = this.contents || [];\n return `${parent}.EDIT(${fromPos},${toPos},${contents\n .map((v) => toXML(v))\n .join('')})`;\n }\n\n /**\n * `getFromPos` returns the start point of the editing range.\n */\n public getFromPos(): CRDTTreePos {\n return this.fromPos;\n }\n\n /**\n * `getToPos` returns the end point of the editing range.\n */\n public getToPos(): CRDTTreePos {\n return this.toPos;\n }\n\n /**\n * `getContent` returns the content of Edit.\n */\n public getContents(): Array<CRDTTreeNode> | undefined {\n return this.contents;\n }\n\n /**\n * `getSplitLevel` returns the split level of Edit.\n */\n public getSplitLevel(): number {\n return this.splitLevel;\n }\n\n /**\n * `getMaxCreatedAtMapByActor` returns the map that stores the latest creation time\n * by actor for the nodes included in the editing range.\n */\n public getMaxCreatedAtMapByActor(): Map<string, TimeTicket> {\n return this.maxCreatedAtMapByActor;\n }\n}\n","/*\n * Copyright 2024 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TimeTicket } from './ticket';\n\n/**\n * `VersionVector` is a vector clock that is used to detect the relationship\n * between changes whether they are causally related or concurrent. It is\n * similar to vector clocks, but it is synced with lamport timestamp of the\n * change.\n */\nexport class VersionVector {\n private vector: Map<string, bigint>;\n\n constructor(vector?: Map<string, bigint>) {\n this.vector = vector || new Map();\n }\n\n /**\n * `set` sets the lamport timestamp of the given actor.\n */\n public set(actorID: string, lamport: bigint): void {\n this.vector.set(actorID, lamport);\n }\n\n /**\n * `unset` removes the version for the given actor from the VersionVector.\n */\n public unset(actorID: string): void {\n this.vector.delete(actorID);\n }\n\n /**\n * `get` gets the lamport timestamp of the given actor.\n */\n public get(actorID: string): bigint | undefined {\n return this.vector.get(actorID);\n }\n\n /**\n * `maxLamport` returns max lamport value from vector\n */\n public maxLamport() {\n let max = BigInt(0);\n\n for (const [, lamport] of this) {\n if (lamport > max) {\n max = lamport;\n }\n }\n\n return max;\n }\n\n /**\n * `max` returns new version vector which consists of max value of each vector\n */\n public max(other: VersionVector): VersionVector {\n const maxVector = new Map<string, bigint>();\n\n for (const [actorID, lamport] of other) {\n const currentLamport = this.vector.get(actorID);\n const maxLamport = currentLamport\n ? currentLamport > lamport\n ? currentLamport\n : lamport\n : lamport;\n\n maxVector.set(actorID, maxLamport);\n }\n\n for (const [actorID, lamport] of this) {\n const otherLamport = other.get(actorID);\n const maxLamport = otherLamport\n ? otherLamport > lamport\n ? otherLamport\n : lamport\n : lamport;\n\n maxVector.set(actorID, maxLamport);\n }\n\n return new VersionVector(maxVector);\n }\n\n /**\n * `afterOrEqual` returns vector[other.actorID] is greaterOrEqual than given ticket's lamport\n */\n public afterOrEqual(other: TimeTicket) {\n const lamport = this.vector.get(other.getActorID());\n\n if (lamport === undefined) {\n return false;\n }\n\n return lamport >= other.getLamport();\n }\n\n /**\n * `deepcopy` returns a deep copy of this `VersionVector`.\n */\n public deepcopy(): VersionVector {\n const copied = new Map<string, bigint>();\n for (const [key, value] of this.vector) {\n copied.set(key, value);\n }\n return new VersionVector(copied);\n }\n\n /**\n * `filter` returns new version vector consist of filter's actorID.\n */\n public filter(versionVector: VersionVector) {\n const filtered = new Map<string, bigint>();\n\n for (const [actorID] of versionVector) {\n const lamport = this.vector.get(actorID);\n\n if (lamport !== undefined) {\n filtered.set(actorID, lamport);\n }\n }\n\n return new VersionVector(filtered);\n }\n\n /**\n * `size` returns size of version vector\n */\n public size(): number {\n return this.vector.size;\n }\n\n // eslint-disable-next-line jsdoc/require-jsdoc\n public *[Symbol.iterator](): IterableIterator<[string, bigint]> {\n for (const [key, value] of this.vector) {\n yield [key, value];\n }\n }\n}\n\n/**\n * `InitialVersionVector` is the initial version vector.\n */\nexport const InitialVersionVector = new VersionVector(new Map());\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n ActorID,\n InitialActorID,\n} from '@yorkie-js-sdk/src/document/time/actor_id';\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { InitialVersionVector, VersionVector } from '../time/version_vector';\n\n/**\n * `ChangeID` is for identifying the Change. This is immutable.\n */\nexport class ChangeID {\n // `clientSeq` is the sequence number of the client that created this change.\n private clientSeq: number;\n // `serverSeq` is optional and only present for changes stored on the server.\n private serverSeq?: bigint;\n // `lamport` and `actor` are the lamport clock and the actor of this change.\n // This is used to determine the order of changes in logical time.\n private lamport: bigint;\n private actor: ActorID;\n // `versionVector` is the vector clock of this change. This is used to\n // determine the relationship is causal or not between changes.\n private versionVector: VersionVector;\n\n constructor(\n clientSeq: number,\n lamport: bigint,\n actor: ActorID,\n vector: VersionVector,\n serverSeq?: bigint,\n ) {\n this.clientSeq = clientSeq;\n this.serverSeq = serverSeq;\n this.lamport = lamport;\n this.versionVector = vector;\n this.actor = actor;\n }\n\n /**\n * `of` creates a new instance of ChangeID.\n */\n public static of(\n clientSeq: number,\n lamport: bigint,\n actor: ActorID,\n vector: VersionVector,\n serverSeq?: bigint,\n ): ChangeID {\n return new ChangeID(clientSeq, lamport, actor, vector, serverSeq);\n }\n\n /**\n * `next` creates a next ID of this ID.\n */\n public next(): ChangeID {\n const vector = this.versionVector.deepcopy();\n vector.set(this.actor, this.lamport + 1n);\n\n return new ChangeID(\n this.clientSeq + 1,\n this.lamport + 1n,\n this.actor,\n vector,\n );\n }\n\n /**\n * `syncClocks` syncs logical clocks with the given ID.\n */\n public syncClocks(other: ChangeID): ChangeID {\n const lamport =\n other.lamport > this.lamport ? other.lamport + 1n : this.lamport + 1n;\n\n // NOTE(chacha912): For changes created by legacy SDK prior to v0.5.2 that lack version\n // vectors, document's version vector was not being properly accumlated. To address this,\n // we generate a version vector using the lamport timestamp when no version vector exists.\n let otherVV = other.versionVector;\n if (otherVV.size() === 0) {\n otherVV = otherVV.deepcopy();\n otherVV.set(other.actor, other.lamport);\n }\n\n const maxVersionVector = this.versionVector.max(otherVV);\n const newID = new ChangeID(\n this.clientSeq,\n lamport,\n this.actor,\n maxVersionVector,\n );\n newID.versionVector.set(this.actor, lamport);\n return newID;\n }\n\n /**\n * `setClocks` sets the given clocks to this ID. This is used when the snapshot\n * is given from the server.\n */\n public setClocks(otherLamport: bigint, vector: VersionVector): ChangeID {\n const lamport =\n otherLamport > this.lamport ? otherLamport + 1n : this.lamport + 1n;\n\n // NOTE(chacha912): Documents created by server may have an InitialActorID\n // in their version vector. Although server is not an actual client, it\n // generates document snapshots from changes by participating with an\n // InitialActorID during document instance creation and accumulating stored\n // changes in DB.\n // Semantically, including a non-client actor in version vector is\n // problematic. To address this, we remove the InitialActorID from snapshots.\n vector.unset(InitialActorID);\n\n const maxVersionVector = this.versionVector.max(vector);\n maxVersionVector.set(this.actor, lamport);\n\n return ChangeID.of(this.clientSeq, lamport, this.actor, maxVersionVector);\n }\n\n /**\n * `createTimeTicket` creates a ticket of the given delimiter.\n */\n public createTimeTicket(delimiter: number): TimeTicket {\n return TimeTicket.of(this.lamport, delimiter, this.actor);\n }\n\n /**\n * `setActor` sets the given actor.\n */\n public setActor(actorID: ActorID): ChangeID {\n return new ChangeID(\n this.clientSeq,\n this.lamport,\n actorID,\n this.versionVector,\n this.serverSeq,\n );\n }\n\n /**\n * `setVersionVector` sets the given version vector.\n */\n public setVersionVector(versionVector: VersionVector): ChangeID {\n return new ChangeID(\n this.clientSeq,\n this.lamport,\n this.actor,\n versionVector,\n this.serverSeq,\n );\n }\n\n /**\n * `getClientSeq` returns the client sequence of this ID.\n */\n public getClientSeq(): number {\n return this.clientSeq;\n }\n\n /**\n * `getServerSeq` returns the server sequence of this ID.\n */\n public getServerSeq(): string {\n if (this.serverSeq) {\n return this.serverSeq.toString();\n }\n return '';\n }\n\n /**\n * `getLamport` returns the lamport clock of this ID.\n */\n public getLamport(): bigint {\n return this.lamport;\n }\n\n /**\n * `getLamportAsString` returns the lamport clock of this ID as a string.\n */\n public getLamportAsString(): string {\n return this.lamport.toString();\n }\n\n /**\n * `getActorID` returns the actor of this ID.\n */\n public getActorID(): string {\n return this.actor;\n }\n\n /**\n * `getVersionVector` returns the version vector of this ID.\n */\n public getVersionVector(): VersionVector {\n return this.versionVector;\n }\n\n /**\n * `toTestString` returns a string containing the meta data of this ID.\n */\n public toTestString(): string {\n return `${this.lamport.toString()}:${this.actor.slice(-2)}:${\n this.clientSeq\n }`;\n }\n}\n\n/**\n * `InitialChangeID` represents the initial state ID. Usually this is used to\n * represent a state where nothing has been edited.\n */\nexport const InitialChangeID = new ChangeID(\n 0,\n 0n,\n InitialActorID,\n InitialVersionVector,\n);\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ActorID } from '@yorkie-js-sdk/src/document/time/actor_id';\nimport {\n OpSource,\n Operation,\n OperationInfo,\n} from '@yorkie-js-sdk/src/document/operation/operation';\nimport { CRDTRoot } from '@yorkie-js-sdk/src/document/crdt/root';\nimport { ChangeID } from '@yorkie-js-sdk/src/document/change/change_id';\nimport { Indexable } from '@yorkie-js-sdk/src/document/document';\nimport { converter } from '@yorkie-js-sdk/src/api/converter';\nimport { HistoryOperation } from '@yorkie-js-sdk/src/document/history';\nimport {\n PresenceChange,\n PresenceChangeType,\n} from '@yorkie-js-sdk/src/document/presence/presence';\nimport { deepcopy } from '@yorkie-js-sdk/src/util/object';\n\n/**\n * `ChangeStruct` represents the structure of Change.\n * This is used to serialize and deserialize Change.\n */\nexport type ChangeStruct<P extends Indexable> = {\n changeID: string;\n message?: string;\n operations?: Array<string>;\n presenceChange?: {\n type: PresenceChangeType;\n presence?: P;\n };\n};\n\n/**\n * `Change` represents a unit of modification in the document.\n */\nexport class Change<P extends Indexable> {\n private id: ChangeID;\n\n // `operations` represent a series of user edits.\n private operations: Array<Operation>;\n\n // `presenceChange` represents the presenceChange of the user who made the change.\n private presenceChange?: PresenceChange<P>;\n\n // `message` is used to save a description of the change.\n private message?: string;\n\n constructor({\n id,\n operations,\n presenceChange,\n message,\n }: {\n id: ChangeID;\n operations?: Array<Operation>;\n presenceChange?: PresenceChange<P>;\n message?: string;\n }) {\n this.id = id;\n this.operations = operations || [];\n this.presenceChange = presenceChange;\n this.message = message;\n }\n\n /**\n * `create` creates a new instance of Change.\n */\n public static create<P extends Indexable>({\n id,\n operations,\n presenceChange,\n message,\n }: {\n id: ChangeID;\n operations?: Array<Operation>;\n presenceChange?: PresenceChange<P>;\n message?: string;\n }): Change<P> {\n return new Change({ id, operations, presenceChange, message });\n }\n\n /**\n * `getID` returns the ID of this change.\n */\n public getID(): ChangeID {\n return this.id;\n }\n\n /**\n * `getMessage` returns the message of this change.\n */\n public getMessage(): string | undefined {\n return this.message;\n }\n\n /**\n * `hasOperations` returns whether this change has operations or not.\n */\n public hasOperations(): boolean {\n return this.operations.length > 0;\n }\n\n /**\n * `getOperations` returns the operations of this change.\n */\n public getOperations(): Array<Operation> {\n return this.operations;\n }\n\n /**\n * `setActor` sets the given actor.\n */\n public setActor(actorID: ActorID): void {\n for (const operation of this.operations) {\n operation.setActor(actorID);\n }\n\n this.id = this.id.setActor(actorID);\n }\n\n /**\n * `hasPresenceChange` returns whether this change has presence change or not.\n */\n public hasPresenceChange(): boolean {\n return this.presenceChange !== undefined;\n }\n\n /**\n * `getPresenceChange` returns the presence change of this change.\n */\n public getPresenceChange(): PresenceChange<P> | undefined {\n return this.presenceChange;\n }\n\n /**\n * `execute` executes the operations of this change to the given root.\n */\n public execute(\n root: CRDTRoot,\n presences: Map<ActorID, P>,\n source: OpSource,\n ): {\n opInfos: Array<OperationInfo>;\n reverseOps: Array<HistoryOperation<P>>;\n } {\n const changeOpInfos: Array<OperationInfo> = [];\n const reverseOps: Array<HistoryOperation<P>> = [];\n\n for (const operation of this.operations) {\n const executionResult = operation.execute(\n root,\n source,\n this.id.getVersionVector(),\n );\n // NOTE(hackerwins): If the element was removed while executing undo/redo,\n // the operation is not executed and executionResult is undefined.\n if (!executionResult) continue;\n const { opInfos, reverseOp } = executionResult;\n changeOpInfos.push(...opInfos);\n\n // TODO(hackerwins): This condition should be removed after implementing\n // all reverse operations.\n if (reverseOp) {\n reverseOps.unshift(reverseOp);\n }\n }\n\n if (this.presenceChange) {\n if (this.presenceChange.type === PresenceChangeType.Put) {\n presences.set(\n this.id.getActorID(),\n deepcopy(this.presenceChange.presence),\n );\n } else {\n presences.delete(this.id.getActorID());\n }\n }\n\n return { opInfos: changeOpInfos, reverseOps };\n }\n\n /**\n * `toTestString` returns a string containing the meta data of this change.\n */\n public toTestString(): string {\n return `${this.operations\n .map((operation) => operation.toTestString())\n .join(',')}`;\n }\n\n /**\n * `toStruct` returns the structure of this change.\n */\n public toStruct(): ChangeStruct<P> {\n return {\n changeID: converter.bytesToHex(\n converter.toChangeID(this.getID()).toBinary(),\n ),\n message: this.getMessage(),\n operations: this.getOperations().map((op) =>\n converter.bytesToHex(converter.toOperation(op).toBinary()),\n ),\n presenceChange: this.getPresenceChange(),\n };\n }\n\n /**\n * `fromStruct` creates a instance of Change from the struct.\n */\n public static fromStruct<P extends Indexable>(\n struct: ChangeStruct<P>,\n ): Change<P> {\n const { changeID, operations, presenceChange, message } = struct;\n return Change.create<P>({\n id: converter.bytesToChangeID(converter.hexToBytes(changeID)),\n operations: operations?.map((op) => {\n return converter.bytesToOperation(converter.hexToBytes(op));\n }),\n presenceChange: presenceChange as any,\n message,\n });\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Indexable } from '@yorkie-js-sdk/src/document/document';\nimport { Checkpoint } from '@yorkie-js-sdk/src/document/change/checkpoint';\nimport { Change } from '@yorkie-js-sdk/src/document/change/change';\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { VersionVector } from '../time/version_vector';\n\n/**\n * `ChangePack` is a unit for delivering changes in a document to the remote.\n *\n */\nexport class ChangePack<P extends Indexable> {\n /**\n * `documentKey` is the key of the document.\n */\n private documentKey: string;\n\n /**\n * `Checkpoint` is used to determine the client received changes.\n */\n private checkpoint: Checkpoint;\n /**\n * `isRemoved` is a flag that indicates whether the document is removed.\n */\n private isRemoved: boolean;\n\n private changes: Array<Change<P>>;\n\n /**\n * `snapshot` is a byte array that encodes the document.\n */\n private snapshot?: Uint8Array;\n\n /**\n * `minSyncedTicket` is the minimum logical time taken by clients who attach\n * to the document. It is used to collect garbage on the replica on the\n * client.\n */\n private minSyncedTicket?: TimeTicket;\n\n /**\n * `versionVector` is the version vector current document\n */\n private versionVector?: VersionVector;\n\n constructor(\n key: string,\n checkpoint: Checkpoint,\n isRemoved: boolean,\n changes: Array<Change<P>>,\n versionVector?: VersionVector,\n snapshot?: Uint8Array,\n minSyncedTicket?: TimeTicket,\n ) {\n this.documentKey = key;\n this.checkpoint = checkpoint;\n this.isRemoved = isRemoved;\n this.changes = changes;\n this.snapshot = snapshot;\n this.minSyncedTicket = minSyncedTicket;\n this.versionVector = versionVector;\n }\n /**\n * `create` creates a new instance of ChangePack.\n */\n public static create<P extends Indexable>(\n key: string,\n checkpoint: Checkpoint,\n isRemoved: boolean,\n changes: Array<Change<P>>,\n versionVector?: VersionVector,\n snapshot?: Uint8Array,\n minSyncedTicket?: TimeTicket,\n ): ChangePack<P> {\n return new ChangePack<P>(\n key,\n checkpoint,\n isRemoved,\n changes,\n versionVector,\n snapshot,\n minSyncedTicket,\n );\n }\n\n /**\n * `getDocumentKey` returns the document key of this pack.\n */\n public getDocumentKey(): string {\n return this.documentKey;\n }\n\n /**\n * `getCheckpoint` returns the checkpoint of this pack.\n */\n public getCheckpoint(): Checkpoint {\n return this.checkpoint;\n }\n\n /**\n * `getIsRemoved` returns the whether this document is removed.\n */\n public getIsRemoved(): boolean {\n return this.isRemoved;\n }\n\n /**\n * `getChanges` returns the changes of this pack.\n */\n public getChanges(): Array<Change<P>> {\n return this.changes;\n }\n\n /**\n * `hasChanges` returns the whether this pack has changes or not.\n */\n public hasChanges(): boolean {\n return this.changes.length > 0;\n }\n\n /**\n * `getChangeSize` returns the size of changes this pack has.\n */\n public getChangeSize(): number {\n return this.changes.length;\n }\n\n /**\n * `hasSnapshot` returns the whether this pack has a snapshot or not.\n */\n public hasSnapshot(): boolean {\n return !!this.snapshot && !!this.snapshot.length;\n }\n\n /**\n * `getSnapshot` returns the snapshot of this pack.\n */\n public getSnapshot(): Uint8Array | undefined {\n return this.snapshot;\n }\n\n /**\n * `getMinSyncedTicket` returns the minimum synced ticket of this pack.\n */\n public getMinSyncedTicket(): TimeTicket | undefined {\n return this.minSyncedTicket;\n }\n\n /**\n * `getVersionVector` returns the document's version vector of this pack\n */\n public getVersionVector(): VersionVector | undefined {\n return this.versionVector;\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * `Checkpoint` is used to determine the changes sent and received by the\n * client. This is immutable.\n *\n **/\nexport class Checkpoint {\n private serverSeq: bigint;\n private clientSeq: number;\n\n constructor(serverSeq: bigint, clientSeq: number) {\n this.serverSeq = serverSeq;\n this.clientSeq = clientSeq;\n }\n\n /**\n * `of` creates a new instance of Checkpoint.\n */\n public static of(serverSeq: bigint, clientSeq: number): Checkpoint {\n return new Checkpoint(serverSeq, clientSeq);\n }\n\n /**\n * `increaseClientSeq` creates a new instance with increased client sequence.\n */\n public increaseClientSeq(inc: number): Checkpoint {\n if (inc === 0) {\n return this;\n }\n\n return new Checkpoint(this.serverSeq, this.clientSeq + inc);\n }\n\n /**\n * `forward` creates a new instance with the given checkpoint if it is\n * greater than the values of internal properties.\n */\n public forward(other: Checkpoint): Checkpoint {\n if (this.equals(other)) {\n return this;\n }\n\n const serverSeq =\n this.serverSeq > other.serverSeq ? this.serverSeq : other.serverSeq;\n const clientSeq = Math.max(this.clientSeq, other.clientSeq);\n return Checkpoint.of(serverSeq, clientSeq);\n }\n\n /**\n * `getServerSeqAsString` returns the server seq of this checkpoint as a\n * string.\n */\n public getServerSeqAsString(): string {\n return this.serverSeq.toString();\n }\n\n /**\n * `getClientSeq` returns the client seq of this checkpoint.\n */\n public getClientSeq(): number {\n return this.clientSeq;\n }\n\n /**\n * `getServerSeq` returns the server seq of this checkpoint.\n */\n public getServerSeq(): bigint {\n return this.serverSeq;\n }\n\n /**\n * `equals` returns whether the given checkpoint is equal to this checkpoint\n * or not.\n */\n public equals(other: Checkpoint): boolean {\n return (\n this.clientSeq === other.clientSeq && this.serverSeq == other.serverSeq\n );\n }\n\n /**\n * `toTestString` returns a string containing the meta data of this\n * checkpoint.\n */\n public toTestString(): string {\n return `serverSeq=${this.serverSeq}, clientSeq=${this.clientSeq}`;\n }\n}\n\n/**\n * `InitialCheckpoint` is the initial value of the checkpoint.\n */\nexport const InitialCheckpoint = new Checkpoint(0n, 0);\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ActorID } from '@yorkie-js-sdk/src/document/time/actor_id';\nimport { Comparator } from '@yorkie-js-sdk/src/util/comparator';\nimport { SplayNode, SplayTree } from '@yorkie-js-sdk/src/util/splay_tree';\nimport { LLRBTree } from '@yorkie-js-sdk/src/util/llrb_tree';\nimport {\n InitialTimeTicket,\n MaxLamport,\n TimeTicket,\n TimeTicketStruct,\n} from '@yorkie-js-sdk/src/document/time/ticket';\nimport { VersionVector } from '@yorkie-js-sdk/src/document/time/version_vector';\nimport { GCChild, GCPair, GCParent } from '@yorkie-js-sdk/src/document/crdt/gc';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\n\nexport interface ValueChange<T> {\n actor: ActorID;\n from: number;\n to: number;\n value?: T;\n}\n\ninterface RGATreeSplitValue {\n length: number;\n\n substring(indexStart: number, indexEnd?: number): RGATreeSplitValue;\n}\n\n/**\n * `RGATreeSplitPosStruct` is a structure represents the meta data of the node pos.\n * It is used to serialize and deserialize the node pos.\n */\nexport type RGATreeSplitPosStruct = {\n id: RGATreeSplitNodeIDStruct;\n relativeOffset: number;\n};\n\n/**\n * `RGATreeSplitNodeIDStruct` is a structure represents the meta data of the node id.\n * It is used to serialize and deserialize the node id.\n */\nexport type RGATreeSplitNodeIDStruct = {\n createdAt: TimeTicketStruct;\n offset: number;\n};\n\n/**\n * `RGATreeSplitNodeID` is an ID of RGATreeSplitNode.\n */\nexport class RGATreeSplitNodeID {\n private createdAt: TimeTicket;\n private offset: number;\n\n constructor(createdAt: TimeTicket, offset: number) {\n this.createdAt = createdAt;\n this.offset = offset;\n }\n\n /**\n * `of` creates a instance of RGATreeSplitNodeID.\n */\n public static of(createdAt: TimeTicket, offset: number): RGATreeSplitNodeID {\n return new RGATreeSplitNodeID(createdAt, offset);\n }\n\n /**\n * `fromStruct` creates a instance of RGATreeSplitNodeID from the struct.\n */\n public static fromStruct(\n struct: RGATreeSplitNodeIDStruct,\n ): RGATreeSplitNodeID {\n return RGATreeSplitNodeID.of(\n TimeTicket.fromStruct(struct.createdAt),\n struct.offset,\n );\n }\n\n /**\n * `getCreatedAt` returns the creation time of this ID.\n */\n public getCreatedAt(): TimeTicket {\n return this.createdAt;\n }\n\n /**\n * `getOffset` returns returns the offset of this ID.\n */\n public getOffset(): number {\n return this.offset;\n }\n\n /**\n * `equals` returns whether given ID equals to this ID or not.\n */\n public equals(other: RGATreeSplitNodeID): boolean {\n return (\n this.createdAt.compare(other.createdAt) === 0 &&\n this.offset === other.offset\n );\n }\n\n /**\n * `hasSameCreatedAt` returns whether given ID has same creation time with this ID.\n */\n public hasSameCreatedAt(other: RGATreeSplitNodeID): boolean {\n return this.createdAt.compare(other.createdAt) === 0;\n }\n\n /**\n * `split` creates a new ID with an offset from this ID.\n */\n public split(offset: number): RGATreeSplitNodeID {\n return new RGATreeSplitNodeID(this.createdAt, this.offset + offset);\n }\n\n /**\n * `toStruct` returns the structure of this node id.\n */\n public toStruct(): RGATreeSplitNodeIDStruct {\n return {\n createdAt: this.createdAt.toStruct(),\n offset: this.offset,\n };\n }\n\n /**\n * `toTestString` returns a String containing\n * the meta data of the node id for debugging purpose.\n */\n public toTestString(): string {\n return `${this.createdAt.toTestString()}:${this.offset}`;\n }\n\n /**\n * `toIDString` returns a string that can be used as an ID for this node id.\n */\n public toIDString(): string {\n return `${this.createdAt.toIDString()}:${this.offset}`;\n }\n}\n\nconst InitialRGATreeSplitNodeID = RGATreeSplitNodeID.of(InitialTimeTicket, 0);\n\n/**\n * `RGATreeSplitPos` is the position of the text inside the node.\n */\nexport class RGATreeSplitPos {\n private id: RGATreeSplitNodeID;\n private relativeOffset: number;\n\n constructor(id: RGATreeSplitNodeID, relativeOffset: number) {\n this.id = id;\n this.relativeOffset = relativeOffset;\n }\n\n /**\n * `of` creates a instance of RGATreeSplitPos.\n */\n public static of(\n id: RGATreeSplitNodeID,\n relativeOffset: number,\n ): RGATreeSplitPos {\n return new RGATreeSplitPos(id, relativeOffset);\n }\n\n /**\n * `fromStruct` creates a instance of RGATreeSplitPos from the struct.\n */\n public static fromStruct(struct: RGATreeSplitPosStruct): RGATreeSplitPos {\n const id = RGATreeSplitNodeID.fromStruct(struct.id);\n return RGATreeSplitPos.of(id, struct.relativeOffset);\n }\n\n /**\n * `getID` returns the ID of this RGATreeSplitPos.\n */\n public getID(): RGATreeSplitNodeID {\n return this.id;\n }\n\n /**\n * `getRelativeOffset` returns the relative offset of this RGATreeSplitPos.\n */\n public getRelativeOffset(): number {\n return this.relativeOffset;\n }\n\n /**\n * `getAbsoluteID` returns the absolute id of this RGATreeSplitPos.\n */\n public getAbsoluteID(): RGATreeSplitNodeID {\n return RGATreeSplitNodeID.of(\n this.id.getCreatedAt(),\n this.id.getOffset() + this.relativeOffset,\n );\n }\n\n /**\n *`toTestString` returns a String containing\n * the meta data of the position for debugging purpose.\n */\n public toTestString(): string {\n return `${this.id.toTestString()}:${this.relativeOffset}`;\n }\n\n /**\n * `toStruct` returns the structure of this node pos.\n */\n public toStruct(): RGATreeSplitPosStruct {\n return {\n id: this.id.toStruct(),\n relativeOffset: this.relativeOffset,\n };\n }\n\n /**\n * `equals` returns whether given pos equal to this pos or not.\n */\n public equals(other: RGATreeSplitPos): boolean {\n if (!this.id.equals(other.id)) {\n return false;\n }\n\n return this.relativeOffset === other.relativeOffset;\n }\n}\n\nexport type RGATreeSplitPosRange = [RGATreeSplitPos, RGATreeSplitPos];\n\n/**\n * `RGATreeSplitNode` is a node of RGATreeSplit.\n */\nexport class RGATreeSplitNode<T extends RGATreeSplitValue>\n extends SplayNode<T>\n implements GCChild\n{\n private id: RGATreeSplitNodeID;\n private removedAt?: TimeTicket;\n\n private prev?: RGATreeSplitNode<T>;\n private next?: RGATreeSplitNode<T>;\n private insPrev?: RGATreeSplitNode<T>;\n private insNext?: RGATreeSplitNode<T>;\n\n constructor(id: RGATreeSplitNodeID, value?: T, removedAt?: TimeTicket) {\n super(value!);\n this.id = id;\n this.removedAt = removedAt;\n }\n\n /**\n * `create` creates a instance of RGATreeSplitNode.\n */\n public static create<T extends RGATreeSplitValue>(\n id: RGATreeSplitNodeID,\n value?: T,\n ): RGATreeSplitNode<T> {\n return new RGATreeSplitNode(id, value);\n }\n\n /**\n * `createComparator` creates a function to compare two RGATreeSplitNodeID.\n */\n public static createComparator(): Comparator<RGATreeSplitNodeID> {\n return (p1: RGATreeSplitNodeID, p2: RGATreeSplitNodeID): number => {\n const compare = p1.getCreatedAt().compare(p2.getCreatedAt());\n if (compare !== 0) {\n return compare;\n }\n\n if (p1.getOffset() > p2.getOffset()) {\n return 1;\n } else if (p1.getOffset() < p2.getOffset()) {\n return -1;\n }\n return 0;\n };\n }\n\n /**\n * `getID` returns the ID of this RGATreeSplitNode.\n */\n public getID(): RGATreeSplitNodeID {\n return this.id;\n }\n\n /**\n * `getCreatedAt` returns creation time of the Id of RGATreeSplitNode.\n */\n public getCreatedAt(): TimeTicket {\n return this.id.getCreatedAt();\n }\n\n /**\n * `getLength` returns the length of this node.\n */\n public getLength(): number {\n if (this.removedAt) {\n return 0;\n }\n return this.getContentLength();\n }\n\n /**\n * `getContentLength` returns the length of this value.\n */\n public getContentLength(): number {\n return (this.value && this.value.length) || 0;\n }\n\n /**\n * `getPrev` returns a previous node of this node.\n */\n public getPrev(): RGATreeSplitNode<T> | undefined {\n return this.prev;\n }\n\n /**\n * `getNext` returns a next node of this node.\n */\n public getNext(): RGATreeSplitNode<T> | undefined {\n return this.next;\n }\n\n /**\n * `getInsPrev` returns a previous node of this node insertion.\n */\n public getInsPrev(): RGATreeSplitNode<T> | undefined {\n return this.insPrev;\n }\n\n /**\n * `getInsNext` returns a next node of this node insertion.\n */\n public getInsNext(): RGATreeSplitNode<T> | undefined {\n return this.insNext;\n }\n\n /**\n * `getInsPrevID` returns a ID of previous node insertion.\n */\n public getInsPrevID(): RGATreeSplitNodeID {\n return this.insPrev!.getID();\n }\n\n /**\n * `setPrev` sets previous node of this node.\n */\n public setPrev(node?: RGATreeSplitNode<T>): void {\n this.prev = node;\n if (node) {\n node.next = this;\n }\n }\n\n /**\n * `setNext` sets next node of this node.\n */\n public setNext(node?: RGATreeSplitNode<T>): void {\n this.next = node;\n if (node) {\n node.prev = this;\n }\n }\n\n /**\n * `setInsPrev` sets previous node of this node insertion.\n */\n public setInsPrev(node?: RGATreeSplitNode<T>): void {\n this.insPrev = node;\n if (node) {\n node.insNext = this;\n }\n }\n\n /**\n * `setInsNext` sets next node of this node insertion.\n */\n public setInsNext(node?: RGATreeSplitNode<T>): void {\n this.insNext = node;\n if (node) {\n node.insPrev = this;\n }\n }\n\n /**\n * `hasNext` checks if next node exists.\n */\n public hasNext(): boolean {\n return !!this.next;\n }\n\n /**\n * `hasInsPrev` checks if previous insertion node exists.\n */\n public hasInsPrev(): boolean {\n return !!this.insPrev;\n }\n\n /**\n * `isRemoved` checks if removed time exists.\n */\n public isRemoved(): boolean {\n return !!this.removedAt;\n }\n\n /**\n * `getRemovedAt` returns the remove time of this node.\n */\n public getRemovedAt(): TimeTicket | undefined {\n return this.removedAt;\n }\n\n /**\n * `split` creates a new split node of the given offset.\n */\n public split(offset: number): RGATreeSplitNode<T> {\n return new RGATreeSplitNode(\n this.id.split(offset),\n this.splitValue(offset),\n this.removedAt,\n );\n }\n\n /**\n * `canDelete` checks if node is able to delete.\n */\n public canDelete(\n editedAt: TimeTicket,\n maxCreatedAt: TimeTicket | undefined,\n clientLamportAtChange: bigint,\n ): boolean {\n const justRemoved = !this.removedAt;\n const nodeExisted = maxCreatedAt\n ? !this.getCreatedAt().after(maxCreatedAt)\n : this.getCreatedAt().getLamport() <= clientLamportAtChange;\n\n if (nodeExisted && (!this.removedAt || editedAt.after(this.removedAt))) {\n return justRemoved;\n }\n\n return false;\n }\n\n /**\n * `canStyle` checks if node is able to set style.\n */\n public canStyle(\n editedAt: TimeTicket,\n maxCreatedAt: TimeTicket | undefined,\n clientLamportAtChange: bigint,\n ): boolean {\n const nodeExisted = maxCreatedAt\n ? !this.getCreatedAt().after(maxCreatedAt)\n : this.getCreatedAt().getLamport() <= clientLamportAtChange;\n\n return nodeExisted && (!this.removedAt || editedAt.after(this.removedAt));\n }\n\n /**\n * `remove` removes node of given edited time.\n */\n public remove(editedAt?: TimeTicket): void {\n this.removedAt = editedAt;\n }\n\n /**\n * `createRange` creates ranges of RGATreeSplitPos.\n */\n public createPosRange(): RGATreeSplitPosRange {\n return [\n RGATreeSplitPos.of(this.id, 0),\n RGATreeSplitPos.of(this.id, this.getLength()),\n ];\n }\n\n /**\n * `deepcopy` returns a new instance of this RGATreeSplitNode without structural info.\n */\n public deepcopy(): RGATreeSplitNode<T> {\n return new RGATreeSplitNode(this.id, this.value, this.removedAt);\n }\n\n /**\n * `toTestString` returns a String containing\n * the meta data of the node for debugging purpose.\n */\n public toTestString(): string {\n return `${this.id.toTestString()} ${this.value ? this.value : ''}`;\n }\n\n private splitValue(offset: number): T {\n const value = this.value;\n this.value = value.substring(0, offset) as T;\n return value.substring(offset, value.length) as T;\n }\n\n /**\n * `toIDString` returns a string that can be used as an ID for this position.\n */\n public toIDString(): string {\n return this.id.toIDString();\n }\n}\n\n/**\n * `RGATreeSplit` is a block-based list with improved index-based lookup in RGA.\n * The difference from RGATreeList is that it has data on a block basis to\n * reduce the size of CRDT metadata. When an edit occurs on a block,\n * the block is split.\n *\n */\nexport class RGATreeSplit<T extends RGATreeSplitValue> implements GCParent {\n private head: RGATreeSplitNode<T>;\n private treeByIndex: SplayTree<T>;\n private treeByID: LLRBTree<RGATreeSplitNodeID, RGATreeSplitNode<T>>;\n\n constructor() {\n this.head = RGATreeSplitNode.create(InitialRGATreeSplitNodeID);\n this.treeByIndex = new SplayTree();\n this.treeByID = new LLRBTree(RGATreeSplitNode.createComparator());\n\n this.treeByIndex.insert(this.head);\n this.treeByID.put(this.head.getID(), this.head);\n }\n\n /**\n * `create` creates a instance RGATreeSplit.\n */\n public static create<T extends RGATreeSplitValue>(): RGATreeSplit<T> {\n return new RGATreeSplit();\n }\n\n /**\n * `edit` does following steps\n * 1. split nodes with from and to\n * 2. delete between from and to\n * 3. insert a new node\n * 4. add removed node\n * @param range - range of RGATreeSplitNode\n * @param editedAt - edited time\n * @param value - value\n * @param maxCreatedAtMapByActor - maxCreatedAtMapByActor\n * @returns `[RGATreeSplitPos, Map<string, TimeTicket>, Array<GCPair>, Array<Change>]`\n */\n public edit(\n range: RGATreeSplitPosRange,\n editedAt: TimeTicket,\n value?: T,\n maxCreatedAtMapByActor?: Map<string, TimeTicket>,\n versionVector?: VersionVector,\n ): [\n RGATreeSplitPos,\n Map<string, TimeTicket>,\n Array<GCPair>,\n Array<ValueChange<T>>,\n ] {\n // 01. split nodes with from and to\n const [toLeft, toRight] = this.findNodeWithSplit(range[1], editedAt);\n const [fromLeft, fromRight] = this.findNodeWithSplit(range[0], editedAt);\n\n // 02. delete between from and to\n const nodesToDelete = this.findBetween(fromRight, toRight);\n const [changes, maxCreatedAtMap, removedNodes] = this.deleteNodes(\n nodesToDelete,\n editedAt,\n maxCreatedAtMapByActor,\n versionVector,\n );\n\n const caretID = toRight ? toRight.getID() : toLeft.getID();\n let caretPos = RGATreeSplitPos.of(caretID, 0);\n\n // 03. insert a new node\n if (value) {\n const idx = this.posToIndex(fromLeft.createPosRange()[1], true);\n\n const inserted = this.insertAfter(\n fromLeft,\n RGATreeSplitNode.create(RGATreeSplitNodeID.of(editedAt, 0), value),\n );\n\n if (changes.length && changes[changes.length - 1].from === idx) {\n changes[changes.length - 1].value = value;\n } else {\n changes.push({\n actor: editedAt.getActorID(),\n from: idx,\n to: idx,\n value,\n });\n }\n\n caretPos = RGATreeSplitPos.of(\n inserted.getID(),\n inserted.getContentLength(),\n );\n }\n\n // 04. add removed node\n const pairs: Array<GCPair> = [];\n for (const [, removedNode] of removedNodes) {\n pairs.push({ parent: this, child: removedNode });\n }\n\n return [caretPos, maxCreatedAtMap, pairs, changes];\n }\n\n /**\n * `indexToPos` finds RGATreeSplitPos of given offset.\n */\n public indexToPos(idx: number): RGATreeSplitPos {\n const [node, offset] = this.treeByIndex.find(idx);\n const splitNode = node as RGATreeSplitNode<T>;\n return RGATreeSplitPos.of(splitNode.getID(), offset);\n }\n\n /**\n * `findIndexesFromRange` finds indexes based on range.\n */\n public findIndexesFromRange(range: RGATreeSplitPosRange): [number, number] {\n const [fromPos, toPos] = range;\n return [this.posToIndex(fromPos, false), this.posToIndex(toPos, true)];\n }\n\n /**\n * `posToIndex` converts the given position to index.\n */\n public posToIndex(pos: RGATreeSplitPos, preferToLeft: boolean): number {\n const absoluteID = pos.getAbsoluteID();\n const node = preferToLeft\n ? this.findFloorNodePreferToLeft(absoluteID)\n : this.findFloorNode(absoluteID);\n if (!node) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `the node of the given id should be found: ${absoluteID.toTestString()}`,\n );\n }\n const index = this.treeByIndex.indexOf(node!);\n const offset = node!.isRemoved()\n ? 0\n : absoluteID.getOffset() - node!.getID().getOffset();\n return index + offset;\n }\n\n /**\n * `findNode` finds node of given id.\n */\n public findNode(id: RGATreeSplitNodeID): RGATreeSplitNode<T> {\n return this.findFloorNode(id)!;\n }\n\n /**\n * `length` returns size of RGATreeSplit.\n */\n public get length(): number {\n return this.treeByIndex.length;\n }\n\n /**\n * `getTreeByIndex` returns the tree by index for debugging purpose.\n */\n public getTreeByIndex(): SplayTree<T> {\n return this.treeByIndex;\n }\n\n /**\n * `getTreeByID` returns the tree by ID for debugging purpose.\n */\n public getTreeByID(): LLRBTree<RGATreeSplitNodeID, RGATreeSplitNode<T>> {\n return this.treeByID;\n }\n\n /**\n * `toString` returns the string encoding of this RGATreeSplit.\n */\n public toString(): string {\n const str = [];\n\n for (const node of this) {\n if (!node.isRemoved()) {\n str.push(node.getValue());\n }\n }\n\n return str.join('');\n }\n\n // eslint-disable-next-line jsdoc/require-jsdoc\n public *[Symbol.iterator](): IterableIterator<RGATreeSplitNode<T>> {\n let node = this.head.getNext();\n while (node) {\n yield node;\n node = node.getNext();\n }\n }\n\n /**\n * `getHead` returns head of RGATreeSplitNode.\n */\n public getHead(): RGATreeSplitNode<T> {\n return this.head;\n }\n\n /**\n * `deepcopy` copies itself deeply.\n */\n public deepcopy(): RGATreeSplit<T> {\n const clone = new RGATreeSplit<T>();\n\n let node = this.head.getNext();\n\n let prev = clone.head;\n let current;\n while (node) {\n current = clone.insertAfter(prev, node.deepcopy());\n if (node.hasInsPrev()) {\n const insPrevNode = clone.findNode(node.getInsPrevID());\n current.setInsPrev(insPrevNode);\n }\n\n prev = current;\n node = node.getNext();\n }\n\n return clone;\n }\n\n /**\n * `toTestString` returns a String containing the meta data of the node\n * for debugging purpose.\n */\n public toTestString(): string {\n const result = [];\n\n let node: RGATreeSplitNode<T> | undefined = this.head;\n while (node) {\n if (node.isRemoved()) {\n result.push(`{${node.toTestString()}}`);\n } else {\n result.push(`[${node.toTestString()}]`);\n }\n\n node = node.getNext();\n }\n\n return result.join('');\n }\n\n /**\n * `insertAfter` inserts the given node after the given previous node.\n */\n public insertAfter(\n prevNode: RGATreeSplitNode<T>,\n newNode: RGATreeSplitNode<T>,\n ): RGATreeSplitNode<T> {\n const next = prevNode.getNext();\n newNode.setPrev(prevNode);\n if (next) {\n next.setPrev(newNode);\n }\n\n this.treeByID.put(newNode.getID(), newNode);\n this.treeByIndex.insertAfter(prevNode, newNode);\n\n return newNode;\n }\n\n /**\n * `findNodeWithSplit` splits and return nodes of the given position.\n */\n public findNodeWithSplit(\n pos: RGATreeSplitPos,\n editedAt: TimeTicket,\n ): [RGATreeSplitNode<T>, RGATreeSplitNode<T>] {\n const absoluteID = pos.getAbsoluteID();\n let node = this.findFloorNodePreferToLeft(absoluteID);\n const relativeOffset = absoluteID.getOffset() - node.getID().getOffset();\n\n this.splitNode(node, relativeOffset);\n\n while (node.hasNext() && node.getNext()!.getCreatedAt().after(editedAt)) {\n node = node.getNext()!;\n }\n\n return [node, node.getNext()!];\n }\n\n private findFloorNodePreferToLeft(\n id: RGATreeSplitNodeID,\n ): RGATreeSplitNode<T> {\n let node = this.findFloorNode(id);\n if (!node) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `the node of the given id should be found: ${id.toTestString()}`,\n );\n }\n\n if (id.getOffset() > 0 && node!.getID().getOffset() == id.getOffset()) {\n // NOTE: InsPrev may not be present due to GC.\n if (!node!.hasInsPrev()) {\n return node!;\n }\n node = node!.getInsPrev();\n }\n\n return node!;\n }\n\n private findFloorNode(\n id: RGATreeSplitNodeID,\n ): RGATreeSplitNode<T> | undefined {\n const entry = this.treeByID.floorEntry(id);\n if (!entry) {\n return;\n }\n\n if (!entry.key.equals(id) && !entry.key.hasSameCreatedAt(id)) {\n return;\n }\n\n return entry.value;\n }\n\n /**\n * `findBetween` returns nodes between fromNode and toNode.\n */\n public findBetween(\n fromNode: RGATreeSplitNode<T>,\n toNode: RGATreeSplitNode<T>,\n ): Array<RGATreeSplitNode<T>> {\n const nodes = [];\n\n let current: RGATreeSplitNode<T> | undefined = fromNode;\n while (current && current !== toNode) {\n nodes.push(current);\n current = current.getNext();\n }\n\n return nodes;\n }\n\n private splitNode(\n node: RGATreeSplitNode<T>,\n offset: number,\n ): RGATreeSplitNode<T> | undefined {\n if (offset > node.getContentLength()) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `offset should be less than or equal to length`,\n );\n }\n\n if (offset === 0) {\n return node;\n } else if (offset === node.getContentLength()) {\n return node.getNext();\n }\n\n const splitNode = node.split(offset);\n this.treeByIndex.updateWeight(splitNode);\n this.insertAfter(node, splitNode);\n\n const insNext = node.getInsNext();\n if (insNext) {\n insNext.setInsPrev(splitNode);\n }\n splitNode.setInsPrev(node);\n\n return splitNode;\n }\n\n private deleteNodes(\n candidates: Array<RGATreeSplitNode<T>>,\n editedAt: TimeTicket,\n maxCreatedAtMapByActor?: Map<string, TimeTicket>,\n versionVector?: VersionVector,\n ): [\n Array<ValueChange<T>>,\n Map<string, TimeTicket>,\n Map<string, RGATreeSplitNode<T>>,\n ] {\n if (!candidates.length) {\n return [[], new Map(), new Map()];\n }\n\n // There are 2 types of nodes in `candidates`: should delete, should not delete.\n // `nodesToKeep` contains nodes should not delete,\n // then is used to find the boundary of the range to be deleted.\n const [nodesToDelete, nodesToKeep] = this.filterNodes(\n candidates,\n editedAt,\n maxCreatedAtMapByActor,\n versionVector,\n );\n\n const createdAtMapByActor = new Map();\n const removedNodes = new Map();\n // First we need to collect indexes for change.\n const changes = this.makeChanges(nodesToKeep, editedAt);\n for (const node of nodesToDelete) {\n // Then make nodes be tombstones and map that.\n const actorID = node.getCreatedAt().getActorID();\n if (\n !createdAtMapByActor.has(actorID) ||\n node.getID().getCreatedAt().after(createdAtMapByActor.get(actorID))\n ) {\n createdAtMapByActor.set(actorID, node.getID().getCreatedAt());\n }\n removedNodes.set(node.getID().toIDString(), node);\n node.remove(editedAt);\n }\n // Finally remove index nodes of tombstones.\n this.deleteIndexNodes(nodesToKeep);\n\n return [changes, createdAtMapByActor, removedNodes];\n }\n\n private filterNodes(\n candidates: Array<RGATreeSplitNode<T>>,\n editedAt: TimeTicket,\n maxCreatedAtMapByActor?: Map<string, TimeTicket>,\n versionVector?: VersionVector,\n ): [Array<RGATreeSplitNode<T>>, Array<RGATreeSplitNode<T> | undefined>] {\n const nodesToDelete: Array<RGATreeSplitNode<T>> = [];\n const nodesToKeep: Array<RGATreeSplitNode<T> | undefined> = [];\n\n const [leftEdge, rightEdge] = this.findEdgesOfCandidates(candidates);\n nodesToKeep.push(leftEdge);\n\n for (const node of candidates) {\n const actorID = node.getCreatedAt().getActorID();\n let maxCreatedAt: TimeTicket | undefined;\n let clientLamportAtChange = 0n;\n if (versionVector === undefined && maxCreatedAtMapByActor === undefined) {\n // Local edit - use version vector comparison\n clientLamportAtChange = MaxLamport;\n } else if (versionVector!.size() > 0) {\n clientLamportAtChange = versionVector!.get(actorID)\n ? versionVector!.get(actorID)!\n : 0n;\n } else {\n maxCreatedAt = maxCreatedAtMapByActor!.has(actorID)\n ? maxCreatedAtMapByActor!.get(actorID)\n : InitialTimeTicket;\n }\n\n if (node.canDelete(editedAt, maxCreatedAt, clientLamportAtChange)) {\n nodesToDelete.push(node);\n } else {\n nodesToKeep.push(node);\n }\n }\n nodesToKeep.push(rightEdge);\n\n return [nodesToDelete, nodesToKeep];\n }\n\n /**\n * `findEdgesOfCandidates` finds the edges outside `candidates`,\n * (which has not already been deleted, or be undefined but not yet implemented)\n * right edge is undefined means `candidates` contains the end of text.\n */\n private findEdgesOfCandidates(\n candidates: Array<RGATreeSplitNode<T>>,\n ): [RGATreeSplitNode<T>, RGATreeSplitNode<T> | undefined] {\n return [\n candidates[0].getPrev()!,\n candidates[candidates.length - 1].getNext(),\n ];\n }\n\n private makeChanges(\n boundaries: Array<RGATreeSplitNode<T> | undefined>,\n editedAt: TimeTicket,\n ): Array<ValueChange<T>> {\n const changes: Array<ValueChange<T>> = [];\n let fromIdx: number, toIdx: number;\n\n for (let i = 0; i < boundaries.length - 1; i++) {\n const leftBoundary = boundaries[i];\n const rightBoundary = boundaries[i + 1];\n\n if (leftBoundary!.getNext() == rightBoundary) {\n continue;\n }\n\n [fromIdx] = this.findIndexesFromRange(\n leftBoundary!.getNext()!.createPosRange(),\n );\n if (rightBoundary) {\n [, toIdx] = this.findIndexesFromRange(\n rightBoundary.getPrev()!.createPosRange(),\n );\n } else {\n toIdx = this.treeByIndex.length;\n }\n\n if (fromIdx < toIdx) {\n changes.push({\n actor: editedAt.getActorID(),\n from: fromIdx,\n to: toIdx,\n });\n }\n }\n\n return changes.reverse();\n }\n\n /**\n * `deleteIndexNodes` clears the index nodes of the given deletion boundaries.\n * The boundaries mean the nodes that will not be deleted in the range.\n */\n private deleteIndexNodes(\n boundaries: Array<RGATreeSplitNode<T> | undefined>,\n ): void {\n for (let i = 0; i < boundaries.length - 1; i++) {\n const leftBoundary = boundaries[i];\n const rightBoundary = boundaries[i + 1];\n // If there is no node to delete between boundaries, do notting.\n if (leftBoundary!.getNext() != rightBoundary) {\n this.treeByIndex.deleteRange(leftBoundary!, rightBoundary);\n }\n }\n }\n\n /**\n * `purge` physically purges the given node from RGATreeSplit.\n */\n public purge(node: RGATreeSplitNode<T>): void {\n this.treeByIndex.delete(node);\n this.treeByID.remove(node.getID());\n\n const prev = node.getPrev();\n const next = node.getNext();\n const insPrev = node.getInsPrev();\n const insNext = node.getInsNext();\n\n if (prev) {\n prev.setNext(next);\n }\n if (next) {\n next.setPrev(prev);\n }\n\n node.setPrev(undefined);\n node.setNext(undefined);\n\n if (insPrev) {\n insPrev.setInsNext(insNext);\n }\n\n if (insNext) {\n insNext.setInsPrev(insPrev);\n }\n\n node.setInsPrev(undefined);\n node.setInsNext(undefined);\n }\n}\n","/*\n * Copyright 2023 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n `removeDecimal` returns a number with the decimal part removed.\n */\nexport const removeDecimal = (number: number) =>\n number < 0 ? Math.ceil(number) : Math.floor(number);\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { CRDTElement } from '@yorkie-js-sdk/src/document/crdt/element';\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport Long from 'long';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\nimport {\n Primitive,\n PrimitiveType,\n} from '@yorkie-js-sdk/src/document/crdt/primitive';\nimport { removeDecimal } from '@yorkie-js-sdk/src/util/number';\nimport type * as Devtools from '@yorkie-js-sdk/src/devtools/types';\n\nexport enum CounterType {\n IntegerCnt,\n LongCnt,\n}\n\nexport type CounterValue = number | Long;\n\n/**\n * `CRDTCounter` is a CRDT implementation of a counter. It is used to represent\n * a number that can be incremented or decremented.\n *\n * @internal\n */\nexport class CRDTCounter extends CRDTElement {\n private valueType: CounterType;\n private value: CounterValue;\n\n constructor(\n valueType: CounterType,\n value: CounterValue,\n createdAt: TimeTicket,\n ) {\n super(createdAt);\n this.valueType = valueType;\n switch (valueType) {\n case CounterType.IntegerCnt:\n if (typeof value === 'number') {\n if (value > Math.pow(2, 31) - 1 || value < -Math.pow(2, 31)) {\n this.value = Long.fromNumber(value).toInt();\n } else {\n this.value = removeDecimal(value);\n }\n } else {\n this.value = value.toInt();\n }\n break;\n case CounterType.LongCnt:\n if (typeof value === 'number') {\n this.value = Long.fromNumber(value);\n } else {\n this.value = value;\n }\n break;\n default:\n throw new YorkieError(\n Code.ErrUnimplemented,\n `unimplemented type: ${valueType}`,\n );\n }\n }\n\n /**\n * `of` creates a new instance of Counter.\n */\n public static create(\n valueType: CounterType,\n value: CounterValue,\n createdAt: TimeTicket,\n ): CRDTCounter {\n return new CRDTCounter(valueType, value, createdAt);\n }\n /**\n * `valueFromBytes` parses the given bytes into value.\n */\n public static valueFromBytes(\n counterType: CounterType,\n bytes: Uint8Array,\n ): CounterValue {\n switch (counterType) {\n case CounterType.IntegerCnt:\n return bytes[0] | (bytes[1] << 8) | (bytes[2] << 16) | (bytes[3] << 24);\n case CounterType.LongCnt:\n return Long.fromBytesLE(Array.from(bytes));\n default:\n throw new YorkieError(\n Code.ErrUnimplemented,\n `unimplemented type: ${counterType}`,\n );\n }\n }\n\n /**\n * `toJSON` returns the JSON encoding of the value.\n */\n public toJSON(): string {\n return `${this.value}`;\n }\n\n /**\n * `toSortedJSON` returns the sorted JSON encoding of the value.\n */\n public toSortedJSON(): string {\n return this.toJSON();\n }\n\n /**\n * `toJSForTest` returns value with meta data for testing.\n */\n public toJSForTest(): Devtools.JSONElement {\n return {\n createdAt: this.getCreatedAt().toTestString(),\n value: this.value,\n type: 'YORKIE_COUNTER',\n };\n }\n\n /**\n * `deepcopy` copies itself deeply.\n */\n public deepcopy(): CRDTCounter {\n const counter = CRDTCounter.create(\n this.valueType,\n this.value,\n this.getCreatedAt(),\n );\n counter.setMovedAt(this.getMovedAt());\n return counter;\n }\n\n /**\n * `getType` returns the type of the value.\n */\n public getType(): CounterType {\n return this.valueType;\n }\n\n /**\n * `getCounterType` returns counter type of given value.\n */\n public static getCounterType(value: CounterValue): CounterType | undefined {\n switch (typeof value) {\n case 'object':\n if (value instanceof Long) {\n return CounterType.LongCnt;\n } else {\n return;\n }\n case 'number':\n if (value > Math.pow(2, 31) - 1 || value < -Math.pow(2, 31)) {\n return CounterType.LongCnt;\n } else {\n return CounterType.IntegerCnt;\n }\n default:\n return;\n }\n }\n /**\n * `isSupport` check if there is a counter type of given value.\n */\n public static isSupport(value: CounterValue): boolean {\n return !!CRDTCounter.getCounterType(value);\n }\n\n /**\n * `isInteger` checks if the num is integer.\n */\n public static isInteger(num: number): boolean {\n return num % 1 === 0;\n }\n\n /**\n * `isNumericType` check numeric type by JSONCounter.\n */\n public isNumericType(): boolean {\n const t = this.valueType;\n return t === CounterType.IntegerCnt || t === CounterType.LongCnt;\n }\n\n /**\n * `getValueType` get counter value type.\n */\n public getValueType(): CounterType {\n return this.valueType;\n }\n\n /**\n * `getValue` get counter value.\n */\n public getValue(): CounterValue {\n return this.value;\n }\n\n /**\n * `toBytes` creates an array representing the value.\n */\n public toBytes(): Uint8Array {\n switch (this.valueType) {\n case CounterType.IntegerCnt: {\n const intVal = this.value as number;\n return new Uint8Array([\n intVal & 0xff,\n (intVal >> 8) & 0xff,\n (intVal >> 16) & 0xff,\n (intVal >> 24) & 0xff,\n ]);\n }\n case CounterType.LongCnt: {\n const longVal = this.value as Long;\n const longToBytes = longVal.toBytesLE();\n return Uint8Array.from(longToBytes);\n }\n default:\n throw new YorkieError(\n Code.ErrUnimplemented,\n `unimplemented type: ${this.valueType}`,\n );\n }\n }\n\n /**\n * `increase` increases numeric data.\n */\n public increase(v: Primitive): CRDTCounter {\n /**\n * `checkNumericType` checks if the given target is a numeric type.\n */\n function checkNumericType(target: Primitive | CRDTCounter): void {\n if (!target.isNumericType()) {\n throw new TypeError(\n `Unsupported type of value: ${typeof target.getValue()}`,\n );\n }\n }\n checkNumericType(this);\n checkNumericType(v);\n\n if (this.valueType === CounterType.LongCnt) {\n this.value = (this.value as Long).add(v.getValue() as number | Long);\n } else {\n if (v.getType() === PrimitiveType.Long) {\n this.value = (this.value as number) + (v.getValue() as Long).toInt();\n } else {\n this.value = Long.fromNumber(\n (this.value as number) + removeDecimal(v.getValue() as number),\n ).toInt();\n }\n }\n\n return this;\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport Long from 'long';\nimport {\n ExecutionResult,\n Operation,\n} from '@yorkie-js-sdk/src/document/operation/operation';\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { CRDTElement } from '@yorkie-js-sdk/src/document/crdt/element';\nimport { CRDTRoot } from '@yorkie-js-sdk/src/document/crdt/root';\nimport {\n Primitive,\n PrimitiveType,\n} from '@yorkie-js-sdk/src/document/crdt/primitive';\nimport { CRDTCounter } from '@yorkie-js-sdk/src/document/crdt/counter';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\n\n/**\n * `IncreaseOperation` represents an operation that increments a numeric value to Counter.\n * Among Primitives, numeric types Integer, Long are used as values.\n */\nexport class IncreaseOperation extends Operation {\n private value: CRDTElement;\n\n constructor(\n parentCreatedAt: TimeTicket,\n value: CRDTElement,\n executedAt?: TimeTicket,\n ) {\n super(parentCreatedAt, executedAt);\n this.value = value;\n }\n\n /**\n * `create` creates a new instance of IncreaseOperation.\n */\n public static create(\n parentCreatedAt: TimeTicket,\n value: CRDTElement,\n executedAt?: TimeTicket,\n ): IncreaseOperation {\n return new IncreaseOperation(parentCreatedAt, value, executedAt);\n }\n\n /**\n * `execute` executes this operation on the given `CRDTRoot`.\n */\n public execute(root: CRDTRoot): ExecutionResult {\n const parentObject = root.findByCreatedAt(this.getParentCreatedAt());\n if (!parentObject) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to find ${this.getParentCreatedAt()}`,\n );\n }\n if (!(parentObject instanceof CRDTCounter)) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to execute, only Counter can execute increase`,\n );\n }\n const counter = parentObject as CRDTCounter;\n const value = this.value.deepcopy() as Primitive;\n counter.increase(value);\n return {\n opInfos: [\n {\n type: 'increase',\n path: root.createPath(this.getParentCreatedAt()),\n value: value.getValue() as number,\n },\n ],\n reverseOp: this.toReverseOperation(),\n };\n }\n\n /**\n * `toReverseOperation` returns the reverse operation of this operation.\n */\n private toReverseOperation(): Operation {\n const primitiveValue = this.value.deepcopy() as Primitive;\n\n const valueType = primitiveValue.getType();\n const value =\n valueType === PrimitiveType.Long\n ? (primitiveValue.getValue() as Long).multiply(-1)\n : (primitiveValue.getValue() as number) * -1;\n\n const reverseOp = IncreaseOperation.create(\n this.getParentCreatedAt(),\n Primitive.of(value, primitiveValue.getCreatedAt()),\n );\n return reverseOp;\n }\n\n /**\n * `getEffectedCreatedAt` returns the creation time of the effected element.\n */\n public getEffectedCreatedAt(): TimeTicket {\n return this.getParentCreatedAt();\n }\n\n /**\n * `toTestString` returns a string containing the meta data.\n */\n public toTestString(): string {\n return `${this.getParentCreatedAt().toTestString()}.INCREASE.${this.value.toJSON()}`;\n }\n\n /**\n * `getValue` returns the value of this operation.\n */\n public getValue(): CRDTElement {\n return this.value;\n }\n}\n","/*\n * Copyright 2023 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { VersionVector } from '@yorkie-js-sdk/src/document/time/version_vector';\nimport { CRDTRoot } from '@yorkie-js-sdk/src/document/crdt/root';\nimport {\n CRDTTree,\n CRDTTreePos,\n TreeChange,\n} from '@yorkie-js-sdk/src/document/crdt/tree';\nimport {\n Operation,\n OperationInfo,\n ExecutionResult,\n OpSource,\n} from '@yorkie-js-sdk/src/document/operation/operation';\nimport { GCPair } from '@yorkie-js-sdk/src/document/crdt/gc';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\n\n/**\n * `TreeStyleOperation` represents an operation that modifies the style of the\n * node in the Tree.\n */\nexport class TreeStyleOperation extends Operation {\n private fromPos: CRDTTreePos;\n private toPos: CRDTTreePos;\n private maxCreatedAtMapByActor: Map<string, TimeTicket>;\n private attributes: Map<string, string>;\n private attributesToRemove: Array<string>;\n\n constructor(\n parentCreatedAt: TimeTicket,\n fromPos: CRDTTreePos,\n toPos: CRDTTreePos,\n maxCreatedAtMapByActor: Map<string, TimeTicket>,\n attributes: Map<string, string>,\n attributesToRemove: Array<string>,\n executedAt: TimeTicket,\n ) {\n super(parentCreatedAt, executedAt);\n this.fromPos = fromPos;\n this.toPos = toPos;\n this.maxCreatedAtMapByActor = maxCreatedAtMapByActor;\n this.attributes = attributes;\n this.attributesToRemove = attributesToRemove;\n }\n\n /**\n * `create` creates a new instance of TreeStyleOperation.\n */\n public static create(\n parentCreatedAt: TimeTicket,\n fromPos: CRDTTreePos,\n toPos: CRDTTreePos,\n maxCreatedAtMapByActor: Map<string, TimeTicket>,\n attributes: Map<string, string>,\n executedAt: TimeTicket,\n ): TreeStyleOperation {\n return new TreeStyleOperation(\n parentCreatedAt,\n fromPos,\n toPos,\n maxCreatedAtMapByActor,\n attributes,\n [],\n executedAt,\n );\n }\n\n /**\n * `createTreeRemoveStyleOperation` creates a new instance of TreeStyleOperation for style deletion.\n */\n public static createTreeRemoveStyleOperation(\n parentCreatedAt: TimeTicket,\n fromPos: CRDTTreePos,\n toPos: CRDTTreePos,\n maxCreatedAtMapByActor: Map<string, TimeTicket>,\n attributesToRemove: Array<string>,\n executedAt: TimeTicket,\n ): TreeStyleOperation {\n return new TreeStyleOperation(\n parentCreatedAt,\n fromPos,\n toPos,\n maxCreatedAtMapByActor,\n new Map(),\n attributesToRemove,\n executedAt,\n );\n }\n\n /**\n * `execute` executes this operation on the given `CRDTRoot`.\n */\n public execute(\n root: CRDTRoot,\n _: OpSource,\n versionVector: VersionVector,\n ): ExecutionResult {\n const parentObject = root.findByCreatedAt(this.getParentCreatedAt());\n if (!parentObject) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to find ${this.getParentCreatedAt()}`,\n );\n }\n if (!(parentObject instanceof CRDTTree)) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `fail to execute, only Tree can execute edit`,\n );\n }\n const tree = parentObject as CRDTTree;\n let changes: Array<TreeChange>;\n let pairs: Array<GCPair>;\n if (this.attributes.size) {\n const attributes: { [key: string]: any } = {};\n [...this.attributes].forEach(([key, value]) => (attributes[key] = value));\n\n [, pairs, changes] = tree.style(\n [this.fromPos, this.toPos],\n attributes,\n this.getExecutedAt(),\n this.maxCreatedAtMapByActor,\n versionVector,\n );\n } else {\n const attributesToRemove = this.attributesToRemove;\n\n [, pairs, changes] = tree.removeStyle(\n [this.fromPos, this.toPos],\n attributesToRemove,\n this.getExecutedAt(),\n this.maxCreatedAtMapByActor,\n versionVector,\n );\n }\n\n for (const pair of pairs) {\n root.registerGCPair(pair);\n }\n\n return {\n opInfos: changes.map(({ from, to, value, fromPath, toPath }) => {\n return {\n type: 'tree-style',\n from,\n to,\n value: this.attributes.size\n ? { attributes: value }\n : { attributesToRemove: value },\n fromPath,\n toPath,\n path: root.createPath(this.getParentCreatedAt()),\n } as OperationInfo;\n }),\n };\n }\n\n /**\n * `getEffectedCreatedAt` returns the creation time of the effected element.\n */\n public getEffectedCreatedAt(): TimeTicket {\n return this.getParentCreatedAt();\n }\n\n /**\n * `toTestString` returns a string containing the meta data.\n */\n public toTestString(): string {\n const parent = this.getParentCreatedAt().toTestString();\n const fromPos = `${this.fromPos\n .getLeftSiblingID()\n .getCreatedAt()\n .toTestString()}:${this.fromPos.getLeftSiblingID().getOffset()}`;\n const toPos = `${this.toPos\n .getLeftSiblingID()\n .getCreatedAt()\n .toTestString()}:${this.toPos.getLeftSiblingID().getOffset()}`;\n\n return `${parent}.STYLE(${fromPos},${toPos},${Object.entries(\n this.attributes || {},\n )\n .map(([k, v]) => `${k}:\"${v}\"`)\n .join(' ')})`;\n }\n\n /**\n * `getFromPos` returns the start point of the editing range.\n */\n public getFromPos(): CRDTTreePos {\n return this.fromPos;\n }\n\n /**\n * `getToPos` returns the end point of the editing range.\n */\n public getToPos(): CRDTTreePos {\n return this.toPos;\n }\n\n /**\n * `getAttributes` returns the attributes of Style.\n */\n public getAttributes(): Map<string, string> {\n return this.attributes;\n }\n\n /**\n * `getAttributesToRemove` returns the attributes of Style to remove.\n */\n public getAttributesToRemove(): Array<string> {\n return this.attributesToRemove;\n }\n\n /**\n * `getMaxCreatedAtMapByActor` returns the map that stores the latest creation time\n * by actor for the nodes included in the styling range.\n */\n public getMaxCreatedAtMapByActor(): Map<string, TimeTicket> {\n return this.maxCreatedAtMapByActor;\n }\n}\n","/*\n * Copyright 2023 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ConnectError } from '@connectrpc/connect';\nimport { ErrorInfo } from '@buf/googleapis_googleapis.bufbuild_es/google/rpc/error_details_pb';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\nimport { Indexable } from '@yorkie-js-sdk/src/document/document';\nimport {\n PresenceChange,\n PresenceChangeType,\n} from '@yorkie-js-sdk/src/document/presence/presence';\nimport {\n InitialTimeTicket,\n TimeTicket,\n} from '@yorkie-js-sdk/src/document/time/ticket';\nimport { ActorID } from '@yorkie-js-sdk/src/document/time/actor_id';\nimport { Operation } from '@yorkie-js-sdk/src/document/operation/operation';\nimport { SetOperation } from '@yorkie-js-sdk/src/document/operation/set_operation';\nimport { AddOperation } from '@yorkie-js-sdk/src/document/operation/add_operation';\nimport { MoveOperation } from '@yorkie-js-sdk/src/document/operation/move_operation';\nimport { RemoveOperation } from '@yorkie-js-sdk/src/document/operation/remove_operation';\nimport { EditOperation } from '@yorkie-js-sdk/src/document/operation/edit_operation';\nimport { StyleOperation } from '@yorkie-js-sdk/src/document/operation/style_operation';\nimport { TreeEditOperation } from '@yorkie-js-sdk/src/document/operation/tree_edit_operation';\nimport { ChangeID } from '@yorkie-js-sdk/src/document/change/change_id';\nimport { Change } from '@yorkie-js-sdk/src/document/change/change';\nimport { ChangePack } from '@yorkie-js-sdk/src/document/change/change_pack';\nimport { Checkpoint } from '@yorkie-js-sdk/src/document/change/checkpoint';\nimport { ElementRHT } from '@yorkie-js-sdk/src/document/crdt/element_rht';\nimport { RGATreeList } from '@yorkie-js-sdk/src/document/crdt/rga_tree_list';\nimport { CRDTElement } from '@yorkie-js-sdk/src/document/crdt/element';\nimport { CRDTObject } from '@yorkie-js-sdk/src/document/crdt/object';\nimport { CRDTArray } from '@yorkie-js-sdk/src/document/crdt/array';\nimport { VersionVector } from '@yorkie-js-sdk/src/document/time/version_vector';\nimport { CRDTTreePos } from './../document/crdt/tree';\nimport {\n RGATreeSplit,\n RGATreeSplitNode,\n RGATreeSplitNodeID,\n RGATreeSplitPos,\n} from '@yorkie-js-sdk/src/document/crdt/rga_tree_split';\nimport { CRDTText, CRDTTextValue } from '@yorkie-js-sdk/src/document/crdt/text';\nimport {\n Primitive,\n PrimitiveType,\n} from '@yorkie-js-sdk/src/document/crdt/primitive';\nimport {\n Change as PbChange,\n ChangeID as PbChangeID,\n ChangePack as PbChangePack,\n Checkpoint as PbCheckpoint,\n JSONElement as PbJSONElement,\n JSONElementSimple as PbJSONElementSimple,\n NodeAttr as PbNodeAttr,\n Operation as PbOperation,\n Presence as PbPresence,\n PresenceChange as PbPresenceChange,\n RGANode as PbRGANode,\n RHTNode as PbRHTNode,\n Snapshot as PbSnapshot,\n TextNode as PbTextNode,\n TextNodeID as PbTextNodeID,\n TextNodePos as PbTextNodePos,\n TimeTicket as PbTimeTicket,\n TreeNode as PbTreeNode,\n TreeNodes as PbTreeNodes,\n TreePos as PbTreePos,\n TreeNodeID as PbTreeNodeID,\n VersionVector as PbVersionVector,\n ValueType as PbValueType,\n JSONElement_Tree as PbJSONElement_Tree,\n JSONElement_Text as PbJSONElement_Text,\n JSONElement_Primitive as PbJSONElement_Primitive,\n JSONElement_Counter as PbJSONElement_Counter,\n JSONElement_JSONObject as PbJSONElement_JSONObject,\n JSONElement_JSONArray as PbJSONElement_JSONArray,\n PresenceChange_ChangeType as PbPresenceChange_ChangeType,\n Operation_Set as PbOperation_Set,\n Operation_Add as PbOperation_Add,\n Operation_Move as PbOperation_Move,\n Operation_Remove as PbOperation_Remove,\n Operation_Edit as PbOperation_Edit,\n Operation_Style as PbOperation_Style,\n Operation_Increase as PbOperation_Increase,\n Operation_TreeEdit as PbOperation_TreeEdit,\n Operation_TreeStyle as PbOperation_TreeStyle,\n} from '@yorkie-js-sdk/src/api/yorkie/v1/resources_pb';\nimport { IncreaseOperation } from '@yorkie-js-sdk/src/document/operation/increase_operation';\nimport {\n CounterType,\n CRDTCounter,\n} from '@yorkie-js-sdk/src/document/crdt/counter';\nimport {\n CRDTTree,\n CRDTTreeNode,\n CRDTTreeNodeID,\n} from '@yorkie-js-sdk/src/document/crdt/tree';\nimport { traverseAll } from '../util/index_tree';\nimport { TreeStyleOperation } from '../document/operation/tree_style_operation';\nimport { RHT } from '../document/crdt/rht';\n\n/**\n * `toPresence` converts the given model to Protobuf format.\n */\nfunction toPresence(presence: Indexable): PbPresence {\n const pbPresence = new PbPresence();\n const pbDataMap = pbPresence.data;\n for (const [key, value] of Object.entries(presence)) {\n pbDataMap[key] = JSON.stringify(value);\n }\n return pbPresence;\n}\n\n/**\n * `toPresenceChange` converts the given model to Protobuf format.\n */\nfunction toPresenceChange(\n presenceChange: PresenceChange<Indexable>,\n): PbPresenceChange {\n if (presenceChange.type === PresenceChangeType.Put) {\n return new PbPresenceChange({\n type: PbPresenceChange_ChangeType.PUT,\n presence: toPresence(presenceChange.presence),\n });\n }\n if (presenceChange.type === PresenceChangeType.Clear) {\n return new PbPresenceChange({\n type: PbPresenceChange_ChangeType.CLEAR,\n });\n }\n\n throw new YorkieError(Code.ErrUnimplemented, `unimplemented type`);\n}\n\n/**\n * `toCheckpoint` converts the given model to Protobuf format.\n */\nfunction toCheckpoint(checkpoint: Checkpoint): PbCheckpoint {\n return new PbCheckpoint({\n serverSeq: checkpoint.getServerSeq(),\n clientSeq: checkpoint.getClientSeq(),\n });\n}\n\n/**\n * `toChangeID` converts the given model to Protobuf format.\n */\nfunction toChangeID(changeID: ChangeID): PbChangeID {\n return new PbChangeID({\n clientSeq: changeID.getClientSeq(),\n lamport: changeID.getLamport(),\n actorId: toUint8Array(changeID.getActorID()),\n versionVector: toVersionVector(changeID.getVersionVector()),\n });\n}\n\n/**\n * `toTimeTicket` converts the given model to Protobuf format.\n */\nfunction toTimeTicket(ticket?: TimeTicket): PbTimeTicket | undefined {\n if (!ticket) {\n return;\n }\n\n return new PbTimeTicket({\n lamport: ticket.getLamport(),\n delimiter: ticket.getDelimiter(),\n actorId: toUint8Array(ticket.getActorID()),\n });\n}\n\n/**\n * `toVersionVector` converts the given model to Protobuf format.\n */\nfunction toVersionVector(vector?: VersionVector): PbVersionVector | undefined {\n if (!vector) {\n return;\n }\n\n const pbVector = new PbVersionVector();\n for (const [actorID, lamport] of vector) {\n pbVector.vector[actorID] = BigInt(lamport.toString());\n }\n return pbVector;\n}\n\n/**\n * `toValueType` converts the given model to Protobuf format.\n */\nfunction toValueType(valueType: PrimitiveType): PbValueType {\n switch (valueType) {\n case PrimitiveType.Null:\n return PbValueType.NULL;\n case PrimitiveType.Boolean:\n return PbValueType.BOOLEAN;\n case PrimitiveType.Integer:\n return PbValueType.INTEGER;\n case PrimitiveType.Long:\n return PbValueType.LONG;\n case PrimitiveType.Double:\n return PbValueType.DOUBLE;\n case PrimitiveType.String:\n return PbValueType.STRING;\n case PrimitiveType.Bytes:\n return PbValueType.BYTES;\n case PrimitiveType.Date:\n return PbValueType.DATE;\n default:\n throw new YorkieError(\n Code.ErrInvalidType,\n `unsupported type: ${valueType}`,\n );\n }\n}\n\n/**\n * `toCounterType` converts the given model to Protobuf format.\n */\nfunction toCounterType(valueType: CounterType): PbValueType {\n switch (valueType) {\n case CounterType.IntegerCnt:\n return PbValueType.INTEGER_CNT;\n case CounterType.LongCnt:\n return PbValueType.LONG_CNT;\n default:\n throw new YorkieError(\n Code.ErrInvalidType,\n `unsupported type: ${valueType}`,\n );\n }\n}\n\n/**\n * `toElementSimple` converts the given model to Protobuf format.\n */\nfunction toElementSimple(element: CRDTElement): PbJSONElementSimple {\n if (element instanceof CRDTObject) {\n return new PbJSONElementSimple({\n type: PbValueType.JSON_OBJECT,\n createdAt: toTimeTicket(element.getCreatedAt()),\n value: objectToBytes(element),\n });\n }\n if (element instanceof CRDTArray) {\n return new PbJSONElementSimple({\n type: PbValueType.JSON_ARRAY,\n createdAt: toTimeTicket(element.getCreatedAt()),\n value: arrayToBytes(element),\n });\n }\n if (element instanceof CRDTText) {\n return new PbJSONElementSimple({\n type: PbValueType.TEXT,\n createdAt: toTimeTicket(element.getCreatedAt()),\n });\n }\n if (element instanceof Primitive) {\n return new PbJSONElementSimple({\n type: toValueType(element.getType()),\n createdAt: toTimeTicket(element.getCreatedAt()),\n value: element.toBytes(),\n });\n }\n if (element instanceof CRDTCounter) {\n return new PbJSONElementSimple({\n type: toCounterType(element.getType()),\n createdAt: toTimeTicket(element.getCreatedAt()),\n value: element.toBytes(),\n });\n }\n if (element instanceof CRDTTree) {\n return new PbJSONElementSimple({\n type: PbValueType.TREE,\n createdAt: toTimeTicket(element.getCreatedAt()),\n value: treeToBytes(element),\n });\n }\n\n throw new YorkieError(Code.ErrUnimplemented, `unimplemented element`);\n}\n\n/**\n * `toTextNodeID` converts the given model to Protobuf format.\n */\nfunction toTextNodeID(id: RGATreeSplitNodeID): PbTextNodeID {\n return new PbTextNodeID({\n createdAt: toTimeTicket(id.getCreatedAt()),\n offset: id.getOffset(),\n });\n}\n\n/**\n * `toTextNodePos` converts the given model to Protobuf format.\n */\nfunction toTextNodePos(pos: RGATreeSplitPos): PbTextNodePos {\n return new PbTextNodePos({\n createdAt: toTimeTicket(pos.getID().getCreatedAt()),\n offset: pos.getID().getOffset(),\n relativeOffset: pos.getRelativeOffset(),\n });\n}\n\n/**\n * `toTreePos` converts the given model to Protobuf format.\n */\nfunction toTreePos(pos: CRDTTreePos): PbTreePos {\n return new PbTreePos({\n parentId: toTreeNodeID(pos.getParentID()),\n leftSiblingId: toTreeNodeID(pos.getLeftSiblingID()),\n });\n}\n\n/**\n * `toTreeNodeID` converts the given model to Protobuf format.\n */\nfunction toTreeNodeID(treeNodeID: CRDTTreeNodeID): PbTreeNodeID {\n return new PbTreeNodeID({\n createdAt: toTimeTicket(treeNodeID.getCreatedAt()),\n offset: treeNodeID.getOffset(),\n });\n}\n\n/**\n * `toOperation` converts the given model to Protobuf format.\n */\nfunction toOperation(operation: Operation): PbOperation {\n const pbOperation = new PbOperation();\n\n if (operation instanceof SetOperation) {\n const setOperation = operation as SetOperation;\n const pbSetOperation = new PbOperation_Set();\n pbSetOperation.parentCreatedAt = toTimeTicket(\n setOperation.getParentCreatedAt(),\n );\n pbSetOperation.key = setOperation.getKey();\n pbSetOperation.value = toElementSimple(setOperation.getValue());\n pbSetOperation.executedAt = toTimeTicket(setOperation.getExecutedAt());\n pbOperation.body.case = 'set';\n pbOperation.body.value = pbSetOperation;\n } else if (operation instanceof AddOperation) {\n const addOperation = operation as AddOperation;\n const pbAddOperation = new PbOperation_Add();\n pbAddOperation.parentCreatedAt = toTimeTicket(\n addOperation.getParentCreatedAt(),\n );\n pbAddOperation.prevCreatedAt = toTimeTicket(\n addOperation.getPrevCreatedAt(),\n );\n pbAddOperation.value = toElementSimple(addOperation.getValue());\n pbAddOperation.executedAt = toTimeTicket(addOperation.getExecutedAt());\n pbOperation.body.case = 'add';\n pbOperation.body.value = pbAddOperation;\n } else if (operation instanceof MoveOperation) {\n const moveOperation = operation as MoveOperation;\n const pbMoveOperation = new PbOperation_Move();\n pbMoveOperation.parentCreatedAt = toTimeTicket(\n moveOperation.getParentCreatedAt(),\n );\n pbMoveOperation.prevCreatedAt = toTimeTicket(\n moveOperation.getPrevCreatedAt(),\n );\n pbMoveOperation.createdAt = toTimeTicket(moveOperation.getCreatedAt());\n pbMoveOperation.executedAt = toTimeTicket(moveOperation.getExecutedAt());\n pbOperation.body.case = 'move';\n pbOperation.body.value = pbMoveOperation;\n } else if (operation instanceof RemoveOperation) {\n const removeOperation = operation as RemoveOperation;\n const pbRemoveOperation = new PbOperation_Remove();\n pbRemoveOperation.parentCreatedAt = toTimeTicket(\n removeOperation.getParentCreatedAt(),\n );\n pbRemoveOperation.createdAt = toTimeTicket(removeOperation.getCreatedAt());\n pbRemoveOperation.executedAt = toTimeTicket(\n removeOperation.getExecutedAt(),\n );\n pbOperation.body.case = 'remove';\n pbOperation.body.value = pbRemoveOperation;\n } else if (operation instanceof EditOperation) {\n const editOperation = operation as EditOperation;\n const pbEditOperation = new PbOperation_Edit();\n pbEditOperation.parentCreatedAt = toTimeTicket(\n editOperation.getParentCreatedAt(),\n );\n pbEditOperation.from = toTextNodePos(editOperation.getFromPos());\n pbEditOperation.to = toTextNodePos(editOperation.getToPos());\n const pbCreatedAtMapByActor = pbEditOperation.createdAtMapByActor;\n for (const [key, value] of editOperation.getMaxCreatedAtMapByActor()) {\n pbCreatedAtMapByActor[key] = toTimeTicket(value)!;\n }\n pbEditOperation.content = editOperation.getContent();\n const pbAttributes = pbEditOperation.attributes;\n for (const [key, value] of editOperation.getAttributes()) {\n pbAttributes[key] = value;\n }\n pbEditOperation.executedAt = toTimeTicket(editOperation.getExecutedAt());\n pbOperation.body.case = 'edit';\n pbOperation.body.value = pbEditOperation;\n } else if (operation instanceof StyleOperation) {\n const styleOperation = operation as StyleOperation;\n const pbStyleOperation = new PbOperation_Style();\n pbStyleOperation.parentCreatedAt = toTimeTicket(\n styleOperation.getParentCreatedAt(),\n );\n pbStyleOperation.from = toTextNodePos(styleOperation.getFromPos());\n pbStyleOperation.to = toTextNodePos(styleOperation.getToPos());\n const pbCreatedAtMapByActor = pbStyleOperation.createdAtMapByActor;\n for (const [key, value] of styleOperation.getMaxCreatedAtMapByActor()) {\n pbCreatedAtMapByActor[key] = toTimeTicket(value)!;\n }\n const pbAttributes = pbStyleOperation.attributes;\n for (const [key, value] of styleOperation.getAttributes()) {\n pbAttributes[key] = value;\n }\n pbStyleOperation.executedAt = toTimeTicket(styleOperation.getExecutedAt());\n pbOperation.body.case = 'style';\n pbOperation.body.value = pbStyleOperation;\n } else if (operation instanceof IncreaseOperation) {\n const increaseOperation = operation as IncreaseOperation;\n const pbIncreaseOperation = new PbOperation_Increase();\n pbIncreaseOperation.parentCreatedAt = toTimeTicket(\n increaseOperation.getParentCreatedAt(),\n );\n pbIncreaseOperation.value = toElementSimple(increaseOperation.getValue());\n pbIncreaseOperation.executedAt = toTimeTicket(\n increaseOperation.getExecutedAt(),\n );\n pbOperation.body.case = 'increase';\n pbOperation.body.value = pbIncreaseOperation;\n } else if (operation instanceof TreeEditOperation) {\n const treeEditOperation = operation as TreeEditOperation;\n const pbTreeEditOperation = new PbOperation_TreeEdit();\n const pbCreatedAtMapByActor = pbTreeEditOperation.createdAtMapByActor;\n for (const [key, value] of treeEditOperation.getMaxCreatedAtMapByActor()) {\n pbCreatedAtMapByActor[key] = toTimeTicket(value)!;\n }\n pbTreeEditOperation.parentCreatedAt = toTimeTicket(\n treeEditOperation.getParentCreatedAt(),\n );\n pbTreeEditOperation.from = toTreePos(treeEditOperation.getFromPos());\n pbTreeEditOperation.to = toTreePos(treeEditOperation.getToPos());\n pbTreeEditOperation.contents = toTreeNodesWhenEdit(\n treeEditOperation.getContents()!,\n );\n pbTreeEditOperation.splitLevel = treeEditOperation.getSplitLevel();\n\n pbTreeEditOperation.executedAt = toTimeTicket(\n treeEditOperation.getExecutedAt(),\n );\n pbOperation.body.case = 'treeEdit';\n pbOperation.body.value = pbTreeEditOperation;\n } else if (operation instanceof TreeStyleOperation) {\n const treeStyleOperation = operation as TreeStyleOperation;\n const pbTreeStyleOperation = new PbOperation_TreeStyle();\n pbTreeStyleOperation.parentCreatedAt = toTimeTicket(\n treeStyleOperation.getParentCreatedAt(),\n );\n pbTreeStyleOperation.from = toTreePos(treeStyleOperation.getFromPos());\n pbTreeStyleOperation.to = toTreePos(treeStyleOperation.getToPos());\n const pbCreatedAtMapByActor = pbTreeStyleOperation.createdAtMapByActor;\n for (const [key, value] of treeStyleOperation.getMaxCreatedAtMapByActor()) {\n pbCreatedAtMapByActor[key] = toTimeTicket(value)!;\n }\n\n const attributesToRemove = treeStyleOperation.getAttributesToRemove();\n if (attributesToRemove.length > 0) {\n pbTreeStyleOperation.attributesToRemove = attributesToRemove;\n } else {\n const attributesMap = pbTreeStyleOperation.attributes;\n\n for (const [key, value] of treeStyleOperation.getAttributes()) {\n attributesMap[key] = value;\n }\n }\n pbTreeStyleOperation.executedAt = toTimeTicket(\n treeStyleOperation.getExecutedAt(),\n );\n pbOperation.body.case = 'treeStyle';\n pbOperation.body.value = pbTreeStyleOperation;\n } else {\n throw new YorkieError(Code.ErrUnimplemented, 'unimplemented operation');\n }\n\n return pbOperation;\n}\n\n/**\n * `toOperations` converts the given model to Protobuf format.\n */\nfunction toOperations(operations: Array<Operation>): Array<PbOperation> {\n const pbOperations = [];\n for (const operation of operations) {\n pbOperations.push(toOperation(operation));\n }\n return pbOperations;\n}\n\n/**\n * `toChange` converts the given model to Protobuf format.\n */\nfunction toChange(change: Change<Indexable>): PbChange {\n const pbChange = new PbChange({\n id: toChangeID(change.getID()),\n message: change.getMessage(),\n });\n if (change.hasOperations()) {\n pbChange.operations = toOperations(change.getOperations());\n }\n if (change.hasPresenceChange()) {\n pbChange.presenceChange = toPresenceChange(change.getPresenceChange()!);\n }\n return pbChange;\n}\n\n/**\n * `toChanges` converts the given model to Protobuf format.\n */\nfunction toChanges(changes: Array<Change<Indexable>>): Array<PbChange> {\n const pbChanges = [];\n for (const change of changes) {\n pbChanges.push(toChange(change));\n }\n return pbChanges;\n}\n\n/**\n * `toRHTNodes` converts the given model to Protobuf format.\n */\nfunction toRHTNodes(rht: ElementRHT): Array<PbRHTNode> {\n const pbRHTNodes = [];\n for (const rhtNode of rht) {\n pbRHTNodes.push(\n new PbRHTNode({\n key: rhtNode.getStrKey(),\n element: toElement(rhtNode.getValue()),\n }),\n );\n }\n\n return pbRHTNodes;\n}\n\n/**\n * `toRGANodes` converts the given model to Protobuf format.\n */\nfunction toRGANodes(rgaTreeList: RGATreeList): Array<PbRGANode> {\n const pbRGANodes = [];\n for (const rgaTreeListNode of rgaTreeList) {\n pbRGANodes.push(\n new PbRGANode({\n element: toElement(rgaTreeListNode.getValue()),\n }),\n );\n }\n\n return pbRGANodes;\n}\n\n/**\n * `toTextNodes` converts the given model to Protobuf format.\n */\nfunction toTextNodes(\n rgaTreeSplit: RGATreeSplit<CRDTTextValue>,\n): Array<PbTextNode> {\n const pbTextNodes = [];\n\n for (const textNode of rgaTreeSplit) {\n const pbTextNode = new PbTextNode();\n pbTextNode.id = toTextNodeID(textNode.getID());\n pbTextNode.value = textNode.getValue().getContent();\n pbTextNode.removedAt = toTimeTicket(textNode.getRemovedAt());\n\n const pbNodeAttrsMap = pbTextNode.attributes;\n const attrs = textNode.getValue().getAttrs();\n for (const attr of attrs) {\n const pbNodeAttr = new PbNodeAttr();\n pbNodeAttr.value = attr.getValue();\n pbNodeAttr.updatedAt = toTimeTicket(attr.getUpdatedAt());\n pbNodeAttrsMap[attr.getKey()] = pbNodeAttr;\n }\n\n pbTextNodes.push(pbTextNode);\n }\n\n return pbTextNodes;\n}\n\n/**\n * `toTreeNodesWhenEdit` converts the given model to Protobuf format.\n */\nfunction toTreeNodesWhenEdit(nodes: Array<CRDTTreeNode>): Array<PbTreeNodes> {\n const pbTreeNodesList: Array<PbTreeNodes> = [];\n if (!nodes || !nodes.length) {\n return pbTreeNodesList;\n }\n\n for (const node of nodes) {\n pbTreeNodesList.push(\n new PbTreeNodes({\n content: toTreeNodes(node),\n }),\n );\n }\n\n return pbTreeNodesList;\n}\n\n/**\n * `toRHT` converts the given model to Protobuf format.\n */\nfunction toRHT(rht: RHT): { [key: string]: PbNodeAttr } {\n const pbRHT: { [key: string]: PbNodeAttr } = {};\n for (const node of rht) {\n pbRHT[node.getKey()] = new PbNodeAttr({\n value: node.getValue(),\n updatedAt: toTimeTicket(node.getUpdatedAt()),\n isRemoved: node.isRemoved(),\n });\n }\n\n return pbRHT;\n}\n\n/**\n * `toTreeNodes` converts the given model to Protobuf format.\n */\nfunction toTreeNodes(node: CRDTTreeNode): Array<PbTreeNode> {\n if (!node) {\n return [];\n }\n\n const pbTreeNodes: Array<PbTreeNode> = [];\n traverseAll(node, (n, depth) => {\n const pbTreeNode = new PbTreeNode({\n id: toTreeNodeID(n.id),\n type: n.type,\n removedAt: toTimeTicket(n.removedAt),\n depth,\n });\n\n if (n.isText) {\n pbTreeNode.value = n.value;\n }\n if (n.insPrevID) {\n pbTreeNode.insPrevId = toTreeNodeID(n.insPrevID);\n }\n if (n.insNextID) {\n pbTreeNode.insNextId = toTreeNodeID(n.insNextID);\n }\n\n if (n.attrs) {\n pbTreeNode.attributes = toRHT(n.attrs);\n }\n\n pbTreeNodes.push(pbTreeNode);\n });\n\n return pbTreeNodes;\n}\n\n/**\n * `toObject` converts the given model to Protobuf format.\n */\nfunction toObject(obj: CRDTObject): PbJSONElement {\n const pbElement = new PbJSONElement();\n pbElement.body.case = 'jsonObject';\n pbElement.body.value = new PbJSONElement_JSONObject({\n nodes: toRHTNodes(obj.getRHT()),\n createdAt: toTimeTicket(obj.getCreatedAt()),\n movedAt: toTimeTicket(obj.getMovedAt()),\n removedAt: toTimeTicket(obj.getRemovedAt()),\n });\n return pbElement;\n}\n\n/**\n * `toArray` converts the given model to Protobuf format.\n */\nfunction toArray(arr: CRDTArray): PbJSONElement {\n const pbElement = new PbJSONElement();\n pbElement.body.case = 'jsonArray';\n pbElement.body.value = new PbJSONElement_JSONArray({\n nodes: toRGANodes(arr.getElements()),\n createdAt: toTimeTicket(arr.getCreatedAt()),\n movedAt: toTimeTicket(arr.getMovedAt()),\n removedAt: toTimeTicket(arr.getRemovedAt()),\n });\n return pbElement;\n}\n\n/**\n * `toPrimitive` converts the given model to Protobuf format.\n */\nfunction toPrimitive(primitive: Primitive): PbJSONElement {\n const pbElement = new PbJSONElement();\n pbElement.body.case = 'primitive';\n pbElement.body.value = new PbJSONElement_Primitive({\n type: toValueType(primitive.getType()),\n value: primitive.toBytes(),\n createdAt: toTimeTicket(primitive.getCreatedAt()),\n movedAt: toTimeTicket(primitive.getMovedAt()),\n removedAt: toTimeTicket(primitive.getRemovedAt()),\n });\n return pbElement;\n}\n\n/**\n * `toText` converts the given model to Protobuf format.\n */\nfunction toText(text: CRDTText<Record<string, any>>): PbJSONElement {\n const pbElement = new PbJSONElement();\n pbElement.body.case = 'text';\n pbElement.body.value = new PbJSONElement_Text({\n nodes: toTextNodes(text.getRGATreeSplit()),\n createdAt: toTimeTicket(text.getCreatedAt()),\n movedAt: toTimeTicket(text.getMovedAt()),\n removedAt: toTimeTicket(text.getRemovedAt()),\n });\n return pbElement;\n}\n\n/**\n * `toCounter` converts the given model to Protobuf format.\n */\nfunction toCounter(counter: CRDTCounter): PbJSONElement {\n const pbElement = new PbJSONElement();\n pbElement.body.case = 'counter';\n pbElement.body.value = new PbJSONElement_Counter({\n type: toCounterType(counter.getType()),\n value: counter.toBytes(),\n createdAt: toTimeTicket(counter.getCreatedAt()),\n movedAt: toTimeTicket(counter.getMovedAt()),\n removedAt: toTimeTicket(counter.getRemovedAt()),\n });\n return pbElement;\n}\n\n/**\n * `toTree` converts the given model to Protobuf format.\n */\nfunction toTree(tree: CRDTTree): PbJSONElement {\n const pbElement = new PbJSONElement();\n pbElement.body.case = 'tree';\n pbElement.body.value = new PbJSONElement_Tree({\n nodes: toTreeNodes(tree.getRoot()),\n createdAt: toTimeTicket(tree.getCreatedAt()),\n movedAt: toTimeTicket(tree.getMovedAt()),\n removedAt: toTimeTicket(tree.getRemovedAt()),\n });\n return pbElement;\n}\n\n/**\n * `toElement` converts the given model to Protobuf format.\n */\nfunction toElement(element: CRDTElement): PbJSONElement {\n if (element instanceof CRDTObject) {\n return toObject(element);\n }\n if (element instanceof CRDTArray) {\n return toArray(element);\n }\n if (element instanceof Primitive) {\n return toPrimitive(element);\n }\n if (element instanceof CRDTText) {\n return toText(element);\n }\n if (element instanceof CRDTCounter) {\n return toCounter(element);\n }\n if (element instanceof CRDTTree) {\n return toTree(element);\n }\n\n throw new YorkieError(Code.ErrUnimplemented, `unimplemented element`);\n}\n\n/**\n * `toChangePack` converts the given model to Protobuf format.\n */\nfunction toChangePack(pack: ChangePack<Indexable>): PbChangePack {\n return new PbChangePack({\n documentKey: pack.getDocumentKey(),\n checkpoint: toCheckpoint(pack.getCheckpoint()),\n isRemoved: pack.getIsRemoved(),\n changes: toChanges(pack.getChanges()),\n snapshot: pack.getSnapshot(),\n versionVector: toVersionVector(pack.getVersionVector()),\n minSyncedTicket: toTimeTicket(pack.getMinSyncedTicket()),\n });\n}\n\n/**\n * `errorMetadataOf` returns the error metadata of the given connect error.\n */\nexport function errorMetadataOf(error: ConnectError): Record<string, string> {\n if (!(error instanceof ConnectError)) {\n return {};\n }\n\n // NOTE(chacha912): Currently, we only use the first detail to represent the\n // error metadata.\n const infos = error.findDetails(ErrorInfo);\n for (const info of infos) {\n return info.metadata;\n }\n\n return {};\n}\n\n/**\n * `errorCodeOf` returns the error code of the given connect error.\n */\nexport function errorCodeOf(error: ConnectError): string {\n return errorMetadataOf(error).code ?? '';\n}\n\n/**\n * `fromChangeID` converts the given Protobuf format to model format.\n */\nfunction fromChangeID(pbChangeID: PbChangeID): ChangeID {\n // TODO(hackerwins): Remove BigInt conversion. Some of the bigint values are\n // passed as string in the protobuf. We should fix this in the future.\n return ChangeID.of(\n pbChangeID.clientSeq,\n BigInt(pbChangeID.lamport),\n toHexString(pbChangeID.actorId),\n fromVersionVector(pbChangeID.versionVector)!,\n BigInt(pbChangeID.serverSeq),\n );\n}\n\n/**\n * `fromVersionVector` converts the given Protobuf format to model format.\n */\nfunction fromVersionVector(\n pbVersionVector?: PbVersionVector,\n): VersionVector | undefined {\n if (!pbVersionVector) {\n return;\n }\n\n const vector = new VersionVector();\n Object.entries(pbVersionVector.vector).forEach(([key, value]) => {\n vector.set(key, BigInt(value.toString()));\n });\n return vector;\n}\n\n/**\n * `fromTimeTicket` converts the given Protobuf format to model format.\n */\nfunction fromTimeTicket(pbTimeTicket?: PbTimeTicket): TimeTicket | undefined {\n if (!pbTimeTicket) {\n return;\n }\n\n return TimeTicket.of(\n BigInt(pbTimeTicket.lamport),\n pbTimeTicket.delimiter,\n toHexString(pbTimeTicket.actorId),\n );\n}\n\n/**\n * `fromPresence` converts the given Protobuf format to model format.\n */\nfunction fromPresence<P extends Indexable>(pbPresence: PbPresence): P {\n const data: Record<string, string> = {};\n Object.entries(pbPresence.data).forEach(([key, value]) => {\n data[key] = JSON.parse(value);\n });\n\n return data as P;\n}\n\n/**\n * `fromPresenceChange` converts the given Protobuf format to model format.\n */\nfunction fromPresenceChange<P extends Indexable>(\n pbPresenceChange: PbPresenceChange,\n): PresenceChange<P> {\n const type = pbPresenceChange.type;\n if (type === PbPresenceChange_ChangeType.PUT) {\n const presence = fromPresence<P>(pbPresenceChange.presence!);\n return {\n type: PresenceChangeType.Put,\n presence,\n };\n }\n if (type === PbPresenceChange_ChangeType.CLEAR) {\n return {\n type: PresenceChangeType.Clear,\n };\n }\n\n throw new YorkieError(Code.ErrInvalidType, `unsupported type: ${type}`);\n}\n\n/**\n * `fromPresences` converts the given Protobuf format to model format.\n */\nfunction fromPresences<P extends Indexable>(pbPresences: {\n [key: string]: PbPresence;\n}): Map<ActorID, P> {\n const presences = new Map<ActorID, P>();\n Object.entries(pbPresences).forEach(([actorID, pbPresence]) => {\n presences.set(actorID, fromPresence(pbPresence));\n });\n return presences;\n}\n\n/**\n * `fromValueType` converts the given Protobuf format to model format.\n */\nfunction fromValueType(pbValueType: PbValueType): PrimitiveType {\n switch (pbValueType) {\n case PbValueType.NULL:\n return PrimitiveType.Null;\n case PbValueType.BOOLEAN:\n return PrimitiveType.Boolean;\n case PbValueType.INTEGER:\n return PrimitiveType.Integer;\n case PbValueType.LONG:\n return PrimitiveType.Long;\n case PbValueType.DOUBLE:\n return PrimitiveType.Double;\n case PbValueType.STRING:\n return PrimitiveType.String;\n case PbValueType.BYTES:\n return PrimitiveType.Bytes;\n case PbValueType.DATE:\n return PrimitiveType.Date;\n }\n throw new YorkieError(\n Code.ErrUnimplemented,\n `unimplemented value type: ${pbValueType}`,\n );\n}\n\n/**\n * `fromCounterType` converts the given Protobuf format to model format.\n */\nfunction fromCounterType(pbValueType: PbValueType): CounterType {\n switch (pbValueType) {\n case PbValueType.INTEGER_CNT:\n return CounterType.IntegerCnt;\n case PbValueType.LONG_CNT:\n return CounterType.LongCnt;\n }\n throw new YorkieError(\n Code.ErrUnimplemented,\n `unimplemented value type: ${pbValueType}`,\n );\n}\n\n/**\n * `fromElementSimple` converts the given Protobuf format to model format.\n */\nfunction fromElementSimple(pbElementSimple: PbJSONElementSimple): CRDTElement {\n switch (pbElementSimple.type) {\n case PbValueType.JSON_OBJECT:\n if (!pbElementSimple.value) {\n return CRDTObject.create(fromTimeTicket(pbElementSimple.createdAt)!);\n }\n return bytesToObject(pbElementSimple.value);\n case PbValueType.JSON_ARRAY:\n if (!pbElementSimple.value) {\n return CRDTArray.create(fromTimeTicket(pbElementSimple.createdAt)!);\n }\n return bytesToArray(pbElementSimple.value);\n case PbValueType.TEXT:\n return CRDTText.create(\n RGATreeSplit.create(),\n fromTimeTicket(pbElementSimple.createdAt)!,\n );\n case PbValueType.TREE:\n return bytesToTree(pbElementSimple.value)!;\n case PbValueType.NULL:\n case PbValueType.BOOLEAN:\n case PbValueType.INTEGER:\n case PbValueType.LONG:\n case PbValueType.DOUBLE:\n case PbValueType.STRING:\n case PbValueType.BYTES:\n case PbValueType.DATE:\n return Primitive.of(\n Primitive.valueFromBytes(\n fromValueType(pbElementSimple.type),\n pbElementSimple.value,\n ),\n fromTimeTicket(pbElementSimple.createdAt)!,\n );\n case PbValueType.INTEGER_CNT:\n case PbValueType.LONG_CNT:\n return CRDTCounter.create(\n fromCounterType(pbElementSimple.type),\n CRDTCounter.valueFromBytes(\n fromCounterType(pbElementSimple.type),\n pbElementSimple.value,\n ),\n fromTimeTicket(pbElementSimple.createdAt)!,\n );\n }\n}\n\n/**\n * `fromTextNodePos` converts the given Protobuf format to model format.\n */\nfunction fromTextNodePos(pbTextNodePos: PbTextNodePos): RGATreeSplitPos {\n return RGATreeSplitPos.of(\n RGATreeSplitNodeID.of(\n fromTimeTicket(pbTextNodePos.createdAt)!,\n pbTextNodePos.offset,\n ),\n pbTextNodePos.relativeOffset,\n );\n}\n\n/**\n * `fromTextNodeID` converts the given Protobuf format to model format.\n */\nfunction fromTextNodeID(pbTextNodeID: PbTextNodeID): RGATreeSplitNodeID {\n return RGATreeSplitNodeID.of(\n fromTimeTicket(pbTextNodeID.createdAt)!,\n pbTextNodeID.offset,\n );\n}\n\n/**\n * `fromTextNode` converts the given Protobuf format to model format.\n */\nfunction fromTextNode(pbTextNode: PbTextNode): RGATreeSplitNode<CRDTTextValue> {\n const textValue = CRDTTextValue.create(pbTextNode.value);\n Object.entries(pbTextNode.attributes).forEach(([key, value]) => {\n textValue.setAttr(key, value.value, fromTimeTicket(value.updatedAt)!);\n });\n\n const textNode = RGATreeSplitNode.create(\n fromTextNodeID(pbTextNode.id!),\n textValue,\n );\n textNode.remove(fromTimeTicket(pbTextNode.removedAt));\n return textNode;\n}\n\n/**\n * `fromTreePos` converts the given Protobuf format to model format.\n */\nfunction fromTreePos(pbTreePos: PbTreePos): CRDTTreePos {\n return CRDTTreePos.of(\n fromTreeNodeID(pbTreePos.parentId!),\n fromTreeNodeID(pbTreePos.leftSiblingId!),\n );\n}\n\n/**\n * `fromTreeNodeID` converts the given Protobuf format to model format.\n */\nfunction fromTreeNodeID(pbTreeNodeID: PbTreeNodeID): CRDTTreeNodeID {\n return CRDTTreeNodeID.of(\n fromTimeTicket(pbTreeNodeID.createdAt)!,\n pbTreeNodeID.offset,\n );\n}\n\n/**\n * `fromTreeNodesWhenEdit` converts the given Protobuf format to model format.\n */\nfunction fromTreeNodesWhenEdit(\n pbTreeNodes: Array<PbTreeNodes>,\n): Array<CRDTTreeNode> | undefined {\n if (!pbTreeNodes.length) {\n return;\n }\n\n const treeNodes: Array<CRDTTreeNode> = [];\n pbTreeNodes.forEach((node) => {\n const treeNode = fromTreeNodes(node.content);\n treeNodes.push(treeNode!);\n });\n\n return treeNodes;\n}\n\n/**\n * `fromTreeNodes` converts the given Protobuf format to model format.\n */\nfunction fromTreeNodes(\n pbTreeNodes: Array<PbTreeNode>,\n): CRDTTreeNode | undefined {\n if (pbTreeNodes.length === 0) {\n return;\n }\n\n const nodes: Array<CRDTTreeNode> = [];\n for (const pbTreeNode of pbTreeNodes) {\n nodes.push(fromTreeNode(pbTreeNode));\n }\n\n const root = nodes[nodes.length - 1];\n const depthTable = new Map<number, CRDTTreeNode>();\n depthTable.set(pbTreeNodes[nodes.length - 1].depth, nodes[nodes.length - 1]);\n for (let i = nodes.length - 2; i >= 0; i--) {\n const parent = depthTable.get(pbTreeNodes[i].depth - 1);\n parent!.prepend(nodes[i]);\n depthTable.set(pbTreeNodes[i].depth, nodes[i]);\n }\n\n root.updateDescendantsSize();\n\n // build CRDTTree from the root to construct the links between nodes.\n return CRDTTree.create(root, InitialTimeTicket).getRoot();\n}\n\n/**\n * `fromRHT` converts the given Protobuf format to model format.\n */\nfunction fromRHT(pbRHT: { [key: string]: PbNodeAttr }): RHT {\n const rht = RHT.create();\n for (const [key, pbRHTNode] of Object.entries(pbRHT)) {\n rht.setInternal(\n key,\n pbRHTNode.value,\n fromTimeTicket(pbRHTNode.updatedAt)!,\n pbRHTNode.isRemoved,\n );\n }\n\n return rht;\n}\n\n/**\n * `fromTreeNode` converts the given Protobuf format to model format.\n */\nfunction fromTreeNode(pbTreeNode: PbTreeNode): CRDTTreeNode {\n const id = fromTreeNodeID(pbTreeNode.id!);\n const node = CRDTTreeNode.create(id, pbTreeNode.type);\n const pbAttrs = Object.entries(pbTreeNode.attributes);\n if (node.isText) {\n node.value = pbTreeNode.value;\n } else if (pbAttrs.length) {\n node.attrs = fromRHT(pbTreeNode.attributes);\n }\n\n if (pbTreeNode.insPrevId) {\n node.insPrevID = fromTreeNodeID(pbTreeNode.insPrevId);\n }\n\n if (pbTreeNode.insNextId) {\n node.insNextID = fromTreeNodeID(pbTreeNode.insNextId);\n }\n\n node.removedAt = fromTimeTicket(pbTreeNode.removedAt);\n\n return node;\n}\n\n/**\n * `fromOperation` converts the given Protobuf format to model format.\n */\nfunction fromOperation(pbOperation: PbOperation): Operation | undefined {\n if (pbOperation.body.case === 'set') {\n const pbSetOperation = pbOperation.body.value;\n return SetOperation.create(\n pbSetOperation!.key,\n fromElementSimple(pbSetOperation!.value!),\n fromTimeTicket(pbSetOperation!.parentCreatedAt)!,\n fromTimeTicket(pbSetOperation!.executedAt)!,\n );\n } else if (pbOperation.body.case === 'add') {\n const pbAddOperation = pbOperation.body.value;\n return AddOperation.create(\n fromTimeTicket(pbAddOperation!.parentCreatedAt)!,\n fromTimeTicket(pbAddOperation!.prevCreatedAt)!,\n fromElementSimple(pbAddOperation!.value!),\n fromTimeTicket(pbAddOperation!.executedAt)!,\n );\n } else if (pbOperation.body.case === 'move') {\n const pbMoveOperation = pbOperation.body.value;\n return MoveOperation.create(\n fromTimeTicket(pbMoveOperation!.parentCreatedAt)!,\n fromTimeTicket(pbMoveOperation!.prevCreatedAt)!,\n fromTimeTicket(pbMoveOperation!.createdAt)!,\n fromTimeTicket(pbMoveOperation!.executedAt)!,\n );\n } else if (pbOperation.body.case === 'remove') {\n const pbRemoveOperation = pbOperation.body.value;\n return RemoveOperation.create(\n fromTimeTicket(pbRemoveOperation!.parentCreatedAt)!,\n fromTimeTicket(pbRemoveOperation!.createdAt)!,\n fromTimeTicket(pbRemoveOperation!.executedAt)!,\n );\n } else if (pbOperation.body.case === 'edit') {\n const pbEditOperation = pbOperation.body.value;\n const createdAtMapByActor = new Map();\n Object.entries(pbEditOperation!.createdAtMapByActor).forEach(\n ([key, value]) => {\n createdAtMapByActor.set(key, fromTimeTicket(value));\n },\n );\n const attributes = new Map();\n Object.entries(pbEditOperation!.attributes).forEach(([key, value]) => {\n attributes.set(key, value);\n });\n return EditOperation.create(\n fromTimeTicket(pbEditOperation!.parentCreatedAt)!,\n fromTextNodePos(pbEditOperation!.from!),\n fromTextNodePos(pbEditOperation!.to!),\n createdAtMapByActor,\n pbEditOperation!.content,\n attributes,\n fromTimeTicket(pbEditOperation!.executedAt)!,\n );\n } else if (pbOperation.body.case === 'style') {\n const pbStyleOperation = pbOperation.body.value;\n const createdAtMapByActor = new Map();\n Object.entries(pbStyleOperation!.createdAtMapByActor).forEach(\n ([key, value]) => {\n createdAtMapByActor.set(key, fromTimeTicket(value));\n },\n );\n const attributes = new Map();\n Object.entries(pbStyleOperation!.attributes).forEach(([key, value]) => {\n attributes.set(key, value);\n });\n return StyleOperation.create(\n fromTimeTicket(pbStyleOperation!.parentCreatedAt)!,\n fromTextNodePos(pbStyleOperation!.from!),\n fromTextNodePos(pbStyleOperation!.to!),\n createdAtMapByActor,\n attributes,\n fromTimeTicket(pbStyleOperation!.executedAt)!,\n );\n } else if (pbOperation.body.case === 'select') {\n // TODO(hackerwins): Select is deprecated.\n return;\n } else if (pbOperation.body.case === 'increase') {\n const pbIncreaseOperation = pbOperation.body.value;\n return IncreaseOperation.create(\n fromTimeTicket(pbIncreaseOperation!.parentCreatedAt)!,\n fromElementSimple(pbIncreaseOperation!.value!),\n fromTimeTicket(pbIncreaseOperation!.executedAt)!,\n );\n } else if (pbOperation.body.case === 'treeEdit') {\n const pbTreeEditOperation = pbOperation.body.value;\n const createdAtMapByActor = new Map();\n Object.entries(pbTreeEditOperation!.createdAtMapByActor).forEach(\n ([key, value]) => {\n createdAtMapByActor.set(key, fromTimeTicket(value));\n },\n );\n return TreeEditOperation.create(\n fromTimeTicket(pbTreeEditOperation!.parentCreatedAt)!,\n fromTreePos(pbTreeEditOperation!.from!),\n fromTreePos(pbTreeEditOperation!.to!),\n fromTreeNodesWhenEdit(pbTreeEditOperation!.contents),\n pbTreeEditOperation!.splitLevel,\n createdAtMapByActor,\n fromTimeTicket(pbTreeEditOperation!.executedAt)!,\n );\n } else if (pbOperation.body.case === 'treeStyle') {\n const pbTreeStyleOperation = pbOperation.body.value;\n const attributes = new Map();\n const attributesToRemove = pbTreeStyleOperation.attributesToRemove;\n const createdAtMapByActor = new Map();\n if (pbTreeStyleOperation?.createdAtMapByActor) {\n Object.entries(pbTreeStyleOperation!.createdAtMapByActor).forEach(\n ([key, value]) => {\n createdAtMapByActor.set(key, fromTimeTicket(value));\n },\n );\n }\n\n if (attributesToRemove?.length > 0) {\n return TreeStyleOperation.createTreeRemoveStyleOperation(\n fromTimeTicket(pbTreeStyleOperation!.parentCreatedAt)!,\n fromTreePos(pbTreeStyleOperation!.from!),\n fromTreePos(pbTreeStyleOperation!.to!),\n createdAtMapByActor,\n attributesToRemove,\n fromTimeTicket(pbTreeStyleOperation!.executedAt)!,\n );\n } else {\n Object.entries(pbTreeStyleOperation!.attributes).forEach(\n ([key, value]) => {\n attributes.set(key, value);\n },\n );\n return TreeStyleOperation.create(\n fromTimeTicket(pbTreeStyleOperation!.parentCreatedAt)!,\n fromTreePos(pbTreeStyleOperation!.from!),\n fromTreePos(pbTreeStyleOperation!.to!),\n createdAtMapByActor,\n attributes,\n fromTimeTicket(pbTreeStyleOperation!.executedAt)!,\n );\n }\n } else {\n throw new YorkieError(Code.ErrUnimplemented, `unimplemented operation`);\n }\n}\n\n/**\n * `fromOperations` converts the given Protobuf format to model format.\n */\nfunction fromOperations(pbOperations: Array<PbOperation>): Array<Operation> {\n const operations = [];\n for (const pbOperation of pbOperations) {\n const operation = fromOperation(pbOperation);\n if (operation) {\n operations.push(operation);\n }\n }\n return operations;\n}\n\n/**\n * `fromChanges` converts the given Protobuf format to model format.\n */\nfunction fromChanges<P extends Indexable>(\n pbChanges: Array<PbChange>,\n): Array<Change<P>> {\n const changes: Array<Change<P>> = [];\n\n for (const pbChange of pbChanges) {\n changes.push(\n Change.create({\n id: fromChangeID(pbChange.id!),\n operations: fromOperations(pbChange.operations),\n presenceChange: pbChange.presenceChange\n ? fromPresenceChange(pbChange.presenceChange!)\n : undefined,\n message: pbChange.message,\n }),\n );\n }\n\n return changes;\n}\n\n/**\n * `fromCheckpoint` converts the given Protobuf format to model format.\n */\nfunction fromCheckpoint(pbCheckpoint: PbCheckpoint): Checkpoint {\n return Checkpoint.of(BigInt(pbCheckpoint.serverSeq), pbCheckpoint.clientSeq);\n}\n\n/**\n * `fromChangePack` converts the given Protobuf format to model format.\n */\nfunction fromChangePack<P extends Indexable>(\n pbPack: PbChangePack,\n): ChangePack<P> {\n return ChangePack.create<P>(\n pbPack.documentKey!,\n fromCheckpoint(pbPack.checkpoint!),\n pbPack.isRemoved,\n fromChanges(pbPack.changes),\n fromVersionVector(pbPack.versionVector),\n pbPack.snapshot,\n fromTimeTicket(pbPack.minSyncedTicket),\n );\n}\n\n/**\n * `fromObject` converts the given Protobuf format to model format.\n */\nfunction fromObject(pbObject: PbJSONElement_JSONObject): CRDTObject {\n const rht = new ElementRHT();\n for (const pbRHTNode of pbObject.nodes) {\n const value = fromElement(pbRHTNode.element!);\n rht.set(pbRHTNode.key, value, value.getPositionedAt());\n }\n\n const obj = new CRDTObject(fromTimeTicket(pbObject.createdAt)!, rht);\n obj.setMovedAt(fromTimeTicket(pbObject.movedAt));\n obj.setRemovedAt(fromTimeTicket(pbObject.removedAt));\n return obj;\n}\n\n/**\n * `fromArray` converts the given Protobuf format to model format.\n */\nfunction fromArray(pbArray: PbJSONElement_JSONArray): CRDTArray {\n const rgaTreeList = new RGATreeList();\n for (const pbRGANode of pbArray.nodes) {\n // eslint-disable-next-line\n rgaTreeList.insert(fromElement(pbRGANode.element!));\n }\n\n const arr = new CRDTArray(fromTimeTicket(pbArray.createdAt)!, rgaTreeList);\n arr.setMovedAt(fromTimeTicket(pbArray.movedAt));\n arr.setRemovedAt(fromTimeTicket(pbArray.removedAt));\n return arr;\n}\n\n/**\n * `fromPrimitive` converts the given Protobuf format to model format.\n */\nfunction fromPrimitive(pbPrimitive: PbJSONElement_Primitive): Primitive {\n const primitive = Primitive.of(\n Primitive.valueFromBytes(\n fromValueType(pbPrimitive.type),\n pbPrimitive.value,\n ),\n fromTimeTicket(pbPrimitive.createdAt)!,\n );\n primitive.setMovedAt(fromTimeTicket(pbPrimitive.movedAt));\n primitive.setRemovedAt(fromTimeTicket(pbPrimitive.removedAt));\n return primitive;\n}\n\n/**\n * `fromText` converts the given Protobuf format to model format.\n */\nfunction fromText<A extends Indexable>(\n pbText: PbJSONElement_Text,\n): CRDTText<A> {\n const rgaTreeSplit = new RGATreeSplit<CRDTTextValue>();\n\n let prev = rgaTreeSplit.getHead();\n for (const pbNode of pbText.nodes) {\n const current = rgaTreeSplit.insertAfter(prev, fromTextNode(pbNode));\n if (pbNode.insPrevId) {\n current.setInsPrev(\n rgaTreeSplit.findNode(fromTextNodeID(pbNode.insPrevId!)),\n );\n }\n prev = current;\n }\n const text = new CRDTText<A>(rgaTreeSplit, fromTimeTicket(pbText.createdAt)!);\n text.setMovedAt(fromTimeTicket(pbText.movedAt));\n text.setRemovedAt(fromTimeTicket(pbText.removedAt));\n return text;\n}\n\n/**\n * `fromCounter` converts the given Protobuf format to model format.\n */\nfunction fromCounter(pbCounter: PbJSONElement_Counter): CRDTCounter {\n const counter = CRDTCounter.create(\n fromCounterType(pbCounter.type),\n CRDTCounter.valueFromBytes(\n fromCounterType(pbCounter.type),\n pbCounter.value,\n ),\n fromTimeTicket(pbCounter.createdAt)!,\n );\n counter.setMovedAt(fromTimeTicket(pbCounter.movedAt));\n counter.setRemovedAt(fromTimeTicket(pbCounter.removedAt));\n return counter;\n}\n\n/**\n * `fromTree` converts the given Protobuf format to model format.\n */\nfunction fromTree(pbTree: PbJSONElement_Tree): CRDTTree {\n const root = fromTreeNodes(pbTree.nodes);\n return CRDTTree.create(root!, fromTimeTicket(pbTree.createdAt)!);\n}\n\n/**\n * `fromElement` converts the given Protobuf format to model format.\n */\nfunction fromElement(pbElement: PbJSONElement): CRDTElement {\n if (pbElement.body.case === 'jsonObject') {\n return fromObject(pbElement.body.value!);\n } else if (pbElement.body.case === 'jsonArray') {\n return fromArray(pbElement.body.value!);\n } else if (pbElement.body.case === 'primitive') {\n return fromPrimitive(pbElement.body.value!);\n } else if (pbElement.body.case === 'text') {\n return fromText(pbElement.body.value!);\n } else if (pbElement.body.case === 'counter') {\n return fromCounter(pbElement.body.value!);\n } else if (pbElement.body.case === 'tree') {\n return fromTree(pbElement.body.value!);\n } else {\n throw new YorkieError(Code.ErrUnimplemented, `unimplemented element`);\n }\n}\n\n/**\n * `bytesToSnapshot` creates a Snapshot from the given byte array.\n */\nfunction bytesToSnapshot<P extends Indexable>(\n bytes?: Uint8Array,\n): {\n root: CRDTObject;\n presences: Map<ActorID, P>;\n} {\n if (!bytes) {\n return {\n root: CRDTObject.create(InitialTimeTicket),\n presences: new Map(),\n };\n }\n\n const snapshot = PbSnapshot.fromBinary(bytes);\n return {\n root: fromElement(snapshot.root!) as CRDTObject,\n presences: fromPresences<P>(snapshot.presences),\n };\n}\n\n/**\n * `versionVectorToHex` converts the given VersionVector to bytes.\n */\nfunction versionVectorToHex(vector: VersionVector): string {\n const pbVersionVector = toVersionVector(vector)!;\n\n return bytesToHex(pbVersionVector.toBinary());\n}\n\n/**\n * `hexToVersionVector` creates a VersionVector from the given bytes.\n */\nfunction hexToVersionVector(hex: string): VersionVector {\n const bytes = hexToBytes(hex);\n const pbVersionVector = PbVersionVector.fromBinary(bytes);\n\n return fromVersionVector(pbVersionVector)!;\n}\n\n/**\n * `bytesToObject` creates an JSONObject from the given byte array.\n */\nfunction bytesToObject(bytes?: Uint8Array): CRDTObject {\n if (!bytes) {\n throw new YorkieError(Code.ErrInvalidArgument, 'bytes is empty');\n }\n\n const pbElement = PbJSONElement.fromBinary(bytes);\n return fromObject(pbElement.body.value! as PbJSONElement_JSONObject);\n}\n\n/**\n * `objectToBytes` converts the given JSONObject to byte array.\n */\nfunction objectToBytes(obj: CRDTObject): Uint8Array {\n return toElement(obj).toBinary();\n}\n\n/**\n * `bytesToArray` creates an CRDTArray from the given bytes.\n */\nfunction bytesToArray(bytes?: Uint8Array): CRDTArray {\n if (!bytes) {\n throw new YorkieError(Code.ErrInvalidArgument, 'bytes is empty');\n }\n\n const pbElement = PbJSONElement.fromBinary(bytes);\n return fromArray(pbElement.body.value! as PbJSONElement_JSONArray);\n}\n\n/**\n * `arrayToBytes` converts the given CRDTArray to bytes.\n */\nfunction arrayToBytes(array: CRDTArray): Uint8Array {\n return toArray(array).toBinary();\n}\n\n/**\n * `bytesToTree` creates an CRDTTree from the given bytes.\n */\nfunction bytesToTree(bytes?: Uint8Array): CRDTTree {\n if (!bytes) {\n throw new YorkieError(Code.ErrInvalidArgument, 'bytes is empty');\n }\n\n const pbElement = PbJSONElement.fromBinary(bytes);\n return fromTree(pbElement.body.value! as PbJSONElement_Tree);\n}\n\n/**\n * `treeToBytes` converts the given tree to bytes.\n */\nfunction treeToBytes(tree: CRDTTree): Uint8Array {\n return toTree(tree).toBinary();\n}\n\n/**\n * `bytesToHex` creates an hex string from the given byte array.\n */\nfunction bytesToHex(bytes?: Uint8Array): string {\n if (!bytes) {\n return '';\n }\n\n return Array.from(bytes)\n .map((b) => b.toString(16).padStart(2, '0'))\n .join('');\n}\n\n/**\n * `toHexString` converts the given byte array to hex string.\n */\nfunction toHexString(bytes: Uint8Array): string {\n return bytesToHex(bytes);\n}\n\n/**\n * `hexToBytes` converts the given hex string to byte array.\n */\nfunction hexToBytes(hex: string): Uint8Array {\n return new Uint8Array(\n hex.match(/.{1,2}/g)!.map((byte) => parseInt(byte, 16)),\n );\n}\n\n/**\n * `toUnit8Array` converts the given hex string to byte array.\n */\nfunction toUint8Array(hex: string): Uint8Array {\n return hexToBytes(hex);\n}\n\n/**\n * `bytesToChangeID` creates a ChangeID from the given bytes.\n */\nfunction bytesToChangeID(bytes: Uint8Array): ChangeID {\n const pbChangeID = PbChangeID.fromBinary(bytes);\n return fromChangeID(pbChangeID);\n}\n\n/**\n * `bytesToOperation` creates an Operation from the given bytes.\n */\nfunction bytesToOperation(bytes: Uint8Array): Operation {\n const pbOperation = PbOperation.fromBinary(bytes);\n return fromOperation(pbOperation)!;\n}\n\n/**\n * `converter` is a converter that converts the given model to protobuf format.\n * is also used to convert models to bytes and vice versa.\n */\nexport const converter = {\n fromPresence,\n toChangePack,\n fromChangePack,\n fromChanges,\n toTreeNodes,\n fromTreeNodes,\n objectToBytes,\n bytesToObject,\n bytesToSnapshot,\n bytesToHex,\n hexToBytes,\n toHexString,\n toUint8Array,\n toOperation,\n toChangeID,\n PbChangeID,\n bytesToChangeID,\n bytesToOperation,\n versionVectorToHex,\n hexToVersionVector,\n};\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport enum LogLevel {\n Trivial,\n Debug,\n Info,\n Warn,\n Error,\n Fatal,\n}\n\nlet level = LogLevel.Warn;\n\n/**\n * `setLogLevel` sets log level.\n */\nexport function setLogLevel(l: LogLevel): void {\n level = l;\n}\n\nexport const logger = {\n trivial: (...messages: Array<unknown>): void => {\n if (level > LogLevel.Trivial) {\n return;\n }\n\n if (typeof console != 'undefined') {\n console.log('YORKIE T:', ...messages);\n }\n },\n\n debug: (...messages: Array<unknown>): void => {\n if (level > LogLevel.Debug) {\n return;\n }\n\n if (typeof console != 'undefined') {\n console.log('YORKIE D:', ...messages);\n }\n },\n\n info: (...messages: Array<unknown>): void => {\n if (level > LogLevel.Info) {\n return;\n }\n\n if (typeof console != 'undefined') {\n console.log('YORKIE I:', ...messages);\n }\n },\n\n warn: (...messages: Array<unknown>): void => {\n if (level > LogLevel.Warn) {\n return;\n }\n\n if (typeof console != 'undefined') {\n if (typeof console.warn !== 'undefined') {\n console.warn('YORKIE W:', ...messages);\n } else {\n console.log('YORKIE W:', ...messages);\n }\n }\n },\n\n error: (...messages: Array<unknown>): void => {\n if (level > LogLevel.Error) {\n return;\n }\n\n if (typeof console != 'undefined') {\n if (typeof console.error !== 'undefined') {\n console.error('YORKIE E:', ...messages);\n } else {\n console.log('YORKIE E:', ...messages);\n }\n }\n },\n\n fatal: (...messages: Array<unknown>): void => {\n if (typeof console != 'undefined') {\n if (typeof console.error !== 'undefined') {\n console.error('YORKIE F:', ...messages);\n } else {\n console.log('YORKIE F:', ...messages);\n }\n }\n },\n\n isEnabled: (l: LogLevel): boolean => {\n return level <= l;\n },\n};\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type UUID = string;\n\n/**\n * `uuid` generates uuid string\n * @see http://www.ietf.org/rfc/rfc4122.txt\n */\nexport function uuid(): UUID {\n return 'xxxxxxxx-xxxx-4xxxy-xxxx-xxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n const v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n","import { Document, Indexable } from '@yorkie-js-sdk/src/document/document';\nimport { SyncMode } from '@yorkie-js-sdk/src/client/client';\nimport { Unsubscribe } from '../yorkie';\n\n/**\n * `WatchStream` is a stream that watches the changes of the document.\n */\nexport type WatchStream = any; // TODO(hackerwins): Define proper type of watchStream.\n\n/**\n * `Attachment` is a class that manages the state of the document.\n */\nexport class Attachment<T, P extends Indexable> {\n // TODO(hackerwins): Consider to changing the modifiers of the following properties to private.\n private reconnectStreamDelay: number;\n doc: Document<T, P>;\n docID: string;\n syncMode: SyncMode;\n remoteChangeEventReceived: boolean;\n\n watchStream?: WatchStream;\n watchLoopTimerID?: ReturnType<typeof setTimeout>;\n watchAbortController?: AbortController;\n\n unsubscribeBroadcastEvent: Unsubscribe;\n\n constructor(\n reconnectStreamDelay: number,\n doc: Document<T, P>,\n docID: string,\n syncMode: SyncMode,\n unsubscribeBroacastEvent: Unsubscribe,\n ) {\n this.reconnectStreamDelay = reconnectStreamDelay;\n this.doc = doc;\n this.docID = docID;\n this.syncMode = syncMode;\n this.remoteChangeEventReceived = false;\n this.unsubscribeBroadcastEvent = unsubscribeBroacastEvent;\n }\n\n /**\n * `changeSyncMode` changes the sync mode of the document.\n */\n public changeSyncMode(syncMode: SyncMode) {\n this.syncMode = syncMode;\n }\n\n /**\n * `needRealtimeSync` returns whether the document needs to be synced in real time.\n */\n public needRealtimeSync(): boolean {\n if (this.syncMode === SyncMode.RealtimeSyncOff) {\n return false;\n }\n\n if (this.syncMode === SyncMode.RealtimePushOnly) {\n return this.doc.hasLocalChanges();\n }\n\n return (\n this.syncMode !== SyncMode.Manual &&\n (this.doc.hasLocalChanges() || this.remoteChangeEventReceived)\n );\n }\n\n /**\n * `runWatchLoop` runs the watch loop.\n */\n public async runWatchLoop(\n watchStreamCreator: (onDisconnect: () => void) => Promise<WatchStream>,\n ): Promise<void> {\n const doLoop = async (): Promise<void> => {\n if (this.watchStream) {\n return Promise.resolve();\n }\n if (this.watchLoopTimerID) {\n clearTimeout(this.watchLoopTimerID);\n this.watchLoopTimerID = undefined;\n }\n\n try {\n [this.watchStream, this.watchAbortController] =\n await watchStreamCreator(() => {\n this.watchStream = undefined;\n this.watchAbortController = undefined;\n this.watchLoopTimerID = setTimeout(\n doLoop,\n this.reconnectStreamDelay,\n );\n });\n } catch (err) {\n // TODO(hackerwins): For now, if the creation of the watch stream fails,\n // it is considered normal and the watch loop is executed again after a\n // certain period of time.\n // In the future, we need to find a better way to handle this.\n }\n };\n\n await doLoop();\n }\n\n /**\n * `cancelWatchStream` cancels the watch stream.\n */\n public cancelWatchStream(): void {\n if (this.watchStream && this.watchAbortController) {\n this.watchAbortController.abort();\n this.watchStream = undefined;\n this.watchAbortController = undefined;\n }\n clearTimeout(this.watchLoopTimerID);\n this.watchLoopTimerID = undefined;\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { logger } from '@yorkie-js-sdk/src/util/logger';\nimport { uuid } from '@yorkie-js-sdk/src/util/uuid';\nimport { Code, YorkieError } from './error';\n\nexport type NextFn<T> = (value: T) => void;\n\nexport type ErrorFn = (error: Error) => void;\n\nexport type CompleteFn = () => void;\n\nexport interface Observer<T> {\n next: NextFn<T>;\n error?: ErrorFn;\n complete?: CompleteFn;\n}\n\nexport type Unsubscribe = () => void;\n\nexport interface SubscribeFn<T> {\n (\n next: Observer<T> | NextFn<T>,\n error?: ErrorFn,\n complete?: CompleteFn,\n ): Unsubscribe;\n (observer: Observer<T>): Unsubscribe;\n}\n\ninterface ObserverEntry<T> {\n subscriptionID: string;\n observer: Observer<T>;\n}\n\nconst Noop = (): void => {\n // Do nothing\n};\n\n/**\n * `ObserverProxy` is proxy of `Observer`.\n */\nclass ObserverProxy<T> implements Observer<T> {\n public finalized = false;\n\n private observers: Array<ObserverEntry<T>> | undefined = [];\n private finalError?: Error;\n\n constructor(executor: Executor<T>) {\n try {\n executor(this);\n } catch (error: any) {\n this.error(error);\n }\n }\n\n /**\n * `next` iterates next observer synchronously.\n */\n public next(value: T): void {\n this.forEachObserver((observer: Observer<T>) => {\n observer.next(value);\n });\n }\n\n /**\n * `error` invoke error.\n */\n public error(error: Error): void {\n this.forEachObserver((observer: Observer<T>) => {\n observer.error!(error);\n });\n this.close(error);\n }\n\n /**\n * `complete` completes observer.\n */\n public complete(): void {\n this.forEachObserver((observer: Observer<T>) => {\n observer.complete!();\n });\n this.close();\n }\n\n /**\n * `subscribe` is a function for subscribing observer.\n */\n public subscribe(\n nextOrObserver: Observer<T> | NextFn<T>,\n error?: ErrorFn,\n complete?: CompleteFn,\n ): Unsubscribe {\n let observer: Observer<T>;\n\n if (!nextOrObserver) {\n throw new YorkieError(Code.ErrInvalidArgument, 'missing observer');\n }\n\n if (this.finalized) {\n throw new YorkieError(\n Code.ErrRefused,\n 'observable is finalized due to previous error',\n );\n }\n\n if (typeof nextOrObserver === 'object') {\n observer = nextOrObserver as Observer<T>;\n } else {\n observer = {\n next: nextOrObserver as NextFn<T>,\n error,\n complete,\n } as Observer<T>;\n }\n\n if (observer.next === undefined) {\n observer.next = Noop as NextFn<T>;\n }\n if (observer.error === undefined) {\n observer.error = Noop as ErrorFn;\n }\n if (observer.complete === undefined) {\n observer.complete = Noop as CompleteFn;\n }\n\n const id = uuid();\n const unsub = this.unsubscribeOne.bind(this, id);\n\n this.observers!.push({\n subscriptionID: id,\n observer: observer as Observer<T>,\n });\n\n if (this.finalized) {\n try {\n if (this.finalError) {\n observer.error!(this.finalError);\n } else {\n observer.complete!();\n }\n } catch (err) {\n // nothing\n logger.warn(err);\n }\n }\n\n return unsub;\n }\n\n private unsubscribeOne(id: string): void {\n this.observers = this.observers?.filter((it) => it.subscriptionID !== id);\n }\n\n private forEachObserver(fn: (observer: Observer<T>) => void): void {\n if (this.finalized) {\n return;\n }\n\n for (let i = 0; i < this.observers!.length; i++) {\n this.sendOne(i, fn);\n }\n }\n\n private sendOne(i: number, fn: (observer: Observer<T>) => void): void {\n if (this.observers !== undefined && this.observers[i] !== undefined) {\n try {\n fn(this.observers[i].observer);\n } catch (err) {\n logger.error(err);\n }\n }\n }\n\n private close(err?: Error): void {\n if (this.finalized) {\n return;\n }\n\n this.finalized = true;\n if (err !== undefined) {\n this.finalError = err;\n }\n\n this.observers = undefined;\n }\n}\n\nexport interface Observable<T> {\n subscribe: SubscribeFn<T>;\n getProxy?: () => ObserverProxy<T>;\n}\n\nexport type Executor<T> = (observer: Observer<T>) => void;\n\n/**\n * `createObservable` creates a new instance of ObserverProxy\n * and subscribe the instance.\n */\nexport function createObservable<T>(executor: Executor<T>): Observable<T> {\n const proxy = new ObserverProxy(executor);\n return {\n subscribe: proxy.subscribe.bind(proxy),\n getProxy: (): ObserverProxy<T> => {\n return proxy;\n },\n };\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n TimeTicket,\n InitialDelimiter,\n} from '@yorkie-js-sdk/src/document/time/ticket';\nimport { CRDTRoot } from '@yorkie-js-sdk/src/document/crdt/root';\nimport {\n CRDTContainer,\n CRDTElement,\n} from '@yorkie-js-sdk/src/document/crdt/element';\nimport { Operation } from '@yorkie-js-sdk/src/document/operation/operation';\nimport { ChangeID } from '@yorkie-js-sdk/src/document/change/change_id';\nimport { Change } from '@yorkie-js-sdk/src/document/change/change';\nimport { PresenceChange } from '@yorkie-js-sdk/src/document/presence/presence';\nimport { Indexable } from '@yorkie-js-sdk/src/document/document';\nimport { deepcopy } from '@yorkie-js-sdk/src/util/object';\nimport { GCPair } from '@yorkie-js-sdk/src/document/crdt/gc';\n\n/**\n * `ChangeContext` is used to record the context of modification when editing\n * a document. Each time we add an operation, a new time ticket is issued.\n * Finally returns a Change after the modification has been completed.\n */\nexport class ChangeContext<P extends Indexable = Indexable> {\n private id: ChangeID;\n private delimiter: number;\n private message?: string;\n\n private root: CRDTRoot;\n private operations: Array<Operation>;\n private presenceChange?: PresenceChange<P>;\n\n /**\n * `previousPresence` stores the previous presence to be used for undoing\n * presence changes.\n */\n private previousPresence: P;\n\n /**\n * `reversePresenceKeys` stores the keys of the presence to be used for undoing\n * presence changes.\n */\n private reversePresenceKeys: Set<string>;\n\n constructor(id: ChangeID, root: CRDTRoot, presence: P, message?: string) {\n this.id = id;\n this.delimiter = InitialDelimiter;\n\n this.root = root;\n this.operations = [];\n this.previousPresence = deepcopy(presence);\n this.presenceChange = undefined;\n this.reversePresenceKeys = new Set();\n this.message = message;\n }\n\n /**\n * `create` creates a new instance of ChangeContext.\n */\n public static create<P extends Indexable>(\n id: ChangeID,\n root: CRDTRoot,\n presence: P,\n message?: string,\n ): ChangeContext<P> {\n return new ChangeContext(id, root, presence, message);\n }\n\n /**\n * `push` pushes the given operation to this context.\n */\n public push(operation: Operation): void {\n this.operations.push(operation);\n }\n\n /**\n * `registerElement` registers the given element to the root.\n */\n public registerElement(element: CRDTElement, parent: CRDTContainer): void {\n this.root.registerElement(element, parent);\n }\n\n /**\n * `registerRemovedElement` register removed element for garbage collection.\n */\n public registerRemovedElement(deleted: CRDTElement): void {\n this.root.registerRemovedElement(deleted);\n }\n\n /**\n * `registerGCPair` registers the given pair to hash table.\n */\n public registerGCPair(pair: GCPair): void {\n this.root.registerGCPair(pair);\n }\n\n /**\n * `getChange` creates a new instance of Change in this context.\n */\n public getChange(): Change<P> {\n return Change.create<P>({\n id: this.id,\n operations: this.operations,\n presenceChange: this.presenceChange,\n message: this.message,\n });\n }\n\n /**\n * `hasChange` returns whether this context has change or not.\n */\n public hasChange(): boolean {\n return this.operations.length > 0 || this.presenceChange !== undefined;\n }\n\n /**\n * `setPresenceChange` registers the presence change to this context.\n */\n public setPresenceChange(presenceChange: PresenceChange<P>) {\n this.presenceChange = presenceChange;\n }\n\n /**\n * `setReversePresence` registers the previous presence to undo presence updates.\n */\n public setReversePresence(\n presence: Partial<P>,\n option?: { addToHistory: boolean },\n ) {\n for (const key of Object.keys(presence)) {\n if (option?.addToHistory) {\n this.reversePresenceKeys.add(key);\n } else {\n this.reversePresenceKeys.delete(key);\n }\n }\n }\n\n /**\n * `toReversePresence` returns the reverse presence of this context.\n */\n public getReversePresence() {\n if (this.reversePresenceKeys.size === 0) return undefined;\n\n const reversePresence: Partial<P> = {};\n for (const key of this.reversePresenceKeys) {\n reversePresence[key as keyof P] = this.previousPresence[key as keyof P];\n }\n return reversePresence;\n }\n\n /**\n * `issueTimeTicket` creates a time ticket to be used to create a new operation.\n */\n public issueTimeTicket(): TimeTicket {\n this.delimiter += 1;\n return this.id.createTimeTicket(this.delimiter);\n }\n\n /**\n * `getLastTimeTicket` returns the last time ticket issued in this context.\n */\n public getLastTimeTicket(): TimeTicket {\n return this.id.createTimeTicket(this.delimiter);\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n InitialTimeTicket,\n TimeTicket,\n} from '@yorkie-js-sdk/src/document/time/ticket';\nimport {\n CRDTContainer,\n CRDTElement,\n} from '@yorkie-js-sdk/src/document/crdt/element';\nimport { CRDTObject } from '@yorkie-js-sdk/src/document/crdt/object';\nimport { GCPair } from '@yorkie-js-sdk/src/document/crdt/gc';\nimport { CRDTText } from '@yorkie-js-sdk/src/document/crdt/text';\nimport { CRDTTree } from '@yorkie-js-sdk/src/document/crdt/tree';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\nimport { VersionVector } from '../time/version_vector';\n\n/**\n * `CRDTElementPair` is a structure that represents a pair of element and its\n * parent. It is used to find the parent of a specific element to perform\n * garbage collection and to find the path of a specific element.\n */\ninterface CRDTElementPair {\n element: CRDTElement;\n parent?: CRDTContainer;\n}\n\n/**\n * `RootStats` is a structure that represents the statistics of the root object.\n */\nexport interface RootStats {\n /**\n * `elements` is the number of elements in the root object.\n */\n elements?: number;\n\n /**\n * `gcElements` is the number of elements that can be garbage collected.\n */\n gcElements?: number;\n\n /**\n * `gcPairs` is the number of garbage collection pairs.\n */\n gcPairs?: number;\n}\n\n/**\n * `CRDTRoot` is a structure that represents the root. It has a hash table of\n * all elements to find a specific element when applying remote changes\n * received from server.\n *\n * Every element has a unique `TimeTicket` at creation, which allows us to find\n * a particular element.\n */\nexport class CRDTRoot {\n /**\n * `rootObject` is the root object of the document.\n */\n private rootObject: CRDTObject;\n\n /**\n * `elementPairMapByCreatedAt` is a hash table that maps the creation time of\n * an element to the element itself and its parent.\n */\n private elementPairMapByCreatedAt: Map<string, CRDTElementPair>;\n\n /**\n * `gcElementSetByCreatedAt` is a hash set that contains the creation\n * time of the removed element. It is used to find the removed element when\n * executing garbage collection.\n */\n private gcElementSetByCreatedAt: Set<string>;\n\n /**\n * `gcPairMap` is a hash table that maps the IDString of GCChild to the\n * element itself and its parent.\n */\n private gcPairMap: Map<string, GCPair>;\n\n constructor(rootObject: CRDTObject) {\n this.rootObject = rootObject;\n this.elementPairMapByCreatedAt = new Map();\n this.gcElementSetByCreatedAt = new Set();\n this.gcPairMap = new Map();\n this.registerElement(rootObject, undefined);\n\n rootObject.getDescendants((elem) => {\n if (elem.getRemovedAt()) {\n this.registerRemovedElement(elem);\n }\n if (elem instanceof CRDTText || elem instanceof CRDTTree) {\n for (const pair of elem.getGCPairs()) {\n this.registerGCPair(pair);\n }\n }\n return false;\n });\n }\n\n /**\n * `create` creates a new instance of Root.\n */\n public static create(): CRDTRoot {\n return new CRDTRoot(CRDTObject.create(InitialTimeTicket));\n }\n\n /**\n * `findByCreatedAt` returns the element of given creation time.\n */\n public findByCreatedAt(createdAt: TimeTicket): CRDTElement | undefined {\n const pair = this.elementPairMapByCreatedAt.get(createdAt.toIDString());\n if (!pair) {\n return;\n }\n\n return pair.element;\n }\n\n /**\n * `findElementPairByCreatedAt` returns the element and parent pair\n * of given creation time.\n */\n public findElementPairByCreatedAt(\n createdAt: TimeTicket,\n ): CRDTElementPair | undefined {\n return this.elementPairMapByCreatedAt.get(createdAt.toIDString());\n }\n\n /**\n * `createSubPaths` creates an array of the sub paths for the given element.\n */\n public createSubPaths(createdAt: TimeTicket): Array<string> {\n let pair = this.elementPairMapByCreatedAt.get(createdAt.toIDString());\n if (!pair) {\n return [];\n }\n\n const subPaths: Array<string> = [];\n while (pair.parent) {\n const createdAt = pair.element.getCreatedAt();\n const subPath = pair.parent.subPathOf(createdAt);\n if (subPath === undefined) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `cant find the given element: ${createdAt.toIDString()}`,\n );\n }\n\n subPaths.unshift(subPath!);\n pair = this.elementPairMapByCreatedAt.get(\n pair.parent.getCreatedAt().toIDString(),\n )!;\n }\n\n subPaths.unshift('$');\n return subPaths;\n }\n\n /**\n * `createPath` creates path of the given element.\n */\n public createPath(createdAt: TimeTicket): string {\n return this.createSubPaths(createdAt).join('.');\n }\n\n /**\n * `registerElement` registers the given element and its descendants to hash table.\n */\n public registerElement(element: CRDTElement, parent?: CRDTContainer): void {\n this.elementPairMapByCreatedAt.set(element.getCreatedAt().toIDString(), {\n parent,\n element,\n });\n\n if (element instanceof CRDTContainer) {\n element.getDescendants((elem, parent) => {\n this.registerElement(elem, parent);\n return false;\n });\n }\n }\n\n /**\n * `deregisterElement` deregister the given element and its descendants from hash table.\n */\n public deregisterElement(element: CRDTElement): number {\n let count = 0;\n\n const deregisterElementInternal = (elem: CRDTElement) => {\n const createdAt = elem.getCreatedAt().toIDString();\n this.elementPairMapByCreatedAt.delete(createdAt);\n this.gcElementSetByCreatedAt.delete(createdAt);\n count++;\n };\n\n deregisterElementInternal(element);\n if (element instanceof CRDTContainer) {\n element.getDescendants((e) => {\n deregisterElementInternal(e);\n return false;\n });\n }\n\n return count;\n }\n\n /**\n * `registerRemovedElement` registers the given element to the hash set.\n */\n public registerRemovedElement(element: CRDTElement): void {\n this.gcElementSetByCreatedAt.add(element.getCreatedAt().toIDString());\n }\n\n /**\n * `registerGCPair` registers the given pair to hash table.\n */\n public registerGCPair(pair: GCPair): void {\n const prev = this.gcPairMap.get(pair.child.toIDString());\n if (prev) {\n this.gcPairMap.delete(pair.child.toIDString());\n return;\n }\n\n this.gcPairMap.set(pair.child.toIDString(), pair);\n }\n\n /**\n * `getElementMapSize` returns the size of element map.\n */\n public getElementMapSize(): number {\n return this.elementPairMapByCreatedAt.size;\n }\n\n /**\n * `getGarbageElementSetSize()` returns the size of removed element set.\n */\n public getGarbageElementSetSize(): number {\n const seen = new Set<string>();\n\n for (const createdAt of this.gcElementSetByCreatedAt) {\n seen.add(createdAt);\n const pair = this.elementPairMapByCreatedAt.get(createdAt)!;\n if (pair.element instanceof CRDTContainer) {\n pair.element.getDescendants((el) => {\n seen.add(el.getCreatedAt().toIDString());\n return false;\n });\n }\n }\n return seen.size;\n }\n\n /**\n * `getObject` returns root object.\n */\n public getObject(): CRDTObject {\n return this.rootObject;\n }\n\n /**\n * `getGarbageLen` returns length of nodes which can be garbage collected.\n */\n public getGarbageLen(): number {\n return this.getGarbageElementSetSize() + this.gcPairMap.size;\n }\n\n /**\n * `deepcopy` copies itself deeply.\n */\n public deepcopy(): CRDTRoot {\n return new CRDTRoot(this.rootObject.deepcopy());\n }\n\n /**\n * `garbageCollect` purges elements that were removed before the given time.\n */\n public garbageCollect(minSyncedVersionVector: VersionVector): number {\n let count = 0;\n\n for (const createdAt of this.gcElementSetByCreatedAt) {\n const pair = this.elementPairMapByCreatedAt.get(createdAt)!;\n const removedAt = pair.element.getRemovedAt();\n\n if (removedAt && minSyncedVersionVector?.afterOrEqual(removedAt)) {\n pair.parent!.purge(pair.element);\n count += this.deregisterElement(pair.element);\n }\n }\n\n for (const [, pair] of this.gcPairMap) {\n const removedAt = pair.child.getRemovedAt();\n if (removedAt && minSyncedVersionVector?.afterOrEqual(removedAt)) {\n pair.parent.purge(pair.child);\n\n this.gcPairMap.delete(pair.child.toIDString());\n count += 1;\n }\n }\n\n return count;\n }\n\n /**\n * `toJSON` returns the JSON encoding of this root object.\n */\n public toJSON(): string {\n return this.rootObject.toJSON();\n }\n\n /**\n * `toSortedJSON` returns the sorted JSON encoding of this root object.\n */\n public toSortedJSON(): string {\n return this.rootObject.toSortedJSON();\n }\n\n /**\n * `getStats` returns the current statistics of the root object.\n * This includes counts of various types of elements and structural information.\n */\n public getStats(): RootStats {\n return {\n elements: this.getElementMapSize(),\n gcPairs: this.gcPairMap.size,\n gcElements: this.getGarbageElementSetSize(),\n };\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { logger, LogLevel } from '@yorkie-js-sdk/src/util/logger';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { SetOperation } from '@yorkie-js-sdk/src/document/operation/set_operation';\nimport { RemoveOperation } from '@yorkie-js-sdk/src/document/operation/remove_operation';\nimport { ChangeContext } from '@yorkie-js-sdk/src/document/change/context';\nimport { CRDTElement } from '@yorkie-js-sdk/src/document/crdt/element';\nimport { CRDTObject } from '@yorkie-js-sdk/src/document/crdt/object';\nimport {\n toJSONElement,\n buildCRDTElement,\n} from '@yorkie-js-sdk/src/document/json/element';\nimport * as Devtools from '@yorkie-js-sdk/src/devtools/types';\n\n/**\n * `JSONObject` represents a JSON object, but unlike regular JSON, it has time\n * tickets created by a logical clock to resolve conflicts.\n */\nexport type JSONObject<T> = {\n /**\n * `getID` returns the ID(time ticket) of this Object.\n */\n getID?(): TimeTicket;\n\n /**\n * `toJSON` returns the JSON encoding of this object.\n */\n toJSON?(): string;\n\n /**\n * `toJS` returns the JSON object of this object.\n */\n toJS?(): T;\n\n /**\n * `toJSForTest` returns the JSON object of this object for debugging.\n * @internal\n */\n toJSForTest?(): Devtools.JSONElement;\n} & T;\n\n/**\n * `createJSONObject` creates a new instance of JSONObject.\n */\nexport function createJSONObject<T>(\n context: ChangeContext,\n target: CRDTObject,\n): JSONObject<T> {\n const objectProxy = new ObjectProxy(context);\n return new Proxy(target, objectProxy.getHandlers()) as any;\n}\n\n/**\n * `ObjectProxy` is a proxy representing `Object`.\n */\nexport class ObjectProxy {\n private context: ChangeContext;\n private handlers: any;\n\n constructor(context: ChangeContext) {\n this.context = context;\n this.handlers = {\n set: (target: CRDTObject, key: string, value: any): boolean => {\n if (logger.isEnabled(LogLevel.Trivial)) {\n logger.trivial(`obj[${key}]=${JSON.stringify(value)}`);\n }\n\n ObjectProxy.setInternal(context, target, key, value);\n return true;\n },\n\n get: (\n target: CRDTObject,\n keyOrMethod: Extract<keyof JSONObject<any>, 'string'>,\n ): any => {\n if (logger.isEnabled(LogLevel.Trivial)) {\n logger.trivial(`obj[${keyOrMethod}]`);\n }\n\n if (keyOrMethod === 'getID') {\n return (): TimeTicket => {\n return target.getCreatedAt();\n };\n } else if (keyOrMethod === 'toJSON' || keyOrMethod === 'toString') {\n return (): string => {\n return target.toJSON();\n };\n } else if (keyOrMethod === 'toJS') {\n return (): object => {\n return target.toJS();\n };\n } else if (keyOrMethod === 'toJSForTest') {\n return (): Devtools.JSONElement => {\n return target.toJSForTest();\n };\n }\n\n return toJSONElement(context, target.get(keyOrMethod));\n },\n\n ownKeys: (target: CRDTObject): Array<string> => {\n return target.getKeys();\n },\n\n getOwnPropertyDescriptor: () => {\n return {\n enumerable: true,\n configurable: true,\n };\n },\n\n deleteProperty: (target: CRDTObject, key: string): boolean => {\n if (logger.isEnabled(LogLevel.Trivial)) {\n logger.trivial(`obj[${key}]`);\n }\n\n ObjectProxy.deleteInternal(context, target, key);\n return true;\n },\n };\n }\n\n /**\n * `setInternal` sets a new Object for the given key\n */\n public static setInternal(\n context: ChangeContext,\n target: CRDTObject,\n key: string,\n value: unknown,\n ): void {\n if (key.includes('.')) {\n throw new YorkieError(\n Code.ErrInvalidObjectKey,\n `key must not contain the '.'.`,\n );\n }\n\n const createdAt = context.issueTimeTicket();\n const element = buildCRDTElement(context, value, createdAt);\n const removed = target.set(key, element, createdAt);\n context.registerElement(element, target);\n if (removed) {\n context.registerRemovedElement(removed);\n }\n context.push(\n SetOperation.create(\n key,\n element.deepcopy(),\n target.getCreatedAt(),\n createdAt,\n ),\n );\n }\n\n /**\n * `buildObjectMembers` constructs an object where all values from the\n * user-provided object are transformed into CRDTElements.\n * This function takes an object and iterates through its values,\n * converting each value into a corresponding CRDTElement.\n */\n public static buildObjectMembers(\n context: ChangeContext,\n value: object,\n ): { [key: string]: CRDTElement } {\n const members: { [key: string]: CRDTElement } = {};\n for (const [k, v] of Object.entries(value)) {\n if (k.includes('.')) {\n throw new YorkieError(\n Code.ErrInvalidObjectKey,\n `key must not contain the '.'.`,\n );\n }\n\n const createdAt = context.issueTimeTicket();\n const elem = buildCRDTElement(context, v, createdAt);\n members[k] = elem;\n }\n return members;\n }\n\n /**\n * `deleteInternal` deletes the value of the given key.\n */\n public static deleteInternal(\n context: ChangeContext,\n target: CRDTObject,\n key: string,\n ): void {\n const ticket = context.issueTimeTicket();\n const deleted = target.deleteByKey(key, ticket);\n if (!deleted) {\n return;\n }\n\n context.push(\n RemoveOperation.create(\n target.getCreatedAt(),\n deleted.getCreatedAt(),\n ticket,\n ),\n );\n context.registerRemovedElement(deleted);\n }\n\n /**\n * `getHandlers` gets handlers.\n */\n public getHandlers(): any {\n return this.handlers;\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { logger, LogLevel } from '@yorkie-js-sdk/src/util/logger';\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { AddOperation } from '@yorkie-js-sdk/src/document/operation/add_operation';\nimport { MoveOperation } from '@yorkie-js-sdk/src/document/operation/move_operation';\nimport { RemoveOperation } from '@yorkie-js-sdk/src/document/operation/remove_operation';\nimport { ChangeContext } from '@yorkie-js-sdk/src/document/change/context';\nimport { CRDTElement } from '@yorkie-js-sdk/src/document/crdt/element';\nimport { CRDTArray } from '@yorkie-js-sdk/src/document/crdt/array';\nimport { Primitive } from '@yorkie-js-sdk/src/document/crdt/primitive';\nimport {\n JSONElement,\n WrappedElement,\n toWrappedElement,\n toJSONElement,\n buildCRDTElement,\n} from '@yorkie-js-sdk/src/document/json/element';\nimport * as Devtools from '@yorkie-js-sdk/src/devtools/types';\n\n/**\n * `JSONArray` represents JSON array, but unlike regular JSON, it has time\n * tickets created by a logical clock to resolve conflicts.\n */\nexport type JSONArray<T> = {\n /**\n * `getID` returns the ID, `TimeTicket` of this Object.\n */\n getID?(): TimeTicket;\n\n /**\n * `getElementByID` returns the element for the given ID.\n */\n getElementByID?(createdAt: TimeTicket): WrappedElement<T>;\n\n /**\n * `getElementByIndex` returns the element for the given index.\n */\n getElementByIndex?(index: number): WrappedElement<T>;\n\n /**\n * `getLast` returns the last element of this array.\n */\n getLast?(): WrappedElement<T>;\n\n /**\n * `deleteByID` deletes the element of the given ID.\n */\n deleteByID?(createdAt: TimeTicket): WrappedElement<T>;\n\n /**\n * `insertBefore` inserts a value before the given next element.\n */\n insertBefore?(nextID: TimeTicket, value: any): WrappedElement<T>;\n\n /**\n * `insertAfter` inserts a value after the given previous element.\n */\n insertAfter?(prevID: TimeTicket, value: any): WrappedElement<T>;\n\n /**\n * `moveBefore` moves the element before the given next element.\n */\n moveBefore?(nextID: TimeTicket, id: TimeTicket): void;\n\n /**\n * `moveAfter` moves the element after the given previous element.\n */\n moveAfter?(prevID: TimeTicket, id: TimeTicket): void;\n\n /**\n * `moveFront` moves the element before the first element.\n */\n moveFront?(id: TimeTicket): void;\n\n /**\n * `moveLast` moves the element after the last element.\n */\n moveLast?(id: TimeTicket): void;\n\n /**\n * `toTestString` returns a String containing the meta data of the node\n * for debugging purpose.\n */\n toTestString?(): string;\n\n /**\n * `toJSForTest` returns the JSON object of this array for debugging.\n * @internal\n */\n toJSForTest?(): Devtools.JSONElement;\n} & Array<T>;\n\n/**\n * `createJSONArray` creates a new instance of JSONArray.\n */\nexport function createJSONArray(\n context: ChangeContext,\n target: CRDTArray,\n): JSONArray<WrappedElement> {\n const arrayProxy = new ArrayProxy(context, target);\n return new Proxy(target, arrayProxy.getHandlers()) as any;\n}\n\n/**\n * `isNumericString` checks if value is numeric string.\n */\nfunction isNumericString(val: any): boolean {\n if (typeof val === 'string' || val instanceof String) {\n return !isNaN(val as any);\n }\n return false;\n}\n\n/**\n * `isReadOnlyArrayMethod` checks if the method is a standard array read-only operation.\n */\nfunction isReadOnlyArrayMethod(method: string): boolean {\n return [\n 'concat',\n 'entries',\n 'every',\n 'filter',\n 'find',\n 'findIndex',\n 'forEach',\n 'join',\n 'keys',\n 'map',\n 'reduce',\n 'reduceRight',\n 'slice',\n 'some',\n 'toLocaleString',\n 'toString',\n 'values',\n ].includes(method);\n}\n\n/**\n * `ArrayProxy` is a proxy for Array.\n */\nexport class ArrayProxy {\n private context: ChangeContext;\n private handlers: any;\n private array: CRDTArray;\n\n constructor(context: ChangeContext, array: CRDTArray) {\n this.context = context;\n this.array = array;\n this.handlers = {\n get: (\n target: CRDTArray,\n method: keyof JSONArray<unknown>,\n receiver: any,\n ): any => {\n if (method === 'getID') {\n return (): TimeTicket => {\n return target.getCreatedAt();\n };\n } else if (method === 'getElementByID') {\n return (createdAt: TimeTicket): WrappedElement | undefined => {\n const elem = target.getByID(createdAt);\n if (!elem || elem.isRemoved()) {\n return;\n }\n return toWrappedElement(context, elem);\n };\n } else if (method === 'getElementByIndex') {\n return (index: number): WrappedElement | undefined => {\n const elem = target.get(index);\n return toWrappedElement(context, elem);\n };\n } else if (method === 'getLast') {\n return (): WrappedElement | undefined => {\n return toWrappedElement(context, target.getLast());\n };\n } else if (method === 'deleteByID') {\n return (createdAt: TimeTicket): WrappedElement | undefined => {\n const deleted = ArrayProxy.deleteInternalByID(\n context,\n target,\n createdAt,\n );\n return toWrappedElement(context, deleted);\n };\n } else if (method === 'insertAfter') {\n return (\n prevID: TimeTicket,\n value: any,\n ): WrappedElement | undefined => {\n const inserted = ArrayProxy.insertAfterInternal(\n context,\n target,\n prevID,\n value,\n );\n return toWrappedElement(context, inserted);\n };\n } else if (method === 'insertBefore') {\n return (\n nextID: TimeTicket,\n value: any,\n ): WrappedElement | undefined => {\n const inserted = ArrayProxy.insertBeforeInternal(\n context,\n target,\n nextID,\n value,\n );\n return toWrappedElement(context, inserted);\n };\n } else if (method === 'moveBefore') {\n return (nextID: TimeTicket, id: TimeTicket): void => {\n ArrayProxy.moveBeforeInternal(context, target, nextID, id);\n };\n // JavaScript Native API\n } else if (method === 'moveAfter') {\n return (prevID: TimeTicket, id: TimeTicket): void => {\n ArrayProxy.moveAfterInternal(context, target, prevID, id);\n };\n } else if (method === 'moveFront') {\n return (id: TimeTicket): void => {\n ArrayProxy.moveFrontInternal(context, target, id);\n };\n } else if (method === 'moveLast') {\n return (id: TimeTicket): void => {\n ArrayProxy.moveLastInternal(context, target, id);\n };\n } else if (isNumericString(method)) {\n return toJSONElement(context, target.get(Number(method as string)));\n } else if (method === 'push') {\n return (value: any): number => {\n return ArrayProxy.pushInternal(context, target, value);\n };\n } else if (method === 'splice') {\n return (\n start: number,\n deleteCount?: number,\n ...items: Array<any>\n ): JSONArray<JSONElement> => {\n return ArrayProxy.splice(\n context,\n target,\n start,\n deleteCount,\n ...items,\n );\n };\n } else if (method === 'length') {\n return target.length;\n } else if (typeof method === 'symbol' && method === Symbol.iterator) {\n return ArrayProxy.iteratorInternal.bind(this, context, target);\n } else if (method === 'includes') {\n return (searchElement: JSONElement, fromIndex?: number): boolean => {\n return ArrayProxy.includes(\n context,\n target,\n searchElement,\n fromIndex,\n );\n };\n } else if (method === 'indexOf') {\n return (searchElement: JSONElement, fromIndex?: number): number => {\n return ArrayProxy.indexOf(\n context,\n target,\n searchElement,\n fromIndex,\n );\n };\n } else if (method === 'lastIndexOf') {\n return (searchElement: JSONElement, fromIndex?: number): number => {\n return ArrayProxy.lastIndexOf(\n context,\n target,\n searchElement,\n fromIndex,\n );\n };\n } else if (method === 'toJSForTest') {\n return (): Devtools.JSONElement => {\n return target.toJSForTest();\n };\n } else if (method === 'toTestString') {\n return (): string => ArrayProxy.toTestString(target);\n } else if (\n typeof method === 'string' &&\n isReadOnlyArrayMethod(method)\n ) {\n return (...args: any) => {\n const arr = Array.from(target).map((elem) =>\n toJSONElement(context, elem),\n );\n return Array.prototype[method as any].apply(arr, args);\n };\n }\n\n // TODO we need to distinguish between the case we need to call default\n // behavior and the case where we need to call an internal method\n // throw new TypeError(`Unsupported method: ${String(method)}`);\n return Reflect.get(target, method, receiver);\n },\n\n deleteProperty: (target: CRDTArray, key: string): boolean => {\n if (logger.isEnabled(LogLevel.Trivial)) {\n logger.trivial(`array[${key}]`);\n }\n ArrayProxy.deleteInternalByIndex(context, target, Number.parseInt(key));\n return true;\n },\n };\n }\n\n // eslint-disable-next-line jsdoc/require-jsdoc\n public static *iteratorInternal(\n change: ChangeContext,\n target: CRDTArray,\n ): IterableIterator<WrappedElement> {\n for (const elem of target) {\n yield toWrappedElement(change, elem)!;\n }\n }\n\n /**\n * `buildArrayElements` constructs array elements based on the user-provided array.\n */\n public static buildArrayElements(\n context: ChangeContext,\n value: Array<unknown>,\n ): Array<CRDTElement> {\n const elements: Array<CRDTElement> = [];\n for (const v of value) {\n const createdAt = context.issueTimeTicket();\n const elem = buildCRDTElement(context, v, createdAt);\n elements.push(elem);\n }\n return elements;\n }\n\n /**\n * `pushInternal` pushes the value to the target array.\n */\n public static pushInternal(\n context: ChangeContext,\n target: CRDTArray,\n value: unknown,\n ): number {\n ArrayProxy.insertAfterInternal(\n context,\n target,\n target.getLastCreatedAt(),\n value,\n );\n return target.length;\n }\n\n /**\n * `moveBeforeInternal` moves the given `createdAt` element\n * after the previously created element.\n */\n public static moveBeforeInternal(\n context: ChangeContext,\n target: CRDTArray,\n nextCreatedAt: TimeTicket,\n createdAt: TimeTicket,\n ): void {\n const ticket = context.issueTimeTicket();\n const prevCreatedAt = target.getPrevCreatedAt(nextCreatedAt);\n target.moveAfter(prevCreatedAt, createdAt, ticket);\n context.push(\n MoveOperation.create(\n target.getCreatedAt(),\n prevCreatedAt,\n createdAt,\n ticket,\n ),\n );\n }\n\n /**\n * `moveAfterInternal` moves the given `createdAt` element\n * after the specific element.\n */\n public static moveAfterInternal(\n context: ChangeContext,\n target: CRDTArray,\n prevCreatedAt: TimeTicket,\n createdAt: TimeTicket,\n ): void {\n const ticket = context.issueTimeTicket();\n target.moveAfter(prevCreatedAt, createdAt, ticket);\n context.push(\n MoveOperation.create(\n target.getCreatedAt(),\n prevCreatedAt,\n createdAt,\n ticket,\n ),\n );\n }\n\n /**\n * `moveFrontInternal` moves the given `createdAt` element\n * at the first of array.\n */\n public static moveFrontInternal(\n context: ChangeContext,\n target: CRDTArray,\n createdAt: TimeTicket,\n ): void {\n const ticket = context.issueTimeTicket();\n const head = target.getHead();\n target.moveAfter(head.getCreatedAt(), createdAt, ticket);\n context.push(\n MoveOperation.create(\n target.getCreatedAt(),\n head.getCreatedAt(),\n createdAt,\n ticket,\n ),\n );\n }\n\n /**\n * `moveLastInternal` moves the given `createdAt` element\n * at the last of array.\n */\n public static moveLastInternal(\n context: ChangeContext,\n target: CRDTArray,\n createdAt: TimeTicket,\n ): void {\n const ticket = context.issueTimeTicket();\n const last = target.getLastCreatedAt();\n target.moveAfter(last, createdAt, ticket);\n context.push(\n MoveOperation.create(target.getCreatedAt(), last, createdAt, ticket),\n );\n }\n\n /**\n * `insertAfterInternal` inserts the value after the previously created element.\n */\n public static insertAfterInternal(\n context: ChangeContext,\n target: CRDTArray,\n prevCreatedAt: TimeTicket,\n value: unknown,\n ): CRDTElement {\n const createdAt = context.issueTimeTicket();\n const element = buildCRDTElement(context, value, createdAt);\n target.insertAfter(prevCreatedAt, element);\n context.registerElement(element, target);\n context.push(\n AddOperation.create(\n target.getCreatedAt(),\n prevCreatedAt,\n element.deepcopy(),\n createdAt,\n ),\n );\n return element;\n }\n\n /**\n * `insertBeforeInternal` inserts the value before the previously created element.\n */\n public static insertBeforeInternal(\n context: ChangeContext,\n target: CRDTArray,\n nextCreatedAt: TimeTicket,\n value: unknown,\n ): CRDTElement {\n return ArrayProxy.insertAfterInternal(\n context,\n target,\n target.getPrevCreatedAt(nextCreatedAt),\n value,\n );\n }\n\n /**\n * `deleteInternalByIndex` deletes target element of given index.\n */\n public static deleteInternalByIndex(\n context: ChangeContext,\n target: CRDTArray,\n index: number,\n ): CRDTElement | undefined {\n const ticket = context.issueTimeTicket();\n const deleted = target.deleteByIndex(index, ticket);\n if (!deleted) {\n return;\n }\n\n context.push(\n RemoveOperation.create(\n target.getCreatedAt(),\n deleted.getCreatedAt(),\n ticket,\n ),\n );\n context.registerRemovedElement(deleted);\n return deleted;\n }\n\n /**\n * `deleteInternalByID` deletes the element of the given ID.\n */\n public static deleteInternalByID(\n context: ChangeContext,\n target: CRDTArray,\n createdAt: TimeTicket,\n ): CRDTElement {\n const ticket = context.issueTimeTicket();\n const deleted = target.delete(createdAt, ticket);\n context.push(\n RemoveOperation.create(\n target.getCreatedAt(),\n deleted.getCreatedAt(),\n ticket,\n ),\n );\n context.registerRemovedElement(deleted);\n return deleted;\n }\n\n /**\n * `splice` is a method to remove elements from the array.\n */\n public static splice(\n context: ChangeContext,\n target: CRDTArray,\n start: number,\n deleteCount?: number,\n ...items: Array<any>\n ): JSONArray<JSONElement> {\n const length = target.length;\n const from =\n start >= 0 ? Math.min(start, length) : Math.max(length + start, 0);\n const to =\n deleteCount === undefined\n ? length\n : deleteCount < 0\n ? from\n : Math.min(from + deleteCount, length);\n const removeds: JSONArray<JSONElement> = [];\n for (let i = from; i < to; i++) {\n const removed = ArrayProxy.deleteInternalByIndex(context, target, from);\n if (removed) {\n const removedElem = removed.deepcopy();\n removedElem.setRemovedAt();\n removeds.push(toJSONElement(context, removedElem)!);\n }\n }\n if (items) {\n let previousID =\n from === 0 ? target.getHead().getID() : target.get(from - 1)!.getID();\n for (const item of items) {\n const newElem = ArrayProxy.insertAfterInternal(\n context,\n target,\n previousID,\n item,\n );\n previousID = newElem.getID();\n }\n }\n return removeds;\n }\n\n /**\n * `includes` returns true if the given element is in the array.\n */\n public static includes(\n context: ChangeContext,\n target: CRDTArray,\n searchElement: JSONElement,\n fromIndex?: number,\n ): boolean {\n const length = target.length;\n const from =\n fromIndex === undefined\n ? 0\n : fromIndex < 0\n ? Math.max(fromIndex + length, 0)\n : fromIndex;\n\n if (from >= length) return false;\n\n if (Primitive.isSupport(searchElement)) {\n const arr = Array.from(target).map((elem) =>\n toJSONElement(context, elem),\n );\n return arr.includes(searchElement, from);\n }\n\n for (let i = from; i < length; i++) {\n if (\n target.get(i)?.getID() === (searchElement as WrappedElement).getID!()\n ) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * `indexOf` returns the index of the given element.\n */\n public static indexOf(\n context: ChangeContext,\n target: CRDTArray,\n searchElement: JSONElement,\n fromIndex?: number,\n ): number {\n const length = target.length;\n const from =\n fromIndex === undefined\n ? 0\n : fromIndex < 0\n ? Math.max(fromIndex + length, 0)\n : fromIndex;\n\n if (from >= length) return -1;\n\n if (Primitive.isSupport(searchElement)) {\n const arr = Array.from(target).map((elem) =>\n toJSONElement(context, elem),\n );\n return arr.indexOf(searchElement, from);\n }\n\n for (let i = from; i < length; i++) {\n if (\n target.get(i)?.getID() === (searchElement as WrappedElement).getID!()\n ) {\n return i;\n }\n }\n return -1;\n }\n\n /**\n * `lastIndexOf` returns the last index of the given element.\n */\n public static lastIndexOf(\n context: ChangeContext,\n target: CRDTArray,\n searchElement: JSONElement,\n fromIndex?: number,\n ): number {\n const length = target.length;\n const from =\n fromIndex === undefined || fromIndex >= length\n ? length - 1\n : fromIndex < 0\n ? fromIndex + length\n : fromIndex;\n\n if (from < 0) return -1;\n\n if (Primitive.isSupport(searchElement)) {\n const arr = Array.from(target).map((elem) =>\n toJSONElement(context, elem),\n );\n return arr.lastIndexOf(searchElement, from);\n }\n\n for (let i = from; i > 0; i--) {\n if (\n target.get(i)?.getID() === (searchElement as WrappedElement).getID!()\n ) {\n return i;\n }\n }\n return -1;\n }\n /**\n * `toTestString` returns a String containing the meta data of the node\n * for debugging purpose.\n */\n public static toTestString(target: CRDTArray): string {\n return target.toTestString();\n }\n\n /**\n * `getHandlers` gets handlers.\n */\n public getHandlers(): any {\n return this.handlers;\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { logger, LogLevel } from '@yorkie-js-sdk/src/util/logger';\nimport { Indexable } from '@yorkie-js-sdk/src/document/document';\nimport {\n TimeTicket,\n TimeTicketStruct,\n} from '@yorkie-js-sdk/src/document/time/ticket';\nimport { ChangeContext } from '@yorkie-js-sdk/src/document/change/context';\nimport {\n RGATreeSplitNode,\n RGATreeSplitNodeID,\n RGATreeSplitPos,\n RGATreeSplitPosRange,\n} from '@yorkie-js-sdk/src/document/crdt/rga_tree_split';\nimport {\n CRDTText,\n CRDTTextValue,\n TextValueType,\n} from '@yorkie-js-sdk/src/document/crdt/text';\nimport { EditOperation } from '@yorkie-js-sdk/src/document/operation/edit_operation';\nimport { StyleOperation } from '@yorkie-js-sdk/src/document/operation/style_operation';\nimport { stringifyObjectValues } from '@yorkie-js-sdk/src/util/object';\nimport type * as Devtools from '@yorkie-js-sdk/src/devtools/types';\nimport { SplayTree } from '@yorkie-js-sdk/src/util/splay_tree';\nimport { LLRBTree } from '@yorkie-js-sdk/src/util/llrb_tree';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\n\n/**\n * `TextPosStruct` represents the structure of RGATreeSplitPos.\n * It is used to serialize and deserialize the RGATreeSplitPos.\n */\nexport type TextPosStruct = {\n id: { createdAt: TimeTicketStruct; offset: number };\n relativeOffset: number;\n};\n\n/**\n * `TextPosStructRange` represents the structure of RGATreeSplitPosRange.\n * It is used to serialize and deserialize the RGATreeSplitPosRange.\n */\nexport type TextPosStructRange = [TextPosStruct, TextPosStruct];\n\n/**\n * `Text` is an extended data type for the contents of a text editor.\n */\nexport class Text<A extends Indexable = Indexable> {\n private context?: ChangeContext;\n private text?: CRDTText<A>;\n\n constructor(context?: ChangeContext, text?: CRDTText<A>) {\n this.context = context;\n this.text = text;\n }\n\n /**\n * `initialize` initialize this text with context and internal text.\n * @internal\n */\n public initialize(context: ChangeContext, text: CRDTText<A>): void {\n this.context = context;\n this.text = text;\n }\n\n /**\n * `getID` returns the ID of this text.\n */\n public getID(): TimeTicket {\n return this.text!.getID();\n }\n\n /**\n * `edit` edits this text with the given content.\n */\n edit(\n fromIdx: number,\n toIdx: number,\n content: string,\n attributes?: A,\n ): [number, number] | undefined {\n if (!this.context || !this.text) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Text is not initialized yet',\n );\n }\n\n if (fromIdx > toIdx) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n 'from should be less than or equal to to',\n );\n }\n\n const range = this.text.indexRangeToPosRange(fromIdx, toIdx);\n if (logger.isEnabled(LogLevel.Debug)) {\n logger.debug(\n `EDIT: f:${fromIdx}->${range[0].toTestString()}, t:${toIdx}->${range[1].toTestString()} c:${content}`,\n );\n }\n const attrs = attributes ? stringifyObjectValues(attributes) : undefined;\n const ticket = this.context.issueTimeTicket();\n const [maxCreatedAtMapByActor, , pairs, rangeAfterEdit] = this.text.edit(\n range,\n content,\n ticket,\n attrs,\n );\n\n for (const pair of pairs) {\n this.context!.registerGCPair(pair);\n }\n\n this.context.push(\n new EditOperation(\n this.text.getCreatedAt(),\n range[0],\n range[1],\n maxCreatedAtMapByActor,\n content,\n attrs ? new Map(Object.entries(attrs)) : new Map(),\n ticket,\n ),\n );\n\n return this.text.findIndexesFromRange(rangeAfterEdit);\n }\n\n /**\n * `delete` deletes the text in the given range.\n */\n delete(fromIdx: number, toIdx: number): [number, number] | undefined {\n return this.edit(fromIdx, toIdx, '');\n }\n\n /**\n * `empty` makes the text empty.\n */\n empty(): [number, number] | undefined {\n return this.edit(0, this.length, '');\n }\n\n /**\n * `setStyle` styles this text with the given attributes.\n */\n setStyle(fromIdx: number, toIdx: number, attributes: A): boolean {\n if (!this.context || !this.text) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Text is not initialized yet',\n );\n }\n\n if (fromIdx > toIdx) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n 'from should be less than or equal to to',\n );\n }\n\n const range = this.text.indexRangeToPosRange(fromIdx, toIdx);\n if (logger.isEnabled(LogLevel.Debug)) {\n logger.debug(\n `STYL: f:${fromIdx}->${range[0].toTestString()}, t:${toIdx}->${range[1].toTestString()} a:${JSON.stringify(\n attributes,\n )}`,\n );\n }\n\n const attrs = stringifyObjectValues(attributes);\n const ticket = this.context.issueTimeTicket();\n const [maxCreatedAtMapByActor, pairs] = this.text.setStyle(\n range,\n attrs,\n ticket,\n );\n\n for (const pair of pairs) {\n this.context!.registerGCPair(pair);\n }\n\n this.context.push(\n new StyleOperation(\n this.text.getCreatedAt(),\n range[0],\n range[1],\n maxCreatedAtMapByActor,\n new Map(Object.entries(attrs)),\n ticket,\n ),\n );\n\n return true;\n }\n\n /**\n * `indexRangeToPosRange` returns TextRangeStruct of the given index range.\n */\n indexRangeToPosRange(range: [number, number]): TextPosStructRange {\n if (!this.context || !this.text) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Text is not initialized yet',\n );\n }\n\n const textRange = this.text.indexRangeToPosRange(range[0], range[1]);\n return [textRange[0].toStruct(), textRange[1].toStruct()];\n }\n\n /**\n * `posRangeToIndexRange` returns indexes of the given TextRangeStruct.\n */\n posRangeToIndexRange(range: TextPosStructRange): [number, number] {\n if (!this.context || !this.text) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Text is not initialized yet',\n );\n }\n\n const textRange = this.text.findIndexesFromRange([\n RGATreeSplitPos.fromStruct(range[0]),\n RGATreeSplitPos.fromStruct(range[1]),\n ]);\n return [textRange[0], textRange[1]];\n }\n\n /**\n * `toTestString` returns a String containing the meta data of the node\n * for debugging purpose.\n */\n toTestString(): string {\n if (!this.context || !this.text) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Text is not initialized yet',\n );\n }\n\n return this.text.toTestString();\n }\n\n /**\n * `values` returns values of this text.\n */\n values(): Array<TextValueType<A>> {\n if (!this.context || !this.text) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Text is not initialized yet',\n );\n }\n\n return this.text.values();\n }\n\n /**\n * `length` returns size of RGATreeList.\n */\n public get length(): number {\n return this.text!.length;\n }\n\n /**\n * `getTreeByIndex` returns IndexTree of the text for testing purpose.\n */\n public getTreeByIndex(): SplayTree<CRDTTextValue> {\n return this.text!.getTreeByIndex();\n }\n\n /**\n * `getTreeByID` returns IDTree of the text for testing purpose.\n */\n public getTreeByID(): LLRBTree<\n RGATreeSplitNodeID,\n RGATreeSplitNode<CRDTTextValue>\n > {\n return this.text!.getTreeByID();\n }\n\n /**\n * `toString` returns the string representation of this text.\n */\n toString(): string {\n if (!this.context || !this.text) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Text is not initialized yet',\n );\n }\n\n return this.text.toString();\n }\n\n /**\n * `toJSON` returns the JSON string of this tree.\n */\n public toJSON(): string {\n if (!this.context || !this.text) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Text is not initialized yet',\n );\n }\n\n return this.text.toJSON();\n }\n\n /**\n * `toJSForTest` returns value with meta data for testing.\n * @internal\n */\n public toJSForTest(): Devtools.JSONElement {\n if (!this.context || !this.text) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Text is not initialized yet',\n );\n }\n\n return this.text.toJSForTest();\n }\n\n /**\n * `createRangeForTest` returns pair of RGATreeSplitNodePos of the given indexes\n * for testing purpose.\n */\n createRangeForTest(fromIdx: number, toIdx: number): RGATreeSplitPosRange {\n if (!this.context || !this.text) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Text is not initialized yet',\n );\n }\n\n return this.text.indexRangeToPosRange(fromIdx, toIdx);\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { ChangeContext } from '@yorkie-js-sdk/src/document/change/context';\nimport { Primitive } from '@yorkie-js-sdk/src/document/crdt/primitive';\nimport { IncreaseOperation } from '@yorkie-js-sdk/src/document/operation/increase_operation';\nimport Long from 'long';\nimport {\n CounterType,\n CRDTCounter,\n} from '@yorkie-js-sdk/src/document/crdt/counter';\nimport type * as Devtools from '@yorkie-js-sdk/src/devtools/types';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\n\n/**\n * `Counter` is a custom data type that is used to counter.\n */\nexport class Counter {\n private valueType: CounterType;\n private value: number | Long;\n private context?: ChangeContext;\n private counter?: CRDTCounter;\n\n constructor(valueType: CounterType, value: number | Long) {\n this.valueType = valueType;\n this.value = value;\n }\n\n /**\n * `initialize` initialize this text with context and internal text.\n * @internal\n */\n public initialize(context: ChangeContext, counter: CRDTCounter): void {\n this.valueType = counter.getValueType();\n this.context = context;\n this.counter = counter;\n this.value = counter.getValue();\n }\n\n /**\n * `getID` returns the ID of this text.\n */\n public getID(): TimeTicket {\n return this.counter!.getID();\n }\n\n /**\n * `getValue` returns the value of this counter;\n * @internal\n */\n public getValue(): number | Long {\n return this.value;\n }\n\n /**\n * `getValueType` returns the value type of this counter.\n */\n public getValueType(): CounterType {\n return this.valueType;\n }\n\n /**\n * `increase` increases numeric data.\n */\n public increase(v: number | Long): Counter {\n if (!this.context || !this.counter) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Counter is not initialized yet',\n );\n }\n\n const ticket = this.context.issueTimeTicket();\n const value = Primitive.of(v, ticket);\n if (!value.isNumericType()) {\n throw new TypeError(\n `Unsupported type of value: ${typeof value.getValue()}`,\n );\n }\n\n this.counter.increase(value);\n this.context.push(\n IncreaseOperation.create(this.counter.getCreatedAt(), value, ticket),\n );\n\n return this;\n }\n\n /**\n * `toJSForTest` returns value with meta data for testing.\n * @internal\n */\n public toJSForTest(): Devtools.JSONElement {\n if (!this.context || !this.counter) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Counter is not initialized yet',\n );\n }\n\n return this.counter.toJSForTest();\n }\n}\n","/*\n * Copyright 2023 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\nimport { ChangeContext } from '@yorkie-js-sdk/src/document/change/context';\nimport {\n CRDTTree,\n CRDTTreeNodeID,\n CRDTTreeNode,\n CRDTTreePos,\n} from '@yorkie-js-sdk/src/document/crdt/tree';\n\nimport {\n IndexTree,\n DefaultRootType,\n DefaultTextType,\n} from '@yorkie-js-sdk/src/util/index_tree';\nimport { TreeEditOperation } from '@yorkie-js-sdk/src/document/operation/tree_edit_operation';\nimport { isEmpty, stringifyObjectValues } from '@yorkie-js-sdk/src/util/object';\nimport { RHT } from '../crdt/rht';\nimport { TreeStyleOperation } from '../operation/tree_style_operation';\nimport type {\n ElementNode,\n TextNode,\n TreeNode,\n TreeChange,\n TreeChangeType,\n TreePosStructRange,\n CRDTTreeNodeIDStruct,\n} from '@yorkie-js-sdk/src/document/crdt/tree';\nimport type * as Devtools from '@yorkie-js-sdk/src/devtools/types';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\n\n/**\n * NOTE(hackerwins): In normal case, we should define the following types in\n * json package, because they are directly used by the user. However, we define\n * them in crdt package to avoid circular dependency between json and crdt.\n */\nexport {\n TreeNode,\n ElementNode,\n TextNode,\n TreeChange,\n TreeChangeType,\n TreePosStructRange,\n CRDTTreeNodeIDStruct,\n};\n\n/**\n * `buildDescendants` builds descendants of the given tree node.\n */\nfunction buildDescendants(\n treeNode: TreeNode,\n parent: CRDTTreeNode,\n context: ChangeContext,\n) {\n const { type } = treeNode;\n const ticket = context.issueTimeTicket();\n\n if (type === DefaultTextType) {\n validateTextNode(treeNode as TextNode);\n const { value } = treeNode as TextNode;\n const textNode = CRDTTreeNode.create(\n CRDTTreeNodeID.of(ticket, 0),\n type,\n value,\n );\n\n parent.append(textNode);\n } else {\n const { children = [] } = treeNode as ElementNode;\n const { attributes } = treeNode as ElementNode;\n let attrs;\n\n if (typeof attributes === 'object' && !isEmpty(attributes)) {\n const stringifiedAttributes = stringifyObjectValues(attributes);\n attrs = new RHT();\n\n for (const [key, value] of Object.entries(stringifiedAttributes)) {\n attrs.set(key, value, ticket);\n }\n }\n const elementNode = CRDTTreeNode.create(\n CRDTTreeNodeID.of(ticket, 0),\n type,\n undefined,\n attrs,\n );\n\n parent.append(elementNode);\n\n for (const child of children) {\n buildDescendants(child, elementNode, context);\n }\n }\n}\n\n/**\n * createCRDTTreeNode returns CRDTTreeNode by given TreeNode.\n */\nfunction createCRDTTreeNode(context: ChangeContext, content: TreeNode) {\n const { type } = content;\n const ticket = context.issueTimeTicket();\n\n let root;\n if (content.type === DefaultTextType) {\n const { value } = content as TextNode;\n root = CRDTTreeNode.create(CRDTTreeNodeID.of(ticket, 0), type, value);\n } else if (content) {\n const { children = [] } = content as ElementNode;\n const { attributes } = content as ElementNode;\n let attrs;\n\n if (typeof attributes === 'object' && !isEmpty(attributes)) {\n const stringifiedAttributes = stringifyObjectValues(attributes);\n attrs = new RHT();\n\n for (const [key, value] of Object.entries(stringifiedAttributes)) {\n attrs.set(key, value, ticket);\n }\n }\n\n root = CRDTTreeNode.create(\n CRDTTreeNodeID.of(context.issueTimeTicket(), 0),\n type,\n undefined,\n attrs,\n );\n\n for (const child of children) {\n buildDescendants(child, root, context);\n }\n }\n\n return root;\n}\n\n/**\n * `validateTextNode` ensures that a text node has a non-empty string value.\n */\nfunction validateTextNode(textNode: TextNode): boolean {\n if (!textNode.value.length) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n 'text node cannot have empty value',\n );\n }\n\n return true;\n}\n\n/**\n * `validateTreeNodes` ensures that treeNodes consists of only one type.\n */\nfunction validateTreeNodes(treeNodes: Array<TreeNode>): boolean {\n if (!treeNodes.length) {\n return true;\n }\n\n const firstTreeNodeType = treeNodes[0].type;\n if (firstTreeNodeType === DefaultTextType) {\n for (const treeNode of treeNodes) {\n const { type } = treeNode;\n if (type !== DefaultTextType) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n 'element node and text node cannot be passed together',\n );\n }\n validateTextNode(treeNode as TextNode);\n }\n } else {\n for (const treeNode of treeNodes) {\n const { type } = treeNode;\n if (type === DefaultTextType) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n 'element node and text node cannot be passed together',\n );\n }\n }\n }\n\n return true;\n}\n\n/**\n * `Tree` is a CRDT-based tree structure that is used to represent the document\n * tree of text-based editor such as ProseMirror.\n */\nexport class Tree {\n private initialRoot?: ElementNode;\n private context?: ChangeContext;\n private tree?: CRDTTree;\n\n constructor(initialRoot?: ElementNode) {\n this.initialRoot = initialRoot;\n }\n\n /**\n * `initialize` initialize this tree with context and internal tree.\n * @internal\n */\n public initialize(context: ChangeContext, tree: CRDTTree): void {\n this.context = context;\n this.tree = tree;\n }\n\n /**\n * `getID` returns the ID of this tree.\n */\n public getID(): TimeTicket {\n return this.tree!.getID();\n }\n\n /**\n * `buildRoot` builds the root of this tree with the given initial root\n * which set by the user.\n */\n public buildRoot(context: ChangeContext): CRDTTreeNode {\n if (!this.initialRoot) {\n return CRDTTreeNode.create(\n CRDTTreeNodeID.of(context.issueTimeTicket(), 0),\n DefaultRootType,\n );\n }\n\n // TODO(hackerwins): Need to use the ticket of operation of creating tree.\n const root = CRDTTreeNode.create(\n CRDTTreeNodeID.of(context.issueTimeTicket(), 0),\n this.initialRoot.type,\n );\n\n for (const child of this.initialRoot.children) {\n buildDescendants(child, root, context);\n }\n\n return root;\n }\n\n /**\n * `getSize` returns the size of this tree.\n */\n public getSize(): number {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n\n return this.tree.getSize();\n }\n\n /**\n * `getNodeSize` returns the node size of this tree.\n */\n public getNodeSize(): number {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n\n return this.tree.getNodeSize();\n }\n\n /**\n * `getIndexTree` returns the index tree of this tree.\n */\n public getIndexTree(): IndexTree<CRDTTreeNode> {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n\n return this.tree.getIndexTree();\n }\n\n /**\n * `styleByPath` sets the attributes to the elements of the given path.\n */\n public styleByPath(path: Array<number>, attributes: { [key: string]: any }) {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n\n if (!path.length) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n 'path should not be empty',\n );\n }\n const [fromPos, toPos] = this.tree.pathToPosRange(path);\n const ticket = this.context.issueTimeTicket();\n const attrs = attributes ? stringifyObjectValues(attributes) : undefined;\n\n const [maxCreationMapByActor] = this.tree!.style(\n [fromPos, toPos],\n attrs,\n ticket,\n );\n\n this.context.push(\n TreeStyleOperation.create(\n this.tree.getCreatedAt(),\n fromPos,\n toPos,\n maxCreationMapByActor,\n attrs ? new Map(Object.entries(attrs)) : new Map(),\n ticket,\n ),\n );\n }\n\n /**\n * `style` sets the attributes to the elements of the given range.\n */\n public style(\n fromIdx: number,\n toIdx: number,\n attributes: { [key: string]: any },\n ) {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n\n if (fromIdx > toIdx) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n 'from should be less than or equal to to',\n );\n }\n\n const fromPos = this.tree.findPos(fromIdx);\n const toPos = this.tree.findPos(toIdx);\n const ticket = this.context.issueTimeTicket();\n const attrs = attributes ? stringifyObjectValues(attributes) : undefined;\n\n const [maxCreationMapByActor, pairs] = this.tree!.style(\n [fromPos, toPos],\n attrs,\n ticket,\n );\n\n for (const pair of pairs) {\n this.context!.registerGCPair(pair);\n }\n\n this.context.push(\n TreeStyleOperation.create(\n this.tree.getCreatedAt(),\n fromPos,\n toPos,\n maxCreationMapByActor,\n attrs ? new Map(Object.entries(attrs)) : new Map(),\n ticket,\n ),\n );\n }\n\n /**\n * `removeStyle` removes the attributes to the elements of the given range.\n */\n public removeStyle(\n fromIdx: number,\n toIdx: number,\n attributesToRemove: Array<string>,\n ) {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n\n if (fromIdx > toIdx) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n 'from should be less than or equal to to',\n );\n }\n\n const fromPos = this.tree.findPos(fromIdx);\n const toPos = this.tree.findPos(toIdx);\n const ticket = this.context.issueTimeTicket();\n\n const [maxCreationMapByActor, pairs] = this.tree!.removeStyle(\n [fromPos, toPos],\n attributesToRemove,\n ticket,\n );\n\n for (const pair of pairs) {\n this.context!.registerGCPair(pair);\n }\n\n this.context.push(\n TreeStyleOperation.createTreeRemoveStyleOperation(\n this.tree.getCreatedAt(),\n fromPos,\n toPos,\n maxCreationMapByActor,\n attributesToRemove,\n ticket,\n ),\n );\n }\n\n private editInternal(\n fromPos: CRDTTreePos,\n toPos: CRDTTreePos,\n contents: Array<TreeNode>,\n splitLevel = 0,\n ): boolean {\n if (contents.length !== 0 && contents[0]) {\n validateTreeNodes(contents);\n if (contents[0].type !== DefaultTextType) {\n for (const content of contents) {\n const { children = [] } = content as ElementNode;\n validateTreeNodes(children);\n }\n }\n }\n\n const ticket = this.context!.getLastTimeTicket();\n let crdtNodes = new Array<CRDTTreeNode>();\n\n if (contents[0]?.type === DefaultTextType) {\n let compVal = '';\n for (const content of contents) {\n const { value } = content as TextNode;\n compVal += value;\n }\n crdtNodes.push(\n CRDTTreeNode.create(\n CRDTTreeNodeID.of(this.context!.issueTimeTicket(), 0),\n DefaultTextType,\n compVal,\n ),\n );\n } else {\n crdtNodes = contents\n .map((content) => content && createCRDTTreeNode(this.context!, content))\n .filter((a) => a) as Array<CRDTTreeNode>;\n }\n\n const [, pairs, maxCreatedAtMapByActor] = this.tree!.edit(\n [fromPos, toPos],\n crdtNodes.length\n ? crdtNodes.map((crdtNode) => crdtNode?.deepcopy())\n : undefined,\n splitLevel,\n ticket,\n () => this.context!.issueTimeTicket(),\n );\n\n for (const pair of pairs) {\n this.context!.registerGCPair(pair);\n }\n\n this.context!.push(\n TreeEditOperation.create(\n this.tree!.getCreatedAt(),\n fromPos,\n toPos,\n crdtNodes.length ? crdtNodes : undefined,\n splitLevel,\n maxCreatedAtMapByActor,\n ticket,\n ),\n );\n\n return true;\n }\n\n /**\n * `editByPath` edits this tree with the given node and path.\n */\n public editByPath(\n fromPath: Array<number>,\n toPath: Array<number>,\n content?: TreeNode,\n splitLevel = 0,\n ): boolean {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n if (fromPath.length !== toPath.length) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n 'path length should be equal',\n );\n }\n if (!fromPath.length || !toPath.length) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n 'path should not be empty',\n );\n }\n\n const fromPos = this.tree.pathToPos(fromPath);\n const toPos = this.tree.pathToPos(toPath);\n\n return this.editInternal(\n fromPos,\n toPos,\n content ? [content] : [],\n splitLevel,\n );\n }\n\n /**\n * `editBulkByPath` edits this tree with the given node and path.\n */\n public editBulkByPath(\n fromPath: Array<number>,\n toPath: Array<number>,\n contents: Array<TreeNode>,\n splitLevel = 0,\n ): boolean {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n if (fromPath.length !== toPath.length) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n 'path length should be equal',\n );\n }\n if (!fromPath.length || !toPath.length) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n 'path should not be empty',\n );\n }\n\n const fromPos = this.tree.pathToPos(fromPath);\n const toPos = this.tree.pathToPos(toPath);\n\n return this.editInternal(fromPos, toPos, contents, splitLevel);\n }\n\n /**\n * `edit` edits this tree with the given nodes.\n */\n public edit(\n fromIdx: number,\n toIdx: number,\n content?: TreeNode,\n splitLevel = 0,\n ): boolean {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n if (fromIdx > toIdx) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n 'from should be less than or equal to to',\n );\n }\n\n const fromPos = this.tree.findPos(fromIdx);\n const toPos = this.tree.findPos(toIdx);\n\n return this.editInternal(\n fromPos,\n toPos,\n content ? [content] : [],\n splitLevel,\n );\n }\n\n /**\n * `editBulk` edits this tree with the given nodes.\n */\n public editBulk(\n fromIdx: number,\n toIdx: number,\n contents: Array<TreeNode>,\n splitLevel = 0,\n ): boolean {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n if (fromIdx > toIdx) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n 'from should be less than or equal to to',\n );\n }\n\n const fromPos = this.tree.findPos(fromIdx);\n const toPos = this.tree.findPos(toIdx);\n\n return this.editInternal(fromPos, toPos, contents, splitLevel);\n }\n\n /**\n * `toXML` returns the XML string of this tree.\n */\n public toXML(): string {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n\n return this.tree.toXML();\n }\n\n /**\n * `toJSON` returns the JSON string of this tree.\n */\n public toJSON(): string {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n\n return this.tree.toJSON();\n }\n\n /**\n * `toJSForTest` returns value with meta data for testing.\n * @internal\n */\n public toJSForTest(): Devtools.JSONElement {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n\n return this.tree.toJSForTest();\n }\n\n /**\n * `toJSInfoForTest` returns detailed TreeNode information for use in Devtools.\n *\n * @internal\n */\n public toJSInfoForTest(): Devtools.TreeNodeInfo {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n\n return this.tree.toJSInfoForTest();\n }\n\n /**\n * `getRootTreeNode` returns TreeNode of this tree.\n */\n public getRootTreeNode() {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n\n return this.tree.getRootTreeNode();\n }\n\n /**\n * `indexToPath` returns the path of the given index.\n */\n public indexToPath(index: number): Array<number> {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n\n return this.tree.indexToPath(index);\n }\n\n /**\n * `pathToIndex` returns the index of given path.\n */\n public pathToIndex(path: Array<number>): number {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n\n return this.tree.pathToIndex(path);\n }\n\n /**\n * `pathRangeToPosRange` converts the path range into the position range.\n */\n pathRangeToPosRange(\n range: [Array<number>, Array<number>],\n ): TreePosStructRange {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n\n const indexRange: [number, number] = [\n this.tree.pathToIndex(range[0]),\n this.tree.pathToIndex(range[1]),\n ];\n const posRange = this.tree.indexRangeToPosRange(indexRange);\n return [posRange[0].toStruct(), posRange[1].toStruct()];\n }\n\n /**\n * `indexRangeToPosRange` converts the index range into the position range.\n */\n indexRangeToPosRange(range: [number, number]): TreePosStructRange {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n\n return this.tree.indexRangeToPosStructRange(range);\n }\n\n /**\n * `posRangeToIndexRange` converts the position range into the index range.\n */\n posRangeToIndexRange(range: TreePosStructRange): [number, number] {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n\n const posRange: [CRDTTreePos, CRDTTreePos] = [\n CRDTTreePos.fromStruct(range[0]),\n CRDTTreePos.fromStruct(range[1]),\n ];\n\n return this.tree.posRangeToIndexRange(posRange);\n }\n\n /**\n * `posRangeToPathRange` converts the position range into the path range.\n */\n posRangeToPathRange(\n range: TreePosStructRange,\n ): [Array<number>, Array<number>] {\n if (!this.context || !this.tree) {\n throw new YorkieError(\n Code.ErrNotInitialized,\n 'Tree is not initialized yet',\n );\n }\n\n const posRange: [CRDTTreePos, CRDTTreePos] = [\n CRDTTreePos.fromStruct(range[0]),\n CRDTTreePos.fromStruct(range[1]),\n ];\n\n return this.tree.posRangeToPathRange(posRange);\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ChangeContext } from '@yorkie-js-sdk/src/document/change/context';\nimport { CRDTElement } from '@yorkie-js-sdk/src/document/crdt/element';\nimport { CRDTObject } from '@yorkie-js-sdk/src/document/crdt/object';\nimport { CRDTArray } from '@yorkie-js-sdk/src/document/crdt/array';\nimport {\n Primitive,\n PrimitiveValue,\n} from '@yorkie-js-sdk/src/document/crdt/primitive';\nimport { CRDTText } from '@yorkie-js-sdk/src/document/crdt/text';\nimport {\n CounterType,\n CRDTCounter,\n} from '@yorkie-js-sdk/src/document/crdt/counter';\nimport { CRDTTree } from '@yorkie-js-sdk/src/document/crdt/tree';\nimport { RGATreeSplit } from '@yorkie-js-sdk/src/document/crdt/rga_tree_split';\nimport { TimeTicket } from '@yorkie-js-sdk/src/document/time/ticket';\n\nimport {\n JSONObject,\n createJSONObject,\n ObjectProxy,\n} from '@yorkie-js-sdk/src/document/json/object';\nimport {\n JSONArray,\n createJSONArray,\n ArrayProxy,\n} from '@yorkie-js-sdk/src/document/json/array';\nimport { Text } from '@yorkie-js-sdk/src/document/json/text';\nimport { Counter } from '@yorkie-js-sdk/src/document/json/counter';\nimport { Tree } from '@yorkie-js-sdk/src/document/json/tree';\nimport { Indexable } from '../document';\n\n/**\n * `createJSON` create a new instance of JSONObject.\n */\nexport function createJSON<T>(\n context: ChangeContext,\n target: CRDTObject,\n): JSONObject<T> {\n return createJSONObject(context, target);\n}\n\n/**\n * `WrappedElement` is a wrapper of JSONElement that provides `getID()`.\n */\nexport type WrappedElement<T = unknown, A extends Indexable = Indexable> =\n | Primitive\n | JSONObject<T>\n | JSONArray<T>\n | Text<A>\n | Counter\n | Tree;\n\n/**\n * `JSONElement` is a wrapper for `CRDTElement` that provides users with an\n * easy-to-use interface for manipulating `Document`s.\n */\nexport type JSONElement<T = unknown, A extends Indexable = Indexable> =\n | PrimitiveValue\n | JSONObject<T>\n | JSONArray<T>\n | Text<A>\n | Counter\n | Tree;\n\n/**\n * `LeafElement` is a leaf element of JSONElement.\n */\nexport type LeafElement = PrimitiveValue | Primitive | Text | Counter | Tree;\n\n/**\n * `BaseArray` is a base type of JSONArray.\n */\nexport type BaseArray<T> = JSONArray<T> | Array<T>;\n\nexport type BaseObject<T> = JSONObject<T> | Record<string, T>;\n\n/**\n * `toWrappedElement` converts the CRDT type to `WrappedElement`.\n */\nexport function toWrappedElement(\n context: ChangeContext,\n elem?: CRDTElement,\n): WrappedElement | undefined {\n if (!elem) {\n return;\n } else if (elem instanceof Primitive) {\n return elem;\n } else if (elem instanceof CRDTObject) {\n return createJSONObject(context, elem);\n } else if (elem instanceof CRDTArray) {\n return createJSONArray(context, elem);\n } else if (elem instanceof CRDTText) {\n return new Text(context, elem);\n } else if (elem instanceof CRDTCounter) {\n const counter = new Counter(CounterType.IntegerCnt, 0);\n counter.initialize(context, elem);\n return counter;\n } else if (elem instanceof CRDTTree) {\n const tree = new Tree();\n tree.initialize(context, elem);\n return tree;\n }\n\n throw new TypeError(`Unsupported type of element: ${typeof elem}`);\n}\n\n/**\n * `toJSONElement` converts the CRDT type to `JSONElement`.\n */\nexport function toJSONElement(\n context: ChangeContext,\n elem?: CRDTElement,\n): JSONElement | undefined {\n const wrappedElement = toWrappedElement(context, elem);\n if (wrappedElement instanceof Primitive) {\n return wrappedElement.getValue();\n }\n\n return wrappedElement;\n}\n\n/**\n * `buildCRDTElement` constructs a CRDTElement from the given value.\n */\nexport function buildCRDTElement(\n context: ChangeContext,\n value: unknown,\n createdAt: TimeTicket,\n): CRDTElement {\n let element: CRDTElement;\n if (Primitive.isSupport(value)) {\n element = Primitive.of(value as PrimitiveValue, createdAt);\n } else if (Array.isArray(value)) {\n element = CRDTArray.create(\n createdAt,\n ArrayProxy.buildArrayElements(context, value),\n );\n } else if (typeof value === 'object') {\n if (value instanceof Text) {\n element = CRDTText.create(RGATreeSplit.create(), createdAt);\n value.initialize(context, element as CRDTText);\n } else if (value instanceof Counter) {\n element = CRDTCounter.create(\n value.getValueType(),\n value.getValue(),\n createdAt,\n );\n value.initialize(context, element as CRDTCounter);\n } else if (value instanceof Tree) {\n element = CRDTTree.create(value.buildRoot(context), createdAt);\n value.initialize(context, element as CRDTTree);\n } else {\n element = CRDTObject.create(\n createdAt,\n ObjectProxy.buildObjectMembers(context, value!),\n );\n }\n } else {\n throw new TypeError(`Unsupported type of value: ${typeof value}`);\n }\n return element;\n}\n","/*\n * Copyright 2023 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Operation } from './operation/operation';\nimport { Indexable } from './document';\n\n/**\n * `HistoryOperation` is a type of history operation.\n */\nexport type HistoryOperation<P extends Indexable> =\n | Operation\n | {\n type: 'presence';\n value: Partial<P>;\n };\n\n/**\n * `MaxUndoRedoStackDepth` is the maximum depth of undo/redo stack.\n */\nexport const MaxUndoRedoStackDepth = 50;\n\n/**\n * `History` is a class that stores the history of the document.\n */\nexport class History<P extends Indexable> {\n private undoStack: Array<Array<HistoryOperation<P>>> = [];\n private redoStack: Array<Array<HistoryOperation<P>>> = [];\n\n /**\n * `hasUndo` returns true if there are undo operations.\n */\n public hasUndo(): boolean {\n return this.undoStack.length > 0;\n }\n\n /**\n * `hasRedo` returns true if there are redo operations.\n */\n public hasRedo(): boolean {\n return this.redoStack.length > 0;\n }\n\n /**\n * `pushUndo` pushes new undo operations of a change to undo stack.\n */\n public pushUndo(undoOps: Array<HistoryOperation<P>>): void {\n if (this.undoStack.length >= MaxUndoRedoStackDepth) {\n this.undoStack.shift();\n }\n this.undoStack.push(undoOps);\n }\n\n /**\n * `popUndo` pops the last undo operations of a change from undo stack.\n */\n public popUndo(): Array<HistoryOperation<P>> | undefined {\n return this.undoStack.pop();\n }\n\n /**\n * `pushRedo` pushes new redo operations of a change to redo stack.\n */\n public pushRedo(redoOps: Array<HistoryOperation<P>>): void {\n if (this.redoStack.length >= MaxUndoRedoStackDepth) {\n this.redoStack.shift();\n }\n this.redoStack.push(redoOps);\n }\n\n /**\n * `popRedo` pops the last redo operations of a change from redo stack.\n */\n public popRedo(): Array<HistoryOperation<P>> | undefined {\n return this.redoStack.pop();\n }\n\n /**\n * `clearRedo` flushes remaining redo operations.\n */\n public clearRedo(): void {\n this.redoStack = [];\n }\n\n /**\n * `getUndoStackForTest` returns the undo stack for test.\n */\n public getUndoStackForTest(): Array<Array<HistoryOperation<P>>> {\n return this.undoStack;\n }\n\n /**\n * `getRedoStackForTest` returns the redo stack for test.\n */\n public getRedoStackForTest(): Array<Array<HistoryOperation<P>>> {\n return this.redoStack;\n }\n}\n","/*\n * Copyright 2024 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { DocEventsForReplay } from './types';\n\n/**\n * `EventSourceDevPanel` is the name of the source representing messages\n * from the Devtools panel.\n */\nexport const EventSourceDevPanel = 'yorkie-devtools-panel';\n\n/**\n * `EventSourceSDK` is the name of the source representing messages\n * from the SDK.\n */\nexport const EventSourceSDK = 'yorkie-devtools-sdk';\n\n/**\n * PanelToSDKMessage is a message sent from the Devtools panel to the SDK.\n */\nexport type PanelToSDKMessage =\n /**\n * Informs the SDK that the panel is available.\n */\n | { msg: 'devtools::connect' }\n\n /**\n * Informs the SDK that the panel is not available.\n */\n | { msg: 'devtools::disconnect' }\n\n /**\n * Informs the SDK that the panel is interested in receiving the \"event\" for the document,\n * starting with the initial \"full sync\" event.\n */\n | {\n msg: 'devtools::subscribe';\n docKey: string;\n };\n\n/**\n * Definition of all messages the SDK can send to the Devtools panel.\n */\nexport type SDKToPanelMessage =\n /**\n * Sent when the dev panel is already opened and listened,\n * before the sdk is loaded. If the panel receives this message,\n * it will replay its initial \"connect\" message.\n */\n | {\n msg: 'refresh-devtools';\n }\n /**\n * Sent when the document is available for the panel to watch.\n */\n | {\n msg: 'doc::available';\n docKey: string;\n }\n /**\n * Sent initially, to synchronize the entire current state of the document.\n */\n | {\n msg: 'doc::sync::full';\n docKey: string;\n events: Array<DocEventsForReplay>;\n }\n /**\n * Sent whenever the document is changed.\n */\n | {\n msg: 'doc::sync::partial';\n docKey: string;\n event: DocEventsForReplay;\n };\n\nexport type FullPanelToSDKMessage = PanelToSDKMessage & {\n source: 'yorkie-devtools-panel';\n};\n\nexport type FullSDKToPanelMessage = SDKToPanelMessage & {\n source: 'yorkie-devtools-sdk';\n};\n","/*\n * Copyright 2024 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { PrimitiveValue } from '@yorkie-js-sdk/src/document/crdt/primitive';\nimport type { CRDTTreePosStruct } from '@yorkie-js-sdk/src/document/crdt/tree';\nimport { CounterValue } from '@yorkie-js-sdk/src/document/crdt/counter';\nimport {\n Json,\n DocEvent,\n DocEventType,\n type Indexable,\n type StatusChangedEvent,\n type SnapshotEvent,\n type LocalChangeEvent,\n type RemoteChangeEvent,\n type InitializedEvent,\n type WatchedEvent,\n type UnwatchedEvent,\n type PresenceChangedEvent,\n} from '@yorkie-js-sdk/src/document/document';\nimport type { OperationInfo } from '@yorkie-js-sdk/src/document/operation/operation';\n\n/**\n * `Client` represents a client value in devtools.\n */\nexport type Client = {\n clientID: string;\n presence: Json;\n};\n\n/**\n * `JSONElement` represents the result of `Element.toJSForTest()`.\n */\nexport type JSONElement = {\n type: JSONElementType;\n key?: string;\n value: JSONElementValue;\n createdAt: string;\n};\n\ntype JSONElementType =\n | 'YORKIE_PRIMITIVE'\n | 'YORKIE_COUNTER'\n | 'YORKIE_OBJECT'\n | 'YORKIE_ARRAY'\n | 'YORKIE_TEXT'\n | 'YORKIE_TREE';\n\n/**\n * `ElementValue` represents the result of `Element.toJSForTest()`.\n *\n * NOTE(chacha912): Json type is used to represent the result of\n * `Text.toJSForTest()` and `Tree.toJSForTest()`.\n */\ntype JSONElementValue =\n | PrimitiveValue\n | CounterValue\n | ContainerValue // Array | Object\n | Json; // Text | Tree\n\n/**\n * `ContainerValue` represents the result of `Array.toJSForTest()` and\n * `Object.toJSForTest()`.\n */\nexport type ContainerValue = {\n [key: string]: JSONElement;\n};\n\n/**\n * `TreeNodeInfo` represents the crdt tree node information in devtools.\n */\nexport type TreeNodeInfo = {\n id: string;\n type: string;\n parent?: string;\n size: number;\n value?: string;\n removedAt?: string;\n isRemoved: boolean;\n insPrev?: string;\n insNext?: string;\n children: Array<TreeNodeInfo>;\n attributes?: object; // TODO(chacha912): Specify the type accurately.\n depth: number;\n index?: number;\n path?: Array<number>;\n pos?: CRDTTreePosStruct;\n};\n\n/**\n * `DocEventForReplay` is an event used to replay a document.\n */\nexport type DocEventForReplay<\n P extends Indexable = Indexable,\n T = OperationInfo,\n> =\n | StatusChangedEvent\n | SnapshotEvent\n | LocalChangeEvent<T, P>\n | RemoteChangeEvent<T, P>\n | InitializedEvent<P>\n | WatchedEvent<P>\n | UnwatchedEvent<P>\n | PresenceChangedEvent<P>;\n\n/**\n * `DocEventsForReplay` is a list of events used to replay a document.\n */\nexport type DocEventsForReplay = Array<DocEventForReplay>;\n\n/**\n * `isDocEventForReplay` checks if an event can be used to replay a document.\n */\nexport function isDocEventForReplay(\n event: DocEvent,\n): event is DocEventForReplay {\n const types = [\n DocEventType.StatusChanged,\n DocEventType.Snapshot,\n DocEventType.LocalChange,\n DocEventType.RemoteChange,\n DocEventType.Initialized,\n DocEventType.Watched,\n DocEventType.Unwatched,\n DocEventType.PresenceChanged,\n ];\n\n return types.includes(event.type);\n}\n\n/**\n * `isDocEventsForReplay` checks if a list of events can be used to replay a document.\n */\nexport function isDocEventsForReplay(\n events: Array<DocEvent>,\n): events is DocEventsForReplay {\n return events.every(isDocEventForReplay);\n}\n","/*\n * Copyright 2024 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Document, Indexable } from '@yorkie-js-sdk/src/yorkie';\nimport { logger } from '@yorkie-js-sdk/src/util/logger';\nimport type * as DevTools from './protocol';\nimport { EventSourceDevPanel, EventSourceSDK } from './protocol';\nimport { DocEventsForReplay, isDocEventsForReplay } from './types';\n\ntype DevtoolsStatus = 'connected' | 'disconnected' | 'synced';\nlet devtoolsStatus: DevtoolsStatus = 'disconnected';\nconst unsubsByDocKey = new Map<string, Array<() => void>>();\n\n/**\n * `docEventsForReplayByDocKey` stores all events in the document for replaying\n * (time-traveling feature) in Devtools. Later, external storage such as\n * IndexedDB will be used.\n */\nconst docEventsForReplayByDocKey = new Map<string, Array<DocEventsForReplay>>();\ndeclare global {\n interface Window {\n docEventsForReplayByDocKey: Map<string, Array<DocEventsForReplay>>;\n }\n}\nif (typeof window !== 'undefined') {\n window.docEventsForReplayByDocKey = docEventsForReplayByDocKey;\n}\n\n/**\n * `sendToPanel` sends a message to the devtools panel.\n */\nfunction sendToPanel(\n message: DevTools.SDKToPanelMessage,\n options?: { force: boolean },\n): void {\n if (!(options?.force || devtoolsStatus !== 'disconnected')) {\n return;\n }\n\n window.postMessage(\n {\n source: EventSourceSDK,\n ...message,\n },\n '*',\n );\n}\n\n/**\n * `setupDevtools` sets up the devtools integration. It sends messages to the\n * devtools panel when a document is available, when a document is subscribed,\n * and when a document is changed.\n */\nexport function setupDevtools<T, P extends Indexable>(\n doc: Document<T, P>,\n): void {\n if (\n !doc.isEnableDevtools() ||\n typeof window === 'undefined' ||\n unsubsByDocKey.has(doc.getKey())\n ) {\n return;\n }\n\n docEventsForReplayByDocKey.set(doc.getKey(), []);\n const unsub = doc.subscribe('all', (event) => {\n if (!isDocEventsForReplay(event)) {\n return;\n }\n\n docEventsForReplayByDocKey.get(doc.getKey())!.push(event);\n if (devtoolsStatus === 'synced') {\n sendToPanel({\n msg: 'doc::sync::partial',\n docKey: doc.getKey(),\n event,\n });\n }\n });\n // TODO(chacha912): Cancel the subscription when the document is removed.\n unsubsByDocKey.set(doc.getKey(), [unsub]);\n\n // NOTE(chacha912): Send initial message, in case the devtool panel is already open.\n sendToPanel(\n {\n msg: 'refresh-devtools',\n },\n { force: true },\n );\n\n // TODO(hackerwins): We need to ensure that this event listener should be\n // removed later.\n window.addEventListener(\n 'message',\n (event: MessageEvent<DevTools.FullPanelToSDKMessage>) => {\n if (event.data?.source !== EventSourceDevPanel) {\n return;\n }\n\n const message = event.data;\n switch (message.msg) {\n case 'devtools::connect':\n if (devtoolsStatus !== 'disconnected') {\n break;\n }\n devtoolsStatus = 'connected';\n sendToPanel({\n msg: 'doc::available',\n docKey: doc.getKey(),\n });\n logger.info(`[YD] Devtools connected. Doc: ${doc.getKey()}`);\n break;\n case 'devtools::disconnect':\n devtoolsStatus = 'disconnected';\n logger.info(`[YD] Devtools disconnected. Doc: ${doc.getKey()}`);\n break;\n case 'devtools::subscribe':\n devtoolsStatus = 'synced';\n sendToPanel({\n msg: 'doc::sync::full',\n docKey: doc.getKey(),\n events: docEventsForReplayByDocKey.get(doc.getKey())!,\n });\n logger.info(`[YD] Devtools subscribed. Doc: ${doc.getKey()}`);\n break;\n }\n },\n );\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type { WatchDocumentResponse } from '@yorkie-js-sdk/src/api/yorkie/v1/yorkie_pb';\nimport { DocEventType as PbDocEventType } from '@yorkie-js-sdk/src/api/yorkie/v1/resources_pb';\nimport { logger, LogLevel } from '@yorkie-js-sdk/src/util/logger';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\nimport { deepcopy } from '@yorkie-js-sdk/src/util/object';\nimport {\n Observer,\n Observable,\n createObservable,\n Unsubscribe,\n ErrorFn,\n CompleteFn,\n NextFn,\n} from '@yorkie-js-sdk/src/util/observable';\nimport {\n ActorID,\n InitialActorID,\n} from '@yorkie-js-sdk/src/document/time/actor_id';\nimport {\n Change,\n ChangeStruct,\n} from '@yorkie-js-sdk/src/document/change/change';\nimport {\n ChangeID,\n InitialChangeID,\n} from '@yorkie-js-sdk/src/document/change/change_id';\nimport { ChangeContext } from '@yorkie-js-sdk/src/document/change/context';\nimport { converter } from '@yorkie-js-sdk/src/api/converter';\nimport { ChangePack } from '@yorkie-js-sdk/src/document/change/change_pack';\nimport { CRDTRoot, RootStats } from '@yorkie-js-sdk/src/document/crdt/root';\nimport { CRDTObject } from '@yorkie-js-sdk/src/document/crdt/object';\nimport {\n createJSON,\n JSONElement,\n LeafElement,\n BaseArray,\n BaseObject,\n} from '@yorkie-js-sdk/src/document/json/element';\nimport {\n Checkpoint,\n InitialCheckpoint,\n} from '@yorkie-js-sdk/src/document/change/checkpoint';\nimport {\n OpSource,\n OperationInfo,\n ObjectOperationInfo,\n TextOperationInfo,\n CounterOperationInfo,\n ArrayOperationInfo,\n TreeOperationInfo,\n Operation,\n} from '@yorkie-js-sdk/src/document/operation/operation';\nimport { JSONObject } from '@yorkie-js-sdk/src/document/json/object';\nimport { Counter } from '@yorkie-js-sdk/src/document/json/counter';\nimport { Text } from '@yorkie-js-sdk/src/document/json/text';\nimport { Tree } from '@yorkie-js-sdk/src/document/json/tree';\nimport {\n Presence,\n PresenceChangeType,\n} from '@yorkie-js-sdk/src/document/presence/presence';\nimport { History, HistoryOperation } from '@yorkie-js-sdk/src/document/history';\nimport { setupDevtools } from '@yorkie-js-sdk/src/devtools';\nimport * as Devtools from '@yorkie-js-sdk/src/devtools/types';\nimport { VersionVector } from './time/version_vector';\n\n/**\n * `BroadcastOptions` are the options to create a new document.\n *\n * @public\n */\nexport interface BroadcastOptions {\n /**\n * `error` is called when an error occurs.\n */\n error?: ErrorFn;\n\n /**\n * `maxRetries` is the maximum number of retries.\n */\n maxRetries?: number;\n}\n\n/**\n * `DocumentOptions` are the options to create a new document.\n *\n * @public\n */\nexport interface DocumentOptions {\n /**\n * `disableGC` disables garbage collection if true.\n */\n disableGC?: boolean;\n\n /**\n * `enableDevtools` enables devtools if true.\n */\n enableDevtools?: boolean;\n}\n\n/**\n * `DocStatus` represents the status of the document.\n * @public\n */\nexport enum DocStatus {\n /**\n * Detached means that the document is not attached to the client.\n * The actor of the ticket is created without being assigned.\n */\n Detached = 'detached',\n /**\n * Attached means that this document is attached to the client.\n * The actor of the ticket is created with being assigned by the client.\n */\n Attached = 'attached',\n /**\n * Removed means that this document is removed. If the document is removed,\n * it cannot be edited.\n */\n Removed = 'removed',\n}\n\n/**\n * `DocEventType` represents the type of the event that occurs in `Document`.\n * @public\n */\nexport enum DocEventType {\n /**\n * status changed event type\n */\n StatusChanged = 'status-changed',\n\n /**\n * `ConnectionChanged` means that the watch stream connection status has changed.\n */\n ConnectionChanged = 'connection-changed',\n\n /**\n * `SyncStatusChanged` means that the document sync status has changed.\n */\n SyncStatusChanged = 'sync-status-changed',\n\n /**\n * snapshot event type\n */\n Snapshot = 'snapshot',\n\n /**\n * local document change event type\n */\n LocalChange = 'local-change',\n\n /**\n * remote document change event type\n */\n RemoteChange = 'remote-change',\n\n /**\n * `Initialized` means that online clients have been loaded from the server.\n */\n Initialized = 'initialized',\n\n /**\n * `Watched` means that the client has established a connection with the server,\n * enabling real-time synchronization.\n */\n Watched = 'watched',\n\n /**\n * `Unwatched` means that the connection has been disconnected.\n */\n Unwatched = 'unwatched',\n\n /**\n * `PresenceChanged` means that the presences of the client has updated.\n */\n PresenceChanged = 'presence-changed',\n\n /**\n * `Broadcast` means that the broadcast event is received from the remote client.\n */\n Broadcast = 'broadcast',\n\n /**\n * `LocalBroadcast` means that the broadcast event is sent from the local client.\n */\n LocalBroadcast = 'local-broadcast',\n\n /**\n * `AuthError` indicates an authorization failure in syncLoop or watchLoop.\n */\n AuthError = 'auth-error',\n}\n\n/**\n * `DocEvent` is an event that occurs in `Document`. It can be delivered\n * using `Document.subscribe()`.\n *\n * @public\n */\nexport type DocEvent<P extends Indexable = Indexable, T = OperationInfo> =\n | StatusChangedEvent\n | ConnectionChangedEvent\n | SyncStatusChangedEvent\n | SnapshotEvent\n | LocalChangeEvent<T, P>\n | RemoteChangeEvent<T, P>\n | InitializedEvent<P>\n | WatchedEvent<P>\n | UnwatchedEvent<P>\n | PresenceChangedEvent<P>\n | BroadcastEvent\n | LocalBroadcastEvent\n | AuthErrorEvent;\n\n/**\n * `DocEvents` represents document events that occur within\n * a single transaction (e.g., doc.update).\n */\nexport type DocEvents<P extends Indexable = Indexable> = Array<DocEvent<P>>;\n\n/**\n * @internal\n */\nexport interface BaseDocEvent {\n type: DocEventType;\n}\n\n/**\n * `StatusChangedEvent` is an event that occurs when the status of a document changes.\n *\n * @public\n */\nexport interface StatusChangedEvent extends BaseDocEvent {\n /**\n * enum {@link DocEventType}.StatusChanged\n */\n type: DocEventType.StatusChanged;\n source: OpSource;\n value:\n | { status: DocStatus.Attached; actorID: string }\n | { status: DocStatus.Detached }\n | { status: DocStatus.Removed };\n}\n\n/**\n * `StreamConnectionStatus` represents whether the stream connection is connected or not.\n * @public\n */\nexport enum StreamConnectionStatus {\n /**\n * `Connected` means that the stream connection is connected.\n */\n Connected = 'connected',\n /**\n * `Disconnected` means that the stream connection is disconnected.\n */\n Disconnected = 'disconnected',\n}\n\n/**\n * `ConnectionChangedEvent` is an event that occurs when the stream connection state changes.\n *\n * @public\n */\nexport interface ConnectionChangedEvent extends BaseDocEvent {\n /**\n * enum {@link DocEventType}.ConnectionChanged\n */\n type: DocEventType.ConnectionChanged;\n value: StreamConnectionStatus;\n}\n\n/**\n * `DocSyncStatus` represents the result of synchronizing the document with the server.\n * @public\n */\nexport enum DocSyncStatus {\n /**\n * `Synced` means that document synced successfully.\n */\n Synced = 'synced',\n /**\n * `SyncFiled` means that document synchronization has failed.\n */\n SyncFailed = 'sync-failed',\n}\n\n/**\n * `SyncStatusChangedEvent` is an event that occurs when document is synced with the server.\n *\n * @public\n */\nexport interface SyncStatusChangedEvent extends BaseDocEvent {\n /**\n * enum {@link DocEventType}.SyncStatusChanged\n */\n type: DocEventType.SyncStatusChanged;\n value: DocSyncStatus;\n}\n\n/**\n * `SnapshotEvent` is an event that occurs when a snapshot is received from\n * the server.\n *\n * @public\n */\nexport interface SnapshotEvent extends BaseDocEvent {\n /**\n * enum {@link DocEventType}.Snapshot\n */\n type: DocEventType.Snapshot;\n source: OpSource.Remote;\n value: {\n snapshot: string | undefined;\n serverSeq: string;\n snapshotVector: string;\n };\n}\n\n/**\n * `ChangeInfo` represents the modifications made during a document update\n * and the message passed.\n */\nexport interface ChangeInfo<T = OperationInfo> {\n message: string;\n operations: Array<T>;\n actor: ActorID;\n clientSeq: number;\n serverSeq: string;\n}\n\n/**\n * `LocalChangeEvent` is an event that occurs when the document is changed\n * by local changes.\n *\n * @public\n */\nexport interface LocalChangeEvent<\n T = OperationInfo,\n P extends Indexable = Indexable,\n> extends BaseDocEvent {\n /**\n * enum {@link DocEventType}.LocalChange\n */\n type: DocEventType.LocalChange;\n source: OpSource.Local | OpSource.UndoRedo;\n value: ChangeInfo<T>;\n rawChange?: ChangeStruct<P>;\n}\n\n/**\n * `RemoteChangeEvent` is an event that occurs when the document is changed\n * by remote changes.\n *\n * @public\n */\nexport interface RemoteChangeEvent<\n T = OperationInfo,\n P extends Indexable = Indexable,\n> extends BaseDocEvent {\n /**\n * enum {@link DocEventType}.RemoteChange\n */\n type: DocEventType.RemoteChange;\n source: OpSource.Remote;\n value: ChangeInfo<T>;\n rawChange?: ChangeStruct<P>;\n}\n\nexport interface InitializedEvent<P extends Indexable> extends BaseDocEvent {\n type: DocEventType.Initialized;\n source: OpSource.Local;\n value: Array<{ clientID: ActorID; presence: P }>;\n}\n\nexport interface WatchedEvent<P extends Indexable> extends BaseDocEvent {\n type: DocEventType.Watched;\n source: OpSource.Remote;\n value: { clientID: ActorID; presence: P };\n}\n\nexport interface UnwatchedEvent<P extends Indexable> extends BaseDocEvent {\n type: DocEventType.Unwatched;\n source: OpSource.Remote;\n value: { clientID: ActorID; presence: P };\n}\n\nexport interface PresenceChangedEvent<P extends Indexable>\n extends BaseDocEvent {\n type: DocEventType.PresenceChanged;\n source: OpSource;\n value: { clientID: ActorID; presence: P };\n}\n\nexport interface BroadcastEvent extends BaseDocEvent {\n type: DocEventType.Broadcast;\n value: { clientID: ActorID; topic: string; payload: Json };\n options?: BroadcastOptions;\n}\n\nexport interface LocalBroadcastEvent extends BaseDocEvent {\n type: DocEventType.LocalBroadcast;\n value: { topic: string; payload: any };\n options?: BroadcastOptions;\n}\n\nexport interface AuthErrorEvent extends BaseDocEvent {\n type: DocEventType.AuthError;\n value: {\n reason: string;\n method: 'PushPull' | 'WatchDocuments' | 'Broadcast';\n };\n}\n\ntype DocEventCallbackMap<P extends Indexable> = {\n default: NextFn<\n | SnapshotEvent\n | LocalChangeEvent<OperationInfo, P>\n | RemoteChangeEvent<OperationInfo, P>\n >;\n presence: NextFn<\n | InitializedEvent<P>\n | WatchedEvent<P>\n | UnwatchedEvent<P>\n | PresenceChangedEvent<P>\n >;\n 'my-presence': NextFn<InitializedEvent<P> | PresenceChangedEvent<P>>;\n others: NextFn<WatchedEvent<P> | UnwatchedEvent<P> | PresenceChangedEvent<P>>;\n connection: NextFn<ConnectionChangedEvent>;\n status: NextFn<StatusChangedEvent>;\n sync: NextFn<SyncStatusChangedEvent>;\n broadcast: NextFn<BroadcastEvent>;\n 'local-broadcast': NextFn<LocalBroadcastEvent>;\n 'auth-error': NextFn<AuthErrorEvent>;\n all: NextFn<DocEvents<P>>;\n};\nexport type DocEventTopic = keyof DocEventCallbackMap<never>;\nexport type DocEventCallback<P extends Indexable> =\n DocEventCallbackMap<P>[DocEventTopic];\n\n/**\n * `Json` represents the JSON data type. It is used to represent the data\n * structure of the document.\n */\nexport type Json = JsonPrimitive | JsonArray | JsonObject;\n\n// eslint-disable-next-line @typescript-eslint/ban-types\ntype JsonPrimitive = string | number | boolean | null;\ntype JsonArray = Array<Json>;\ntype JsonObject = { [key: string]: Json | undefined };\n\n/**\n * `Indexable` represents the type of the indexable object. It is used to\n * represent the presence information of the client.\n * @public\n */\nexport type Indexable = Record<string, Json>;\n\n/**\n * `DocKey` represents the key of the document.\n * @public\n */\nexport type DocKey = string;\n\n/**\n * `OperationInfoOfElement` represents the type of the operation info of the given element.\n */\ntype OperationInfoOfElement<TElement> = TElement extends Text\n ? TextOperationInfo\n : TElement extends Counter\n ? CounterOperationInfo\n : TElement extends Tree\n ? TreeOperationInfo\n : TElement extends BaseArray<any>\n ? ArrayOperationInfo\n : TElement extends BaseObject<any>\n ? ObjectOperationInfo\n : OperationInfo;\n\n/**\n * `OperationInfoOfInternal` represents the type of the operation info of the\n * given path in the Document.subscribe.\n *\n * TODO(easylogic): If the parent is optional, children cannot be inferred.\n * TODO(easylogic): Currently, the below cases of Document.subscribe are confused.\n * ```\n * type DocType = { obj: { key: string }, text: Text }\n * $.obj.text ->> obj's operations\n * $.text ->> text's operations\n * ```\n */\ntype OperationInfoOfInternal<\n TElement,\n TKeyOrPath,\n TDepth extends number = 0,\n> = TDepth extends 0\n ? TElement\n : TKeyOrPath extends `${infer TFirst}.${infer TRest}`\n ? TFirst extends keyof TElement\n ? TElement[TFirst] extends BaseArray<unknown>\n ? OperationInfoOfInternal<\n TElement[TFirst],\n number,\n DecreasedDepthOf<TDepth>\n >\n : OperationInfoOfInternal<\n TElement[TFirst],\n TRest,\n DecreasedDepthOf<TDepth>\n >\n : OperationInfo\n : TKeyOrPath extends keyof TElement\n ? TElement[TKeyOrPath] extends BaseArray<unknown>\n ? ArrayOperationInfo\n : OperationInfoOfElement<TElement[TKeyOrPath]>\n : OperationInfo;\n\n/**\n * `DecreasedDepthOf` represents the type of the decreased depth of the given depth.\n */\ntype DecreasedDepthOf<Depth extends number = 0> = Depth extends 10\n ? 9\n : Depth extends 9\n ? 8\n : Depth extends 8\n ? 7\n : Depth extends 7\n ? 6\n : Depth extends 6\n ? 5\n : Depth extends 5\n ? 4\n : Depth extends 4\n ? 3\n : Depth extends 3\n ? 2\n : Depth extends 2\n ? 1\n : Depth extends 1\n ? 0\n : -1;\n\n/**\n * `PathOfInternal` represents the type of the path of the given element.\n */\ntype PathOfInternal<\n TElement,\n Prefix extends string = '',\n Depth extends number = 0,\n> = Depth extends 0\n ? Prefix\n : TElement extends Record<string, any>\n ? {\n [TKey in keyof TElement]: TElement[TKey] extends LeafElement\n ? `${Prefix}${TKey & string}`\n : TElement[TKey] extends BaseArray<infer TArrayElement>\n ?\n | `${Prefix}${TKey & string}`\n | `${Prefix}${TKey & string}.${number}`\n | PathOfInternal<\n TArrayElement,\n `${Prefix}${TKey & string}.${number}.`,\n DecreasedDepthOf<Depth>\n >\n :\n | `${Prefix}${TKey & string}`\n | PathOfInternal<\n TElement[TKey],\n `${Prefix}${TKey & string}.`,\n DecreasedDepthOf<Depth>\n >;\n }[keyof TElement]\n : Prefix extends `${infer TRest}.`\n ? TRest\n : Prefix;\n\n/**\n * `OperationInfoOf` represents the type of the operation info of the given\n * path in the Document.subscribe. It is used to remove the `$.` prefix.\n */\ntype OperationInfoOf<\n TDocument,\n TKey extends string = '',\n TDepth extends number = 10,\n> = TKey extends `$.${infer TPath}`\n ? OperationInfoOfInternal<TDocument, TPath, TDepth>\n : OperationInfoOfInternal<TDocument, TKey, TDepth>;\n\n/**\n * `PathOf` represents the type of the all possible paths in the Document.subscribe.\n */\ntype PathOf<TDocument, Depth extends number = 10> = PathOfInternal<\n TDocument,\n '$.',\n Depth\n>;\n\n/**\n * `Document` is a CRDT-based data type. We can represent the model\n * of the application and edit it even while offline.\n *\n * @public\n */\nexport class Document<T, P extends Indexable = Indexable> {\n private key: DocKey;\n private status: DocStatus;\n private opts: DocumentOptions;\n\n private changeID: ChangeID;\n private checkpoint: Checkpoint;\n private localChanges: Array<Change<P>>;\n\n private root: CRDTRoot;\n private clone?: {\n root: CRDTRoot;\n presences: Map<ActorID, P>;\n };\n\n private eventStream: Observable<DocEvents<P>>;\n private eventStreamObserver!: Observer<DocEvents<P>>;\n\n /**\n * `onlineClients` is a set of client IDs that are currently online.\n */\n private onlineClients: Set<ActorID>;\n\n /**\n * `presences` is a map of client IDs to their presence information.\n */\n private presences: Map<ActorID, P>;\n\n /**\n * `history` is exposed to the user to manage undo/redo operations.\n */\n public history;\n\n /**\n * `internalHistory` is used to manage undo/redo operations internally.\n */\n public internalHistory: History<P>;\n\n /**\n * `isUpdating` is whether the document is updating by updater or not. It is\n * used to prevent the updater from calling undo/redo.\n */\n private isUpdating: boolean;\n\n constructor(key: string, opts?: DocumentOptions) {\n this.opts = opts || {};\n\n this.key = key;\n this.status = DocStatus.Detached;\n this.root = CRDTRoot.create();\n\n this.changeID = InitialChangeID;\n this.checkpoint = InitialCheckpoint;\n this.localChanges = [];\n\n this.eventStream = createObservable<DocEvents<P>>((observer) => {\n this.eventStreamObserver = observer;\n });\n\n this.onlineClients = new Set();\n this.presences = new Map();\n\n this.isUpdating = false;\n this.internalHistory = new History();\n this.history = {\n canUndo: this.canUndo.bind(this),\n canRedo: this.canRedo.bind(this),\n undo: this.undo.bind(this),\n redo: this.redo.bind(this),\n };\n\n setupDevtools(this);\n }\n\n /**\n * `update` executes the given updater to update this document.\n */\n public update(\n updater: (root: JSONObject<T>, presence: Presence<P>) => void,\n message?: string,\n ): void {\n if (this.getStatus() === DocStatus.Removed) {\n throw new YorkieError(Code.ErrDocumentRemoved, `${this.key} is removed`);\n }\n\n // 01. Update the clone object and create a change.\n this.ensureClone();\n const actorID = this.changeID.getActorID();\n const context = ChangeContext.create<P>(\n this.changeID.next(),\n this.clone!.root,\n this.clone!.presences.get(actorID) || ({} as P),\n message,\n );\n\n try {\n const proxy = createJSON<JSONObject<T>>(\n context,\n this.clone!.root.getObject(),\n );\n\n if (!this.presences.has(actorID)) {\n this.clone!.presences.set(actorID, {} as P);\n }\n\n // NOTE(hackerwins): The updater should not be able to call undo/redo.\n // If the updater calls undo/redo, an error will be thrown.\n this.isUpdating = true;\n updater(\n proxy,\n new Presence(context, this.clone!.presences.get(actorID)!),\n );\n } catch (err) {\n // drop clone because it is contaminated.\n this.clone = undefined;\n\n throw err;\n } finally {\n this.isUpdating = false;\n }\n\n // 02. Update the root object and presences from changes.\n if (context.hasChange()) {\n if (logger.isEnabled(LogLevel.Trivial)) {\n logger.trivial(`trying to update a local change: ${this.toJSON()}`);\n }\n\n const change = context.getChange();\n const { opInfos, reverseOps } = change.execute(\n this.root,\n this.presences,\n OpSource.Local,\n );\n const reversePresence = context.getReversePresence();\n if (reversePresence) {\n reverseOps.push({\n type: 'presence',\n value: reversePresence,\n });\n }\n\n this.localChanges.push(change);\n if (reverseOps.length > 0) {\n this.internalHistory.pushUndo(reverseOps);\n }\n // NOTE(chacha912): Clear redo when a new local operation is applied.\n if (opInfos.length > 0) {\n this.internalHistory.clearRedo();\n }\n this.changeID = change.getID();\n\n // 03. Publish the document change event.\n // NOTE(chacha912): Check opInfos, which represent the actually executed operations.\n const event: DocEvents<P> = [];\n if (opInfos.length > 0) {\n event.push({\n type: DocEventType.LocalChange,\n source: OpSource.Local,\n value: {\n message: change.getMessage() || '',\n operations: opInfos,\n actor: actorID,\n clientSeq: change.getID().getClientSeq(),\n serverSeq: change.getID().getServerSeq(),\n },\n rawChange: this.isEnableDevtools() ? change.toStruct() : undefined,\n });\n }\n if (change.hasPresenceChange()) {\n event.push({\n type: DocEventType.PresenceChanged,\n source: OpSource.Local,\n value: {\n clientID: actorID,\n presence: this.getPresence(actorID)!,\n },\n });\n }\n\n this.publish(event);\n\n if (logger.isEnabled(LogLevel.Trivial)) {\n logger.trivial(`after update a local change: ${this.toJSON()}`);\n }\n }\n }\n\n /**\n * `subscribe` registers a callback to subscribe to events on the document.\n * The callback will be called when the document is changed.\n */\n public subscribe(\n next: DocEventCallbackMap<P>['default'],\n error?: ErrorFn,\n complete?: CompleteFn,\n ): Unsubscribe;\n /**\n * `subscribe` registers a callback to subscribe to events on the document.\n * The callback will be called when the clients watching the document\n * establishe or update its presence.\n */\n public subscribe(\n type: 'presence',\n next: DocEventCallbackMap<P>['presence'],\n error?: ErrorFn,\n complete?: CompleteFn,\n ): Unsubscribe;\n /**\n * `subscribe` registers a callback to subscribe to events on the document.\n * The callback will be called when the current client establishes or updates its presence.\n */\n public subscribe(\n type: 'my-presence',\n next: DocEventCallbackMap<P>['my-presence'],\n error?: ErrorFn,\n complete?: CompleteFn,\n ): Unsubscribe;\n /**\n * `subscribe` registers a callback to subscribe to events on the document.\n * The callback will be called when the client establishes or terminates a connection,\n * or updates its presence.\n */\n public subscribe(\n type: 'others',\n next: DocEventCallbackMap<P>['others'],\n error?: ErrorFn,\n complete?: CompleteFn,\n ): Unsubscribe;\n /**\n * `subscribe` registers a callback to subscribe to events on the document.\n * The callback will be called when the stream connection status changes.\n */\n public subscribe(\n type: 'connection',\n next: DocEventCallbackMap<P>['connection'],\n error?: ErrorFn,\n complete?: CompleteFn,\n ): Unsubscribe;\n /**\n * `subscribe` registers a callback to subscribe to events on the document.\n * The callback will be called when the document status changes.\n */\n public subscribe(\n type: 'status',\n next: DocEventCallbackMap<P>['status'],\n error?: ErrorFn,\n complete?: CompleteFn,\n ): Unsubscribe;\n /**\n * `subscribe` registers a callback to subscribe to events on the document.\n * The callback will be called when the document is synced with the server.\n */\n public subscribe(\n type: 'sync',\n next: DocEventCallbackMap<P>['sync'],\n error?: ErrorFn,\n complete?: CompleteFn,\n ): Unsubscribe;\n /**\n * `subscribe` registers a callback to subscribe to events on the document.\n * The callback will be called when the targetPath or any of its nested values change.\n */\n public subscribe<\n TPath extends PathOf<T>,\n TOperationInfo extends OperationInfoOf<T, TPath>,\n >(\n targetPath: TPath,\n next: NextFn<\n LocalChangeEvent<TOperationInfo, P> | RemoteChangeEvent<TOperationInfo, P>\n >,\n error?: ErrorFn,\n complete?: CompleteFn,\n ): Unsubscribe;\n /**\n * `subscribe` registers a callback to subscribe to events on the document.\n * The callback will be called when the broadcast event is received from the remote client.\n */\n public subscribe(\n type: 'broadcast',\n next: DocEventCallbackMap<P>['broadcast'],\n error?: ErrorFn,\n ): Unsubscribe;\n /**\n * `subscribe` registers a callback to subscribe to events on the document.\n * The callback will be called when the local client sends a broadcast event.\n */\n public subscribe(\n type: 'local-broadcast',\n next: DocEventCallbackMap<P>['local-broadcast'],\n error?: ErrorFn,\n ): Unsubscribe;\n /**\n * `subscribe` registers a callback to subscribe to events on the document.\n * The callback will be called when the authentification error occurs.\n */\n public subscribe(\n type: 'auth-error',\n next: DocEventCallbackMap<P>['auth-error'],\n error?: ErrorFn,\n ): Unsubscribe;\n /**\n * `subscribe` registers a callback to subscribe to events on the document.\n */\n public subscribe(\n type: 'all',\n next: DocEventCallbackMap<P>['all'],\n error?: ErrorFn,\n complete?: CompleteFn,\n ): Unsubscribe;\n /**\n * `subscribe` registers a callback to subscribe to events on the document.\n */\n public subscribe<\n TPath extends PathOf<T>,\n TOperationInfo extends OperationInfoOf<T, TPath>,\n >(\n arg1: TPath | DocEventTopic | DocEventCallbackMap<P>['default'],\n arg2?:\n | NextFn<\n | LocalChangeEvent<TOperationInfo, P>\n | RemoteChangeEvent<TOperationInfo, P>\n >\n | DocEventCallback<P>\n | ErrorFn,\n arg3?: ErrorFn | CompleteFn,\n arg4?: CompleteFn,\n ): Unsubscribe {\n if (typeof arg1 === 'string') {\n if (typeof arg2 !== 'function') {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n 'Second argument must be a callback function',\n );\n }\n if (arg1 === 'presence') {\n const callback = arg2 as DocEventCallbackMap<P>['presence'];\n return this.eventStream.subscribe(\n (event) => {\n for (const docEvent of event) {\n if (\n docEvent.type !== DocEventType.Initialized &&\n docEvent.type !== DocEventType.Watched &&\n docEvent.type !== DocEventType.Unwatched &&\n docEvent.type !== DocEventType.PresenceChanged\n ) {\n continue;\n }\n\n callback(docEvent);\n }\n },\n arg3,\n arg4,\n );\n }\n if (arg1 === 'my-presence') {\n const callback = arg2 as DocEventCallbackMap<P>['my-presence'];\n return this.eventStream.subscribe(\n (event) => {\n for (const docEvent of event) {\n if (\n docEvent.type !== DocEventType.Initialized &&\n docEvent.type !== DocEventType.PresenceChanged\n ) {\n continue;\n }\n\n if (\n docEvent.type === DocEventType.PresenceChanged &&\n docEvent.value.clientID !== this.changeID.getActorID()\n ) {\n continue;\n }\n\n callback(docEvent);\n }\n },\n arg3,\n arg4,\n );\n }\n if (arg1 === 'others') {\n const callback = arg2 as DocEventCallbackMap<P>['others'];\n return this.eventStream.subscribe(\n (event) => {\n for (const docEvent of event) {\n if (\n docEvent.type !== DocEventType.Watched &&\n docEvent.type !== DocEventType.Unwatched &&\n docEvent.type !== DocEventType.PresenceChanged\n ) {\n continue;\n }\n\n if (docEvent.value.clientID !== this.changeID.getActorID()) {\n callback(docEvent);\n }\n }\n },\n arg3,\n arg4,\n );\n }\n if (arg1 === 'connection') {\n const callback = arg2 as DocEventCallbackMap<P>['connection'];\n return this.eventStream.subscribe(\n (event) => {\n for (const docEvent of event) {\n if (docEvent.type !== DocEventType.ConnectionChanged) {\n continue;\n }\n callback(docEvent);\n }\n },\n arg3,\n arg4,\n );\n }\n if (arg1 === 'status') {\n const callback = arg2 as DocEventCallbackMap<P>['status'];\n return this.eventStream.subscribe(\n (event) => {\n for (const docEvent of event) {\n if (docEvent.type !== DocEventType.StatusChanged) {\n continue;\n }\n callback(docEvent);\n }\n },\n arg3,\n arg4,\n );\n }\n if (arg1 === 'sync') {\n const callback = arg2 as DocEventCallbackMap<P>['sync'];\n return this.eventStream.subscribe(\n (event) => {\n for (const docEvent of event) {\n if (docEvent.type !== DocEventType.SyncStatusChanged) {\n continue;\n }\n callback(docEvent);\n }\n },\n arg3,\n arg4,\n );\n }\n if (arg1 === 'local-broadcast') {\n const callback = arg2 as DocEventCallbackMap<P>['local-broadcast'];\n return this.eventStream.subscribe((event) => {\n for (const docEvent of event) {\n if (docEvent.type !== DocEventType.LocalBroadcast) {\n continue;\n }\n\n callback(docEvent);\n }\n }, arg3);\n }\n if (arg1 === 'broadcast') {\n const callback = arg2 as DocEventCallbackMap<P>['broadcast'];\n return this.eventStream.subscribe((event) => {\n for (const docEvent of event) {\n if (docEvent.type !== DocEventType.Broadcast) {\n continue;\n }\n\n callback(docEvent);\n }\n }, arg3);\n }\n if (arg1 === 'auth-error') {\n const callback = arg2 as DocEventCallbackMap<P>['auth-error'];\n return this.eventStream.subscribe((event) => {\n for (const docEvent of event) {\n if (docEvent.type !== DocEventType.AuthError) {\n continue;\n }\n\n callback(docEvent);\n }\n }, arg3);\n }\n if (arg1 === 'all') {\n const callback = arg2 as DocEventCallbackMap<P>['all'];\n return this.eventStream.subscribe(callback, arg3, arg4);\n }\n const target = arg1;\n const callback = arg2 as NextFn<\n | LocalChangeEvent<TOperationInfo, P>\n | RemoteChangeEvent<TOperationInfo, P>\n >;\n return this.eventStream.subscribe(\n (event) => {\n for (const docEvent of event) {\n if (\n docEvent.type !== DocEventType.LocalChange &&\n docEvent.type !== DocEventType.RemoteChange\n ) {\n continue;\n }\n\n const targetOps: Array<TOperationInfo> = [];\n for (const op of docEvent.value.operations) {\n if (this.isSameElementOrChildOf(op.path, target)) {\n targetOps.push(op as TOperationInfo);\n }\n }\n targetOps.length &&\n callback({\n ...docEvent,\n value: { ...docEvent.value, operations: targetOps },\n });\n }\n },\n arg3,\n arg4,\n );\n }\n if (typeof arg1 === 'function') {\n const callback = arg1 as DocEventCallbackMap<P>['default'];\n const error = arg2 as ErrorFn;\n const complete = arg3 as CompleteFn;\n return this.eventStream.subscribe(\n (event) => {\n for (const docEvent of event) {\n if (\n docEvent.type !== DocEventType.Snapshot &&\n docEvent.type !== DocEventType.LocalChange &&\n docEvent.type !== DocEventType.RemoteChange\n ) {\n continue;\n }\n\n callback(docEvent);\n }\n },\n error,\n complete,\n );\n }\n\n throw new YorkieError(Code.ErrInvalidArgument, `\"${arg1}\" is not a valid`);\n }\n\n /**\n * `publish` triggers an event in this document, which can be received by\n * callback functions from document.subscribe().\n */\n public publish(event: DocEvents<P>) {\n if (this.eventStreamObserver) {\n this.eventStreamObserver.next(event);\n }\n }\n\n private isSameElementOrChildOf(elem: string, parent: string): boolean {\n if (parent === elem) {\n return true;\n }\n\n const nodePath = elem.split('.');\n const targetPath = parent.split('.');\n return targetPath.every((path, index) => path === nodePath[index]);\n }\n\n /**\n * `removePushedLocalChanges` removes local changes that have been applied to\n * the server from the local changes.\n *\n * @param clientSeq - client sequence number to remove local changes before it\n */\n private removePushedLocalChanges(clientSeq: number) {\n while (this.localChanges.length) {\n const change = this.localChanges[0];\n if (change.getID().getClientSeq() > clientSeq) {\n break;\n }\n this.localChanges.shift();\n }\n }\n\n /**\n * `applyChangePack` applies the given change pack into this document.\n * 1. Remove local changes applied to server.\n * 2. Update the checkpoint.\n * 3. Do Garbage collection.\n *\n * @param pack - change pack\n * @internal\n */\n public applyChangePack(pack: ChangePack<P>): void {\n const hasSnapshot = pack.hasSnapshot();\n\n // 01. Apply snapshot or changes to the root object.\n if (hasSnapshot) {\n this.applySnapshot(\n pack.getCheckpoint().getServerSeq(),\n pack.getVersionVector()!,\n pack.getSnapshot()!,\n pack.getCheckpoint().getClientSeq(),\n );\n } else {\n this.applyChanges(pack.getChanges(), OpSource.Remote);\n this.removePushedLocalChanges(pack.getCheckpoint().getClientSeq());\n }\n\n // 02. Update the checkpoint.\n this.checkpoint = this.checkpoint.forward(pack.getCheckpoint());\n\n // 03. Do Garbage collection.\n if (!hasSnapshot) {\n this.garbageCollect(pack.getVersionVector()!);\n }\n\n // 04. Update the status.\n if (pack.getIsRemoved()) {\n this.applyStatus(DocStatus.Removed);\n }\n\n if (logger.isEnabled(LogLevel.Trivial)) {\n logger.trivial(`${this.root.toJSON()}`);\n }\n }\n\n /**\n * `getCheckpoint` returns the checkpoint of this document.\n *\n * @internal\n */\n public getCheckpoint(): Checkpoint {\n return this.checkpoint;\n }\n\n /**\n * `getChangeID` returns the change id of this document.\n *\n * @internal\n */\n public getChangeID(): ChangeID {\n return this.changeID;\n }\n\n /**\n * `hasLocalChanges` returns whether this document has local changes or not.\n */\n public hasLocalChanges(): boolean {\n return this.localChanges.length > 0;\n }\n\n /**\n * `ensureClone` make a clone of root.\n *\n * @internal\n */\n public ensureClone(): void {\n if (this.clone) {\n return;\n }\n\n this.clone = {\n root: this.root.deepcopy(),\n presences: deepcopy(this.presences),\n };\n }\n\n /**\n * `createChangePack` create change pack of the local changes to send to the\n * remote server.\n *\n * @internal\n */\n public createChangePack(): ChangePack<P> {\n const changes = Array.from(this.localChanges);\n const checkpoint = this.checkpoint.increaseClientSeq(changes.length);\n return ChangePack.create(\n this.key,\n checkpoint,\n false,\n changes,\n this.getVersionVector(),\n );\n }\n\n /**\n * `setActor` sets actor into this document. This is also applied in the local\n * changes the document has.\n *\n * @internal\n */\n public setActor(actorID: ActorID): void {\n for (const change of this.localChanges) {\n change.setActor(actorID);\n }\n this.changeID = this.changeID.setActor(actorID);\n\n // TODO(hackerwins): If the given actorID is not IntialActorID, we need to\n // update InitialActor of the root and clone.\n }\n\n /**\n * `isEnableDevtools` returns whether devtools is enabled or not.\n */\n public isEnableDevtools(): boolean {\n return !!this.opts.enableDevtools;\n }\n\n /**\n * `getKey` returns the key of this document.\n */\n public getKey(): string {\n return this.key;\n }\n\n /**\n * `getStatus` returns the status of this document.\n */\n public getStatus(): DocStatus {\n return this.status;\n }\n\n /**\n * `getClone` return clone object.\n *\n * @internal\n */\n public getCloneRoot(): CRDTObject | undefined {\n if (!this.clone) {\n return;\n }\n\n return this.clone.root.getObject();\n }\n\n /**\n * `getRoot` returns a new proxy of cloned root.\n */\n public getRoot(): JSONObject<T> {\n this.ensureClone();\n\n const context = ChangeContext.create(\n this.changeID.next(),\n this.clone!.root,\n this.clone!.presences.get(this.changeID.getActorID()) || ({} as P),\n );\n return createJSON<T>(context, this.clone!.root.getObject());\n }\n\n /**\n * `garbageCollect` purges elements that were removed before the given time.\n *\n * @internal\n */\n public garbageCollect(minSyncedVersionVector: VersionVector): number {\n if (this.opts.disableGC) {\n return 0;\n }\n\n if (this.clone) {\n this.clone.root.garbageCollect(minSyncedVersionVector);\n }\n return this.root.garbageCollect(minSyncedVersionVector);\n }\n\n /**\n * `getRootObject` returns root object.\n *\n * @internal\n */\n public getRootObject(): CRDTObject {\n return this.root.getObject();\n }\n\n /**\n * `getGarbageLen` returns the length of elements should be purged.\n *\n * @internal\n */\n public getGarbageLen(): number {\n return this.root.getGarbageLen();\n }\n\n /**\n * `getGarbageLenFromClone` returns the length of elements should be purged from clone.\n */\n public getGarbageLenFromClone(): number {\n return this.clone!.root.getGarbageLen();\n }\n\n /**\n * `toJSON` returns the JSON encoding of this document.\n */\n public toJSON(): string {\n return this.root.toJSON();\n }\n\n /**\n * `toSortedJSON` returns the sorted JSON encoding of this document.\n */\n public toSortedJSON(): string {\n return this.root.toSortedJSON();\n }\n\n /**\n * `getStats` returns the statistics of this document.\n */\n public getStats(): RootStats {\n return this.root.getStats();\n }\n\n /**\n * `toJSForTest` returns value with meta data for testing.\n */\n public toJSForTest(): Devtools.JSONElement {\n return {\n ...this.getRoot().toJSForTest!(),\n key: 'root',\n };\n }\n\n /**\n * `applySnapshot` applies the given snapshot into this document.\n */\n public applySnapshot(\n serverSeq: bigint,\n snapshotVector: VersionVector,\n snapshot?: Uint8Array,\n clientSeq: number = -1,\n ) {\n const { root, presences } = converter.bytesToSnapshot<P>(snapshot);\n this.root = new CRDTRoot(root);\n this.presences = presences;\n this.changeID = this.changeID.setClocks(\n snapshotVector.maxLamport(),\n snapshotVector,\n );\n\n // drop clone because it is contaminated.\n this.clone = undefined;\n\n this.removePushedLocalChanges(clientSeq);\n\n // NOTE(hackerwins): If the document has local changes, we need to apply\n // them after applying the snapshot, as local changes are not included in the snapshot data.\n // Afterward, we should publish a snapshot event with the latest\n // version of the document to ensure the user receives the most up-to-date snapshot.\n this.applyChanges(this.localChanges, OpSource.Local);\n this.publish([\n {\n type: DocEventType.Snapshot,\n source: OpSource.Remote,\n value: {\n serverSeq: serverSeq.toString(),\n snapshot: this.isEnableDevtools()\n ? converter.bytesToHex(snapshot)\n : undefined,\n snapshotVector: converter.versionVectorToHex(snapshotVector),\n },\n },\n ]);\n }\n\n /**\n * `applyChanges` applies the given changes into this document.\n */\n public applyChanges(changes: Array<Change<P>>, source: OpSource): void {\n if (logger.isEnabled(LogLevel.Debug)) {\n logger.debug(\n `trying to apply ${changes.length} remote changes.` +\n `elements:${this.root.getElementMapSize()}, ` +\n `removeds:${this.root.getGarbageElementSetSize()}`,\n );\n }\n if (logger.isEnabled(LogLevel.Trivial)) {\n logger.trivial(\n changes\n .map(\n (change) =>\n `${change.getID().toTestString()}\\t${change.toTestString()}`,\n )\n .join('\\n'),\n );\n }\n\n for (const change of changes) {\n this.applyChange(change, source);\n }\n\n if (logger.isEnabled(LogLevel.Debug)) {\n logger.debug(\n `after appling ${changes.length} remote changes.` +\n `elements:${this.root.getElementMapSize()}, ` +\n ` removeds:${this.root.getGarbageElementSetSize()}`,\n );\n }\n }\n\n /**\n * `applyChange` applies the given change into this document.\n */\n public applyChange(change: Change<P>, source: OpSource) {\n this.ensureClone();\n change.execute(this.clone!.root, this.clone!.presences, source);\n\n const event: DocEvents<P> = [];\n const actorID = change.getID().getActorID();\n if (change.hasPresenceChange() && this.onlineClients.has(actorID)) {\n const presenceChange = change.getPresenceChange()!;\n switch (presenceChange.type) {\n case PresenceChangeType.Put:\n // NOTE(chacha912): When the user exists in onlineClients, but\n // their presence was initially absent, we can consider that we have\n // received their initial presence, so trigger the 'watched' event.\n\n event.push(\n this.presences.has(actorID)\n ? {\n type: DocEventType.PresenceChanged,\n source,\n value: {\n clientID: actorID,\n presence: presenceChange.presence,\n },\n }\n : {\n type: DocEventType.Watched,\n source: OpSource.Remote,\n value: {\n clientID: actorID,\n presence: presenceChange.presence,\n },\n },\n );\n break;\n case PresenceChangeType.Clear:\n // NOTE(chacha912): When the user exists in onlineClients, but\n // PresenceChange(clear) is received, we can consider it as detachment\n // occurring before unwatching.\n // Detached user is no longer participating in the document, we remove\n // them from the online clients and trigger the 'unwatched' event.\n event.push({\n type: DocEventType.Unwatched,\n source: OpSource.Remote,\n value: {\n clientID: actorID,\n presence: this.getPresence(actorID)!,\n },\n });\n this.removeOnlineClient(actorID);\n break;\n default:\n break;\n }\n }\n\n const { opInfos } = change.execute(this.root, this.presences, source);\n this.changeID = this.changeID.syncClocks(change.getID());\n if (opInfos.length > 0) {\n const rawChange = this.isEnableDevtools() ? change.toStruct() : undefined;\n event.push(\n source === OpSource.Remote\n ? {\n type: DocEventType.RemoteChange,\n source,\n value: {\n actor: actorID,\n clientSeq: change.getID().getClientSeq(),\n serverSeq: change.getID().getServerSeq(),\n message: change.getMessage() || '',\n operations: opInfos,\n },\n rawChange,\n }\n : {\n type: DocEventType.LocalChange,\n source,\n value: {\n actor: actorID,\n clientSeq: change.getID().getClientSeq(),\n serverSeq: change.getID().getServerSeq(),\n message: change.getMessage() || '',\n operations: opInfos,\n },\n rawChange,\n },\n );\n }\n // DocEvent should be emitted synchronously with applying changes.\n // This is because 3rd party model should be synced with the Document\n // after RemoteChange event is emitted. If the event is emitted\n // asynchronously, the model can be changed and breaking consistency.\n if (event.length > 0) {\n this.publish(event);\n }\n }\n\n /**\n * `applyWatchStream` applies the given watch stream response into this document.\n */\n public applyWatchStream(resp: WatchDocumentResponse) {\n if (resp.body.case === 'initialization') {\n const clientIDs = resp.body.value.clientIds;\n const onlineClients: Set<ActorID> = new Set();\n for (const clientID of clientIDs) {\n if (clientID === this.changeID.getActorID()) {\n continue;\n }\n onlineClients.add(clientID);\n }\n this.setOnlineClients(onlineClients);\n\n this.publish([\n {\n type: DocEventType.Initialized,\n source: OpSource.Local,\n value: this.getPresences(),\n },\n ]);\n return;\n }\n\n if (resp.body.case === 'event') {\n const { type, publisher } = resp.body.value;\n const event: Array<WatchedEvent<P> | UnwatchedEvent<P> | BroadcastEvent> =\n [];\n if (type === PbDocEventType.DOCUMENT_WATCHED) {\n if (this.onlineClients.has(publisher) && this.hasPresence(publisher)) {\n return;\n }\n\n this.addOnlineClient(publisher);\n // NOTE(chacha912): We added to onlineClients, but we won't trigger watched event\n // unless we also know their initial presence data at this point.\n if (this.hasPresence(publisher)) {\n event.push({\n type: DocEventType.Watched,\n source: OpSource.Remote,\n value: {\n clientID: publisher,\n presence: this.getPresence(publisher)!,\n },\n });\n }\n } else if (type === PbDocEventType.DOCUMENT_UNWATCHED) {\n const presence = this.getPresence(publisher);\n this.removeOnlineClient(publisher);\n // NOTE(chacha912): There is no presence, when PresenceChange(clear) is applied before unwatching.\n // In that case, the 'unwatched' event is triggered while handling the PresenceChange.\n if (presence) {\n event.push({\n type: DocEventType.Unwatched,\n source: OpSource.Remote,\n value: { clientID: publisher, presence },\n });\n }\n } else if (type === PbDocEventType.DOCUMENT_BROADCAST) {\n if (resp.body.value.body) {\n const { topic, payload } = resp.body.value.body;\n const decoder = new TextDecoder();\n\n event.push({\n type: DocEventType.Broadcast,\n value: {\n clientID: publisher,\n topic,\n payload: JSON.parse(decoder.decode(payload)),\n },\n });\n }\n }\n\n if (event.length > 0) {\n this.publish(event);\n }\n }\n }\n\n /**\n * `applyStatus` applies the document status into this document.\n */\n public applyStatus(status: DocStatus) {\n this.status = status;\n\n if (status === DocStatus.Detached) {\n this.setActor(InitialActorID);\n }\n\n this.publish([\n {\n source: status === DocStatus.Removed ? OpSource.Remote : OpSource.Local,\n type: DocEventType.StatusChanged,\n value:\n status === DocStatus.Attached\n ? { status, actorID: this.changeID.getActorID() }\n : { status },\n },\n ]);\n }\n\n /**\n * `applyDocEventForReplay` applies the given event into this document.\n */\n public applyDocEventForReplay(event: Devtools.DocEventForReplay<P>) {\n if (event.type === DocEventType.StatusChanged) {\n this.applyStatus(event.value.status);\n if (event.value.status === DocStatus.Attached) {\n this.setActor(event.value.actorID);\n }\n return;\n }\n\n if (event.type === DocEventType.Snapshot) {\n const { snapshot, serverSeq, snapshotVector } = event.value;\n if (!snapshot) return;\n\n // TODO(hackerwins): We need to check version vector and lamport clock\n // of the snapshot is valid.\n this.applySnapshot(\n BigInt(serverSeq),\n converter.hexToVersionVector(snapshotVector),\n converter.hexToBytes(snapshot),\n );\n return;\n }\n\n if (\n event.type === DocEventType.LocalChange ||\n event.type === DocEventType.RemoteChange\n ) {\n if (!event.rawChange) return;\n const change = Change.fromStruct<P>(event.rawChange);\n this.applyChange(change, event.source);\n }\n\n if (event.type === DocEventType.Initialized) {\n const onlineClients: Set<ActorID> = new Set();\n for (const { clientID, presence } of event.value) {\n onlineClients.add(clientID);\n this.presences.set(clientID, presence);\n }\n this.setOnlineClients(onlineClients);\n return;\n }\n\n if (event.type === DocEventType.Watched) {\n const { clientID, presence } = event.value;\n this.addOnlineClient(clientID);\n this.presences.set(clientID, presence);\n return;\n }\n\n if (event.type === DocEventType.Unwatched) {\n const { clientID } = event.value;\n this.removeOnlineClient(clientID);\n this.presences.delete(clientID);\n }\n\n if (event.type === DocEventType.PresenceChanged) {\n const { clientID, presence } = event.value;\n this.presences.set(clientID, presence);\n }\n }\n\n /**\n * `applyDocEventsForReplay` applies the given events into this document.\n */\n public applyDocEventsForReplay(event: Array<Devtools.DocEventForReplay<P>>) {\n for (const docEvent of event) {\n this.applyDocEventForReplay(docEvent);\n }\n }\n\n /**\n * `getValueByPath` returns the JSONElement corresponding to the given path.\n */\n public getValueByPath(path: string): JSONElement | undefined {\n if (!path.startsWith('$')) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n `path must start with \"$\"`,\n );\n }\n const pathArr = path.split('.');\n pathArr.shift();\n let value: JSONObject<any> = this.getRoot();\n for (const key of pathArr) {\n value = value[key];\n if (value === undefined) return undefined;\n }\n return value;\n }\n\n /**\n * `setOnlineClients` sets the given online client set.\n *\n * @internal\n */\n public setOnlineClients(onlineClients: Set<ActorID>) {\n this.onlineClients = onlineClients;\n }\n\n /**\n * `resetOnlineClients` resets the online client set.\n *\n * @internal\n */\n public resetOnlineClients() {\n this.onlineClients = new Set();\n }\n\n /**\n * `addOnlineClient` adds the given clientID into the online client set.\n *\n * @internal\n */\n public addOnlineClient(clientID: ActorID) {\n this.onlineClients.add(clientID);\n }\n\n /**\n * `removeOnlineClient` removes the clientID from the online client set.\n *\n * @internal\n */\n public removeOnlineClient(clientID: ActorID) {\n this.onlineClients.delete(clientID);\n }\n\n /**\n * `hasPresence` returns whether the given clientID has a presence or not.\n *\n * @internal\n */\n public hasPresence(clientID: ActorID): boolean {\n return this.presences.has(clientID);\n }\n\n /**\n * `getMyPresence` returns the presence of the current client.\n */\n public getMyPresence(): P {\n // TODO(chacha912): After resolving the presence initialization issue,\n // remove default presence.(#608)\n if (this.status !== DocStatus.Attached) {\n return {} as P;\n }\n\n const p = this.presences.get(this.changeID.getActorID())!;\n return p ? deepcopy(p) : ({} as P);\n }\n\n /**\n * `getPresence` returns the presence of the given clientID.\n */\n public getPresence(clientID: ActorID): P | undefined {\n if (clientID === this.changeID.getActorID()) {\n return this.getMyPresence();\n }\n\n if (!this.onlineClients.has(clientID)) return;\n const p = this.presences.get(clientID);\n return p ? deepcopy(p) : undefined;\n }\n\n /**\n * `getPresenceForTest` returns the presence of the given clientID\n * regardless of whether the client is online or not.\n *\n * @internal\n */\n public getPresenceForTest(clientID: ActorID): P | undefined {\n const p = this.presences.get(clientID);\n return p ? deepcopy(p) : undefined;\n }\n\n /**\n * `getPresences` returns the presences of online clients.\n */\n public getPresences(): Array<{ clientID: ActorID; presence: P }> {\n const presences: Array<{ clientID: ActorID; presence: P }> = [];\n presences.push({\n clientID: this.changeID.getActorID(),\n presence: deepcopy(this.getMyPresence()),\n });\n\n for (const clientID of this.onlineClients) {\n if (this.presences.has(clientID)) {\n presences.push({\n clientID,\n presence: deepcopy(this.presences.get(clientID)!),\n });\n }\n }\n return presences;\n }\n\n /**\n * `getSelfForTest` returns the client that has attached this document.\n *\n * @internal\n */\n public getSelfForTest() {\n return {\n clientID: this.getChangeID().getActorID(),\n presence: this.getMyPresence(),\n };\n }\n\n /**\n * `getOthersForTest` returns all the other clients in online, sorted by clientID.\n *\n * @internal\n */\n public getOthersForTest() {\n const myClientID = this.getChangeID().getActorID();\n\n return this.getPresences()\n .filter((a) => a.clientID !== myClientID)\n .sort((a, b) => (a.clientID > b.clientID ? 1 : -1));\n }\n\n /**\n * `canUndo` returns whether there are any operations to undo.\n */\n private canUndo(): boolean {\n return this.internalHistory.hasUndo() && !this.isUpdating;\n }\n\n /**\n * 'filterVersionVector' filters detached client's lamport from version vector.\n */\n private filterVersionVector(minSyncedVersionVector: VersionVector) {\n const versionVector = this.changeID.getVersionVector();\n const filteredVersionVector = versionVector.filter(minSyncedVersionVector);\n\n this.changeID = this.changeID.setVersionVector(filteredVersionVector);\n }\n /**\n * `canRedo` returns whether there are any operations to redo.\n */\n private canRedo(): boolean {\n return this.internalHistory.hasRedo() && !this.isUpdating;\n }\n\n /**\n * `undo` undoes the last operation executed by the current client.\n * It does not impact operations made by other clients.\n */\n private undo(): void {\n if (this.isUpdating) {\n throw new YorkieError(\n Code.ErrRefused,\n 'Undo is not allowed during an update',\n );\n }\n const undoOps = this.internalHistory.popUndo();\n if (undoOps === undefined) {\n throw new YorkieError(\n Code.ErrRefused,\n 'There is no operation to be undone',\n );\n }\n\n this.ensureClone();\n // TODO(chacha912): After resolving the presence initialization issue,\n // remove default presence.(#608)\n const context = ChangeContext.create<P>(\n this.changeID.next(),\n this.clone!.root,\n this.clone!.presences.get(this.changeID.getActorID()) || ({} as P),\n );\n\n // apply undo operation in the context to generate a change\n for (const undoOp of undoOps) {\n if (!(undoOp instanceof Operation)) {\n // apply presence change to the context\n const presence = new Presence<P>(\n context,\n deepcopy(this.clone!.presences.get(this.changeID.getActorID())!),\n );\n presence.set(undoOp.value, { addToHistory: true });\n continue;\n }\n const ticket = context.issueTimeTicket();\n undoOp.setExecutedAt(ticket);\n context.push(undoOp);\n }\n\n const change = context.getChange();\n change.execute(this.clone!.root, this.clone!.presences, OpSource.UndoRedo);\n\n const { opInfos, reverseOps } = change.execute(\n this.root,\n this.presences,\n OpSource.UndoRedo,\n );\n const reversePresence = context.getReversePresence();\n if (reversePresence) {\n reverseOps.push({\n type: 'presence',\n value: reversePresence,\n });\n }\n if (reverseOps.length > 0) {\n this.internalHistory.pushRedo(reverseOps);\n }\n\n // NOTE(chacha912): When there is no applied operation or presence\n // during undo/redo, skip propagating change remotely.\n if (!change.hasPresenceChange() && opInfos.length === 0) {\n return;\n }\n\n this.localChanges.push(change);\n this.changeID = change.getID();\n const actorID = this.changeID.getActorID();\n const event: DocEvents<P> = [];\n if (opInfos.length > 0) {\n event.push({\n type: DocEventType.LocalChange,\n source: OpSource.UndoRedo,\n value: {\n message: change.getMessage() || '',\n operations: opInfos,\n actor: actorID,\n clientSeq: change.getID().getClientSeq(),\n serverSeq: change.getID().getServerSeq(),\n },\n rawChange: this.isEnableDevtools() ? change.toStruct() : undefined,\n });\n }\n if (change.hasPresenceChange()) {\n event.push({\n type: DocEventType.PresenceChanged,\n source: OpSource.UndoRedo,\n value: {\n clientID: actorID,\n presence: this.getPresence(actorID)!,\n },\n });\n }\n this.publish(event);\n }\n\n /**\n * `redo` redoes the last operation executed by the current client.\n * It does not impact operations made by other clients.\n */\n private redo(): void {\n if (this.isUpdating) {\n throw new YorkieError(\n Code.ErrRefused,\n 'Redo is not allowed during an update',\n );\n }\n\n const redoOps = this.internalHistory.popRedo();\n if (redoOps === undefined) {\n throw new YorkieError(\n Code.ErrRefused,\n 'There is no operation to be redone',\n );\n }\n\n this.ensureClone();\n const context = ChangeContext.create<P>(\n this.changeID.next(),\n this.clone!.root,\n this.clone!.presences.get(this.changeID.getActorID()) || ({} as P),\n );\n\n // apply redo operation in the context to generate a change\n for (const redoOp of redoOps) {\n if (!(redoOp instanceof Operation)) {\n // apply presence change to the context\n const presence = new Presence<P>(\n context,\n deepcopy(this.clone!.presences.get(this.changeID.getActorID())!),\n );\n presence.set(redoOp.value, { addToHistory: true });\n continue;\n }\n const ticket = context.issueTimeTicket();\n redoOp.setExecutedAt(ticket);\n context.push(redoOp);\n }\n\n const change = context.getChange();\n change.execute(this.clone!.root, this.clone!.presences, OpSource.UndoRedo);\n\n const { opInfos, reverseOps } = change.execute(\n this.root,\n this.presences,\n OpSource.UndoRedo,\n );\n const reversePresence = context.getReversePresence();\n if (reversePresence) {\n reverseOps.push({\n type: 'presence',\n value: reversePresence,\n });\n }\n if (reverseOps.length > 0) {\n this.internalHistory.pushUndo(reverseOps);\n }\n\n // NOTE(chacha912): When there is no applied operation or presence\n // during undo/redo, skip propagating change remotely.\n if (!change.hasPresenceChange() && opInfos.length === 0) {\n return;\n }\n\n this.localChanges.push(change);\n this.changeID = change.getID();\n const actorID = this.changeID.getActorID();\n const event: DocEvents<P> = [];\n if (opInfos.length > 0) {\n event.push({\n type: DocEventType.LocalChange,\n source: OpSource.UndoRedo,\n value: {\n message: change.getMessage() || '',\n operations: opInfos,\n actor: actorID,\n clientSeq: change.getID().getClientSeq(),\n serverSeq: change.getID().getServerSeq(),\n },\n rawChange: this.isEnableDevtools() ? change.toStruct() : undefined,\n });\n }\n if (change.hasPresenceChange()) {\n event.push({\n type: DocEventType.PresenceChanged,\n source: OpSource.UndoRedo,\n value: {\n clientID: actorID,\n presence: this.getPresence(actorID)!,\n },\n });\n }\n this.publish(event);\n }\n\n /**\n * `getUndoStackForTest` returns the undo stack for test.\n */\n public getUndoStackForTest(): Array<Array<HistoryOperation<P>>> {\n return this.internalHistory.getUndoStackForTest();\n }\n\n /**\n * `getRedoStackForTest` returns the redo stack for test.\n */\n public getRedoStackForTest(): Array<Array<HistoryOperation<P>>> {\n return this.internalHistory.getRedoStackForTest();\n }\n\n /**\n * `broadcast` the payload to the given topic.\n */\n public broadcast(topic: string, payload: Json, options?: BroadcastOptions) {\n const broadcastEvent: LocalBroadcastEvent = {\n type: DocEventType.LocalBroadcast,\n value: { topic, payload },\n options,\n };\n\n this.publish([broadcastEvent]);\n }\n\n /**\n * `getVersionVector` returns the version vector of document\n */\n public getVersionVector() {\n return this.changeID.getVersionVector();\n }\n}\n","/*\n * Copyright 2021 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Interceptor } from '@connectrpc/connect';\n\n/**\n * `createAuthInterceptor` creates an interceptor to add the Authorization header for each\n * request.\n */\nexport function createAuthInterceptor(\n apiKey?: string,\n token?: string,\n): {\n authInterceptor: Interceptor;\n setToken: (token: string) => void;\n} {\n let currentToken = token;\n\n const setToken = (token: string) => {\n currentToken = token;\n };\n\n const authInterceptor: Interceptor = (next) => async (req) => {\n if (apiKey) {\n req.header.set('x-api-key', apiKey);\n }\n if (currentToken) {\n req.header.set('authorization', currentToken);\n }\n return await next(req);\n };\n\n return {\n authInterceptor,\n setToken,\n };\n}\n","/*\n * Copyright 2021 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport pkg from '../../package.json';\nimport { Interceptor } from '@connectrpc/connect';\n\n/**\n * `createMetricInterceptor` creates an interceptor to add the x-yorkie-user-agent header for each\n * request.\n */\nexport function createMetricInterceptor(): Interceptor {\n return (next) => async (req) => {\n req.header.set('x-yorkie-user-agent', pkg.name + '/' + pkg.version);\n return await next(req);\n };\n}\n","/*\n * Copyright 2024 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * `validateSerializable` returns whether the given value is serializable or not.\n */\nexport const validateSerializable = (value: unknown): boolean => {\n try {\n const serialized = JSON.stringify(value);\n\n if (serialized === undefined) {\n return false;\n }\n } catch (error) {\n return false;\n }\n return true;\n};\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ActorID } from '@yorkie-js-sdk/src/document/time/actor_id';\nimport {\n createPromiseClient,\n PromiseClient,\n ConnectError,\n Code as ConnectErrorCode,\n} from '@connectrpc/connect';\nimport { createGrpcWebTransport } from '@connectrpc/connect-web';\nimport { YorkieService } from '@yorkie-js-sdk/src/api/yorkie/v1/yorkie_connect';\nimport { WatchDocumentResponse } from '@yorkie-js-sdk/src/api/yorkie/v1/yorkie_pb';\nimport { DocEventType as PbDocEventType } from '@yorkie-js-sdk/src/api/yorkie/v1/resources_pb';\nimport {\n converter,\n errorCodeOf,\n errorMetadataOf,\n} from '@yorkie-js-sdk/src/api/converter';\nimport { Code, YorkieError } from '@yorkie-js-sdk/src/util/error';\nimport { logger } from '@yorkie-js-sdk/src/util/logger';\nimport { uuid } from '@yorkie-js-sdk/src/util/uuid';\nimport { Attachment, WatchStream } from '@yorkie-js-sdk/src/client/attachment';\nimport {\n Document,\n DocKey,\n DocStatus,\n Indexable,\n DocEventType,\n StreamConnectionStatus,\n DocSyncStatus,\n} from '@yorkie-js-sdk/src/document/document';\nimport { OpSource } from '@yorkie-js-sdk/src/document/operation/operation';\nimport { createAuthInterceptor } from '@yorkie-js-sdk/src/client/auth_interceptor';\nimport { createMetricInterceptor } from '@yorkie-js-sdk/src/client/metric_interceptor';\nimport { validateSerializable } from '../util/validator';\nimport { Json, BroadcastOptions } from '@yorkie-js-sdk/src/document/document';\n\n/**\n * `SyncMode` defines synchronization modes for the PushPullChanges API.\n * @public\n */\nexport enum SyncMode {\n /**\n * `Manual` mode indicates that changes are not automatically pushed or pulled.\n */\n Manual = 'manual',\n\n /**\n * `Realtime` mode indicates that changes are automatically pushed and pulled.\n */\n Realtime = 'realtime',\n\n /**\n * `RealtimePushOnly` mode indicates that only local changes are automatically pushed.\n */\n RealtimePushOnly = 'realtime-pushonly',\n\n /**\n * `RealtimeSyncOff` mode indicates that changes are not automatically pushed or pulled,\n * but the watch stream is kept active.\n */\n RealtimeSyncOff = 'realtime-syncoff',\n}\n\n/**\n * `ClientStatus` represents the status of the client.\n * @public\n */\nexport enum ClientStatus {\n /**\n * `Deactivated` means that the client is not activated. It is the initial\n * status of the client. If the client is deactivated, all `Document`s of the\n * client are also not used.\n */\n Deactivated = 'deactivated',\n\n /**\n * `Activated` means that the client is activated. If the client is activated,\n * all `Document`s of the client are also ready to be used.\n */\n Activated = 'activated',\n}\n\n/**\n * `ClientCondition` represents the condition of the client.\n */\nexport enum ClientCondition {\n /**\n * `SyncLoop` is a key of the sync loop condition.\n */\n SyncLoop = 'SyncLoop',\n\n /**\n * `WatchLoop` is a key of the watch loop condition.\n */\n WatchLoop = 'WatchLoop',\n}\n\n/**\n * `ClientOptions` are user-settable options used when defining clients.\n *\n * @public\n */\nexport interface ClientOptions {\n /**\n * `key` is the client key. It is used to identify the client.\n * If not set, a random key is generated.\n */\n key?: string;\n\n /**\n * `apiKey` is the API key of the project. It is used to identify the project.\n * If not set, API key of the default project is used.\n */\n apiKey?: string;\n\n /**\n * `metadata` is the metadata of the client. It is used to store additional\n * information about the client.\n */\n metadata?: Record<string, string>;\n\n /**\n * `authTokenInjector` is a function that provides a token for the auth webhook.\n * When the webhook response status code is 401, this function is called to refresh the token.\n * The `reason` parameter is the reason from the webhook response.\n */\n authTokenInjector?: (reason?: string) => Promise<string>;\n\n /**\n * `syncLoopDuration` is the duration of the sync loop. After each sync loop,\n * the client waits for the duration to next sync. The default value is\n * `50`(ms).\n */\n syncLoopDuration?: number;\n\n /**\n * `retrySyncLoopDelay` is the delay of the retry sync loop. If the sync loop\n * fails, the client waits for the delay to retry the sync loop. The default\n * value is `1000`(ms).\n */\n retrySyncLoopDelay?: number;\n\n /**\n * `reconnectStreamDelay` is the delay of the reconnect stream. If the stream\n * is disconnected, the client waits for the delay to reconnect the stream. The\n * default value is `1000`(ms).\n */\n reconnectStreamDelay?: number;\n}\n\n/**\n * `DefaultClientOptions` is the default options for Client.\n */\nconst DefaultClientOptions = {\n syncLoopDuration: 50,\n retrySyncLoopDelay: 1000,\n reconnectStreamDelay: 1000,\n};\n\n/**\n * `DefaultBroadcastOptions` is the default options for broadcast.\n */\nconst DefaultBroadcastOptions = {\n maxRetries: Infinity,\n initialRetryInterval: 1000,\n maxBackoff: 20000,\n};\n\n/**\n * `Client` is a normal client that can communicate with the server.\n * It has documents and sends changes of the documents in local\n * to the server to synchronize with other replicas in remote.\n *\n * @public\n */\nexport class Client {\n private id?: ActorID;\n private key: string;\n private metadata: Record<string, string>;\n private status: ClientStatus;\n private attachmentMap: Map<DocKey, Attachment<unknown, any>>;\n\n private apiKey: string;\n private authTokenInjector?: (reason?: string) => Promise<string>;\n private conditions: Record<ClientCondition, boolean>;\n private syncLoopDuration: number;\n private reconnectStreamDelay: number;\n private retrySyncLoopDelay: number;\n\n private rpcClient: PromiseClient<typeof YorkieService>;\n private setAuthToken: (token: string) => void;\n private taskQueue: Array<() => Promise<any>>;\n private processing = false;\n private keepalive = false;\n\n /**\n * @param rpcAddr - the address of the RPC server.\n * @param opts - the options of the client.\n */\n constructor(rpcAddr: string, opts?: ClientOptions) {\n opts = opts || DefaultClientOptions;\n\n this.key = opts.key ? opts.key : uuid();\n this.metadata = opts.metadata || {};\n this.status = ClientStatus.Deactivated;\n this.attachmentMap = new Map();\n\n // TODO(hackerwins): Consider to group the options as a single object.\n this.apiKey = opts.apiKey || '';\n this.authTokenInjector = opts.authTokenInjector;\n this.conditions = {\n [ClientCondition.SyncLoop]: false,\n [ClientCondition.WatchLoop]: false,\n };\n this.syncLoopDuration =\n opts.syncLoopDuration ?? DefaultClientOptions.syncLoopDuration;\n this.reconnectStreamDelay =\n opts.reconnectStreamDelay ?? DefaultClientOptions.reconnectStreamDelay;\n this.retrySyncLoopDelay =\n opts.retrySyncLoopDelay ?? DefaultClientOptions.retrySyncLoopDelay;\n\n const { authInterceptor, setToken } = createAuthInterceptor(this.apiKey);\n this.setAuthToken = setToken;\n\n // Here we make the client itself, combining the service\n // definition with the transport.\n this.rpcClient = createPromiseClient(\n YorkieService,\n createGrpcWebTransport({\n baseUrl: rpcAddr,\n interceptors: [authInterceptor, createMetricInterceptor()],\n fetch: (input, init) => {\n const newInit = {\n ...init,\n keepalive: this.keepalive,\n };\n\n return fetch(input as RequestInfo, newInit);\n },\n }),\n );\n this.taskQueue = [];\n }\n\n /**\n * `activate` activates this client. That is, it registers itself to the server\n * and receives a unique ID from the server. The given ID is used to\n * distinguish different clients.\n */\n public async activate(): Promise<void> {\n if (this.isActive()) {\n return Promise.resolve();\n }\n\n if (this.authTokenInjector) {\n const token = await this.authTokenInjector();\n this.setAuthToken(token);\n }\n\n return this.enqueueTask(async () => {\n return this.rpcClient\n .activateClient(\n {\n clientKey: this.key,\n metadata: this.metadata,\n },\n { headers: { 'x-shard-key': this.apiKey } },\n )\n .then((res) => {\n this.id = res.clientId;\n this.status = ClientStatus.Activated;\n this.runSyncLoop();\n\n logger.info(`[AC] c:\"${this.getKey()}\" activated, id:\"${this.id}\"`);\n })\n .catch(async (err) => {\n logger.error(`[AC] c:\"${this.getKey()}\" err :`, err);\n await this.handleConnectError(err);\n throw err;\n });\n });\n }\n\n /**\n * `deactivate` deactivates this client.\n *\n * @param options - If keepalive is true, the client will request deactivation\n * immediately using `fetch` with the `keepalive` option enabled. This is\n * useful for ensuring the deactivation request completes even if the page is\n * being unloaded, such as in `beforeunload` or `unload` event listeners.\n */\n public deactivate(options = { keepalive: false }): Promise<void> {\n if (this.status === ClientStatus.Deactivated) {\n return Promise.resolve();\n }\n\n const task = async () => {\n try {\n await this.rpcClient.deactivateClient(\n { clientId: this.id! },\n { headers: { 'x-shard-key': this.apiKey } },\n );\n this.deactivateInternal();\n logger.info(`[DC] c\"${this.getKey()}\" deactivated`);\n } catch (err) {\n logger.error(`[DC] c:\"${this.getKey()}\" err :`, err);\n await this.handleConnectError(err);\n throw err;\n }\n };\n\n if (options.keepalive) {\n this.keepalive = true;\n const resp = task();\n this.keepalive = false;\n return resp;\n }\n\n return this.enqueueTask(task);\n }\n\n /**\n * `attach` attaches the given document to this client. It tells the server that\n * this client will synchronize the given document.\n */\n public attach<T, P extends Indexable>(\n doc: Document<T, P>,\n options: {\n initialRoot?: T;\n initialPresence?: P;\n syncMode?: SyncMode;\n } = {},\n ): Promise<Document<T, P>> {\n if (!this.isActive()) {\n throw new YorkieError(\n Code.ErrClientNotActivated,\n `${this.key} is not active`,\n );\n }\n if (doc.getStatus() !== DocStatus.Detached) {\n throw new YorkieError(\n Code.ErrDocumentNotDetached,\n `${doc.getKey()} is not detached`,\n );\n }\n doc.setActor(this.id!);\n doc.update((_, p) => p.set(options.initialPresence || {}));\n const unsubscribeBroacastEvent = doc.subscribe(\n 'local-broadcast',\n async (event) => {\n const { topic, payload } = event.value;\n const errorFn = event.options?.error;\n const options = event.options;\n\n try {\n await this.broadcast(doc.getKey(), topic, payload, options);\n } catch (error: unknown) {\n if (error instanceof Error) {\n errorFn?.(error);\n }\n }\n },\n );\n\n const syncMode = options.syncMode ?? SyncMode.Realtime;\n return this.enqueueTask(async () => {\n return this.rpcClient\n .attachDocument(\n {\n clientId: this.id!,\n changePack: converter.toChangePack(doc.createChangePack()),\n },\n { headers: { 'x-shard-key': `${this.apiKey}/${doc.getKey()}` } },\n )\n .then(async (res) => {\n const pack = converter.fromChangePack<P>(res.changePack!);\n doc.applyChangePack(pack);\n if (doc.getStatus() === DocStatus.Removed) {\n return doc;\n }\n\n doc.applyStatus(DocStatus.Attached);\n this.attachmentMap.set(\n doc.getKey(),\n new Attachment(\n this.reconnectStreamDelay,\n doc,\n res.documentId,\n syncMode,\n unsubscribeBroacastEvent,\n ),\n );\n\n if (syncMode !== SyncMode.Manual) {\n await this.runWatchLoop(doc.getKey());\n }\n\n logger.info(`[AD] c:\"${this.getKey()}\" attaches d:\"${doc.getKey()}\"`);\n\n const crdtObject = doc.getRootObject();\n if (options.initialRoot) {\n const initialRoot = options.initialRoot;\n doc.update((root) => {\n for (const [k, v] of Object.entries(initialRoot)) {\n if (!crdtObject.has(k)) {\n const key = k as keyof T;\n root[key] = v as any;\n }\n }\n });\n }\n\n return doc;\n })\n .catch(async (err) => {\n logger.error(`[AD] c:\"${this.getKey()}\" err :`, err);\n await this.handleConnectError(err);\n throw err;\n });\n });\n }\n\n /**\n * `detach` detaches the given document from this client. It tells the\n * server that this client will no longer synchronize the given document.\n *\n * To collect garbage things like CRDT tombstones left on the document, all\n * the changes should be applied to other replicas before GC time. For this,\n * if the document is no longer used by this client, it should be detached.\n */\n public detach<T, P extends Indexable>(\n doc: Document<T, P>,\n options: {\n removeIfNotAttached?: boolean;\n } = {},\n ): Promise<Document<T, P>> {\n if (!this.isActive()) {\n throw new YorkieError(\n Code.ErrClientNotActivated,\n `${this.key} is not active`,\n );\n }\n const attachment = this.attachmentMap.get(doc.getKey());\n if (!attachment) {\n throw new YorkieError(\n Code.ErrDocumentNotAttached,\n `${doc.getKey()} is not attached`,\n );\n }\n doc.update((_, p) => p.clear());\n\n return this.enqueueTask(async () => {\n return this.rpcClient\n .detachDocument(\n {\n clientId: this.id!,\n documentId: attachment.docID,\n changePack: converter.toChangePack(doc.createChangePack()),\n removeIfNotAttached: options.removeIfNotAttached ?? false,\n },\n { headers: { 'x-shard-key': `${this.apiKey}/${doc.getKey()}` } },\n )\n .then((res) => {\n const pack = converter.fromChangePack<P>(res.changePack!);\n doc.applyChangePack(pack);\n if (doc.getStatus() !== DocStatus.Removed) {\n doc.applyStatus(DocStatus.Detached);\n }\n this.detachInternal(doc.getKey());\n\n logger.info(`[DD] c:\"${this.getKey()}\" detaches d:\"${doc.getKey()}\"`);\n return doc;\n })\n .catch(async (err) => {\n logger.error(`[DD] c:\"${this.getKey()}\" err :`, err);\n await this.handleConnectError(err);\n throw err;\n });\n });\n }\n\n /**\n * `changeRealtimeSync` changes the synchronization mode of the given document.\n */\n public async changeSyncMode<T, P extends Indexable>(\n doc: Document<T, P>,\n syncMode: SyncMode,\n ): Promise<Document<T, P>> {\n if (!this.isActive()) {\n throw new YorkieError(\n Code.ErrClientNotActivated,\n `${this.key} is not active`,\n );\n }\n\n const attachment = this.attachmentMap.get(doc.getKey());\n if (!attachment) {\n throw new YorkieError(\n Code.ErrDocumentNotAttached,\n `${doc.getKey()} is not attached`,\n );\n }\n\n const prevSyncMode = attachment.syncMode;\n if (prevSyncMode === syncMode) {\n return doc;\n }\n\n attachment.changeSyncMode(syncMode);\n\n // realtime to manual\n if (syncMode === SyncMode.Manual) {\n attachment.cancelWatchStream();\n return doc;\n }\n\n if (syncMode === SyncMode.Realtime) {\n // NOTE(hackerwins): In non-pushpull mode, the client does not receive change events\n // from the server. Therefore, we need to set `remoteChangeEventReceived` to true\n // to sync the local and remote changes. This has limitations in that unnecessary\n // syncs occur if the client and server do not have any changes.\n attachment.remoteChangeEventReceived = true;\n }\n\n // manual to realtime\n if (prevSyncMode === SyncMode.Manual) {\n await this.runWatchLoop(doc.getKey());\n }\n\n return doc;\n }\n\n /**\n * `sync` pushes local changes of the attached documents to the server and\n * receives changes of the remote replica from the server then apply them to\n * local documents.\n */\n public sync<T, P extends Indexable>(\n doc?: Document<T, P>,\n ): Promise<Array<Document<T, P>>> {\n if (!this.isActive()) {\n throw new YorkieError(\n Code.ErrClientNotActivated,\n `${this.key} is not active`,\n );\n }\n if (doc) {\n // prettier-ignore\n const attachment = this.attachmentMap.get(doc.getKey()) as Attachment<T, P>;\n if (!attachment) {\n throw new YorkieError(\n Code.ErrDocumentNotAttached,\n `${doc.getKey()} is not attached`,\n );\n }\n return this.enqueueTask(async () => {\n return this.syncInternal(attachment, SyncMode.Realtime).catch(\n async (err) => {\n logger.error(`[SY] c:\"${this.getKey()}\" err :`, err);\n await this.handleConnectError(err);\n throw err;\n },\n );\n });\n }\n\n return this.enqueueTask(async () => {\n const promises = [];\n for (const [, attachment] of this.attachmentMap) {\n promises.push(this.syncInternal(attachment, attachment.syncMode));\n }\n return Promise.all(promises).catch(async (err) => {\n logger.error(`[SY] c:\"${this.getKey()}\" err :`, err);\n await this.handleConnectError(err);\n throw err;\n });\n });\n }\n\n /**\n * `remove` removes the given document.\n */\n public remove<T, P extends Indexable>(doc: Document<T, P>): Promise<void> {\n if (!this.isActive()) {\n throw new YorkieError(\n Code.ErrClientNotActivated,\n `${this.key} is not active`,\n );\n }\n const attachment = this.attachmentMap.get(doc.getKey());\n if (!attachment) {\n throw new YorkieError(\n Code.ErrDocumentNotAttached,\n `${doc.getKey()} is not attached`,\n );\n }\n doc.setActor(this.id!);\n\n const pbChangePack = converter.toChangePack(doc.createChangePack());\n pbChangePack.isRemoved = true;\n\n return this.enqueueTask(async () => {\n return this.rpcClient\n .removeDocument(\n {\n clientId: this.id!,\n documentId: attachment.docID,\n changePack: pbChangePack,\n },\n { headers: { 'x-shard-key': `${this.apiKey}/${doc.getKey()}` } },\n )\n .then((res) => {\n const pack = converter.fromChangePack<P>(res.changePack!);\n doc.applyChangePack(pack);\n this.detachInternal(doc.getKey());\n\n logger.info(`[RD] c:\"${this.getKey()}\" removes d:\"${doc.getKey()}\"`);\n })\n .catch(async (err) => {\n logger.error(`[RD] c:\"${this.getKey()}\" err :`, err);\n await this.handleConnectError(err);\n throw err;\n });\n });\n }\n\n /**\n * `getID` returns a ActorID of client.\n */\n public getID(): string | undefined {\n return this.id;\n }\n\n /**\n * `getKey` returns a key of client.\n */\n public getKey(): string {\n return this.key;\n }\n\n /**\n * `isActive` checks if the client is active.\n */\n public isActive(): boolean {\n return this.status === ClientStatus.Activated;\n }\n\n /**\n * `getStatus` returns the status of this client.\n */\n public getStatus(): ClientStatus {\n return this.status;\n }\n\n /**\n * `getCondition` returns the condition of this client.\n */\n public getCondition(condition: ClientCondition): boolean {\n return this.conditions[condition];\n }\n\n /**\n * `broadcast` broadcasts the given payload to the given topic.\n */\n public broadcast(\n docKey: DocKey,\n topic: string,\n payload: Json,\n options?: BroadcastOptions,\n ): Promise<void> {\n if (!this.isActive()) {\n throw new YorkieError(\n Code.ErrClientNotActivated,\n `${this.key} is not active`,\n );\n }\n const attachment = this.attachmentMap.get(docKey);\n if (!attachment) {\n throw new YorkieError(\n Code.ErrDocumentNotAttached,\n `${docKey} is not attached`,\n );\n }\n\n if (!validateSerializable(payload)) {\n throw new YorkieError(\n Code.ErrInvalidArgument,\n 'payload is not serializable',\n );\n }\n\n const maxRetries =\n options?.maxRetries ?? DefaultBroadcastOptions.maxRetries;\n const maxBackoff = DefaultBroadcastOptions.maxBackoff;\n\n let retryCount = 0;\n\n const exponentialBackoff = (retryCount: number) => {\n const retryInterval = Math.min(\n DefaultBroadcastOptions.initialRetryInterval * 2 ** retryCount,\n maxBackoff,\n );\n return retryInterval;\n };\n\n const doLoop = async (): Promise<any> => {\n return this.enqueueTask(async () => {\n return this.rpcClient\n .broadcast(\n {\n clientId: this.id!,\n documentId: attachment.docID,\n topic,\n payload: new TextEncoder().encode(JSON.stringify(payload)),\n },\n { headers: { 'x-shard-key': `${this.apiKey}/${docKey}` } },\n )\n .then(() => {\n logger.info(\n `[BC] c:\"${this.getKey()}\" broadcasts d:\"${docKey}\" t:\"${topic}\"`,\n );\n })\n .catch(async (err) => {\n logger.error(`[BC] c:\"${this.getKey()}\" err:`, err);\n if (await this.handleConnectError(err)) {\n if (\n err instanceof ConnectError &&\n errorCodeOf(err) === Code.ErrUnauthenticated\n ) {\n attachment.doc.publish([\n {\n type: DocEventType.AuthError,\n value: {\n reason: errorMetadataOf(err).reason,\n method: 'Broadcast',\n },\n },\n ]);\n }\n\n if (retryCount < maxRetries) {\n retryCount++;\n setTimeout(() => doLoop(), exponentialBackoff(retryCount - 1));\n logger.info(\n `[BC] c:\"${this.getKey()}\" retry attempt ${retryCount}/${maxRetries}`,\n );\n } else {\n logger.error(\n `[BC] c:\"${this.getKey()}\" exceeded maximum retry attempts`,\n );\n\n // Stop retrying after maxRetries\n throw err;\n }\n } else {\n // Stop retrying if the error is not retryable\n throw err;\n }\n });\n });\n };\n\n return doLoop();\n }\n\n /**\n * `runSyncLoop` runs the sync loop. The sync loop pushes local changes to\n * the server and pulls remote changes from the server.\n */\n private runSyncLoop(): void {\n const doLoop = (): void => {\n if (!this.isActive()) {\n logger.debug(`[SL] c:\"${this.getKey()}\" exit sync loop`);\n this.conditions[ClientCondition.SyncLoop] = false;\n return;\n }\n\n const syncJobs = [];\n for (const [, attachment] of this.attachmentMap) {\n if (attachment.needRealtimeSync()) {\n attachment.remoteChangeEventReceived = false;\n syncJobs.push(\n this.syncInternal(attachment, attachment.syncMode).catch(\n async (err) => {\n if (\n err instanceof ConnectError &&\n errorCodeOf(err) === Code.ErrUnauthenticated\n ) {\n attachment.doc.publish([\n {\n type: DocEventType.AuthError,\n value: {\n reason: errorMetadataOf(err).reason,\n method: 'PushPull',\n },\n },\n ]);\n }\n throw err;\n },\n ),\n );\n }\n }\n\n Promise.all(syncJobs)\n .then(() => setTimeout(doLoop, this.syncLoopDuration))\n .catch(async (err) => {\n logger.error(`[SL] c:\"${this.getKey()}\" sync failed:`, err);\n if (await this.handleConnectError(err)) {\n setTimeout(doLoop, this.retrySyncLoopDelay);\n } else {\n this.conditions[ClientCondition.SyncLoop] = false;\n }\n });\n };\n\n logger.debug(`[SL] c:\"${this.getKey()}\" run sync loop`);\n this.conditions[ClientCondition.SyncLoop] = true;\n doLoop();\n }\n\n /**\n * `runWatchLoop` runs the watch loop for the given document. The watch loop\n * listens to the events of the given document from the server.\n */\n private async runWatchLoop(docKey: DocKey): Promise<void> {\n const attachment = this.attachmentMap.get(docKey);\n if (!attachment) {\n throw new YorkieError(\n Code.ErrDocumentNotAttached,\n `${docKey} is not attached`,\n );\n }\n\n this.conditions[ClientCondition.WatchLoop] = true;\n return attachment.runWatchLoop(\n (onDisconnect: () => void): Promise<[WatchStream, AbortController]> => {\n if (!this.isActive()) {\n this.conditions[ClientCondition.WatchLoop] = false;\n return Promise.reject(\n new YorkieError(\n Code.ErrClientNotActivated,\n `${this.key} is not active`,\n ),\n );\n }\n\n const ac = new AbortController();\n const stream = this.rpcClient.watchDocument(\n {\n clientId: this.id!,\n documentId: attachment.docID,\n },\n {\n headers: { 'x-shard-key': `${this.apiKey}/${docKey}` },\n signal: ac.signal,\n },\n );\n\n attachment.doc.publish([\n {\n type: DocEventType.ConnectionChanged,\n value: StreamConnectionStatus.Connected,\n },\n ]);\n logger.info(`[WD] c:\"${this.getKey()}\" watches d:\"${docKey}\"`);\n\n return new Promise((resolve, reject) => {\n const handleStream = async () => {\n try {\n for await (const resp of stream) {\n this.handleWatchDocumentsResponse(attachment, resp);\n\n // NOTE(hackerwins): When the first response is received, we need to\n // resolve the promise to notify that the watch stream is ready.\n if (resp.body.case === 'initialization') {\n resolve([stream, ac]);\n }\n }\n } catch (err) {\n attachment.doc.resetOnlineClients();\n attachment.doc.publish([\n {\n type: DocEventType.Initialized,\n source: OpSource.Local,\n value: attachment.doc.getPresences(),\n },\n ]);\n attachment.doc.publish([\n {\n type: DocEventType.ConnectionChanged,\n value: StreamConnectionStatus.Disconnected,\n },\n ]);\n logger.debug(`[WD] c:\"${this.getKey()}\" unwatches`);\n\n if (await this.handleConnectError(err)) {\n if (\n err instanceof ConnectError &&\n errorCodeOf(err) === Code.ErrUnauthenticated\n ) {\n attachment.doc.publish([\n {\n type: DocEventType.AuthError,\n value: {\n reason: errorMetadataOf(err).reason,\n method: 'WatchDocuments',\n },\n },\n ]);\n }\n onDisconnect();\n } else {\n this.conditions[ClientCondition.WatchLoop] = false;\n }\n\n reject(err);\n }\n };\n\n handleStream();\n });\n },\n );\n }\n\n private handleWatchDocumentsResponse<T, P extends Indexable>(\n attachment: Attachment<T, P>,\n resp: WatchDocumentResponse,\n ) {\n if (\n resp.body.case === 'event' &&\n resp.body.value.type === PbDocEventType.DOCUMENT_CHANGED\n ) {\n attachment.remoteChangeEventReceived = true;\n return;\n }\n\n attachment.doc.applyWatchStream(resp);\n }\n\n private deactivateInternal() {\n this.status = ClientStatus.Deactivated;\n\n for (const [key, attachment] of this.attachmentMap) {\n this.detachInternal(key);\n attachment.doc.applyStatus(DocStatus.Detached);\n }\n }\n\n private detachInternal(docKey: DocKey) {\n // NOTE(hackerwins): If attachment is not found, it means that the document\n // has been already detached by another routine.\n // This can happen when detach or remove is called while the watch loop is\n // running.\n const attachment = this.attachmentMap.get(docKey);\n if (!attachment) {\n return;\n }\n\n attachment.cancelWatchStream();\n attachment.unsubscribeBroadcastEvent();\n this.attachmentMap.delete(docKey);\n }\n\n private syncInternal<T, P extends Indexable>(\n attachment: Attachment<T, P>,\n syncMode: SyncMode,\n ): Promise<Document<T, P>> {\n const { doc, docID } = attachment;\n\n const reqPack = doc.createChangePack();\n return this.rpcClient\n .pushPullChanges(\n {\n clientId: this.id!,\n documentId: docID,\n changePack: converter.toChangePack(reqPack),\n pushOnly: syncMode === SyncMode.RealtimePushOnly,\n },\n { headers: { 'x-shard-key': `${this.apiKey}/${doc.getKey()}` } },\n )\n .then((res) => {\n const respPack = converter.fromChangePack<P>(res.changePack!);\n\n // NOTE(chacha912, hackerwins): If syncLoop already executed with\n // PushPull, ignore the response when the syncMode is PushOnly.\n if (\n respPack.hasChanges() &&\n (attachment.syncMode === SyncMode.RealtimePushOnly ||\n attachment.syncMode === SyncMode.RealtimeSyncOff)\n ) {\n return doc;\n }\n\n doc.applyChangePack(respPack);\n attachment.doc.publish([\n {\n type: DocEventType.SyncStatusChanged,\n value: DocSyncStatus.Synced,\n },\n ]);\n // NOTE(chacha912): If a document has been removed, watchStream should\n // be disconnected to not receive an event for that document.\n if (doc.getStatus() === DocStatus.Removed) {\n this.detachInternal(doc.getKey());\n }\n\n const docKey = doc.getKey();\n const remoteSize = respPack.getChangeSize();\n logger.info(\n `[PP] c:\"${this.getKey()}\" sync d:\"${docKey}\", push:${reqPack.getChangeSize()} pull:${remoteSize} cp:${respPack\n .getCheckpoint()\n .toTestString()}`,\n );\n return doc;\n })\n .catch(async (err) => {\n doc.publish([\n {\n type: DocEventType.SyncStatusChanged,\n value: DocSyncStatus.SyncFailed,\n },\n ]);\n logger.error(`[PP] c:\"${this.getKey()}\" err :`, err);\n throw err;\n });\n }\n\n /**\n * `handleConnectError` handles the given error. If the given error can be\n * retried after handling, it returns true.\n */\n private async handleConnectError(err: any): Promise<boolean> {\n if (!(err instanceof ConnectError)) {\n return false;\n }\n\n // NOTE(hackerwins): These errors are retryable.\n // Connect guide indicates that for error codes like `ResourceExhausted` and\n // `Unavailable`, retries should be attempted following their guidelines.\n // Additionally, `Unknown` and `Canceled` are added separately as it\n // typically occurs when the server is stopped.\n if (\n err.code === ConnectErrorCode.Canceled ||\n err.code === ConnectErrorCode.Unknown ||\n err.code === ConnectErrorCode.ResourceExhausted ||\n err.code === ConnectErrorCode.Unavailable\n ) {\n return true;\n }\n\n // NOTE(chacha912): If the error is `Unauthenticated`, it means that the\n // token is invalid or expired. In this case, the client gets a new token\n // from the `authTokenInjector` and retries the api call.\n if (errorCodeOf(err) === Code.ErrUnauthenticated) {\n if (this.authTokenInjector) {\n const token = await this.authTokenInjector(errorMetadataOf(err).reason);\n this.setAuthToken(token);\n }\n return true;\n }\n\n // NOTE(hackerwins): Some errors should fix the state of the client.\n if (\n errorCodeOf(err) === Code.ErrClientNotActivated ||\n errorCodeOf(err) === Code.ErrClientNotFound\n ) {\n this.deactivateInternal();\n }\n\n return false;\n }\n\n /**\n * `enqueueTask` enqueues the given task to the task queue.\n */\n private enqueueTask(task: () => Promise<any>): Promise<any> {\n return new Promise((resolve, reject) => {\n this.taskQueue.push(() => task().then(resolve).catch(reject));\n\n if (!this.processing) {\n this.processNext();\n }\n });\n }\n\n /**\n * `processNext` processes the next task in the task queue. This method is\n * part of enqueueTask.\n */\n private async processNext() {\n if (this.taskQueue.length === 0) {\n this.processing = false;\n return;\n }\n\n try {\n this.processing = true;\n const task = this.taskQueue.shift()!;\n await task();\n } catch (error) {\n logger.error(`[TQ] c:\"${this.getKey()}\" process failed, id:\"${this.id}\"`);\n }\n\n this.processNext();\n }\n}\n","/*\n * Copyright 2020 The Yorkie Authors. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Client } from '@yorkie-js-sdk/src/client/client';\nimport { Document } from '@yorkie-js-sdk/src/document/document';\nimport { Text } from '@yorkie-js-sdk/src/document/json/text';\nimport { Tree } from '@yorkie-js-sdk/src/document/json/tree';\nimport { Counter } from '@yorkie-js-sdk/src/document/json/counter';\nimport { CounterType } from '@yorkie-js-sdk/src/document/crdt/counter';\nimport * as Devtools from '@yorkie-js-sdk/src/devtools/types';\n\nexport {\n Client,\n ClientStatus,\n ClientCondition,\n SyncMode,\n type ClientOptions,\n} from '@yorkie-js-sdk/src/client/client';\nexport {\n DocEventType,\n type SnapshotEvent,\n type LocalChangeEvent,\n type RemoteChangeEvent,\n type ConnectionChangedEvent,\n type SyncStatusChangedEvent,\n type WatchedEvent,\n type UnwatchedEvent,\n type PresenceChangedEvent,\n type InitializedEvent,\n StreamConnectionStatus,\n DocSyncStatus,\n DocStatus,\n type Indexable,\n type Json,\n type DocEvent,\n type DocEvents,\n Document,\n type ChangeInfo,\n} from '@yorkie-js-sdk/src/document/document';\nexport {\n type Observer,\n type Observable,\n type NextFn,\n type ErrorFn,\n type CompleteFn,\n type Unsubscribe,\n} from '@yorkie-js-sdk/src/util/observable';\nexport {\n TimeTicket,\n type TimeTicketStruct,\n} from '@yorkie-js-sdk/src/document/time/ticket';\nexport { type ActorID } from '@yorkie-js-sdk/src/document/time/actor_id';\nexport { VersionVector } from '@yorkie-js-sdk/src/document/time/version_vector';\nexport type {\n OperationInfo,\n TextOperationInfo,\n CounterOperationInfo,\n ArrayOperationInfo,\n ObjectOperationInfo,\n TreeOperationInfo,\n AddOpInfo,\n IncreaseOpInfo,\n RemoveOpInfo,\n SetOpInfo,\n MoveOpInfo,\n EditOpInfo,\n StyleOpInfo,\n TreeEditOpInfo,\n TreeStyleOpInfo,\n} from '@yorkie-js-sdk/src/document/operation/operation';\nexport { OpSource } from '@yorkie-js-sdk/src/document/operation/operation';\n\nexport {\n Primitive,\n type PrimitiveValue,\n} from '@yorkie-js-sdk/src/document/crdt/primitive';\nimport { Primitive } from '@yorkie-js-sdk/src/document/crdt/primitive';\n\nexport {\n type WrappedElement,\n type JSONElement,\n} from '@yorkie-js-sdk/src/document/json/element';\nexport { type JSONObject } from '@yorkie-js-sdk/src/document/json/object';\nexport { type JSONArray } from '@yorkie-js-sdk/src/document/json/array';\nexport { Counter } from '@yorkie-js-sdk/src/document/json/counter';\nexport { type CounterValue } from '@yorkie-js-sdk/src/document/crdt/counter';\nexport {\n Text,\n type TextPosStruct,\n type TextPosStructRange,\n} from '@yorkie-js-sdk/src/document/json/text';\nexport {\n Tree,\n type TreeNode,\n type ElementNode,\n type TextNode,\n type TreeChange,\n type TreeChangeType,\n type CRDTTreeNodeIDStruct,\n type TreePosStructRange,\n} from '@yorkie-js-sdk/src/document/json/tree';\nexport { Change } from '@yorkie-js-sdk/src/document/change/change';\nexport { converter } from '@yorkie-js-sdk/src/api/converter';\n\nimport { LogLevel, setLogLevel } from '@yorkie-js-sdk/src/util/logger';\nexport { LogLevel, setLogLevel } from '@yorkie-js-sdk/src/util/logger';\n\nexport {\n EventSourceDevPanel,\n EventSourceSDK,\n type PanelToSDKMessage,\n type SDKToPanelMessage,\n type FullPanelToSDKMessage,\n type FullSDKToPanelMessage,\n} from '@yorkie-js-sdk/src/devtools/protocol';\nexport { Devtools };\n\n/**\n * The top-level yorkie namespace with additional properties.\n *\n * In production, this will be called exactly once and the result\n * assigned to the `yorkie` global.\n *\n * e.g) `new yorkie.Client(...);`\n *\n * @public\n */\nexport default {\n Client,\n Document,\n Primitive,\n Text,\n Counter,\n Tree,\n LogLevel,\n setLogLevel,\n IntType: CounterType.IntegerCnt,\n LongType: CounterType.LongCnt,\n};\n\n// TODO(hackerwins): Remove this when we have a better way to expose the API.\nif (typeof globalThis !== 'undefined') {\n (globalThis as any).yorkie = {\n Client,\n Document,\n Primitive,\n Text,\n Counter,\n Tree,\n LogLevel,\n setLogLevel,\n IntType: CounterType.IntegerCnt,\n LongType: CounterType.LongCnt,\n };\n}\n"],"names":["Code","name","_a","TWO_PWR_32_DBL","ScalarType","LongType","WireType","makeReadOptions","makeWriteOptions","readField","writeField","readScalar","writeScalar","val","a","_b","_c","_d","_e","_f","MethodKind","MethodIdempotency","__asyncValues","v","__await","__asyncGenerator","__asyncDelegator","_g","_h","fetch","message","header","input","ValueType","DocEventType","Presence","Checkpoint","Change","TimeTicket","VersionVector","ChangeID","Operation","RHTNode","PresenceChange_ChangeType","ChangePack","PresenceChangeType","compare","OpSource","negate","toUnsigned","PrimitiveType","node","maxCreatedAt","TokenType","leftChildNode","offset","start","end","CounterType","PbPresence","PbPresenceChange","PbPresenceChange_ChangeType","PbCheckpoint","PbChangeID","PbTimeTicket","PbVersionVector","PbValueType","PbJSONElementSimple","PbTextNodeID","PbTextNodePos","PbTreePos","PbTreeNodeID","PbOperation","PbOperation_Set","PbOperation_Add","PbOperation_Move","PbOperation_Remove","PbOperation_Edit","PbOperation_Style","PbOperation_Increase","PbOperation_TreeEdit","PbOperation_TreeStyle","PbChange","PbRHTNode","PbRGANode","PbTextNode","PbNodeAttr","PbTreeNodes","PbTreeNode","PbJSONElement","PbJSONElement_JSONObject","PbJSONElement_JSONArray","PbJSONElement_Primitive","PbJSONElement_Text","PbJSONElement_Counter","PbJSONElement_Tree","PbChangePack","PbSnapshot","LogLevel","createdAt","parent","types","DocStatus","StreamConnectionStatus","DocSyncStatus","callback","PbDocEventType","token","SyncMode","ClientStatus","ClientCondition","options","retryCount","ConnectErrorCode"],"mappings":";;;AAAA;AAsBO,IAAIA;AAAAA,CACV,SAAUA,OAAM;AAIb,EAAAA,MAAKA,MAAK,UAAU,IAAI,CAAC,IAAI;AAI7B,EAAAA,MAAKA,MAAK,SAAS,IAAI,CAAC,IAAI;AAI5B,EAAAA,MAAKA,MAAK,iBAAiB,IAAI,CAAC,IAAI;AAIpC,EAAAA,MAAKA,MAAK,kBAAkB,IAAI,CAAC,IAAI;AAIrC,EAAAA,MAAKA,MAAK,UAAU,IAAI,CAAC,IAAI;AAI7B,EAAAA,MAAKA,MAAK,eAAe,IAAI,CAAC,IAAI;AAIlC,EAAAA,MA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